Example #1
0
    def node_control_drop_handler(self, event):
        # Drag and Drop from the DataPool
        if(event.mimeData().hasFormat("openalealab/control")):
            # -- retreive the data from the event mimeData --
            pieceData = event.mimeData().data("openalealab/control")
            dataStream = qt.QtCore.QDataStream(pieceData, qt.QtCore.QIODevice.ReadOnly)
            identifier, data_key = str(pieceData).split(';')

            # -- find node factory --
            pkgmanager = PackageManager()
            pkg = pkgmanager["openalea.oalab"]
            factory = pkg.get_factory("control")

            # -- instantiate the new node at the given position --
            position = self.mapToScene(event.pos())
            node = self.__drop_from_factory(factory, [position.x(), position.y()])
            if node:
                node.set_input(0, data_key)
                node.set_caption(data_key)
            event.setDropAction(qt.QtCore.Qt.CopyAction)
            event.accept()
Example #2
0
    def node_datapool_drop_handler(self, event):
        # Drag and Drop from the DataPool
        if(event.mimeData().hasFormat("openalea/data_instance")):
            # -- retreive the data from the event mimeData --
            pieceData = event.mimeData().data("openalea/data_instance")
            dataStream = qt.QtCore.QDataStream(pieceData, qt.QtCore.QIODevice.ReadOnly)
            data_key = str()
            data_key = str(data_key + dataStream)

            # -- find node factory --
            pkgmanager = PackageManager()
            pkg = pkgmanager["system"]
            factory = pkg.get_factory("pool reader")

            # -- instantiate the new node at the given position --
            position = self.mapToScene(event.pos())
            node = self.__drop_from_factory(factory, [position.x(), position.y()])
            if node:
                node.set_input(0, data_key)
                node.set_caption("pool ['%s']" % (data_key,))
            event.setDropAction(qt.QtCore.Qt.MoveAction)
            event.accept()
Example #3
0
    def node_data_drop_handler(self, event):
        # Drag and Drop from the DataPool
        if(event.mimeData().hasFormat("openalealab/data")):
            # -- retreive the data from the event mimeData --
            from openalea.oalab.mimedata.builtin import decode_project_item
            data = decode_project_item(
                str(event.mimeData().data("openalealab/data")),
                "openalealab/data",
                "openalealab/data")

            # -- find node factory --
            pkgmanager = PackageManager()
            pkg = pkgmanager["openalea.oalab"]
            factory = pkg.get_factory("data")

            # -- instantiate the new node at the given position --
            position = self.mapToScene(event.pos())
            node = self.__drop_from_factory(factory, [position.x(), position.y()])
            if node:
                node.set_input(0, data.name)
                node.set_caption(unicode(data.name))
            event.setDropAction(qt.QtCore.Qt.CopyAction)
            event.accept()