Update of /cvsroot/pure-data/extensions/gui/ix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21213
Modified Files: mat.wid Log Message: wrapping expr args in {} cut down the memory leakage by 90% still pretty bad tho
Index: mat.wid =================================================================== RCS file: /cvsroot/pure-data/extensions/gui/ix/mat.wid,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** mat.wid 4 Jul 2005 22:49:25 -0000 1.13 --- mat.wid 5 Jul 2005 07:52:23 -0000 1.14 *************** *** 6,10 **** variable _ set id [lindex [$p.m itemcget $item -tags] 1] ! set len [expr [dict get $_($t) $id xx] - [dict get $_($t) $id x]] set vel [$p.m itemcget $item -fillopacity] pd [concat $t.rp _cb note [dict get $_($t) $id y] $vel $len ;]} --- 6,10 ---- variable _ set id [lindex [$p.m itemcget $item -tags] 1] ! set len [expr {[dict get $_($t) $id xx] - [dict get $_($t) $id x]}] set vel [$p.m itemcget $item -fillopacity] pd [concat $t.rp _cb note [dict get $_($t) $id y] $vel $len ;]} *************** *** 13,18 **** variable _ foreach xy $axis { ! set mv [expr ($_($t:${xy}b) - $_($t:${xy}a)) / 4.0] ! foreach ab {a b} {set _($t:${xy}$ab) [expr $_($t:${xy}$ab) $d $mv]}} mat_redraw $p $t all mat_gridlines $p $t} --- 13,18 ---- variable _ foreach xy $axis { ! set mv [expr {($_($t:${xy}b) - $_($t:${xy}a)) / 4.0}] ! foreach ab {a b} {set _($t:${xy}$ab) [expr { $d > 0 ? $_($t:${xy}$ab) + $mv : $_($t:${xy}$ab) - $mv }]}} mat_redraw $p $t all mat_gridlines $p $t} *************** *** 30,35 **** if {$x >= $_($t:cx)} {set xa $_($t:fx);set xb $x} else {set xa $x;set xb $_($t:fx)} if {$y >= $_($t:cy)} {set ya $_($t:fy);set yb $y} else {set ya $y;set yb $_($t:fy)} ! set w [expr abs($xb - $xa)] ! set h [expr abs($yb - $ya)] $p.m coords sel [::tkpath::coords rect $xa $ya $w $h -rx 12 -ry 12] $p.m itemconfigure sel -stroke $_($t:sc)}}} --- 30,35 ---- if {$x >= $_($t:cx)} {set xa $_($t:fx);set xb $x} else {set xa $x;set xb $_($t:fx)} if {$y >= $_($t:cy)} {set ya $_($t:fy);set yb $y} else {set ya $y;set yb $_($t:fy)} ! set w [expr {abs($xb - $xa)}] ! set h [expr {abs($yb - $ya)}] $p.m coords sel [::tkpath::coords rect $xa $ya $w $h -rx 12 -ry 12] $p.m itemconfigure sel -stroke $_($t:sc)}}} *************** *** 46,50 **** switch $r { abs {dict set _($t) $item $v [set $v]} ! rel {dict set _($t) $item $v [expr [dict get $_($t) $item $v] + [set $v]]}}}} mat_redraw $p $t [dict get $_($t) $item ci]}
--- 46,50 ---- switch $r { abs {dict set _($t) $item $v [set $v]} ! rel {dict set _($t) $item $v [expr {[dict get $_($t) $item $v] + [set $v]}]}}}} mat_redraw $p $t [dict get $_($t) $item ci]}
*************** *** 59,68 **** proc mat_resize_canvas {p t a x y} { variable _ ! set mx [expr $x - $_($t:cx)] ! set my [expr $y - $_($t:cy)] foreach xy {x y} { ! set mvt [mat_tr $p $t $xy d [expr $$xy - $_($t:c$xy)]] ! set _($t:${xy}a) [expr $_($t:${xy}a) - $mvt] ! set _($t:${xy}b) [expr $_($t:${xy}b) + $mvt]} mat_redraw $p $t all mat_gridlines $p $t} --- 59,69 ---- proc mat_resize_canvas {p t a x y} { variable _ ! set mx [expr {$x - $_($t:cx)}] ! set my [expr {$y - $_($t:cy)}] foreach xy {x y} { ! set pos [set $xy] ! set mvt [mat_tr $p $t $xy d [expr {$pos - $_($t:c$xy)}]] ! set _($t:${xy}a) [expr {$_($t:${xy}a) - $mvt}] ! set _($t:${xy}b) [expr {$_($t:${xy}b) + $mvt}]} mat_redraw $p $t all mat_gridlines $p $t} *************** *** 77,82 **** set px [mat_tr $p $t x t [dict get $_($t) $id x]] set py [mat_tr $p $t y t [dict get $_($t) $id y]] ! set sx [expr abs([mat_tr $p $t x id [expr [dict get $_($t) $id xx] - [dict get $_($t) $id x]]])] ! set sy [expr abs([mat_tr $p $t y id 1])] # puts "$px $py $sx $sy" $p.m coords $item [::tkpath::coords rect $px $py $sx $sy -rx 3 -ry 3]}} --- 78,83 ---- set px [mat_tr $p $t x t [dict get $_($t) $id x]] set py [mat_tr $p $t y t [dict get $_($t) $id y]] ! set sx [expr {abs([mat_tr $p $t x id [expr {[dict get $_($t) $id xx] - [dict get $_($t) $id x]}]])}] ! set sy [expr {abs([mat_tr $p $t y id 1])}] # puts "$px $py $sx $sy" $p.m coords $item [::tkpath::coords rect $px $py $sx $sy -rx 3 -ry 3]}} *************** *** 84,90 **** proc mat_object_trans {p t a x y} { variable _ ! set velo [expr ($x - $_($t:cx)) / 100.0] foreach item $_($t:sel) { ! set vel [expr $velo + [$p.m itemcget $item -fillopacity]] if {$vel > 1} {set vel 1} if {$vel < 0} {set vel 0} --- 85,91 ---- proc mat_object_trans {p t a x y} { variable _ ! set velo [expr {($x - $_($t:cx)) / 100.0}] foreach item $_($t:sel) { ! set vel [expr {$velo + [$p.m itemcget $item -fillopacity]}] if {$vel > 1} {set vel 1} if {$vel < 0} {set vel 0} *************** *** 95,103 **** proc mat_move_canvas {p t a x y} { variable _ ! set mx [expr $x - $_($t:cx)] ! set my [expr $y - $_($t:cy)] foreach xy {x y} { ! set mvt [mat_tr $p $t $xy d [expr $$xy - $_($t:c$xy)]] ! foreach ab {a b} {set _($t:${xy}$ab) [expr $_($t:${xy}$ab) - $mvt]}} mat_redraw $p $t all mat_gridlines $p $t} --- 96,105 ---- proc mat_move_canvas {p t a x y} { variable _ ! set mx [expr {$x - $_($t:cx)}] ! set my [expr {$y - $_($t:cy)}] foreach xy {x y} { ! set pos [set $xy] ! set mvt [mat_tr $p $t $xy d [expr {$pos - $_($t:c$xy)}]] ! foreach ab {a b} {set _($t:${xy}$ab) [expr {$_($t:${xy}$ab) - $mvt}]}} mat_redraw $p $t all mat_gridlines $p $t} *************** *** 105,110 **** proc mat_move_object {p t a x y} { variable _ ! set mx [mat_tr $p $t x d [expr $x - $_($t:cx)]] ! set my [mat_tr $p $t y d [expr $y - $_($t:cy)]] foreach item $_($t:sel) {mat_item_update $p $t [lindex [$p.m itemcget $item -tags] 1] - rel $mx $my $mx $my}}
--- 107,112 ---- proc mat_move_object {p t a x y} { variable _ ! set mx [mat_tr $p $t x d [expr {$x - $_($t:cx)}]] ! set my [mat_tr $p $t y d [expr {$y - $_($t:cy)}]] foreach item $_($t:sel) {mat_item_update $p $t [lindex [$p.m itemcget $item -tags] 1] - rel $mx $my $mx $my}}
*************** *** 116,124 **** proc mat_hover {p t x y} { variable _ if {[$p.m find withtag sel] ne ""} { set clicked [$p.m find overlapping $_($t:fx) $_($t:fy) $x $y] mat_sel motion $p $t $x $y } else { - # if {[llength $_($t:sel)] > 1} {return} set clicked [$p.m find overlapping $x $y $x $y] } --- 118,126 ---- proc mat_hover {p t x y} { variable _ + mat_loc $p $t $x $y if {[$p.m find withtag sel] ne ""} { set clicked [$p.m find overlapping $_($t:fx) $_($t:fy) $x $y] mat_sel motion $p $t $x $y } else { set clicked [$p.m find overlapping $x $y $x $y] } *************** *** 128,131 **** --- 130,134 ---- if {$clicked ne ""} { mat_mode $p $t move_object + if {[$p.m find withtag sel] eq "" && [llength $_($t:sel)] > 1} {return} foreach item $_($t:sel) { if {[lsearch -integer $clicked $item] < 0} { *************** *** 134,146 **** set id [lindex [$p.m itemcget $item -tags] 1] $p.m itemconfigure $item -fill $_($t:sc) ! # mat_note $p $t $item ! $p.m create text "[expr [winfo width $p.m] - 8.0 ] [expr [winfo height $p.m] - 8.0 - 11 * $n.0]" -fill "#ff0022" -justify right -anchor se -font {{bitstream vera sans} 10} -tags hover -text [dict get $_($t) $id] incr n } set _($t:sel) $clicked } else { mat_mode $p $t move_canvas } - mat_loc $p $t $x $y }
--- 137,148 ---- set id [lindex [$p.m itemcget $item -tags] 1] $p.m itemconfigure $item -fill $_($t:sc) ! $p.m create text [list [expr [winfo width $p.m] - 8.0] [expr [winfo height $p.m] - 8.0 - 11 * $n.0]] -fill "#ff0022" -justify right -anchor se -font {{bitstream vera sans} 10} -tags hover -text [dict get $_($t) $id] incr n } set _($t:sel) $clicked + } else { mat_mode $p $t move_canvas } }
*************** *** 193,200 **** array set dm {x width y height} switch $inv { ! t {return [expr ($v - $_($t:${d}a)) / ($_($t:${d}b) - $_($t:${d}a) + 0.0) * [winfo $dm($d) $p.m]]} ! i {return [expr ($_($t:${d}b) - $_($t:${d}a)) * $v /([winfo $dm($d) $p.m] + 0.0) + $_($t:${d}a)]} ! d {return [expr ($_($t:${d}b) - $_($t:${d}a)) * $v /([winfo $dm($d) $p.m] + 0.0)]} ! id {return [expr $v / ($_($t:${d}b) - $_($t:${d}a) + 0.0) * [winfo $dm($d) $p.m]]}}}
proc mat_zoom {p t a} { --- 195,202 ---- array set dm {x width y height} switch $inv { ! t {return [expr {($v - $_($t:${d}a)) / ($_($t:${d}b) - $_($t:${d}a) + 0.0) * [winfo $dm($d) $p.m]}]} ! i {return [expr {($_($t:${d}b) - $_($t:${d}a)) * $v /([winfo $dm($d) $p.m] + 0.0) + $_($t:${d}a)}]} ! d {return [expr {($_($t:${d}b) - $_($t:${d}a)) * $v /([winfo $dm($d) $p.m] + 0.0)}]} ! id {return [expr {$v / ($_($t:${d}b) - $_($t:${d}a) + 0.0) * [winfo $dm($d) $p.m]}]}}}
proc mat_zoom {p t a} { *************** *** 256,263 **** pack $p.m -side left bind $p.m <Motion> "::ix::mat_hover $p $t %x %y" ! bind $p.m <4> "::ix::mat_scroll $p $t + x" ! bind $p.m <5> "::ix::mat_scroll $p $t - x" ! bind $p.m <Shift-4> "::ix::mat_scroll $p $t - y" ! bind $p.m <Shift-5> "::ix::mat_scroll $p $t + y" foreach m {"Control-" "" "Shift-" "Double-"} { foreach bn {1 2 3} { --- 258,265 ---- pack $p.m -side left bind $p.m <Motion> "::ix::mat_hover $p $t %x %y" ! bind $p.m <4> "::ix::mat_scroll $p $t 1 x" ! bind $p.m <5> "::ix::mat_scroll $p $t -1 x" ! bind $p.m <Shift-4> "::ix::mat_scroll $p $t -1 y" ! bind $p.m <Shift-5> "::ix::mat_scroll $p $t 1 y" foreach m {"Control-" "" "Shift-" "Double-"} { foreach bn {1 2 3} { *************** *** 266,270 **** bind $p.m <$m[lindex [lindex $b $ba] 0]> "::ix::mat_click [list [string tolower [string trimright $m -1]]] $bn [lindex [lindex $b $ba] 1] $p $t %x %y %X %Y"}}} set bd [expr {[$p cget -bd] * 2}] ! $p configure -bg gray -width [expr [winfo width $p.m] + $bd] -height [expr [winfo height $p.m] + $bd] $p.m create text {20 20} -fill blue -justify left -anchor w -font {{bitstream vera sans} 18} -tags mode -text move_canvas $p.m create text "10 $h" -fill red -justify left -anchor sw -font {{bitstream vera sans} 12 bold} -fill purple -tags loc -text "" --- 268,272 ---- bind $p.m <$m[lindex [lindex $b $ba] 0]> "::ix::mat_click [list [string tolower [string trimright $m -1]]] $bn [lindex [lindex $b $ba] 1] $p $t %x %y %X %Y"}}} set bd [expr {[$p cget -bd] * 2}] ! $p configure -bg gray -width [expr {[winfo width $p.m] + $bd}] -height [expr {[winfo height $p.m] + $bd}] $p.m create text {20 20} -fill blue -justify left -anchor w -font {{bitstream vera sans} 18} -tags mode -text move_canvas $p.m create text "10 $h" -fill red -justify left -anchor sw -font {{bitstream vera sans} 12 bold} -fill purple -tags loc -text "" *************** *** 282,287 **** array set tj {x center y left} array set igx {y width x height} ! if {$_($t:${xy}a) > $_($t:${xy}b)} {set oa ">=";set ob "-"} {set oa "<=";set ob "+"} ! for {set x [expr int($_($t:${xy}a) / ($_($t:q${xy}) + 0.0) + 1)*($_($t:q${xy}) + 0.0)]} {[expr $x $oa $_($t:${xy}b)]} {set x [expr $x $ob $_($t:q${xy})]} { set og [mat_tr $p $t $xy t $x] set invgeo [winfo $igx($xy) $w] --- 284,288 ---- array set tj {x center y left} array set igx {y width x height} ! for {set x [expr {int($_($t:${xy}a) / ($_($t:q${xy}) + 0.0) + 1)*($_($t:q${xy}) + 0.0)}]} {[expr {$_($t:${xy}a) > $_($t:${xy}b) ? $x >= $_($t:${xy}b) : $x <= $_($t:${xy}b)}]} {set x [expr {$_($t:${xy}a) > $_($t:${xy}b) ? $x - $_($t:q${xy}) : $x + $_($t:q${xy})}]} { set og [mat_tr $p $t $xy t $x] set invgeo [winfo $igx($xy) $w]