예제 #1
0
파일: Node.py 프로젝트: pydoted/dotEd
    def __init__(self, id, dicDotAttrs={}, x=0.0, y=0.0):
        self.id = id
        self.x = x
        self.y = y

        self.neighbours = {}
        self.dotAttrs = {}

        dictAttrs = dicDotAttrs.copy()
        dictAttrs[NodeDotAttrs.pos.value] = NodeDotPosUtils.formatPos(x, y)
        self.edit(dictAttrs)
예제 #2
0
    def __init__(self, id, dicDotAttrs={}, x=0.0, y=0.0):
        self.id = id
        self.x = x
        self.y = y

        self.neighbours = {}
        self.dotAttrs = {}

        dictAttrs = dicDotAttrs.copy()
        dictAttrs[NodeDotAttrs.pos.value] = NodeDotPosUtils.formatPos(x, y)
        self.edit(dictAttrs)
예제 #3
0
    def checkNodeAttrsForm(self, dictNodeAttrs):
        '''Return None if an attribute of a node is not valid, else an error
        message.

        Argument(s):
        dictNodeAttrs (str): Dot attributes values of the nodes
        '''
        for attr in dictNodeAttrs.keys():
            # Case of pos attribute
            if (attr == NodeDotAttrs.pos.value and
                    not NodeDotPosUtils.isPosValid(dictNodeAttrs[attr])):
                return self.formatErrorMessage(NodeDotAttrs.pos.value,
                                               dictNodeAttrs[attr])

        # All attributes are valid
        return None
예제 #4
0
    def checkNodeAttrsForm(self, dictNodeAttrs):
        '''Return None if an attribute of a node is not valid, else an error
        message.

        Argument(s):
        dictNodeAttrs (str): Dot attributes values of the nodes
        '''
        for attr in dictNodeAttrs.keys():
            # Case of pos attribute
            if (attr == NodeDotAttrs.pos.value
                    and not NodeDotPosUtils.isPosValid(dictNodeAttrs[attr])):
                return self.formatErrorMessage(NodeDotAttrs.pos.value,
                                               dictNodeAttrs[attr])

        # All attributes are valid
        return None
예제 #5
0
    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)
예제 #6
0
    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)
예제 #7
0
    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
예제 #8
0
파일: Node.py 프로젝트: pydoted/dotEd
    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
예제 #9
0
 def onEditPos(self):
     """Callback function when editing the pos."""
     self.graphicsGraphView.controller.onEditNode(
         self.id, {NodeDotAttrs.pos.value: NodeDotPosUtils.formatPos(self.x(), self.y())}
     )
예제 #10
0
 def onEditPos(self):
     '''Callback function when editing the pos.'''
     self.graphicsGraphView.controller.onEditNode(self.id, {
         NodeDotAttrs.pos.value:
         NodeDotPosUtils.formatPos(self.x(), self.y())
     })