source: tol/tolbase/lib/toltk/sergraph.tcl @ a721096

1941-docker-image-to-testdevel
Last change on this file since a721096 was a721096, checked in by Jorge Pérez <josp.jorge@…>, 18 years ago

Fixed bug when drawing TimeSet markers in a Serie graph.

This functionality was lost when changing tol::info var syntax.

Fixes #611

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

  • Property mode set to 100644
File size: 49.4 KB
Line 
1#/////////////////////////////////////////////////////////////////////////////
2# FILE    : sergraph.tcl
3# PURPOSE : This file
4#           It's a child of bayesGraph so inherites all its functionalities.
5#/////////////////////////////////////////////////////////////////////////////
6
7package require bcolor
8package require bmultiselect
9
10namespace eval ::SeriesGraph {
11  variable tmpOpt
12}
13
14#/////////////////////////////////////////////////////////////////////////////
15proc ::SeriesGraph::Create { path list args } {
16#
17# PURPOSE:
18#     
19# PARAMETERS:
20#   path
21#   this -> bayesgraph instance
22#   structure ->
23#   fileGCF -> file the graphic configuration file. Default ""
24#
25#/////////////////////////////////////////////////////////////////////////////
26#puts "SeriesGraph::Create path=$path list=$list args=$args ........"
27  array set opts {
28    -struct g
29    -fileGCF ""
30    -photo 0
31    -title {}
32  }
33  array set opts $args
34  set t0 [time {
35  set Instance [::bayesGraph::Create $path $opts(-struct) -photo $opts(-photo)]
36  }]
37  puts "time in ::bayesGraph::Create = $t0"
38  upvar \#0 ${Instance}::widgets widgets
39  upvar \#0 ${Instance}::data data
40
41  set data(namespace)            SeriesGraph
42  set data(proc,OnGetLabel)      ::SeriesGraph::GetLabel
43  set data(proc,OnOptionCreate)  ::SeriesGraph::OptionsCreate
44  set data(proc,OnOptionDestroy) ::SeriesGraph::OptionsDestroy
45  set data(proc,OnOptionApply)   ::SeriesGraph::OptionsApply
46  set data(proc,OnComputeStepX)  ::SeriesGraph::ComputeStepX
47  set data(proc,OnFixStepX)      ::SeriesGraph::FixStepX
48  set data(proc,OnEvalWindow)    ::SeriesGraph::EvalWindow
49  set data(proc,OnToTable)       ::SeriesGraph::ToTable
50  set data(proc,OnWriteIni)      ::SeriesGraph::WriteIni
51  set data(proc,xAxisCommand)    [list ::SeriesGraph::GetTickLabel $Instance]
52  set data(proc,x2AxisCommand)   [list ::SeriesGraph::GetTickLabel $Instance] 
53
54  PushButtons $Instance
55
56  # Fill graph
57  set lstInfo [::SeriesGraph::CreateLine $Instance $list]
58  set lstname [lindex $lstInfo 0]
59  set lstdesc [lindex $lstInfo 1]
60
61  #Establecer el fichero GCF del que se lee
62  if {[string length $opts(-fileGCF)]} {
63    ::bayesGraph::LoadGCF $Instance $opts(-fileGCF)
64  } else  {
65    ::bayesGraph::LoadGCF $Instance
66  }
67  ReadIni   $Instance
68  Configure $Instance
69
70  SetLabelSerie $Instance $lstname $lstdesc
71 
72  #set title chart
73  if {[string length $opts(-title)]} {
74    ::bayesGraph::SetMainTitle $Instance $opts(-title)
75  }
76
77  return $Instance
78}
79
80#/////////////////////////////////////////////////////////////////////////////
81  proc ::SeriesGraph::CreateLine { this lst } {
82#
83# PURPOSE:
84#     
85# PARAMETERS:
86#   this -> bayesgraph instance
87#   lst  -> values to draw
88#
89#/////////////////////////////////////////////////////////////////////////////
90  upvar \#0 ${this}::data data
91  upvar \#0 ${this}::widgets widgets
92
93  for  {set gr 0} {$gr<$data(gr,numGraph)} {incr gr 1} {
94    set grpath $widgets(gr,$gr)
95    set sergrp [lindex $lst $gr]
96    # variables especificas de cada grafico
97    set data(gr,active) $gr
98    set data(gr,$gr,sergrp) $sergrp
99    set data(gr,$gr,n_ser) [$sergrp serie size]
100    set data(gr,$gr,OnGetXTicks)  ::SeriesGraph::GetXTicks
101    set data(gr,$gr,OnGetXValues) ::SeriesGraph::GetXValues
102    # insert the series into the graph
103    for {set i 0} {$i < $data(gr,$gr,n_ser)} {incr i} {
104      # names and description
105      set objref  [$sergrp serie $i reference]
106      if {[llength $objref]>1} {
107        array set objinfo [TclInfoRef $objref]
108      } else {
109        array set objinfo [TclInfoVar Serie $objref]
110      }
111      if {[info exists objinfo(DESC)]} {
112        lappend lstdesc $objinfo(DESC)
113      } else  {
114        lappend lstdesc {}
115      }
116      lappend lstname l$i-0
117      # values
118      set j 0
119      set segs {}
120      foreach vec_data [$sergrp serie $i data] {
121        $grpath line create l$i-$j -xdata [lindex $vec_data 0] \
122                                   -ydata [lindex $vec_data 1]
123        lappend segs l$i-$j
124        if { $j } {
125          $grpath line configure l$i-$j -label ""
126        } else {
127          $grpath line configure l$i-0 -label [$sergrp serie $i name]
128        }
129        incr j
130      }
131      lappend data(gr,$gr,elements) $segs
132    }
133 
134    global zoomInfo
135  }
136  ::bayesGraph::BindLegend $this
137  return [list $lstname $lstdesc]
138}
139
140#/////////////////////////////////////////////////////////////////////////////
141proc ::SeriesGraph::AddSerieToGraph { this newSer {typSer LineElement} } {
142#
143# PURPOSE: Anhadimos una nueva Serie a un grafico existente.
144#   Los pasos a seguir son los siguientes:
145#   1. borramos todas las lineas existentes
146#   2. capturamos las Series anteriores
147#   3. creamos un nuevo conjunto de Series
148#   4. pintamos las nuevas series
149#   5. ?? dejar el grafico como estaba (exactamente no se lo que implica)
150#
151# PARAMETERS:
152#   this -> bayesgraph instance
153#   newSer -> new serie
154#   typSer -> type of line [LineElement | BarElement]
155#
156#/////////////////////////////////////////////////////////////////////////////
157  upvar \#0 ${this}::data data
158  upvar \#0 ${this}::widgets widgets
159  upvar \#0 ::bayesGraph::tmpOpt ary
160 
161  for  {set gr 0} {$gr<$data(gr,numGraph)} {incr gr 1} {
162    # path of Graph
163    set grpath $widgets(gr,$gr)
164    #   1. borramos todas las lineas existentes
165    # type of series
166    foreach item $data(gr,$gr,elements) {
167      lappend typesSeries [$grpath element type $item]
168    }
169    lappend typesSeries $typSer
170    # clear lines
171    set data(gr,$gr,elements) {}
172    set namLin [$grpath element names]
173    foreach item $namLin {
174      $grpath element delete $item
175    }
176    #   2. capturamos las Series anteriores
177    for {set s 0} {$s<$data(gr,$gr,n_ser)} {incr s 1} {
178      lappend series [$data(gr,$gr,sergrp) serie $s name]
179    } 
180    #   3. creamos un nuevo conjunto de Series
181    if {[info exists data(gr,$gr,sergrp)]} {
182      ::tol::seriegrp destroy $data(gr,$gr,sergrp)
183    }
184    lappend series $newSer
185    set sergrp $data(gr,$gr,sergrp)
186    eval "::tol::seriegrp create $sergrp $series"
187    #   4. pintamos las nuevas series   
188    set lstInfo [::SeriesGraph::CreateLine $this $sergrp]
189    set lstname [lindex $lstInfo 0]
190    set lstdesc [lindex $lstInfo 1]
191    #   5. ?? dejar el grafico como estaba (exactamente no se lo que implica)
192    ::SeriesGraph::Configure     $this
193    ::SeriesGraph::SetLabelSerie $this $lstname $lstdesc
194    # change types
195    foreach git $data(gr,$gr,elements) typ $typesSeries {
196      if ![string equal $typ [$grpath element type [lindex $git 0]]] {
197        ::bayesGraph::ElemOptChangeType $this [lindex $git 0] $git
198      }
199    }
200    # show info
201    #set data(gr,$gr,listNames)  $lstname
202    #set data(gr,$gr,listLabels) $lstdesc
203  }
204}
205
206
207#/////////////////////////////////////////////////////////////////////////////
208proc ::SeriesGraph::SetLabelSerie {this lines lstdesc} {
209#
210# PURPOSE: Establecemos nombres de las lineas con la descripcion de las
211#          series pintadas
212#
213# PARAMETERS: this -> Instancia bysgraph
214#             lines -> nombre de las series pintadas
215#             lstdesc -> descripciones de las lineas pintadas
216#
217#/////////////////////////////////////////////////////////////////////////////
218  upvar \#0 ${this}::options opt
219  upvar \#0 ${this}::data data
220  upvar \#0 ${this}::widgets widgets
221  for {set gr 0} {$gr<$data(gr,numGraph)} {incr gr} {
222    set grpath $widgets(gr,$gr)
223    if {$opt(gr,$gr,sergrp,lineShowDescription)==1} {
224      foreach l $lines d $lstdesc {
225        if {[string length $d]} {
226          $grpath element configure $l -label $d
227        }
228      }
229    }
230  }
231}
232
233
234#/////////////////////////////////////////////////////////////////////////////
235proc ::SeriesGraph::PushButtons {this} {
236#
237#///////////////////////////////////////////////////////////////////////////// 
238  upvar \#0 ${this}::widgets widgets
239  upvar \#0 ${this}::data data
240  set widgets(tbe,path) [frame $widgets(tb,path).tbe -bd 2]
241  set tbe $widgets(tbe,path) 
242  pack $tbe -side left
243  #grid $tbe -sticky ew
244  set data(tb,btes) ""
245  set widgets(tb,bte,sep) [Separator $tbe.sep -orient vertical]
246  lappend data(tb,btes) sep
247  set widgets(tb,bte,average) [Button $tbe.average -image [::Bitmap::get "average"] \
248                              -highlightthickness 0 -activebackground \#ececec \
249                              -takefocus 0 -relief link -bd 1 -padx 1 -pady 1 \
250                              -helptext [mc "Show/Hide Average"] \
251                              -command [list ::SeriesGraph::OptionAverage $this]]
252  lappend data(tb,btes) average
253  set widgets(tb,bte,stddev) [Button $tbe.stddev -image [::Bitmap::get "stddev"] \
254                              -highlightthickness 0 -activebackground \#ececec \
255                              -takefocus 0 -relief link -bd 1 -padx 1 -pady 1 \
256                              -helptext [mc "Show/Hide Std. Dev."] \
257                              -command [list ::SeriesGraph::OptionStdDev $this]]
258  lappend data(tb,btes) stddev
259  set widgets(tb,bte,stattb) [Button $tbe.stattb -image [::Bitmap::get "tablestat"] \
260                              -highlightthickness 0 -activebackground \#ececec \
261                              -takefocus 0 -relief link -bd 1 -padx 1 -pady 1 \
262                              -helptext [mc "View Statistics table"] \
263                              -command [list ::SeriesGraph::StatisticsTable $this]]
264  lappend data(tb,btes) stattb
265
266 # set widgets(tb,bte,accgra) [Button $tbe.acugra -image [::Bitmap::get "Serie"] \
267                              -highlightthickness 0 -activebackground \#ececec \
268                              -takefocus 0 -relief link -bd 1 -padx 1 -pady 1 \
269                              -helptext [mc "Accumulate graph"] \
270                              -command [list ::SeriesGraph::AccumulateGraph $this]]
271 # lappend data(tb,btes) accgra
272
273
274  # pack de los botones especificos
275  set but_col 0
276  foreach but $data(tb,btes) {
277    if { [string equal -length 3 $but "sep"] } {
278      grid $widgets(tb,bte,$but) -row 0 -column $but_col -sticky ns -padx 3
279    } else  {
280      grid $widgets(tb,bte,$but) -row 0 -column $but_col -sticky w -ipadx 2 -ipady 2 -pady 1
281    }
282    incr but_col
283  }
284  grid columnconfigure $tbe $but_col -weight 1
285}
286
287
288#/////////////////////////////////////////////////////////////////////////////
289proc ::SeriesGraph::Configure {this} {
290#
291#///////////////////////////////////////////////////////////////////////////// 
292  upvar \#0 ${this}::data data
293  upvar \#0 ${this}::options opt
294  ::bayesGraph::Configure $this
295  set old_active $data(gr,active)
296  for {set gr 0} {$gr<$data(gr,numGraph)} {incr gr} {
297    set data(gr,active) $gr
298
299    OptionsApplyDateFormat $this $opt(gr,$gr,sergrp,dateString)
300    OptionsApplyAxis       $this $opt(gr,$gr,sergrp,xAxis)
301    OptionsApplyXMarkers $this $opt(gr,$gr,sergrp,xMarkers) $opt(gr,$gr,sergrp,xMarkersColors)\
302           $opt(gr,$gr,sergrp,xMarkersDashes) $opt(gr,$gr,sergrp,xMarkersWidths)
303    OptionsApplyYMarkers    $this ${this}::options gr,$gr,sergrp
304  }
305  set data(gr,active) $old_active
306}
307
308
309#/////////////////////////////////////////////////////////////////////////////
310proc ::SeriesGraph::GetLabel { this bltg tick y} {
311#
312#///////////////////////////////////////////////////////////////////////////// 
313  upvar \#0 ${this}::data data
314  set gr $data(gr,active)
315
316  if [string is int $tick] {
317    set str ""
318    catch {
319      set str [$data(gr,$gr,sergrp) dating $tick]
320    }
321    set label "t = $str, z = $y"
322  } else  {
323    set label "t = $tick, z = $y"
324  }
325  return $label
326}
327
328
329#/////////////////////////////////////////////////////////////////////////////
330proc ::SeriesGraph::GetTickLabel { this bltg tick } {
331#
332#///////////////////////////////////////////////////////////////////////////// 
333  set sergrp [getSerGroup $this]
334  if [string is int $tick] {
335    set str ""
336    catch {
337      set str [$sergrp dating $tick]
338    }
339    return $str
340  } else {
341#    return $tick
342     return ""
343  }
344}
345
346#/////////////////////////////////////////////////////////////////////////////
347  proc ::SeriesGraph::GetXTicks {Instance} {
348#
349# PURPOSE:
350#
351# PARAMETERS:
352#   Instance -> Instancia bysgraph
353#
354# RETURN:
355#
356#/////////////////////////////////////////////////////////////////////////////
357  upvar \#0 ${Instance}::data data
358  upvar \#0 ${Instance}::widgets widgets
359 
360  set gr $data(gr,active)
361  set values [::bayesGraph::GetLimitsValueAxis $Instance x]
362  if {[llength $values]} {
363    for {set i [expr int([lindex $values 0])]} \
364        {$i <= [expr int([lindex $values 1])]} {incr i} {
365      lappend lst [GetTickLabel $Instance $widgets(gr,$gr) $i]
366    }
367  } else {
368    set lst {}
369  }
370  return $lst
371}
372
373#/////////////////////////////////////////////////////////////////////////////
374  proc ::SeriesGraph::GetXValues {Instance } {
375#
376# PURPOSE:
377#
378# PARAMETERS:
379#   Instance -> Instancia bysgraph
380#
381# RETURN:
382#
383#/////////////////////////////////////////////////////////////////////////////
384  upvar \#0 ${Instance}::data data
385  set gr $data(gr,active)
386  set values [::bayesGraph::GetLimitsValueAxis $Instance y]
387  if {[llength $values]} {
388    for {set i [expr int([lindex $values 0])]} \
389        {$i <= [expr int([lindex $values 1])]} {incr i} {
390      lappend lst $i
391    }
392  } else  {
393    set lst {}
394  }
395  return $lst
396}
397
398#/////////////////////////////////////////////////////////////////////////////
399  proc ::SeriesGraph::ComputeStepX {this min max total} {
400#
401# PURPOSE:
402#
403# PARAMETERS:
404#   this  -> Instancia bysgraph
405#   min   ->
406#   max   ->
407#   total ->
408#
409# RETURN:
410#
411#/////////////////////////////////////////////////////////////////////////////
412  set step {}
413  if {[string length $min] && [string length $max]} {
414    set dif [expr $max - $min]
415    if {$total > $dif} {
416      set step 1
417    } else {
418#puts "SeriesGraph:.ComputeStepX $this  min=$min  max=$max  total=$total  dif=$dif"
419      if {![catch {expr int(ceil($dif/$total))} res]} {
420        set step $res
421      } else {
422        #puts "SeriesGraph.ComputeStepX. $res"
423        Tolcon_Trace "SeriesGraph.ComputeStepX. $res"
424        set step 0
425      }
426      #set step [expr int(ceil($dif/$total))]
427    }
428  }
429  return $step
430}
431
432
433#/////////////////////////////////////////////////////////////////////////////
434proc ::SeriesGraph::FixStepX {this min max step} {
435#
436#///////////////////////////////////////////////////////////////////////////// 
437#TODO: Error en la resta
438  set ok 1
439  if {[string length $max] && [string length $min]} {
440    set dif [expr $max - $min]
441  } else  {
442    set ok 0
443  }
444  if {($ok) && ($step>$dif)} {
445    set step [expr round($dif)]
446  } else {
447    set step [expr round($step)]
448  }
449  return $step
450}
451
452
453#/////////////////////////////////////////////////////////////////////////////
454proc ::SeriesGraph::getSerGroup {this} {
455#
456#///////////////////////////////////////////////////////////////////////////// 
457  upvar \#0 ${this}::data data
458
459  set gr $data(gr,active)
460  set sergrp $data(gr,$gr,sergrp)
461  return $sergrp
462}
463
464
465#/////////////////////////////////////////////////////////////////////////////
466proc ::SeriesGraph::EvalWindow {this} {
467#
468#///////////////////////////////////////////////////////////////////////////// 
469  set sergrp [getSerGroup $this]
470  set result ""
471  set numCols [$sergrp serie size]
472  for {set i 0} {$i < $numCols} {incr i} {
473    lappend result [$sergrp serie $i name]
474  }
475  return [ListToStr $result]
476}
477
478
479#/////////////////////////////////////////////////////////////////////////////
480proc ::SeriesGraph::ToTable {this} {
481#
482#///////////////////////////////////////////////////////////////////////////// 
483  set grpath [::bayesGraph::getActiveGraph $this]
484  set sergrp [getSerGroup $this]
485  set tl .tbl_from_$sergrp
486  if [winfo exists $tl] {
487     raise $tl
488  } else {
489    # create
490        set tl [::project::CreateForm \
491        -title [mc "Time series table"] \
492        -type Tables \
493        -iniconfig SeriesTable -helpkey "Tb4GraSer"
494    ]
495        set tlf [$tl getframe]
496    # config
497    btable $tlf.t -parent $tl \
498                  -posteditcmd [list ::TolConsole::TableRecentUpdate $tlf.t] \
499                  -iniconfig btable
500    set tempformat [$sergrp format]
501    $sergrp format ""
502    $tlf.t fillSerie $sergrp [TolDateFormat2TclDateFormat $tempformat]
503    $sergrp format $tempformat
504    $tl bind <Control-F4> [list $tl kill]
505    pack $tlf.t -fill both -expand yes
506  }
507}
508
509
510#/////////////////////////////////////////////////////////////////////////////
511proc ::SeriesGraph::StatisticsTable {this} {
512#
513#///////////////////////////////////////////////////////////////////////////// 
514  set grpath [::bayesGraph::getActiveGraph $this]
515  set sergrp [getSerGroup $this]
516
517  set tl .stattbl_from_$sergrp
518  if [winfo exists $tl] {
519    raise $tl
520  } else {
521    # create
522    set tl [::project::CreateForm \
523        -title [mc "Statistics table"] \
524        -type Tables \
525        -labelini StatisticsTable
526    ]
527        set tlf [$tl getframe]
528    # config
529    btable $tlf.t -parent $tl \
530                  -posteditcmd [list ::TolConsole::TableRecentUpdate $tlf.t] \
531                  -iniconfig btable
532    $tlf.t fillStatistics $sergrp
533    $tl bind <Control-F4> [list $tl kill]
534    pack $tlf.t -fill both -expand yes
535  }
536}
537
538
539#/////////////////////////////////////////////////////////////////////////////
540proc ::SeriesGraph::OptionAverage {this} {
541#
542#///////////////////////////////////////////////////////////////////////////// 
543  upvar \#0 ${this}::data data
544  upvar \#0 ${this}::options opt
545  set gr $data(gr,active)
546 
547  set opt(gr,$gr,sergrp,yMarkerAve) [expr !$opt(gr,$gr,sergrp,yMarkerAve)]
548  OptionsApplyYMarker    $this ${this}::options gr,$gr,sergrp {Ave Average}
549
550}
551
552
553#/////////////////////////////////////////////////////////////////////////////
554proc ::SeriesGraph::OptionStdDev {this} {
555#
556#///////////////////////////////////////////////////////////////////////////// 
557  upvar \#0 ${this}::data data
558  upvar \#0 ${this}::options opt
559  set gr $data(gr,active)
560 
561  set opt(gr,$gr,sergrp,yMarkerDev) [expr !$opt(gr,$gr,sergrp,yMarkerDev)]
562  OptionsApplyYMarkerNDev    $this ${this}::options gr,$gr,sergrp
563}
564
565
566#/////////////////////////////////////////////////////////////////////////////
567proc ::SeriesGraph::AccumulateGraph {this} {
568#
569#///////////////////////////////////////////////////////////////////////////// 
570  set grpath [::bayesGraph::getActiveGraph $this]
571  set sergrpOld [getSerGroup $this]
572
573  set tl .accgra_from_$sergrpOld
574  if [winfo exists $tl] {
575    raise $tl
576  } else {
577    set tl [::project::CreateForm $tl \
578              -title    [mc "Accumulate Time series graph"] \
579              -type     Graphs ]
580
581    set sergrp groupFrom$sergrpOld
582    eval "::tol::seriegrp create $sergrp {FinSemMes}"
583    wm withdraw $tl
584
585    set Instance [::SeriesGraph::Create $tl.g $sergrp]
586    bind $tl.g <Destroy> +[list ::tol::seriegrp destroy $sergrp]
587    pack $tl.g -fill both -expand yes
588    wm withdraw $tl
589    wm deiconify $tl
590    update
591    # Esta opción se debe aplicar cuando el gráfico esté empacado
592    ::bayesGraph::GrapOptApplyAxisTicks $Instance ${Instance}::options gr,0
593    $tl bind <Control-F4> [list $tl kill]
594  }
595}
596
597
598#/////////////////////////////////////////////////////////////////////////////
599  proc ::SeriesGraph::OptionsDestroy {this} {
600#
601# PURPOSE: Called before options dialog is destroyed. This procedure is called
602#          by parent BayesGraph. Actually doesn't do anything.
603#
604# PARAMETERS:
605#   this -> Instance of BayesGraph
606#
607#/////////////////////////////////////////////////////////////////////////////
608}
609
610#/////////////////////////////////////////////////////////////////////////////
611  proc ::SeriesGraph::OptionsCreate {this ts} {
612#
613# PURPOSE: Creates especific options of a series graph. It's called by
614#          BayesGraph when general graph options are created.
615#
616# PARAMETERS:
617#   this -> Instance of BayesTable
618#   ts   -> tabset in which options must be created
619#
620#/////////////////////////////////////////////////////////////////////////////
621  #insertar tabset
622  $ts insert end Series
623  set f [frame $ts.f]
624  $ts tab configure "Series" -text "Series" -window $f\
625    -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
626
627  set w_tabset [::blt::tabset $f.ts -relief flat -highlightthickness 0\
628                        -bd 0 -outerpad 0 -tier 2 -slant right -textside right]
629  $w_tabset insert end DateFormat Axis X-Markers Y-Markers Legend
630
631  set f1 [frame $w_tabset.f1]
632  set f2 [frame $w_tabset.f2]
633  set f3 [frame $w_tabset.f3]
634  set f4 [frame $w_tabset.f4]
635  set f5 [frame $w_tabset.f5]
636
637
638  $w_tabset tab configure "DateFormat" -text [mc "Date Format"]\
639    -window $f1 -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
640  $w_tabset tab configure "Axis" -text [mc "Axis"] \
641    -window $f2 -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
642  $w_tabset tab configure "X-Markers" -text [mc "X-Markers"]\
643    -window $f3 -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
644  $w_tabset tab configure "Y-Markers" -text [mc "Y-Markers"]\
645    -window $f4 -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
646  $w_tabset tab configure "Legend" -text [mc "Legend"]\
647    -window $f5 -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
648
649
650  OptionsGet $this
651
652  OptionsCreateDateFormat $this $f1
653  OptionsCreateAxis       $this $f2
654  OptionsCreateXMarkers   $this $f3
655  OptionsCreateYMarkers   $this $f4
656  OptionsCreateLegend     $this $f5
657
658  OptionsInit  $this
659  OptionsCheck $this
660  OptionsSet   $this
661
662  grid $w_tabset -sticky news 
663  grid rowconfigure    $f 0 -weight 1
664  grid columnconfigure $f 0 -weight 1
665     
666}
667
668
669#/////////////////////////////////////////////////////////////////////////////
670proc ::SeriesGraph::ShowSpecifiers {w} {
671#
672#///////////////////////////////////////////////////////////////////////////// 
673  if [winfo exist $w.t] {
674    raise $w.t
675    return
676  }
677  set dialog [Dialog $w.t -title [mc "Format Specifiers"]\
678              -default 0 -parent $w -modal none -separator true]
679  wm resizable $dialog 0 0
680  set w [$dialog getframe]
681
682  set f1 [frame $w.f1]
683  set f2 [frame $w.f2]
684  set f3 [frame $w.f3]
685  set f4 [frame $w.f4]
686  set f5 [frame $w.f5]
687  set color1 red
688
689  label $f1.lwda -text "%W" -foreground $color1
690  label $f1.lwd  -text [mc "Long Weekday"]
691  label $f1.lmna -text "%N" -foreground $color1
692  label $f1.lmn  -text [mc "Long Month Name"]
693  label $f1.swda -text "%w" -foreground $color1
694  label $f1.swd  -text [mc "Short Weekday"]
695  label $f1.smna -text "%n" -foreground $color1
696  label $f1.smn  -text [mc "Short Month Name"]
697  grid $f1.lwda $f1.lwd -sticky nw -padx 5
698  grid $f1.lmna $f1.lmn -sticky nw -padx 5
699  grid $f1.swda $f1.swd -sticky nw -padx 5
700  grid $f1.smna $f1.smn -sticky nw -padx 5
701
702  label $f2.dna  -text "%d" -foreground $color1
703  label $f2.dn   -text [mc "Day Number"]
704  label $f2.mna  -text "%m" -foreground $color1
705  label $f2.mn   -text [mc "Month Number"]
706  label $f2.tyda -text "%y" -foreground $color1
707  label $f2.tyd  -text [mc "Two Year Digit"]
708  label $f2.fyda -text "%Y" -foreground $color1
709  label $f2.fyd  -text [mc "Four Year Digit"]
710  grid $f2.dna  $f2.dn  -sticky nw -padx 5
711  grid $f2.mna  $f2.mn  -sticky nw -padx 5
712  grid $f2.tyda $f2.tyd -sticky nw -padx 5
713  grid $f2.fyda $f2.fyd -sticky nw -padx 5
714
715  label $f3.ha  -text "%h" -foreground $color1
716  label $f3.h   -text [mc "Hour"]
717  label $f3.ia  -text "%i" -foreground $color1
718  label $f3.i   -text [mc "Minute"]
719  label $f3.sa  -text "%s" -foreground $color1
720  label $f3.s   -text [mc "Second"]
721  grid $f3.ha $f3.h   -sticky nw -padx 5
722  grid $f3.ia $f3.i   -sticky nw -padx 5
723  grid $f3.sa $f3.s   -sticky nw -padx 5
724
725
726  label $f4.fuda -text "%u" -foreground $color1
727  label $f4.fud  -text [mc "Forze uncompleted dates"]
728  label $f4.fcda -text "%c" -foreground $color1
729  label $f4.fcd  -text [mc "Forze completed dates"]
730  label $f4.psa  -text "%%" -foreground $color1
731  label $f4.ps   -text [mc "Percent symbol (%)"]
732 
733  grid $f4.fuda $f4.fud   -sticky nw -padx 5
734  grid $f4.fcda $f4.fcd   -sticky nw -padx 5
735  grid $f4.psa  $f4.ps    -sticky nw -padx 5
736 
737  Button $f5.b -image [::Bitmap::get "accept"]\
738      -helptext [mc "OK"] -relief link -compound left -text [mc "Accept"]\
739      -command "destroy $dialog"   
740
741  grid $f5.b -columnspan 2 -sticky ns
742
743  grid $f1 $f2 -sticky nw -padx 20 -pady 5
744  grid $f3 $f4 -sticky n
745  grid $f5 -sticky s -columnspan 2 -pady 3
746
747  bind $dialog <F1> "ShowHelp Tb4GraSerOpc"
748  $dialog draw
749}
750
751
752#/////////////////////////////////////////////////////////////////////////////
753proc ::SeriesGraph::OptionsCreateDateFormat {this w} {
754#
755#///////////////////////////////////////////////////////////////////////////// 
756  variable tmpOpt
757  variable formats
758
759  # X-Axis
760  TitleFrame $w.tf1 -text [mc "Format String"]
761  set f1 [$w.tf1 getframe]
762
763  set formats [list \
764     [mc "TOL Long Format"]        "%cy%Ym%md%d%uh%hi%is%s" \
765     [mc "TOL Short Format"]       "%cy%Ym%md%d" \
766     "Completo YYYY/MM/dd"    "%c%w %Y/%m/%d" \
767     "Completo dd/MM/YYYY"    "%c%w %d/%m/%Y" \
768     "Fecha larga"            "%c%W, %d de %N de %Y" \
769     "Completo dd/Month/YYYY" "%c%w %d/%n/%Y" \
770     [mc "User Defined"]]
771  foreach {cad for} $formats {
772    lappend lstCad $cad
773  }
774
775  label $f1.lFormat -text [mc Format]:
776  ComboBox $f1.cbFormat -width 30 -height 6 -editable false -values $lstCad\
777      -textvariable ::SeriesGraph::tmpOpt(var,dateFormat)\
778      -modifycmd [list ::SeriesGraph::OptionsCheckDateFormat $this]
779  label $f1.lString -text [mc String]:
780  set tmpOpt(widgets,dateString) [Entry $f1.eString -width 45 -state disabled\
781         -textvariable ::SeriesGraph::tmpOpt(var,dateString)]
782  bind $f1.eString <KeyRelease> [list ::SeriesGraph::OptionsCheckDateString $this]
783  label $f1.lView   -text [mc Sample]:
784  set tmpOpt(widgets,dateView) [Entry $f1.eView   -width 45 -state disabled\
785         -textvariable ::SeriesGraph::tmpOpt(var,dateView)]
786  button $f1.bHelp  -text [mc "Format Specifiers"] \
787         -image [::Bitmap::get infor] -compound left \
788         -command [list ::SeriesGraph::ShowSpecifiers $w]
789  frame $f1.f -width 25
790  grid $f1.f $f1.lFormat $f1.cbFormat -sticky nw -padx 2 -pady 2
791  grid ^     $f1.lString $f1.eString  -sticky nw -padx 2 -pady 2
792  grid ^     $f1.lView   $f1.eView    -sticky nw -padx 2 -pady 2
793  grid ^     $f1.bHelp   -            -column 1    -sticky nw -pady 2
794  grid rowconfigure    $f1 3 -weight 1
795  grid columnconfigure $f1 2 -weight 1
796  grid $w.tf1 -sticky news -padx 2
797  grid rowconfigure    $w 0 -weight 1
798  grid columnconfigure $w 0 -weight 1
799}
800
801
802#/////////////////////////////////////////////////////////////////////////////
803proc ::SeriesGraph::OptionsCreateAxis {this w} {
804#
805#///////////////////////////////////////////////////////////////////////////// 
806  variable tmpOpt
807
808  # X-Axis
809
810  TitleFrame $w.tf -text [mc "X-Axis Ticks"]
811  set f [$w.tf getframe]
812
813  label $f.lxAxis -text [mc "Select TimeSets for axis"]:
814  set lst [::tol::info variable TimeSet]
815  # list of values
816  foreach it $tmpOpt(var,xAxis) {
817    if { [set idx [lsearch $lst $it]] != -1} {
818      set lst [lreplace $lst $idx $idx]
819    } else  {
820      set idx [lsearch $tmpOpt(var,xAxis) $it]
821      set tmpOpt(var,xAxis) [lreplace $tmpOpt(var,xAxis) $idx $idx]
822    }
823  }
824  set tmpOpt(widget,xAxisMSEL) \
825    [bmultiselect $f.msel -unsel $lst -sel $tmpOpt(var,xAxis)]
826
827
828  frame $f.f -width 25
829  grid $f.lxAxis - -sticky nw -padx 2
830  #grid $f.f $f.msel   -sticky nw -padx 10 -pady 2
831  grid $f.f $f.msel   -sticky news -padx 10 -pady 2 
832  grid rowconfigure    $f 1 -weight 1
833  grid columnconfigure $f 1 -weight 1
834  grid $w.tf -sticky news -padx 2
835  grid rowconfigure    $w 0 -weight 1
836  grid columnconfigure $w 0 -weight 1
837}
838
839
840#/////////////////////////////////////////////////////////////////////////////
841proc ::SeriesGraph::OptionsCreateXMarkers {this w} {
842#
843#///////////////////////////////////////////////////////////////////////////// 
844  upvar \#0 ${this}::widgets widgets
845  upvar \#0 ${this}::data data
846  upvar \#0 ${this}::options opt
847  variable tmpOpt
848
849  set gr $data(gr,active)
850  set g $widgets(gr,$gr)
851
852  # X-Markers
853  set w_tabset [::blt::tabset $w.ts -relief flat -highlightthickness 0\
854        -bd 0 -outerpad 0 -tier 2 -slant right -textside right]
855  $w_tabset insert end Markers Style
856
857  set f1 [frame $w_tabset.f1]
858  set f2 [frame $w_tabset.f2]
859
860  $w_tabset tab configure "Markers" -text [mc "Markers"]\
861        -window $f1 -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
862  $w_tabset tab configure "Style" -text [mc "Style"] \
863        -window $f2 -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
864
865  TitleFrame $f1.tf -text [mc "X-Markers"]
866  set f [$f1.tf getframe]
867  label $f.lxMarker -text [mc "Select TimeSets to mark"]:
868  set lst [::tol::info variable TimeSet]
869  # list of values
870  foreach it $tmpOpt(var,xMarkers) {
871    if { [set idx [lsearch $lst $it]] != -1} {
872      set lst [lreplace $lst $idx $idx]
873    } else  {
874      set idx [lsearch $tmpOpt(var,xMarkers) $it]
875      set tmpOpt(var,xMarkers) [lreplace $tmpOpt(var,xMarkers) $idx $idx]
876    }
877  }
878
879  set tmpOpt(widget,xMarkerMSEL) \
880    [bmultiselect $f.msel -unsel $lst -sel $tmpOpt(var,xMarkers)] 
881
882  frame $f.f -width 25
883  grid $f.lxMarker - -sticky nw -padx 2
884  grid $f.f $f.msel     -sticky news -padx 10 -pady 2
885  grid rowconfigure    $f 1 -weight 1
886  grid columnconfigure $f 1 -weight 1
887
888  grid $f1.tf -sticky news -padx 2
889  grid rowconfigure    $f1 0 -weight 1
890  grid columnconfigure $f1 0 -weight 1 
891
892
893  TitleFrame $f2.tf -text [mc "X-Markers Style"]
894  set f [$f2.tf getframe]
895 
896  label $f.lStyle -text [mc "Choose lines color, type and width for 5 X-Markers"]:
897  for {set i 0} {$i < 5} {incr i} {
898    label $f.lDesc$i -text "[mc Marker] [expr $i+1]:"
899    label $f.lColor$i -text [mc Color]:
900    bcolor $f.fColor$i -variable ::SeriesGraph::tmpOpt(var,xMarkerColor$i)
901    label $f.lDashes$i -text [mc "Style"]:
902    ::Objects::ComboDashesCreate ::SeriesGraph::tmpOpt(var,xMarkerDashes$i) $f.sbDashes$i
903    label   $f.lWidth$i -text [mc "Width"]:
904    SpinBox $f.sbWidth$i -justify right -width 4 -editable 0 -range {0 10}\
905            -textvariable ::SeriesGraph::tmpOpt(var,xMarkerWidth$i)
906  }
907
908  grid $f.lStyle - - - - - - - -sticky nw -padx 2 -pady 2
909  frame $f.f -width 25
910  for {set i 0} {$i < 5} {incr i} {
911    grid $f.f $f.lDesc$i $f.lColor$i $f.fColor$i $f.lDashes$i $f.sbDashes$i\
912              $f.lWidth$i $f.sbWidth$i -sticky nw -padx 2
913  } 
914
915  grid columnconfigure $f 1 -pad 10
916  grid columnconfigure $f 3 -pad 20
917  grid columnconfigure $f 5 -pad 20
918  grid columnconfigure $f 7 -pad 20
919
920  grid rowconfigure    $f 6 -weight 1
921  grid columnconfigure $f 8 -weight 1
922   
923  grid $f2.tf -sticky news -padx 2
924  grid rowconfigure    $f2 0 -weight 1
925  grid columnconfigure $f2 0 -weight 1
926   
927  grid $w_tabset -sticky news
928  grid rowconfigure    $w 0 -weight 1
929  grid columnconfigure $w 0 -weight 1
930}
931
932
933#/////////////////////////////////////////////////////////////////////////////
934proc ::SeriesGraph::OptionsCreateYMarkers {this w} {
935#
936#///////////////////////////////////////////////////////////////////////////// 
937  upvar \#0 ${this}::widgets widgets
938  upvar \#0 ${this}::data data
939  variable tmpOpt
940 
941  set gr $data(gr,active)
942  set g $widgets(gr,$gr) 
943
944  # Y-Markers
945  TitleFrame $w.tf -text [mc "Y-Markers"]
946  set f [$w.tf getframe]
947  label $f.lyMarker -text [mc "Select Statistics to mark"]:
948
949  foreach {key txt} {Ave "Average" Dev "Std. Dev." Var "Varianze" Med "Median"
950                     Max "Maximun" Min "Minimun"} {
951    checkbutton $f.ch$key -text [mc $txt]   -highlightthickness 0\
952     -pady 0 -padx 0 -variable ::SeriesGraph::tmpOpt(var,yMarker$key) 
953    label $f.lColor$key -text [mc Color]:
954    bcolor $f.fColor$key -optmenu 2 \
955      -variable ::SeriesGraph::tmpOpt(var,yMarkerColor$key)
956    label $f.lDashes$key -text [mc "Style"]:
957    ::Objects::ComboDashesCreate ::SeriesGraph::tmpOpt(var,yMarkerDashes$key) $f.sbDashes$key
958    label   $f.lWidth$key -text [mc "Width"]:
959    SpinBox $f.sbWidth$key -justify right -width 4 -editable 0 -range {0 10}\
960            -textvariable ::SeriesGraph::tmpOpt(var,yMarkerWidth$key)
961  }
962  frame $f.fNDev
963  label $f.fNDev.lNDev -text [mc "Draw Average +- "]
964  SpinBox $f.fNDev.sbNDev -justify right -width 4 -editable 0 -range {1 10}\
965            -textvariable ::SeriesGraph::tmpOpt(var,yMarkerNDev)
966  label $f.fNDev.lNDev2 -text [mc "Std. Dev."]
967 
968  grid $f.fNDev.lNDev $f.fNDev.sbNDev $f.fNDev.lNDev2 -sticky nw -padx 2
969
970  grid $f.lyMarker - - - - - - -sticky nw -padx 2 -pady 4
971  frame $f.f -width 25
972  set key Ave
973  grid $f.f $f.ch$key $f.lColor$key $f.fColor$key $f.lDashes$key $f.sbDashes$key \
974         $f.lWidth$key $f.sbWidth$key -sticky nw -padx 2
975  foreach key {Dev Var Med Max Min} {
976    grid ^ $f.ch$key $f.lColor$key $f.fColor$key $f.lDashes$key $f.sbDashes$key \
977         $f.lWidth$key $f.sbWidth$key -sticky nw -padx 2
978  }
979  grid ^ ^ $f.fNDev - - - - - -sticky nw -padx 2 -pady 4
980  grid rowconfigure    $f 7 -weight 1
981  grid columnconfigure $f 1 -pad 10
982  grid columnconfigure $f 3 -pad 20
983  grid columnconfigure $f 5 -pad 20
984  grid columnconfigure $f 7 -weight 1
985 
986  grid $w.tf -sticky news -padx 2
987  grid rowconfigure    $w 0 -weight 1
988  grid columnconfigure $w 0 -weight 1
989
990}
991
992#/////////////////////////////////////////////////////////////////////////////
993proc ::SeriesGraph::OptionsCreateLegend {this w} {
994#
995# PURPOSE: Opciones sobre la leyenda
996#
997# PARAMETERS:
998#   this   -> Instance of BayesGraph
999#   w -> frame
1000#
1001#/////////////////////////////////////////////////////////////////////////////
1002  variable tmpOpt
1003
1004  # Legend
1005  TitleFrame $w.tf -text [mc "Legend"]
1006  set f [$w.tf getframe]
1007  checkbutton $f.cbshow -text [mc "showDesc"] -highlightthickness 0\
1008     -pady 0 -padx 0 -variable ::SeriesGraph::tmpOpt(var,lineShowDescription)
1009
1010  grid $f.cbshow       -sticky nw
1011  grid rowconfigure    $f 1 -weight 1
1012  grid columnconfigure $f 1 -weight 1
1013 
1014  grid $w.tf           -sticky news -padx 2
1015  grid rowconfigure    $w 0 -weight 1
1016  grid columnconfigure $w 0 -weight 1
1017}
1018
1019#/////////////////////////////////////////////////////////////////////////////
1020  proc ::SeriesGraph::OptionsGet {this} {
1021#
1022# PURPOSE: Initializes all options variables and stores them into the
1023#          temporary 'tmpOpt' array.
1024#
1025# PARAMETERS:
1026#   this   -> Instance of BayesGraph
1027#
1028#/////////////////////////////////////////////////////////////////////////////
1029  upvar \#0 ${this}::data data
1030  upvar \#0 ${this}::options opt
1031  variable tmpOpt
1032
1033  set gr $data(gr,active)
1034  set g [::bayesGraph::getActiveGraph $this]
1035  set sergrp [getSerGroup $this]
1036
1037  set tmpOpt(var,dateString)   $opt(gr,${gr},sergrp,dateString)
1038
1039  #Opciones inicializadas desde código
1040  #if {[info exist ${this}::options(gr,${gr},sergrp,xMarkers)]}
1041  set tmpOpt(var,xMarkers)  $opt(gr,$gr,sergrp,xMarkers)
1042  set tmpOpt(var,yMarkers)  $opt(gr,$gr,sergrp,yMarkers)
1043  set tmpOpt(var,xAxis)     $opt(gr,$gr,sergrp,xAxis)
1044  set i 0
1045  foreach color $opt(gr,$gr,sergrp,xMarkersColors) {
1046    set tmpOpt(var,xMarkerColor$i) $color
1047    incr i
1048  }
1049  set i 0
1050  foreach width $opt(gr,$gr,sergrp,xMarkersWidths) {
1051    set tmpOpt(var,xMarkerWidth$i) $width
1052    incr i
1053  }
1054  set i 0
1055  foreach dashes $opt(gr,$gr,sergrp,xMarkersDashes) {
1056    set tmpOpt(var,xMarkerDashes$i) $dashes
1057    incr i
1058  }
1059  foreach key {Ave Dev Var Med Max Min} {
1060    set tmpOpt(var,yMarker$key)       $opt(gr,$gr,sergrp,yMarker$key)
1061    set tmpOpt(var,yMarkerColor$key)  $opt(gr,$gr,sergrp,yMarkerColor$key) 
1062    set tmpOpt(var,yMarkerDashes$key) $opt(gr,$gr,sergrp,yMarkerDashes$key)
1063    set tmpOpt(var,yMarkerWidth$key)  $opt(gr,$gr,sergrp,yMarkerWidth$key)
1064  }
1065  set tmpOpt(var,yMarkerNDev) $opt(gr,$gr,sergrp,yMarkerNDev)
1066
1067  set tmpOpt(var,lineShowDescription) $opt(gr,$gr,sergrp,lineShowDescription)
1068
1069}
1070
1071
1072#/////////////////////////////////////////////////////////////////////////////
1073proc ::SeriesGraph::OptionsInit {this} {
1074#
1075#///////////////////////////////////////////////////////////////////////////// 
1076
1077}
1078
1079
1080#/////////////////////////////////////////////////////////////////////////////
1081  proc ::SeriesGraph::OptionsSet {this} {
1082#
1083# PURPOSE: Commits all options values from the temporary 'tmpOpt' array to
1084#          other structure.
1085#
1086# PARAMETERS:
1087#   this   -> Instance of BayesGraph
1088#
1089#/////////////////////////////////////////////////////////////////////////////
1090  upvar \#0 ${this}::widgets widgets
1091  upvar \#0 ${this}::data data
1092  upvar \#0 ${this}::options options
1093  set gr $data(gr,active)
1094  variable tmpOpt
1095
1096  regsub -all var, [array names ::SeriesGraph::tmpOpt var,*] "" optNames
1097  foreach it $optNames {
1098    set options(gr,$gr,sergrp,$it) $tmpOpt(var,$it)
1099  }
1100}
1101
1102
1103#/////////////////////////////////////////////////////////////////////////////
1104proc ::SeriesGraph::OptionsApply {this} {
1105#
1106#///////////////////////////////////////////////////////////////////////////// 
1107  variable tmpOpt
1108  OptionsApplyDateFormat $this $tmpOpt(var,dateString)
1109
1110  set lstXAxis  [$tmpOpt(widget,xAxisMSEL) cget -sel] 
1111  set tmpOpt(var,xAxis) $lstXAxis
1112  OptionsApplyAxis       $this $lstXAxis
1113
1114  set ::SeriesGraph::tmpOpt(var,xMarkersColors) {}
1115  set ::SeriesGraph::tmpOpt(var,xMarkersDashes) {}
1116  set ::SeriesGraph::tmpOpt(var,xMarkersWidths) {}
1117  for {set i 0} {$i < 5} {incr i} {
1118    lappend tmpOpt(var,xMarkersColors) $tmpOpt(var,xMarkerColor$i)
1119    lappend tmpOpt(var,xMarkersDashes) $tmpOpt(var,xMarkerDashes$i)
1120    lappend tmpOpt(var,xMarkersWidths) $tmpOpt(var,xMarkerWidth$i)
1121  }
1122
1123  set lstXMarkers [$tmpOpt(widget,xMarkerMSEL) cget -sel] 
1124  set tmpOpt(var,xMarkers) $lstXMarkers
1125  OptionsApplyXMarkers $this $lstXMarkers $tmpOpt(var,xMarkersColors) \
1126         $tmpOpt(var,xMarkersDashes) $tmpOpt(var,xMarkersWidths)
1127
1128  OptionsApplyYMarkers  $this ::SeriesGraph::tmpOpt var
1129  #Save options after apply
1130  OptionsSet $this
1131}
1132
1133
1134#/////////////////////////////////////////////////////////////////////////////
1135proc ::SeriesGraph::OptionsApplyDateFormat {this dateString} {
1136#
1137#///////////////////////////////////////////////////////////////////////////// 
1138  set g [::bayesGraph::getActiveGraph $this]
1139  set sergrp [getSerGroup $this]
1140  $sergrp format $dateString
1141  $g axis view x
1142}
1143
1144
1145#/////////////////////////////////////////////////////////////////////////////
1146proc ::SeriesGraph::OptionsApplyAxis {this lstXAxis} {
1147#
1148#/////////////////////////////////////////////////////////////////////////////
1149  set  MAXTICKS 10001.0
1150  set g      [::bayesGraph::getActiveGraph $this]
1151  set sergrp [getSerGroup $this]
1152
1153  $g axis configure x -majorticks ""
1154  if {[llength $lstXAxis]} {   
1155    catch {eval $sergrp ticks add $lstXAxis}
1156    set _majorticks [list ]
1157    foreach tms $lstXAxis {
1158      if {![catch {::tol::info var TimeSet $tms}]} {
1159        set _majorticks [lunion $_majorticks [$sergrp ticks get $tms]]
1160      }
1161    }
1162    set _majorticks [lsort $_majorticks]
1163    set length [llength $_majorticks]
1164    if {$length >= $MAXTICKS} {
1165      set P [expr {int(ceil($length/$MAXTICKS))}]
1166      set majorticks [list]
1167      for {set idx 0} {$idx < $length} {incr idx $P} {
1168        lappend majorticks [lindex $_majorticks $idx]
1169      }
1170    } else {
1171      set majorticks $_majorticks
1172    }
1173    $g axis configure x -majorticks $majorticks
1174    catch {eval $sergrp ticks remove $lstXAxis}
1175  }
1176}
1177
1178
1179#/////////////////////////////////////////////////////////////////////////////
1180proc ::SeriesGraph::OptionsApplyXMarkers {this lstXMarkers lstColors lstDashes lstWidths} {
1181#
1182#///////////////////////////////////////////////////////////////////////////// 
1183  variable tmpOpt
1184  set g      [::bayesGraph::getActiveGraph $this]
1185  set sergrp [getSerGroup $this]
1186 
1187  #foreach marker [$g marker names] {
1188  #  $g marker delete $marker
1189  #}
1190 
1191  #X-Markers
1192  if [llength $lstXMarkers] {
1193    set coltbl $lstColors
1194    ::bayesGraph::CreateColorTable coltbl [llength $lstXMarkers]
1195    set dif [expr [llength $lstXMarkers] - [llength lstDashes]]
1196    for {set i 0} {$i < $dif} {incr i} {
1197       lappend lstDashes {2 2}
1198       lappend lstWidths 1
1199    }
1200    set i 0
1201    catch {eval $sergrp ticks add $lstXMarkers}
1202    foreach tms $lstXMarkers {
1203      if {![catch {::tol::info var [list TimeSet $tms]}]} {
1204        $g marker bind $tms <Enter> [list ::bayesGraph::WriteInfo $this "[mc Marker]X: $tms"]
1205        $g marker bind $tms <Leave> [list ::bayesGraph::WriteInfo $this ""]
1206        set color  [lindex $coltbl $i]
1207        set dashes [lindex $lstDashes $i]
1208        set width  [lindex $lstWidths $i]
1209        Tolcon_Trace "DEBUG=[$sergrp ticks get $tms]"
1210        foreach x [$sergrp ticks get $tms] {
1211          catch {$g marker create line -name ${i}_$x -coords [list $x -Inf $x Inf] \
1212                        -outline $color -dashes $dashes -linewidth $width -bindtags $tms}
1213        }
1214        incr i
1215      }
1216    }
1217    catch {eval $sergrp ticks remove $lstXMarkers}
1218  }
1219}
1220
1221
1222#/////////////////////////////////////////////////////////////////////////////
1223  proc ::SeriesGraph::OptionsApplyYMarker {this var pre marker} {
1224#
1225# PURPOSE:
1226#
1227# PARAMETERS:
1228#   this  ->
1229#   var   ->
1230#   pre   ->
1231#   maker -> list with {key name} of statistic. Example: {Ave Average}
1232#
1233#/////////////////////////////////////////////////////////////////////////////
1234  upvar \#0 $var ary
1235  set g      [::bayesGraph::getActiveGraph $this]
1236  set sergrp [getSerGroup $this]
1237  foreach {key name} $marker { }
1238  for {set i 0} {$i < [$sergrp serie size]} {incr i} {
1239    if $ary(${pre},yMarker$key) {
1240      set y [lindex [lindex [::tol::seriestat [$sergrp serie $i reference] $name] 1] 1]
1241      if {[string equal $y "?"]} {
1242        tk_messageBox -parent $g -type ok -title [mc "Warning"] \
1243          -message [mc "Cant draw %1\$s y marker because its value is ?" [mc $name]]
1244      } else  {
1245        set nameSer [$g line cget l${i}-0 -label]
1246#rcsoto
1247        set mapY    [$g line cget l${i}-0 -mapy]
1248        set text "[mc Marker]Y: [mc $name] [mc of] $nameSer: $y"
1249        if [string equal $ary(${pre},yMarkerColor$key) "defcolor"] {
1250          if {[$g element type l${i}-0] eq "LineElement"} {
1251            set color [$g line cget l${i}-0 -color]
1252          } else {
1253            set color [$g line cget l${i}-0 -background]
1254          }
1255        } else  {
1256          set color $ary(${pre},yMarkerColor$key)
1257        }
1258        set dashes  $ary(${pre},yMarkerDashes$key)
1259        set width   $ary(${pre},yMarkerWidth$key)
1260        $g marker bind $name$nameSer <Enter> [list ::bayesGraph::WriteInfo $this $text]
1261        $g marker bind $name$nameSer <Leave> [list ::bayesGraph::WriteInfo $this ""]
1262        $g marker create line -name ${i}_$key -coords [list -Inf $y Inf $y]\
1263          -outline $color -dashes $dashes -linewidth $width \
1264          -bindtags $name$nameSer -mapy $mapY
1265      }   
1266    } else  {
1267      if [llength [$g marker names ${i}_$key]] {
1268        $g marker delete ${i}_$key
1269      }
1270    }
1271  }
1272}
1273
1274
1275#/////////////////////////////////////////////////////////////////////////////
1276proc ::SeriesGraph::OptionsApplyYMarkerNDev {this var pre} {
1277#
1278#///////////////////////////////////////////////////////////////////////////// 
1279  upvar \#0 $var ary
1280  set g      [::bayesGraph::getActiveGraph $this]
1281  set sergrp [getSerGroup $this]
1282
1283  for {set i 0} {$i < [$sergrp serie size]} {incr i} {
1284    if $ary(${pre},yMarkerDev) {
1285      set dev [lindex [lindex [::tol::seriestat [$sergrp serie $i reference] "Std. Dev."] 1] 1]
1286      set avg [lindex [lindex [::tol::seriestat [$sergrp serie $i reference] "Average"] 1] 1]
1287      if {[expr [string equal $dev "?"] || [string equal $avg "?"]]} {
1288        tk_messageBox -parent $g -type ok -title [mc "Warning"] \
1289         -message [mc "Cant draw '%1\$s' y marker because its value is ?" [mc {Std. Dev.}]]
1290      } else {
1291        set y1 [expr $avg + $ary(${pre},yMarkerNDev) * $dev]
1292        set y2 [expr $avg - $ary(${pre},yMarkerNDev) * $dev]
1293        set nameSer [$g line cget l${i}-0 -label]
1294       
1295        set text1 "[mc Marker] Y: [mc "Average"] + $ary(${pre},yMarkerNDev) * [mc "Std. Dev."] [mc of] $nameSer: $y1"
1296        set text2 "[mc Marker] Y: [mc "Average"] - $ary(${pre},yMarkerNDev) * [mc "Std. Dev."] [mc of] $nameSer: $y2"
1297        if [string equal $ary(${pre},yMarkerColorDev) "defcolor"] {
1298          if {[$g element type l${i}-0] eq "LineElement"} {
1299            set color [$g line cget l${i}-0 -color]
1300          } else {
1301            set color [$g line cget l${i}-0 -background]
1302          }
1303        } else  {
1304            set color $ary(${pre},yMarkerColorDev)
1305        }
1306        set dashes  $ary(${pre},yMarkerDashesDev)
1307        set width   $ary(${pre},yMarkerWidthDev)
1308        $g marker bind StdDev1$nameSer <Enter> [list ::bayesGraph::WriteInfo $this $text1]
1309        $g marker bind StdDev2$nameSer <Enter> [list ::bayesGraph::WriteInfo $this $text2]
1310        $g marker bind StdDev1$nameSer <Leave> [list ::bayesGraph::WriteInfo $this ""]
1311        $g marker bind StdDev2$nameSer <Leave> [list ::bayesGraph::WriteInfo $this ""]
1312        $g marker create line -name ${i}_std1 -coords [list -Inf $y1 Inf $y1]\
1313                -outline $color -dashes $dashes -linewidth $width -bindtags StdDev1$nameSer
1314        $g marker create line -name ${i}_std2 -coords [list -Inf $y2 Inf $y2]\
1315                -outline $color -dashes $dashes -linewidth $width -bindtags StdDev2$nameSer
1316      }   
1317    } else {
1318      if [llength [$g marker names ${i}_std1]] {
1319        $g marker delete ${i}_std1
1320        $g marker delete ${i}_std2
1321      }
1322    }
1323  }
1324}
1325
1326
1327#/////////////////////////////////////////////////////////////////////////////
1328proc ::SeriesGraph::OptionsApplyYMarkers {this var pre} {
1329#
1330#///////////////////////////////////////////////////////////////////////////// 
1331  foreach stat {{Ave "Average"} {Var "Varianze"} {Med "Median"} {Max "Maximun"} {Min "Minimun"}} {
1332    OptionsApplyYMarker $this $var $pre $stat
1333  }
1334  OptionsApplyYMarkerNDev $this $var $pre
1335}
1336
1337
1338#/////////////////////////////////////////////////////////////////////////////
1339proc ::SeriesGraph::OptionsCheck {this} {
1340#
1341#///////////////////////////////////////////////////////////////////////////// 
1342  OptionsCheckDateString $this
1343  #OptionsCheckDateFormat $this
1344}
1345
1346
1347#/////////////////////////////////////////////////////////////////////////////
1348proc ::SeriesGraph::OptionsCheckDateFormat {this} {
1349#
1350#///////////////////////////////////////////////////////////////////////////// 
1351  variable tmpOpt
1352  variable formats
1353
1354  if [string equal $tmpOpt(var,dateFormat) [mc "User Defined"]] {
1355    $tmpOpt(widgets,dateString) configure -state normal
1356    #set tmpOpt(var,dateString) ""
1357  } else  {
1358    $tmpOpt(widgets,dateString) configure -state disabled
1359    set idx [lsearch -exact $formats $tmpOpt(var,dateFormat)]
1360    set tmpOpt(var,dateString) [lindex $formats [expr $idx+1]]
1361    #Coger la fecha del sistema, aplicarle el formato y mostrarla
1362    set tmpOpt(var,dateView) [::tol::date now $tmpOpt(var,dateString)]
1363
1364  }
1365}
1366
1367
1368#/////////////////////////////////////////////////////////////////////////////
1369proc ::SeriesGraph::OptionsCheckDateString {this} {
1370#
1371#///////////////////////////////////////////////////////////////////////////// 
1372  variable tmpOpt
1373  variable formats
1374
1375  if {[set idx [lsearch -exact $formats $tmpOpt(var,dateString)]] != -1} {
1376    set tmpOpt(var,dateFormat) [lindex $formats [expr $idx-1]]
1377  } else  {
1378    set tmpOpt(var,dateFormat) [lindex $formats end]
1379    $tmpOpt(widgets,dateString) configure -state normal
1380  }
1381  set tmpOpt(var,dateView) [::tol::date now $tmpOpt(var,dateString)]
1382}
1383
1384
1385#/////////////////////////////////////////////////////////////////////////////
1386  proc ::SeriesGraph::ReadIni {this} {
1387#
1388# PURPOSE: Reads series graph specific options from .ini file. First of all,
1389#          reads options from BayesGraph. Ini file is the active graphic
1390#          configuration file.
1391#
1392# PARAMETERS:
1393#   this  -> Instance of BayesGraph
1394#
1395#/////////////////////////////////////////////////////////////////////////////
1396  upvar \#0 ${this}::data data
1397  upvar \#0 ${this}::options opt
1398  #set rini ::iniFile::Read
1399  set rini ::iniFile::ReadGCF
1400  #Leer las opciones específicas
1401
1402  for  {set gr 0} {$gr<$data(gr,numGraph)} {incr gr} {
1403    set sergrp $data(gr,$gr,sergrp)
1404    set opt(gr,$gr,sergrp,dateString) [$rini SeriesGraph dateString [$sergrp format]]
1405    set opt(gr,$gr,sergrp,xMarkers)   [$rini SeriesGraph SxMarkers   {}]
1406    set opt(gr,$gr,sergrp,xMarkersColors) [$rini SeriesGraph SxMarkersColors\
1407         {#356a6a #804000 #05eefa #009148 #ffffbb}]
1408    set opt(gr,$gr,sergrp,xMarkersWidths) \
1409        [$rini SeriesGraph SxMarkersWidths   {1 1 1 1 1}]
1410    set opt(gr,$gr,sergrp,xMarkersDashes) \
1411        [$rini SeriesGraph SxMarkersDashes   {{1 1} {2 2} {3 3} {4 4} {5 5}}]
1412    foreach key {Ave Dev Var Med Max Min} {
1413      set opt(gr,$gr,sergrp,yMarker$key)  [$rini SeriesGraph SyMarker$key  0]
1414      set opt(gr,$gr,sergrp,yMarkerColor$key)  [$rini SeriesGraph SyMarkerColor$key  defcolor]
1415      set opt(gr,$gr,sergrp,yMarkerDashes$key) [$rini SeriesGraph SyMarkerDashes$key  {3 1}]
1416      set opt(gr,$gr,sergrp,yMarkerWidth$key)  [$rini SeriesGraph SyMarkerWidth$key   1]
1417    }
1418    set opt(gr,$gr,sergrp,yMarkerNDev)  [$rini SeriesGraph SyMarkerNDev   2]
1419    set opt(gr,$gr,sergrp,yMarkers)     [$rini SeriesGraph SyMarkers   {}]
1420    set opt(gr,$gr,sergrp,xAxis)        [$rini SeriesGraph SxAxis      {}]
1421    set opt(gr,$gr,sergrp,lineShowDescription) \
1422      [$rini SeriesGraph lineShowDescription 0]
1423  }
1424  #Leer las opciones de bayesGraph
1425  ::bayesGraph::ReadIni $this
1426}
1427
1428
1429#/////////////////////////////////////////////////////////////////////////////
1430  proc ::SeriesGraph::WriteIni {this} {
1431#
1432# PURPOSE: Writes series graph specific options to .ini file. This procedure
1433#          is called by parent BayesGraph. Ini file is the active graphic
1434#          configuration file.
1435#
1436# PARAMETERS:
1437#   this  -> Instance of BayesGraph
1438#
1439#/////////////////////////////////////////////////////////////////////////////
1440  upvar \#0 ${this}::data data
1441  upvar \#0 ${this}::widgets widgets
1442  upvar \#0 ${this}::options opt
1443 
1444  set gr $data(gr,active)
1445  #set wini ::iniFile::Write
1446  set wini ::iniFile::WriteGCF
1447
1448  $wini SeriesGraph dateString $opt(gr,$gr,sergrp,dateString)
1449  $wini SeriesGraph SxMarkers  $opt(gr,$gr,sergrp,xMarkers)
1450  $wini SeriesGraph SxMarkersColors  $opt(gr,$gr,sergrp,xMarkersColors)
1451  $wini SeriesGraph SxMarkersWidths  $opt(gr,$gr,sergrp,xMarkersWidths)
1452  $wini SeriesGraph SxMarkersDashes  $opt(gr,$gr,sergrp,xMarkersDashes)
1453  foreach key {Ave Dev Var Med Max Min} {
1454    $wini SeriesGraph SyMarker$key       $opt(gr,$gr,sergrp,yMarker$key)
1455    $wini SeriesGraph SyMarkerColor$key  $opt(gr,$gr,sergrp,yMarkerColor$key) 
1456    $wini SeriesGraph SyMarkerDashes$key $opt(gr,$gr,sergrp,yMarkerDashes$key)
1457    $wini SeriesGraph SyMarkerWidth$key  $opt(gr,$gr,sergrp,yMarkerWidth$key)
1458  }
1459  $wini SeriesGraph SyMarkerNDev $opt(gr,$gr,sergrp,yMarkerNDev)
1460  $wini SeriesGraph SyMarkers  $opt(gr,$gr,sergrp,yMarkers)
1461  $wini SeriesGraph SxAxis     $opt(gr,$gr,sergrp,xAxis)
1462
1463  $wini SeriesGraph lineShowDescription \
1464    $opt(gr,$gr,sergrp,lineShowDescription)
1465}
Note: See TracBrowser for help on using the repository browser.