call do_*_motion() regardless of drawing status
This commit is contained in:
parent
4a7e677bf3
commit
03754f3cec
@ -252,7 +252,7 @@ class SketchWidget:
|
|||||||
self.view_center[1] - this_pt[1] + start_pt[1])
|
self.view_center[1] - this_pt[1] + start_pt[1])
|
||||||
self.panning_start = (event.x, self.size[1] - event.y)
|
self.panning_start = (event.x, self.size[1] - event.y)
|
||||||
self.queue_redraw()
|
self.queue_redraw()
|
||||||
elif self.drawingShape is not None:
|
else:
|
||||||
if self.mode == 'line':
|
if self.mode == 'line':
|
||||||
self.do_line_motion(event.x, event.y)
|
self.do_line_motion(event.x, event.y)
|
||||||
elif self.mode == 'circle':
|
elif self.mode == 'circle':
|
||||||
@ -383,31 +383,32 @@ class SketchWidget:
|
|||||||
self.queue_redraw()
|
self.queue_redraw()
|
||||||
|
|
||||||
def do_line_motion(self, x, y):
|
def do_line_motion(self, x, y):
|
||||||
this_pt = self.screenPtToPt((x, self.size[1] - y))
|
if self.drawingShape is not None:
|
||||||
start = self.drawingShape.getPt(0)
|
this_pt = self.screenPtToPt((x, self.size[1] - y))
|
||||||
angle = math.atan2(this_pt[1] - start[1], this_pt[0] - start[0])
|
start = self.drawingShape.getPt(0)
|
||||||
angle *= 180.0 / math.pi
|
angle = math.atan2(this_pt[1] - start[1], this_pt[0] - start[0])
|
||||||
def within(a, b, d): return abs(a - b) < d
|
angle *= 180.0 / math.pi
|
||||||
def snaps_to(q): return within(angle, q, self.snap_angle)
|
def within(a, b, d): return abs(a - b) < d
|
||||||
hv_snap_dist = self.screenDistToDist(self.hv_snap_dist)
|
def snaps_to(q): return within(angle, q, self.snap_angle)
|
||||||
if ((snaps_to(-180) or snaps_to(180) or snaps_to(0))
|
hv_snap_dist = self.screenDistToDist(self.hv_snap_dist)
|
||||||
and within(start[1], this_pt[1], hv_snap_dist)):
|
if ((snaps_to(-180) or snaps_to(180) or snaps_to(0))
|
||||||
this_pt = (this_pt[0], start[1])
|
and within(start[1], this_pt[1], hv_snap_dist)):
|
||||||
if not (len(self.drawingConstraints) > 0
|
this_pt = (this_pt[0], start[1])
|
||||||
and isinstance(self.drawingConstraints[0], Horizontal)):
|
if not (len(self.drawingConstraints) > 0
|
||||||
c = Horizontal(self.drawingShape, 0, self.drawingShape, 1)
|
and isinstance(self.drawingConstraints[0], Horizontal)):
|
||||||
self.drawingConstraints = [c]
|
c = Horizontal(self.drawingShape, 0, self.drawingShape, 1)
|
||||||
elif ((snaps_to(-90) or snaps_to(90))
|
self.drawingConstraints = [c]
|
||||||
and within(start[0], this_pt[0], hv_snap_dist)):
|
elif ((snaps_to(-90) or snaps_to(90))
|
||||||
this_pt = (start[0], this_pt[1])
|
and within(start[0], this_pt[0], hv_snap_dist)):
|
||||||
if not (len(self.drawingConstraints) > 0
|
this_pt = (start[0], this_pt[1])
|
||||||
and isinstance(self.drawingConstraints[0], Vertical)):
|
if not (len(self.drawingConstraints) > 0
|
||||||
c = Vertical(self.drawingShape, 0, self.drawingShape, 1)
|
and isinstance(self.drawingConstraints[0], Vertical)):
|
||||||
self.drawingConstraints = [c]
|
c = Vertical(self.drawingShape, 0, self.drawingShape, 1)
|
||||||
else:
|
self.drawingConstraints = [c]
|
||||||
self.drawingConstraints = []
|
else:
|
||||||
self.drawingShape.setPt(1, this_pt)
|
self.drawingConstraints = []
|
||||||
self.queue_redraw()
|
self.drawingShape.setPt(1, this_pt)
|
||||||
|
self.queue_redraw()
|
||||||
|
|
||||||
def do_circle_left_click(self, x, y):
|
def do_circle_left_click(self, x, y):
|
||||||
pt = self.screenPtToPt((x, self.size[1] - y))
|
pt = self.screenPtToPt((x, self.size[1] - y))
|
||||||
@ -423,10 +424,11 @@ class SketchWidget:
|
|||||||
self.queue_redraw()
|
self.queue_redraw()
|
||||||
|
|
||||||
def do_circle_motion(self, x, y):
|
def do_circle_motion(self, x, y):
|
||||||
pt = self.screenPtToPt((x, self.size[1] - y))
|
if self.drawingShape is not None:
|
||||||
r = self.dist_bw(self.drawingShape.getPt(0), pt)
|
pt = self.screenPtToPt((x, self.size[1] - y))
|
||||||
self.drawingShape.setRadius(r)
|
r = self.dist_bw(self.drawingShape.getPt(0), pt)
|
||||||
self.queue_redraw()
|
self.drawingShape.setRadius(r)
|
||||||
|
self.queue_redraw()
|
||||||
|
|
||||||
def cancel_drawing_shape(self):
|
def cancel_drawing_shape(self):
|
||||||
self.drawingShape = None
|
self.drawingShape = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user