[PD-cvs] pd/src desire.tk,1.1.2.600.2.290,1.1.2.600.2.291

Mathieu Bouchard matju at users.sourceforge.net
Mon Aug 6 06:21:13 CEST 2007


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3496

Modified Files:
      Tag: desiredata
	desire.tk 
Log Message:
rename @obj1, at obj2 to @from, at to; cleanup


Index: desire.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v
retrieving revision 1.1.2.600.2.290
retrieving revision 1.1.2.600.2.291
diff -C2 -d -r1.1.2.600.2.290 -r1.1.2.600.2.291
*** desire.tk	6 Aug 2007 03:32:01 -0000	1.1.2.600.2.290
--- desire.tk	6 Aug 2007 04:21:08 -0000	1.1.2.600.2.291
***************
*** 2068,2076 ****
  		if {[llength $@selection_wire] != 1} {return}
  		puts "insert object for $@selection_wire"
! 		mset {obj1 outlet obj2 inlet} [$@selection_wire report]
  		set c [$self widget]
  		set iowidth [$self look iowidth]
! 		mset {ox1 oy1 ox2 oy2} [lmap / [$c bbox ${obj1}o${outlet}] [$self zoom]]
! 		mset {ix1 iy1 ix2 iy2} [lmap / [$c bbox ${obj2}i${inlet}] [$self zoom]]
  		set x1 [expr $ox1 + ($iowidth / 2)]
  		set y1 [expr ($oy1 + $oy2) / 2]
--- 2068,2076 ----
  		if {[llength $@selection_wire] != 1} {return}
  		puts "insert object for $@selection_wire"
! 		mset {from outlet to inlet} [$@selection_wire report]
  		set c [$self widget]
  		set iowidth [$self look iowidth]
! 		mset {ox1 oy1 ox2 oy2} [lmap / [$c bbox ${from}o${outlet}] [$self zoom]]
! 		mset {ix1 iy1 ix2 iy2} [lmap / [$c bbox   ${to}i${inlet}] [$self zoom]]
  		set x1 [expr $ox1 + ($iowidth / 2)]
  		set y1 [expr ($oy1 + $oy2) / 2]
***************
*** 2087,2098 ****
  	set wire [$self selection_wire]
  	$self selection_wire-= $wire
! 	mset {obj1 outlet obj2 inlet} [$wire report]
  	$self disconnect [$wire connects]
  	set @keynav 0; $@active hide; set @keynav_tab_sel "object"
! 	set obj1_idx [$self children_idx $obj1]
! 	set obj2_idx [$self children_idx $obj2]
  	set obj3_idx [$self children_idx $obj]
! 	$self connect [list $obj1_idx $outlet $obj3_idx 0] [list $self keynav_current=]
! 	$self connect [list $obj3_idx 0 $obj2_idx $inlet]
  	$self action= none
  }
--- 2087,2098 ----
  	set wire [$self selection_wire]
  	$self selection_wire-= $wire
! 	mset {from outlet to inlet} [$wire report]
  	$self disconnect [$wire connects]
  	set @keynav 0; $@active hide; set @keynav_tab_sel "object"
! 	set from_idx [$self children_idx $from]
! 	set   to_idx [$self children_idx $to]
  	set obj3_idx [$self children_idx $obj]
! 	$self connect [list $from_idx $outlet $obj3_idx 0] [list $self keynav_current=]
! 	$self connect [list $obj3_idx 0 $to_idx $inlet]
  	$self action= none
  }
