예제 #1
0
    def _stepNodes(self, srcShape: Shape, oglCoordinate: OglCoordinate):

        oldX, oldY = srcShape.GetPosition()
        newX: int = oglCoordinate.x
        newY: int = oglCoordinate.y

        self.logger.info(
            f'{srcShape} - oldX,oldY: ({oldX},{oldY}) newX,newY: ({newX},{newY})'
        )
        #
        srcShape.SetPosition(newX, newY)
예제 #2
0
    def SetSelected(self, state: bool = True):
        """
        Select the shape.

        @param state
        """
        Shape.SetSelected(self, state)
        if self._resizable:
            self.ShowSizers(state)
예제 #3
0
 def DrawBorder(self, dc):
     """
     Draw the border of the shape, for fast rendering.
     """
     Shape.DrawBorder(self, dc)
     sx, sy = self.GetPosition()
     sx, sy = sx - self._ox, sy - self._oy
     width, height = self.GetSize()
     dc.DrawRectangle(sx, sy, width, height)
예제 #4
0
 def Detach(self):
     """
     Detach the shape from its diagram.
     This is the way to delete a shape. All anchor points are also
     removed, and link lines too.
     """
     # do not detach a protected shape
     if self._diagram is not None and not self._protected:
         Shape.Detach(self)
         self.ShowSizers(False)
예제 #5
0
    def SetSelected(self, state: bool = True):
        """
        Select the shape (default) or not

        Args:
            state:
        """
        Shape.SetSelected(self, state)
        for ctrl in self._controls:
            ctrl.SetVisible(state)
예제 #6
0
    def __init__(self, srcAnchor: AnchorPoint, dstAnchor: AnchorPoint):
        """

        Args:
            srcAnchor: the source anchor of the line.
            dstAnchor: the destination anchor of the line.
        """
        Shape.__init__(self)
        self._srcAnchor: AnchorPoint = srcAnchor
        self._dstAnchor: AnchorPoint = dstAnchor

        self._controls:  ControlPoints = ControlPoints([])
        self._drawArrow: bool = True
        self._arrowSize: int = 8
        self._spline:    bool = False
        if srcAnchor:
            srcAnchor.AddLine(self)
        if dstAnchor:
            dstAnchor.AddLine(self)
예제 #7
0
파일: TextShape.py 프로젝트: hasii2011/PyUt
    def DrawBorder(self, dc: DC):
        """
        Draw the border of the shape, for fast rendering.

        Args:
            dc
        """
        if self._selected:
            RectangleShape.DrawBorder(self, dc)
        else:
            Shape.DrawBorder(self, dc)
예제 #8
0
파일: Diagram.py 프로젝트: hasii2011/PyUt
    def MoveToFront(self, shape: Shape):
        """
        Move the given shape to the end of the display list => last drawn.

        Args:
            shape: The shape to move
        """
        shapes = [shape] + shape.GetAllChildren()
        for s in shapes:
            self._shapes.remove(s)
        self._shapes = self._shapes + shapes
예제 #9
0
파일: Diagram.py 프로젝트: hasii2011/PyUt
    def MoveToBack(self, shape: Shape):
        """
        Move the given shape to the start of the display list => first drawn.

        Args:
            shape: The shape to move
        """
        shapes = [shape] + shape.GetAllChildren()
        for s in shapes:
            self._shapes.remove(s)
        self._shapes = shapes + self._shapes
예제 #10
0
 def Detach(self):
     """
     Detach the line and all its line points, including src and dst.
     """
     if self._diagram is not None and not self._protected:
         Shape.Detach(self)
         # while loop, because Detach will remove controls from the list on
         # which we iterate
         while self._controls:
             self._controls[0].Detach()
         self._srcAnchor.RemoveLine(self)
         self._dstAnchor.RemoveLine(self)
예제 #11
0
    def UpdateModel(self):
        """
        Added by P. Dabrowski <*****@*****.**> (12.11.2005)

        Updates the model when the shape (view) is moved or resized.
        """
        #  change the coordinates of model
        Shape.UpdateModel(self)

        #  get the size of the shape (view)
        width, height = self.GetSize()

        # get the ratio between the model and the shape (view) from
        # the diagram frame where the shape is displayed.
        ratio = self.GetDiagram().GetPanel().GetCurrentZoom()

        # set the new size to the model.
        self.GetModel().SetSize(round(width//ratio), round(height//ratio))
예제 #12
0
    def UpdateFromModel(self):
        """
        Added by P. Dabrowski <*****@*****.**> (12.11.2005)

        Updates the shape position and size from the model in the light of a
        change of state of the diagram frame (here it's only for the zoom)
        """

        #  change the position of the shape from the model
        Shape.UpdateFromModel(self)

        #  get the model size
        width, height = self.GetModel().GetSize()

        #  get the diagram frame ratio between the shape and the model
        ratio = self.GetDiagram().GetPanel().GetCurrentZoom()

        # set the new size to the shape.
        self._width, self._height = width * ratio, height * ratio
예제 #13
0
    def Draw(self, dc: DC, withChildren=True):
        """
        Draw the point on the dc.

        Args:
            dc:
            withChildren:
        """
        if self._visible or (self._visibleWhenSelected and self._selected):

            self.__penSaveColor = dc.GetPen().GetColour()
            Shape.Draw(self, dc, False)

            self.__resetPenColor(dc)

            x, y = self.GetPosition()
            if not self._selected:
                dc.DrawRectangle(x - 1, y - 1, 3, 3)
            else:
                dc.DrawRectangle(x - 3, y - 3, 7, 7)
            if withChildren:
                self.DrawChildren(dc)
예제 #14
0
    def Draw(self, dc: DC, withChildren: bool = False):
        """
        Draw the rectangle on the dc.

        Args:
            dc:
            withChildren:

        Returns:

        """
        if self._visible:
            Shape.Draw(self, dc, False)
            if self._drawFrame:
                sx, sy = self.GetPosition()
                sx, sy = sx - self._ox, sy - self._oy
                width, height = self.GetSize()

                dc.DrawRectangle(sx, sy, width, height)
            if withChildren:
                self.DrawChildren(dc)
            if self._topLeftSizer is not None:
                self._topLeftSizer.Draw(dc, False)