def draw_point(self, gc: wx.GraphicsContext, point: Vec2, radius: float): """ Drawing a single point. Args: gc: Graphics context to modify. point: Point to be drawn. radius: Radius of the point. """ center = point - Vec2.repeat(radius / 2) gc.DrawEllipse(center.x, center.y, radius, radius)
def __init__(self, parent, arrow_tip: ArrowTip): """ Initialize the arrow designer window with the given starting arrow tip. Args: parent: The parent window. arrow_tip: ArrowTip object defining the arrow tip used. """ dim = Vec2(22, 16) self.csize = 20 size = dim * self.csize + Vec2.repeat(1) super().__init__(parent, size=size.as_tuple()) # add 1 to range end, so that the grid rectangle side will be included. rows = [r for r in range(0, int(size.y), self.csize)] cols = [c for c in range(0, int(size.x), self.csize)] self.begin_points = list() self.end_points = list() for r in rows: self.begin_points.append(wx.Point2D(0, r)) self.end_points.append(wx.Point2D(size.x - 1, r)) for c in cols: self.begin_points.append(wx.Point2D(c, 0)) self.end_points.append(wx.Point2D(c, size.y - 1)) self.handle_c = api.get_theme('handle_color') self.hl_handle_c = api.get_theme('highlighted_handle_color') self.handle_pen = wx.Pen(self.handle_c) self.hl_handle_pen = wx.Pen(self.hl_handle_c) self.handle_brush = wx.Brush(self.handle_c) self.hl_handle_brush = wx.Brush(self.hl_handle_c) phantom_c = opacity_mul(self.handle_c, 0.5) self.phantom_pen = wx.Pen(phantom_c) self.phantom_brush = wx.Brush(phantom_c) self.arrow_tip = arrow_tip self.radius = 12 self.radius_sq = self.radius**2 self.hover_idx = -1 self.dragged_point = None self.dragging = False self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_MOTION, self.OnMotion) self.SetDoubleBuffered(True)