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(),
|
'line': LineMode(),
|
||||||
'circle': CircleMode(),
|
'circle': CircleMode(),
|
||||||
'connect': ConnectMode(),
|
'connect': ConnectMode(),
|
||||||
|
'horizontal': HorizontalMode(),
|
||||||
|
'vertical': VerticalMode(),
|
||||||
}
|
}
|
||||||
self.mode_name = 'select'
|
self.mode_name = 'select'
|
||||||
self.mode = self.modes[self.mode_name]
|
self.mode = self.modes[self.mode_name]
|
||||||
@ -635,3 +637,57 @@ class ConnectMode(Mode):
|
|||||||
self.first_ptref = None
|
self.first_ptref = None
|
||||||
else:
|
else:
|
||||||
sw.window.set_mode('')
|
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('')
|
||||||
|
@ -34,6 +34,8 @@ class Window(object):
|
|||||||
addButton('line', 'Line')
|
addButton('line', 'Line')
|
||||||
addButton('circle', 'Circle')
|
addButton('circle', 'Circle')
|
||||||
addButton('connect', 'Connect')
|
addButton('connect', 'Connect')
|
||||||
|
addButton('horizontal', 'Horiz')
|
||||||
|
addButton('vertical', 'Vert')
|
||||||
|
|
||||||
self.status_lbl = gtk.Label()
|
self.status_lbl = gtk.Label()
|
||||||
self.status_lbl.set_alignment(0.0, 0.5)
|
self.status_lbl.set_alignment(0.0, 0.5)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user