Skip to content
Permalink
Browse files

[processing] Draw arrows connected to selected/hovered components

slightly darker

Makes it easier to track connections in a complex model
  • Loading branch information
nyalldawson committed Mar 1, 2019
1 parent 2178e1a commit dab4a043094fa632cabb2e0b3cab0a2f2e5d0e91
@@ -68,6 +68,7 @@ def __init__(self, startItem, startIndex, endItem, endIndex,
self.endPoints = []
self.setFlag(QGraphicsItem.ItemIsSelectable, False)
self.myColor = QApplication.palette().color(QPalette.WindowText)
self.myColor.setAlpha(150)
self.setPen(QPen(self.myColor, 1, Qt.SolidLine,
Qt.RoundCap, Qt.RoundJoin))
self.setZValue(0)
@@ -125,10 +126,19 @@ def updatePath(self):
self.setPath(path)

def paint(self, painter, option, widget=None):
color = self.myColor

if self.startItem.isSelected() or self.endItem.isSelected():
color.setAlpha(220)
elif self.startItem.hover_over_item or self.endItem.hover_over_item:
color.setAlpha(150)
else:
color.setAlpha(80)

myPen = self.pen()
myPen.setColor(self.myColor)
myPen.setColor(color)
painter.setPen(myPen)
painter.setBrush(self.myColor)
painter.setBrush(color)
painter.setRenderHint(QPainter.Antialiasing)

for point in self.endPoints:
@@ -188,6 +188,7 @@ def hoverLeaveEvent(self, event):
if self.hover_over_item:
self.hover_over_item = False
self.update()
self.repaintArrows()

def updateToolTip(self, event):
prev_status = self.hover_over_item
@@ -199,6 +200,7 @@ def updateToolTip(self, event):
self.hover_over_item = False
if self.hover_over_item != prev_status:
self.update()
self.repaintArrows()

def contextMenuEvent(self, event):
if isinstance(self.element, QgsProcessingModelOutput):
@@ -427,6 +429,10 @@ def getLinkPointForOutput(self, outputIndex):
else:
return QPointF(0, 0)

def repaintArrows(self):
for arrow in self.arrows:
arrow.update()

def itemChange(self, change, value):
if change == QGraphicsItem.ItemPositionHasChanged:
for arrow in self.arrows:
@@ -440,8 +446,10 @@ def itemChange(self, change, value):
self.model.parameterComponent(self.element.parameterName()).setPosition(self.pos())
elif isinstance(self.element, QgsProcessingModelOutput):
self.model.childAlgorithm(self.element.childId()).modelOutput(self.element.name()).setPosition(self.pos())
elif change == QGraphicsItem.ItemSelectedChange:
self.repaintArrows()

return value
return super().itemChange(change, value)

def polygon(self):
font = QFont('Verdana', 8)

0 comments on commit dab4a04

Please sign in to comment.
You can’t perform that action at this time.