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)
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
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
def SetSelected(self, state: bool = True): """ Select the shape. @param state """ Shape.SetSelected(self, state) for ctrl in self._controls: ctrl.SetVisible(state)
def SetSelected(self, state: bool = True): """ Select the shape. @param state """ Shape.SetSelected(self, state) if self._resizable: self.ShowSizers(state)
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)
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)
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)
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)
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)
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
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)
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)