***************
*** 2110,2117 ****
  def Canvas new_object_chain_wire {obj} {
  	obj_hist prepend [$obj text]
! 	set obj1_idx [$self children_idx [lindex [$self selection] 0]]
  	$self deselect_all
! 	set obj2_idx [$self children_idx $obj]
! 	$self connect [list $obj1_idx 0 $obj2_idx 0]
  	$self action= none
  	$self selection= $obj
--- 2110,2117 ----
  def Canvas new_object_chain_wire {obj} {
  	obj_hist prepend [$obj text]
! 	set from_idx [$self children_idx [lindex [$self selection] 0]]
  	$self deselect_all
! 	set to_idx [$self children_idx $obj]
! 	$self connect [list $from_idx 0 $to_idx 0]
  	$self action= none
  	$self selection= $obj
***************
*** 2871,2882 ****
  		mset {type id detail} [$self identify_target $x $y 0]
  		if {$type == "wire"} {
! 			mset {obj1 outlet obj2 inlet} [$id report]
  			$self disconnect [$id connects]
! 			set obj1_idx [$self children_idx $obj1]
! 			set obj2_idx [$self children_idx $obj2]
  			foreach obj $in_objs {
  				set obj3_idx [$self children_idx $obj]
  				if {![llength [$obj ioselect]]} {set port 0} else {set port [lindex [$obj ioselect] 0]}
! 				set w1 [list $obj1_idx $outlet $obj3_idx $port]
  				if {[lsearch $@wires $w1] == -1} {$self connect $w1}
  			}
--- 2871,2882 ----
  		mset {type id detail} [$self identify_target $x $y 0]
  		if {$type == "wire"} {
! 			mset {from outlet to inlet} [$id report]
  			$self disconnect [$id connects]
! 			set from_idx [$self children_idx $from]
! 			set   to_idx [$self children_idx $to]
  			foreach obj $in_objs {
  				set obj3_idx [$self children_idx $obj]
  				if {![llength [$obj ioselect]]} {set port 0} else {set port [lindex [$obj ioselect] 0]}
! 				set w1 [list $from_idx $outlet $obj3_idx $port]
  				if {[lsearch $@wires $w1] == -1} {$self connect $w1}
  			}
***************
*** 2884,2888 ****
  				set obj3_idx [$self children_idx $obj]
  				if {![llength [$obj ioselect]]} {set port 0} else {set port [lindex [$obj ioselect] 0]}
! 				set w2 [list $obj3_idx $port $obj2_idx $inlet]
  				if {[lsearch $@wires $w2] == -1} {$self connect $w2}
  			}
--- 2884,2888 ----
  				set obj3_idx [$self children_idx $obj]
  				if {![llength [$obj ioselect]]} {set port 0} else {set port [lindex [$obj ioselect] 0]}
! 				set w2 [list $obj3_idx $port $to_idx $inlet]
  				if {[lsearch $@wires $w2] == -1} {$self connect $w2}
  			}
***************
*** 3642,3648 ****
  }
  
  def Canvas clear_wires {} {
! 	set @auto_wire_obj2 {}; set @auto_wire_obj1 {}
! 	if {[llength $@selection] == 1 } {
  		set objs $@selection
  	} else {
--- 3642,3669 ----
  }
  
+ def Canvas clear_wires_of {obj} {
+     if {![llength [$obj ioselect]]} {
+ 	set port 0; set type "none"
+     } else {
+ 	set port [lindex [$obj ioselect] 0]
+ 	set type [lindex [$obj ioselect] 1]
+     }
+     foreach wire [$obj wires2] {
+ 	mset {from outlet to inlet} [$wire report]
+ 	switch $type {
+ 	    i {if   {$to==$obj &&  $inlet==$port} {$self disconnect [$wire connects]; if  {!$inlet} {lappend @auto_wire_from $from}}}
+ 	    o {if {$from==$obj && $outlet==$port} {$self disconnect [$wire connects]; if {!$outlet} {lappend @auto_wire_to   $to}}}
+ 	    none {
+ 		$self disconnect [$wire connects]
+ 		if {$from==$obj && !$outlet} {lappend @auto_wire_to   $to}
+ 		if {  $to==$obj && ! $inlet} {lappend @auto_wire_from $from}
+ 	    }
+ 	}
+     }
+ }
+ 
  def Canvas clear_wires {} {
! 	set @auto_wire_to {}; set @auto_wire_from {}
! 	if {[llength $@selection] == 1} {
  		set objs $@selection
  	} else {
***************
*** 3655,3702 ****
  	}
  	foreach obj $objs {
! 		if {![llength [$obj ioselect]]} {
! 			set port 0; set type "none"
! 		} else {
! 			set port [lindex [$obj ioselect] 0]
! 			set type [lindex [$obj ioselect] 1]
! 		}
! 		foreach wire [$obj wires2] {
! 			mset {obj1 outlet obj2 inlet} [$wire report]
! 			switch $type {
! 				i {
! 					if {$obj2 == $obj && $inlet == $port} {
! 						$self disconnect [$wire connects]
! 						if {!$inlet} {lappend @auto_wire_obj1 $obj1}
! 					}
! 				}
! 				o {
! 					if {$obj1 == $obj && $outlet == $port} {
! 						$self disconnect [$wire connects]
! 						if {!$outlet} {lappend @auto_wire_obj2 $obj2}
! 					}
! 				}
! 				none {
! 					$self disconnect [$wire connects]
! 					if {$obj1 == $obj} {
! 						if {!$outlet} {lappend @auto_wire_obj2 $obj2}
! 					}
! 					if {$obj2 == $obj} {
! 						if {! $inlet} {lappend @auto_wire_obj1 $obj1}
! 					}
! 				}
! 			}
! 		}
  	}
  }
  
  def Canvas reconnect {} {
! 	foreach obj1 $@auto_wire_obj1 {
! 		set idx1 [$self children_idx $obj1]
! 		foreach obj2 $@auto_wire_obj2 {
! 			set idx2 [$self children_idx $obj2]
  			set wire [list $idx1 0 $idx2 0]
! 			if {[$self wire_idx [list $idx1 0 $idx2 0]] < 0} {
! 				$self connect [list $idx1 0 $idx2 0]
! 			}
  		}
  	}
--- 3676,3690 ----
  	}
  	foreach obj $objs {
! 		$self clear_wires_of $obj
  	}
  }
  
  def Canvas reconnect {} {
! 	foreach from $@auto_wire_from {
! 		set idx1 [$self children_idx $from]
! 		foreach to $@auto_wire_to {
! 			set idx2 [$self children_idx $to]
  			set wire [list $idx1 0 $idx2 0]
! 			if {[$self wire_idx $wire] < 0} {$self connect $wire}
  		}
  	}
***************
*** 3919,3933 ****
  	switch $type {
  	    outlet {
! 		set @from $from
! 		set @outlet $port
! 		set @to ""
! 		set @inlet ""
  		set port_name ${from}o${port}
  	    }
  	    inlet {
! 		set @from ""
! 		set @outlet ""
! 		set @to $from
! 		set @inlet $port
  		set port_name ${from}i${port}
  	    }
--- 3907,3917 ----
  	switch $type {
  	    outlet {
! 		set @from $from; set @outlet $port
! 		set   @to ""   ; set @inlet ""
  		set port_name ${from}o${port}
  	    }
  	    inlet {
! 		set @from ""   ; set @outlet ""
! 		set   @to $from; set @inlet $port
  		set port_name ${from}i${port}
  	    }
***************
*** 3956,3965 ****
  		}
  		inlet {
! 			mset [list type @to @inlet] $target
  		}
  		default {}
  	}
  	set from_idx [$@canvas children_idx $@from]
! 	set to_idx [$@canvas children_idx $@to]
  	if {$from_idx >= 0 && $to_idx >= 0 && $@from != $@to} {
  		$@canvas connect [list $from_idx $@outlet $to_idx $@inlet]
--- 3940,3949 ----
  		}
  		inlet {
! 			mset [list type   @to  @inlet] $target
  		}
  		default {}
  	}
  	set from_idx [$@canvas children_idx $@from]
! 	set   to_idx [$@canvas children_idx $@to]
  	if {$from_idx >= 0 && $to_idx >= 0 && $@from != $@to} {
  		$@canvas connect [list $from_idx $@outlet $to_idx $@inlet]
***************
*** 4946,4954 ****
  	mset {from outlet to inlet} $@connects
  	set children [$c children]
! 	set @obj1 [lindex $children $from]
! 	set @obj2 [lindex $children $to]
  	# associate wires to its connected objects
! 	lappend _($@obj1:wires2) $self
! 	lappend _($@obj2:wires2) $self
  }
  
--- 4930,4938 ----
  	mset {from outlet to inlet} $@connects
  	set children [$c children]
! 	set @from [lindex $children $from]
! 	set   @to [lindex $children $to]
  	# associate wires to its connected objects
! 	lappend _($@from:wires2) $self
! 	lappend   _($@to:wires2) $self
  }
  
