Пример #1
0
    def process_draw(self, gc: wx.GraphicsContext):
        gc.SetBrush(self.background_brush)
        gc.DrawRectangle(self.left, self.top, self.right, self.bottom)

        gc.SetBrush(self.lacking_brush)
        gc.SetPen(self.lacking_pen)
        gc.DrawLines([(self.start_x, self.start_y), (self.end_x, self.end_y)])
        for idx, value in enumerate(self.values):
            amount = self.value_to_position(value)

            tx = amount * (self.end_x - self.start_x) + self.start_x
            ty = amount * (self.end_y - self.start_y) + self.start_y
            gc.SetBrush(self.selected_brush)
            gc.SetPen(self.selected_pen)
            gc.DrawLines([(self.start_x, self.start_y), (tx, ty)])
            gc.DrawEllipse(tx - BLIP_RADIUS / 2, ty - BLIP_RADIUS / 2,
                           BLIP_RADIUS, BLIP_RADIUS)
            if self.moving and self.seeker == idx:
                gc.SetBrush(self.moving_brush)
                gc.DrawEllipse(
                    tx - MOVE_RADIUS / 2,
                    ty - MOVE_RADIUS / 2,
                    MOVE_RADIUS,
                    MOVE_RADIUS,
                )
        if self.seeker != -1:
            try:
                gc.DrawText(
                    f"{self.values[self.seeker]:.2f}",
                    self.start_x,
                    self.start_y,
                )
            except IndexError:
                pass
Пример #2
0
 def paint_arrow_tip(self, gc: wx.GraphicsContext, fill: wx.Colour):
     assert len(self.arrow_adjusted_coords) == 4, \
         "Arrow adjusted coords is not of length 4: {}".format(self.arrow_adjusted_coords)
     gc.SetPen(gc.CreatePen(wx.GraphicsPenInfo(fill)))
     gc.SetBrush(wx.Brush(fill))
     gc.DrawLines([wx.Point2D(*(coord))
                   for coord in self.arrow_adjusted_coords])
Пример #3
0
    def process_draw(self, gc: wx.GraphicsContext):
        # Draw Box
        gc.SetBrush(wx.TRANSPARENT_BRUSH)
        gc.SetPen(self.checkline_pen)
        gc.DrawRectangle(self.left, self.top, self.right - self.left,
                         self.bottom - self.top)
        if self.value:
            # Draw Check
            gc.SetPen(self.checkline_pen)
            check = [(0.2, 0.5), (0.4, 0.75), (0.8, 0.2)]
            for i in range(len(check)):
                x, y = check[i]
                check[i] = towards(self.left, self.right,
                                   x), towards(self.top, self.bottom, y)
            gc.DrawLines(check)

        if self.text:
            height = self.bottom - self.top
            width = self.right - self.left
            text_size = height * 3.0 / 4.0  # px to pt conversion
            try:
                self.font.SetFractionalPointSize(text_size)
            except AttributeError:
                self.font.SetPointSize(int(text_size))
            gc.SetFont(self.font, self.font_color)
            gc.DrawText(self.text, self.right + width * self._text_gap,
                        self.top)
Пример #4
0
 def process_draw(self, gc: wx.GraphicsContext):
     if self.point_series:
         if self.scene.context.elements.default_stroke is None:
             self.pen.SetColour(wx.BLUE)
         else:
             self.pen.SetColour(
                 wx.Colour(
                     swizzlecolor(
                         self.scene.context.elements.default_stroke)))
         gc.SetPen(self.pen)
         if self.scene.context.elements.default_fill is None:
             gc.SetBrush(wx.TRANSPARENT_BRUSH)
         else:
             gc.SetBrush(
                 wx.Brush(
                     wx.Colour(
                         swizzlecolor(
                             self.scene.context.elements.default_fill)),
                     wx.BRUSHSTYLE_SOLID,
                 ))
         points = list(self.point_series)
         if self.mouse_position is not None:
             points.append(self.mouse_position)
         points.append(points[0])
         gc.DrawLines(points)
Пример #5
0
    def draw_points(self, gc: wx.GraphicsContext, points: List[Vec2],
                    radius: float):
        """
        Drawing points for arrow.

        Args: 
            self: the Designer Window to initialize.
            gc (wx.GraphixContext): Graphics context to modify.
            points (List[Vect2]): Points to be drawn in form of a list.
            radius (float): radius for the points.

        """
        gc.SetPen(wx.Pen(wx.BLACK, 2))
        gc.SetBrush(wx.Brush(wx.BLACK, wx.BRUSHSTYLE_FDIAGONAL_HATCH))
        plotted = [p * self.csize for p in points]  # points to be plotted
        if self.dragging:
            assert self.hover_idx != -1 and self.dragged_point is not None
            plotted[self.hover_idx] = self.dragged_point

        gc.DrawLines([wx.Point2D(*p)
                      for p in plotted] + [wx.Point2D(*plotted[0])])
        for i, p in enumerate(plotted):
            if self.dragging and i == self.hover_idx:
                continue
            if i == 3:
                # the last point is the tip, so draw it in a different color
                gc.SetPen(wx.BLACK_PEN)
                gc.SetBrush(wx.BLACK_BRUSH)
            else:
                gc.SetPen(self.handle_pen)
                gc.SetBrush(self.handle_brush)
            self.draw_point(gc, p, radius)

        # Draw the hover point
        if self.hover_idx != -1:
            point = self.dragged_point if self.dragging else plotted[
                self.hover_idx]
            assert self.hover_idx >= 0 and self.hover_idx < 4
            assert point is not None
            gc.SetPen(self.hl_handle_pen)
            gc.SetBrush(self.hl_handle_brush)
            self.draw_point(gc, point, radius)

            if self.dragging:
                assert self.dragged_point is not None
                drop_point = self.projected_landing(self.dragged_point)
                gc.SetPen(self.phantom_pen)
                gc.SetBrush(self.phantom_brush)
                self.draw_point(gc, drop_point, radius)