From a0fe5aa6aa4ae45ddb1063593c3b2337ac2ec33b Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 27 Jul 2011 23:17:35 -0400 Subject: [PATCH] move glColor() out of individual draw routines --- SketchWidget.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/SketchWidget.py b/SketchWidget.py index e992896..5b28599 100644 --- a/SketchWidget.py +++ b/SketchWidget.py @@ -24,6 +24,7 @@ class SketchWidget: 'arrow': gtk.gdk.Cursor(gtk.gdk.ARROW), 'crosshair': gtk.gdk.Cursor(gtk.gdk.CROSSHAIR), } + self.current_snap_point = None # Configuration parameters self.line_width = 1.5 @@ -125,7 +126,9 @@ class SketchWidget: self.drawConstraints() if self.drawingShape is not None: + glColor(*self.line_color) self.drawShape(self.drawingShape) + glColor(*self.constraint_color) for c in self.drawingConstraints: self.drawConstraint(c) @@ -157,13 +160,11 @@ class SketchWidget: return dist / self.size[0] * self.view_width def drawLine(self, shape): - glColor(*self.line_color) pt0 = self.ptToScreenPt(shape.getPt(0)) pt1 = self.ptToScreenPt(shape.getPt(1)) self.drawFilledLine(pt0[0], pt0[1], pt1[0], pt1[1], self.line_width) def drawCircle(self, shape): - glColor(*self.line_color) center = self.ptToScreenPt(shape.getCenter()) rad = self.distToScreenDist(shape.getRadius()) if rad < 30: @@ -284,6 +285,7 @@ class SketchWidget: self.widget.queue_draw_area(0, 0, *map(int, self.size)) def drawShapes(self): + glColor(*self.line_color) for shape in self.sketch: self.drawShape(shape) @@ -294,6 +296,7 @@ class SketchWidget: self.drawCircle(shape) def drawConstraints(self): + glColor(*self.constraint_color) for c in self.sketch.constraints: self.drawConstraint(c) @@ -306,12 +309,10 @@ class SketchWidget: self.drawVertical(c) def drawConnect(self, con): - glColor(*self.constraint_color) pt = self.ptToScreenPt(con.shape1.getPt(con.pt1)) self.drawHandle(pt[0], pt[1]) def drawHandle(self, x, y): - glColor(*self.constraint_color) self.drawFilledCircle(x, y, self.line_width, 4) s = self.line_width * 2 glBegin(GL_LINE_LOOP) @@ -322,7 +323,6 @@ class SketchWidget: glEnd() def drawHorizontal(self, con): - glColor(*self.constraint_color) l = 15.0 glPushAttrib(GL_LINE_BIT) glEnable(GL_LINE_STIPPLE) @@ -338,7 +338,6 @@ class SketchWidget: glPopAttrib() def drawVertical(self, con): - glColor(*self.constraint_color) l = 15.0 glPushAttrib(GL_LINE_BIT) glEnable(GL_LINE_STIPPLE)