Пример #1
0
    def onEditColor(self):
        """Callback function when editing the color."""
        # Open ColorPicker
        colorHex = QColorDialog.getColor()

        # If "OK" button pressed
        if colorHex.isValid():
            # Set the new color
            self.setPen(QPen(colorHex))

            # Create dictionnary and send update
            dicDotAttrs = {NodeDotAttrs.color.value: NodeDotColorUtils.formatColor(colorHex.name())}
            self.graphicsGraphView.controller.onEditNode(self.id, dicDotAttrs)
Пример #2
0
    def onEditColor(self):
        '''Callback function when editing the color.'''
        # Open ColorPicker
        colorHex = QColorDialog.getColor()

        # If "OK" button pressed
        if colorHex.isValid():
            # Set the new color
            self.setPen(QPen(colorHex))

            # Create dictionnary and send update
            dicDotAttrs = {
                NodeDotAttrs.color.value:
                NodeDotColorUtils.formatColor(colorHex.name())
            }
            self.graphicsGraphView.controller.onEditNode(self.id, dicDotAttrs)
Пример #3
0
    def editColor(self, dictArgsNode):
        '''Edit the color.

        Argument(s):
        dictArgsNode (Dictionary[]): Dictionary of arguments of the node
        '''
        color = None

        # Check if color is defined
        if (NodeDotAttrs.color.value in dictArgsNode[NodeArgs.dotAttrs]
                and dictArgsNode[NodeArgs.dotAttrs][NodeDotAttrs.color.value]):
            color = NodeDotColorUtils.getColor(
                dictArgsNode[NodeArgs.dotAttrs][NodeDotAttrs.color.value])
        # If not define, reset color to black
        else:
            color = QColor(Qt.black)

        # Only update if no changement
        if color and color != self.pen().color():
            self.setPen(QPen(color))
Пример #4
0
    def editColor(self, dictArgsNode):
        """Edit the color.

        Argument(s):
        dictArgsNode (Dictionary[]): Dictionary of arguments of the node
        """
        color = None

        # Check if color is defined
        if (
            NodeDotAttrs.color.value in dictArgsNode[NodeArgs.dotAttrs]
            and dictArgsNode[NodeArgs.dotAttrs][NodeDotAttrs.color.value]
        ):
            color = NodeDotColorUtils.getColor(dictArgsNode[NodeArgs.dotAttrs][NodeDotAttrs.color.value])
        # If not define, reset color to black
        else:
            color = QColor(Qt.black)

        # Only update if no changement
        if color and color != self.pen().color():
            self.setPen(QPen(color))
Пример #5
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
        '''
        message = DotAttrsUtilsV1_0.checkNodeAttrsForm(self, dictNodeAttrs)
        # If message is not None, then there is an invalid attribute
        if message:
            return message

        # Check color attribute
        if (NodeDotAttrs.color.value in dictNodeAttrs
                and not NodeDotColorUtils.isColorValid(
                    dictNodeAttrs[NodeDotAttrs.color.value])):
            return DotAttrsUtilsV1_0.formatErrorMessage(
                self, NodeDotAttrs.color.value,
                dictNodeAttrs[NodeDotAttrs.color.value])

        # All attributes are valid
        return None
Пример #6
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
        '''
        message = DotAttrsUtilsV1_0.checkNodeAttrsForm(self, dictNodeAttrs)
        # If message is not None, then there is an invalid attribute
        if message:
            return message

        # Check color attribute
        if (NodeDotAttrs.color.value in dictNodeAttrs and
            not NodeDotColorUtils.isColorValid(dictNodeAttrs
                                               [NodeDotAttrs.color.value])):
            return DotAttrsUtilsV1_0.formatErrorMessage(
                self,
                NodeDotAttrs.color.value,
                dictNodeAttrs[NodeDotAttrs.color.value]
            )

        # All attributes are valid
        return None