draw horizontal and vertical constraints
This commit is contained in:
parent
0401d89bb4
commit
02db7d629d
@ -270,18 +270,55 @@ class SketchWidget:
|
|||||||
self.drawCircle(shape)
|
self.drawCircle(shape)
|
||||||
|
|
||||||
def drawConstraints(self):
|
def drawConstraints(self):
|
||||||
|
glColor(*self.constraint_color)
|
||||||
for c in self.sketch.constraints:
|
for c in self.sketch.constraints:
|
||||||
if isinstance(c, Connect):
|
if isinstance(c, Connect):
|
||||||
self.drawConnect(c)
|
self.drawConnect(c)
|
||||||
|
elif isinstance(c, Horizontal):
|
||||||
|
self.drawHorizontal(c)
|
||||||
|
elif isinstance(c, Vertical):
|
||||||
|
self.drawVertical(c)
|
||||||
|
|
||||||
def drawConnect(self, con):
|
def drawConnect(self, con):
|
||||||
glColor(*self.constraint_color)
|
|
||||||
pt = self.ptToScreenPt(con.shape1.getPt(con.pt1))
|
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
|
s = self.line_width * 2
|
||||||
glBegin(GL_LINE_LOOP)
|
glBegin(GL_LINE_LOOP)
|
||||||
glVertex(pt[0] + s, pt[1] + s)
|
glVertex(x + s, y + s)
|
||||||
glVertex(pt[0] - s, pt[1] + s)
|
glVertex(x - s, y + s)
|
||||||
glVertex(pt[0] - s, pt[1] - s)
|
glVertex(x - s, y - s)
|
||||||
glVertex(pt[0] + s, pt[1] - s)
|
glVertex(x + s, y - s)
|
||||||
glEnd()
|
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()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user