diff --git a/config/generic.xml b/config/generic.xml index 39835c9b..a59f2569 100755 --- a/config/generic.xml +++ b/config/generic.xml @@ -44,6 +44,7 @@ 0 0 0 + false diff --git a/hammerdb b/hammerdb index c0e4d51a..f3d95956 100755 --- a/hammerdb +++ b/hammerdb @@ -189,7 +189,7 @@ if [info exist env(Load_List)] { } } -append modulelist { Thread msgcat tablelist_tile tooltip tkcon xml xscale ctext comm emu_graph socktest tkblt huddle jobs } +append modulelist { Thread msgcat tablelist_tile tooltip tkcon xml xscale ctext comm emu_graph socktest tkblt huddle jobs tkpath } set loadtext "Loading hammerdb modules" after 100 diff --git a/modules/emu_graph-2.0.tm b/modules/emu_graph-2.0.tm index 00055163..ce3f0d00 100755 --- a/modules/emu_graph-2.0.tm +++ b/modules/emu_graph-2.0.tm @@ -22,6 +22,9 @@ # 4. draw all non-inside segments # proc ::Ribbon::Draw {w pxy dir length} { +#we use gradients in gray for the ribbon. To prevent recreating the same gradients, once created it is stored in ribtransitions dict for reuse. +upvar #0 ribtransitions ribtransitions +if {![info exists ribtransitions]} { set ribtransitions [dict create] } set dx 4 set dy -10 @@ -64,11 +67,30 @@ for {set i 0; set i1 1} {$i < $CNT-1} {incr i; incr i1} { if {$Q($i,badR) || $Q($i1,badL)} continue set xy [concat $P($i) $Q($i) $Q($i1) $P($i1)] - set clr gray[expr {99-round(abs($P($i,beta) - 360))}] +#For each polygon in ribbon create a grayscale gradient for effect + set gval [expr {99-round(abs($P($i,beta) - 360))}] + set gvallight [expr {$gval + 20 }] + if { $gvallight > 100 } { + set gvallight 100 + } + set gvaldark [expr {$gval - 20 }] + if { $gvaldark < 0 } { + set gvaldark 0 + } + if {![ dict exists $ribtransitions $gval ] } { +#create the gradient for the angle and save for reuse + set transition [ subst {$w gradient create linear -method pad -lineartransition {1 0 0 0} \ + -stops {{0 white} {0.33 [ concat gray$gvallight ]} {0.66 [ concat gray$gval ]} {1 [ concat gray$gvaldark ]}}}] + set grad [ eval $transition ] + dict set ribtransitions $gval $grad + } else { +#gradient already created so reuse + set grad [ dict get $ribtransitions $gval ] + } #modify original to give all segments a tag for deletion - $w create poly $xy -fill $clr -outline black -tags 3dribbon - $w lower 3dribbon + eval "$w create ppolygon $xy -fill $grad -tags 3dribbon" } + $w raise 3dribbon } ##+########################################################################## @@ -247,7 +269,7 @@ proc emu_graph args { error "Usage: emu_graph graph \[options\] ($restargs)" } set emu_graph($graph,datasets) {} - set emu_graph($graph,gradsets) {} + #set emu_graph($graph,gradsets) {} # define the widget command namespace eval :: \ @@ -398,7 +420,29 @@ proc destroy {graph} { } proc redraw {graph timelist timelength} { - variable emu_graph +global tc_scale +if { [ llength $timelist ] != 0 } { +dict set tc_scale timelist $timelist +dict set tc_scale timelength [ llength [ join $timelist ]] +} +variable emu_graph +if { ([ dict get $tc_scale resize_count ] > 1) && ([ dict get $tc_scale resize_count ] > [ dict get $tc_scale last_resize ]) } { +#draw with resize +set new_height [ expr {(($emu_graph(tce,height) / 100) * [ dict get $tc_scale height_percent ]) + $emu_graph(tce,height)} ] +set new_width [ expr {(($emu_graph(tce,width) / 100) * [ dict get $tc_scale width_percent ]) + $emu_graph(tce,width)} ] +set emu_graph(tce,height) $new_height +set emu_graph(tce,width) $new_width +dict set tc_scale emu_width $new_width +dict set tc_scale emu_height $new_height +dict set tc_scale last_resize_width [ dict get $tc_scale width ] +dict set tc_scale last_resize_height [ dict get $tc_scale height ] +dict set tc_scale last_resize [ dict get $tc_scale resize_count ] +} else { +#do draw without resize +dict set tc_scale emu_width $emu_graph(tce,width) +dict set tc_scale emu_height $emu_graph(tce,height) +} + if {![is_graph $graph]} { error "$graph is not an emu_graph" } @@ -419,7 +463,6 @@ proc is_graph {graph} { } proc auto_range {graph} { - variable emu_graph if {![is_graph $graph]} { @@ -455,9 +498,11 @@ proc auto_range {graph} { [$emu_graph($graph,$tag,trackdata) end]] set xyrange [list $xrange $yrange] } elseif { [info exists emu_graph($graph,$tag,coords)] } { + ## pad coordinates to correctly autorange + set padcoords [ pad_coords $emu_graph($graph,$tag,coords) ] set xyrange [maxrange $xyrange \ [range\ - $emu_graph($graph,$tag,coords)\ + $padcoords\ $mask $maskthresh]] } } @@ -539,6 +584,9 @@ proc assign_colors {graph dataset} { } proc plot_data {graph} { +upvar #0 genericdict genericdict +catch {set ribenable [ dict get $genericdict transaction_counter tc_graph_ribbon ]} +if { ![ info exists ribenable ] } { set ribenable false } variable emu_graph @@ -551,20 +599,18 @@ proc plot_data {graph} { set x_min_c [x2canvas $graph $x_min] set x_max_c [x2canvas $graph $x_max] set y_min_c [y2canvas $graph $y_min] - set canvas $emu_graph($graph,canvas) - foreach tag $emu_graph($graph,gradsets) { - $canvas delete -withtag $tag - } - set emu_graph($graph,gradsets) {} - + #foreach tag $emu_graph($graph,gradsets) { + # $canvas delete -withtag $tag + #} + #set emu_graph($graph,gradsets) {} + #If the data has not been queried we do not enter this foreach or plot data foreach tag $emu_graph($graph,datasets) { # plot the points, first delete any old ones $canvas delete -withtag $tag $canvas delete -withtag 3dribbon set tags [list graph$graph data$graph $tag] - if { [info exists emu_graph($graph,$tag,trackdata)] } { ## get coords data from an emu trackdata object set coords \ @@ -575,13 +621,12 @@ proc plot_data {graph} { $emu_graph($graph,ymin) $emu_graph($graph,ymax)\ $emu_graph($graph,yfactor) $emu_graph($graph,yref)] } elseif { [info exists emu_graph($graph,$tag,coords)] } { - ## coords have been supplied - set coords \ - [scale_points $graph $emu_graph($graph,$tag,coords)] + ## coords have been supplied, these are the transaction count numbers + set padcoords [ pad_coords $emu_graph($graph,$tag,coords) ] + set coords [ scale_points $graph $padcoords ] } else { set coords {} } - # we may have a masking vector if { [info exists emu_graph($graph,$tag,mask)] } { set mask $emu_graph($graph,$tag,mask) @@ -614,67 +659,59 @@ proc plot_data {graph} { set ribcoords $coords set coords [concat $x_min_c $y_min_c $coords $x_max_c $y_min_c ] - #grab last 6 points for gradient poly - set lastsixcoords [ lrange $coords end-5 end ] - #complete grad coordinates by adding pair at bottom of line in line with last point - set gradcoords [ concat [ lindex $lastsixcoords 0 ] [ lindex $lastsixcoords end ] $lastsixcoords ] - #delete last 6 points - set coordscopy [ lreplace $coords end-5 end ] - #complete coords by adding same pair - lappend coordscopy [ expr [ lindex $lastsixcoords 0 ] + 2 ] [ lindex $lastsixcoords 1 ] [ expr [ lindex $lastsixcoords 0 ] + 2 ] [ lindex $lastsixcoords end ] - set x1 [ lindex $gradcoords 0 ] - set x2 [ lindex $gradcoords end-1 ] - set z1 [ lindex $gradcoords 3 ] - set z2 [ lindex $gradcoords 4 ] - set z3 [ lindex $gradcoords 5 ] - set width [expr {$x2-$x1}] - eval "$canvas create poly $coordscopy -fill $colour1 -tag {$tag}" + set coordscopy2 [ lreplace $coords end-1 end ] + set coordscopy2 [ lreplace $coordscopy2 0 1 ] + set transition [ subst {$canvas gradient create linear -method pad -lineartransition {0 1 0 0} -stops {{0 white} {0.4 $colour1}}}] + set gradcolour1 [ eval $transition ] + eval "$canvas create polyline $coords -stroke white -strokewidth 0 -strokelinejoin round -fill $gradcolour1 -fillopacity 0.25 -tag {$tag}" + #$canvas lower $tag + $canvas raise $tag + if { $ribenable } { ::Ribbon::Draw $canvas $ribcoords l 18 - $canvas lower $tag - #create gradient poly as a number of polys from colour to white - for {set x 1} {$x < $width} {incr x} { - set gradcolour [ get_colour $rgb1 $rgb2 $width $x ] - eval "$canvas create poly [expr $x1+$x] $z1 $z2 $z3 [expr $x1+$x+1] [ lindex $gradcoords end ] -fill $gradcolour -tag {$tag-g-$x}" - lappend emu_graph($graph,gradsets) $tag-g-$x + } else { + eval "$canvas create polyline $coordscopy2 -stroke $colour1 -strokewidth 5 -strokelinejoin round -tag {$tag}" } + #$canvas lower $tag + $canvas raise $tag + $canvas raise prect } - for {set i 0} {$i < [llength $coords]-1} {incr i 2} { - ## we'll draw the point if were either not masking or if - ## the mask value is over the threshold - if { $mask == 0 || \ - [lindex $mask [expr {$i/2}]] >= $maskthresh } { - set point [lrange $coords $i [expr {$i+1}]] - if { [point_in_bounds $graph $point] } { - - if { $labelcolors } { - ## find the colour for this point via its label - set ll [lindex $emu_graph($graph,$tag,labels) \ - [expr {$i/2}]] - set color $emu_graph($graph,$tag,colour,$ll) - } else { - set ll {} - set color $emu_graph($graph,$tag,colour) - } - - if { $emu_graph($graph,$tag,points) } { - - set thesetags [linsert $tags end point \ - "index[expr {$i/2}]" "label$ll"] - - set ox [lindex $point 0] - set oy [lindex $point 1] - $canvas create oval \ - [expr {$ox-2}] [expr {$oy-2}]\ - [expr {$ox+2}] [expr {$oy+2}]\ - -fill $color \ - -outline black\ - -width 0 \ - -tag $thesetags - } - } - } - } +# for {set i 0} {$i < [llength $coords]-1} {incr i 2} { +# ## we'll draw the point if were either not masking or if +# ## the mask value is over the threshold +# if { $mask == 0 || \ +# [lindex $mask [expr {$i/2}]] >= $maskthresh } { +# set point [lrange $coords $i [expr {$i+1}]] +# if { [point_in_bounds $graph $point] } { +# +# if { $labelcolors } { +# ## find the colour for this point via its label +# set ll [lindex $emu_graph($graph,$tag,labels) \ +# [expr {$i/2}]] +# set color $emu_graph($graph,$tag,colour,$ll) +# } else { +# set ll {} +# set color $emu_graph($graph,$tag,colour) +# } +# +# if { $emu_graph($graph,$tag,points) } { +# +# set thesetags [linsert $tags end point \ +# "index[expr {$i/2}]" "label$ll"] +# +# set ox [lindex $point 0] +# set oy [lindex $point 1] +# $canvas create oval \ +# [expr {$ox-2}] [expr {$oy-2}]\ +# [expr {$ox+2}] [expr {$oy+2}]\ +# -fill $color \ +# -outline black\ +# -width 0 \ +# -tag $thesetags +# } +# } +# } +# } } } @@ -698,7 +735,6 @@ proc point_in_bounds {graph point} { proc scale_factor {graph} { - variable emu_graph if {![is_graph $graph]} { @@ -718,10 +754,13 @@ proc scale_factor {graph} { set emu_graph($graph,xfactor) $xfactor set emu_graph($graph,yfactor) $yfactor - } proc axes {graph timelist timelength} { +set timelist [ pad_time $timelist ] +set timelength [ llength $timelist ] +set padstroke [ pad_stroke ] + # generate axes for a plot variable emu_graph @@ -737,7 +776,6 @@ proc axes {graph timelist timelength} { set x_max $emu_graph($graph,xmax) set y_min $emu_graph($graph,ymin) set y_max $emu_graph($graph,ymax) - set y_min_c [y2canvas $graph $y_min] set y_max_c [y2canvas $graph $y_max] set x_min_c [x2canvas $graph $x_min] @@ -754,12 +792,12 @@ proc axes {graph timelist timelength} { # clear up any existing axes $canvas delete -withtag axis - - $canvas create rect $x_min_c $y_min_c $x_max_c [ expr $y_max_c - 20 ]\ - -outline black -tag [list graph$graph axis] + $canvas delete prect + $canvas create prect $x_min_c [ expr {$y_min_c + $padstroke} ] $x_max_c [ expr $y_max_c - 30 ] -stroke "#c8c8c8" -tag prect # y-pos of tick end points and of axis tick labels - set ticky [expr {$y_min_c-$ticklen}] + #set ticky [expr {$y_min_c-$ticklen}] + set ticky [expr {$y_max_c - 30 }] set texty [expr {$y_min_c+$axistextoffset}] # put ticks and numbers on the axis # starting at next nice number above x_min @@ -772,21 +810,18 @@ proc axes {graph timelist timelength} { if {$t >= $x_min} { #puts "t=$t, next t [expr {$t+$delta_x}]" set x [x2canvas $graph $t] - $canvas create line $x $y_min_c $x $ticky \ - -fill black -tag [list graph$graph axis] - $canvas create line $x [expr $y_max_c-20] $x [expr {$y_max_c+$ticklen-20}]\ - -fill black -tag [list graph$graph axis] + $canvas create pline $x [ expr {$y_min_c + $padstroke} ] $x $ticky -stroke "#c8c8c8" -strokedasharray "3 3 3 3" -strokewidth 1 -tag [list graph$graph axis] if { ($t eq 1) || ($t eq 4) || ($t eq 7) || ($t eq 10) || ($t eq 13) || ($t eq 16) || ($t eq 19) } { set n [ expr {$t * 2 - 1} ] set tind [ lindex [ split $timelist ] $n ] regsub -all {\}} $tind tind $canvas create text [x2canvas $graph $t] $texty \ - -fill black -text $tind -font "$graphfont 7" -tag [list graph$graph axis]\ + -fill "#626262" -text $tind -font "$graphfont 7" -tag [list graph$graph axis]\ -anchor w } } } - +set padstroke [ pad_stroke ] # now the y axis set tickx1 [expr {[x2canvas $graph $x_min]+$ticklen}] set tickx2 [expr {[x2canvas $graph $x_max]-$ticklen}] @@ -800,16 +835,56 @@ if { ($t eq 1) || ($t eq 4) || ($t eq 7) || ($t eq 10) || ($t eq 13) || ($t eq 1 ## this is because of a problem with rounding down in nicenum if {$f >= $y_min} { set y [y2canvas $graph $f] - $canvas create line [x2canvas $graph $x_min]\ - $y $tickx1 $y -fill black -tag [list graph$graph axis] - $canvas create line [x2canvas $graph $x_max]\ - $y $tickx2 $y -fill black -tag [list graph$graph axis] + $canvas create pline [x2canvas $graph $x_min] [ expr {$y + $padstroke} ] [x2canvas $graph $x_max] [ expr {$y + $padstroke} ] -stroke "#c8c8c8" -strokedasharray "3 3 3 3" -strokewidth 1 -tag [list graph$graph axis] # and add the label set dispf [ expr {int($f)} ] $canvas create text $textx $y -text $dispf -anchor e \ - -fill black -tag [list graph$graph axis] -font "$graphfont 7" + -fill "#626262" -tag [list graph$graph axis] -font "$graphfont 7" } } +$canvas raise prect +$canvas lower [list graph$graph axis] +} + +proc pad_coords { coords } { +for {set i 1} {$i <= 20} {incr i} { lappend padcoords $i 0 } +set bcindex [ llength $padcoords ] +set datapoints [ llength $coords ] +if { $datapoints <= 40 } { +for {set i $datapoints} {$i >= 1} {incr i -2} { +set coordinate [ lindex $coords [ expr {$i-1} ]] +set padcoords [ lreplace $padcoords [ expr {$bcindex - 1}] [ expr {$bcindex - 1}] $coordinate ] +incr bcindex -2 +} +return $padcoords +} else { +return $coords +} +} + +proc pad_time { timelist } { +for {set i 1} {$i <= 20} {incr i} { lappend padtime $i --:--:-- } +set ptindex [ llength $padtime ] +set datapoints [ llength [ join $timelist ]] +if { $datapoints <= 40 } { +for {set i $datapoints} {$i >= 1} {incr i -2} { +set tstamp [ lindex [ join $timelist ] [ expr {$i-1} ]] +set padtime [ lreplace $padtime [ expr {$ptindex - 1}] [ expr {$ptindex - 1}] $tstamp ] +incr ptindex -2 +} +return $padtime +} else { +return $timelist +} +} + +proc pad_stroke {} { +#If graph has ribbon effect we do not need extra padding to allow for the stroke width +upvar #0 genericdict genericdict +catch {set ribenable [ dict get $genericdict transaction_counter tc_graph_ribbon ]} +if { ![ info exists ribenable ] } { set ribenable false } +if { $ribenable } { set padstroke 0 } else { set padstroke 3 } +return $padstroke } # scale_points with inlined scaling, Mark Koennecke @@ -822,7 +897,6 @@ proc scale_points {graph coords} { set result {} foreach {x y} $coords { -# puts "x: $x, y: $y" lappend result [expr {int(($x - $emu_graph($graph,xmin)) \ * $emu_graph($graph,xfactor) + $emu_graph($graph,xref))}] @@ -887,7 +961,6 @@ proc canvas2x {graph cx} { proc x2canvas {graph x} { variable emu_graph - if {![is_graph $graph]} { error "$graph is not an emu_graph" } diff --git a/src/generic/genmetrics.tcl b/src/generic/genmetrics.tcl index dea03b6e..a8e33502 100755 --- a/src/generic/genmetrics.tcl +++ b/src/generic/genmetrics.tcl @@ -74,19 +74,19 @@ proc DoDisplay {maxcpu cpu_model caller} { set scrollheight [ expr {$height*2} ] frame $metframe.f -bd $S(border) -relief flat -bg $CLR(bg) if { $ttk::currentTheme eq "black" } { - set cnv1 [ canvas $metframe.sv -width 11 -highlightthickness 0 -background #424242 ] + set cnv1 [ tkp::canvas $metframe.sv -width 11 -highlightthickness 0 -background #424242 ] } else { - set cnv1 [ canvas $metframe.sv -width 11 -highlightthickness 0 -background #dcdad5 ] + set cnv1 [ tkp::canvas $metframe.sv -width 11 -highlightthickness 0 -background #dcdad5 ] } pack $cnv1 -expand 0 -fill y -ipadx 0 -ipady 0 -padx 0 -pady 0 -side right pack $metframe.f -fill both -expand 1 #Create fixed header - canvas $metframe.f.header -highlightthickness 0 -bd 0 -width $width -height $S(hdscl) -bg $CLR(bg) + tkp::canvas $metframe.f.header -highlightthickness 0 -bd 0 -width $width -height $S(hdscl) -bg $CLR(bg) $metframe.f.header create text [ expr {$width/2 - $S(hdralign)} ] $S(txtalign) -text "$cpu_model ($maxcpu CPUs)" -fill $CLR(usr) -font {basic} -tags "cpumodel" pack $metframe.f.header #Height for all objects is the height of the bar and text multiplied by all cpus add header set canvforbars $cnvpth.c - canvas $canvforbars -highlightthickness 0 -bd 0 -width $width -height $height -bg $CLR(bg) -scrollregion "0 0 $width $scrollheight" -yscrollcommand "$metframe.sv.scrollY set" -yscrollincrement 10 + tkp::canvas $canvforbars -highlightthickness 0 -bd 0 -width $width -height $height -bg $CLR(bg) -scrollregion "0 0 $width $scrollheight" -yscrollcommand "$metframe.sv.scrollY set" -yscrollincrement 10 #Add scrollbar but now can't scroll multiple canvases or a frame so have to put all ojects in one canvas to scroll set scr1 [ ttk::scrollbar $metframe.sv.scrollY -orient vertical -command "$canvforbars yview" ] pack $canvforbars -expand 0 -fill y -ipadx 0 -ipady 0 -padx 0 -pady 0 @@ -110,12 +110,15 @@ proc DoDisplay {maxcpu cpu_model caller} { set x0 [ expr {$x0 - $rowdeduction} ] set x1 [expr {$x0 + $S(bar,width)}] } + #colour gradients for usr and sys + set usr [$canvforbars gradient create linear -stops {{0 lightgreen} {1 green}}] + set sys [$canvforbars gradient create linear -stops {{0 indianred} {1 darkred}}] #hold array of coords for each CPU for later update set cpucoords($cpu) [ list $x0 $y0 $x1 $y1 ] - $canvforbars create rect $x0 $y1 $x1 $y1 -tag bar$cpu-sys -fill $CLR(sys) - $canvforbars create rect $x0 $y1 $x1 $y1 -tag bar$cpu-usr -fill $CLR(usr) + $canvforbars create prect $x0 $y1 $x1 $y1 -tag bar$cpu-sys -fill $sys + $canvforbars create prect $x0 $y1 $x1 $y1 -tag bar$cpu-usr -fill $usr for { set ymask $y0 } { $ymask <= $y1 } { incr ymask $S(mask) } { - $canvforbars create rect $x0 $ymask $x1 [ expr $ymask + $S(maskplus) ] -tag bar$cpu-mask -fill $CLR(bg) -outline $CLR(bg) + $canvforbars create prect $x0 $ymask $x1 [ expr $ymask + $S(maskplus) ] -tag bar$cpu-mask -fill $CLR(bg) } #Set CPU utilisation % value and hide with same as background colour $canvforbars create text [ expr $x0 + $S(txtalign) ] [ expr $y1 + $S(txtalign) ] -text "0%" -fill $CLR(bg) -font [ list basic [ expr [ font actual basic -size ] - 2 ] ] -tags "pcent$cpu" diff --git a/src/generic/gentc.tcl b/src/generic/gentc.tcl index a62c9230..c226c3eb 100755 --- a/src/generic/gentc.tcl +++ b/src/generic/gentc.tcl @@ -857,26 +857,66 @@ proc transcount { } { .ed_mainFrame.notebook select .ed_mainFrame.tc set old 0 global win_scale_fact - set scale_width [ expr {(525 / 1.333333) * $win_scale_fact} ] - set tcc_height [ expr {(60 / 1.333333) * $win_scale_fact} ] - set tcg_height [ expr {(250 / 1.333333) * $win_scale_fact} ] - set emug_height [ expr {(150 / 1.333333) * $win_scale_fact} ] - set axistextoffset [ expr {(20 / 1.333333) * $win_scale_fact * 0.50} ] - set ticklen [ expr {(10 / 1.333333) * $win_scale_fact * 0.60} ] - set xref [ expr {(75 / 1.333333) * $win_scale_fact * 0.90} ] - #canvas for black on white numbers - pack [ canvas .ed_mainFrame.tc.c -width $scale_width -height $tcc_height -background white -highlightthickness 0 ] -fill both -expand 1 -side top + global tc_scale + unset -nocomplain tc_scale + set scale_width [ expr {(535 / 1.333333) * $win_scale_fact} ] +set tcc_height [ expr {(60 / 1.333333) * $win_scale_fact} ] +set tcg_height [ expr {(250 / 1.333333) * $win_scale_fact} ] +set emug_height [ expr {(150 / 1.333333) * $win_scale_fact} ] +set axistextoffset [ expr {(20 / 1.333333) * $win_scale_fact * 0.50} ] +set ticklen [ expr {(10 / 1.333333) * $win_scale_fact * 0.60} ] +set xref [ expr {(75 / 1.333333) * $win_scale_fact * 0.90} ] + + +#canvas for black on white numbers +.ed_mainFrame.tc configure -background white +pack [ tkp::canvas .ed_mainFrame.tc.c -width $scale_width -height $tcc_height -background white -highlightthickness 0 ] -side top -anchor ne -padx [ list 0 [ expr {$scale_width * 0.05} ] ] -ipadx [ expr {$scale_width * 0.10} ] #Emu graph canvas - pack [ canvas .ed_mainFrame.tc.g -width $scale_width -height $tcg_height -background white -highlightthickness 0 ] -fill both -expand 1 -side left + pack [ tkp::canvas .ed_mainFrame.tc.g -width $scale_width -height $tcg_height -background white -highlightthickness 0 ] -fill both -expand 1 -side left + unset -nocomplain tc_scale + foreach param {scale_width tcc_height tcg_height emug_height axistextoffset ticklen xref} { dict set tc_scale $param [ set $param ] } + dict set tc_scale width $scale_width + dict set tc_scale height $tcg_height + dict set tc_scale last_resize_width [ dict get $tc_scale width ] + dict set tc_scale last_resize_height [ dict get $tc_scale height ] + dict set tc_scale emu_width $scale_width + dict set tc_scale emu_height $emug_height + dict set tc_scale resize_count 0 + dict set tc_scale last_resize 0 + bind .ed_mainFrame.tc.g { + #Configure is triggered dynamically whenever we resize the canvas + global tc_scale + dict set tc_scale resize_count [ expr {[ dict get $tc_scale resize_count ] + 1}] + if { ([ dict get $tc_scale last_resize ] eq 0) } { + dict set tc_scale old_width [ dict get $tc_scale width ] + dict set tc_scale old_height [ dict get $tc_scale height ] + } else { + dict set tc_scale old_width [ dict get $tc_scale last_resize_width ] + dict set tc_scale old_height [ dict get $tc_scale last_resize_height ] + } + dict set tc_scale width %w.0 + dict set tc_scale height %h.0 + #We capture canvas % scale this is passed to redraw and use to scale the emu graph + dict set tc_scale width_percent [ expr {(([ dict get $tc_scale width ] - [ dict get $tc_scale old_width ]) / [ dict get $tc_scale old_width ]) * 100}] + dict set tc_scale height_percent [ expr {(([ dict get $tc_scale height ] - [ dict get $tc_scale old_height ]) / [ dict get $tc_scale old_height ]) * 100}] + if { ![ dict exists $tc_scale graph ] } { + dict set tc_scale graph tce + dict set tc_scale timelist {} + dict set tc_scale timelength {} + } + #Keep the LCD Number to 5% of the top right corner + pack .ed_mainFrame.tc.c -padx [ list 0 [ expr {[ dict get $tc_scale width ] * 0.05} ] ] + #Redraw the graph to same percent as the canvas has been resized + emu_graph::redraw [ dict get $tc_scale graph ] [ dict get $tc_scale timelist ] [ dict get $tc_scale timelength ] + } set graph [ create_image graph icons ] - #.ed_mainFrame.tc.g create image 300 100 -image $graph - .ed_mainFrame.tc.g create image [ expr {[winfo reqwidth .ed_mainFrame.tc.g ]/1.75} ] [ expr {[ winfo reqwidth .ed_mainFrame.tc.g ]/6} ] -image $graph -anchor center + .ed_mainFrame.tc.g create image [ expr {[winfo reqwidth .ed_mainFrame.tc.g ]/1.6} ] [ expr {[ winfo reqheight .ed_mainFrame.tc.g ]/3} ] -image $graph -anchor center set tcdata {} set timedata {} #Set Up LCD Pixels for Canvas size X pixels by Y Pixels Pixel On Rim Colour, Pixel On Fill Colour, Pixel Off Rim Colour, Pixel Off Fill Colour #Black & White #7 x 87 is the number of pixels we create 7 in height and 87 in length. This remains fixed as we scale up pixel size. - LCD_Pixels 7 87 #626262 black white white $win_scale_fact + LCD_Pixels 7 87 #626262 #626262 white white $win_scale_fact #Add same padding set varLCDx 3 set varLCDy 3 @@ -906,8 +946,6 @@ proc transcount { } { incr varLCDx 3 #showLCD 0 - #emu_graph::emu_graph tce -canvas .ed_mainFrame.tc.g -width $scale_width -height $emug_height \ -#-axistextoffset 10 -autorange 1 -ticklen 5 -xref 75 emu_graph::emu_graph tce -canvas .ed_mainFrame.tc.g -width $scale_width -height $emug_height \ -axistextoffset $axistextoffset -autorange 1 -ticklen $ticklen -xref $xref @@ -969,7 +1007,7 @@ proc show_tc_errmsg {} { LCD_Display " TX ERROR " 0 0 0 #attempt to delete canvas catch { .ed_mainFrame.tc.g delete "all" } - .ed_mainFrame.tc.g create image [ expr {[winfo reqwidth .ed_mainFrame.tc.g ]/1.75} ] [ expr {[ winfo reqwidth .ed_mainFrame.tc.g ]/6} ] -image $ban -anchor center + .ed_mainFrame.tc.g create image [ expr {[winfo reqwidth .ed_mainFrame.tc.g ]/1.6} ] [ expr {[ winfo reqheight .ed_mainFrame.tc.g ]/3} ] -image $ban -anchor center #error message is always followed by thread release before loop enter #so remove tc_threadID to prevent false positive on startup post_kill_transcount_cleanup diff --git a/src/mariadb/mariaotc.tcl b/src/mariadb/mariaotc.tcl index cf0db13f..75638f92 100755 --- a/src/mariadb/mariaotc.tcl +++ b/src/mariadb/mariaotc.tcl @@ -136,7 +136,7 @@ proc tcount_maria {bm interval masterthread} { set transval [expr {[expr {abs($new - $old)}] * $mplier}] if { [ catch [ subst {thread::send -async $MASTER {::showLCD $transval }} ] ] } { break } } - if { $tcsize >= 4 } { + if { $tcsize >= 2 } { if { $iconflag eq 0 } { if { [ catch [ subst {thread::send -async $MASTER { .ed_mainFrame.tc.g delete "all" }} ] ] } { break } set iconflag 1 diff --git a/src/mssqlserver/mssqlsotc.tcl b/src/mssqlserver/mssqlsotc.tcl index a3aaa706..62d28d5f 100755 --- a/src/mssqlserver/mssqlsotc.tcl +++ b/src/mssqlserver/mssqlsotc.tcl @@ -113,7 +113,7 @@ proc tcount_mssqls {bm interval masterthread} { } set transval [expr {[expr {abs($new - $old)}] * $mplier}] if { [ catch [ subst {thread::send -async $MASTER {::showLCD $transval }} ] ] } { break }} - if { $tcsize >= 4 } { + if { $tcsize >= 2 } { if { $iconflag eq 0 } { if { [ catch [ subst {thread::send -async $MASTER { .ed_mainFrame.tc.g delete "all" }} ] ] } { break } set iconflag 1 diff --git a/src/mysql/mysqlotc.tcl b/src/mysql/mysqlotc.tcl index eaa07f93..7fb9eff0 100755 --- a/src/mysql/mysqlotc.tcl +++ b/src/mysql/mysqlotc.tcl @@ -133,7 +133,7 @@ proc tcount_mysql {bm interval masterthread} { } set transval [expr {[expr {abs($new - $old)}] * $mplier}] if { [ catch [ subst {thread::send -async $MASTER {::showLCD $transval }} ] ] } { break }} - if { $tcsize >= 4 } { + if { $tcsize >= 2 } { if { $iconflag eq 0 } { if { [ catch [ subst {thread::send -async $MASTER { .ed_mainFrame.tc.g delete "all" }} ] ] } { break } set iconflag 1 diff --git a/src/oracle/oraotc.tcl b/src/oracle/oraotc.tcl index db2ff6a5..ecff785a 100755 --- a/src/oracle/oraotc.tcl +++ b/src/oracle/oraotc.tcl @@ -131,7 +131,7 @@ proc tcount_ora {bm interval masterthread} { } set transval [expr {[expr {abs($new - $old)}] * $mplier}] if { [ catch [ subst {thread::send -async $MASTER {::showLCD $transval }} ] ] } { break }} - if { $tcsize >= 4 } { + if { $tcsize >= 2 } { if { $iconflag eq 0 } { if { [ catch [ subst {thread::send -async $MASTER { .ed_mainFrame.tc.g delete "all" }} ] ] } { break } set iconflag 1 diff --git a/src/postgresql/pgotc.tcl b/src/postgresql/pgotc.tcl index f0f81d29..30755882 100755 --- a/src/postgresql/pgotc.tcl +++ b/src/postgresql/pgotc.tcl @@ -105,7 +105,7 @@ proc tcount_pg {bm interval masterthread} { } set transval [expr {[expr {abs($new - $old)}] * $mplier}] if { [ catch [ subst {thread::send -async $MASTER {::showLCD $transval }} ] ] } { break }} - if { $tcsize >= 4 } { + if { $tcsize >= 2 } { if { $iconflag eq 0 } { if { [ catch [ subst {thread::send -async $MASTER { .ed_mainFrame.tc.g delete "all" }} ] ] } { break } set iconflag 1 diff --git a/src/redis/redisotc.tcl b/src/redis/redisotc.tcl index fdb8b198..cf3ee3e1 100755 --- a/src/redis/redisotc.tcl +++ b/src/redis/redisotc.tcl @@ -89,7 +89,7 @@ proc tcount_redis {bm interval masterthread} { } set transval [expr {[expr {abs($new - $old)}] * $mplier}] if { [ catch [ subst {thread::send -async $MASTER {::showLCD $transval }} ] ] } { break }} - if { $tcsize >= 4 } { + if { $tcsize >= 2 } { if { $iconflag eq 0 } { if { [ catch [ subst {thread::send -async $MASTER { .ed_mainFrame.tc.g delete "all" }} ] ] } { break } set iconflag 1