예제 #1
0
    def getAdjustedText(self, text):
        font = QFont('Verdana', 8)
        fm = QFontMetricsF(font)
        w = fm.width(text)
        if w < self.BOX_WIDTH - 25 - FlatButtonGraphicItem.WIDTH:
            return text

        text = text[0:-3] + '...'
        w = fm.width(text)
        while w > self.BOX_WIDTH - 25 - FlatButtonGraphicItem.WIDTH:
            text = text[0:-4] + '...'
            w = fm.width(text)
        return text
예제 #2
0
    def getAdjustedText(self, text):
        font = QFont('Verdana', 8)
        fm = QFontMetricsF(font)
        w = fm.width(text)
        if w < self.BOX_WIDTH - 25 - FlatButtonGraphicItem.WIDTH:
            return text

        text = text[0:-3] + '...'
        w = fm.width(text)
        while w > self.BOX_WIDTH - 25 - FlatButtonGraphicItem.WIDTH:
            text = text[0:-4] + '...'
            w = fm.width(text)
        return text
예제 #3
0
 def getLinkPointForOutput(self, outputIndex):
     if isinstance(self.element, Algorithm) and self.element.algorithm.outputs:
         outputIndex = (outputIndex if not self.element.outputsFolded else -1)
         text = self.getAdjustedText(self.element.algorithm.outputs[outputIndex].description)
         font = QFont('Verdana', 8)
         fm = QFontMetricsF(font)
         w = fm.width(text)
         h = fm.height() * 1.2 * (outputIndex + 1) + fm.height() / 2.0
         y = h + ModelerGraphicItem.BOX_HEIGHT / 2.0 + 5
         x = (-ModelerGraphicItem.BOX_WIDTH / 2 + 33 + w
              + 5 if not self.element.outputsFolded else 10)
         return QPointF(x, y)
     else:
         return QPointF(0, 0)
예제 #4
0
 def getLinkPointForOutput(self, outputIndex):
     if isinstance(self.element,
                   Algorithm) and self.element.algorithm.outputs:
         outputIndex = (outputIndex
                        if not self.element.outputsFolded else -1)
         text = self.getAdjustedText(
             self.element.algorithm.outputs[outputIndex].description)
         font = QFont('Verdana', 8)
         fm = QFontMetricsF(font)
         w = fm.width(text)
         h = fm.height() * 1.2 * (outputIndex + 1) + fm.height() / 2.0
         y = h + ModelerGraphicItem.BOX_HEIGHT / 2.0 + 5
         x = (-ModelerGraphicItem.BOX_WIDTH / 2 + 33 + w +
              5 if not self.element.outputsFolded else 10)
         return QPointF(x, y)
     else:
         return QPointF(0, 0)