obj method canvaseditor shearMode {{mode parallel}} {
set canvas [my canvas]
$self selected dots storeXY
$self selected calcCenter
#
set axis [$self calcAxis]
set p0 [$axis firstDot]
set p1 [$axis lastDot]
#
set cx [$p0 cget -x]
set cy [$p0 cget -y]
set ex [$p1 cget -x]
set ey [$p1 cget -y]
set dx [- $ex $cx]
set dy [- $ey $cy]
set phi [- [atan2 $dx $dy] [atan2 1 0]]
#
set nDot [$self nearestDot -selected -end]
set x0 [$nDot cget -x]
set y0 [$nDot cget -y]
#
$self memory currentDot $nDot
$self memory transformation "shear diagonal $mode"
#
if {[distToLine $cx $cy $ex $ey $x0 $y0] < 1} then {
return -code error "Too close to axis!"
}
#
set dot [new dot $x0 $y0]
#
$self memory before [$self undoRedoCode]
#
$self pointerToDot $nDot
$self memory currentDot $nDot
$self selected blink off
$self basicBindings off
$self statusLine Shear objects diagonal $mode
$self snapMode on
$axis dots show
switch -exact -- $mode {
horizontal {
set motionBinding [subst -nocommand {
$dot configure -x [$self canvasx %x] -y $y0
$self shearSelection $dot $nDot $cx $cy $phi $mode
}]
}
vertical {
set motionBinding [subst -nocommand {
$dot configure -x $x0 -y [$self canvasy %y]
$self shearSelection $dot $nDot $cx $cy $phi $mode
}]
}
default {
set motionBinding [subst -nocommand {
$dot configure -x [$self canvasx %x] -y [$self canvasy %y]
$self shearSelection $dot $nDot $cx $cy $phi $mode
}]
}
}
after idle [list bind $canvas <Motion> $motionBinding]
bind $canvas <<Click>> "
$self finishTransform
$dot destroy
$axis dots show no
"
}
© Wolf-Dieter Busch | Home | Sitemap | Urheber | A-Z