snap lines to shape handles while drawing
This commit is contained in:
parent
c75fbc50ab
commit
fdcb07003c
@ -376,16 +376,31 @@ class SketchWidget:
|
||||
self.cancel_drawing_shape()
|
||||
|
||||
def do_line_left_click(self, x, y):
|
||||
start = self.screenPtToPt((x, self.size[1] - y))
|
||||
previous_line = None
|
||||
click_pt = self.screenPtToPt((x, self.size[1] - y))
|
||||
start = click_pt
|
||||
start_pt_ref = None
|
||||
if self.hover_snap_point is not None:
|
||||
start = self.hover_snap_point[0].getPt(self.hover_snap_point[1])
|
||||
start_pt_ref = self.hover_snap_point
|
||||
if self.drawingShape is not None:
|
||||
# end a currently drawing line
|
||||
start = self.drawingShape.getPt(1) # start at last snap point
|
||||
previous_line = self.drawingShape
|
||||
prev_line = self.drawingShape
|
||||
if self.hover_snap_point is not None:
|
||||
c = Connect(self.hover_snap_point[0], self.hover_snap_point[1],
|
||||
self.drawingShape, 1)
|
||||
self.drawingConstraints['c2'] = c
|
||||
pt = self.hover_snap_point[0].getPt(self.hover_snap_point[1])
|
||||
self.drawingShape.setPt(1, pt)
|
||||
self.merge_in_drawing_shape()
|
||||
self.drawingShape = Line(start[0], start[1], start[0], start[1])
|
||||
if previous_line is not None:
|
||||
connect = Connect(previous_line, 1, self.drawingShape, 0)
|
||||
self.drawingConstraints['c'] = connect
|
||||
start = prev_line.getPt(1)
|
||||
start_pt_ref = (prev_line, 1)
|
||||
# begin a new line
|
||||
self.drawingShape = Line(
|
||||
start[0], start[1], click_pt[0], click_pt[1])
|
||||
if start_pt_ref is not None:
|
||||
c = Connect(start_pt_ref[0], start_pt_ref[1], self.drawingShape, 0)
|
||||
self.drawingConstraints['c1'] = c
|
||||
self.queue_redraw()
|
||||
|
||||
def do_line_right_click(self, x, y):
|
||||
|
Loading…
x
Reference in New Issue
Block a user