complete circle drawing
This commit is contained in:
parent
4ec320ff5d
commit
b95e8e8789
@ -246,6 +246,8 @@ class SketchWidget:
|
|||||||
elif self.drawingShape is not None:
|
elif self.drawingShape is not None:
|
||||||
if self.mode == 'line':
|
if self.mode == 'line':
|
||||||
self.do_line_motion(event.x, event.y)
|
self.do_line_motion(event.x, event.y)
|
||||||
|
elif self.mode == 'circle':
|
||||||
|
self.do_circle_motion(event.x, event.y)
|
||||||
|
|
||||||
def scroll_event(self, widget, event, data = None):
|
def scroll_event(self, widget, event, data = None):
|
||||||
if event.direction == gtk.gdk.SCROLL_UP:
|
if event.direction == gtk.gdk.SCROLL_UP:
|
||||||
@ -353,8 +355,8 @@ class SketchWidget:
|
|||||||
def do_line_left_click(self, x, y):
|
def do_line_left_click(self, x, y):
|
||||||
start = self.screenPtToPt((x, self.size[1] - y))
|
start = self.screenPtToPt((x, self.size[1] - y))
|
||||||
if self.drawingShape is not None:
|
if self.drawingShape is not None:
|
||||||
self.merge_in_drawing_shape()
|
|
||||||
start = self.drawingShape.getPt(1) # start at last snap point
|
start = self.drawingShape.getPt(1) # start at last snap point
|
||||||
|
self.merge_in_drawing_shape()
|
||||||
self.drawingShape = Line(start[0], start[1], start[0], start[1])
|
self.drawingShape = Line(start[0], start[1], start[0], start[1])
|
||||||
self.queue_redraw()
|
self.queue_redraw()
|
||||||
|
|
||||||
@ -395,6 +397,9 @@ class SketchWidget:
|
|||||||
pt = self.screenPtToPt((x, self.size[1] - y))
|
pt = self.screenPtToPt((x, self.size[1] - y))
|
||||||
if self.drawingShape is None:
|
if self.drawingShape is None:
|
||||||
self.drawingShape = Circle(pt[0], pt[1], 0)
|
self.drawingShape = Circle(pt[0], pt[1], 0)
|
||||||
|
else:
|
||||||
|
self.merge_in_drawing_shape()
|
||||||
|
self.queue_redraw()
|
||||||
|
|
||||||
def do_circle_right_click(self, x, y):
|
def do_circle_right_click(self, x, y):
|
||||||
if self.drawingShape is not None:
|
if self.drawingShape is not None:
|
||||||
@ -402,8 +407,20 @@ class SketchWidget:
|
|||||||
self.drawingShape = None
|
self.drawingShape = None
|
||||||
self.queue_redraw()
|
self.queue_redraw()
|
||||||
|
|
||||||
|
def do_circle_motion(self, x, y):
|
||||||
|
pt = self.screenPtToPt((x, self.size[1] - y))
|
||||||
|
r = self.dist_bw(self.drawingShape.getPt(0), pt)
|
||||||
|
self.drawingShape.setRadius(r)
|
||||||
|
self.queue_redraw()
|
||||||
|
|
||||||
def merge_in_drawing_shape(self):
|
def merge_in_drawing_shape(self):
|
||||||
self.sketch.shapes.append(self.drawingShape)
|
self.sketch.shapes.append(self.drawingShape)
|
||||||
for c in self.drawingConstraints:
|
for c in self.drawingConstraints:
|
||||||
self.sketch.constraints.append(c)
|
self.sketch.constraints.append(c)
|
||||||
|
self.drawingShape = None
|
||||||
self.drawingConstraints = []
|
self.drawingConstraints = []
|
||||||
|
|
||||||
|
def dist_bw(self, pt1, pt2):
|
||||||
|
x = pt2[0] - pt1[0]
|
||||||
|
y = pt2[1] - pt1[1]
|
||||||
|
return math.sqrt(x * x + y * y)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user