def draw(self, canvas): ''' Draws a free point on the canvas. The point is drawn with small handles showing the axes along which it can be dragged. ''' x, y = canvas.pos_to_pixel(self.x, self.y) dark_grey = (60, 60, 60) light_grey = (100, 100, 100) # If the vertex is being dragged, draw small # arrows to show in which ways it is free if self.valid and (self.dragging or self.hover): canvas.SetPen(self.light_color if self._x_free else light_grey, 8) canvas.dc.DrawLine(x-10, y, x+10, y) canvas.SetPen(self.light_color if self._y_free else light_grey, 8) canvas.dc.DrawLine(x, y-10, x, y+10) canvas.SetPen(self.dark_color if self._x_free else dark_grey, 4) canvas.dc.DrawLine(x-10, y, x+10, y) canvas.SetPen(self.dark_color if self._y_free else dark_grey, 4) canvas.dc.DrawLine(x, y-10, x, y+10) Point.draw(self, canvas)
def draw(self, canvas): x, y = canvas.pos_to_pixel(self.x, self.y) dark_grey = (60, 60, 60) light_grey = (100, 100, 100) if self.valid: canvas.SetPen(self.dark_color, 4, wx.LONG_DASH) canvas.SetBrush(self.dark_color) self.arrow_from(self.parent) if self.valid and (self.dragging or self.hover): x0 = x - math.cos(self.angle)*10 x1 = x + math.cos(self.angle)*10 y0 = y + math.sin(self.angle)*10 y1 = y - math.sin(self.angle)*10 if self._offset_free: canvas.SetPen(self.light_color, 8) canvas.dc.DrawLine(x0, y0, x1, y1) canvas.SetPen(self.dark_color, 4) canvas.dc.DrawLine(x0, y0, x1, y1) else: canvas.SetPen(light_grey, 8) canvas.dc.DrawLine(x0, y0, x1, y1) canvas.SetPen(dark_grey, 4) canvas.dc.DrawLine(x0, y0, x1, y1) Point.draw(self, canvas)
def __init__(self, name, x, y, angle=0, value=''): Point.__init__(self, name) self.create_evaluators(x=(x, float), y=(y, float), angle=(angle, float)) self.parameters['value'] = StrEvaluator(self, value) self.pads = {} self._i = 1 self.priority = 1 self.light_color = (0, 255, 0) self.dark_color = (0, 150, 0)
def __init__(self, name='perp', parent='parent', perp='perp', offset=0.0): Point.__init__(self, name) self.create_evaluators(parent=(parent, Point), perp=(perp, Point), offset=(offset, float))
def __init__(self, name='free_point', x=0, y=0): Point.__init__(self, name) self.create_evaluators(x=(x, float), y=(y, float))
def __init__(self, name='linked_point', parent='', dx=0, dy=0): Point.__init__(self, name) self.create_evaluators(dx=(dx, float), dy=(dy, float), parent=(parent, Point))