Пример #1
0
    def getOglUseCases(self, xmlOglUseCases: NodeList) -> OglUseCases:
        """
        Parse the XML elements given and build data layer for PyUt actors.

        Args:
            xmlOglUseCases:     XML 'GraphicUseCase' elements

        Returns:
            A dictionary of OglUseCase objects
        """
        oglUseCases: OglUseCases = cast(OglUseCases, {})

        for xmlOglUseCase in xmlOglUseCases:

            pyutUseCase: PyutUseCase = PyutUseCase()

            # Building OGL UseCase
            height: int = PyutUtils.strFloatToInt(xmlOglUseCase.getAttribute(PyutXmlConstants.ATTR_HEIGHT))
            width:  int = PyutUtils.strFloatToInt(xmlOglUseCase.getAttribute(PyutXmlConstants.ATTR_WIDTH))
            oglUseCase = OglUseCase(pyutUseCase, width, height)

            xmlUseCase: Element = xmlOglUseCase.getElementsByTagName(PyutXmlConstants.ELEMENT_MODEL_USE_CASE)[0]

            pyutUseCase.setId(int(xmlUseCase.getAttribute(PyutXmlConstants.ATTR_ID)))
            pyutUseCase.setName(xmlUseCase.getAttribute(PyutXmlConstants.ATTR_NAME))
            pyutUseCase.setFilename(xmlUseCase.getAttribute(PyutXmlConstants.ATTR_FILENAME))

            x: int = PyutUtils.strFloatToInt(xmlOglUseCase.getAttribute(PyutXmlConstants.ATTR_X))
            y: int = PyutUtils.strFloatToInt(xmlOglUseCase.getAttribute(PyutXmlConstants.ATTR_Y))
            oglUseCase.SetPosition(x, y)

            oglUseCases[pyutUseCase.getId()] = oglUseCase

        return oglUseCases
Пример #2
0
    def _getOglUseCases(self, xmlOglUseCases, dicoOglObjects, dicoLink,
                        dicoFather, umlFrame):
        """
        Parse the XML elements given and build data layer for PyUT actors.

        @param Element[] xmlOglUseCases : XML 'GraphicUseCase' elements
        @param {id / srcName, OglObject} dicoOglObjects : OGL objects loaded
        @param {id / srcName, OglLink} dicoLink : OGL links loaded
        @param {id / srcName, id / srcName} dicoFather: Inheritance
        @param UmlFrame umlFrame : Where to draw
        @since 2.0
        @author Philippe Waelti <*****@*****.**>
        """
        oldData = 0

        for xmlOglUseCase in xmlOglUseCases:
            pyutUseCase = PyutUseCase()

            # Building OGL UseCase
            height = int(xmlOglUseCase.getAttribute('height'))
            width = int(xmlOglUseCase.getAttribute('width'))
            oglUseCase = OglUseCase(pyutUseCase, width, height)

            xmlUseCase = xmlOglUseCase.getElementsByTagName('UseCase')[0]

            # Backward compatibility (pyut v1.0). If id not present,
            # auto set by the instantiation of object
            if xmlUseCase.hasAttribute('id'):
                pyutUseCase.setId(int(xmlUseCase.getAttribute('id')))
            else:
                oldData = 1

            # adding name for this class
            s = xmlUseCase.getAttribute('name').encode("charmap")
            pyutUseCase.setName(s)

            # adding fathers
            self._getFathers(xmlUseCase.getElementsByTagName("Father"),
                             dicoFather, pyutUseCase.getId())

            # Update dicos
            dicoLink[pyutUseCase.getId()] = self._getLinks(xmlUseCase)
            dicoOglObjects[pyutUseCase.getId()] = oglUseCase

            # Update UML Frame
            x = int(xmlOglUseCase.getAttribute('x'))
            y = int(xmlOglUseCase.getAttribute('y'))
            umlFrame.addShape(oglUseCase, x, y)

        return oldData
