Skip to content
Permalink
Browse files

[processing] update color scheme and position of modeler elements

  • Loading branch information
nirvn committed Jan 2, 2017
1 parent d01e3fe commit 4603eb0f3d138fb8f118d97dabb94328b6001960
Showing with 18 additions and 9 deletions.
  1. +18 −9 python/plugins/processing/modeler/ModelerGraphicItem.py
@@ -100,12 +100,12 @@ def __init__(self, element, model):
alg = element.algorithm
if alg.parameters:
pt = self.getLinkPointForParameter(-1)
pt = QPointF(0, pt.y() + 2)
pt = QPointF(0, pt.y())
self.inButton = FoldButtonGraphicItem(pt, self.foldInput, self.element.paramsFolded)
self.inButton.setParentItem(self)
if alg.outputs:
pt = self.getLinkPointForOutput(-1)
pt = QPointF(0, pt.y() + 2)
pt = QPointF(0, pt.y())
self.outButton = FoldButtonGraphicItem(pt, self.foldOutput, self.element.outputsFolded)
self.outButton.setParentItem(self)

@@ -132,6 +132,7 @@ def addArrow(self, arrow):

def boundingRect(self):
font = QFont('Verdana', 8)
font.setPixelSize(12)
fm = QFontMetricsF(font)
unfolded = isinstance(self.element, Algorithm) and not self.element.paramsFolded
numParams = len(self.element.algorithm.parameters) if unfolded else 0
@@ -216,6 +217,7 @@ def removeElement(self):

def getAdjustedText(self, text):
font = QFont('Verdana', 8)
font.setPixelSize(12)
fm = QFontMetricsF(font)
w = fm.width(text)
if w < self.BOX_WIDTH - 25 - FlatButtonGraphicItem.WIDTH:
@@ -233,27 +235,31 @@ def paint(self, painter, option, widget=None):
-(ModelerGraphicItem.BOX_HEIGHT + 2) / 2.0,
ModelerGraphicItem.BOX_WIDTH + 2,
ModelerGraphicItem.BOX_HEIGHT + 2)
painter.setPen(QPen(Qt.gray, 1))
color = QColor(125, 232, 232)
color = QColor(172, 196, 114)
outline = QColor(90, 140, 90)
if isinstance(self.element, ModelerParameter):
color = QColor(179, 179, 255)
color = QColor(238, 242, 131)
outline = QColor(234, 226, 118)
elif isinstance(self.element, Algorithm):
color = Qt.white
outline = Qt.gray
painter.setPen(QPen(outline, 1))
painter.setBrush(QBrush(color, Qt.SolidPattern))
painter.drawRect(rect)
font = QFont('Verdana', 8)
font.setPixelSize(12)
painter.setFont(font)
painter.setPen(QPen(Qt.black))
text = self.getAdjustedText(self.text)
if isinstance(self.element, Algorithm) and not self.element.active:
painter.setPen(QPen(Qt.gray))
text = text + "\n(deactivated)"
elif self.isSelected():
painter.setPen(QPen(Qt.blue))
painter.setPen(QPen(outline))
fm = QFontMetricsF(font)
text = self.getAdjustedText(self.text)
h = fm.height()
pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, h / 2.0)
h = fm.ascent()
pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, ModelerGraphicItem.BOX_HEIGHT / 2.0 - h + 1)
painter.drawText(pt, text)
painter.setPen(QPen(Qt.black))
if isinstance(self.element, Algorithm):
@@ -272,7 +278,7 @@ def paint(self, painter, option, widget=None):
+ 33, h)
painter.drawText(pt, text)
i += 1
h = fm.height() * 1.2
h = fm.height() * 1.1
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, h)
painter.drawText(pt, 'Out')
@@ -297,6 +303,7 @@ def getLinkPointForParameter(self, paramIndex):
paramIndex = -1
offsetX = 17
font = QFont('Verdana', 8)
font.setPixelSize(12)
fm = QFontMetricsF(font)
if isinstance(self.element, Algorithm):
h = -(fm.height() * 1.2) * (paramIndex + 2) - fm.height() / 2.0 + 8
@@ -310,6 +317,7 @@ def getLinkPointForOutput(self, outputIndex):
outputIndex = (outputIndex if not self.element.outputsFolded else -1)
text = self.getAdjustedText(self.element.algorithm.outputs[outputIndex].description)
font = QFont('Verdana', 8)
font.setPixelSize(12)
fm = QFontMetricsF(font)
w = fm.width(text)
h = fm.height() * 1.2 * (outputIndex + 1) + fm.height() / 2.0
@@ -330,6 +338,7 @@ def itemChange(self, change, value):

def polygon(self):
font = QFont('Verdana', 8)
font.setPixelSize(12)
fm = QFontMetricsF(font)
hUp = fm.height() * 1.2 * (len(self.element.parameters) + 2)
hDown = fm.height() * 1.2 * (len(self.element.outputs) + 2)

0 comments on commit 4603eb0

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