コード例 #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 __createAssocLabelElement(self, eltText: str, xmlDoc: Document,
                                  miniOglShape: Shape) -> Element:
        """
        Creates an element of the form:

        ```html
        `<eltText x="nnnn.n" y="nnnn.n"/>`
        ```

        e.g.

        ```html
            `<LabelCenter x="1811.0" y="1137.5"/>`
        ```

        Args:
            eltText:        The element name
            xmlDoc:         The minidom document
            miniOglShape:   The shape for which we are extracting a position

        Returns:
            A new minidom element
        """
        label: Element = xmlDoc.createElement(eltText)

        x, y = miniOglShape.GetModel().GetPosition()
        simpleX, simpleY = self.__getSimpleCoordinates(x, y)
        self.logger.info(
            f'x,y = ({x},{y})   simpleX,simpleY = ({simpleX},{simpleY})')
        label.setAttribute(PyutXmlConstants.ATTR_X, simpleX)
        label.setAttribute(PyutXmlConstants.ATTR_Y, simpleY)

        return label
コード例 #3
0
ファイル: OglToMiniDom.py プロジェクト: curiousTauseef/PyUt
    def __createAssocLabelElement(self, eltText: str, xmlDoc: Document,
                                  miniOglShape: Shape) -> Element:
        """
        Creates an element of the form:

        ```html
        `<eltText x="nnnn.n" y="nnnn.n"/>`
        ```

        e.g.

        ```html
            `<LabelCenter x="1811.0" y="1137.5"/>`
        ```

        Args:
            eltText:        The element name
            xmlDoc:         The minidom document
            miniOglShape:   The shape for which we are extracting a position

        Returns:
            A new minidom element
        """
        label: Element = xmlDoc.createElement(eltText)

        x, y = miniOglShape.GetModel().GetPosition()
        label.setAttribute(PyutXmlConstants.ATTR_X, str(x))
        label.setAttribute(PyutXmlConstants.ATTR_Y, str(y))

        return label
コード例 #4
0
    def SetSelected(self, state: bool = True):
        """
        Select the shape.

        @param  state
        """
        Shape.SetSelected(self, state)
        for ctrl in self._controls:
            ctrl.SetVisible(state)
コード例 #5
0
    def SetSelected(self, state: bool = True):
        """
        Select the shape.

        @param state
        """
        Shape.SetSelected(self, state)
        if self._resizable:
            self.ShowSizers(state)
コード例 #6
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)
コード例 #7
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)
コード例 #8
0
    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)
コード例 #9
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)
コード例 #10
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(width / ratio, height / ratio)
コード例 #11
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
コード例 #12
0
ファイル: PointShape.py プロジェクト: curiousTauseef/PyUt
    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)
コード例 #13
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)