connectWarpedLineToDot

$canvaseditor connectWarpedLineToDot $dot1
connects warped line by dot if possible.

Use immediately after warp.


obj method canvaseditor connectWarpedLineToDot dot1 {
  $self buildInfoWindow
  $self statusLine Failure: not connected
  # exactly one object selected?
  set selection [my selection]
  if {[llength $selection] != 1} then {
    $self statusLine Failure: more than 1 object selected
    return
  }
  # not a chaining dot?
  set lines [$dot1 private lines]
  if {[llength $lines] != 1} then {
    $self statusLine Failure: target ist connection of [llength $lines] lines
    return
  }
  lassign $lines line1
  lassign $selection line0
  # is object a line?
  if {![$line0 isa line]} then {
    $self statusLine Failure: [$line0 info class] selected
    return
  }
  # same group?
  if {[$line0 group] ne [$line1 group]} then {
    $self statusLine Failure: not same group
    return
  }
  set dot0 [$self memory currentDot]
  # exactly one line?
  if {[llength [$dot0 lines]] != 1} then {
    $self statusLine Failure: warped line already connected
    return
  }
  #
  if {
    ($dot0 eq [$line0 lastDot] && $dot1 eq [$line1 lastDot] ) ||
    ($dot0 eq [$line0 firstDot] && $dot1 eq [$line1 firstDot] )
  } then {
    foreach line [$line0 chainedList] {
      $line private dots [lreverse [$line private dots]]
    }
  }
  if {[$line0 lastDot] eq $dot0} then {
    $line0 joinEnd $line1 
  } else {
    $line0 joinEnd $line1 first
  }
  $self statusLine Success: lines connected
}

© Wolf-Dieter Busch | Home | Sitemap | Urheber | A-Z