createGroup

$canvaseditor createGroup
creates new group object out of selected objects. Manages selection by the way.

obj method canvaseditor createGroup {} {
  set elements [my selection]
  if {[llength $elements] < 2} return
  #
  # check on connected lines
  #
  foreach obj [my selection] {
    if {[$obj isa line]} then {
      foreach dot [$obj dots -end] {
        foreach line [$dot lines] {
          if {$line ni [my selection]} then {
            $obj unjoin $line
            break
          }
        }
      }
    }
  }
  #
  set g [new group {*}$elements]
  foreach obj $elements {
    $self select $obj
  }
  $self select $g
  lappend undoLines "$self select"
  foreach obj $elements {
    lappend undoLines "$g release $obj"\
    }
  set undoString \n[join $undoLines \n]\n
  #
  lappend redoLines "$self select"
  foreach obj $elements {
    lappend redoLines "$g add $obj"
  }
  set redoString \n[join $redoLines \n]\n
  #
  $self initUndoRedo $undoString $redoString
}

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