***************
*** 4966,4972 ****
  }
  
! def Wire   from {} {return $@obj1}
  def Wire outlet {} {return $@outlet}
! def Wire     to {} {return $@obj2}
  def Wire  inlet {} {return $@inlet}
  def Wire move {dx dy} {$self changed}
--- 4950,4956 ----
  }
  
! def Wire   from {} {return $@from}
  def Wire outlet {} {return $@outlet}
! def Wire     to {} {return $@to}
  def Wire  inlet {} {return $@inlet}
  def Wire move {dx dy} {$self changed}
***************
*** 4977,4986 ****
  
  def Wire bbox {} {
! 	set obj1 $@obj1; set outlet $@outlet
! 	set obj2 $@obj2; set  inlet  $@inlet
  	set zoom [$@canvas zoom]
  	set c [$@canvas widget]
! 	mset {x1 y1} [lmap / [rect_centre [$c bbox ${obj1}o${outlet}]] $zoom]
! 	mset {x2 y2} [lmap / [rect_centre [$c bbox ${obj2}i${inlet} ]] $zoom]
  	list $x1 $y1 $x2 $y2
  }
--- 4961,4970 ----
  
  def Wire bbox {} {
! 	set from $@from; set outlet $@outlet
! 	set   to $@to;   set  inlet  $@inlet
  	set zoom [$@canvas zoom]
  	set c [$@canvas widget]
! 	mset {x1 y1} [lmap / [rect_centre [$c bbox ${from}o${outlet}]] $zoom]
! 	mset {x2 y2} [lmap / [rect_centre [$c bbox   ${to}i${inlet} ]] $zoom]
  	list $x1 $y1 $x2 $y2
  }
