move glColor() out of individual draw routines
This commit is contained in:
parent
03754f3cec
commit
a0fe5aa6aa
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user