draw horizontal and vertical constraints

This commit is contained in:
Josh Holtrop 2011-04-23 21:06:56 -04:00
parent 0401d89bb4
commit 02db7d629d

View File

@ -270,18 +270,55 @@ class SketchWidget:
self.drawCircle(shape)
def drawConstraints(self):
glColor(*self.constraint_color)
for c in self.sketch.constraints:
if isinstance(c, Connect):
self.drawConnect(c)
elif isinstance(c, Horizontal):
self.drawHorizontal(c)
elif isinstance(c, Vertical):
self.drawVertical(c)
def drawConnect(self, con):
glColor(*self.constraint_color)
pt = self.ptToScreenPt(con.shape1.getPt(con.pt1))
self.drawFilledCircle(pt[0], pt[1], self.line_width, 4)
self.drawHandle(pt[0], pt[1])
def drawHandle(self, x, y):
self.drawFilledCircle(x, y, self.line_width, 4)
s = self.line_width * 2
glBegin(GL_LINE_LOOP)
glVertex(pt[0] + s, pt[1] + s)
glVertex(pt[0] - s, pt[1] + s)
glVertex(pt[0] - s, pt[1] - s)
glVertex(pt[0] + s, pt[1] - s)
glVertex(x + s, y + s)
glVertex(x - s, y + s)
glVertex(x - s, y - s)
glVertex(x + s, y - s)
glEnd()
def drawHorizontal(self, con):
l = 15.0
glPushAttrib(GL_LINE_BIT)
glEnable(GL_LINE_STIPPLE)
glLineStipple(3, 0x5555)
if con.shape1 == con.shape2 and isinstance(con.shape1, Line):
pt = self.ptToScreenPt(con.shape1.getPt(2))
glBegin(GL_LINES)
glVertex(pt[0] - l/2, pt[1] + self.line_width * 2)
glVertex(pt[0] + l/2, pt[1] + self.line_width * 2)
glVertex(pt[0] - l/2, pt[1] - self.line_width * 2)
glVertex(pt[0] + l/2, pt[1] - self.line_width * 2)
glEnd()
glPopAttrib()
def drawVertical(self, con):
l = 15.0
glPushAttrib(GL_LINE_BIT)
glEnable(GL_LINE_STIPPLE)
glLineStipple(3, 0x5555)
if con.shape1 == con.shape2 and isinstance(con.shape1, Line):
pt = self.ptToScreenPt(con.shape1.getPt(2))
glBegin(GL_LINES)
glVertex(pt[0] - self.line_width * 2, pt[1] + l/2)
glVertex(pt[0] - self.line_width * 2, pt[1] - l/2)
glVertex(pt[0] + self.line_width * 2, pt[1] + l/2)
glVertex(pt[0] + self.line_width * 2, pt[1] - l/2)
glEnd()
glPopAttrib()