Пример #3
0
    def _pyutUseCaseToXml(self, pyutUseCase: PyutUseCase,
                          xmlDoc: Document) -> Element:
        """
        Export a PyutUseCase to a minidom Element.

        Args:
            pyutUseCase:    Use case to convert
            xmlDoc:         xml document

        Returns:
            A new minidom element
        """
        root = xmlDoc.createElement(PyutXmlConstants.ELEMENT_MODEL_USE_CASE)

        useCaseId = self._idFactory.getID(pyutUseCase)
        root.setAttribute(PyutXmlConstants.ATTR_ID, str(useCaseId))
        root.setAttribute(PyutXmlConstants.ATTR_NAME, pyutUseCase.getName())
        root.setAttribute(PyutXmlConstants.ATTR_FILENAME,
                          pyutUseCase.getFilename())

        return root
Пример #4
0
    def createNewUseCase(self, x, y):
        """
        Add a new use case at (x, y).

        @return PyutUseCase : the newly created PyutUseCase
        """
        pyutUseCase: PyutUseCase = PyutUseCase()
        oglUseCase: OglUseCase = OglUseCase(pyutUseCase)

        self.addShape(oglUseCase, x, y)
        self.Refresh()
        return pyutUseCase
Пример #5
0
    def _getOglUseCases(self, xmlOglUseCases, dicoOglObjects, dicoLink,
                        dicoFather, umlFrame):
        """
        Parse the XML elements given and build data layer for PyUT actors.

        @param Element[] xmlOglUseCases : XML 'GraphicUseCase' elements
        @param {id / srcName, OglObject} dicoOglObjects : OGL objects loaded
        @param {id / srcName, OglLink} dicoLink : OGL links loaded
        @param {id / srcName, id / srcName} dicoFather: Inheritance
        @param UmlFrame umlFrame : Where to draw
        """
        for xmlOglUseCase in xmlOglUseCases:
            pyutUseCase = PyutUseCase()

            # Building OGL UseCase
            height = float(xmlOglUseCase.getAttribute('height'))
            width = float(xmlOglUseCase.getAttribute('width'))
            oglUseCase = OglUseCase(pyutUseCase, width, height)

            xmlUseCase = xmlOglUseCase.getElementsByTagName('UseCase')[0]

            pyutUseCase.setId(int(xmlUseCase.getAttribute('id')))

            # adding name for this class
            # pyutUseCase.setName(xmlUseCase.getAttribute('name').encode("charmap"))
            # Python 3 is already utf-8;  don't need to encode anything
            pyutUseCase.setName(xmlUseCase.getAttribute('name'))

            # adding associated filename ([email protected])
            pyutUseCase.setFilename(xmlUseCase.getAttribute('filename'))

            # Update dicos
            dicoOglObjects[pyutUseCase.getId()] = oglUseCase

            # Update UML Frame
            x = float(xmlOglUseCase.getAttribute('x'))
            y = float(xmlOglUseCase.getAttribute('y'))
            umlFrame.addShape(oglUseCase, x, y)
Пример #6
0
    def __init__(self, pyutUseCase=None, w: int = 100, h: int = 60):
        """

        Args:
            pyutUseCase:
            w: Width of the shape
            h: Height of the shape
        """
        # Init associated PyutObject
        if pyutUseCase is None:
            pyutObject = PyutUseCase()
        else:
            pyutObject = pyutUseCase

        super().__init__(pyutObject, w, h)

        # Should not draw border
        self._drawFrame = False
Пример #7
0
    def __init__(self, pyutUseCase=None, w: float = 100.0, h: float = 60.0):
        """
        Constructor.
        @param  w : Width of the shape
        @param  h : Height of the shape

        @since 1.0
        @author Philippe Waelti <*****@*****.**>
        """
        # Init associated PyutObject
        if pyutUseCase is None:
            pyutObject = PyutUseCase()
        else:
            pyutObject = pyutUseCase

        super().__init__(pyutObject, w, h)

        # Should not draw border
        self._drawFrame = False