Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Accepted changes by Frank Gover for robustness of bbox handles. Accepted plotchart based examples for multiple bounded crosshairs. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | crosshair-bboxes-3603562 |
Files: | files | file ages | folders |
SHA1: | 6548d8e6e5abbd25a545899d830294c92595f541 |
User & Date: | andreask 2013-02-25 19:59:05 |
Context
2013-02-25
| ||
20:13 | Do not invoke the tracking callback while the crosshairs are out of bounds. Closed-Leaf check-in: 9804fb212f user: andreask tags: crosshair-bboxes-3603562 | |
19:59 | Accepted changes by Frank Gover for robustness of bbox handles. Accepted plotchart based examples for multiple bounded crosshairs. check-in: 6548d8e6e5 user: andreask tags: crosshair-bboxes-3603562 | |
2013-02-14
| ||
05:34 | [Bug 3603562]: Allow the confinement of the crosshairs to one or more rectangular bounding boxes. Bumped version to 1.1. check-in: 9382d1e073 user: aku tags: crosshair-bboxes-3603562 | |
Changes
Added examples/canvas/crosshairs_for_axes.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# test_axis.tcl -- # Test the drawing of the axis: nice rounded values? # And vertical text to right axis? # # NOTE: # Negative values require floor() instead of ceil()! # # NOTE: # Problem with right axis! # # TODO: # Floor and Ceil and less stringent check for bounds! # set base [file dirname [file dirname [file dirname [file normalize [info script]]]]] source "$base/modules/plotchart/plotchart.tcl" source "$base/modules/crosshair/crosshair.tcl" package require Plotchart grid [canvas .c1] [canvas .c2] grid [canvas .c3] [canvas .c4] # # Create the plots # set plot_axes [list { 0.12 10.4 1.0} {-0.12 10.4 2.5} \ {10.12 -10.4 -2.0} {-5.1 -4.5 0.1} \ {-0.12 10.4 2.5} { 0.12 10.4 1.0} \ {-5.1 -4.5 0.1} {10.12 -10.4 -2.0}] set i 1 foreach {x y} $plot_axes { set p($i) [::Plotchart::createXYPlot .c${i} $x $y ] incr i } set p(5) [::Plotchart::createRightAxis $p(2) {-5.99 -4.5 0.1}] $p(2) plot data 10.0 -5.0 $p(2) plot data -10.0 -5.0 $p(5) dataconfig data -colour green $p(5) plot data 10.0 -4.7 $p(5) plot data -10.0 -4.7 $p(2) vtext "my_changes" $p(5) vtext "Data" # Adding crosshairs to the plots set i 1 array set color {1 blue 2 red 3 green 4 black} foreach {x y} $plot_axes { .c${i} configure -cursor tcross crosshair::crosshair .c$i -dash {.} -fill $color($i) crosshair::track on .c$i put_coords set bbox_ll [::Plotchart::coordsToPixel [$p($i) canvas] [lindex $x 0] [lindex $y 0]] set bbox_ur [::Plotchart::coordsToPixel [$p($i) canvas] [lindex $x 1] [lindex $y 1]] #--- testing coordinate mixed up if {$i==0} { set bbox [concat $bbox_ll $bbox_ur] } elseif {$i==1} { set bbox [list [lindex $bbox_ur 0] [lindex $bbox_ll 1] [lindex $bbox_ll 0] [lindex $bbox_ur 1]] } elseif {$i==2} { set bbox [list [lindex $bbox_ll 0] [lindex $bbox_ur 1] [lindex $bbox_ur 0] [lindex $bbox_ll 1]] } else { set bbox [concat $bbox_ur $bbox_ll] } crosshair::bbox_add .c$i "$bbox" puts "plot $i ==> bbox== $bbox color = $color($i)" incr i } proc put_coords {a b c d e f g} { set pcoords [::Plotchart::pixelToCoords $a $b $c] set pcoord_x [lindex $pcoords 0] set pcoord_y [lindex $pcoords 1] puts "Canvas=$a Canvas_Coords=($b $c) PlotChart_plot_coords=([format "%.2f %.2f" $pcoord_x $pcoord_y])" } catch { console show } |
Added examples/canvas/crosshairs_for_multixyplot.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# test_txplot.tcl -- # Test the -box options for time-x-plots set base [file dirname [file dirname [file dirname [file normalize [info script]]]]] source "$base/modules/plotchart/plotchart.tcl" source "$base/modules/crosshair/crosshair.tcl" package require Plotchart pack [canvas .c -width 600 -height 410 -bg white] ::Plotchart::plotstyle configure default xyplot bottomaxis subtextcolor blue ::Plotchart::plotstyle configure default xyplot bottomaxis font "Helvetica 14" ::Plotchart::plotstyle configure default xyplot bottomaxis subtextfont "Helvetica 12 bold" ::Plotchart::plotstyle configure default xyplot leftaxis font "Helvetica 14" ::Plotchart::plotstyle configure default xyplot leftaxis subtextfont "Helvetica 12 bold" ::Plotchart::plotstyle configure default xyplot leftaxis subtextcolor red ::Plotchart::plotstyle configure default xyplot leftaxis usesubtext 1 set p1 [::Plotchart::createXYPlot .c {0 100 30} {0 20 5} -box {0 0 400 200}] set p2 [::Plotchart::createXYPlot .c {0 100 30} {0 20 5} -box {100 210 400 200}] #.c create rectangle 0 210 400 410 $p1 plot data 0 10 $p1 plot data 100 15 $p1 xtext Aha #$p1 xsubtext "1, 2, 3" $p1 ytext "Same spot?" $p2 plot data 0 10 $p2 plot data 100 15 $p2 ytext "Higher up" #$p2 ysubtext "Lower down" $p2 vtext "To the left" #$p2 vsubtext "To the right" .c configure -cursor tcross crosshair::crosshair .c -dash {.} -fill blue #crosshair::track on .c put_coords set bbox_ll [::Plotchart::coordsToPixel [$p1 canvas] 0 0 ] set bbox_ur [::Plotchart::coordsToPixel [$p1 canvas] 100 20] set bbox_p1 [concat $bbox_ll $bbox_ur] crosshair::bbox_add .c "$bbox_p1" set bbox_ll [::Plotchart::coordsToPixel [$p2 canvas] 0 0 ] set bbox_ur [::Plotchart::coordsToPixel [$p2 canvas] 100 20] set bbox_p2 [concat $bbox_ll $bbox_ur] crosshair::bbox_add .c "$bbox_p2" catch { console show } |
Changes to modules/crosshair/ChangeLog.
1 2 3 4 5 6 7 |
2013-02-13 Andreas Kupries <andreas_kupries@users.sourceforge.net> * crosshair.tcl: [Bug 3603562]: Allow the confinement of the * crosshair.man: crosshairs to one or more rectangular bounding * pkgIndex.tcl: boxes. Bumped version to 1.1. 2009-01-21 Andreas Kupries <andreas_kupries@users.sourceforge.net> |
> > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
2013-02-25 Andreas Kupries <andreas_kupries@users.sourceforge.net> * crosshair.tcl: [Bug 3603562]: Tweaks and fixes for robustness. * ../../examples/canvas/crosshair_for_axes.tcl: Examples of bounded * ../../examples/canvas/crosshair_for_multixyplot.tcl: crosshairs. 2013-02-13 Andreas Kupries <andreas_kupries@users.sourceforge.net> * crosshair.tcl: [Bug 3603562]: Allow the confinement of the * crosshair.man: crosshairs to one or more rectangular bounding * pkgIndex.tcl: boxes. Bumped version to 1.1. 2009-01-21 Andreas Kupries <andreas_kupries@users.sourceforge.net> |
Changes to modules/crosshair/crosshair.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ... 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 ... 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
# crosshair.tcl - # # Kevin's mouse-tracking crosshair in Tk's canvas widget. # # This package displays a mouse-tracking crosshair in the canvas widget. # # Copyright (c) 2003 by Kevin B. Kenny. All rights reserved. # Redistribution permitted under the terms in # http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tcl/tcl/license.terms?rev=1.3&content-type=text/plain # # Copyright (c) 2008 Andreas Kupries. Added ability to provide the tracking # information to external users. # # Copyright (c) 2013 Frank Gover, Andreas Kupries. Added ability to # bound the crosshairs to an area of the canvas. Useful # for plots. ................................................................................ proc ::crosshair::bbox_add { w bbox } { variable config if { ![info exists config($w)] } { return -code error "no crosshairs in $w" } array set opts $config($w) lappend opts(bbox) $bbox set config($w) [array get opts] set token bbox$w/[llength $opts(bbox)] return $token } #---------------------------------------------------------------------- # # ::crosshair::bbox_remove -- # ................................................................................ set llx [lindex $box 0] set lly [lindex $box 1] set urx [lindex $box 2] set ury [lindex $box 3] #puts \tTEST($x,$y):$llx,$lly,$urx,$ury:[expr {($x < $llx) || ($x > $urx) || ($y < $lly) || ($y > $ury)}] # Test each edge expr {($x < $llx) || ($x > $urx) || ($y < $lly) || ($y > $ury)} } #---------------------------------------------------------------------- # # ::crosshair::Move -- # # Moves the crosshairs in a camvas |
| < > > > > > > > > > > > > < | > | | | < > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 ... 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# crosshair.tcl - # # Kevin's mouse-tracking crosshair in Tk's canvas widget. # # This package displays a mouse-tracking crosshair in the canvas widget. # # Copyright (c) 2003 by Kevin B. Kenny. All rights reserved. # Redistribution permitted under the terms of the Tcl License. # # Copyright (c) 2008 Andreas Kupries. Added ability to provide the tracking # information to external users. # # Copyright (c) 2013 Frank Gover, Andreas Kupries. Added ability to # bound the crosshairs to an area of the canvas. Useful # for plots. ................................................................................ proc ::crosshair::bbox_add { w bbox } { variable config if { ![info exists config($w)] } { return -code error "no crosshairs in $w" } array set opts $config($w) # Sort the coordinates and make sure the bbox is in format # "lower-left upper-right". The larger Y is on the lower left and # the larger X is on the upper right. set x_coords [lsort -real -increasing [list [lindex $bbox 0] [lindex $bbox 2]]] set y_coords [lsort -real -decreasing [list [lindex $bbox 1] [lindex $bbox 3]]] set bbox [list \ [lindex $x_coords 0] [lindex $y_coords 0] \ [lindex $x_coords 1] [lindex $y_coords 1]] lappend opts(bbox) $bbox set config($w) [array get opts] set token bbox$w/[llength $opts(bbox)] return $token } #---------------------------------------------------------------------- # # ::crosshair::bbox_remove -- # ................................................................................ set llx [lindex $box 0] set lly [lindex $box 1] set urx [lindex $box 2] set ury [lindex $box 3] #puts \tTEST($x,$y):$llx,$lly,$urx,$ury:[expr {($x < $llx) || ($x > $urx) || ($y < $lly) || ($y > $ury)}] # Test each edge. Note that the border lines are considered as "outside". expr {($x <= $llx) || ($x >= $urx) || ($y >= $lly) || ($y <= $ury)} } #---------------------------------------------------------------------- # # ::crosshair::Move -- # # Moves the crosshairs in a camvas |