コード例 #1
0
    def Draw(self, dc: DC, withChildren: bool = True):
        """
        Draw the line on the dc.

        Args:
            dc:
            withChildren:
        """
        if self._visible:

            super().Draw(dc=dc, withChildren=withChildren)
            line = self.GetSegments()
            if self._selected:
                dc.SetPen(RED_PEN)
            if self._spline:
                dc.DrawSpline(line)
            else:
                dc.DrawLines(line)
            for control in self._controls:
                control.Draw(dc)
            if self._selected:
                self._srcAnchor.Draw(dc)
                self._dstAnchor.Draw(dc)
            dc.SetPen(BLACK_PEN)
            if self._drawArrow:
                u, v = line[-2], line[-1]
                self.DrawArrow(dc, u, v)
            if withChildren:
                self.DrawChildren(dc)
コード例 #2
0
    def Draw(self, dc: DC, withChildren: bool = True):
        """
        Draw the line on the dc.

        Args:
            dc:
            withChildren:
        """
        if self._visible:

            super().Draw(dc=dc, withChildren=withChildren)

            line = self.GetSegments()
            from org.pyut.ogl.sd.OglSDMessage import OglSDMessage
            if isinstance(self, OglSDMessage):
                LineShape.clsLogger.debug(f'{self} - {self._selected=}')

            if self._selected:
                dc.SetPen(RED_PEN)
            if self._spline:
                dc.DrawSpline(line)
            else:
                dc.DrawLines(line)
            for control in self._controls:
                control.Draw(dc)
            if self._selected:
                self._srcAnchor.Draw(dc)
                self._dstAnchor.Draw(dc)
            dc.SetPen(BLACK_PEN)
            if self._drawArrow:
                u, v = line[-2], line[-1]
                self.DrawArrow(dc, u, v)
            if withChildren:
                # LineShape.clsLogger.debug(f'Call DrawChildren()')
                self.DrawChildren(dc)
コード例 #3
0
 def Draw(self, dc: wx.DC):
     dc.SetPen(self.__Pen)
     x = min([self.__X1, self.__X2])
     y = min([self.__Y1, self.__Y2])
     w = max([self.__X1, self.__X2]) - x
     h = max([self.__Y1, self.__Y2]) - y
     dc.DrawRectangle(x, y, w, h)
コード例 #4
0
    def _drawGrid(self, memDC: DC, width: int, height: int, startX: int,
                  startY: int):

        # self.clsLogger.info(f'{width=} {height=} {startX=} {startY=}')
        savePen = memDC.GetPen()

        newPen: Pen = self._getGridPen()
        memDC.SetPen(newPen)

        self._drawHorizontalLines(memDC=memDC,
                                  width=width,
                                  height=height,
                                  startX=startX,
                                  startY=startY)
        self._drawVerticalLines(memDC=memDC,
                                width=width,
                                height=height,
                                startX=startX,
                                startY=startY)
        memDC.SetPen(savePen)
コード例 #5
0
ファイル: OglInterface.py プロジェクト: hasii2011/PyUt
    def Draw(self, dc: DC, withChildren: bool = False):
        """
        Called for drawing of interface links.
        OglLink drew regular lines
        I need dashed lines for an interface

        Args:
            dc: Device context
            withChildren:   Draw the children or not

        """
        self.updateLabels()
        if self._visible:
            line = self.GetSegments()
            if self._selected:
                dc.SetPen(RED_PEN)

            if self._spline:
                dc.DrawSpline(line)
            else:
                pen: Pen = dc.GetPen()  #
                pen.SetStyle(
                    PENSTYLE_SHORT_DASH
                )  # This is what is different from OglLink.Draw(..)
                dc.SetPen(pen)  #
                dc.DrawLines(line)

            for control in self._controls:
                control.Draw(dc)

            if self._selected:
                self._srcAnchor.Draw(dc)
                self._dstAnchor.Draw(dc)
            dc.SetPen(BLACK_PEN)

            if self._drawArrow:
                u, v = line[-2], line[-1]
                self.DrawArrow(dc, u, v)

            if withChildren is True:
                self.DrawChildren(dc)
コード例 #6
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)
コード例 #7
0
ファイル: OglSDMessage.py プロジェクト: hasii2011/PyUt
    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
ファイル: Shape.py プロジェクト: curiousTauseef/PyUt
    def Draw(self, dc: DC, withChildren: bool = True):
        """
        Draw the shape.
        For a shape, only the anchors are drawn. Nothing is drawn if the
        shape is set invisible.
        For children classes, the main classes would normally call it's
        parent's Draw method, passing withChildren = False, and finally
        calling itself the DrawChildren method.

        Args:
            dc:             wxPython device context
            withChildren:   draw the children or not
        """

        if self._visible:
            dc.SetPen(self._pen)
            dc.SetBrush(self._brush)
            if withChildren:
                self.DrawChildren(dc)

        if self._selected:
            dc.SetPen(RED_PEN)
            self.DrawHandles(dc)
コード例 #9
0
    def drawLosange(self, dc: DC, filled: bool = False):
        """
        Draw an arrow at the beginning of the line.

        Args:
            dc:         The device context
            filled:     True if the losange must be filled, False otherwise

        Note:  Losange is French for 'diamond'
        """
        pi_6 = pi / 6
        points = []
        line = self.GetSegments()
        x1, y1 = line[1]
        x2, y2 = line[0]
        a = x2 - x1
        b = y2 - y1
        if abs(a) < 0.01:  # vertical segment
            if b > 0:
                alpha = -pi / 2
            else:
                alpha = pi / 2
        else:
            if a == 0:
                if b > 0:
                    alpha = pi / 2
                else:
                    alpha = 3 * pi / 2
            else:
                alpha = atan(b / a)
        if a > 0:
            alpha += pi
        alpha1 = alpha + pi_6
        alpha2 = alpha - pi_6
        size = 8
        points.append((x2 + size * cos(alpha1), y2 + size * sin(alpha1)))
        points.append((x2, y2))
        points.append((x2 + size * cos(alpha2), y2 + size * sin(alpha2)))
        points.append((x2 + 2 * size * cos(alpha), y2 + 2 * size * sin(alpha)))
        dc.SetPen(BLACK_PEN)
        if filled:
            dc.SetBrush(BLACK_BRUSH)
        else:
            dc.SetBrush(WHITE_BRUSH)
        dc.DrawPolygon(points)
        dc.SetBrush(WHITE_BRUSH)
コード例 #10
0
ファイル: OglSDMessage.py プロジェクト: curiousTauseef/PyUt
    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)
コード例 #11
0
ファイル: PointShape.py プロジェクト: hasii2011/PyUt
    def __resetPenColor(self, dc: DC):

        pen: Pen = dc.GetPen()
        pen.SetColour(self.__penSaveColor)
        dc.SetPen(pen)
コード例 #12
0
    def Draw(self, dc: wx.DC):
        (x, y, w, h) = self.EnclosingRectangle()

        dc.SetPen(self.Pen())
        dc.DrawRectangle(x, y, w, h)
コード例 #13
0
 def Draw(self, dc: wx.DC):
     dc.SetPen(self.Pen())
     dc.DrawLine(self.X1(), self.Y1(), self.X2(), self.Y2())