def __messageFilter(self, message): if message.matches(EController.kMessageNodeAdded): handle, name = message.getData() if not name: name = None if handle.IsContainer: newNode = EPoint(handle) else: newNode = ENode(handle) newNode.setPos(self.__kDummy.scenePos()) self.addItem(newNode, name) self.__kSelected.Item = newNode if message.matches(EController.kMessageNodeRemoved): self.removeItem(self.__nodes[message.getData()]) self.__nodes.pop(message.getData(), None) return if message.matches(EController.kMessageConnectionMade): if not len(message.getData()): return dataOne = self.__getDataFromId(message.getData()[0]) dataTwo = self.__getDataFromId(message.getData()[1]) if dataOne and dataTwo: if any([isinstance(dataOne[ENode.kGuiAttributeParent], EPoint), isinstance(dataTwo[ENode.kGuiAttributeParent], EPoint)]): conn = EEdge(dataOne, dataTwo, message.getData()[2], True) dataOne[ENode.kGuiAttributeParent].togglePlug(message.getData()[0]) dataTwo[ENode.kGuiAttributeParent].togglePlug(message.getData()[1]) else: conn = EEdge(dataOne, dataTwo, message.getData()[2]) self.__connections[conn.Id] = conn self.addItem(conn) return if message.matches(EGraphHandle.kMessageConnectionBroke): if message.getData() in self.__connections.keys(): connHead = self.__connections[message.getData()].Head#[ENode.kGuiAttributeId] connTail = self.__connections[message.getData()].Tail#[ENode.kGuiAttributeId] self.removeItem(self.__connections[message.getData()]) self.__connections.pop(message.getData(), None) self.update() return
def __messageFilter(self, message): if message.matches(EController.kMessageNodeAdded): handle, name = message.getData() if handle.IsContainer: newNode = EPoint(handle) else: newNode = ENode(handle) newNode.setPos(self.__kDummy.scenePos()) newNode.Name = self.__updateNamespace(name) self.addItem(newNode) self.__kSelected.Item = newNode if message.matches(EController.kMessageNodeRemoved): self.__kSelected.Item = None self.onSelectionChanged.emit(type("EData", (EObject,), {'nodeName': '', 'nodeProperties': []})) node = self.__nodes[message.getData()] self.removeItem(node) self.__nodes.pop(message.getData(), None) return if message.matches(EController.kMessageConnectionMade): if not len(message.getData()): return dataOne = self.__getDataFromId(message.getData()[0]) dataTwo = self.__getDataFromId(message.getData()[1]) if dataOne and dataTwo: if any([isinstance(dataOne[ENode.kGuiAttributeParent], EPoint), isinstance(dataTwo[ENode.kGuiAttributeParent], EPoint)]): conn = EEdge(dataOne, dataTwo, message.getData()[2], True) conn.Tail[ENode.kGuiAttributeParent].togglePlug(conn.Tail[ENode.kGuiAttributeId]) else: conn = EEdge(dataOne, dataTwo, message.getData()[2]) self.__connections[conn.Id] = conn self.addItem(conn) return if message.matches(EController.kMessageConnectionBroke): if message.getData() in self.__connections.keys(): connTail = self.__connections[message.getData()].Tail if isinstance(connTail[ENode.kGuiAttributeParent], EPoint): connTail[ENode.kGuiAttributeParent].togglePlug(connTail[ENode.kGuiAttributeId]) self.removeItem(self.__connections[message.getData()]) self.__connections.pop(message.getData(), None) self.update() return