From f2fdf190794053a28c46f42279bd3cad373873f7 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 3 Apr 2011 20:09:56 -0400 Subject: [PATCH] SketchWidget: refactor drawing of shapes/constraints --- SketchWidget.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/SketchWidget.py b/SketchWidget.py index 08c7635..5e08037 100644 --- a/SketchWidget.py +++ b/SketchWidget.py @@ -6,6 +6,7 @@ import gtk.gtkgl from OpenGL.GL import * from shapes import * +from constraints import * class SketchWidget: def __init__(self, sketch): @@ -25,6 +26,7 @@ class SketchWidget: self.background_color = (0.6, 0.9, 1.0, 1.0) self.line_color = (0.1, 0.4, 1.0, 1.0) self.axis_color = (1.0, 0.0, 0.0, 1.0) + self.constraint_color = (0.5, 1.0, 0.0, 1.0) try: # try double-buffered @@ -103,12 +105,8 @@ class SketchWidget: self.drawAxes() - glColor(*self.line_color) - for shape in self.sketch: - if isinstance(shape, Line): - self.drawLine(shape, self.line_width) - elif isinstance(shape, Circle): - self.drawCircle(shape, self.line_width) + self.drawShapes() + self.drawConstraints() if self.drawingLine is not None: self.drawLine(self.drawingLine, self.line_width) @@ -263,3 +261,18 @@ class SketchWidget: def queue_redraw(self): self.widget.queue_draw_area(0, 0, int(self.size[0]), int(self.size[1])) + + def drawShapes(self): + glColor(*self.line_color) + for shape in self.sketch: + if isinstance(shape, Line): + self.drawLine(shape, self.line_width) + elif isinstance(shape, Circle): + self.drawCircle(shape, self.line_width) + + def drawConstraints(self): + glColor(*self.constraint_color) + for c in self.sketch.constraints: + if isinstance(c, Connect): +# self.drawConnect(c) + pass