ConnectMode creates Connect object and re-solves sketch!

This commit is contained in:
Josh Holtrop 2011-09-08 16:32:26 -04:00
parent 702aa1eaf8
commit e0491b7b1a

View File

@ -376,6 +376,7 @@ class SketchWidget(object):
if c in self.cursors and c != self.cursor: if c in self.cursors and c != self.cursor:
self.cursor = c self.cursor = c
self.widget.window.set_cursor(self.cursors[c]) self.widget.window.set_cursor(self.cursors[c])
self.mode.start_mode(self)
def cancel_drawing_shape(self): def cancel_drawing_shape(self):
if self.drawingShape is not None: if self.drawingShape is not None:
@ -480,7 +481,7 @@ class Mode(object):
pass pass
def do_motion(self, sw, x, y): def do_motion(self, sw, x, y):
pass pass
def begin_mode(self, sw): def start_mode(self, sw):
pass pass
def end_mode(self, sw): def end_mode(self, sw):
pass pass
@ -608,8 +609,24 @@ class CircleMode(Mode):
return 'crosshair' return 'crosshair'
class ConnectMode(Mode): class ConnectMode(Mode):
def start_mode(self, sw):
self.first_ptref = None
def get_cursor(self): def get_cursor(self):
return 'crosshair' return 'crosshair'
def do_motion(self, sw, x, y): def do_motion(self, sw, x, y):
sw.update_hover_snap_point(x, y) sw.update_hover_snap_point(x, y)
def do_left_click(self, sw, x, y):
if sw.hover_snap_ptref is not None:
if self.first_ptref is None:
self.first_ptref = sw.hover_snap_ptref
else:
c = Connect(self.first_ptref.shape, self.first_ptref.ptNum,
sw.hover_snap_ptref.shape, sw.hover_snap_ptref.ptNum)
sw.sketch.constraints.append(c)
sw.invalidate()
def do_right_click(self, sw, x, y):
sw.window.set_mode('')