def onCreateNode(self, idNode, dicDotAttrs): '''Callback function when creating a node. Argument(s): idNode (str): ID of the node dicDotAttrs (Dictionary[]): Dot attributes of the node ''' self.checkAndCleanAttrs(dicDotAttrs) if NodeDotAttrs.pos.value in dicDotAttrs: if dicDotAttrs[NodeDotAttrs.pos.value]: # Get position coords = NodeDotPosUtils.getPos( dicDotAttrs[NodeDotAttrs.pos.value]) self.model.addNode(idNode, dicDotAttrs, coords[NodeArgs.x], coords[NodeArgs.y]) else: self.model.addNode(idNode, dicDotAttrs)
def onCreateNode(self, idNode, dicDotAttrs): '''Callback function when creating a node. Argument(s): idNode (str): ID of the node dicDotAttrs (Dictionary[]): Dot attributes of the node ''' self.checkAndCleanAttrs(dicDotAttrs) if NodeDotAttrs.pos.value in dicDotAttrs: if dicDotAttrs[NodeDotAttrs.pos.value]: # Get position coords = NodeDotPosUtils.getPos( dicDotAttrs[NodeDotAttrs.pos.value]) self.model.addNode(idNode, dicDotAttrs, coords[NodeArgs.x], coords[NodeArgs.y]) else: self.model.addNode(idNode, dicDotAttrs)
def edit(self, dicDotAttrs): '''Edit dot attributes of the node. Argument(s): dicDotAttrs (Dictionary[]): Dot attributes of the node ''' for attr, val in dicDotAttrs.items(): # Case of pos attribute: we need to update x and y if attr == NodeDotAttrs.pos.value: if val: pos = NodeDotPosUtils.getPos(val) if pos: self.x = pos[NodeArgs.x] self.y = pos[NodeArgs.y] else: self.x = 0.0 self.y = 0.0 else: self.x = 0.0 self.y = 0.0 self.dotAttrs[attr] = val
def edit(self, dicDotAttrs): '''Edit dot attributes of the node. Argument(s): dicDotAttrs (Dictionary[]): Dot attributes of the node ''' for attr, val in dicDotAttrs.items(): # Case of pos attribute: we need to update x and y if attr == NodeDotAttrs.pos.value: if val: pos = NodeDotPosUtils.getPos(val) if pos: self.x = pos[NodeArgs.x] self.y = pos[NodeArgs.y] else: self.x = 0.0 self.y = 0.0 else: self.x = 0.0 self.y = 0.0 self.dotAttrs[attr] = val