source: tol/tolbase/lib/toltk/bysgropt.tcl @ e933fd6

1941-docker-image-to-testdevel
Last change on this file since e933fd6 was e933fd6, checked in by Pedro Gea <pgea@…>, 10 years ago

Refs #1933
Se sustituyen los ::blt::tabset por NoteBook de BWidget. En total se sustituyeron 19 tabsets.
Se suspenden un par de widgets que parece que no se usan, y por tanto tampoco se les ha sustituido ::blt::tabset: bsersel, btab. bchilddetail tampoco parece usarse.
Se corrige un problem en InsertItem de tolinspe.

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@7337 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 142.2 KB
RevLine 
[6d7779d]1#/////////////////////////////////////////////////////////////////////////////
2# FILE    : bysgropt.tcl
3# PURPOSE : This file is continuation of bysgraph.tcl. It contains procedures
4#           relative to graph options.
5#/////////////////////////////////////////////////////////////////////////////
6
7package require blistbox
8package require bcomboboxplus
9package require blistorder
10package require bcolor
11package require bfont
12
13
14#/////////////////////////////////////////////////////////////////////////////
[c61d3f9]15proc ::bayesGraph::ReadIni {this {holdon 0}} {
[6d7779d]16# PURPOSE: Reads general graph options from .ini file. The ini file is the
17#          active graphic configuration file.
18#
19# PARAMETERS:
20#   this  -> Instance of BayesGraph
21#
22#/////////////////////////////////////////////////////////////////////////////
23  upvar \#0 ${this}::data data
24  upvar \#0 ${this}::widgets widgets
25  upvar \#0 ${this}::options opt
26
27  variable optLinesAll
28 
29  #set rini ::iniFile::Read
[c61d3f9]30  if {!$holdon} {
31    set rini ::iniFile::ReadGCF
32    set key $data(namespace)
[6d7779d]33
[c61d3f9]34    set opt(PhotoLastDir)    [$rini $key PhotoLastDir {}]
35    set opt(grid) [$rini $key grid 1]
36  }
[6d7779d]37  for  {set gr 0} {$gr<$data(gr,numGraph)} {incr gr} {
38    set g $widgets(gr,$gr)
39
[c61d3f9]40    if {!$holdon} {
41      set opt(gr,$gr,yFormatNumber)   [$rini $key yFormatNumber  ""]
42      set opt(gr,$gr,y2FormatNumber)  [$rini $key y2FormatNumber ""]
43      set opt(gr,$gr,yFormatPercent)  [$rini $key yFormatPercent  0]
44      set opt(gr,$gr,y2FormatPercent) [$rini $key y2FormatPercent 0]
45      set opt(gr,$gr,xFormatNumber)   [$rini $key xFormatNumber  ""]
46      set opt(gr,$gr,x2FormatNumber)  [$rini $key x2FormatNumber ""]
47      set opt(gr,$gr,xFormatPercent)  [$rini $key xFormatPercent  0]
48      set opt(gr,$gr,x2FormatPercent) [$rini $key x2FormatPercent 0]
49     
50      set opt(gr,$gr,yAxisAll)      [$rini $key yAxisAll  1]
51      set opt(gr,$gr,xAxisAll)      [$rini $key xAxisAll  1]
52      set opt(gr,$gr,x2AxisAll)     [$rini $key x2AxisAll 1]
53      set opt(gr,$gr,y2AxisAll)     [$rini $key y2AxisAll 1]
54     
55      set opt(gr,$gr,xTicksWidth)   [$rini $key xTicksWidth 1]
56      set opt(gr,$gr,yTicksWidth)   [$rini $key yTicksWidth 1]
57      set opt(gr,$gr,xTicksShow)    [$rini $key xTicksShow  1]
58      set opt(gr,$gr,yTicksShow)    [$rini $key yTicksShow  1]
59      set opt(gr,$gr,xTicksType)    [$rini $key xTicksType  auto]
60      set opt(gr,$gr,yTicksType)    [$rini $key yTicksType  total]
61      set opt(gr,$gr,x2TicksType)   [$rini $key x2TicksType auto]
62      set opt(gr,$gr,y2TicksType)   [$rini $key y2TicksType total]
63     
64      set opt(gr,$gr,xTicksTotal)   [$rini $key xTicksTotal 10]
65      set opt(gr,$gr,yTicksTotal)   [$rini $key yTicksTotal 10]
66      set opt(gr,$gr,x2TicksTotal)  [$rini $key x2TicksTotal 10]
67      set opt(gr,$gr,y2TicksTotal)  [$rini $key y2TicksTotal 10]
68     
69      set opt(gr,$gr,xTicksStep)    [$rini $key xTicksStep  0]
70      set opt(gr,$gr,yTicksStep)    [$rini $key yTicksStep  0]
[8960892]71      set opt(gr,$gr,xTicksFont)    [$rini $key xTicksFont   {{Lucida Console} 9}]
72      set opt(gr,$gr,yTicksFont)    [$rini $key yTicksFont   {{Lucida Console} 9}]
[c61d3f9]73      set opt(gr,$gr,xTicksRotate)  [$rini $key xTicksRotate 90]
74      set opt(gr,$gr,yTicksRotate)  [$rini $key yTicksRotate [$g axis cget y -rotate]]
75      set opt(gr,$gr,xTicksColor)   [$rini $key xTicksColor  [$g axis cget x -color]]
76      set opt(gr,$gr,yTicksColor)   [$rini $key yTicksColor  [$g axis cget y -color]]
77      set opt(gr,$gr,xTicksShadow)  [$rini $key xTicksShadow [lindex [$g axis cget x -tickshadow] 0]]
78      set opt(gr,$gr,yTicksShadow)  [$rini $key yTicksShadow [lindex [$g axis cget y -tickshadow] 0]]
79      set opt(gr,$gr,xTicksLength)  [$rini $key xTicksLength 4]
80      set opt(gr,$gr,yTicksLength)  [$rini $key yTicksLength 4]
81      set opt(gr,$gr,xTicksSubdivisions) [$rini $key xTicksSubdivisions 1]
82      set opt(gr,$gr,yTicksSubdivisions) [$rini $key yTicksSubdivisions 1]
83     
84      set opt(gr,$gr,xAxisShow)     [$rini $key xAxisShow  1]
85      set opt(gr,$gr,yAxisShow)     [$rini $key yAxisShow  1]
86      set opt(gr,$gr,x2AxisShow)    [$rini $key x2AxisShow 0]
87      set opt(gr,$gr,y2AxisShow)    [$rini $key y2AxisShow 0]
88     
89      set opt(gr,$gr,xAxisMin)      [$rini $key xAxisMin   0]
90      set opt(gr,$gr,x2AxisMin)     [$rini $key x2AxisMin  0]
91      set opt(gr,$gr,yAxisMin)      [$rini $key yAxisMin   0]
92      set opt(gr,$gr,y2AxisMin)     [$rini $key y2AxisMin  0]
93     
94      set opt(gr,$gr,xAxisMax)      [$rini $key xAxisMax   100]
95      set opt(gr,$gr,yAxisMax)      [$rini $key yAxisMax   100]
96      set opt(gr,$gr,x2AxisMax)     [$rini $key x2AxisMax  100]
97      set opt(gr,$gr,y2AxisMax)     [$rini $key y2AxisMax  100]
98     
99      set opt(gr,$gr,x2TicksWidth)  [$rini $key x2TicksWidth 1]
100      set opt(gr,$gr,y2TicksWidth)  [$rini $key y2TicksWidth 1]
101      set opt(gr,$gr,x2TicksShow)   [$rini $key x2TicksShow 1]
102      set opt(gr,$gr,y2TicksShow)   [$rini $key y2TicksShow 1]
103      set opt(gr,$gr,x2TicksStep)   [$rini $key x2TicksStep  10]
104      set opt(gr,$gr,y2TicksStep)   [$rini $key y2TicksStep  10]
[8960892]105      set opt(gr,$gr,x2TicksFont)   [$rini $key x2TicksFont   {{Lucida Console} 9}]
106      set opt(gr,$gr,y2TicksFont)   [$rini $key y2TicksFont   {{Lucida Console} 9}]
[c61d3f9]107      set opt(gr,$gr,x2TicksRotate) [$rini $key x2TicksRotate [$g axis cget x2 -rotate]]
108      set opt(gr,$gr,y2TicksRotate) [$rini $key y2TicksRotate [$g axis cget y2 -rotate]]
109      set opt(gr,$gr,x2TicksColor)  [$rini $key x2TicksColor  [$g axis cget x2 -color]]
110      set opt(gr,$gr,y2TicksColor)  [$rini $key y2TicksColor  [$g axis cget y2 -color]]
111      set opt(gr,$gr,x2TicksShadow) [$rini $key x2TicksShadow [lindex [$g axis cget x2 -tickshadow] 0]]
112      set opt(gr,$gr,y2TicksShadow) [$rini $key y2TicksShadow [lindex [$g axis cget y2 -tickshadow] 0]]
113      set opt(gr,$gr,x2TicksLength) [$rini $key x2TicksLength 4]
114      set opt(gr,$gr,y2TicksLength) [$rini $key y2TicksLength 4]
115      set opt(gr,$gr,x2TicksSubdivisions) [$rini $key x2TicksSubdivisions 1]
116      set opt(gr,$gr,y2TicksSubdivisions) [$rini $key y2TicksSubdivisions 1]
117     
118      set opt(gr,$gr,xAxisTitle)   [$rini $key xAxisTitle        ""]
119      set opt(gr,$gr,xAxisColor)   [$rini $key xAxisTitleColor   [$g axis cget x -titlecolor]]
120      set opt(gr,$gr,xAxisFont)    [$rini $key xAxisTitleFont    [$g axis cget x -titlefont]]
121      set opt(gr,$gr,xAxisShadow)  [$rini $key xAxisTitleShadow  [lindex [$g axis cget x -titleshadow] 0]]
122      set opt(gr,$gr,yAxisTitle)   [$rini $key yAxisTitle        ""]
123      set opt(gr,$gr,yAxisColor)   [$rini $key yAxisTitleColor   [$g axis cget y -titlecolor]]
124      set opt(gr,$gr,yAxisFont)    [$rini $key yAxisTitleFont    [$g axis cget y -titlefont]]
125      set opt(gr,$gr,yAxisShadow)  [$rini $key yAxisTitleShadow  [lindex [$g axis cget y -titleshadow] 0]]
126      set opt(gr,$gr,x2AxisTitle)  [$rini $key x2AxisTitle       ""]
127      set opt(gr,$gr,x2AxisColor)  [$rini $key x2AxisTitleColor  [$g axis cget x2 -titlecolor]]
128      set opt(gr,$gr,x2AxisFont)   [$rini $key x2AxisTitleFont   [$g axis cget x2 -titlefont]]
129      set opt(gr,$gr,x2AxisShadow) [$rini $key x2AxisTitleShadow [lindex [$g axis cget x2 -titleshadow] 0]]
130      set opt(gr,$gr,y2AxisTitle)  [$rini $key y2AxisTitle       ""]
131      set opt(gr,$gr,y2AxisColor)  [$rini $key y2AxisTitleColor  [$g axis cget y2 -titlecolor]]
132      set opt(gr,$gr,y2AxisFont)   [$rini $key y2AxisTitleFont   [$g axis cget y2 -titlefont]]
133      set opt(gr,$gr,y2AxisShadow) [$rini $key y2AxisTitleShadow [lindex [$g axis cget y2 -titleshadow] 0]]
134     
135      set opt(gr,$gr,font)         [$rini $key font [$g cget -font]]
136      set opt(gr,$gr,foreground)   [$rini $key foreground [$g cget -foreground]]
137      set opt(gr,$gr,shadow)       [$rini $key shadow [lindex [$g cget -shadow] 0]]
138     
139      # options line
140      set opt(gr,$gr,barmode)       [$rini $key barmode aligned]   
141     
142      set opt(gr,$gr,linehides)     [$rini $key linehides false]
143      set opt(gr,$gr,linetypes)     [$rini $key linetypes LineElement]   
144      set opt(gr,$gr,barwidth)      [$rini $key barwidth 0.6]
[8960892]145      set opt(gr,$gr,linewidth)     [$rini $key linewidth 3]
[c61d3f9]146      set opt(gr,$gr,dashes)        [$rini $key dashes {}]
147      set opt(gr,$gr,smooth)        [$rini $key smooth linear]
148      set opt(gr,$gr,barrelief)     [$rini $key barrelief raised]   
149      set opt(gr,$gr,borderwidth)   [$rini $key borderwidth 0]
150      set opt(gr,$gr,colors)        [$rini $key colors {#00c600 blue red yellow orange #d14949 grey purple pink navyblue #356a6a #804000 #05eefa #009148 #ffffbb #29fb04}]
151     
152      set opt(gr,$gr,xyMappedAxis)     [$rini $key xyMappedAxis {{x y}}]
153      set opt(gr,$gr,areaTypes)        [$rini $key areaTypes none]
154      set opt(gr,$gr,areaTypesBar)     [$rini $key areaTypesBar none]   
155      set opt(gr,$gr,areaTiles)        [$rini $key areaTiles {}]
156      set opt(gr,$gr,areaForegrounds)  [$rini $key areaForegrounds defcolor]
157      set opt(gr,$gr,areaBackgrounds)  [$rini $key areaBackgrounds white]
158      set opt(gr,$gr,stippleimages)    [$rini $key stippleimages {}]
159      set opt(gr,$gr,stippledegradeds) [$rini $key stippledegradeds 50]
160     
161      set opt(gr,$gr,showvalues)      [$rini $key showvalues   none]
162      set opt(gr,$gr,valuefont)       [$rini $key valuefont   {Arial 8}]
163      set opt(gr,$gr,valuerotate)     [$rini $key valuerotate 0]
164      set opt(gr,$gr,valuecolor)      [$rini $key valuecolor  black]
165      set opt(gr,$gr,valueformatdec)  [$rini $key valueformatdec 2]
166      set opt(gr,$gr,valueshadow)     [$rini $key valueshadow    {}]
167      set opt(gr,$gr,valueanchor)     [$rini $key valueanchor  center]
168      set opt(gr,$gr,showsymbols)     [$rini $key showsymbols  0]
169      set opt(gr,$gr,symbol)          [$rini $key symbol  triangle]
170      set opt(gr,$gr,pixels)          [$rini $key pixels 4]
171      set opt(gr,$gr,scalesymbols)    [$rini $key scalesymbols false]
172      set opt(gr,$gr,fill)            [$rini $key fill  defcolor]
173      set opt(gr,$gr,outline)         [$rini $key outline   defcolor]
174      set opt(gr,$gr,outlinewidth)    [$rini $key outlinewidth 1]
175     
176      set opt(gr,$gr,selffit)         [$rini $key selffit 0]
177     
178      set opt(gr,$gr,xMarkers)        [$rini $key xMarkers {}]
179      set opt(gr,$gr,yMarkers)        [$rini $key yMarkers {}]
180      set opt(gr,$gr,xMarkersIn)      [$rini $key xMarkersIn {}]
181      set opt(gr,$gr,yMarkersIn)      [$rini $key yMarkersIn {}]
182     
183      set opt(gr,$gr,x2Markers)       [$rini $key x2Markers {}]
184      set opt(gr,$gr,y2Markers)       [$rini $key y2Markers {}]
185      set opt(gr,$gr,x2MarkersIn)     [$rini $key x2MarkersIn {}]
186      set opt(gr,$gr,y2MarkersIn)     [$rini $key y2MarkersIn {}]
187     
188      set opt(gr,$gr,xMarkersColorsInEach)   [$rini $key xMarkersColorsInEach  \
189                                                  {#356a6a #804000 #05eefa #009148 #ffffbb}]
190      set opt(gr,$gr,x2MarkersColorsInEach)  [$rini $key x2MarkersColorsInEach \
191                                                  {#356a6a #804000 #05eefa #009148 #ffffbb}]
192      set opt(gr,$gr,yMarkersColorsInEach)   [$rini $key yMarkersColorsInEach  \
193                                                  {#356a6a #804000 #05eefa #009148 #ffffbb}]
194      set opt(gr,$gr,y2MarkersColorsInEach)  [$rini $key y2MarkersColorsInEach \
195                                                  {#356a6a #804000 #05eefa #009148 #ffffbb}]
196
197      set opt(gr,$gr,xMarkersDashesInEach)  [$rini $key xMarkersDashesInEach  \
198                                                 {{1 1} {2 2} {3 3} {4 4} {5 5}}]
199      set opt(gr,$gr,x2MarkersDashesInEach) [$rini $key x2MarkersDashesInEach \
200                                                 {{1 1} {2 2} {3 3} {4 4} {5 5}}]
201      set opt(gr,$gr,yMarkersDashesInEach)  [$rini $key yMarkersDashesInEach  \
202                                                 {{1 1} {2 2} {3 3} {4 4} {5 5}}]
203      set opt(gr,$gr,y2MarkersDashesInEach) [$rini $key y2MarkersDashesInEach \
204                                                 {{1 1} {2 2} {3 3} {4 4} {5 5}}]
205     
206      set opt(gr,$gr,xMarkersWidthsInEach)   [$rini $key xMarkersWidthsInEach  \
207                                                  {1 1 1 1 1}]
208      set opt(gr,$gr,x2MarkersWidthsInEach)  [$rini $key x2MarkersWidthsInEach \
209                                                  {1 1 1 1 1}]
210      set opt(gr,$gr,yMarkersWidthsInEach)   [$rini $key yMarkersWidthsInEach  \
211                                                  {1 1 1 1 1}]
212      set opt(gr,$gr,y2MarkersWidthsInEach)  [$rini $key y2MarkersWidthsInEach \
213                                                  {1 1 1 1 1}]
214     
215      set opt(gr,$gr,xMarkersUndersInEach)   [$rini $key xMarkersUndersInEach  \
216                                                  {0 0 0 0 0}]
217      set opt(gr,$gr,x2MarkersUndersInEach)  [$rini $key x2MarkersUndersInEach \
218                                                  {0 0 0 0 0}]
219      set opt(gr,$gr,yMarkersUndersInEach)   [$rini $key yMarkersUndersInEach  \
220                                                  {0 0 0 0 0}]
221      set opt(gr,$gr,y2MarkersUndersInEach)  [$rini $key y2MarkersUndersInEach \
222                                                  {0 0 0 0 0}]
223     
224      set opt(gr,$gr,legend,Hide)     [$rini $key legendHide      [$g legend cget -hide]]
225      set opt(gr,$gr,legend,Bg)       [$rini $key legendBg        ""]
226      set opt(gr,$gr,legend,Bd)       [$rini $key legendBd        [$g legend cget -bd]]
227      set opt(gr,$gr,legend,Fg)       [$rini $key legendFg        [$g legend cget -fg]]
[8960892]228      set opt(gr,$gr,legend,Font)     [$rini $key legendFont      {{Lucida Console} 9}]
[c61d3f9]229      set opt(gr,$gr,legend,Shadow)   [$rini $key legendShadow    [$g legend cget -shadow]]
230      set opt(gr,$gr,legend,Position) [$rini $key legendPosition  "bottom"]
231      set opt(gr,$gr,legend,Anchor)   [$rini $key legendAnchor    [$g legend cget -anchor]]
232      set opt(gr,$gr,legend,Relief)   [$rini $key legendRelief    [$g legend cget -relief]]
233      set opt(gr,$gr,legend,Raised)   [$rini $key legendRaised    [$g legend cget -raised]]
234      set opt(gr,$gr,legend,IPadXl)   [$rini $key legendIPadXl    [lindex [$g legend cget -ipadx] 0]]
235      set opt(gr,$gr,legend,IPadXr)   [$rini $key legendIPadXr    [lindex [$g legend cget -ipadx] 1]]
236      set opt(gr,$gr,legend,IPadYt)   [$rini $key legendIPadYt    [lindex [$g legend cget -ipady] 0]]
237      set opt(gr,$gr,legend,IPadYb)   [$rini $key legendIPadYb    [lindex [$g legend cget -ipady] 1]]
238      set opt(gr,$gr,legend,PadXl)    [$rini $key legendPadXl     [lindex [$g legend cget -padx] 0]]
239      set opt(gr,$gr,legend,PadXr)    [$rini $key legendPadXr     [lindex [$g legend cget -padx] 1]]
240      set opt(gr,$gr,legend,PadYt)    [$rini $key legendPadYt     [lindex [$g legend cget -pady] 0]]
241      set opt(gr,$gr,legend,PadYb)    [$rini $key legendPadYb     [lindex [$g legend cget -pady] 1]]
242      set opt(gr,$gr,legend,Rows)     [$rini $key legendRows      [$g legend cget -rows]]
243      set opt(gr,$gr,legend,Columns)  [$rini $key legendColumns   [$g legend cget -columns]]
244     
245      set opt(gr,$gr,grid,Color)     [$rini $key gridColor     "#e8e8e8"]
246      set opt(gr,$gr,grid,Dashes)    [$rini $key gridDashes    {3 1}]
247      set opt(gr,$gr,grid,LineWidth) [$rini $key gridLineWidth [$g grid cget -linewidth]]
248      set opt(gr,$gr,grid,Minor)     [$rini $key gridMinor     0]
249      set opt(gr,$gr,grid,MapX)      [$rini $key gridMapX      x]
250      set opt(gr,$gr,grid,MapY)      [$rini $key gridMapY      y]
251     
252      set opt(gr,$gr,background)      [$rini $key background  #ffffff]
253      set opt(gr,$gr,relief)          [$rini $key relief      flat]
254      set opt(gr,$gr,areaborderwidth) [$rini $key areaborderwidth 0]
255     
256      set opt(gr,$gr,lm)             [$rini $key lm          [$g cget -lm]]
257      set opt(gr,$gr,rm)             [$rini $key rm          [$g cget -rm]]
258      set opt(gr,$gr,tm)             [$rini $key tm          [$g cget -tm]]
259      set opt(gr,$gr,bm)             [$rini $key bm          [$g cget -bm]]
260      set opt(gr,$gr,plotbackground)  [$rini $key plotbackground  white]
261      set opt(gr,$gr,plotrelief)      [$rini $key plotrelief      flat]
262      set opt(gr,$gr,plotborderwidth) [$rini $key plotborderwidth 0]
263      set opt(gr,$gr,plotpadxl)  [$rini $key plotpadxl 0]
264      set opt(gr,$gr,plotpadxr)  [$rini $key plotpadxr 0]
265      set opt(gr,$gr,plotpadyt)  [$rini $key plotpadyt 0]
266      set opt(gr,$gr,plotpadyb)  [$rini $key plotpadyb 0]
267      set opt(gr,$gr,invertxy)   [$rini $key invertxy 0]
268    }
[6d7779d]269    # Para el orden de las series, opt puede cambiar, pero no cambiamos data
270    # lstnames {id name caption label}
271    set opt(gr,$gr,lstnames) {}
272    set i 1
273    foreach it $data(gr,$gr,elements) {
274      lappend opt(gr,$gr,lstnames) [list $i \
275        $it \
276        [$g element cget [lindex $it 0] -label] \
277        [$g element cget [lindex $it 0] -label]]
278      incr i
279    }   
280
281    #Completamos valores de arrays
282    GrapOptGetMarkers $this
283   
284    # Completamos los arrays de opciones de lineas
285    foreach it $optLinesAll {
286      set len [llength $opt(gr,$gr,$it)]
287      for {set i $len} {[expr $i < [llength [$g element names]]]} {incr i} {
288        lappend opt(gr,$gr,$it) [lindex $opt(gr,$gr,$it) 0]
289      }
290    }
291  }
292}
293
294#/////////////////////////////////////////////////////////////////////////////
295  proc ::bayesGraph::WriteIni {this { gcf 0 } } {
296#
297# PURPOSE: Reads general graph options from .ini file. The ini file is the
298#          active graphic configuration file.
299#
300# PARAMETERS:
301#   this  -> Instance of BayesGraph
302#   gcf   -> 1. Indicate save in GCF file. O. Save in ini file
303#
304#/////////////////////////////////////////////////////////////////////////////
305  upvar \#0 ${this}::data data
306  upvar \#0 ${this}::options opt
307  variable optLinesAll
308 
309  set gr $data(gr,active)
310 
311  # exists gcf     
312  if {$gcf} {
313    set wini ::iniFile::WriteGCF   
314  } else {
315    set wini ::iniFile::Write
316  } 
317
318  set key $data(namespace)
319 
320  $wini $key PhotoLastDir $opt(PhotoLastDir)
321  #Coger el estado del grid
322  $wini $key grid $opt(grid)
323 
324  # opciones de Max y Min de ejes
325  foreach pre {x y x2 y2} {
326    foreach post {Show Min Max All} {
327      $wini $key ${pre}Axis${post} $opt(gr,$gr,${pre}Axis${post})
328    }
329  }
330  # opciones de formato de ejes
331  foreach pre {y y2 x x2} {
332    foreach post {Number Percent} {
333      $wini $key ${pre}Format${post} $opt(gr,$gr,${pre}Format${post})
334    }
335  }
336  #Opciones de ticks (tipo, cuantos, cada cuantos y estilo) de ejes
337  foreach pre {x y x2 y2} {
338    foreach post {Type Total Step Font Rotate Color Shadow Length Subdivisions Width Show} {
339      $wini $key ${pre}Ticks${post} $opt(gr,$gr,${pre}Ticks${post})
340    }
341  }
342  #Opciones del título del gráfico
343  foreach it {font foreground shadow} {
344    $wini $key $it $opt(gr,$gr,$it)
345  }
346  # Titulos y opciones de títulos de título de ejes
347  foreach pre {x y x2 y2} {
348    $wini $key ${pre}AxisTitle $opt(gr,$gr,${pre}AxisTitle)
349    foreach post {Color Font Shadow} {
350      $wini $key ${pre}AxisTitle${post} $opt(gr,$gr,${pre}Axis${post})
351    }
352  }
353
354  #Opciones de auto-ajuste
355  foreach it {selffit} {
356    $wini $key $it $opt(gr,$gr,$it)
357  }
358  #Opciones de Marcadores
359  foreach it {x x2 y y2} {
360    foreach at {"" In} {
361      $wini $key ${it}Markers${at} $opt(gr,$gr,${it}Markers${at})
362    }
363  }
364  foreach it {x x2 y y2} {
365    foreach ty {Colors Dashes Widths Unders} {
366      $wini $key ${it}Markers${ty}InEach $opt(gr,$gr,${it}Markers${ty}InEach)
367    }
368  }
369 
370  #Opciones de estilo de los elementos
371  foreach it $optLinesAll {
372    $wini $key $it $opt(gr,$gr,$it)
373  }
374
375  #Opciones del grid
376  foreach it {Color Dashes LineWidth Minor MapX MapY} {
377    $wini $key grid$it $opt(gr,$gr,grid,$it)
378  }
379  #Opciones de la leyenda
380  foreach it {Hide Rows Columns Font Fg Shadow Bg Bd Relief Position Anchor Raised} {
381    $wini $key legend$it $opt(gr,$gr,legend,$it)
382  }
383  foreach it {IPadXl IPadXr IPadYt IPadYb PadXl PadXr PadYt PadYb} {
384    $wini $key legend$it $opt(gr,$gr,legend,$it)
385  }
386  #Opciones del gráfico
387  foreach it {background relief areaborderwidth lm rm tm bm invertxy} {
388    $wini $key $it $opt(gr,$gr,$it)
389  }
390  foreach it {plotbackground plotrelief plotborderwidth plotpadxl plotpadxr plotpadyt plotpadyb} {
391    $wini $key $it $opt(gr,$gr,$it)
392  }
393 
394  # OnWriteInit 
395  if [info exists ${this}::data(proc,OnWriteIni)] {
396    $data(proc,OnWriteIni) $this
397  }
398 
399  if {$gcf} {
400    ::bayesGraph::SaveGCF $this
401    ::iniFile::FlushGCF $key
402  }
403}
404
405
406#/////////////////////////////////////////////////////////////////////////////
407proc ::bayesGraph::CalculateXAxisNumTicks {this axis} {
408# 
409#/////////////////////////////////////////////////////////////////////////////   
410  upvar \#0 ${this}::data data
411  set gr $data(gr,active)
412  set g [getActiveGraph $this]
413
414  set font [$g axis cget $axis -tickfont]
415  if {[$g axis cget $axis -rotate] > 15} {
416    array set fontMetrics [font metrics $font]
417    set widthTick [expr $fontMetrics(-ascent) + $fontMetrics(-descent)]
418  } else  {
419    set lst [$data(gr,$gr,OnGetXTicks) $this]
420    set widthTick [expr [font measure $font [lindex $lst end]] + 4]
421  }
422  set limits    [$g axis limits $axis]
423  set pixelIni  [$g axis transform $axis [lindex $limits 0]]
424  set pixelFin  [$g axis transform $axis [lindex $limits 1]]
425 
426  set widthAxis [expr $pixelFin - $pixelIni]
427  set nTicks    [expr $widthTick ? ($widthAxis / $widthTick) : 0]
428  return $nTicks
429}
430
431
432#/////////////////////////////////////////////////////////////////////////////   
433proc ::bayesGraph::CalculateYAxisNumTicks {this axis} {
434# 
435#/////////////////////////////////////////////////////////////////////////////     
436  set g [getActiveGraph $this]
437  set font [$g axis cget $axis -tickfont]
438  array set fontMetrics [font metrics $font]
439  #si se ha rotado (hacer si se permite rotar)
440  set heightTick [expr $fontMetrics(-ascent) + $fontMetrics(-descent)]
441  set limits    [$g axis limits $axis]
442  set pixelIni  [$g axis transform $axis [lindex $limits 0]]
443  set pixelFin  [$g axis transform $axis [lindex $limits 1]]
444
445  set heightAxis [expr $pixelIni - $pixelFin]
446  set nTicks    [expr $heightTick ? ($heightAxis / $heightTick) : 0]
447  return $nTicks
448}
449
450
451#/////////////////////////////////////////////////////////////////////////////   
452proc ::bayesGraph::FixXAxisStep {this step axis} {
453# 
454#/////////////////////////////////////////////////////////////////////////////     
455  upvar \#0 ${this}::data data
456  set g [getActiveGraph $this]
457  set min [$g axis cget $axis -min]
458  set max [$g axis cget $axis -max]
459  if {[info exist data(proc,OnFixStepX)]} {
460    set step [$data(proc,OnFixStepX) $this $min $max $step]
461  }
462  return $step
463}
464
465
466#/////////////////////////////////////////////////////////////////////////////   
467proc ::bayesGraph::FixYAxisStep {this step} {
468# 
469#/////////////////////////////////////////////////////////////////////////////     
470  if {$step <= 0} {
471    return 0
472  }
473  if {$step < 1} {
474    set nDig [expr $step ? (int(floor(log10(1/$step)))) : 0]
475    set num [expr $nDig + 2]
476    set step [format "%.${num}f" $step]
477  } else {
478    set nDig [expr $step ? (int(floor(log10($step)))) : 0]
479    if {$nDig >= 1} {
480      set num [expr $nDig - 1]
481      if {![catch {expr int(pow(10,$num)) ? floor($step/int(pow(10,$num)))*pow(10,$num) : 0} res]} {
482        set step $res
483      } else {
484        set step 0
485      }
486      #set step [expr int(pow(10,$num)) ? floor($step/int(pow(10,$num)))*pow(10,$num) : 0]
487    } else  {
488      set num [expr $nDig]
489      set step [format "%.1f" $step]
490    }
491  }
492  return $step
493}
494
495#/////////////////////////////////////////////////////////////////////////////
496  proc ::bayesGraph::ComputeXAxisStep {this nTicks axis} {
497#
498# PURPOSE:
499#
500# PARAMETERS:
501#   this   -> Instance of BayesGraph
502#   nTicks ->
503#   axis   ->
504# RETURN
505#
506#/////////////////////////////////////////////////////////////////////////////
507  upvar \#0 ${this}::data data
508  variable tmpOpt
509  if {$nTicks == 0 } { return 0 }
510
511  set g [getActiveGraph $this]
512  set min [$g axis cget $axis -min]
513  set max [$g axis cget $axis -max]
514  if {![string length $min] && ![string length $max]} {
515    #Le damos el valor minimo y maximo del eje opuesto
516    switch [string length $axis] {
517      2       { set axiOpo [string index $axis 0] }
518      default { set axiOpo ${axis}2 }
519    }
520    set values2 [::bayesGraph::GetLimitsValueAxis $this $axiOpo]
521    set min [lindex $values2 0]
522    set max [lindex $values2 1]
523    set tmpOpt(var,${axis}AxisMin) $min
524    set tmpOpt(var,${axis}AxisMax) $max
525
526    ::bayesGraph::GrapOptApplyAxisLimits $this $axis $min $max
527  } elseif {![string length $min]} {
528    set min [expr $max - 100]
529  } elseif {![string length $max]} {
530    set max [expr $min + 100]
531  }
532  if {[info exist ${this}::data(proc,OnComputeStepX)]} {
533    set step [$data(proc,OnComputeStepX) $this $min $max $nTicks]
534  } else {
535    set dif [expr $max - $min]
536    set step [expr $nTicks ? ($dif/$nTicks) : 0]
537  }
538  return $step
539}
540
541
542#/////////////////////////////////////////////////////////////////////////////   
543proc ::bayesGraph::ComputeYAxisStep {this nTicks axis} {
544# 
545#/////////////////////////////////////////////////////////////////////////////     
546  variable tmpOpt
547  if {$nTicks == 0 } { return 0 }
548  set g [getActiveGraph $this]
549  #Obtenemos valor minimo y maximo de las lineas
550  set min [$g axis cget $axis -min]
551  set max [$g axis cget $axis -max]
552  if {![string length $min] && ![string length $max]} {
553  #Le damos el valor minimo y maximo del eje opuesto
554    switch [string length $axis] {
555      2       { set axiOpo [string index $axis 0] }
556      default { set axiOpo ${axis}2 }
557    }
558    set values2 [::bayesGraph::GetLimitsValueAxis $this $axiOpo]
559    if {[llength $values2]} {
560      set min [lindex $values2 0]
561      set max [lindex $values2 1]
562      set tmpOpt(var,${axis}AxisMin) $min
563      set tmpOpt(var,${axis}AxisMax) $max
564      ::bayesGraph::GrapOptApplyAxisLimits $this $axis $min $max
565    }
566  }
567  # Se comprueba valor de los ejes
568  if {![string length $min] && ![string length $max]} {
569    set min 0
570    set max 100
571  } elseif {![string length $min]} {
572    set min [expr $max - 100]
573  } elseif {![string length $max]} {
574    set max [expr $min + 100]
575  }
576  set dif [expr $max - $min]
577  set step [expr $nTicks ? ($dif/$nTicks) : 0]
578  return [FixYAxisStep $this $step]
579}
580
581
582# Opciones del grafico
583#/////////////////////////////////////////////////////////////////////////////   
584proc ::bayesGraph::LoadGCF {this {fileGCF ""}} {
585# 
586#/////////////////////////////////////////////////////////////////////////////     
587  upvar \#0 ${this}::data data
588  upvar \#0 ${this}::options opt
589  set key $data(namespace)
590
591  if {[string length $fileGCF]} {   
592    set opt(GCFlastDir) [file dirname $fileGCF]
593    set opt(GCFFile)    $fileGCF
594    ::iniFile::SetGCF   $key $opt(GCFFile)
595  } else  { 
596    set opt(GCFFile)    [::iniFile::Read $key GCFFile ""]
597    set opt(GCFlastDir) [::iniFile::Read $key GCFlastDir ""]
598
599    if { ![file exists $opt(GCFFile)] } {
600      if {![string equal $opt(GCFFile) ""]} {
601        tk_messageBox -type ok -icon info \
602          -message [mc "File $opt(GCFFile) doesn't exist"] \
603          -title [mc "Warning"]
604        set opt(GCFFile) ""
605      }   
606      ::iniFile::SetGCF $key ""
607    } else  {   
608      ::iniFile::SetGCF $key $opt(GCFFile)
609    }
610  }
611}
612
613
614#/////////////////////////////////////////////////////////////////////////////   
615proc ::bayesGraph::SaveGCF {this} {
616# 
617#/////////////////////////////////////////////////////////////////////////////     
618  upvar \#0 ${this}::data data
619  upvar \#0 ${this}::options opt
620  set key $data(namespace)
621
622  ::iniFile::Write $key GCFFile $opt(GCFFile)
623  ::iniFile::Write $key GCFlastDir $opt(GCFlastDir)
624  ::iniFile::SaveGCF $key $opt(GCFFile)
625}
626
627
628#/////////////////////////////////////////////////////////////////////////////   
629proc ::bayesGraph::OpenGraphOpt {this} {
630# 
631#/////////////////////////////////////////////////////////////////////////////     
632  upvar \#0 ${this}::data data
633  upvar \#0 ${this}::widgets widgets
634  upvar \#0 ${this}::options opt
635  set key $data(namespace)
636  ::bayesGraph::SaveGCF $this
637  #Escribe en la variable opt(GCFFile)
638  set typelist {{"Graphic Configuration Files" {".gcf"}}}
639  set file [tk_getOpenFile -title [mc "Open"]    -parent $widgets(this) \
640                           -initialdir $opt(GCFlastDir)\
641                           -defaultextension .gcf -filetypes $typelist]
642  #Falta comprobar que el GCF es de mi clave
643  ::iniFile::SetGCF $key $file
644  set opt(GCFFile) $file
645  if ![string equal $file ""] {
646    set opt(GCFlastDir) [file dirname $file]
647  }
648  ::${data(namespace)}::ReadIni   $this
649  ::${data(namespace)}::Configure $this
650}
651
652
653#/////////////////////////////////////////////////////////////////////////////   
654proc ::bayesGraph::SaveGraphOpt {this} {
655# 
656#/////////////////////////////////////////////////////////////////////////////     
657  upvar \#0 ${this}::data data
658  upvar \#0 ${this}::widgets widgets
659  upvar \#0 ${this}::options opt
660  set key $data(namespace)
661  #Escribe en la variable opt(GCFFile)
662  set typelist {{"Graphic Configuration Files" {".gcf"}}}
663  set file [tk_getSaveFile -title [mc "Save as"] -parent $widgets(this) \
664                           -initialdir $opt(GCFlastDir)\
665                           -defaultextension .gcf -filetypes $typelist]
666  set opt(GCFFile) $file
667  set opt(GCFlastDir) [file dirname $file]
668  ::bayesGraph::SaveGCF $this
669  WriteIni $this 1
670}
671
672
673#/////////////////////////////////////////////////////////////////////////////   
674proc ::bayesGraph::GrapOpt {this args} {
675#
676# PURPUSE
677# PARAMETERS: this -> Instace
678#             args -> options
679#               -tabshow: tab selected
680#               -nlne: line show
681#/////////////////////////////////////////////////////////////////////////////     
682  global toltk_options
683  upvar \#0 ${this}::widgets widgets
684  upvar \#0 ${this}::data data
685  # options
686  array set opts [list \
687    -tabshow {} \
688    -nline   1 \
689    -iniaxis x
690  ] 
691  array set opts $args 
692 
693  set path $widgets(this)
694  set dialog [Dialog $path.t -title [mc "Graph Options"]\
695              -modal local -parent $path]
696
697  wm protocol $dialog WM_DELETE_WINDOW [list ::bayesGraph::GrapOptDestroy $this $dialog]
698  set w [$dialog getframe]
699  wm resizable $dialog 0 0
[e933fd6]700  #@ Se ubican las pestañas abajo, ya que NoteBook no las admite a la izquierda
701  set w_tabset [NoteBook $w.nb -tabbevelsize 8 -tabpady {2 6} -font {Arial 8} -side bottom]
[6d7779d]702 
[e933fd6]703  #insertar tabset
704  set num_i 0
705  set lab_i General
706  $w_tabset insert $num_i $lab_i -text "  [mc $lab_i]  " -background \#d9d9d9
707  set tab_i [$w_tabset getframe $lab_i]
708  $tab_i configure -borderwidth 2 -background \#d9d9d9 
709  set f$num_i [frame $tab_i.f]
710  pack $tab_i.f -fill both -expand yes   
711
[6d7779d]712  #Crear opciones generales
713  eval GrapOptCreate $this $f0 [array get opts]
714  #Crear opciones especificas
715  if [info exists ${this}::data(proc,OnOptionCreate)] {
716    $data(proc,OnOptionCreate) $this $w_tabset
717  }
[e933fd6]718  $w_tabset raise [$w_tabset pages 0] 
[6d7779d]719   
720  set w_bbox \
721          [ButtonBox $w.bb -orient horizontal -spacing 10 -padx 0 -pady 0 \
722          -homogeneous false]
723  $w_bbox add -text [mc "Accept"] -image [::Bitmap::get accept] \
724      -helptext [mc "OK"] -relief link -compound left -padx 5 -pady 1\
725      -command [list ::bayesGraph::GrapOptOK $this $dialog]
726  $w_bbox add -text [mc "Cancel"] -image [::Bitmap::get cancelx] \
727      -helptext [mc "Cancel"] -relief link -compound left -padx 5 -pady 1\
728      -command [list ::bayesGraph::GrapOptDestroy $this $dialog]
729  $w_bbox add -text [mc "Apply"] -image [::Bitmap::get apply] \
730      -helptext [mc "Apply"] -relief link -compound left -padx 5 -pady 1\
731      -command [list ::bayesGraph::GrapOptApply $this]
732
733  if {$data(gr,numGraph) > 1} {
734    $w_bbox add -text [mc "Apply to all"] -image [::Bitmap::get applyAll] \
735      -helptext [mc "Apply to all"] -relief link -compound left -padx 5 -pady 1\
736      -command [list ::bayesGraph::GrapOptApplyAll $this]
737  }
738 
739  pack $w_bbox -fill x -expand false -side bottom
[e933fd6]740  $w_tabset compute_size
[6d7779d]741  pack $w_tabset -fill both -expand true
742  bind $dialog <F1> "ShowHelp Tb4GraOpc"
743 
744  $dialog draw
745}
746
747
748#/////////////////////////////////////////////////////////////////////////////
749  proc ::bayesGraph::GrapOptDestroy {this dialog} {
750#
751# PURPOSE: Destroy graph options dialog. It also call to procedure that
752#          destroy specific options of a bayesGraph's child.
753#
754# PARAMETERS:
755#   this   -> Instance of bayesGraph
756#   dialog -> Graph options dialog
757#
758#/////////////////////////////////////////////////////////////////////////////
759  upvar \#0 ${this}::data data
760  variable tmpOpt
761 
762  #Destruir opciones especificas
763  unset data(lines,selectant)
764  if [info exists ${this}::data(proc,OnOptionDestroy)] {
765    $data(proc,OnOptionDestroy) $this
766  }
767  array unset tmpOpt
768  destroy $dialog
769}
770
771
772#/////////////////////////////////////////////////////////////////////////////   
773proc ::bayesGraph::GrapOptCreate {this frame args} {
774# 
775#/////////////////////////////////////////////////////////////////////////////
776  upvar \#0 ${this}::widgets widgets
777  # options
778  array set opts [list \
779    -tabshow {} \
780    -nline   1 \
781    -iniaxis x
782  ]
783  array set opts $args
[e933fd6]784   
785  set widgets(general,w_tabset) [NoteBook $frame.nb -tabbevelsize 8 -tabpady {2 6} -font {Arial 8}]
786  set num_i 0
787  foreach lab_i [list Axis Lines Grid Legend Style] {
788    $widgets(general,w_tabset) insert $num_i $lab_i -text "  [mc $lab_i]  " -background \#d9d9d9
789    set tab_i [$widgets(general,w_tabset) getframe $lab_i]
790    $tab_i configure -borderwidth 2 -background \#d9d9d9
791    incr num_i
792    set f$num_i [frame $tab_i.f]
793    pack $tab_i.f -fill both -expand yes
794  }
795  $widgets(general,w_tabset) raise [$widgets(general,w_tabset) pages 0]
[6d7779d]796 
797  GrapOptGet            $this
798  GrapOptCreateAxisXY   $this $f1 $opts(-iniaxis)
799  GrapOptCreateLines    $this $f2 $opts(-nline)
800  GrapOptCreateGrid     $this $f3
801  GrapOptCreateLegend   $this $f4
802  GrapOptCreateStyle    $this $f5
803
804  GrapOptInit  $this
805  GrapOptCheck $this
806  #GrapOptSet   $this
807 
808  # show tabset indicates
809  if {[string length $opts(-tabshow)]} {
[e933fd6]810    $widgets(general,w_tabset) raise $opts(-tabshow)
[6d7779d]811  } 
812
[e933fd6]813  $widgets(general,w_tabset) compute_size
[6d7779d]814  grid $widgets(general,w_tabset) -sticky news 
815  grid rowconfigure    $frame 0 -weight 1
816  grid columnconfigure $frame 0 -weight 1
817}
818
819
820#/////////////////////////////////////////////////////////////////////////////
821proc ::bayesGraph::ShowAxisSelectXY {this} {
822#
823# PURPOSE: Muestra la informacion relativa al axis seleccionado
824#
825# PARAMETERS: this -> instancia del grafico
826#
827#/////////////////////////////////////////////////////////////////////////////
828  # completamos las accines pendientes de visualizacion
829  update idletasks
830
831  global toltk_options
832  upvar \#0 ${this}::data data
833  set gr $data(gr,active)
834  variable tmpOpt
835  # eje acutal
836  set axis $tmpOpt(var,xyAxisSelect)
837
838  # asignacion de valores
839  foreach {a b} [list $tmpOpt(var,xyOldAxis) xy xy $axis] {
840    if {[info exists tmpOpt(var,${b}AxisShow)]} {
841      set tmpOpt(var,${a}AxisShow)     $tmpOpt(var,${b}AxisShow)
842      set tmpOpt(var,${a}AxisMin)      $tmpOpt(var,${b}AxisMin)
843      set tmpOpt(var,${a}AxisMax)      $tmpOpt(var,${b}AxisMax)
844      set tmpOpt(var,${a}AxisAll)      $tmpOpt(var,${b}AxisAll)
845      set tmpOpt(var,${a}TicksType)    $tmpOpt(var,${b}TicksType)
846      set tmpOpt(var,${a}TicksTotal)   $tmpOpt(var,${b}TicksTotal)
847      set tmpOpt(var,${a}TicksStep)    $tmpOpt(var,${b}TicksStep)
848      set tmpOpt(var,${a}TicksFont)    $tmpOpt(var,${b}TicksFont)
849      set tmpOpt(var,${a}TicksRotate)  $tmpOpt(var,${b}TicksRotate)
850      set tmpOpt(var,${a}TicksColor)   $tmpOpt(var,${b}TicksColor)
851      set tmpOpt(var,${a}TicksLength)  $tmpOpt(var,${b}TicksLength)
852      set tmpOpt(var,${a}TicksShadow)  $tmpOpt(var,${b}TicksShadow)
853      set tmpOpt(var,${a}TicksSubdivisions)  $tmpOpt(var,${b}TicksSubdivisions)
854      set tmpOpt(var,${a}TicksShow)    $tmpOpt(var,${b}TicksShow)
855      set tmpOpt(var,${a}TicksWidth)   $tmpOpt(var,${b}TicksWidth)
856     
857      set tmpOpt(var,${a}AxisTitle)   $tmpOpt(var,${b}AxisTitle)
858      set tmpOpt(var,${a}AxisColor)   $tmpOpt(var,${b}AxisColor)
859      set tmpOpt(var,${a}AxisFont)    $tmpOpt(var,${b}AxisFont)
860      set tmpOpt(var,${a}AxisShadow)  $tmpOpt(var,${b}AxisShadow)
861
862      set tmpOpt(var,${a}FormatNumber)  $tmpOpt(var,${b}FormatNumber)
863      set tmpOpt(var,${a}FormatPercent) $tmpOpt(var,${b}FormatPercent)
864
865      set tmpOpt(var,${a}Markers)       $tmpOpt(var,${b}Markers)
866      set tmpOpt(var,${a}MarkersIn)     $tmpOpt(var,${b}MarkersIn)
867
868      foreach j {0 1 2 3 4} {
869        set tmpOpt(var,${a}MarkerColorInEach$j) $tmpOpt(var,${b}MarkerColorInEach$j)
870        set tmpOpt(var,${a}MarkerWidthInEach$j) $tmpOpt(var,${b}MarkerWidthInEach$j)
871        set tmpOpt(var,${a}MarkerDasheInEach$j) $tmpOpt(var,${b}MarkerDasheInEach$j)
872        set tmpOpt(var,${a}MarkerUnderInEach$j) $tmpOpt(var,${b}MarkerUnderInEach$j)
873      }
874    }
875  }
876  # Etiquetas para los ejes
877  set AXI [string toupper [string index $axis 0]]
878  if {[info exists data(gr,$gr,OnGet${AXI}Ticks)]} {
879    if {[string is double $tmpOpt(var,${axis}AxisMin)] && \
880        [string length $tmpOpt(var,${axis}AxisMin)] } {
881      set value [lindex [$data(gr,$gr,OnGet${AXI}Ticks) $this] \
882        [expr int(floor($tmpOpt(var,${axis}AxisMin)))]]
883      if {[string length $value]} {
884        set tmpOpt(var,xyAxisMin) $value
885      }
886    }
887    if {[string is double $tmpOpt(var,${axis}AxisMax)] && \
888        [string length $tmpOpt(var,${axis}AxisMax)]} {
889      set value [lindex [$data(gr,$gr,OnGet${AXI}Ticks) $this] \
890        [expr int(floor($tmpOpt(var,${axis}AxisMax)))]]
891      if {[string length $value]} {
892        set tmpOpt(var,xyAxisMax) $value
893      }
894    }
895  }
896  # activamos opciones dependiendo de la pulsacion
897#  GrapOptCheckXYTicksType $this
898
899  GrapOptCheckXYAxisAll   $this
900  # guardamos valor actual
901  set tmpOpt(var,xyOldAxis) $axis
902}
903
904#/////////////////////////////////////////////////////////////////////////////
905  proc ::bayesGraph::GrapOptCreateAxisXY {this w {iniaxis x}} {
906#
907# PURPOSE: Muestra la informacion relativa al axis seleccionado
908#
909# PARAMETERS: this -> instancia del grafico
910#
911#/////////////////////////////////////////////////////////////////////////////
912  global toltk_options
913  upvar \#0 ${this}::data data
914  variable tmpOpt
915  set gr $data(gr,active)
916  # X-Selector
917  TitleFrame $w.tfxs -text [mc "Axis"] 
918  set fs [$w.tfxs getframe]
919  # inizializamos visulizacion
920  set tmpOpt(var,xyOldAxis)    $iniaxis
921  set tmpOpt(var,xyAxisSelect) $iniaxis
922  ShowAxisSelectXY $this
923
924  set tmpOpt(widget,rbAxisX) [radiobutton $fs.rbAxisX -text "X: [mc Bottom]"\
925     -value x -highlightthickness 0 -pady 0 \
926     -variable ::bayesGraph::tmpOpt(var,xyAxisSelect) \
927     -command [list ::bayesGraph::ShowAxisSelectXY $this]]
928  set tmpOpt(widget,rbAxisX2) [radiobutton $fs.rbAxisX2 -text "X2: [mc Top]"\
929     -value x2 -highlightthickness 0 -pady 0\
930     -variable ::bayesGraph::tmpOpt(var,xyAxisSelect) \
931     -command [list ::bayesGraph::ShowAxisSelectXY $this]]
932  set tmpOpt(widget,rbAxisY) [radiobutton $fs.rbAxisY -text "Y: [mc Left]" \
933     -value y -highlightthickness 0 -pady 0 \
934     -variable ::bayesGraph::tmpOpt(var,xyAxisSelect) \
935     -command [list ::bayesGraph::ShowAxisSelectXY $this]]
936  set tmpOpt(widget,rbAxisY2) [radiobutton $fs.rbAxisY2 -text "Y2: [mc Right]"\
937     -value y2 -highlightthickness 0 -pady 0\
938     -variable ::bayesGraph::tmpOpt(var,xyAxisSelect) \
939     -command [list ::bayesGraph::ShowAxisSelectXY $this]]
940
941  grid $fs.rbAxisX   -sticky nws -pady 2
942  grid $fs.rbAxisX2  -sticky nws -pady 2
943  grid $fs.rbAxisY   -sticky nws -pady 2
944  grid $fs.rbAxisY2  -sticky nws -pady 2
945
946  grid rowconfigure    $fs 9 -weight 1
947  grid columnconfigure $fs 0 -weight 1
948
[e933fd6]949  # Tab Set   
950  set w_tabset [NoteBook $w.nb -tabbevelsize 8 -tabpady {2 6} -font {Arial 8}]
951  set num_i 0
952  foreach lab_i [list Scales Format Marker Title] {
953    $w_tabset insert $num_i $lab_i -text "  [mc $lab_i]  " -background \#d9d9d9
954    set tab_i [$w_tabset getframe $lab_i]
955    $tab_i configure -borderwidth 2 -background \#d9d9d9
956    incr num_i
957    set f$num_i [frame $tab_i.f]
958    pack $tab_i.f -fill both -expand yes 
959  }
960  $w_tabset raise [$w_tabset pages 0]
[6d7779d]961
962  # X-Axis
963  TitleFrame $f1.tf1a -text [mc "Scales"]
964  set f1a [$f1.tf1a getframe]
965
966  checkbutton $f1a.chShow -text [mc "Visible"]\
967     -highlightthickness 0 -pady 0 -padx 0\
968     -variable ::bayesGraph::tmpOpt(var,xyAxisShow)
969
970  set AXI [string toupper [string index $tmpOpt(var,xyAxisSelect) 0]]
971  #Comprobamos que existe la funcion
972  if {[info exists data(gr,$gr,OnGet${AXI}Ticks)]} {
973    set lst [$data(gr,$gr,OnGet${AXI}Ticks) $this]
974  } else {
975    set lst {}
976  }
977
978  label $f1a.lFirst -text [mc First]:
979  set tmpOpt(widget,xyAxisMin) \
980    [SpinBox $f1a.sbFirst -values $lst -justify right -width 20 \
981      -textvariable ::bayesGraph::tmpOpt(var,xyAxisMin)]
982     
983  label $f1a.lLast -text [mc Last]:
984  set tmpOpt(widget,xyAxisMax) \
985    [SpinBox $f1a.sbLast -values $lst -justify right -width 20 \
986      -textvariable ::bayesGraph::tmpOpt(var,xyAxisMax)]
987 
988  set tmpOpt(widget,chXYAll) \
989    [checkbutton $f1a.chAll -text [mc "All values"]\
990      -highlightthickness 0 -pady 0 -padx 0\
991      -variable ::bayesGraph::tmpOpt(var,xyAxisAll)\
992      -command [list ::bayesGraph::GrapOptCheckXYAxisAll $this]]
993
994  grid $f1a.chShow -            -sticky w -pady 2
995  grid $f1a.lFirst $f1a.sbFirst -sticky w -pady 2
996  grid $f1a.lLast  $f1a.sbLast  -sticky w -pady 2
997  grid $f1a.chAll  -column 1    -sticky nw
998  grid rowconfigure    $f1a 3 -weight 1
999  grid columnconfigure $f1a 1 -weight 1
1000
1001  # X-Axis ticks
1002  TitleFrame $f1.tf1b -text [mc "Ticks"]
1003  set f1b [$f1.tf1b getframe]
1004
1005  set tmpOpt(widget,rbXYTotal) [radiobutton $f1b.rbTotal -text [mc Total]:\
1006     -value total -highlightthickness 0 -pady 0\
1007     -variable ::bayesGraph::tmpOpt(var,xyTicksType)\
1008     -command [list ::bayesGraph::GrapOptCheckXYTicksType $this]]
1009  set tmpOpt(widget,rbXYEach) [radiobutton $f1b.rbEach -text [mc Each]:\
1010     -value each -highlightthickness 0 -pady 0\
1011     -variable ::bayesGraph::tmpOpt(var,xyTicksType)\
1012     -command [list ::bayesGraph::GrapOptCheckXYTicksType $this]]
1013  set tmpOpt(widget,rbXYAuto) [radiobutton $f1b.rbAuto -text [mc Automatic]\
1014     -value auto -highlightthickness 0 -pady 0\
1015     -variable ::bayesGraph::tmpOpt(var,xyTicksType)\
1016     -command [list ::bayesGraph::GrapOptCheckXYTicksType $this]]
1017
1018  set tmpOpt(widget,xyTicksTotal) [Entry $f1b.eTicksTotal -validate key\
1019     -vcmd {expr {[string is int %P] && [string length %P]<3}}\
1020     -width 10 -justify right -textvariable ::bayesGraph::tmpOpt(var,xyTicksTotal)]
1021  set tmpOpt(widget,xyTicksStep) [Entry $f1b.eTicksStep -validate key\
1022     -vcmd {expr {[string is double %P] && [string length %P]<9}}\
1023     -width 10 -justify right -textvariable ::bayesGraph::tmpOpt(var,xyTicksStep)]
1024
1025  frame $f1b.f
1026  label $f1b.f.lFont -text [mc "Font"]:
1027  bfont $f1b.f.bFont -variable ::bayesGraph::tmpOpt(var,xyTicksFont)
1028  label $f1b.f.lRotate -text [mc "Rotate"]:
1029  SpinBox $f1b.f.sbRotate -range {0 360} -width 4 -justify right -editable true\
1030      -textvariable ::bayesGraph::tmpOpt(var,xyTicksRotate)
1031  label $f1b.f.lColor -text [mc "Color"]:
1032  bcolor $f1b.f.fColor -variable ::bayesGraph::tmpOpt(var,xyTicksColor)
1033  label $f1b.f.lLength -text [mc "Length"]:
1034  SpinBox $f1b.f.sbLength -range {0 20} -width 4 -justify right -editable true\
1035      -textvariable ::bayesGraph::tmpOpt(var,xyTicksLength)
1036  label $f1b.f.lShadow -text [mc "Shadow"]:
1037  bcolor $f1b.f.fShadow -variable ::bayesGraph::tmpOpt(var,xyTicksShadow) \
1038    -label "[mc "Change Shadow"]:" -optmenu 1 
1039  label $f1b.f.lSubdiv -text [mc "Subdivisions"]:
1040  SpinBox $f1b.f.sbSubdiv -range {1 10} -width 4 -justify right -editable true\
1041      -textvariable ::bayesGraph::tmpOpt(var,xyTicksSubdivisions)
1042  checkbutton $f1b.f.chShow -text [mc "Show ticks"]\
1043     -highlightthickness 0 -pady 0 -padx 0\
1044     -variable ::bayesGraph::tmpOpt(var,xyTicksShow)
1045  label $f1b.f.lWidth -text [mc "Line width"]:
1046  SpinBox $f1b.f.sbWidth -range {0 10} -width 4 -justify right -editable true\
1047      -textvariable ::bayesGraph::tmpOpt(var,xyTicksWidth)
1048
1049  frame $f1b.f.f -width 15
1050  grid $f1b.f.f $f1b.f.chShow  -              $f1b.f.lWidth  $f1b.f.sbWidth  -sticky nw -padx 2
1051  grid ^        $f1b.f.lFont   $f1b.f.bFont   $f1b.f.lRotate $f1b.f.sbRotate -sticky nw -padx 2
1052  grid ^        $f1b.f.lColor  $f1b.f.fColor  $f1b.f.lLength $f1b.f.sbLength -sticky nw -padx 2
1053  grid ^        $f1b.f.lShadow $f1b.f.fShadow $f1b.f.lSubdiv $f1b.f.sbSubdiv -sticky nw -padx 2
1054  grid columnconfigure $f1b.f 2 -pad 12
1055
1056  grid $f1b.rbTotal $f1b.eTicksTotal -sticky w
1057  grid $f1b.rbEach  $f1b.eTicksStep  -sticky w
1058  grid $f1b.rbAuto  -                -sticky nw
1059  grid $f1b.f       -                -sticky ns -pady 4
1060  grid rowconfigure    $f1b 5 -weight 1
1061  grid columnconfigure $f1b 2 -weight 1
1062
1063  grid $f1.tf1a -sticky news -padx 2
1064  grid $f1.tf1b -sticky news -padx 2
1065  grid rowconfigure    $f1 0 -weight 1
1066  grid rowconfigure    $f1 1 -weight 3
1067  grid columnconfigure $f1 0 -weight 1
1068 
1069  # Tab Title
1070  TitleFrame $f4.tf -text [mc "Title"]
1071  set f4a   [$f4.tf getframe]
1072  ::bayesGraph::GrapOptCreateTitles \
1073    $this $f4a [list xyAxisTitle xyAxisFont xyAxisColor xyAxisShadow]
1074 
1075  grid $f4.tf    -sticky news -padx 2
1076  grid rowconfigure    $f4 0 -weight 1
1077  grid columnconfigure $f4 0 -weight 1
1078 
1079  # Tab Set Format
1080  TitleFrame $f2.tf -text [mc "Number"]
1081  set f2a   [$f2.tf getframe]
1082  # Number
1083  set tmpOpt(var,eNumText)  12345.67890
1084  set tmpOpt(var,eSamText)  ""
1085
1086  label $f2a.lFormat -text [mc "Format"]:
1087  Entry $f2a.eFormat -width 60 -justify left -text $tmpOpt(var,xyFormatNumber) \
1088    -textvariable ::bayesGraph::tmpOpt(var,xyFormatNumber)
1089
1090  checkbutton $f2a.chPercent -text [mc "Show percent"] \
1091     -highlightthickness 0 -pady 0 -padx 0 \
1092     -variable ::bayesGraph::tmpOpt(var,xyFormatPercent) \
1093     -command [list ::bayesGraph::CheckPercent $this]
1094
1095  label $f2a.lNumber -text [mc "Number"]:
1096  Entry $f2a.eNumber -width 30 -justify right \
1097     -validate key -vcmd {string is double %P} \
1098     -text $tmpOpt(var,eNumText) -textvariable ::bayesGraph::tmpOpt(var,eNumText)
1099
1100  Button $f2a.bApply -text [mc Prove]\
1101    -helptext [mc "It proves the specified format"]\
1102    -command  [list ::bayesGraph::ProveNumber $this]
1103
1104  label $f2a.lSample -text [mc "Sample"]:
1105  Entry $f2a.eSample -width 60 -justify left -editable 0 \
1106    -text $tmpOpt(var,eSamText) -textvariable ::bayesGraph::tmpOpt(var,eSamText)
1107
1108  button $f2a.bHelpNumFor -text [mc "Format number"] \
1109     -image [::Bitmap::get infor] -compound left \
1110     -command [list ::bayesGraph::ShowNumberSpecifiers $this $w]
1111
1112  grid $f2a.lFormat      $f2a.eFormat  -            -sticky nw -padx 5 -pady 5
1113  grid $f2a.chPercent    -             -            -sticky nw -padx 5 -pady 5
1114  grid $f2a.lNumber      $f2a.eNumber  $f2a.bApply  -sticky nw -padx 5 -pady 5
1115  grid $f2a.lSample      $f2a.eSample  -            -sticky nw -padx 5 -pady 5
1116  grid $f2a.bHelpNumFor  -             -            -sticky nw -padx 5 -pady 5
1117
1118  grid rowconfigure    $f2a 6 -weight 1
1119  grid columnconfigure $f2a 1 -weight 1
1120
1121  # Text
1122  grid $f2.tf    -sticky news -padx 2
1123  grid rowconfigure    $f2 0 -weight 1
1124  grid columnconfigure $f2 0 -weight 1
1125
1126  # Marker
1127  GrapOptCreateMarkers $this $f3
1128
1129  # Auto-ajuste
1130  TitleFrame $w.tfsf -text [mc "Self fit of values"]
1131  set f3 [$w.tfsf getframe]
1132
1133  checkbutton $f3.cbSelfFit \
1134     -text [mc "Self fit of axes to the data of the graph to open"] \
1135     -highlightthickness 0 -pady 0 -padx 0 -offvalue 0 -onvalue 1 \
1136     -variable ::bayesGraph::tmpOpt(var,selffit)
1137
1138  grid $f3.cbSelfFit -sticky nw -padx 2 -pady 4
1139  grid rowconfigure    $f3 1 -weight 1
1140  grid columnconfigure $f3 1 -weight 1
1141
1142
1143  # General
[e933fd6]1144  $w_tabset compute_size
[6d7779d]1145  grid $w.tfxs  $w_tabset -sticky news -padx 2
1146  grid ^        $w.tfsf   -sticky news -padx 2
1147  grid rowconfigure    $w 0 -weight 1
1148  grid rowconfigure    $w 1 -weight 0
1149  grid columnconfigure $w 1 -weight 1
1150}
1151
1152#/////////////////////////////////////////////////////////////////////////////
1153  proc ::bayesGraph::ShowNumberSpecifiers {this w} {
1154#
1155# PURPOSE: Muestra una ventana con informacion sobre como dar formato a un
1156#   numero. Tambien se puede especificar el formato deseado y hacer pruebas
1157#
1158# PARAMETERS:
1159#   this  -> Instance of BayesGraph
1160#   w     -> Tabset axis
1161#   axis  -> axis [y | y2]
1162#
1163#/////////////////////////////////////////////////////////////////////////////
1164  if [winfo exist $w.t] {
1165    raise $w.numberFormat
1166    return
1167  }
1168  global toltk_options
1169  upvar \#0 ${this}::data data
1170  variable tmpOpt
1171  set dialog [Dialog $w.numberFormat -title [mc "Number format"]\
1172              -default 0 -parent $w -modal local -separator true]
1173  wm resizable $dialog 0 0
1174  set f1 [$dialog getframe]
1175  set color1 red
1176  # help
1177  label $f1.lmenos  -text "%-" -foreground $color1
1178  label $f1.lmenosd -justify left -text [mc ForNumOpc:-]
1179
1180  label $f1.lmas   -text "%+" -foreground $color1
1181  label $f1.lmasd  -justify left -text [mc ForNumOpc:+]
1182 
1183  label $f1.lspace  -text "%space" -foreground $color1
1184  label $f1.lspaced -justify left -text [mc "ForNumOpc:Space"]
1185
1186  label $f1.zero  -text "%0" -foreground $color1
1187  label $f1.zerod -justify left -text [mc "ForNumOpc:Zero"]
1188
1189  label $f1.lf  -text "%f" -foreground $color1
1190  label $f1.lfd -justify left -text [mc "ForNumOpc:f"]
1191
1192  label $f1.leE  -text "%e %E" -foreground $color1
1193  label $f1.leEd -justify left -text [mc "ForNumOpc:e"]
1194
1195  label $f1.lgG  -text "%g %G" -foreground $color1
1196  label $f1.lgGd -justify left -text [mc "ForNumOpc:g"]
1197
1198  label $f1.lpercent  -text "%%" -foreground $color1
1199  label $f1.lpercentd -text [mc "No conversion: just insert %"]
1200 
1201  Button $f1.b -image [::Bitmap::get "accept"]\
1202      -helptext [mc "OK"] -relief link -compound left -text [mc "Accept"]\
1203      -command "destroy $dialog"
1204
1205  grid $f1.lmenos   $f1.lmenosd    -sticky nw -padx 5
1206  grid $f1.lmas     $f1.lmasd      -sticky nw -padx 5
1207  grid $f1.lspace   $f1.lspaced    -sticky nw -padx 5
1208  grid $f1.zero     $f1.zerod      -sticky nw -padx 5
1209  grid $f1.lf       $f1.lfd        -sticky nw -padx 5
1210  grid $f1.leE      $f1.leEd       -sticky nw -padx 5
1211  grid $f1.lgG      $f1.lgGd       -sticky nw -padx 5
1212  grid $f1.lpercent $f1.lpercentd  -sticky nw -padx 5
1213  grid $f1.b                       -sticky ns -columnspan 2 -pady 3
1214
1215  $dialog draw
1216}
1217
1218#/////////////////////////////////////////////////////////////////////////////
1219  proc ::bayesGraph::ProveNumber {this} {
1220#
1221# PURPOSE: guarda los parametros intoducidos
1222#
1223# PARAMETERS:
1224#   this  -> Instance of BayesGraph
1225#
1226#/////////////////////////////////////////////////////////////////////////////
1227  variable tmpOpt
1228
1229  if {[string length $tmpOpt(var,xyFormatNumber)] && \
1230      [string length $tmpOpt(var,eNumText)]} {
1231    if {$tmpOpt(var,xyFormatPercent)} {
1232      set n [expr $tmpOpt(var,eNumText) * 100]
1233    } else  {
1234      set n $tmpOpt(var,eNumText)
1235    }
1236    if {![catch {set tmpOpt(var,eSamText) [format $tmpOpt(var,xyFormatNumber) $n]} res]} {
1237      return $tmpOpt(var,eSamText)
1238    } else {
1239      set tmpOpt(var,eSamText) ""
1240    }
1241  } else {
1242    set tmpOpt(var,eSamText) ""
1243  }
1244}
1245
1246#/////////////////////////////////////////////////////////////////////////////
1247  proc ::bayesGraph::CheckPercent {this} {
1248#
1249# PURPOSE: Añade o elimina el tanto por ciento "%%" del formato
1250#
1251# PARAMETERS:
1252#   this  -> Instance of BayesGraph
1253#
1254#/////////////////////////////////////////////////////////////////////////////
1255  variable tmpOpt
1256  if {$tmpOpt(var,xyFormatPercent)} {
1257    set tmpOpt(var,xyFormatNumber) $tmpOpt(var,xyFormatNumber)%%
1258  } else  {
1259    set p [string first "%%" $tmpOpt(var,xyFormatNumber)]
1260    if {[expr $p >= 0]} {
1261      set tmpOpt(var,xyFormatNumber) \
1262        [string replace $tmpOpt(var,xyFormatNumber) $p \
1263               [expr $p + [string length "%%"] - 1] ""]
1264    }
1265  }
1266}
1267
1268#/////////////////////////////////////////////////////////////////////////////
1269  proc ::bayesGraph::GrapOptCreateTitles {this f lstSuf} {
1270#
1271# PURPOSE: Crea las opcines de visualizacion de titulos de los ejes
1272#
1273# PARAMETERS:
1274#   this  -> Instance of BayesGraph
1275#   f     -> Frame title
1276#   lstSuf -> Lista de sufijo para los nombres de las variables. de 0 a 3
1277#
1278#/////////////////////////////////////////////////////////////////////////////
1279  variable tmpOpt
1280 
1281  label $f.lTitle -text [mc "Title"]:
1282  Entry $f.eTitle -width 45 \
1283    -textvariable ::bayesGraph::tmpOpt(var,[lindex $lstSuf 0])
1284  label $f.lFont -text [mc "Font"]:
1285  bfont $f.bFont -variable ::bayesGraph::tmpOpt(var,[lindex $lstSuf 1])
1286  label $f.lColor -text [mc "Color"]:
1287  bcolor $f.fColor -variable ::bayesGraph::tmpOpt(var,[lindex $lstSuf 2])
1288  label $f.lShadow -text [mc "Shadow"]:
1289  bcolor $f.fShadow -variable ::bayesGraph::tmpOpt(var,[lindex $lstSuf 3]) \
1290    -label "[mc "Change shadow"]:" -optmenu 1 
1291 
1292  frame $f.f -width 25
1293  grid $f.f $f.lTitle $f.eTitle - - - - - -sticky nw -padx 2 -pady 3
1294  grid ^     ^ $f.lFont $f.bFont $f.lColor $f.fColor $f.lShadow $f.fShadow\
1295      -sticky nw -padx 2 -pady 0
1296
1297  grid rowconfigure    $f 7 -weight 1
1298  grid columnconfigure $f 7 -weight 1
1299  grid columnconfigure $f 3 -pad   20
1300  grid columnconfigure $f 5 -pad   20
1301}
1302
1303
1304#/////////////////////////////////////////////////////////////////////////////   
1305proc ::bayesGraph::GrapOptCreateLines {this w {linedefault 1}} {
1306# 
1307#///////////////////////////////////////////////////////////////////////////// 
1308  upvar \#0 ${this}::widgets widgets
1309  variable tmpOpt
1310
1311  # Lines list
1312  TitleFrame $w.tf0 -text [mc "Lines list"]
1313  set f0 [$w.tf0 getframe]
1314
1315  set widgets(lines,lst) [blistorder $f0.linesList \
1316    -cols [list id name caption label] -parent $w \
1317    -hiddencols {id name caption} -selectbackground grey \
1318    -colkeypress {label} -orientation horizontal -showtitles false \
1319    -height 200 -width 100 \
1320    -nomenu true -selectmode single -values $tmpOpt(var,lstnames) \
1321    -selectcommand [list ::bayesGraph::ShowSelectLines $this]]
1322
1323  # LIST LINES
1324  # visualizamos opciones sobre la linea default
1325  # calculation position line in listbox
1326  set i 1
1327  set lineDef $linedefault
1328  foreach it $tmpOpt(var,lstnames) {
1329    if {[string equal $linedefault [lindex $it 0]]} {
1330      set lineDef $i
1331    }
1332    incr i
1333  }
1334
1335  $widgets(lines,lst) selection set $lineDef
1336  ::bayesGraph::ShowOptLines $this $linedefault
1337 
1338  grid $widgets(lines,lst) -sticky news
1339  grid rowconfigure    $f0 0 -weight 1
1340  grid columnconfigure $f0 0 -weight 1 
1341
1342  # OPTIONS LINES AND DATA
[e933fd6]1343  set w_tabset [NoteBook $w.nb -tabbevelsize 8 -tabpady {2 6} -font {Arial 8}]
1344  set num_i 0
1345  foreach lab_i [list Line Data] {
1346    $w_tabset insert $num_i $lab_i -text "  [mc $lab_i]  " -background \#d9d9d9
1347    set tab_i [$w_tabset getframe $lab_i]
1348    $tab_i configure -borderwidth 2 -background \#d9d9d9
1349    incr num_i
1350    set f$num_i [frame $tab_i.f]
1351    pack $tab_i.f -fill both -expand yes 
1352  }
1353  $w_tabset raise [$w_tabset pages 0]
[6d7779d]1354
[e933fd6]1355  GrapOptCreateLinesLine $this $f1
1356  GrapOptCreateLinesData $this $f2
[6d7779d]1357 
1358  #GRID
[e933fd6]1359  $w_tabset compute_size
[6d7779d]1360  grid  $w.tf0 $w_tabset -sticky news -padx 1   
1361 
1362  grid rowconfigure    $w 0 -weight 1
1363 
1364  grid columnconfigure $w 0 -weight 1
1365  grid columnconfigure $w 1 -weight 0
1366}
1367
1368
1369#/////////////////////////////////////////////////////////////////////////////   
1370proc ::bayesGraph::GrapOptCreateLinesLine {this w} {
1371# 
1372#///////////////////////////////////////////////////////////////////////////// 
1373  variable tmpOpt
1374  upvar \#0 ${this}::widgets widgets
1375 
1376  # Optiones lines
1377  TitleFrame $w.tf2 -text [mc "Line Options"]
1378  set f2 [$w.tf2 getframe]
1379
1380  radiobutton $f2.rbIsLine -text [mc "Lines"] \
1381     -value LineElement -highlightthickness 0 -pady 0 -padx 0 \
1382     -variable ::bayesGraph::tmpOpt(var,linetypes_)
1383  label   $f2.llwidth -text [mc "Lines Width"]: 
1384  SpinBox $f2.sblwidth -justify right -width 4 -editable 0 -range {0 10}\
1385      -textvariable ::bayesGraph::tmpOpt(var,linewidth_)
1386  label $f2.ldashes -text [mc "Lines Type"]:
1387  ::Objects::ComboDashesCreate ::bayesGraph::tmpOpt(var,dashes_) ${f2}.sbdashes
1388
1389  label $f2.lSmooth -text [mc "Smooth"]:
1390  set lst {linear step natural quadratic}
1391  foreach it $lst { lappend values [mc $it] }
1392
1393  ComboBox $f2.cbSmooth -width 15 -height 5 -editable false\
1394     -values $values -justify right\
1395     -modifycmd [list ::Objects::ComboUnTranslate $f2.cbSmooth $lst\
1396       ::bayesGraph::tmpOpt(var,smooth_)]
1397  ::Objects::ComboSetIni $f2.cbSmooth $lst ::bayesGraph::tmpOpt(var,smooth_)
1398
1399if {0} {
1400#puts "\nTitle: values: $values lst: $lst ::bayesGraph::tmpOpt(var,smooth_) : $::bayesGraph::tmpOpt(var,smooth_) \n"
1401#puts "\nTitle: [lindex $values [lsearch -exact $lst $::bayesGraph::tmpOpt(var,smooth_)]] \n"
1402  bcomboboxplus $f2.cbSmooth -cols {title id} -varcol {id} -parent $f2 \
1403    -variable ::bayesGraph::tmpOpt(var,smooth_) \
1404    -showtitles false -hiddencols {id} -hiddencolslb {id} \
1405    -text [lindex $values \
1406      [lsearch -exact $lst $::bayesGraph::tmpOpt(var,smooth_)]] \
1407    -values [ljoin $values $lst " "]
1408  $f2.cbSmooth activate select
1409}
1410  set values {}
1411  set lst {none image solid striped {stipple image} {stipple degraded}}
1412  foreach it $lst { lappend values [mc $it]  }
1413  label $f2.llTypeFill -text [mc "Fill type"]:
1414  ComboBox $f2.cblTypeFill -width 15 -height 5 \
1415    -editable false -justify right -values $values \
1416    -modifycmd [list ::Objects::ComboUnTranslate $f2.cblTypeFill $lst\
1417      ::bayesGraph::tmpOpt(var,areaTypes_)]
1418  ::Objects::ComboSetIni $f2.cblTypeFill $lst \
1419    ::bayesGraph::tmpOpt(var,areaTypes_)
1420
1421  variable typelist {{"Gif images" {".gif"}}}
1422  variable defExt .gif
1423  label $f2.lImage -text [mc Image]:
1424  set tmpOpt(widget,areaTile) [::Objects::ChooseFileCreate \
1425    ::bayesGraph::tmpOpt(var,areaTiles_) $f2.bFillImage \
1426    -filetypes $typelist -defaultextension $defExt]
1427 
1428  grid $f2.rbIsLine   -               -sticky nw -pady 0
1429  grid $f2.llwidth    $f2.sblwidth    -sticky nw -pady 0
1430  grid $f2.ldashes    $f2.sbdashes    -sticky nw -pady 0
1431  grid $f2.lSmooth    $f2.cbSmooth    -sticky nw -pady 0
1432  grid $f2.llTypeFill $f2.cblTypeFill -sticky nw -pady 0
1433  grid $f2.lImage     $f2.bFillImage  -sticky nw -pady 0
1434  grid rowconfigure    $f2 10 -weight 1
1435  grid columnconfigure $f2 10 -weight 1
1436
1437  # Optiones bar
1438  TitleFrame $w.tf3 -text [mc "Bar Options"]
1439  set f3 [$w.tf3 getframe]
1440
1441  radiobutton $f3.rbIsLine -text [mc "Bar"] \
1442     -value BarElement -highlightthickness 0 -pady 0 -padx 0 \
1443     -variable ::bayesGraph::tmpOpt(var,linetypes_)
1444  label   $f3.lbwidth -text [mc "Bars Width"]:
1445  SpinBox $f3.sbbwidth -justify right -width 4 -editable 0 \
1446      -values {0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1} \
1447      -textvariable ::bayesGraph::tmpOpt(var,barwidth_)
1448 
1449  set list {flat groove raised ridge solid sunken}
1450  set values ""
1451  foreach it $list { lappend values [mc $it] }
1452  label $f3.lRelief -text [mc "Bar relief"]:
1453  ComboBox $f3.cbRelief -width 15 -height 5 -editable false\
1454      -values $values -justify right\
1455      -modifycmd   [list ::Objects::ComboUnTranslate $f3.cbRelief $list \
1456      ::bayesGraph::tmpOpt(var,barrelief_)]]
1457  ::Objects::ComboSetIni $f3.cbRelief $list \
1458    ::bayesGraph::tmpOpt(var,barrelief_)
1459 
1460  label $f3.lbdw -text [mc "Border width"]:
1461  set tmpOpt(widget,bdwidth) [SpinBox $f3.sbbdw -range {1 100} \
1462    -justify right -width 4 -editable 0 \
1463    -textvariable ::bayesGraph::tmpOpt(var,borderwidth_)]
1464 
1465  label $f3.lbTypeFill -text [mc "Fill type"]:
1466  set values ""
1467  set list {none striped {stipple image} {stipple degraded}}
1468  foreach it $list { lappend values [mc $it]  }
1469  ComboBox $f3.cbbTypeFill -width 15 -height 5 \
1470    -editable false -justify right -values $values \
1471    -modifycmd   [list ::Objects::ComboUnTranslate $f3.cbbTypeFill $list\
1472    ::bayesGraph::tmpOpt(var,areaTypesBar_)]
1473  ::Objects::ComboSetIni $f3.cbbTypeFill $list \
1474    ::bayesGraph::tmpOpt(var,areaTypesBar_)
1475
1476  grid $f3.rbIsLine   -               -sticky nw -pady 1
1477  grid $f3.lbwidth    $f3.sbbwidth    -sticky nw -pady 1
1478  grid $f3.lRelief    $f3.cbRelief    -sticky nw -pady 1
1479  grid $f3.lbdw       $f3.sbbdw       -sticky nw -pady 1
1480  grid $f3.lbTypeFill $f3.cbbTypeFill -sticky nw -pady 1
1481  grid rowconfigure    $f3 10 -weight 1
1482  grid columnconfigure $f3 10 -weight 1
1483   
1484  # General options
1485  TitleFrame $w.tf4 -text [mc "General Options"]
1486  set f4 [$w.tf4 getframe]
1487 
1488  label $f4.lname -text [mc Name]:
1489  Entry $f4.ename -width 50 -justify left \
1490    -textvariable ::bayesGraph::tmpOpt(var,linelabels_)
1491   
1492  checkbutton $f4.chHide -text [mc "Hide line"] \
1493    -highlightthickness 0 -pady 2 -padx 0 -onvalue true -offvalue false \
1494    -variable ::bayesGraph::tmpOpt(var,linehides_) 
1495 
1496  label $f4.lColor -text "[mc Color]:"
1497  bcolor $f4.fColor -variable ::bayesGraph::tmpOpt(var,colors_)
1498
1499  label $f4.lMapped -text "[mc Mapped]:"
1500  foreach axis {x x2 y y2} {
1501    radiobutton $f4.rbMap${axis} -text [string toupper $axis] \
1502      -value $axis -highlightthickness 0 -pady 0 \
1503      -variable ::bayesGraph::tmpOpt(var,[string index $axis 0]MappedAxis_)
1504  }
1505 
1506  label $f4.lForeground -text [mc Foreground]:
1507  bcolor $f4.fForeground -optmenu 2 \
1508    -variable ::bayesGraph::tmpOpt(var,areaForegrounds_)   
1509 
1510  label $f4.lBackground -text [mc Background]:
1511  bcolor $f4.fBackground -optmenu 2 \
1512    -variable ::bayesGraph::tmpOpt(var,areaBackgrounds_)
1513 
1514  variable typelist {{"XBM images" {".xbm"}}}
1515  variable defExt .xbm
1516  label $f4.lImageBack -text [mc {Image background}]:
1517  ::Objects::ChooseFileCreate \
1518    ::bayesGraph::tmpOpt(var,stippleimages_) $f4.bFillImage \
1519    -filetypes $typelist -defaultextension $defExt
1520
1521  label $f4.lsbDegraded -text [mc {Degraded percentage}]:
1522  SpinBox $f4.sbbstipple -justify right -width 4 -editable 0 \
1523    -values {12 25 50 75} \
1524    -textvariable ::bayesGraph::tmpOpt(var,stippledegradeds_) 
1525
1526  grid $f4.chHide      -               -              -              \
1527    -sticky nw -pady 1
1528  grid $f4.lColor      $f4.fColor      -               -              \
1529    -sticky nw -pady 1 
1530  grid $f4.lForeground $f4.fForeground $f4.lImageBack  $f4.bFillImage \
1531    -sticky nw -pady 1
1532  grid $f4.lBackground $f4.fBackground $f4.lsbDegraded $f4.sbbstipple \
1533    -sticky nw -pady 1
1534  grid $f4.lMapped     $f4.rbMapx      $f4.rbMapy      -              \
1535    -sticky nw -pady 1
1536  grid ^               $f4.rbMapx2     $f4.rbMapy2     -              \
1537    -sticky nw -pady 1
1538  grid $f4.lname       $f4.ename       -               -              \
1539    -sticky nw -pady 1
1540 
1541  grid rowconfigure    $f4 10 -weight 1
1542  grid columnconfigure $f4 10 -weight 1
1543 
1544  # Optiones bar
1545  TitleFrame $w.tf5 -text [mc "For all element options"]
1546  set f5 [$w.tf5 getframe] 
1547  set list {infront stacked overlap aligned}
1548  set values ""
1549  foreach it $list { lappend values [mc $it] }
1550  label $f5.lBarMode -text [mc "Bar mode"]:
1551  ComboBox $f5.cbBarMode -width 15 -height 5 -editable false\
1552     -values $values -justify right\
1553     -modifycmd   [list ::Objects::ComboUnTranslate $f5.cbBarMode $list\
1554      ::bayesGraph::tmpOpt(var,barmode)]
1555  ::Objects::ComboSetIni  $f5.cbBarMode $list \
1556    ::bayesGraph::tmpOpt(var,barmode) 
1557 
1558  grid $f5.lBarMode    $f5.cbBarMode   -sticky nw -pady 1 
1559  grid rowconfigure    $f5 10 -weight 1
1560  grid columnconfigure $f5 10 -weight 1
1561 
1562  # Grid title frame
1563  grid  $w.tf2  $w.tf3 -sticky news 
1564  grid  $w.tf4  -      -sticky news
1565  grid  $w.tf5  -      -sticky news
1566 
1567  grid rowconfigure    $w 2  -weight 1
1568  grid columnconfigure $w 10 -weight 1 
1569}
1570
1571
1572#/////////////////////////////////////////////////////////////////////////////   
1573proc ::bayesGraph::GrapOptCreateLinesData {this w} {
1574# 
1575#/////////////////////////////////////////////////////////////////////////////
1576  variable tmpOpt
1577  upvar \#0 ${this}::widgets widgets
1578 
1579  # DATA VALUES
1580  TitleFrame $w.tf1 -text [mc "Data values"]
1581  set f1 [$w.tf1 getframe]
1582  label $f1.lvshowvalues -text [mc "Show"]:
1583
1584  set lst {both none x y}
1585  foreach it $lst { lappend values [mc $it]  }
1586  ComboBox $f1.cbshowvalues -width 8 -height 5 -editable false \
1587    -justify right -values $values \
1588    -modifycmd [list ::Objects::ComboUnTranslate $f1.cbshowvalues $lst \
1589      ::bayesGraph::tmpOpt(var,showvalues_)]
1590  ::Objects::ComboSetIni  $f1.cbshowvalues $lst \
1591    ::bayesGraph::tmpOpt(var,showvalues_)
1592 
1593  label $f1.lvfont -text [mc "Font"]:
1594  bfont $f1.bvfont -variable ::bayesGraph::tmpOpt(var,valuefont_)
1595  label $f1.lvrotate -text [mc Rotate]: -justify right
1596  SpinBox $f1.sbvrotate -range {0 360} -width 15 -justify right -width 4 \
1597    -editable 0 -textvariable ::bayesGraph::tmpOpt(var,valuerotate_)
1598 
1599  label $f1.lvcolor -text [mc Color]:
1600  bcolor $f1.fvcolor -variable ::bayesGraph::tmpOpt(var,valuecolor_)
1601 
1602  label $f1.lvformat -text [mc "Decimals"]:
1603  SpinBox $f1.sbvformat -range {0 4} -width 4 -justify right -editable false \
1604    -textvariable ::bayesGraph::tmpOpt(var,valueformatdec_)
1605 
1606  label $f1.lvshadow -text [mc "Shadow"]:
1607  bcolor $f1.fvshadow -variable ::bayesGraph::tmpOpt(var,valueshadow_) \
1608    -label "[mc "Change Shadow"]:" -optmenu 1 
1609 
1610  label $f1.lvanchor -text [mc Anchor]:
1611  ::Objects::ComboPosCreate ::bayesGraph::tmpOpt(var,valueanchor_) $f1.fvanchor
1612 
1613  grid $f1.lvshowvalues $f1.cbshowvalues  -             -             \
1614    -sticky nw -padx 2 -pady 3
1615  grid $f1.lvfont       $f1.bvfont        $f1.lvrotate  $f1.sbvrotate \
1616    -sticky w  -padx 2 -pady 1
1617  grid $f1.lvcolor      $f1.fvcolor       $f1.lvformat  $f1.sbvformat \
1618    -sticky w  -padx 2 -pady 1
1619  grid $f1.lvshadow     $f1.fvshadow      $f1.lvanchor  $f1.fvanchor  \
1620    -sticky w  -padx 2 -pady 1
1621 
1622  grid rowconfigure    $f1 10 -weight 1
1623  grid columnconfigure $f1 10 -weight 1
1624 
1625  # SYMBOLS DATA
1626  TitleFrame $w.tf2 -text [mc "Data symbols"]
1627  set f2 [$w.tf2 getframe]
1628 
1629  checkbutton $f2.chShowSymbols -text [mc "Show symbols"] \
1630    -highlightthickness 0 -pady 0 -padx 0 \
1631    -variable ::bayesGraph::tmpOpt(var,showsymbols_)
1632#Comando para desabilitar las opciones de simbolos 
1633#  -command [list ::bayesGraph::GrapOptCheckShowSymbols $this $serie]
1634   
1635  label $f2.lSymbol -text [mc "Symbol"]:
1636  set lst {circle square diamond plus cross splus scross triangle arrow}
1637  set values {}
1638  foreach it $lst { lappend values [mc $it] }
1639  ComboBox $f2.cbSymbol -width 10 -height 5 -values $values -justify right \
1640    -modifycmd   [list ::Objects::ComboUnTranslate $f2.cbSymbol $lst \
1641      ::bayesGraph::tmpOpt(var,symbol_)]
1642  ::Objects::ComboSetIni  $f2.cbSymbol $lst \
1643    ::bayesGraph::tmpOpt(var,symbol_)
1644 
1645  label $f2.lPixels -text [mc "Pixels"]:
1646  SpinBox $f2.sbPixels -range {2 36 2} -width 4 -justify right \
1647    -textvariable ::bayesGraph::tmpOpt(var,pixels_)
1648   
1649  checkbutton $f2.chScaleSymbols -highlightthickness 0 -pady 0 -padx 0 \
1650    -text [mc "Scale symbols"] \
1651    -variable ::bayesGraph::tmpOpt(var,scalesymbols_)
1652
1653  label $f2.lFill -text [mc "Fill"]:
1654  bcolor $f2.fFill -variable ::bayesGraph::tmpOpt(var,fill_) -optmenu 3
1655
1656  label $f2.lOutline -text [mc "Outline"]:
1657  bcolor $f2.fOutline -variable ::bayesGraph::tmpOpt(var,outline_) -optmenu 2 
1658
1659  label $f2.lOWid -text [mc "Outline width"]:
1660  SpinBox $f2.sbOWid -range {0 8} -width 4 -justify right \
1661    -textvariable ::bayesGraph::tmpOpt(var,outlinewidth_)
1662
1663  grid $f2.chShowSymbols -            -                  -             \
1664    -sticky nw -padx 2 -pady 4
1665  grid $f2.lSymbol       $f2.cbSymbol $f2.lPixels        $f2.sbPixels  \
1666    -sticky nw -padx 2
1667  grid $f2.lOutline      $f2.fOutline $f2.lOWid          $f2.sbOWid    \
1668    -sticky nw -padx 2
1669  grid $f2.lFill         $f2.fFill    $f2.chScaleSymbols -             \
1670    -sticky nw -padx 2 
1671
1672  grid rowconfigure    $f2 10 -weight 1
1673  grid columnconfigure $f2 10 -weight 1
1674 
1675  grid $w.tf1 -sticky news -padx 2   
1676  grid $w.tf2 -sticky news -padx 2
1677
1678  # GRID
1679  grid rowconfigure    $w 0 -weight 0
1680  grid rowconfigure    $w 1 -weight 1
1681
1682#  grid rowconfigure    $w 1 -weight 0   
1683  grid columnconfigure $w 0 -weight 1
1684}
1685
1686
1687#/////////////////////////////////////////////////////////////////////////////
1688proc ::bayesGraph::GrapOptCreateMarkers {this w} {
1689#
1690# PURPOSE:
1691#
1692# PARAMETERS:
1693#
1694#/////////////////////////////////////////////////////////////////////////////
1695  variable tmpOpt
[e933fd6]1696  # tab_set 
1697  set tsmarker [NoteBook $w.nb -tabbevelsize 8 -tabpady {2 6} -font {Arial 8}]
1698   
1699  set num_i 0
1700  foreach lab_i [list Marker Style] {
1701    $tsmarker insert $num_i $lab_i -text "  [mc $lab_i]  " -background \#d9d9d9
1702    set tab_i [$tsmarker getframe $lab_i]
1703    $tab_i configure -borderwidth 2 -background \#d9d9d9
1704    incr num_i
1705    set f$num_i [frame $tab_i.f]
1706    pack $tab_i.f -fill both -expand yes 
1707  }
1708  $tsmarker raise [$tsmarker pages 0] 
[6d7779d]1709
1710  # Marker
1711  # Each
1712  TitleFrame $f1.eachXY -text [mc "Each"]
1713  ::bayesGraph::CreateMarkers $f1.eachXY xyMarkers
1714  # In X
1715  TitleFrame $f1.inXY -text [mc "In"]
1716  ::bayesGraph::CreateMarkers $f1.inXY xyMarkersIn
1717  # marker
1718  grid $f1.eachXY  $f1.inXY  -sticky news -padx 2
1719  grid rowconfigure    $f1 0 -weight 1
1720  grid columnconfigure $f1 0 -weight 1
1721  grid columnconfigure $f1 1 -weight 1
1722
1723  #Style
1724  TitleFrame $f2.tf -text [mc "Markers Style"]
1725  set f [$f2.tf getframe]
1726 
1727  label $f.lStyle -text [mc "Choose lines color, type, position and width for 5 Markers"]:
1728
1729  label $f.lColor  -text [mc Color]:
1730  label $f.lDashes -text [mc "Style"]:
1731  label $f.lWidth  -text [mc "Width"]:
1732  label $f.lUnder  -text [mc "Under"]:
1733
1734  for {set i 0} {$i < 5} {incr i} {
1735    label $f.lDesc$i -text "[mc Marker] [expr $i+1]:"
1736    bcolor $f.fColor$i \
1737      -variable ::bayesGraph::tmpOpt(var,xyMarkerColorInEach$i)     
1738    ::Objects::ComboDashesCreate \
1739      ::bayesGraph::tmpOpt(var,xyMarkerDasheInEach$i) $f.sbDashes$i
1740    SpinBox $f.sbWidth$i -justify right -width 4 -editable 0 -range {0 10}\
1741            -textvariable ::bayesGraph::tmpOpt(var,xyMarkerWidthInEach$i)
1742    checkbutton $f.chUnder$i -highlightthickness 0 \
1743       -variable ::bayesGraph::tmpOpt(var,xyMarkerUnderInEach$i)
1744  }
1745
1746  grid $f.lStyle - - - - -sticky nw -padx 5 -pady 5
1747  frame $f.f -width 15
1748  grid $f.f  $f.lColor  $f.lDashes  $f.lWidth $f.lUnder -sticky nw -padx 15 -pady 2
1749  for {set i 0} {$i < 5} {incr i} {
1750    grid $f.f $f.fColor$i  $f.sbDashes$i \
1751              $f.sbWidth$i $f.chUnder$i -sticky new -padx 15 -pady 2
1752  } 
1753
1754  grid rowconfigure    $f 100 -weight 1
1755  grid columnconfigure $f 100 -weight 1
1756
1757  # Style
1758  grid $f2.tf -sticky news -padx 2
1759  grid rowconfigure    $f2 0 -weight 1
1760  grid columnconfigure $f2 0 -weight 1
1761
1762  # General
[e933fd6]1763  $tsmarker compute_size
[6d7779d]1764  grid $tsmarker -sticky news -padx 2
1765  grid rowconfigure    $w 0 -weight 1
1766  grid columnconfigure $w 0 -weight 1
1767}
1768
1769
1770#/////////////////////////////////////////////////////////////////////////////
1771proc ::bayesGraph::CreateMarkers {tf axis} {
1772#
1773# PURPOSE:
1774#
1775# PARAMETERS:
1776#
1777#/////////////////////////////////////////////////////////////////////////////
1778  variable tmpOpt
1779
1780  set f [$tf getframe]
1781
1782  entry $f.e -width 18 -validate key\
1783     -vcmd {expr {[string is double %P] && [string length %P]<38}}
1784  Button $f.add -image [Bitmap::get downNext] -height 16 -width 16\
1785      -relief link -helptext [mc "AddMarkSel"]\
1786      -command [list ::bayesGraph::AddElto $f.e $f.sw.lb]
1787  ScrolledWindow $f.sw
1788  blistbox $f.sw.lb -selectmode extended -listvar ::bayesGraph::tmpOpt(var,$axis)\
1789    -width 20 -height 2 -breadonly true -bkeypress true -bparent $tf
1790  $f.sw setwidget $f.sw.lb
1791
1792  bind $f.e     <Key-Return> "[list ::bayesGraph::AddElto $f.e $f.sw.lb]; break"
1793  bind $f.sw.lb <Button-1>   +[list focus -force %W]
1794  bind $f.sw.lb <Key-Delete> +[list ::bayesGraph::DelSelection %W]
1795
1796  grid $f.e    $f.add  -sticky nw -padx 2
1797  grid $f.sw   -       -sticky news
1798  grid rowconfigure    $f 1 -weight 1
1799  grid columnconfigure $f 0 -weight 1
1800}
1801
1802
1803#/////////////////////////////////////////////////////////////////////////////   
1804proc ::bayesGraph::AddElto {e lb} {
1805# 
1806#/////////////////////////////////////////////////////////////////////////////     
1807 
1808  regsub -all -- "( )+" [$e get] "" marker
1809  if [string equal $marker ""] {
1810    return
1811  }
1812  if  { ([lsearch -exact [$lb get 0 end] $marker] != -1) } {
1813    tk_messageBox -type ok -icon info -message [mc "Marker already inserted"] -title [mc "Warning"]
1814  } else {
1815    $lb insert end $marker
1816    $e delete 0 end
1817  }
1818}
1819
1820
1821#/////////////////////////////////////////////////////////////////////////////   
1822proc ::bayesGraph::DelSelection {w} {
1823# 
1824#/////////////////////////////////////////////////////////////////////////////     
1825  foreach i [lsort -integer -decreasing [$w curselection]] {
1826    $w delete $i
1827  }
1828}
1829
1830
1831#/////////////////////////////////////////////////////////////////////////////   
1832proc ::bayesGraph::GrapOptCreateGrid {this w} {
1833#
1834#/////////////////////////////////////////////////////////////////////////////   
1835  variable tmpOpt
1836  TitleFrame $w.tf1 -text [mc "Grid options"]
1837  set f1 [$w.tf1 getframe]
1838
1839  label $f1.lColor -text [mc "Color"]:
1840  bcolor $f1.fColor -variable ::bayesGraph::tmpOpt(var,grid,Color)
1841  label $f1.lDashes -text [mc "Style"]:
1842  ::Objects::ComboDashesCreate ::bayesGraph::tmpOpt(var,grid,Dashes) $f1.sbDashes
1843  label $f1.lLineWidth -text [mc "Line width"]:
1844  SpinBox $f1.sbLineWidth -range {1 4} -width 4 -justify right\
1845      -editable false -textvariable ::bayesGraph::tmpOpt(var,grid,LineWidth)
1846  checkbutton $f1.chMinor -text [mc "Draw for minor ticks"]\
1847     -highlightthickness 0 -pady 0 -padx 0 -variable ::bayesGraph::tmpOpt(var,grid,Minor)
1848 
1849  frame $f1.f
1850  label $f1.f.lMapX -text [mc "Map X to"]:
1851  radiobutton $f1.f.x  -variable ::bayesGraph::tmpOpt(var,grid,MapX) -text [mc "X axis"]  -value x\
1852         -highlightthickness 0 -pady 0
1853  radiobutton $f1.f.x2 -variable ::bayesGraph::tmpOpt(var,grid,MapX) -text [mc "X2 axis"] -value x2\
1854         -highlightthickness 0 -pady 0
1855  radiobutton $f1.f.xN -variable ::bayesGraph::tmpOpt(var,grid,MapX) -text [mc "none"]    -value none\
1856         -highlightthickness 0 -pady 0
1857  label $f1.f.lMapY -text [mc "Map Y to"]:
1858  radiobutton $f1.f.y  -variable ::bayesGraph::tmpOpt(var,grid,MapY) -text [mc "Y axis"]  -value y\
1859         -highlightthickness 0 -pady 0
1860  radiobutton $f1.f.y2 -variable ::bayesGraph::tmpOpt(var,grid,MapY) -text [mc "Y2 axis"] -value y2\
1861         -highlightthickness 0 -pady 0
1862  radiobutton $f1.f.yN -variable ::bayesGraph::tmpOpt(var,grid,MapY) -text [mc "none"]    -value none\
1863         -highlightthickness 0 -pady 0
1864
1865  grid $f1.f.lMapX $f1.f.x $f1.f.x2 $f1.f.xN -sticky nw -padx 2
1866  grid $f1.f.lMapY $f1.f.y $f1.f.y2 $f1.f.yN -sticky nw -padx 2
1867
1868  frame $f1.f1 -width 25
1869  grid $f1.f1 $f1.lColor     $f1.fColor      $f1.lDashes $f1.sbDashes -sticky nw -padx 2
1870  grid ^      $f1.lLineWidth $f1.sbLineWidth $f1.chMinor -            -sticky nw -padx 2
1871  grid ^      $f1.f          -               -           -            -sticky nw -padx 2
1872
1873  grid rowconfigure    $f1 2 -weight 1
1874  grid columnconfigure $f1 4 -weight 1
1875  grid columnconfigure $f1 2 -pad 20
1876
1877  grid $w.tf1 -sticky news -padx 2
1878  grid rowconfigure       $w 0 -weight 1
1879  grid columnconfigure    $w 0 -weight 1
1880
1881}
1882
1883
1884#/////////////////////////////////////////////////////////////////////////////   
1885proc ::bayesGraph::GrapOptCreateLegend {this w} {
1886#
1887#/////////////////////////////////////////////////////////////////////////////   
1888  variable tmpOpt
1889  TitleFrame $w.tf1 -text [mc "Legend options"]
1890  set f1 [$w.tf1 getframe]
1891
1892  checkbutton $f1.chHide -text [mc "Hide legend"] -padx 0 -pady 0\
1893    -highlightthickness 0 -variable ::bayesGraph::tmpOpt(var,legend,Hide)
1894  label $f1.lRows -text [mc "Rows"]:
1895  SpinBox $f1.sbRows -range {0 16} -width 4 -justify right\
1896      -editable false -textvariable ::bayesGraph::tmpOpt(var,legend,Rows)
1897  label $f1.lColumns -text [mc "Columns"]:
1898  SpinBox $f1.sbColumns -range {0 16} -width 4 -justify right\
1899      -editable false -textvariable ::bayesGraph::tmpOpt(var,legend,Columns)
1900
1901  label $f1.lFont -text [mc "Font"]:
1902  bfont $f1.bFont -variable ::bayesGraph::tmpOpt(var,legend,Font)
1903  label $f1.lFg -text [mc "Color"]:
1904  bcolor $f1.fFg -variable ::bayesGraph::tmpOpt(var,legend,Fg)
1905  label $f1.lShadow -text [mc "Shadow"]:
1906  bcolor $f1.fShadow -variable ::bayesGraph::tmpOpt(var,legend,Shadow) \
1907    -label "[mc "Change Shadow"]:" -optmenu 1 
1908
1909  label $f1.lBg -text [mc "Background"]:
1910  bcolor $f1.fBg -variable ::bayesGraph::tmpOpt(var,legend,Bg) -optmenu 1 
1911  set list {flat groove raised ridge solid sunken}
1912  foreach it $list { lappend values [mc $it] }
1913  label $f1.lRelief -text [mc Relief]:
1914  ComboBox $f1.cbRelief -width 10 -height 5 -editable false\
1915     -values $values -justify right\
1916     -modifycmd   [list ::Objects::ComboUnTranslate $f1.cbRelief $list\
1917      ::bayesGraph::tmpOpt(var,legend,Relief)]
1918  ::Objects::ComboSetIni  $f1.cbRelief $list ::bayesGraph::tmpOpt(var,legend,Relief)
1919  label $f1.lBd -text [mc "Border width"]:
1920  SpinBox $f1.sbBd -range {0 6} -width 4 -justify right\
1921      -editable false -textvariable ::bayesGraph::tmpOpt(var,legend,Bd)
1922
1923  label $f1.lPosi -text [mc "Position"]:
1924  #set list {leftmargin rightmargin topmargin bottommargin plotarea}
1925  set list {left right top bottom plotarea}
1926  set values {}
1927  foreach it $list { lappend values [mc $it] }
1928  ComboBox $f1.cbPosi -width 8 -height 5 -editable false\
1929     -values $values -justify right\
1930     -modifycmd   [list ::Objects::ComboUnTranslate $f1.cbPosi $list\
1931      ::bayesGraph::tmpOpt(var,legend,Position)]
1932  ::Objects::ComboSetIni  $f1.cbPosi $list ::bayesGraph::tmpOpt(var,legend,Position) 
1933  label $f1.lAnchor -text [mc Anchor]:
1934  ::Objects::ComboPosCreate ::bayesGraph::tmpOpt(var,legend,Anchor) $f1.fAnchor
1935  checkbutton $f1.chRaised -text [mc "Raised"]\
1936     -highlightthickness 0 -pady 0 -padx 0 -variable ::bayesGraph::tmpOpt(var,legend,Raised)
1937
1938  label $f1.lXPad -text [mc "X pad (left | right)"]
1939  label $f1.lYPad -text [mc "Y pad (top | bottom)"]
1940
1941  label $f1.lIX  -text [mc "Internal"]:
1942  label $f1.lEX  -text [mc "External"]:
1943  label $f1.lIY  -text [mc "Internal"]:
1944  label $f1.lEY  -text [mc "External"]:
1945  SpinBox $f1.sbIPadXl -range {0 50} -width 3 -justify right\
1946      -editable false -textvariable ::bayesGraph::tmpOpt(var,legend,IPadXl)
1947  SpinBox $f1.sbIPadXr -range {0 50} -width 3 -justify right\
1948      -editable false -textvariable ::bayesGraph::tmpOpt(var,legend,IPadXr)
1949  SpinBox $f1.sbIPadYt -range {0 50} -width 3 -justify right\
1950      -editable false -textvariable ::bayesGraph::tmpOpt(var,legend,IPadYt)
1951  SpinBox $f1.sbIPadYb -range {0 50} -width 3 -justify right\
1952      -editable false -textvariable ::bayesGraph::tmpOpt(var,legend,IPadYb)
1953  SpinBox $f1.sbPadXl  -range {0 50} -width 3 -justify right\
1954      -editable false -textvariable ::bayesGraph::tmpOpt(var,legend,PadXl)
1955  SpinBox $f1.sbPadXr  -range {0 50} -width 3 -justify right\
1956      -editable false -textvariable ::bayesGraph::tmpOpt(var,legend,PadXr)
1957  SpinBox $f1.sbPadYt  -range {0 50} -width 3 -justify right\
1958      -editable false -textvariable ::bayesGraph::tmpOpt(var,legend,PadYt)
1959  SpinBox $f1.sbPadYb  -range {0 50} -width 3 -justify right\
1960      -editable false -textvariable ::bayesGraph::tmpOpt(var,legend,PadYb)
1961 
1962  frame $f1.f -width 15
1963  grid $f1.f $f1.chHide -          $f1.lRows   $f1.sbRows   - $f1.lColumns $f1.sbColumns - -sticky nw -padx 2
1964  grid ^     $f1.lFont  $f1.bFont  $f1.lFg     $f1.fFg      - $f1.lShadow  $f1.fShadow   - -sticky nw -padx 2
1965  grid ^     $f1.lBg    $f1.fBg    $f1.lRelief $f1.cbRelief - $f1.lBd      $f1.sbBd      - -sticky nw -padx 2
1966  grid ^     $f1.lPosi  $f1.cbPosi $f1.lAnchor $f1.fAnchor  - $f1.chRaised -             - -sticky nw -padx 2
1967  grid ^     $f1.lXPad  -  $f1.lIX $f1.sbIPadXl $f1.sbIPadXr $f1.lEX $f1.sbPadXl $f1.sbPadXr  -sticky nw -padx 2
1968  grid ^     $f1.lYPad  -  $f1.lIY $f1.sbIPadYt $f1.sbIPadYb $f1.lEY $f1.sbPadYt $f1.sbPadYb  -sticky nw -padx 2
1969
1970  grid rowconfigure    $f1 5 -weight 1
1971  grid columnconfigure $f1 8 -weight 1
1972  grid columnconfigure $f1 2 -pad 20
1973  grid columnconfigure $f1 5 -pad 20
1974  grid columnconfigure $f1 8 -pad 20
1975
1976  grid $w.tf1 -sticky news -padx 2
1977  grid rowconfigure       $w 0 -weight 1
1978  grid columnconfigure    $w 0 -weight 1
1979}
1980
1981
1982#/////////////////////////////////////////////////////////////////////////////   
1983proc ::bayesGraph::GrapOptCreateStyle {this w} {
1984#
1985#/////////////////////////////////////////////////////////////////////////////   
1986  variable tmpOpt
1987 
1988  # Main title
1989  TitleFrame $w.tf0 -text [mc "Main title"]
1990  set f0 [$w.tf0 getframe]
1991  ::bayesGraph::GrapOptCreateTitles \
1992    $this $f0 [list title font foreground shadow]
1993 
1994  grid $w.tf0    -sticky news -padx 2
1995  grid rowconfigure    $f0 0 -weight 1
1996  grid columnconfigure $f0 0 -weight 1
1997 
1998  # Exterior area
1999  TitleFrame $w.tf1 -text [mc "Exterior Area"]
2000  set f1 [$w.tf1 getframe]
2001  label $f1.lBg -text [mc "Background"]:
2002  bcolor $f1.fBg -variable ::bayesGraph::tmpOpt(var,background)
2003  set list {flat groove raised ridge solid sunken}
2004  foreach it $list { lappend values [mc $it] }
2005  label $f1.lRelief -text [mc Relief]:
2006  ComboBox $f1.cbRelief -width 10 -height 5 -editable false\
2007     -values $values -justify right\
2008     -modifycmd   [list ::Objects::ComboUnTranslate $f1.cbRelief $list\
2009      ::bayesGraph::tmpOpt(var,relief)]
2010  ::Objects::ComboSetIni  $f1.cbRelief $list ::bayesGraph::tmpOpt(var,relief)
2011  label $f1.lBd -text [mc "Border width"]:
2012  SpinBox $f1.sbBd -range {0 6} -width 4 -justify right\
2013      -editable false -textvariable ::bayesGraph::tmpOpt(var,areaborderwidth)
2014  label $f1.lMargins -text "[mc MARGINS]"
2015  label $f1.lDesc -text "(0=[mc auto])"
2016  label $f1.lLM -text [mc Left]:
2017  Entry $f1.eLM -validate key -vcmd {expr {[string is integer %P]}}\
2018     -width 10 -justify right -textvariable ::bayesGraph::tmpOpt(var,lm)
2019  label $f1.lRM -text [mc Right]:
2020  Entry $f1.eRM -validate key -vcmd {expr {[string is integer %P]}}\
2021     -width 10 -justify right -textvariable ::bayesGraph::tmpOpt(var,rm)
2022  label $f1.lTM -text [mc Top]:
2023  Entry $f1.eTM -validate key -vcmd {expr {[string is integer %P]}}\
2024     -width 10 -justify right -textvariable ::bayesGraph::tmpOpt(var,tm)
2025  label $f1.lBM -text [mc Bottom]:
2026  Entry $f1.eBM -validate key -vcmd {expr {[string is integer %P]}}\
2027     -width 10 -justify right -textvariable ::bayesGraph::tmpOpt(var,bm)
2028
2029  frame $f1.f -width 25
2030  grid $f1.f $f1.lBg      $f1.fBg $f1.lRelief $f1.cbRelief $f1.lBd  $f1.sbBd  -sticky nw -padx 2
2031  grid ^     $f1.lMargins -       $f1.lLM     $f1.eLM      $f1.lRM  $f1.eRM   -sticky nw -padx 2
2032  grid ^     $f1.lDesc    -       $f1.lTM     $f1.eTM      $f1.lBM  $f1.eBM   -sticky nw -padx 2
2033
2034  grid rowconfigure    $f1 2 -weight 1
2035  grid columnconfigure $f1 6 -weight 1
2036  grid columnconfigure $f1 2 -pad 20
2037  grid columnconfigure $f1 4 -pad 20
2038  grid columnconfigure $f1 6 -pad 20
2039
2040  TitleFrame $w.tf2 -text [mc "Plot Area"]
2041  set f2 [$w.tf2 getframe]
2042
2043  label $f2.lBg -text [mc "Background"]:
2044  bcolor $f2.fBg -variable ::bayesGraph::tmpOpt(var,plotbackground)
2045  set list {flat groove raised ridge solid sunken}
2046  set values {}
2047  foreach it $list { lappend values [mc $it] }
2048  label $f2.lRelief -text [mc Relief]:
2049  ComboBox $f2.cbRelief -width 10 -height 5 -editable false\
2050     -values $values -justify right\
2051     -modifycmd   [list ::Objects::ComboUnTranslate $f2.cbRelief $list\
2052      ::bayesGraph::tmpOpt(var,plotrelief)]
2053  ::Objects::ComboSetIni  $f2.cbRelief $list ::bayesGraph::tmpOpt(var,plotrelief)
2054  label $f2.lBd -text [mc "Border width"]:
2055  SpinBox $f2.sbBd -range {0 6} -width 4 -justify right\
2056      -editable false -textvariable ::bayesGraph::tmpOpt(var,plotborderwidth)
2057  label $f2.lPad -text [mc "PAD"]
2058  label $f2.lPadXl -text [mc Left]:
2059  SpinBox $f2.sbPadXl -range {0 20} -width 3 -justify right\
2060      -editable false -textvariable ::bayesGraph::tmpOpt(var,plotpadxl)
2061  label $f2.lPadXr -text [mc Right]:
2062  SpinBox $f2.sbPadXr -range {0 20} -width 3 -justify right\
2063      -editable false -textvariable ::bayesGraph::tmpOpt(var,plotpadxr)
2064  label $f2.lPadYt -text [mc Top]:
2065  SpinBox $f2.sbPadYt -range {0 20} -width 3 -justify right\
2066      -editable false -textvariable ::bayesGraph::tmpOpt(var,plotpadyt)
2067  label $f2.lPadYb -text [mc Bottom]:
2068  SpinBox $f2.sbPadYb -range {0 20} -width 3 -justify right\
2069      -editable false -textvariable ::bayesGraph::tmpOpt(var,plotpadyb)
2070
2071  checkbutton $f2.chInvertxy -text [mc "Invert X-Y axis"]\
2072     -highlightthickness 0 -pady 0 -padx 0 -variable ::bayesGraph::tmpOpt(var,invertxy)
2073
2074  frame $f2.f -width 25
2075  grid $f2.f $f2.lBg   $f2.fBg $f2.lRelief $f2.cbRelief $f2.lBd    $f2.sbBd    -sticky nw -padx 2
2076  grid ^     $f2.lPad  -       $f2.lPadXl  $f2.sbPadXl  $f2.lPadXr $f2.sbPadXr -sticky nw -padx 2
2077  grid ^     ^         ^       $f2.lPadYt  $f2.sbPadYt  $f2.lPadYb $f2.sbPadYb -sticky nw -padx 2
2078  grid ^     $f2.chInvertxy - - - - - -sticky nw -padx 2
2079
2080  grid rowconfigure    $f2 3 -weight 1
2081  grid columnconfigure $f2 6 -weight 1
2082  grid columnconfigure $f2 2 -pad 20
2083  grid columnconfigure $f2 4 -pad 20
2084  grid columnconfigure $f2 6 -pad 20
2085
2086  grid $w.tf0 -sticky news -padx 2
2087  grid $w.tf1 -sticky news -padx 2
2088  grid $w.tf2 -sticky news -padx 2
2089  grid rowconfigure       $w 0 -weight 1
2090  grid rowconfigure       $w 1 -weight 2
2091  grid rowconfigure       $w 2 -weight 3
2092  grid columnconfigure    $w 0 -weight 1
2093}
2094
2095
2096#/////////////////////////////////////////////////////////////////////////////
2097  proc ::bayesGraph::GrapOptGet {this} {
2098#
2099# PURPOSE: Initializes all options variables and stores them into the
2100#          temporary 'tmpOpt' array.
2101#
2102# PARAMETERS:
2103#   this   -> Instance of BayesGraph
2104#
2105#/////////////////////////////////////////////////////////////////////////////
2106  GrapOptGetAxis    $this
2107  GrapOptGetTitles  $this
2108  GrapOptGetLines   $this
2109#  GrapOptGetData    $this
2110  GrapOptGetMarkers $this
2111  GrapOptGetGrid    $this
2112  GrapOptGetLegend  $this
2113  GrapOptGetStyle   $this
2114  #GrapOptSet $this
2115}
2116
2117#/////////////////////////////////////////////////////////////////////////////
2118  proc ::bayesGraph::GrapOptGetAxis {this} {
2119#
2120# PURPOSE: Initializes axis options variables and stores them into the
2121#          temporary 'tmpOpt' array.
2122#
2123# PARAMETERS:
2124#   this   -> Instance of BayesGraph
2125#
2126#/////////////////////////////////////////////////////////////////////////////
2127  upvar \#0 ${this}::data data
2128  upvar \#0 ${this}::options opt
2129  variable tmpOpt
2130  set gr $data(gr,active)
2131  set g [getActiveGraph $this]
2132 
2133  # opciones recogidas del grafico
2134  foreach axis {x y x2 y2} {
2135    set tmpOpt(var,${axis}AxisMin)     [$g axis cget $axis -min]
2136    set tmpOpt(var,${axis}AxisMax)     [$g axis cget $axis -max]
2137    set tmpOpt(var,${axis}TicksWidth)  [$g axis cget $axis -linewidth]
2138    set tmpOpt(var,${axis}TicksShow)   [$g axis cget $axis -showticks]
2139    set tmpOpt(var,${axis}TicksStep)   [$g axis cget $axis -stepsize]
2140    set tmpOpt(var,${axis}TicksFont)   [$g axis cget $axis -tickfont]
2141    set tmpOpt(var,${axis}TicksRotate) [$g axis cget $axis -rotate]
2142    set tmpOpt(var,${axis}TicksColor)  [$g axis cget $axis -color]
2143    set tmpOpt(var,${axis}TicksShadow) [lindex [$g axis cget $axis -tickshadow] 0]
2144    set tmpOpt(var,${axis}TicksLength) [$g axis cget $axis -ticklength]
2145    set tmpOpt(var,${axis}TicksSubdivisions) [$g axis cget $axis -subdivisions]
2146  }
2147
2148  #Estas opciones deben venir del ini
2149  foreach axis {x y x2 y2} {
2150    set tmpOpt(var,${axis}AxisAll)        $opt(gr,$gr,${axis}AxisAll)
2151    set tmpOpt(var,${axis}AxisShow)       $opt(gr,$gr,${axis}AxisShow)
2152    set tmpOpt(var,${axis}TicksType)      $opt(gr,$gr,${axis}TicksType)
2153    set tmpOpt(var,${axis}TicksTotal)     $opt(gr,$gr,${axis}TicksTotal)
2154    set tmpOpt(var,${axis}TicksStep)      $opt(gr,$gr,${axis}TicksStep)
2155    set tmpOpt(var,${axis}FormatNumber)   $opt(gr,$gr,${axis}FormatNumber)
2156    set tmpOpt(var,${axis}FormatPercent)  $opt(gr,$gr,${axis}FormatPercent)
2157  }
2158 
2159  # comprobamos valor maximo y minimo con opcion "Todos los valores"
2160  foreach axis {x y x2 y2} {
2161    if {$tmpOpt(var,${axis}AxisAll)} {
2162      set values [::bayesGraph::GetLimitsValueAxis $this $axis]
2163      if {![string eq $tmpOpt(var,${axis}AxisMin) [lindex $values 0]] || \
2164            ![string eq $tmpOpt(var,${axis}AxisMin) [lindex $values 0]]} {
2165        set tmpOpt(var,${axis}AxisAll) 0
2166      }
2167    }
2168  }
2169  # Ajust axis chart of values
2170  set tmpOpt(var,selffit)  $opt(gr,$gr,selffit)
2171}
2172
2173
2174#/////////////////////////////////////////////////////////////////////////////   
2175proc ::bayesGraph::GrapOptGetTitles {this} {
2176#
2177#/////////////////////////////////////////////////////////////////////////////   
2178  upvar \#0 ${this}::data data
2179  upvar \#0 ${this}::options opt
2180  variable tmpOpt
2181  set gr $data(gr,active)
2182  set g [getActiveGraph $this]
2183
2184  set tmpOpt(var,title)          [$g cget -title]
2185  set tmpOpt(var,font)           [$g cget -font]
2186  set tmpOpt(var,foreground)     [$g cget -foreground]
2187  set tmpOpt(var,shadow)         [lindex [$g cget -shadow] 0]
2188
2189  foreach pre {x y x2 y2} {
2190    set tmpOpt(var,${pre}AxisTitle) $opt(gr,$gr,${pre}AxisTitle)
2191    foreach post {Color Font Shadow} {
2192      set tmpOpt(var,${pre}Axis${post}) $opt(gr,$gr,${pre}Axis${post})
2193    }
2194  }
2195}
2196
2197
2198#/////////////////////////////////////////////////////////////////////////////   
2199proc ::bayesGraph::GrapOptGetLines {this} {
2200#
2201#/////////////////////////////////////////////////////////////////////////////
2202  upvar \#0 ${this}::data data
2203  upvar \#0 ${this}::options opt
2204  variable tmpOpt
2205
2206  variable optLinesAll
2207 
2208  set gr $data(gr,active)
2209  set g [getActiveGraph $this]
2210
2211  # options general
2212  set tmpOpt(var,barmode) $opt(gr,$gr,barmode)
2213  # optiones lines & bar
2214  foreach key $optLinesAll {
2215    set tmpOpt(var,$key) $opt(gr,$gr,$key) 
2216  }
2217  # names lines
2218  set tmpOpt(var,lstnames) $opt(gr,$gr,lstnames)
2219}
2220
2221
2222#/////////////////////////////////////////////////////////////////////////////
2223proc ::bayesGraph::ShowOptLines {this nline} {
2224#
2225#/////////////////////////////////////////////////////////////////////////////
2226  upvar \#0 ${this}::widgets widgets
2227  variable tmpOpt
2228  variable optLines
2229 
2230  # options general
2231  set idx [expr $nline - 1]
2232  foreach key $optLines {
2233    set tmpOpt(var,${key}_) [lindex $tmpOpt(var,$key) $idx]
2234  }
2235  # axis
2236  set xy [lindex $tmpOpt(var,xyMappedAxis) $idx]
2237  set tmpOpt(var,xMappedAxis_) [lindex $xy 0]
2238  set tmpOpt(var,yMappedAxis_) [lindex $xy 1]
2239  # Name line. Note: label -> 3
2240  foreach id [$widgets(lines,lst) get] {
2241    if {[string equal [$widgets(lines,lst) get $id id] $nline]} {
2242      set idLb $id
2243    }
2244  } 
2245  set tmpOpt(var,linelabels_) [lindex [$widgets(lines,lst) get $idLb label] 0]
2246}
2247
2248
2249#/////////////////////////////////////////////////////////////////////////////
2250proc ::bayesGraph::ShowSelectLines {this} {
2251#
2252#/////////////////////////////////////////////////////////////////////////////
2253  upvar \#0 ${this}::data data
2254  upvar \#0 ${this}::widgets widgets
2255  variable tmpOpt
2256 
2257  # get info now
2258  set linSel {}
2259  set idSel  [$widgets(lines,lst) selection get]
2260  foreach id $idSel {
2261    lappend linSel [$widgets(lines,lst) get $id id]
2262  }
2263 
2264  # check exists selection prior ?
2265  if {[info exists data(lines,selectant)] && \
2266      [llength $data(lines,selectant)]} {
2267    ::bayesGraph::GrapOptSetLines $this $data(lines,selectant)
2268  }
2269
2270  # select prior
2271  set data(lines,selectant)   $linSel
2272
2273  if {[llength data(lines,selectant)]} {
2274    ::bayesGraph::ShowOptLines $this $linSel
2275  } 
2276}
2277
2278
2279#/////////////////////////////////////////////////////////////////////////////
2280proc ::bayesGraph::GrapOptSetLines {this lstlines} {
2281#
2282#/////////////////////////////////////////////////////////////////////////////
2283  upvar \#0 ${this}::widgets widgets
2284  variable tmpOpt
2285  variable optLines
2286
2287  foreach idx $lstlines {
2288    set i [expr $idx - 1]
2289    # options general
2290    foreach key $optLines {
2291      set tmpOpt(var,$key) \
2292        [lreplace $tmpOpt(var,$key) $i $i $tmpOpt(var,${key}_)]
2293    }
2294    # axis
2295    set tmpOpt(var,xyMappedAxis) [lreplace $tmpOpt(var,xyMappedAxis) $i $i \
2296      "$tmpOpt(var,xMappedAxis_) $tmpOpt(var,yMappedAxis_)"]
2297
2298    # Line name
2299    foreach id [$widgets(lines,lst) get] {
2300      if {[string equal [$widgets(lines,lst) get $id id] $idx]} {
2301        set idLb $id
2302      }
2303    }
2304    if {[string length $tmpOpt(var,linelabels_)]} {
2305      set name $tmpOpt(var,linelabels_)
2306    } else {
2307      set name [$widgets(lines,lst) get $idLb caption]
2308    }
2309    $widgets(lines,lst) set $idLb [list $name] label
2310  }
2311 
2312  # new List Names with order
2313  set tmpOpt(var,lstnames) {}
2314  foreach id [$widgets(lines,lst) get] {
2315    lappend tmpOpt(var,lstnames) [$widgets(lines,lst) get $id]
2316  }
2317}
2318
2319
2320#/////////////////////////////////////////////////////////////////////////////   
2321proc ::bayesGraph::GrapOptGetMarkers {this} {
2322#
2323#/////////////////////////////////////////////////////////////////////////////   
2324  upvar \#0 ${this}::data data
2325  upvar \#0 ${this}::options opt
2326  variable tmpOpt
2327  set gr $data(gr,active)
2328
2329  #Estas opciones deben venir del ini
2330  set tmpOpt(var,xMarkers)     $opt(gr,$gr,xMarkers)
2331  set tmpOpt(var,yMarkers)     $opt(gr,$gr,yMarkers)
2332  set tmpOpt(var,xMarkersIn)   $opt(gr,$gr,xMarkersIn)
2333  set tmpOpt(var,yMarkersIn)   $opt(gr,$gr,yMarkersIn)
2334  set tmpOpt(var,x2Markers)    $opt(gr,$gr,x2Markers)
2335  set tmpOpt(var,y2Markers)    $opt(gr,$gr,y2Markers)
2336  set tmpOpt(var,x2MarkersIn)  $opt(gr,$gr,x2MarkersIn)
2337  set tmpOpt(var,y2MarkersIn)  $opt(gr,$gr,y2MarkersIn)
2338
2339  foreach axis {x x2 y y2} {
2340    set i 0
2341    foreach color $opt(gr,$gr,${axis}MarkersColorsInEach) {
2342      set tmpOpt(var,${axis}MarkerColorInEach$i) $color
2343      incr i
2344    }
2345    set i 0
2346    foreach width $opt(gr,$gr,${axis}MarkersWidthsInEach) {
2347      set tmpOpt(var,${axis}MarkerWidthInEach$i) $width
2348      incr i
2349    }
2350    set i 0
2351    foreach dashes $opt(gr,$gr,${axis}MarkersDashesInEach) {
2352      set tmpOpt(var,${axis}MarkerDasheInEach$i) $dashes
2353      incr i
2354    }
2355    set i 0
2356    foreach under $opt(gr,$gr,${axis}MarkersUndersInEach) {
2357      set tmpOpt(var,${axis}MarkerUnderInEach$i) $under
2358      incr i
2359    }
2360
2361  }
2362}
2363
2364
2365#/////////////////////////////////////////////////////////////////////////////   
2366proc ::bayesGraph::GrapOptGetGrid {this} {
2367#
2368#/////////////////////////////////////////////////////////////////////////////   
2369  upvar \#0 ${this}::data data
2370  upvar \#0 ${this}::options opt
2371  set gr $data(gr,active)
2372  set g [getActiveGraph $this]
2373  variable tmpOpt
2374
2375  #  Al coger las opciones de opt, perdemos la opcion de que las opciones
2376  # muestren los cambios hechos desde otro lugar (TkConsole, p.ejemplo)
2377  # pero bueno...
2378  foreach it {Color Dashes LineWidth Minor MapX MapY} {
2379    set tmpOpt(var,grid,$it) $opt(gr,$gr,grid,$it)
2380  }
2381}
2382
2383
2384#/////////////////////////////////////////////////////////////////////////////   
2385proc ::bayesGraph::GrapOptGetLegend {this} {
2386#
2387#/////////////////////////////////////////////////////////////////////////////   
2388  upvar \#0 ${this}::data data
2389  upvar \#0 ${this}::options opt
2390  set gr $data(gr,active)
2391  set g [getActiveGraph $this]
2392  variable tmpOpt
2393
2394  set tmpOpt(var,legend,Hide)     [$g legend cget -hide]
2395  set tmpOpt(var,legend,Bg)       [$g legend cget -bg]
2396  set tmpOpt(var,legend,Bd)       [$g legend cget -bd]
2397  set tmpOpt(var,legend,Fg)       [$g legend cget -fg]
2398  set tmpOpt(var,legend,Font)     [$g legend cget -font]
2399  set tmpOpt(var,legend,Shadow)   [lindex [$g legend cget -shadow] 0]
2400  set tmpOpt(var,legend,Position) $opt(gr,$gr,legend,Position)
2401  set tmpOpt(var,legend,Anchor)   [$g legend cget -anchor]
2402  set tmpOpt(var,legend,Relief)   [$g legend cget -relief]
2403  set tmpOpt(var,legend,Raised)   [$g legend cget -raised]
2404  set tmpOpt(var,legend,IPadXl)   [lindex [$g legend cget -ipadx] 0]
2405  set tmpOpt(var,legend,IPadXr)   [lindex [$g legend cget -ipadx] 1]
2406  set tmpOpt(var,legend,IPadYt)   [lindex [$g legend cget -ipady] 0]
2407  set tmpOpt(var,legend,IPadYb)   [lindex [$g legend cget -ipady] 1]
2408  set tmpOpt(var,legend,PadXl)    [lindex [$g legend cget -padx] 0]
2409  set tmpOpt(var,legend,PadXr)    [lindex [$g legend cget -padx] 1]
2410  set tmpOpt(var,legend,PadYt)    [lindex [$g legend cget -pady] 0]
2411  set tmpOpt(var,legend,PadYb)    [lindex [$g legend cget -pady] 1]
2412  set tmpOpt(var,legend,Rows)     [$g legend cget -rows]
2413  set tmpOpt(var,legend,Columns)  [$g legend cget -columns]
2414}
2415
2416
2417#/////////////////////////////////////////////////////////////////////////////   
2418proc ::bayesGraph::GrapOptGetStyle {this} {
2419#
2420#/////////////////////////////////////////////////////////////////////////////   
2421  upvar \#0 ${this}::data data
2422  upvar \#0 ${this}::options opt
2423  variable tmpOpt
2424  set gr $data(gr,active)
2425  set g [getActiveGraph $this]
2426
2427  foreach it {background relief lm rm tm bm} {
2428    set tmpOpt(var,$it)     [$g cget -$it]
2429  }
2430  foreach it {plotbackground plotrelief plotborderwidth} {
2431    set tmpOpt(var,$it)     [$g cget -$it]
2432  }
2433 
2434  set tmpOpt(var,areaborderwidth)  [$g cget -borderwidth]
2435
2436  set tmpOpt(var,invertxy)  $opt(gr,$gr,invertxy)
2437  set tmpOpt(var,plotpadxl) [lindex [$g cget -plotpadx] 0]
2438  set tmpOpt(var,plotpadxr) [lindex [$g cget -plotpadx] 1]
2439  set tmpOpt(var,plotpadyt) [lindex [$g cget -plotpady] 0]
2440  set tmpOpt(var,plotpadyb) [lindex [$g cget -plotpady] 1]
2441}
2442
2443
2444#/////////////////////////////////////////////////////////////////////////////
2445  proc ::bayesGraph::GrapOptSet {this} {
2446#
2447# PURPOSE: Commits all options values from the temporary 'tmpOpt' array to
2448#          other structure.
2449#
2450# PARAMETERS:
2451#   this   -> Instance of BayesGraph
2452#
2453#/////////////////////////////////////////////////////////////////////////////
2454  upvar \#0 ${this}::widgets widgets
2455  upvar \#0 ${this}::data data
2456  upvar \#0 ${this}::options options
2457
2458  variable tmpOpt
2459
2460  set gr $data(gr,active)
2461 
2462  # options axis
2463  foreach axis {x x2 y y2} {
2464    set tmpOpt(var,${axis}MarkersColorsInEach) {}
2465    set tmpOpt(var,${axis}MarkersWidthsInEach) {}
2466    set tmpOpt(var,${axis}MarkersDashesInEach) {}
2467    set tmpOpt(var,${axis}MarkersUndersInEach) {}
2468  }
2469  # options axis list
2470  foreach axis {x x2 y y2} {
2471    for {set i 0} {$i<5} {incr i} {
2472      lappend tmpOpt(var,${axis}MarkersColorsInEach) \
2473        $tmpOpt(var,${axis}MarkerColorInEach$i)
2474      lappend tmpOpt(var,${axis}MarkersWidthsInEach) \
2475        $tmpOpt(var,${axis}MarkerWidthInEach$i)
2476      lappend tmpOpt(var,${axis}MarkersDashesInEach) \
2477        $tmpOpt(var,${axis}MarkerDasheInEach$i)
2478      lappend tmpOpt(var,${axis}MarkersUndersInEach) \
2479        $tmpOpt(var,${axis}MarkerUnderInEach$i)
2480    }
2481  }
2482
2483  regsub -all var, [array names ::bayesGraph::tmpOpt var,*] "" optNames
2484
2485  foreach it $optNames {
2486    set options(gr,$gr,$it) $tmpOpt(var,$it)
2487  }
2488  #Ya no se usa
2489  set options(gr,${gr}_INIT)  YES
2490}
2491
2492
2493#/////////////////////////////////////////////////////////////////////////////
2494  proc ::bayesGraph::GrapOptInit {this} {
2495#
2496# PURPOSE:
2497#
2498# PARAMETERS:
2499#   this   -> Instance of BayesGraph
2500#
2501#/////////////////////////////////////////////////////////////////////////////
2502upvar \#0 ${this}::data data
2503  variable tmpOpt
2504  set gr $data(gr,active)
2505  set values [::bayesGraph::GetLimitsValueAxis $this x]
2506  if {[string is double $tmpOpt(var,xyAxisMin)] && \
2507      $tmpOpt(var,xyAxisMin) <= [lindex $values 0]} {
2508    $tmpOpt(widget,xyAxisMin) setvalue  first
2509    set tmpOpt(var,xyAxisMin) [$tmpOpt(widget,xyAxisMin) getvalue]
2510  }
2511  if {[string is double $tmpOpt(var,xyAxisMax)] && \
2512      $tmpOpt(var,xyAxisMax) >= [lindex $values 1]} {
2513    $tmpOpt(widget,xyAxisMax) setvalue  last
2514    set tmpOpt(var,xyAxisMax) [$tmpOpt(widget,xyAxisMax) getvalue]
2515  }
2516}
2517
2518
2519#/////////////////////////////////////////////////////////////////////////////   
2520proc ::bayesGraph::GrapOptApplyAll {this} {
2521#
2522#/////////////////////////////////////////////////////////////////////////////   
2523  upvar \#0 ${this}::data data
2524  set old_active $data(gr,active)
2525  for {set gr 0} {$gr<$data(gr,numGraph)} {incr gr} {
2526    set data(gr,active) $gr
2527    GrapOptApply $this
2528  }
2529  set data(gr,active) $old_active
2530}
2531
2532
2533#/////////////////////////////////////////////////////////////////////////////   
2534proc ::bayesGraph::GrapOptApply {this} {
2535#
2536#/////////////////////////////////////////////////////////////////////////////   
2537  upvar \#0 ${this}::data data
2538  upvar \#0 ${this}::options opt
2539
2540  set gr $data(gr,active)
2541  set g [getActiveGraph $this]
2542  variable tmpOpt
2543  upvar \#0 ${this}::widgets widgets
2544
2545  # leemos los valores actuales de los ejes activos en el formulario
2546  ShowAxisSelectXY $this
2547  # leemos los valores actuales de la linea marcada
2548  set linSel {}
2549  foreach id [$widgets(lines,lst) selection get] {
2550    lappend linSel [$widgets(lines,lst) get $id id]
2551  } 
2552  GrapOptSetLines         $this $linSel
2553  # options
2554  GrapOptApplyMappedLines $this ::bayesGraph::tmpOpt var
2555  #Debe ir antes de calcular el step pq cambia rotate
2556  GrapOptApplyTicksStyle $this ::bayesGraph::tmpOpt var
2557  GrapOptApplyAxisPos    $this ::bayesGraph::tmpOpt var
2558  GrapOptApplyAxisTicks  $this ::bayesGraph::tmpOpt var
2559  GrapOptApplyTitles     $this ::bayesGraph::tmpOpt var
2560
2561  GrapOptApplyLnesAll    $this ::bayesGraph::tmpOpt var
2562 
2563  GrapOptApplyMarkers    $this ::bayesGraph::tmpOpt var
2564  GrapOptApplyMarkersIn  $this ::bayesGraph::tmpOpt var
2565
2566  GrapOptApplyGrid       $this ::bayesGraph::tmpOpt var,grid
2567  GrapOptApplyLegend     $this ::bayesGraph::tmpOpt var,legend
2568  GrapOptApplyStyle      $this ::bayesGraph::tmpOpt var
2569
2570  GrapOptApplyOrder       $this ::bayesGraph::tmpOpt var
2571 
2572  # Show Line
2573  if {![info exists opt(gr,$gr,linehides)] || \
2574      ![info exists tmpOpt(::bayesGraph::tmpOpt,linehides)] || \
2575      ![string equal $opt(gr,$gr,linehides) $tmpOpt(::bayesGraph::tmpOpt,linehides)]} {
2576    GrapOptApplyLineDefault $this ::bayesGraph::tmpOpt var hide linehides
2577  } 
2578 
2579
2580  if [info exists ${this}::data(proc,OnOptionApply)] {
2581    $data(proc,OnOptionApply) $this
2582  }
2583
2584  #Save options after apply
2585  GrapOptSet $this
2586}
2587
2588
2589#/////////////////////////////////////////////////////////////////////////////
2590  proc ::bayesGraph::GrapOptApplyAxisPos {this var pre} {
2591#
2592# PURPOSE:
2593#
2594# PARAMETERS:
2595#   this   -> Instance of BayesGraph
2596#
2597#/////////////////////////////////////////////////////////////////////////////
2598  upvar \#0 $var ary
2599
2600  upvar \#0 ${this}::data data
2601#  variable tmpOpt
2602  set gr $data(gr,active)
2603  set g [getActiveGraph $this]
2604  foreach  axis {x y x2 y2} {
2605    # si esta visible
2606    if {![$g axis cget $axis -hide]} {
2607      set AXIS  [string toupper $axis]
2608      set AXI   [string index   $AXIS 0]
2609      if {$ary(${pre},${axis}AxisAll)} {
2610        set values [::bayesGraph::GetLimitsValueAxis $this $axis]
2611        set vmin   [lindex $values 0]
2612        set vmax   [lindex $values 1]
2613      } else  {
2614        set vmin $ary(${pre},${axis}AxisMin)
2615        set vmax $ary(${pre},${axis}AxisMax)
2616      }
2617      if {[info exists data(gr,$gr,OnGet${AXI}Ticks)]} {
2618        set lst [$data(gr,$gr,OnGet${AXI}Ticks) $this]
2619        if {![string is double $vmin]} {
2620          set vmin [lsearch $lst $vmin]
2621        }
2622        if {![string is double $vmax]} {
2623          set vmax [lsearch $lst $vmax]
2624        }
2625      }
2626      if {$vmin<$vmax} {
2627        ::bayesGraph::GrapOptApplyAxisLimits $this $axis $vmin $vmax
2628      }
2629    }
2630  }
2631}
2632
2633
2634#/////////////////////////////////////////////////////////////////////////////
2635  proc ::bayesGraph::GrapOptApplyAxisTicks {this var pre} {
2636#
2637# PURPOSE:
2638#
2639# PARAMETERS:
2640#   this -> Instance of BayesGraph
2641#   var  ->
2642#   pre  ->
2643#
2644#/////////////////////////////////////////////////////////////////////////////
2645  upvar \#0 $var ary
2646  set g [getActiveGraph $this]
2647  # Axis
2648  foreach axis {x x2 y y2} {
2649    set AXI  [string toupper [string index $axis 0]] 
2650    if {![$g axis cget $axis -hide]} {
2651      switch $ary(${pre},${axis}TicksType) {
2652        total {
2653          set step \
2654            [Compute${AXI}AxisStep $this \
2655                                   $ary(${pre},${axis}TicksTotal) \
2656                                   $axis]
2657        }
2658        each {
2659          if {[info exists data(proc,OnFixStep${AXI})]} {
2660            set min  [$g axis cget $axis -min]
2661            set max  [$g axis cget $axis -max]
2662            set step [$data(proc,OnFixStep{AXI}) \
2663                        $this $min $max $ary(${pre},${axis}TicksStep)]         
2664          } else  {
2665            set step $ary(${pre},${axis}TicksStep)
2666          }
2667        }
2668        auto {
2669          set nTicks [Calculate${AXI}AxisNumTicks $this         $axis]
2670          set step   [Compute${AXI}AxisStep       $this $nTicks $axis]
2671        }
2672        default {set step 1}
2673      }
2674      # Verifico si step es demasiado pequeño para los límites del eje
2675      set max [$g axis cget $axis -max]
2676      set min [$g axis cget $axis -min]
2677      set max [expr { $max eq "" ? 1 : $max }]
2678      set min [expr { $min eq "" ? 0 : $min }]
2679      set step [expr { $step eq "" ? 1 : $step }]
2680      if {($step==0) || [expr (($max-$min)/$step) < 1000 ]} {
2681        $g axis configure $axis -stepsize $step
2682      }
2683    }
2684  }
2685}
2686
2687
2688#/////////////////////////////////////////////////////////////////////////////
2689proc ::bayesGraph::GrapOptApplyAxisAuto {this} {
2690#
2691# PURPOSE:
2692#
2693# PARAMETERS:
2694#   this -> Instance of BayesGraph
2695#
2696#/////////////////////////////////////////////////////////////////////////////
2697  update
2698  set g [getActiveGraph $this]
2699  foreach axis {x x2y y2} {
2700    set AXI [string toupper [string index $axis 0]]
2701    set nTicks [Calculate${AXI}AxisNumTicks $this         $axis]
2702    set step   [Compute${AXI}AxisStep       $this $nTicks $axis]
2703    $g axis configure $axis -stepsize $step   
2704  }
2705}
2706
2707
2708#/////////////////////////////////////////////////////////////////////////////   
2709proc ::bayesGraph::GrapOptApplyTicksStyle {this var pre} {
2710#
2711#/////////////////////////////////////////////////////////////////////////////   
2712  upvar \#0 $var ary
2713  upvar \#0 ${this}::data data
2714
2715  set g [getActiveGraph $this]
2716  foreach pref {x x2 y y2} {
2717    # command axis 
2718    set cmd {}
2719    if {[info exists ${this}::data(proc,${pref}AxisCommand)]} {
2720      set cmd "$data(proc,${pref}AxisCommand)"
2721    } else {
2722      set cmd [list ::bayesGraph::FormatNumberAxis \
2723               $ary(${pre},${pref}FormatNumber) \
2724               $ary(${pre},${pref}FormatPercent)]
2725    }
2726    # configuration
2727    $g axis configure $pref \
2728        -tickfont     $ary(${pre},${pref}TicksFont)\
2729        -rotate       $ary(${pre},${pref}TicksRotate)\
2730        -color        $ary(${pre},${pref}TicksColor)\
2731        -ticklength   $ary(${pre},${pref}TicksLength)\
2732        -tickshadow   $ary(${pre},${pref}TicksShadow)\
2733        -subdivisions $ary(${pre},${pref}TicksSubdivisions)\
2734        -linewidth    $ary(${pre},${pref}TicksWidth)\
2735        -showticks    $ary(${pre},${pref}TicksShow)\
2736        -hide         [expr !$ary(${pre},${pref}AxisShow)]\
2737        -command      $cmd
2738  }
2739}
2740
2741
2742#/////////////////////////////////////////////////////////////////////////////
2743  proc ::bayesGraph::FormatNumberAxis {forNum forPer bltg tick} {
2744#
2745# PURPOSE: Aplica un formato a los valores del eje Y.
2746#
2747# PARAMETERS:
2748#   forNum  -> format number
2749#   forPer  -> format percent
2750#   gltg    -> the pathname of the widget
2751#   tick    -> current the numeric value of the tick
2752#
2753#/////////////////////////////////////////////////////////////////////////////
2754
2755  if {[string length $forNum]} {
2756      if {$forPer} {
2757      set valAux [expr $tick * 100]
2758    } else {
2759      set valAux $tick
2760    }
2761    if  {![catch {set nf [format $forNum $valAux]} res]} {
2762      return $nf
2763    } else {
2764      return $tick
2765    }
2766  } else  {
2767    return $tick
2768  }
2769}
2770
2771
2772#/////////////////////////////////////////////////////////////////////////////   
2773proc ::bayesGraph::GrapOptApplyTitles {this var pre} {
2774#
2775#/////////////////////////////////////////////////////////////////////////////   
2776  upvar \#0 $var ary
2777
2778  set g [getActiveGraph $this]
2779  if [info exist ${var}(${pre},title)] {
2780    $g configure -title           "$ary(${pre},title)"
2781  }
2782  $g configure -font         $ary(${pre},font)\
2783               -foreground   $ary(${pre},foreground)\
2784               -shadow       $ary(${pre},shadow)
2785
2786  foreach pref {x y x2 y2} {
2787    $g axis configure $pref -title       $ary(${pre},${pref}AxisTitle)\
2788                            -titlefont   $ary(${pre},${pref}AxisFont)\
2789                            -titlecolor  $ary(${pre},${pref}AxisColor)\
2790                            -titleshadow $ary(${pre},${pref}AxisShadow)
2791  }
2792}
2793
2794#/////////////////////////////////////////////////////////////////////////////   
2795proc ::bayesGraph::GrapOptApplyLnesAll {this var pre} {
2796#/////////////////////////////////////////////////////////////////////////////
2797  upvar \#0 ${this}::options opt
2798  upvar \#0 ${this}::data data
2799  variable tmpOpt
2800  variable optLinesData
2801  variable optLinesSymbol
2802  set gr $data(gr,active)
2803  set okAll 0
2804 
2805  # Line Type
2806  if {![info exists opt(gr,$gr,linetypes)] || \
2807      ![info exists tmpOpt(var,linetypes)] || \
2808      ![string equal $opt(gr,$gr,linetypes) $tmpOpt(var,linetypes)]} {
2809    GrapOptApplyLineTypes $this $var $pre
2810    set okAll 1
2811  } 
2812  # Colors
2813  if {($okAll) || \
2814      ![info exists opt(gr,$gr,colors)] || \
2815      ![info exists tmpOpt(var,colors)] || \
2816      ![string equal $opt(gr,$gr,colors) $tmpOpt(var,colors)]} {
2817    GrapOptApplyColors $this $var $pre
2818  }
2819  # Widths 
2820  if {($okAll) || \
2821      ![info exists opt(gr,$gr,linewidth)] || \
2822      ![info exists tmpOpt(var,linewidth)] || \
2823      ![string equal $opt(gr,$gr,linewidth) $tmpOpt(var,linewidth)]} {
2824    GrapOptApplyLineWidth $this $var $pre
2825  }
2826  # Dashes
2827  if {($okAll) || \
2828      ![info exists opt(gr,$gr,dashes)] || \
2829      ![info exists tmpOpt(var,dashes)] || \
2830      ![string equal $opt(gr,$gr,dashes) $tmpOpt(var,dashes)]} {
2831    GrapOptApplyDashes $this $var $pre
2832  }
2833  # Smooths
2834  if {($okAll) || \
2835      ![info exists opt(gr,$gr,smooth)] || \
2836      ![info exists tmpOpt(var,smooth)] || \
2837      ![string equal $opt(gr,$gr,smooth) $tmpOpt(var,smooth)]} {
2838    GrapOptApplySmooth $this $var $pre
2839  }
2840  # Bar mode
2841  if {($okAll) || \
2842      ![info exists opt(gr,$gr,barmode)] || \
2843      ![info exists tmpOpt(var,barmode)] || \
2844      ![string equal $opt(gr,$gr,barmode) $tmpOpt(var,barmode)]} {
2845    GrapOptApplyBarMode $this $var $pre
2846  }
2847  # Bar Width
2848  if {($okAll) || \
2849      ![info exists opt(gr,$gr,barwidth)] || \
2850      ![info exists tmpOpt(var,barwidth)] || \
2851      ![string equal $opt(gr,$gr,barwidth) $tmpOpt(var,barwidth)]} {
2852    GrapOptApplyBarWidth $this $var $pre
2853  }
2854  # Fill. Depent type line and type fill
2855  GrapOptApplyFill $this $var $pre
2856  # Datas
2857  set ok 0
2858  set optData $optLinesData
2859  foreach key $optData {
2860    if {![info exists opt(gr,$gr,$key)] || \
2861        ![info exists tmpOpt(var,$key)] || \
2862        ![string equal $opt(gr,$gr,$key) $tmpOpt(var,$key)]} {
2863      set ok 1
2864    }
2865  } 
2866  if {$ok} { GrapOptApplyShowValues $this $var $pre }
2867  # Symbol
2868  set ok 0
2869  set optSymbol $optLinesSymbol
2870  foreach key $optSymbol {
2871    if {![info exists opt(gr,$gr,$key)] || \
2872        ![info exists tmpOpt(var,$key)] || \
2873        ![string equal $opt(gr,$gr,$key) $tmpOpt(var,$key)]} {
2874      set ok 1
2875    }
2876  }
2877  if {$ok} { GrapOptApplyShowSymbols $this $var $pre }
2878  # Line Name
2879  if {![info exists opt(gr,$gr,lstnames)] || \
2880      ![info exists tmpOpt(var,lstnames)] || \
2881      ![string equal $opt(gr,$gr,lstnames) $tmpOpt(var,lstnames)]} {
2882    GrapOptApplyLineName $this $var $pre
2883  }
2884}
2885
2886
2887#/////////////////////////////////////////////////////////////////////////////
2888proc ::bayesGraph::GrapOptApplyLineName {this var pre} {
2889#
2890#/////////////////////////////////////////////////////////////////////////////
2891  upvar \#0 $var ary
2892  set g [getActiveGraph $this]
2893
2894  if {[info exists ary($pre,lstnames)]} {
2895    foreach it $ary($pre,lstnames) {
2896      $g element configure [lindex [lindex $it 1] 0] -label [lindex $it 3]
2897    }
2898  } 
2899}
2900
2901
2902#/////////////////////////////////////////////////////////////////////////////
2903proc ::bayesGraph::GrapOptApplyLineDefault {this var pre opt key} {
2904#
2905#/////////////////////////////////////////////////////////////////////////////
2906  upvar \#0 $var ary
2907  set g [getActiveGraph $this]
2908
2909  if {[info exists ary($pre,$key)]} {
2910    set j 0
2911    set lstId [GrapOptGetIdLines $this $var $pre]
2912    foreach it [GrapOptGetNamesLines $this $var $pre] {
2913      set i [expr [lindex $lstId $j] - 1]
2914      foreach e $it {
2915        $g element configure $e -$opt [lindex $ary($pre,$key) $i]
2916      }
2917      incr j
2918    }
2919  } 
2920}
2921
2922 
2923#/////////////////////////////////////////////////////////////////////////////   
2924proc ::bayesGraph::GrapOptApplyLineWidth {this var pre} {
2925#
2926#/////////////////////////////////////////////////////////////////////////////
2927  upvar \#0 $var ary
2928  set g [getActiveGraph $this]
2929
2930  set j 0
2931  set lstId [GrapOptGetIdLines $this $var $pre]
2932  foreach it [GrapOptGetNamesLines $this $var $pre] {
2933    set i [expr [lindex $lstId $j] - 1]
2934    foreach e $it {
2935      if {[string equal [$g element type $e] "LineElement"]} {
2936        $g element configure $e -linewidth [lindex $ary($pre,linewidth) $i]
2937      } else  {
2938        $g element configure $e -borderwidth [lindex $ary($pre,borderwidth) $i]
2939      }
2940    }
2941    incr j
2942  }
2943}
2944
2945
2946#/////////////////////////////////////////////////////////////////////////////   
2947proc ::bayesGraph::GrapOptApplyBarMode {this var pre} {
2948#
2949#/////////////////////////////////////////////////////////////////////////////   
2950  upvar \#0 $var ary
2951  set g [getActiveGraph $this]
2952  $g configure -barmode $ary(${pre},barmode)
2953}
2954
2955
2956#/////////////////////////////////////////////////////////////////////////////   
2957proc ::bayesGraph::GrapOptApplyBarRelief {this var pre} {
2958#
2959#/////////////////////////////////////////////////////////////////////////////   
2960  upvar \#0 $var ary
2961  set g [getActiveGraph $this]
2962   
2963  set j 0
2964  set lstId [GrapOptGetIdLines $this $var $pre]
2965  foreach it [GrapOptGetNamesLines $this $var $pre] {
2966    set i [expr [lindex $lstId $j] - 1]
2967    foreach e $it {
2968      if {[string equal [$g element type $e] "BarElement"]} {
2969        $g element configure $it -relief [lindex $ary($pre,barrelief) $i]
2970      }
2971    }
2972    incr j
2973  }
2974}
2975
2976
2977#/////////////////////////////////////////////////////////////////////////////   
2978proc ::bayesGraph::GrapOptApplyDashes {this var pre} {
2979#
2980#/////////////////////////////////////////////////////////////////////////////   
2981  upvar \#0 $var ary
2982  set g [getActiveGraph $this]
2983
2984  set j 0
2985  set lstId [GrapOptGetIdLines $this $var $pre]
2986  foreach it [GrapOptGetNamesLines $this $var $pre] {
2987    set i [expr [lindex $lstId $j] - 1]
2988    foreach e $it {
2989      if {[string equal [$g element type $e] "LineElement"]} {
2990        $g element configure $e -dashes [lindex $ary($pre,dashes) $i]
2991      }
2992    }
2993    incr j
2994  } 
2995}
2996
2997
2998#/////////////////////////////////////////////////////////////////////////////   
2999proc ::bayesGraph::GrapOptApplySmooth {this var pre} {
3000#
3001#/////////////////////////////////////////////////////////////////////////////   
3002  upvar \#0 $var ary
3003  set g [getActiveGraph $this]
3004
3005  set j 0
3006  set lstId [GrapOptGetIdLines $this $var $pre]
3007  foreach it [GrapOptGetNamesLines $this $var $pre] {
3008    set i [expr [lindex $lstId $j] - 1]
3009    foreach e $it {
3010      if {[string equal [$g element type $e] "LineElement"]} {
3011        $g element configure $e -smooth [lindex $ary($pre,smooth) $i]
3012      }
3013    }
3014    incr j
3015  }   
3016}
3017
3018
3019#/////////////////////////////////////////////////////////////////////////////   
3020proc ::bayesGraph::GrapOptApplyBarWidth {this var pre} {
3021#
3022#/////////////////////////////////////////////////////////////////////////////
3023  upvar \#0 $var ary
3024  set g [getActiveGraph $this]
3025 
3026  set j 0
3027  set lstId [GrapOptGetIdLines $this $var $pre]
3028  foreach it [GrapOptGetNamesLines $this $var $pre] {
3029    set i [expr [lindex $lstId $j] - 1]
3030    foreach e $it {
3031      if {[string equal [$g element type $e] "BarElement"]} {
3032        $g element configure $e -barwidth [lindex $ary($pre,barwidth) $i]
3033      }
3034    } 
3035    incr j
3036  }
3037}
3038
3039
3040#/////////////////////////////////////////////////////////////////////////////   
3041proc ::bayesGraph::GrapOptApplyOrder {this var pre} {
3042#
3043#/////////////////////////////////////////////////////////////////////////////   
3044  upvar \#0 $var ary
3045  set g [getActiveGraph $this]
3046  $g element show \
3047    [lreverse [join [lindex [ltraspose $ary(${pre},lstnames)] 1]]]
3048}
3049
3050
3051#/////////////////////////////////////////////////////////////////////////////   
3052proc ::bayesGraph::GrapOptApplyLineTypes {this var pre} {
3053#
3054#/////////////////////////////////////////////////////////////////////////////
3055  upvar \#0 $var ary
3056  set g [getActiveGraph $this]
3057
3058  set j 0
3059  set lstId [GrapOptGetIdLines $this $var $pre]
3060  foreach it [GrapOptGetNamesLines $this $var $pre] {
3061    set i [expr [lindex $lstId $j] - 1]
3062    foreach e $it {
3063      if {![string equal [$g element type $e] [lindex $ary(${pre},linetypes) $i]]} {
3064        ::bayesGraph::GrapOptChangeType $this $e $e
3065      }
3066    } 
3067    incr j
3068  }
3069}
3070
3071
3072#/////////////////////////////////////////////////////////////////////////////   
3073proc ::bayesGraph::GrapOptApplyColors {this var pre} {
3074#
3075#/////////////////////////////////////////////////////////////////////////////   
3076  upvar \#0 $var ary
3077  set g [getActiveGraph $this]
3078
3079  set j 0
3080  set lstId [GrapOptGetIdLines $this $var $pre]
3081  foreach it [GrapOptGetNamesLines $this $var $pre] {
3082    set i [expr [lindex $lstId $j] - 1]
3083    foreach e $it {
3084      if {[string equal [$g element type $e] "LineElement"]} {
3085        $g element configure $e -color [lindex $ary($pre,colors) $i]
3086      } else  {
3087        $g element configure $e -foreground [lindex $ary($pre,colors) $i]
3088      }
3089    } 
3090    incr j
3091  }
3092}
3093
3094
3095#/////////////////////////////////////////////////////////////////////////////
3096  proc ::bayesGraph::GrapOptApplyFill {this var pre} {
3097#
3098#/////////////////////////////////////////////////////////////////////////////
3099  global toltk_images_path
3100  upvar \#0 $var ary 
3101  set g [getActiveGraph $this]
3102 
3103  set j 0
3104  set lstId [GrapOptGetIdLines $this $var $pre]
3105  foreach it [GrapOptGetNamesLines $this $var $pre] {
3106    set i [expr [lindex $lstId $j] - 1]
3107    foreach e $it {
3108      set areatile    ""
3109      set areapattern ""
3110      # Foreground
3111      if {[string equal [lindex $ary($pre,areaForegrounds) $i] defcolor]} {
3112        if {[string equal [$g element type $e] LineElement]} {
3113          set color [$g line cget $e -color]       
3114        } else {
3115          set color [$g line cget $e -foreground]
3116        }
3117      } else {
3118        set color [lindex $ary($pre,areaForegrounds) $i]
3119      }
3120      # Background
3121      if {[string equal [lindex $ary($pre,areaBackgrounds) $i] defcolor]} {
3122        if [string equal [$g element type $e] LineElement] {
3123          set backcolor [$g line cget $e -color]       
3124        } else {
3125          set backcolor [$g line cget $e -foreground]       
3126        }
3127      } else {
3128        set backcolor [lindex $ary($pre,areaBackgrounds) $i]
3129      }
3130      # Area Type
3131      if [string equal [$g element type $e] LineElement] {
3132        set areaTypeAux [lindex $ary($pre,areaTypes) $i]
3133      } else {
3134        set areaTypeAux [lindex $ary($pre,areaTypesBar) $i]
3135      }
3136      switch $areaTypeAux {     
3137        image {
3138          if ![string equal [lindex $ary($pre,areaTiles) $i] ""] {
3139            set areatile [::Bitmap::get [lindex $ary($pre,areaTiles) $i]]
3140          }
3141        }
3142        solid   { set areapattern solid  }
3143        striped { set areapattern @[file join $toltk_images_path fill.xbm] }
3144        "stipple image" { set areapattern @[lindex $ary($pre,stippleimages) $i] }
3145        "stipple degraded" {
3146          set areapattern "gray[lindex $ary($pre,stippledegradeds) $i]"
3147        }
3148      }
3149      # Apply
3150      if [string equal [$g element type $e] LineElement] {
3151        $g element configure $e -areatile $areatile -areapattern $areapattern \
3152          -areaforeground $color -areabackground $backcolor
3153      } else {
3154        if [string equal $areapattern solid] { set areapattern "" }
3155        $g element configure $e \
3156          -stipple $areapattern -foreground $color -background $backcolor
3157      }
3158    } 
3159    incr j
3160  }
3161}
3162
3163
3164#/////////////////////////////////////////////////////////////////////////////   
3165proc ::bayesGraph::GrapOptApplyShowValues {this var pre} {
3166#
3167#/////////////////////////////////////////////////////////////////////////////   
3168  upvar \#0 $var ary
3169  set g [getActiveGraph $this]
3170 
3171  set j 0
3172  set lstId [GrapOptGetIdLines $this $var $pre]
3173  foreach it [GrapOptGetNamesLines $this $var $pre] {
3174    set i [expr [lindex $lstId $j] - 1]
3175    foreach e $it {
3176      $g element configure $e \
3177        -showvalues  [lindex $ary(${pre},showvalues)         $i] \
3178        -valuefont   [lindex $ary(${pre},valuefont)         $i] \
3179        -valuecolor  [lindex $ary(${pre},valuecolor)        $i] \
3180        -valueformat %0.[lindex $ary(${pre},valueformatdec) $i]f \
3181        -valueshadow [lindex $ary(${pre},valueshadow)       $i] \
3182        -valuerotate [lindex $ary(${pre},valuerotate)       $i] \
3183        -valueanchor [lindex $ary(${pre},valueanchor)       $i]
3184    }     
3185    incr j
3186  }
3187}
3188
3189
3190#/////////////////////////////////////////////////////////////////////////////   
3191proc ::bayesGraph::GrapOptApplyShowSymbols {this var pre} {
3192#
3193#/////////////////////////////////////////////////////////////////////////////   
3194  upvar \#0 $var ary
3195  set g [getActiveGraph $this]
3196 
3197  set j 0
3198  set lstId [GrapOptGetIdLines $this $var $pre]
3199  foreach it [GrapOptGetNamesLines $this $var $pre] {
3200    set i [expr [lindex $lstId $j] - 1]
3201    foreach e $it {
3202      if {[lindex $ary(${pre},showsymbols) $i]} {
3203        if [string equal [$g element type $e] "LineElement"] {     
3204          $g element configure $e \
3205            -symbol       [lindex $ary(${pre},symbol)     $i] \
3206            -pixels       [lindex $ary(${pre},pixels)    $i] \
3207            -scalesymbols [lindex $ary(${pre},scalesymbols)    $i] \
3208            -fill         [lindex $ary(${pre},fill)     $i] \
3209            -outline      [lindex $ary(${pre},outline)      $i] \
3210            -outlinewidth [lindex $ary(${pre},outlinewidth) $i]
3211        }
3212      } else {
3213        if [string equal [$g element type $e] "LineElement"] {
3214          $g element configure $e -symbol none
3215        }
3216      }
3217    }
3218    incr j
3219  }
3220}
3221
3222
3223#/////////////////////////////////////////////////////////////////////////////
3224  proc ::bayesGraph::GrapOptApplyMarkers {this var pre} {
3225#
3226# PURPOSE:
3227#
3228# PARAMETERS:
3229#   this:
3230#   var:
3231#   pre:
3232#
3233#/////////////////////////////////////////////////////////////////////////////
3234  upvar \#0 ${this}::data data
3235  upvar \#0 $var ary
3236  variable tmpOpt
3237 
3238  set gr $data(gr,active)
3239  set g [getActiveGraph $this]
3240 
3241  # delete marker
3242  foreach marker [$g marker names] {
3243    $g marker delete $marker
3244  }
3245  # marker each
[8d0dffc]3246  puts "::bayesGraph::GrapOptApplyMarkers: $g, var=$var, pre=$pre"
3247  puts "[ $g axis cget x -majorticks ]"
[6d7779d]3248  foreach {axis map} {x mapx y mapy x2 mapx y2 mapy} {
3249    # comprobamos si esta visible el eje
3250    if {![$g axis cget $axis -hide]} {
3251    # se puede preguntar por la variable
3252    # if $tmpOpt(var,${axis}AxisShow)
3253      set AXI [string toupper [string index $axis 0]]
3254      if {[info exists ary(${pre},${axis}Markers)]} {
3255        set lstMarkers $ary(${pre},${axis}Markers)
3256        if [llength $lstMarkers] {
3257          if {[info exists data(gr,$gr,OnGet${AXI}Ticks)]} {
3258            set numTicks [llength [$data(gr,$gr,OnGet${AXI}Ticks) $this]]
3259            set iniMarker -1
3260          } else  {
3261            # nos quedamos con el valor minimo y maximo del eje
3262            #TODO: igual es interesante quedarnos con el max y min de las lineas
[8d0dffc]3263            #      asociadas al eje
3264            $g axis configure x -majorticks [ $g axis cger x -majorticks ]
3265            if { 0 } {
[6d7779d]3266            set max [$g axis cget $axis -max]
3267            set min [$g axis cget $axis -min]
3268            if {[string length $max] && [string length $min]} {
3269              set numTicks  $max
3270              set iniMarker $min
3271            } else {
3272              set iniMarker -1
3273              set numTicks   0
3274            }
3275          }
3276          set i 0
[8d0dffc]3277          }
[6d7779d]3278          set j 0
[8d0dffc]3279          puts "lstMarkers = $lstMarkers"
[6d7779d]3280          foreach it $lstMarkers {
3281            if {$j==5} { set j 0 }
3282            set color $tmpOpt(var,${axis}MarkerColorInEach$j)
3283            set width $tmpOpt(var,${axis}MarkerWidthInEach$j)
3284            set dashe $tmpOpt(var,${axis}MarkerDasheInEach$j)
3285            set under $tmpOpt(var,${axis}MarkerUnderInEach$j)
3286            incr j
3287            #set pos -1
3288            set pos $iniMarker
3289            $g marker bind $it <Enter> \
3290                [list ::bayesGraph::WriteInfo $this "[mc Marker]${axis}: each $it"]
[8d0dffc]3291            set majorTicks [ $g axis cget $axis -majorticks ]
[6d7779d]3292            $g marker bind $it <Leave> \
3293                [list ::bayesGraph::WriteInfo $this ""]
[8d0dffc]3294            puts "voy con it = $it"
3295            for { set mt 0 } { $mt < [ llength $majorTicks ] } { incr mt } {
3296              if { [ expr { ( $mt + 1 ) % int( $it ) } ] } continue
3297              set pos [ lindex $majorTicks $mt ]
3298              if { "x" eq [string index $axis 0] } {
3299                set coord [list $pos -Inf $pos Inf]
3300              } else {
3301                set coord [list -Inf $pos Inf $pos]
3302              }
3303              puts "añadiendo marcador $mt en posicion $pos"
3304              catch {
3305                $g marker create line -name ${it}_$pos -coords $coord \
3306                    -outline $color -dashes $dashe -$map $axis \
3307                    -bindtags $it -linewidth $width -under $under
3308              }
3309            }
3310            if { 0 } {
[6d7779d]3311            while {$pos < $numTicks} {
3312              set pos [expr $pos + $it]
3313              # limites
3314              if {[string equal x [string index $axis 0]]} {
3315                set coord [list $pos -Inf $pos Inf]
3316              } else {
3317                set coord [list -Inf $pos Inf $pos]
3318              }
3319              catch { $g marker create line -name ${it}_$pos -coords $coord \
3320                    -outline $color -dashes $dashe -$map $axis \
3321                    -bindtags $it -linewidth $width -under $under }
3322            }
3323            incr i
[8d0dffc]3324            }
[6d7779d]3325          }
3326        }
3327      }
3328    }
3329  }
[8d0dffc]3330  puts "[ $g axis cget x -majorticks ]"
[6d7779d]3331}
3332
3333#/////////////////////////////////////////////////////////////////////////////
3334proc ::bayesGraph::GrapOptApplyMarkersIn {this var pre} {
3335#
3336# PURPOSE:
3337#
3338# PARAMETERS:
3339#
3340#/////////////////////////////////////////////////////////////////////////////
3341  upvar \#0 ${this}::data data
3342  upvar \#0 $var ary
3343  variable tmpOpt
3344
3345  set gr $data(gr,active)
3346  set g [getActiveGraph $this]
3347
3348  # marker in
3349  foreach {axis map} {x mapx y mapy x2 mapx y2 mapy} {
3350# se puede preguntar tambien por -hide del axis
3351    if {![$g axis cget $axis -hide]} {
3352#    if $tmpOpt(var,${axis}AxisSelect)
3353      if {[info exists ary(${pre},${axis}MarkersIn)]} {
3354        set lstMarkersIn $ary(${pre},${axis}MarkersIn)
3355        if [llength $lstMarkersIn] {   
3356          set i 0   
3357          set lon [llength [$g marker names]]
3358          set j [expr $lon<5 ? $lon : $lon % 5]
3359          foreach it $lstMarkersIn {
3360            if {$j==5} { set j 0 }
3361            set color $tmpOpt(var,${axis}MarkerColorInEach$j)
3362            set width $tmpOpt(var,${axis}MarkerWidthInEach$j)
3363            set dashe $tmpOpt(var,${axis}MarkerDasheInEach$j)
3364            set under $tmpOpt(var,${axis}MarkerUnderInEach$j)
3365            incr j 
3366            # limites
3367            if {[string equal x [string index $axis 0]]} {
3368              set coord [list $it -Inf $it Inf]
3369            } else {
3370              set coord [list -Inf $it Inf $it]
3371            }
3372            # axis
3373            if {[string length $it]==2} {
3374              set inx 2
3375            } else {
3376              set inx {}
3377            }
3378            # marker
3379            $g marker bind $it <Enter> \
3380              [list ::bayesGraph::WriteInfo $this "[mc Marker]$axis: in $it"]
3381            $g marker bind $it <Leave> \
3382              [list ::bayesGraph::WriteInfo $this ""]
3383            catch { $g marker create line -name $it -coords $coord \
3384              -outline $color -dashes $dashe -$map $axis \
3385              -bindtags $it -linewidth $width -under $under}
3386            incr i
3387          }
3388        }
3389      }
3390    }
3391  }
3392}
3393
3394
3395#/////////////////////////////////////////////////////////////////////////////   
3396proc ::bayesGraph::GrapOptApplyGrid {this var pre} {
3397#
3398#/////////////////////////////////////////////////////////////////////////////   
3399  upvar \#0 $var ary
3400
3401  set g [getActiveGraph $this]
3402  $g grid configure -color     $ary(${pre},Color)\
3403                    -dashes    $ary(${pre},Dashes)\
3404                    -linewidth $ary(${pre},LineWidth)\
3405                    -minor     $ary(${pre},Minor)
3406  if [string equal $ary(${pre},MapX) "none"] {
3407    $g grid configure -mapx {}
3408  } else {
3409    $g grid configure -mapx $ary(${pre},MapX)
3410  }
3411  if [string equal $ary(${pre},MapY) "none"] {
3412    $g grid configure -mapy {}
3413  } else {
3414    $g grid configure -mapy $ary(${pre},MapY)
3415  }
3416}
3417
3418
3419#/////////////////////////////////////////////////////////////////////////////   
3420proc ::bayesGraph::GrapOptApplyLegend {this var pre} {
3421#
3422#/////////////////////////////////////////////////////////////////////////////   
3423  upvar \#0 $var ary
3424
3425  set g [getActiveGraph $this]
3426
3427  $g legend configure -hide       $ary(${pre},Hide)\
3428                      -bg         $ary(${pre},Bg)\
3429                      -bd         $ary(${pre},Bd)\
3430                      -fg         $ary(${pre},Fg)\
3431                      -font       $ary(${pre},Font)\
3432                      -shadow     $ary(${pre},Shadow)\
3433                      -position   $ary(${pre},Position)\
3434                      -anchor     $ary(${pre},Anchor)\
3435                      -relief     $ary(${pre},Relief)\
3436                      -raised     $ary(${pre},Raised)\
3437                      -ipadx      [list $ary(${pre},IPadXl) $ary(${pre},IPadXr)]\
3438                      -ipady      [list $ary(${pre},IPadYt) $ary(${pre},IPadYb)]\
3439                      -padx       [list $ary(${pre},PadXl)  $ary(${pre},PadXr)]\
3440                      -pady       [list $ary(${pre},PadYt)  $ary(${pre},PadYb)]\
3441                      -rows       $ary(${pre},Rows)\
3442                      -columns    $ary(${pre},Columns)
3443}
3444
3445
3446#/////////////////////////////////////////////////////////////////////////////   
3447proc ::bayesGraph::GrapOptApplyStyle {this var pre} {
3448#
3449#/////////////////////////////////////////////////////////////////////////////   
3450  upvar \#0 $var ary
3451
3452  set g [getActiveGraph $this]
3453  $g configure -plotbackground  $ary(${pre},plotbackground)\
3454               -plotrelief      $ary(${pre},plotrelief)\
3455               -plotborderwidth $ary(${pre},plotborderwidth)\
3456               -plotpadx        [list $ary(${pre},plotpadxl) $ary(${pre},plotpadxr)]\
3457               -plotpady        [list $ary(${pre},plotpadyt) $ary(${pre},plotpadyb)]\
3458               -invertxy        $ary(${pre},invertxy)\
3459               -background      $ary(${pre},background)\
3460               -relief          $ary(${pre},relief)\
3461               -borderwidth     $ary(${pre},areaborderwidth)\
3462               -lm              $ary(${pre},lm)\
3463               -rm              $ary(${pre},rm)\
3464               -tm              $ary(${pre},tm)\
3465               -bm              $ary(${pre},bm)
3466  #El color de los ejes lo vamos a cambiar segun el color de fondo exterior
3467  $g axis configure x  -background $ary(${pre},background)
3468  $g axis configure x2 -background $ary(${pre},background)
3469  $g axis configure y  -background $ary(${pre},background)
3470  $g axis configure y2 -background $ary(${pre},background)
3471}
3472
3473
3474#/////////////////////////////////////////////////////////////////////////////   
3475proc ::bayesGraph::GrapOptOK {this dialog} {
3476#
3477#/////////////////////////////////////////////////////////////////////////////   
3478  GrapOptApply $this
3479  GrapOptDestroy $this $dialog
3480}
3481
3482
3483#/////////////////////////////////////////////////////////////////////////////
3484  proc ::bayesGraph::GrapOptCheck {this} {
3485#
3486# PURPOSE: Checks for all widgets from graph dialog options that need to be
3487#          checked for enabling/disabling other associated controls.
3488#
3489# PARAMETERS:
3490#   this   -> Instance of bayesGraph
3491#
3492#/////////////////////////////////////////////////////////////////////////////
3493  GrapOptCheckXYAxisAll    $this
3494  GrapOptCheckXYTicksType  $this
3495#  GrapOptCheckShowSymbols $this
3496}
3497
3498#/////////////////////////////////////////////////////////////////////////////
3499proc ::bayesGraph::GrapOptCheckXYAxisAll {this} {
3500#
3501# PURPOSE:
3502#
3503# PARAMETERS:
3504#   this   -> Instance of bayesGraph
3505#
3506#///////////////////////////////////////////////////////////////////////////// 
3507  upvar \#0 ${this}::data data
3508  variable tmpOpt
3509  set gr $data(gr,active)
3510  if {[info exists tmpOpt(widget,xyAxisMin)] && \
3511      [info exists tmpOpt(widget,xyAxisMax)] && \
3512      [info exists tmpOpt(var,xyAxisAll)]} {
3513    # eje acutal
3514    set axis $tmpOpt(var,xyAxisSelect)
3515    set AXI  [string toupper [string index $axis 0]]
3516    if {[info exists tmpOpt(var,xyAxisSelect)] &&
3517        [info exists data(gr,$gr,OnGet${AXI}Ticks)]} {
3518      $tmpOpt(widget,xyAxisMin) configure \
3519        -values [$data(gr,$gr,OnGet${AXI}Ticks) $this] -range {}
3520      $tmpOpt(widget,xyAxisMax) configure \
3521         -values [$data(gr,$gr,OnGet${AXI}Ticks) $this] -range {}
3522    } else  {
3523      $tmpOpt(widget,xyAxisMin) configure -values {} -range {-INF INF 1}
3524      $tmpOpt(widget,xyAxisMax) configure -values {} -range {-INF INF 1}
3525    }
3526    if $tmpOpt(var,xyAxisAll) {
3527      focus $tmpOpt(widget,chXYAll)
3528      $tmpOpt(widget,xyAxisMin) configure -state disabled
3529      $tmpOpt(widget,xyAxisMax) configure -state disabled
3530      if {[llength [$tmpOpt(widget,xyAxisMin) cget -values]]} {
3531        $tmpOpt(widget,xyAxisMin) setvalue  first
3532      }
3533      if {[llength [$tmpOpt(widget,xyAxisMax) cget -values]]} {
3534        $tmpOpt(widget,xyAxisMax) setvalue  last
3535      }
3536    } else  {
3537      $tmpOpt(widget,xyAxisMin) configure -state normal
3538      $tmpOpt(widget,xyAxisMax) configure -state normal
3539    }
3540  }
3541}
3542
3543
3544#/////////////////////////////////////////////////////////////////////////////   
3545proc ::bayesGraph::GrapOptCheckXYTicksType {this} {
3546#
3547#/////////////////////////////////////////////////////////////////////////////   
3548  variable tmpOpt
3549  if {[info exists tmpOpt(widget,rbXYTotal)] && \
3550      [info exists tmpOpt(widget,xyTicksStep)] && \
3551      [info exists tmpOpt(widget,xyTicksTotal)]} {
3552    switch $tmpOpt(var,xyTicksType) {
3553      total {
3554        if {[info exists tmpOpt(widget,rbXYTotal)]} {
3555          focus $tmpOpt(widget,rbXYTotal)
3556        }
3557        $tmpOpt(widget,xyTicksStep)  configure -state disabled
3558        $tmpOpt(widget,xyTicksTotal) configure -state normal
3559      }
3560      each {
3561        if {[info exists tmpOpt(widget,rbXYEach)]} {
3562          focus $tmpOpt(widget,rbXYEach)
3563        }
3564        $tmpOpt(widget,xyTicksTotal) configure -state disabled
3565        $tmpOpt(widget,xyTicksStep)  configure -state normal
3566      }
3567      auto {
3568        set tmpOpt(var,xyTicksTotal) \
3569          [CalculateXAxisNumTicks $this $tmpOpt(var,xyAxisSelect)]
3570        set tmpOpt(var,xyTicksStep) \
3571          [ComputeXAxisStep $this $tmpOpt(var,xyTicksTotal) \
3572                                  $tmpOpt(var,xyAxisSelect)]
3573        if {[info exists tmpOpt(widget,rbXYAuto)]} {
3574          focus $tmpOpt(widget,rbXYAuto)
3575        }
3576        $tmpOpt(widget,xyTicksTotal) configure -state disabled
3577        $tmpOpt(widget,xyTicksStep)  configure -state disabled
3578      }
3579    }
3580  }
3581}
3582
3583
3584#/////////////////////////////////////////////////////////////////////////////   
3585proc ::bayesGraph::ChangeFormat  { var name1 name2 op} {
3586#
3587#/////////////////////////////////////////////////////////////////////////////   
3588  upvar \#0 ${name1}($name2) varsource
3589  upvar \#0 $var vardestine
3590  set vardestine %0.${varsource}f
3591}
3592
3593
3594#/////////////////////////////////////////////////////////////////////////////   
3595proc ::bayesGraph::WriteInfo {this text} {
3596#
3597#/////////////////////////////////////////////////////////////////////////////   
3598  upvar \#0 ${this}::widgets widgets
3599  $widgets(sb,lInfo) configure -text $text
3600}
3601
3602
3603#/////////////////////////////////////////////////////////////////////////////
3604  proc ::bayesGraph::GrapOptApplyMappedLines {this var pre} {
3605#
3606# PURPOSE: Asigna las lineas a los ejes especificados en opciones
3607#
3608# PARAMETERS:
3609#   this -> Instance of bayesGraph
3610#   var  -> nombre de la variable
3611#   pre  -> prefijo de array
3612#
3613#/////////////////////////////////////////////////////////////////////////////
3614  upvar \#0 $var ary
3615  set g [getActiveGraph $this]
3616
3617  # all lines
3618  set j 0
3619  set lstId [GrapOptGetIdLines $this $var $pre]
3620  foreach it [GrapOptGetNamesLines $this $var $pre] {
3621    set i [expr [lindex $lstId $j] - 1]
3622    foreach e $it {
3623      set xy [lindex $ary($pre,xyMappedAxis) $i]
3624      if {!([string equal [$g element cget $e -mapx] [lindex $xy 0]] && \
3625            [string equal [$g element cget $e -mapy] [lindex $xy 1]])} {
3626        ::bayesGraph::GrapOptApplyMappedLinesChange \
3627          $this $var $e [lindex $xy 0] [lindex $xy 1]
3628      }
3629    }
3630    incr j
3631  }
3632}
3633
3634
3635#/////////////////////////////////////////////////////////////////////////////
3636  proc ::bayesGraph::GrapOptApplyMappedLinesChange {this var le X Y} {
3637#
3638# PURPOSE: Cambiamos de eje/s un linea. Si el eje no esta visible, lo
3639#          mostramos y configuramos maximo y minimo.
3640#
3641# PARAMETERS:
3642#   this -> Instance of bayesGraph
3643#   var  -> nombre de la variable
3644#   le   -> Lista de elementos
3645#   X    -> Axis X destiny
3646#   Y    -> Axis Y destiny
3647#
3648#/////////////////////////////////////////////////////////////////////////////
3649  upvar \#0 $var ary
3650  set g [getActiveGraph $this]
3651  variable tmpOpt
3652  # comrpbamos que no este en el mismo eje
3653  foreach e $le {
3654    set xOld [$g element cget $e -mapx]
3655    set yOld [$g element cget $e -mapy]
3656    if {($X!=$xOld) || ($Y!=$yOld)} {
3657      foreach axis "$X $Y" {
3658        set axi  [string index $axis 0]
3659        # comprobamos si eje X visible
3660        if {[$g axis cget $axis -hide]} {
3661          $g axis configure $axis -hide 0
3662          if {[info exists tmpOpt(var,${axis}AxisShow)]} {
3663            set tmpOpt(var,${axis}AxisShow) 1
3664          }
3665          # valores
3666          set val  [$g line cget $e -${axi}data]
3667          set lmax [lmaximo $val]
3668          set lmin [lminimo $val]
3669          set tmpOpt(var,${axis}AxisMin) $lmin
3670          set tmpOpt(var,${axis}AxisMax) $lmax
3671          ::bayesGraph::GrapOptApplyAxisLimits $this $axis $lmin $lmax
3672        }
3673      }
3674    }
3675    $g element configure $e -mapx $X -mapy $Y
3676  }
3677}
3678
3679
3680#/////////////////////////////////////////////////////////////////////////////
3681  proc ::bayesGraph::GetLimitsValueAxis {this axis} {
3682#
3683# PURPOSE: Obtenemos el valor maximo y minimo de todas las lineas ascoicadas a
3684#          un eje
3685#  this -> Instance of bayesGraph
3686#  axis -> Eje actual
3687#
3688# PARAMETERS: el valor minimo y maximo asociado a un eje
3689#
3690#/////////////////////////////////////////////////////////////////////////////
3691  # inicializamos variables
3692  set g [getActiveGraph $this]
3693  set axi [string index $axis 0]
3694  set lst [$g element show]
3695  set lmax {}
3696  set lmin {}
3697  # buscamos valor maximo y minimo de todas las lineas
3698  foreach e $lst {
3699    if {( [$g element cget $e -map${axi}]==$axis) && \
3700        (![$g element cget $e -hide])} {
3701      # valores
3702      set val [$g line cget $e -${axi}data]
3703      # buscamos valorores maximos y minimos Y
3704      if {[set vmax [lmaximo $val]] ne ""} {
3705        lappend lmax $vmax
3706      }
3707      if {[set vmin [lminimo $val]] ne ""} {
3708        lappend lmin $vmin
3709      }
3710    }
3711  }
3712  # buscamos el maximo y minimo
3713  if {[llength $lmax] && [llength $lmin]} {
3714    set max [lmaximo $lmax]
3715    set min [lminimo $lmin]
3716    set lst [list $min $max]
3717  } else  {
3718    set lst {}
3719  }
3720  return $lst
3721}
3722
3723
3724#/////////////////////////////////////////////////////////////////////////////
3725  proc ::bayesGraph::GrapOptApplyAxisLimits {this axis min max} {
3726#
3727# PURPOSE: Aplicamos la configuracion de minimo y maximo de un eje. Para ello
3728#          comprobamos que el stepsize no quede muy pequeño
3729#
3730#  this -> Instance of bayesGraph
3731#  axis -> Eje actual
3732#  min  -> Min value
3733#  max  -> Max value
3734#
3735# PARAMETERS: el valor minimo y maximo asociado a un eje
3736#
3737#/////////////////////////////////////////////////////////////////////////////
3738  # inicializamos variables
3739  variable tmpOpt
3740  set g [getActiveGraph $this]
3741  set stepsize [$g axis cget $axis -stepsize]
3742  set maxTicks 200
3743  # comprobamos el valor de stepsize, si es mayor que 1000, aplicamos 1000
3744  # con esta comprobación evitamos que de error al cambiar el min y max
3745  if {[string length $max] && [string length $min]} {
3746    set n [expr $stepsize ? ($max - $min) / $stepsize : $stepsize]
3747    if {$n>$maxTicks} {
3748      set tmpOpt(var,${axis}TicksStep) [expr ($max - $min) / $maxTicks]
3749      $g axis configure $axis -stepsize $tmpOpt(var,${axis}TicksStep)
3750    }
3751  }
3752  # convertimos a double
3753  if {[string is int $min]} { set min "$min.0" }
3754  if {[string is int $max]} { set max "$max.0" }
3755  if {$min<$max} {
3756    if {0 && [string index $axis 0] eq "x"} {
3757      set min [expr $min - 0.5]
3758      set max [expr $max + 0.5]
3759    }
3760    $g axis configure $axis $axis -min $min -max $max
3761  }
3762}
3763
3764
3765#/////////////////////////////////////////////////////////////////////////////
3766  proc ::bayesGraph::SetMainTitle {this title} {
3767#
3768# PURPOSE: Set main title o chart
3769#
3770#  this  -> Instance of bayesGraph
3771#  title -> list of title
3772#
3773# PARAMETERS: el valor minimo y maximo asociado a un eje
3774#
3775#/////////////////////////////////////////////////////////////////////////////
3776  upvar \#0 ${this}::data data
3777  upvar \#0 ${this}::widgets widgets 
3778
3779  for  {set gr 0} {$gr<$data(gr,numGraph)} {incr gr 1} {
3780    set inx [expr $gr>=[llength $title] ? [llength $title] - 1 : $gr]
3781    $widgets(gr,$gr) configure -title [lindex $title $inx]
3782  }
3783}
3784
3785
3786#/////////////////////////////////////////////////////////////////////////////
3787proc ::bayesGraph::GrapOptChangeType {this elem segs} {
3788#
3789#/////////////////////////////////////////////////////////////////////////////   
3790  set g [getActiveGraph $this]
3791  set typeElem   [$g element type [lindex $segs 0]]
3792 
3793  foreach el $segs {
3794    set xdata       [$g element cget $el -xdata]
3795    set ydata       [$g element cget $el -ydata]
3796    set label       [$g element cget $el -label]
3797    set mapx        [$g element cget $el -mapx]
3798    set mapy        [$g element cget $el -mapy]
3799    set label       [$g element cget $el -label]
3800    set hide        [$g element cget $el -hide]
3801    set showvalues  [$g element cget $el -showvalues]
3802    set valueanchor [$g element cget $el -valueanchor]
3803    set valuecolor  [$g element cget $el -valuecolor]
3804    set valuefont   [$g element cget $el -valuefont]
3805    set valueformat [$g element cget $el -valueformat]
3806    set valuerotate [$g element cget $el -valuerotate]
3807    set valueshadow [$g element cget $el -valueshadow]
3808    if [string equal $typeElem "BarElement"] {
3809      set bgcolor [$g element cget $el -background]
3810      set color   [$g element cget $el -foreground]
3811      set width   [$g element cget $el -borderwidth]
3812      set xbm     [$g element cget $el -stipple]
3813     
3814      $g bar delete $el
3815      $g element create $el -xdata $xdata -ydata $ydata\
3816          -color $color -areabackground $bgcolor -areaforeground $color \
3817          -linewidth $width -areapattern $xbm -symbol "none"
3818    } else  {
3819      set color   [$g element cget $el -color]
3820      set bgcolor [$g element cget $el -areabackground]
3821      if {$bgcolor eq "defcolor"} {
3822        set bgcolor $color
3823      }
3824      set width [$g element cget $el -linewidth]
3825      set xbm   [$g element cget $el -areapattern]
3826      if {$xbm eq "solid"} {
3827        set xbm ""
3828      }
3829      $g element delete $el
3830      $g bar create $el -xdata $xdata -ydata $ydata\
3831          -foreground $color   -barwidth 0.5\
3832          -background $bgcolor -borderwidth $width -stipple $xbm
3833    }
3834    $g element conf $el\
3835           -valueanchor $valueanchor -valuecolor  $valuecolor\
3836           -valuefont   $valuefont   -valueformat $valueformat\
3837           -valuerotate $valuerotate -valueshadow $valueshadow\
3838           -showvalues  $showvalues  -hide        $hide\
3839           -mapx $mapx  -mapy $mapy  -label $label
3840  }
3841}
3842
3843#/////////////////////////////////////////////////////////////////////////////   
3844#NOTE. No esta en uso. Para usarla habría que modificar la función y guardar
3845#los widget en variables
3846proc ::bayesGraph::GrapOptCheckShowSymbols {this serie} {
3847#
3848#/////////////////////////////////////////////////////////////////////////////   
3849  variable tmpOptElem
3850
3851  if {!$tmpOptElem(var,curve,$serie,showsymbols)} {
3852    SetAttribute $tmpOptElem(widget,fSymbol) state disabled
3853    $tmpOptElem(widget,chShow)    configure -state normal
3854  } else  {
3855    SetAttribute $tmpOptElem(widget,fSymbol) state normal
3856  }
3857}
3858
3859#/////////////////////////////////////////////////////////////////////////////   
3860proc ::bayesGraph::GrapOptGetNamesLines {this var pre} {
3861#
3862#/////////////////////////////////////////////////////////////////////////////   
3863  upvar \#0 $var ary
3864  return [lindex [ltraspose $ary(${pre},lstnames)] 1]
3865}
3866
3867#/////////////////////////////////////////////////////////////////////////////   
3868proc ::bayesGraph::GrapOptGetIdLines {this var pre} {
3869#
3870#/////////////////////////////////////////////////////////////////////////////   
3871  upvar \#0 $var ary
3872  return [lindex [ltraspose $ary(${pre},lstnames)] 0]
3873}
Note: See TracBrowser for help on using the repository browser.