draw horizontal/vertical constraints connecting multiple shapes

This commit is contained in:
Josh Holtrop 2011-09-30 14:58:00 -04:00
parent a24179d38f
commit 62dcd76efc

View File

@ -335,12 +335,24 @@ class SketchWidget(object):
glVertex(x + s, y - s)
glEnd()
def drawHorizontal(self, con):
l = 15.0
def drawStippleConnect(self, pt1, pt2):
self.drawHandle(*pt1)
self.drawHandle(*pt2)
glPushAttrib(GL_LINE_BIT)
glEnable(GL_LINE_STIPPLE)
glLineStipple(3, 0x5555)
glBegin(GL_LINES)
glVertex(*pt1)
glVertex(*pt2)
glEnd()
glPopAttrib()
def drawHorizontal(self, con):
if con.shape1 == con.shape2 and isinstance(con.shape1, Line):
l = 15.0
glPushAttrib(GL_LINE_BIT)
glEnable(GL_LINE_STIPPLE)
glLineStipple(3, 0x5555)
pt = self.ptToScreenPt(con.shape1.getPt(2))
glBegin(GL_LINES)
glVertex(pt[0] - l/2, pt[1] + self.line_width * 2)
@ -348,14 +360,18 @@ class SketchWidget(object):
glVertex(pt[0] - l/2, pt[1] - self.line_width * 2)
glVertex(pt[0] + l/2, pt[1] - self.line_width * 2)
glEnd()
glPopAttrib()
glPopAttrib()
else:
pt1 = self.ptToScreenPt(con.shape1.getPt(con.pt1))
pt2 = self.ptToScreenPt(con.shape2.getPt(con.pt2))
self.drawStippleConnect(pt1, pt2)
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):
l = 15.0
glPushAttrib(GL_LINE_BIT)
glEnable(GL_LINE_STIPPLE)
glLineStipple(3, 0x5555)
pt = self.ptToScreenPt(con.shape1.getPt(2))
glBegin(GL_LINES)
glVertex(pt[0] - self.line_width * 2, pt[1] + l/2)
@ -363,7 +379,11 @@ class SketchWidget(object):
glVertex(pt[0] + self.line_width * 2, pt[1] + l/2)
glVertex(pt[0] + self.line_width * 2, pt[1] - l/2)
glEnd()
glPopAttrib()
glPopAttrib()
else:
pt1 = self.ptToScreenPt(con.shape1.getPt(con.pt1))
pt2 = self.ptToScreenPt(con.shape2.getPt(con.pt2))
self.drawStippleConnect(pt1, pt2)
def set_mode(self, mode_name):
if mode_name not in self.modes: