示例#1
0
    def itemChange(self, change, value):
        # Move selected nodes and edges to the front, untill unselected
        if change == QGraphicsItem.ItemSelectedChange:
            if QGraphicsItem.isSelected(self):
            	#Unselected (since the flag is not updated yet)
                self.setZValue(0)
                self.setZValueEdges(1)
            else:
            	#Selected
                self.setZValue(4)
                self.setZValueEdges(5)

        #If the position of the node changes -> calculate position change
        #and move edges with the node
        newPos = value

        if change == QGraphicsItem.ItemPositionChange:
            if self.snappingIsOn:
                newPos = self.snapToGrid(newPos)
            posChange = newPos - self.lastPos
            # Due to the grid snapping, only process when node actually moved 
            if not posChange.isNull():
                self.moveEdges(posChange)
                self.lastPos = newPos
                self.widget.editNodePosition(self.nodeName, newPos)

        return super(Node, self).itemChange(change, newPos)
示例#2
0
    def paintNodeBody(self, painter, lod):
        painter.setPen(Qt.black)

        #Subtle gradient
        if lod > 0.2:
            gradient = QLinearGradient(0, 0, self.nodeBodyWidth,
                                       self.nodeBodyHeight)
            gradient.setColorAt(0, self.nodeBodyColor)
            gradient.setColorAt(1, self.nodeBodyColorGradient)
            brush = QBrush(gradient)
        else:
            brush = QBrush(self.nodeBodyColor)

        if self.hover:
            brush = QBrush(self.nodeBodyColorHover)

        if QGraphicsItem.isSelected(self):
            brush = QBrush(self.nodeBodyColorSelected)

        painter.setBrush(brush)

        if lod > 0.1:
            painter.drawRoundedRect(0, 0, self.nodeBodyWidth,
                                    self.nodeBodyHeight, 10, 5)
        else:
            painter.drawRect(0, 0, self.nodeBodyWidth, self.nodeBodyHeight)
示例#3
0
    def itemChange(self, change, value):
        # Move selected nodes and edges to the front, untill unselected
        if change == QGraphicsItem.ItemSelectedChange:
            if QGraphicsItem.isSelected(self):
                #Unselected (since the flag is not updated yet)
                self.setZValue(0)
                self.setZValueEdges(1)
            else:
                #Selected
                self.setZValue(4)
                self.setZValueEdges(5)

        #If the position of the node changes -> calculate position change
        #and move edges with the node
        newPos = value

        if change == QGraphicsItem.ItemPositionChange:
            if self.snappingIsOn:
                newPos = self.snapToGrid(newPos)
            posChange = newPos - self.lastPos
            # Due to the grid snapping, only process when node actually moved
            if not posChange.isNull():
                self.moveEdges(posChange)
                self.lastPos = newPos
                self.widget.editNodePosition(self.nodeName, newPos)

        return super(Node, self).itemChange(change, newPos)
示例#4
0
    def hoverMoveEvent(self, event):
        #Don't execute when the nodeBody is selected in order to prevent unselecting the nodeBody
        if not QGraphicsItem.isSelected(self):
            self.mouseIsOnIO(event.pos())

        super().hoverMoveEvent(event)
        self.update()

        #Must be done after super().mousePressEvent(event) in order to
        #flag the node again after clicking on an input/output
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        self.setFlag(QGraphicsItem.ItemIsMovable, True)
示例#5
0
    def hoverMoveEvent(self, event):
        #Don't execute when the nodeBody is selected in order to prevent unselecting the nodeBody
        if not QGraphicsItem.isSelected(self):
            self.mouseIsOnIO(event.pos())

        super().hoverMoveEvent(event)
        self.update()

        #Must be done after super().mousePressEvent(event) in order to
        #flag the node again after clicking on an input/output
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        self.setFlag(QGraphicsItem.ItemIsMovable, True)
示例#6
0
    def paintEdge(self, painter, lod):
        pen = QPen(Qt.black)
        pen.setWidth(1)
        pen.setCapStyle(Qt.RoundCap)
        brush = QBrush(self.edgeColor)

        if self.hover:
            #pen.setColor(self.edgeColorHover)
            brush.setColor(self.edgeColorHover)

        if QGraphicsItem.isSelected(self):
            #pen.setColor(self.edgeColorSelected)
            brush.setColor(self.edgeColorSelected)

        painter.setPen(pen)
        painter.setBrush(brush)

        edgePath = self.getEdgePath()
        edgePath = edgePath.simplified()

        painter.drawPath(edgePath)
示例#7
0
    def paintNodeBody(self, painter, lod):
        painter.setPen(schemastyle.NODE_BACKGROUND_COLOR)
        brush = QBrush(schemastyle.NODE_BACKGROUND_COLOR)

        if self.hover:
            brush = QBrush(schemastyle.NODE_BACKGROUND_COLOR)

        if QGraphicsItem.isSelected(self):
            brush = QBrush(schemastyle.NODE_BACKGROUND_COLOR)

        painter.setBrush(brush)

        if lod > 0.1:
            painter.setPen(schemastyle.NODE_SHADOW_COLOR)
            painter.setBrush(QBrush(schemastyle.NODE_SHADOW_COLOR))
            painter.drawRoundedRect(3, 3, self.nodeBodyWidth,
                                    self.nodeBodyHeight, 5, 5)
            painter.setPen(schemastyle.NODE_BACKGROUND_COLOR)
            painter.setBrush(QBrush(schemastyle.NODE_BACKGROUND_COLOR))
            painter.drawRoundedRect(0, 0, self.nodeBodyWidth,
                                    self.nodeBodyHeight, 5, 5)
        else:
            painter.drawRect(0, 0, self.nodeBodyWidth, self.nodeBodyHeight)
示例#8
0
    def paintNodeBody(self, painter, lod):
        painter.setPen(Qt.black)
      
        #Subtle gradient
        if lod > 0.2:
            gradient = QLinearGradient(0, 0, self.nodeBodyWidth, self.nodeBodyHeight)
            gradient.setColorAt(0, self.nodeBodyColor)
            gradient.setColorAt(1, self.nodeBodyColorGradient)
            brush = QBrush(gradient)
        else:
            brush = QBrush(self.nodeBodyColor)

        if self.hover:
            brush = QBrush(self.nodeBodyColorHover)

        if QGraphicsItem.isSelected(self):
            brush = QBrush(self.nodeBodyColorSelected)

        painter.setBrush(brush)

        if lod > 0.1:
            painter.drawRoundedRect(0, 0, self.nodeBodyWidth, self.nodeBodyHeight, 10, 5)
        else:
        	painter.drawRect(0, 0, self.nodeBodyWidth, self.nodeBodyHeight)
示例#9
0
    def paintEdge(self, painter, lod):
        pen = QPen(Qt.black)
        pen.setWidth(1)
        pen.setCapStyle(Qt.RoundCap)
        brush = QBrush(self.edgeColor)

        if self.hover:
            #pen.setColor(self.edgeColorHover)
            brush.setColor(self.edgeColorHover)

        if QGraphicsItem.isSelected(self):
            #pen.setColor(self.edgeColorSelected)
            brush.setColor(self.edgeColorSelected)

        painter.setPen(pen)
        painter.setBrush(brush)

        edgePath = self.getEdgePath()       
        edgePath = edgePath.simplified()

        painter.drawPath(edgePath)

        if lod > 0.4:
            self.drawPCRates(painter)