Changeset af3f4af in tol


Ignore:
Timestamp:
Feb 21, 2011, 11:03:45 PM (16 years ago)
Author:
Jorge Pérez <josp.jorge@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
003b0ec
Parents:
cf594ab
Message:

refs #466, show the name of the closest line in a timeserie graph

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

Location:
tolbase/lib/toltk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tolbase/lib/toltk/bysgraph.tcl

    rcf594ab raf3f4af  
    543543  upvar \#0 ${this}::widgets widgets
    544544  upvar \#0 ${this}::data data
    545   if [$widgets(gr,$numGraph) inside $x $y] {
    546     set t [expr round([$widgets(gr,$numGraph) axis invtransform x $x])]
    547     set z [format "%.2f" [$widgets(gr,$numGraph) axis invtransform y $y]]
    548     if [info exists ${this}::data(proc,OnGetLabel)] {
    549       set label [$data(proc,OnGetLabel) $this $widgets(gr,$numGraph) $t $z]
     545
     546  set graph $widgets(gr,$numGraph)
     547  if { [ $graph inside $x $y ] } {
     548    #set t [expr round([$widgets(gr,$numGraph) axis invtransform x $x])]
     549    set t [ $graph axis invtransform x $x ]
     550    set z [ format "%.2f" [ $graph axis invtransform y $y ] ]
     551    if { [ info exists ${this}::data(proc,OnGetLabel) ] } {
     552      if { [$graph element closest $x $y infoLine -interpolate yes] } {
     553        set nameLine $infoLine(name)
     554      } else {
     555        set nameLine ""
     556      }
     557      set label [$data(proc,OnGetLabel) \
     558                     $this $graph $nameLine $t $z]
    550559    } else {
    551560      set label "X = $t, Y = $z"
  • tolbase/lib/toltk/sergraph.tcl

    rcf594ab raf3f4af  
    1010namespace eval ::SeriesGraph {
    1111  variable tmpOpt
     12}
     13
     14proc ::SeriesGraph::ShowSerieInfo { Instance graph x y } {
     15  upvar \#0 ${Instance}::widgets widgets
     16  upvar \#0 ${Instance}::data data
     17 
     18  if ![$graph element closest $x $y info -interpolate yes] {
     19    beep
     20    return
     21  }
     22  parray info
     23}
     24
     25proc ::SeriesGraph::BindSerieInfo { Instance } {
     26  upvar \#0 ${Instance}::widgets widgets
     27  upvar \#0 ${Instance}::data data
     28
     29  set graph $widgets(gr,0)
     30  bind closest-point-$graph <Control-ButtonPress-2>  \
     31      [ string map [list %I $Instance] {
     32        ::SeriesGraph::ShowSerieInfo %I %W %x %y
     33      } ]
     34  blt::AddBindTag $graph closest-point-$graph
     35 
    1236}
    1337
    … …  
    3862  upvar \#0 ${Instance}::widgets widgets
    3963  upvar \#0 ${Instance}::data data
     64
     65  #::SeriesGraph::BindSerieInfo $Instance
     66  #Blt_ClosestPoint $widgets(gr,0)
    4067
    4168  set data(namespace)            SeriesGraph
    … …  
    125152          $grpath line configure l$i-$j -label ""
    126153        } else {
    127           $grpath line configure l$i-0 -label [$sergrp serie $i name]
     154          set nameSerie [$sergrp serie $i name]
     155          $grpath line configure l$i-0 -label $nameSerie
     156          set data(labels,l$i) $nameSerie
    128157        }
    129158        incr j
    … …  
    308337
    309338#/////////////////////////////////////////////////////////////////////////////
    310 proc ::SeriesGraph::GetLabel { this bltg tick y} {
     339proc ::SeriesGraph::GetLabel { this bltg name tick y} {
    311340#
    312341#///////////////////////////////////////////////////////////////////////////// 
    … …  
    314343  set gr $data(gr,active)
    315344
    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
     345  set t [ expr {round($tick)} ]
     346  if { [ catch { $data(gr,$gr,sergrp) dating $t } labelTick ] } {
     347    set labelTick $tick
     348  }
     349  if { [ regexp {(l[0-9])+(-[0-9])*} $name ==> codeLine ] } {
     350    set nameLine $data(labels,$codeLine)
     351  } else {
     352    set nameLine "NO LINE"   
     353  }
     354  return "$nameLine: ($labelTick,$y)"
    326355}
    327356
Note: See TracChangeset for help on using the changeset viewer.