add snap points for just-drawn shapes

This commit is contained in:
Josh Holtrop 2011-07-28 18:06:18 -04:00
parent aebf7df80f
commit f6b2b30910

View File

@ -385,6 +385,8 @@ class SketchWidget:
start_pt_ref = self.hover_snap_ptref
if self.drawingShape is not None:
# end a currently drawing line
# add snap points for newly drawn line
self.add_snap_ptrefs_from_shape(self.drawingShape)
start = self.drawingShape.getPt(1) # start at last snap point
prev_line = self.drawingShape
if self.hover_snap_ptref is not None:
@ -449,6 +451,7 @@ class SketchWidget:
if self.drawingShape is None:
self.drawingShape = Circle(pt[0], pt[1], 0)
else:
self.add_snap_ptrefs_from_shape(self.drawingShape)
self.merge_in_drawing_shape()
self.queue_redraw()
@ -493,9 +496,9 @@ class SketchWidget:
def update_snap_ptrefs(self):
self.snap_ptrefs = {}
for s in self.sketch.shapes:
self.add_snap_ptref(s)
self.add_snap_ptrefs_from_shape(s)
def add_snap_ptref(self, shape):
def add_snap_ptrefs_from_shape(self, shape):
for i in range(shape.nPts()):
pt = self.ptToScreenPt(shape.getPt(i))
self.snap_ptrefs[PointRef(shape, i)] = pt