Example #1
0
    def draw(self, canvas):

        cos = math.cos(self.angle)
        sin = math.sin(self.angle)

        def rotate(x, y):
            return (x * cos - y * sin, x * sin + y * cos)

        if self.valid:
            canvas.dc.SetPen(wx.Pen(self.dark_color, 2, wx.SHORT_DASH))
        else:
            canvas.dc.SetPen(wx.Pen(wx.Colour(255, 0, 0), 2, wx.SHORT_DASH))
        canvas.dc.SetBrush(wx.TRANSPARENT_BRUSH)

        chamfer = abs(abs(self.chamfer.offset) - self.width / 2)
        points = [
            (0, self.chamfer.offset),
            (0, -self.chamfer.offset),
            (-chamfer, -self.width / 2),
            (-self.depth, -self.width / 2),
            (-self.depth, self.width / 2),
            (-chamfer, self.width / 2),
            (0, self.chamfer.offset),
        ]

        for i in range(1, len(points)):
            x0, y0 = rotate(points[i - 1][0], points[i - 1][1])
            x1, y1 = rotate(points[i][0], points[i][1])
            x0, y0 = canvas.pos_to_pixel(x0 + self.x, y0 + self.y)
            x1, y1 = canvas.pos_to_pixel(x1 + self.x, y1 + self.y)
            canvas.dc.DrawLine(x0, y0, x1, y1)
        MathShape.draw(self, canvas)
Example #2
0
    def draw(self, canvas):
        x, y = canvas.pos_to_pixel(self.x, self.y)
        r = canvas.pos_to_pixel(self.r)

        if self.valid:
            canvas.dc.SetPen(wx.Pen(self.dark_color, 2, wx.SHORT_DASH))
        else:
            canvas.dc.SetPen(wx.Pen(wx.Colour(255, 0, 0), 2, wx.SHORT_DASH))
        canvas.dc.SetBrush(wx.TRANSPARENT_BRUSH)
        canvas.dc.DrawCircle(x, y, r)
        MathShape.draw(self, canvas)
Example #3
0
    def draw(self, canvas):
        xmin, ymin = canvas.pos_to_pixel(self.xmin, self.ymin)
        xmax, ymax = canvas.pos_to_pixel(self.xmax, self.ymax)

        if self.valid:
            canvas.dc.SetPen(wx.Pen(self.dark_color, 2, wx.SHORT_DASH))
        else:
            canvas.dc.SetPen(wx.Pen(wx.Colour(255, 0, 0), 2, wx.SHORT_DASH))

        canvas.dc.DrawLine(xmin + 1, ymax - 1, xmin + 1, ymin - 1)
        canvas.dc.DrawLine(xmax + 1, ymax - 1, xmax + 1, ymin - 1)
        canvas.dc.DrawLine(xmin + 1, ymin - 1, xmax + 1, ymin - 1)
        canvas.dc.DrawLine(xmin + 1, ymax - 1, xmax + 1, ymax - 1)

        MathShape.draw(self, canvas)
Example #4
0
    def draw(self, canvas):
        x0, y0 = canvas.pos_to_pixel(self.x, self.y)
        x1, y1 = canvas.pos_to_pixel(self.cornerA.x, self.cornerA.y)
        x2, y2 = canvas.pos_to_pixel(self.cornerB.x, self.cornerB.y)

        if self.valid:
            canvas.dc.SetPen(wx.Pen(self.dark_color, 2, wx.SHORT_DASH))
        else:
            canvas.dc.SetPen(wx.Pen(wx.Colour(255, 0, 0), 2, wx.SHORT_DASH))
        canvas.dc.SetBrush(wx.TRANSPARENT_BRUSH)

        canvas.dc.DrawLine(x0, y0, x1, y1)
        canvas.dc.DrawLine(x1, y1, x2, y2)
        canvas.dc.DrawLine(x2, y2, x0, y0)
        MathShape.draw(self, canvas)
Example #5
0
 def __init__(self, name=str, x=float, y=float, edge=Point):
     MathShape.__init__(self, name=name, x=x, y=y, edge=edge)
Example #6
0
 def __init__(self, name=str, x=float, y=float, bottom=Point, base=PerpendicularPoint, chamfer=PerpendicularPoint):
     MathShape.__init__(self, name=name, x=x, y=y, bottom=bottom, base=base, chamfer=chamfer)
Example #7
0
 def __init__(self, name=str, x=float, y=float, corner=Point):
     MathShape.__init__(self, name=name, x=x, y=y, corner=corner)