示例#1
0
    def Draw(self, dc: DC, withChildren: bool = False):
        """
        Draw the actor.
        @param  dc : Device context
        @param withChildren Draw the children or not

        @since 1.0
        @author Philippe Waelti <*****@*****.**>
        """
        OglObject.Draw(self, dc)
        # Get current font
        dc.SetFont(self._defaultFont)

        # Gets the minimum bounding box for the shape
        width, height = self.GetSize()

        # Calculate the top center of the shape
        x, y = self.GetPosition()

        # drawing is restricted in the specified region of the device
        dc.SetClippingRegion(x, y, width, height)

        # Our sweet actor size
        actorWidth = width
        actorHeight = 0.8 * (height - 2.0 * MARGIN)  # 80 % of total height
        sizer = min(actorHeight, actorWidth)

        # Draw our actor head
        centerX = x + width // 2
        centerY = y + height // 2

        x = centerX - 0.2 * sizer
        y += MARGIN
        dc.DrawEllipse(x, y, 0.4 * sizer, 0.4 * sizer)

        # Draw body and arms
        x = centerX
        y += 0.4 * sizer
        dc.DrawLine(x, y, x, y + 0.3 * actorHeight)
        dc.DrawLine(x - 0.25 * actorWidth, y + 0.15 * actorHeight,
                    x + 0.25 * actorWidth, y + 0.15 * actorHeight)

        # And the feet
        y += 0.3 * actorHeight
        dc.DrawLine(x, y, x - 0.25 * actorWidth, y + 0.3 * actorHeight)
        dc.DrawLine(x, y, x + 0.25 * actorWidth, y + 0.3 * actorHeight)

        # Draw our buddy name
        textWidth, textHeight = dc.GetTextExtent(
            self.getPyutObject().getName())
        y = centerY + 0.5 * height - MARGIN - 0.1 * actorHeight
        dc.DrawText(self.getPyutObject().getName(), x - 0.5 * textWidth, y)
        dc.DestroyClippingRegion()
示例#2
0
    def Draw(self, dc: DC, withChildren: bool = False):
        """
        Paint handler, draws the content of the shape.

        Args:
            dc:     device context to draw to
            withChildren:   Redraw children or not
        """
        OglObject.Draw(self, dc)
        dc.SetFont(self._defaultFont)

        w, h = self.GetSize()

        try:
            # lines = LineSplitter().split(self.getPyutObject().getName(), dc, w - 2 * MARGIN)
            # noteName = self.getPyutObject().getName()
            noteContent = self.getPyutObject().content
            lines = LineSplitter().split(noteContent, dc, w - 2 * OglNote.MARGIN)
        except (ValueError, Exception) as e:
            self.logger.error(f"Unable to display note - {e}")
            return

        baseX, baseY = self.GetPosition()

        dc.SetClippingRegion(baseX, baseY, w, h)

        x = baseX + OglNote.MARGIN
        y = baseY + OglNote.MARGIN

        for line in range(len(lines)):
            dc.DrawText(lines[line], x, y + line * (dc.GetCharHeight() + 5))

        dc.DrawLine(baseX + w - OglNote.MARGIN, baseY, baseX + w, baseY + OglNote.MARGIN)

        dc.DestroyClippingRegion()
示例#3
0
    def _drawVerticalLines(self, memDC: DC, width: int, height: int,
                           startX: int, startY: int):

        y1: int = 0
        y2: int = startY + height
        stop: int = width + startX
        step: int = self._prefs.backgroundGridInterval

        for movingX in range(startX, stop, step):
            memDC.DrawLine(movingX, y1, movingX, y2)
示例#4
0
    def _drawHorizontalLines(self, memDC: DC, width: int, height: int,
                             startX: int, startY: int):

        x1: int = 0
        x2: int = startX + width
        stop: int = height + startY
        step: int = self._prefs.backgroundGridInterval
        for movingY in range(startY, stop, step):
            # self.clsLogger.info(f'{x1=} {movingY=} - {x2=} {movingY=}')
            memDC.DrawLine(x1, movingY, x2, movingY)
示例#5
0
    def Draw(self, dc: DC, withChildren: bool = True):

        dc.SetPen(BLACK_PEN)  # for some reason PEN is RED
        xDest, yDest = self._destinationAnchor.GetPosition()
        attachmentPoint: AttachmentPoint = self._destinationAnchor.attachmentPoint

        circleX, circleY, xSrc, ySrc = self._calculateWhereToDrawLollipop(
            attachmentPoint, xDest, yDest)

        self.logger.debug(f'Source: ({xSrc},{ySrc}) - Dest ({xDest},{yDest})')
        dc.DrawLine(xSrc, ySrc, xDest, yDest)
        dc.DrawCircle(circleX, circleY, LollipopLine.LOLLIPOP_CIRCLE_RADIUS)
