Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15286
Modified Files: Tag: devel_0_39 desire.tk Log Message: getting duplicate to work
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.218 retrieving revision 1.1.2.219 diff -C2 -d -r1.1.2.218 -r1.1.2.219 *** desire.tk 3 Jun 2006 02:05:53 -0000 1.1.2.218 --- desire.tk 3 Jun 2006 21:16:48 -0000 1.1.2.219 *************** *** 896,899 **** --- 896,900 ---- set @ninlets 1 set @noutlets 0 + set @duplicate 0 #set @accels {} super *************** *** 1163,1166 **** --- 1164,1168 ---- # stores wires in the format of {0 1 1 0} id {1 1 2 0} id set @wires_pair {} + set @duplicating 0 #set @wire_hilite {} global history *************** *** 1662,1665 **** --- 1664,1668 ---- set wires {} # look up for wire id + puts "duplicating ????????? $@duplicating" foreach x $wires2 { set outobj [lindex $x 0] *************** *** 1683,1687 **** } } ! set born [lwithout $wires $@wires]; foreach x $born {$x subscribe $self;$x changed;$x canvas= $self} #set dead [lwithout $@wires $wires]; foreach x $dead {$x unsubscribe $self; $x erase} set dead [lwithout $@wires $wires]; foreach x $dead {$x unsubscribe $self} --- 1686,1701 ---- } } ! set born [lwithout $wires $@wires] ! set born_num [expr [llength $born] - 1] ! set i 0 ! foreach x $born { ! $x subscribe $self;$x changed;$x canvas= $self ! if {$@duplicating} { ! lappend @selection_wire $x; $x selected?= 1 ! if {$i == $born_num} {set @duplicating 0} ! } ! incr i ! } ! #set dead [lwithout $@wires $wires]; foreach x $dead {$x unsubscribe $self; $x erase} set dead [lwithout $@wires $wires]; foreach x $dead {$x unsubscribe $self} *************** *** 1916,1943 ****
#-----------------------------------------------------------------------------------# ! def* Canvas click_on_wire {x y b f} { ! puts "click on wire!!!" ! #set c .$self.c ! #if {$f&8} {post "rightclick wire"} ! #$c create line $xys -tags $self -width $thick \ ! #-arrow $arrow -arrowshape $arrowshape -fill $look(wirefg) ! #$c itemconfigure ${obj}BASE -outline $look(wirefg2) ! #$c itemconfigure $id -fill $look(wirefg2) ! #set @selection_wire $id ! # my wire click select end }
def* Canvas select_all {} { ! foreach o $@children {$o selected?= 0} set @selection $@children }
def* Canvas deselect_all {} { ! #puts "selection:$@selection" foreach o $@selection {$o selected?= 0} set @selection {} ! if {$@selection_wire != ""} { ! foreach wire $@selection_wire {$wire select 0} ! } set @select_by "" } --- 1930,2002 ----
#-----------------------------------------------------------------------------------# ! # duplication turns out to be somehow similar to file loading, where the duplicates ! # got added as children before they were born.... so be aware ! def* Canvas duplicate {} { ! global _ canvas ! if {$@selection != ""} { ! set canvas(dup_orig) $@selection ! set dups $@selection ! set @selection {} ! foreach item $dups { ! $item selected?= 0 ! mset {x1 y1} [$item xy] ! if {$_($item:_class) == "Objectbox"} { ! set name $_($item:text) } else { ! set name $_($item:class) ! } ! set @duplicating 1 ! pd .$self obj [expr $x1 + 15] [expr $y1 +15] $name ! set dup_wires $_($item:wires) ! } ! ! } ! ! } ! ! def* Canvas duplicate_wire {} { ! global _ canvas ! puts "!!!!!!!!!!! dup wires for these duplicates::: $@selection !!!!!!!!!!!!" ! puts "!!!!!!!!!!! dup wires ::: $@selection_wire !!!!!!!!!!!!" ! puts "!! $@children !!" ! set i 0 ! foreach obj $canvas(dup_orig) {set _($obj:duplicate) [lindex $@selection $i]; incr i} ! foreach wire $@selection_wire { ! set obj1 $_($wire:obj1) ! set obj2 $_($wire:obj2) ! set obj1_dup $_($obj1:duplicate) ! set obj2_dup $_($obj2:duplicate) ! #puts "$obj1 :: $obj1_dup | $obj2 :: $obj2_dup" ! ! #puts "connect [lsearch $@children $obj1_dup] $_($wire:port1) [lsearch $@children $obj2_dup] $_($wire:port2)" ! pd .$self connect [lsearch $@children $obj1_dup] $_($wire:port1) [lsearch $@children $obj2_dup] $_($wire:port2) ! $wire selected?= 0 ! } ! #clean up ! foreach obj $canvas(dup_orig) {set _($obj:duplicate) 0} ! set $canvas(dup_orig) "" ! #set @duplicating 0 ! set @selection_wire "" ! ! }
def* Canvas select_all {} { ! global look ! foreach o $@children {$o selected?= 1} ! foreach w $@wires {$w selected?= 1} set @selection $@children + set @selection_wire $@wires + #foreach obj $@selection {.$self.c itemconfigure ${obj}BASE -outline $look(objectframe4)} }
def* Canvas deselect_all {} { ! puts "-------------- selection_wire:$@selection_wire ------------" foreach o $@selection {$o selected?= 0} + foreach w $@selection_wire {$w selected?= 0} set @selection {} ! set @selection_wire {} ! #if {$@selection_wire != ""} { ! #foreach wire $@selection_wire {$wire select 0} ! #} set @select_by "" } *************** *** 2005,2012 **** } wire { ! if {$@selection_wire != ""} {$@selection_wire select 0} #set @wire_hilite $id ! set @selection_wire $id ! $id select 1 } default {error BORK} --- 2064,2072 ---- } wire { ! #if {$@selection_wire != ""} {$@selection_wire select 0} #set @wire_hilite $id ! if {[lsearch $@selection_wire $id] < 0} {set @selection_wire $id} ! $id selected?= 1 ! #$id select 1 } default {error BORK} *************** *** 2069,2073 **** puts "selected_objs:$selected_objs selection:$@selection selection_wire:$@selection_wire" # hilite objects ! foreach obj $@selection {$c itemconfigure ${obj}BASE -outline $look(objectframe4)} # hilite wire foreach wire $@selection_wire {$wire select 1} --- 2129,2134 ---- puts "selected_objs:$selected_objs selection:$@selection selection_wire:$@selection_wire" # hilite objects ! #foreach obj $@selection {$c itemconfigure ${obj}BASE -outline $look(objectframe4)} ! foreach obj $@selection {$obj selected?= 1} # hilite wire foreach wire $@selection_wire {$wire select 1} *************** *** 2353,2357 **** set arrowshape [list $arrowsize [expr $arrowsize*4/5] [expr $arrowsize/3]] # need this, maybe... ! if {$@select_by == "selrect"} {set wire_color $look(wirefg2)} {set wire_color $look(wirefg)} #set wire_color $look(wirefg) $self item WIRE line $xys -width $look(wirethick) -smooth yes \ --- 2414,2419 ---- set arrowshape [list $arrowsize [expr $arrowsize*4/5] [expr $arrowsize/3]] # need this, maybe... ! #if {$@select_by == "selrect"} {set wire_color $look(wirefg2)} {set wire_color $look(wirefg)} ! if {[$self selected?]} {set wire_color $look(wirefg2)} {set wire_color $look(wirefg)} #set wire_color $look(wirefg) $self item WIRE line $xys -width $look(wirethick) -smooth yes \ *************** *** 2370,2378 **** }
! def* Wire select {flag} { ! global look ! if {$flag} {set colour $look(wirefg2)} {set colour $look(wirefg)} ! .$@canvas.c itemconfigure ${self}WIRE -fill $colour ! }
def Wire update {source outlet target inlet kind} { --- 2432,2440 ---- }
! #def* Wire select {flag} { ! # global look ! # if {$flag} {set colour $look(wirefg2)} {set colour $look(wirefg)} ! # .$@canvas.c itemconfigure ${self}WIRE -fill $colour ! #}
def Wire update {source outlet target inlet kind} { *************** *** 2480,2483 **** --- 2542,2546 ---- # # a hack to get around the file loading process + # now also used for duplicting object and have them selected... set canvas(current) ""
*************** *** 2511,2514 **** --- 2574,2582 ---- } $x init + if {$_($canvas(current):duplicating)} { + puts "duplicating stuff............ $x" + $x selected?= 1 + lappend _($canvas(current):selection) $x + } } switch -- _($x:_class) { *************** *** 2539,2544 **** --- 2607,2620 ---- if {$unborn_child == [expr [llength $_($canvas(current):unborn)] - 1]} { # when it reachs the last unborn child, its time to draw the wires + # the end of duplication + set _($canvas(current):unborn) "" + if {$_($canvas(current):duplicating)} { + #set _($canvas(current):duplicating) 0 + $canvas(current) duplicate_wire + } else { puts "time to draw wires ----- $_($canvas(current):unborn_wire)" $canvas(current) wires= $_($canvas(current):unborn_wire) + set _($canvas(current):unborn_wire) "" + } } }