***************
*** 4991,4995 ****
  }
  
! def Wire report {} {list $@obj1 $@outlet $@obj2 $@inlet}
  def Wire connects {} {return $@connects}
  proc xys {x1 y1 x2 y2} {
--- 4975,4979 ----
  }
  
! def Wire report {} {list $@from $@outlet $@to $@inlet}
  def Wire connects {} {return $@connects}
  proc xys {x1 y1 x2 y2} {
***************
*** 5013,5019 ****
  	set zoom [$@canvas zoom]
  	set c [$@canvas widget]
! 	set iowidth [$@obj1 look iowidth]
! 	mset {ox1 oy1 ox2 oy2} [$@obj1 io_bbox o $@outlet]
! 	mset {ix1 iy1 ix2 iy2} [$@obj2 io_bbox i $@inlet]
  	set x1 [expr ($ox1+$ox2)/2.0]; set y1 $oy2
  	set x2 [expr ($ix1+$ix2)/2.0]; set y2 $iy1
--- 4997,5003 ----
  	set zoom [$@canvas zoom]
  	set c [$@canvas widget]
! 	set iowidth [$@from look iowidth]
! 	mset {ox1 oy1 ox2 oy2} [$@from io_bbox o $@outlet]
! 	mset {ix1 iy1 ix2 iy2} [  $@to io_bbox i $@inlet]
  	set x1 [expr ($ox1+$ox2)/2.0]; set y1 $oy2
  	set x2 [expr ($ix1+$ix2)/2.0]; set y2 $iy1
***************
*** 5029,5035 ****
  	    set wire_color [$self look fg2] ;# fg2 should be renamed
  	} else {
! 	    if {[info exists _($@obj1:text)] && [info exists _($@obj2:text)]} {
! 		if {[regexp -nocase {~$} [lindex $_($@obj1:text) 0]] && \
! 		    [regexp -nocase {~$} [lindex $_($@obj2:text) 0]]} {
  			set wire_width [expr $wire_width*2]
  		}
--- 5013,5019 ----
  	    set wire_color [$self look fg2] ;# fg2 should be renamed
  	} else {
! 	    if {[info exists _($@from:text)] && [info exists _($@to:text)]} {
! 		if {[regexp -nocase {~$} [lindex $_($@from:text) 0]] && \
! 		    [regexp -nocase {~$} [lindex   $_($@to:text) 0]]} {
  			set wire_width [expr $wire_width*2]
  		}
***************
*** 5044,5049 ****
  	if {![winfo exists .$@canvas.c]} {return}
  	$self unsubscribe $@canvas
! 	$@obj1 delete_wire $self
! 	$@obj2 delete_wire $self
  	$@canvas wires-= $self
  	super
--- 5028,5033 ----
  	if {![winfo exists .$@canvas.c]} {return}
  	$self unsubscribe $@canvas
! 	$@from delete_wire $self
! 	$@to   delete_wire $self
  	$@canvas wires-= $self
  	super
***************
*** 8371,8380 ****
  	if {$selcanvas == ""} {
  		list #X connect \
! 		    [$@canvas index $@obj1] $@outlet \
! 		    [$@canvas index $@obj2] $@inlet
  	} {
  		list #X connect \
! 		    $::obj_index_sel($@canvas:$@obj1) $@outlet \
! 		    $::obj_index_sel($@canvas:$@obj2) $@inlet
  	}
  }
--- 8355,8364 ----
  	if {$selcanvas == ""} {
  		list #X connect \
! 		    [$@canvas index $@from] $@outlet \
! 		    [$@canvas index $@to]   $@inlet
  	} {
  		list #X connect \
! 		    $::obj_index_sel($@canvas:$@from) $@outlet \
! 		    $::obj_index_sel($@canvas:$@to)   $@inlet
  	}
  }
***************
*** 8519,8525 ****
  	puts "$nodes"
  	foreach wire $@wires {
! 		mset {obj1 outlet obj2 inlet}  [$wire report]
! 		set n1  [lindex $nodes [expr [lsearch $nodes $obj1]-1]]
! 		set n2  [lindex $nodes [expr [lsearch $nodes $obj2]-1]]
  		$n1 addedge $n2
  	}
--- 8503,8509 ----
  	puts "$nodes"
  	foreach wire $@wires {
! 		mset {from outlet to inlet}  [$wire report]
! 		set n1  [lindex $nodes [expr [lsearch $nodes $from]-1]]
! 		set n2  [lindex $nodes [expr [lsearch $nodes   $to]-1]]
  		$n1 addedge $n2
  	}





More information about the Pd-cvs mailing list