Example #1
0
    def expandMacro(self):

        # before expansion save the face position for load/paste purposes
        self._face_colpos = self._face.getPos()

        self._src.setPos(self._face.pos())
        self._sink.setPos(self._src.pos())

        self._face.hide()
        self._macroedge.show()
        self._sink.show()
        self._src.show()
        self.resetPortParents()

        for port in self._src.getPorts():
            port.updateEdges()

        for port in self._sink.getPorts():
            port.updateEdges()

        for node in self._encap_nodes:
            node.setPos(self._src.pos())
            node.show()
            for edge in node.edges():
                edge.show()

        # initialize animation (open jaw)
        self._anim = QtCore.QParallelAnimationGroup()
        self._anim.finished.connect(self.jawOpen)
        anim = QtCore.QPropertyAnimation(self._sink, b"pos")
        anim.setDuration(300)
        anim.setEndValue(self._sink_pos + self._src.pos())
        self._anim.addAnimation(anim)

        for node, pos in zip(self._encap_nodes, self._encap_nodepos):
            anim = QtCore.QPropertyAnimation(node, b"pos")
            anim.setDuration(300)
            anim.setEndValue(pos + self._src.pos())
            self._anim.addAnimation(anim)

        self._anim.start()
Example #2
0
    def collapseMacro(self):

        if self.validateSrcNodes():
            return False

        if self.validateSinkNodes():
            return False

        self.listEncapsulatedNodes()

        if manager.isDebug():
            log.debug("nodes:")
            for node in self._encap_nodes:
                log.debug(node.name)

        self.saveNodePos()

        self._face.setPos(self._src.pos())

        # initialize animation stuff (close jaw)
        self._anim = QtCore.QParallelAnimationGroup()
        self._anim.finished.connect(self.jawClosed)
        anim = QtCore.QPropertyAnimation(self._sink, b"pos")
        anim.setDuration(300)
        anim.setEndValue(self._src.pos())
        self._anim.addAnimation(anim)

        for node in self._encap_nodes:
            anim = QtCore.QPropertyAnimation(node, b"pos")
            anim.setDuration(300)
            anim.setEndValue(self._src.pos())
            self._anim.addAnimation(anim)

        self._anim.start()

        return True