示例#6
0
    def Draw(self, dc: DC, withChildren: bool = False):
        """
        Called for drawing the contents of links.

        Args:
            dc:     Device context
            withChildren:   `True` draw the children
        """
        self.updateMessage()

        srcAnchor, dstAnchor = self.getAnchors()

        srcX, srcY = srcAnchor.GetPosition()
        dstX, dstY = dstAnchor.GetPosition()
        self.clsLogger.debug(
            f'Draw line from: ({srcX},{srcY})  to: ({dstX},{dstY})')
        dc.SetPen(GREEN_PEN)
        dc.DrawLine(srcX, srcY, dstX, dstY)
        self.DrawArrow(dc, srcAnchor.GetPosition(), dstAnchor.GetPosition())
        self.DrawChildren(dc=dc)
示例#7
0
    def Draw(self, dc: DC, withChildren: bool = False):
        """
        Called for drawing the contents of links.

        Args:
            dc:     Device context
            withChildren:   `True` draw the children
        """
        self.updateMessage()

        srcAnchor, dstAnchor = self.getAnchors()

        srcX, srcY = srcAnchor.GetPosition()
        dstX, dstY = dstAnchor.GetPosition()

        if self._selected is True:
            dc.SetPen(RED_PEN)

        dc.DrawLine(srcX, srcY, dstX, dstY)
        self.DrawArrow(dc, srcAnchor.GetPosition(), dstAnchor.GetPosition())
        self.DrawChildren(dc=dc)

        dc.SetPen(BLACK_PEN)
示例#8
0
    def Draw(self, dc: DC, withChildren: bool = False):
        """
        Draw an actor

        Args:
            dc:     The device context to draw on
            withChildren:   Draw the children or not

        """
        OglObject.Draw(self, dc)
        # Get current font
        dc.SetFont(self._defaultFont)

        # Gets the minimum bounding box for the shape
        width, height = self.GetSize()

        # Calculate the top center of the shape
        x, y = self.GetPosition()

        # drawing is restricted in the specified region of the device
        dc.SetClippingRegion(x, y, width, height)

        # Our sweet actor size
        actorWidth = width
        actorHeight = int(0.8 *
                          (height - 2.0 * MARGIN))  # 80 % of total height
        sizer = min(actorHeight, actorWidth)

        # Draw our actor head
        centerX = x + width // 2
        centerY = y + height // 2

        x = int(centerX - 0.2 * sizer)
        y += MARGIN
        percentageSizer: int = int(0.4 * sizer)
        # dc.DrawEllipse(x, y, 0.4 * sizer, 0.4 * sizer)
        dc.DrawEllipse(x, y, percentageSizer, percentageSizer)

        # Draw body and arms
        x = centerX
        y += round(0.4 * sizer)
        # dc.DrawLine(x, y, x, y + 0.3 * actorHeight)
        # dc.DrawLine(x - 0.25 * actorWidth, y + 0.15 * actorHeight,
        #             x + 0.25 * actorWidth, y + 0.15 * actorHeight)
        dc.DrawLine(x, y, x, y + round(0.3 * actorHeight))
        dc.DrawLine(round(x - 0.25 * actorWidth),
                    round(y + 0.15 * actorHeight),
                    round(x + 0.25 * actorWidth),
                    round(y + 0.15 * actorHeight))

        # And the feet
        # y += round(0.3 * actorHeight)
        # dc.DrawLine(x, y, x - 0.25 * actorWidth, y + 0.3 * actorHeight)
        # dc.DrawLine(x, y, x + 0.25 * actorWidth, y + 0.3 * actorHeight)

        actorFeetPercentage: int = round(0.3 * actorHeight)
        y += round(actorFeetPercentage)
        # dc.DrawLine(x, y, x - 0.25 * actorWidth, y + actorFeetPercentage)
        # dc.DrawLine(x, y, x + 0.25 * actorWidth, y + actorFeetPercentage)
        dc.DrawLine(x, y, x - round(0.25 * actorWidth),
                    y + actorFeetPercentage)
        dc.DrawLine(x, y, x + round(0.25 * actorWidth),
                    y + actorFeetPercentage)

        # Draw our buddy name
        textWidth, textHeight = dc.GetTextExtent(self.pyutObject.getName())

        # y = centerY + 0.5 * height - MARGIN - 0.1 * actorHeight
        y = round(centerY + 0.5 * height - MARGIN - 0.1 * actorHeight)

        # dc.DrawText(self.getPyutObject().getName(), x - 0.5 * textWidth, y)
        dc.DrawText(self.pyutObject.getName(), round(x - 0.5 * textWidth), y)
        dc.DestroyClippingRegion()
示例#9
0
 def Draw(self, dc: wx.DC):
     dc.SetPen(self.Pen())
     dc.DrawLine(self.X1(), self.Y1(), self.X2(), self.Y2())