add Horiz/Vert contraint buttons and drawing modes
This commit is contained in:
parent
6c6e7be7e4
commit
a24179d38f
@ -26,6 +26,8 @@ class SketchWidget(object):
|
||||
'line': LineMode(),
|
||||
'circle': CircleMode(),
|
||||
'connect': ConnectMode(),
|
||||
'horizontal': HorizontalMode(),
|
||||
'vertical': VerticalMode(),
|
||||
}
|
||||
self.mode_name = 'select'
|
||||
self.mode = self.modes[self.mode_name]
|
||||
@ -635,3 +637,57 @@ class ConnectMode(Mode):
|
||||
self.first_ptref = None
|
||||
else:
|
||||
sw.window.set_mode('')
|
||||
|
||||
class HorizontalMode(Mode):
|
||||
def start_mode(self, sw):
|
||||
self.first_ptref = None
|
||||
|
||||
def get_cursor(self):
|
||||
return 'crosshair'
|
||||
|
||||
def do_motion(self, sw, 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 = Horizontal(self.first_ptref.shape, self.first_ptref.ptNum,
|
||||
sw.hover_snap_ptref.shape, sw.hover_snap_ptref.ptNum)
|
||||
sw.sketch.constraints.append(c)
|
||||
self.first_ptref = None
|
||||
sw.invalidate()
|
||||
|
||||
def do_right_click(self, sw, x, y):
|
||||
if self.first_ptref is not None:
|
||||
self.first_ptref = None
|
||||
else:
|
||||
sw.window.set_mode('')
|
||||
|
||||
class VerticalMode(Mode):
|
||||
def start_mode(self, sw):
|
||||
self.first_ptref = None
|
||||
|
||||
def get_cursor(self):
|
||||
return 'crosshair'
|
||||
|
||||
def do_motion(self, sw, 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 = Vertical(self.first_ptref.shape, self.first_ptref.ptNum,
|
||||
sw.hover_snap_ptref.shape, sw.hover_snap_ptref.ptNum)
|
||||
sw.sketch.constraints.append(c)
|
||||
self.first_ptref = None
|
||||
sw.invalidate()
|
||||
|
||||
def do_right_click(self, sw, x, y):
|
||||
if self.first_ptref is not None:
|
||||
self.first_ptref = None
|
||||
else:
|
||||
sw.window.set_mode('')
|
||||
|
Loading…
x
Reference in New Issue
Block a user