def setCornerRects(self, path):
     pos = QPointF(0., 0.)
     for i in range(path.elementCount()):
         el = path.elementAt(i)
         if el.type in (QPainterPath.MoveToElement,
                        QPainterPath.LineToElement):
             pos.setX(el.x)
             pos.setY(el.y)
         elif el.type == QPainterPath.CurveToElement:
             r = QRectF(pos, QPointF(el.x, el.y))
             self.clipRects += [r.normalized()]
             pos.setX(el.x)
             pos.setY(el.y)
         elif el.type == QPainterPath.CurveToDataElement:
             if self.clipRects:
                 r = self.clipRects[-1]
                 r.setCoords(min([r.left(), el.x]), min([r.top(), el.y]),
                             max([r.right(), el.x]), max([r.bottom(),
                                                          el.y]))
                 self.clipRects[-1] = r.normalized()
 def setCornerRects(self, path):
     pos = QPointF(0., 0.)
     for i in range(path.elementCount()):
         el = path.elementAt(i)
         if el.type in (QPainterPath.MoveToElement,
                        QPainterPath.LineToElement):
             pos.setX(el.x)
             pos.setY(el.y)
         elif el.type == QPainterPath.CurveToElement:
             r = QRectF(pos, QPointF(el.x, el.y))
             self.clipRects += [r.normalized()]
             pos.setX(el.x)
             pos.setY(el.y)
         elif el.type == QPainterPath.CurveToDataElement:
             if self.clipRects:
                 r = self.clipRects[-1]
                 r.setCoords(min([r.left(), el.x]),
                             min([r.top(), el.y]),
                             max([r.right(), el.x]),
                             max([r.bottom(), el.y]))
                 self.clipRects[-1] = r.normalized()
Exemple #3
0
 def toRect(self):
     r = QRectF(self.hInterval.minValue(), self.vInterval.minValue(),
                self.hInterval.maxValue() - self.hInterval.minValue(),
                self.vInterval.maxValue() - self.vInterval.minValue())
     r = r.normalized()
     if self.hInterval.borderFlags() & QwtInterval.ExcludeMinimum:
         r.adjust(1, 0, 0, 0)
     if self.hInterval.borderFlags() & QwtInterval.ExcludeMaximum:
         r.adjust(0, 0, -1, 0)
     if self.vInterval.borderFlags() & QwtInterval.ExcludeMinimum:
         r.adjust(0, 1, 0, 0)
     if self.vInterval.borderFlags() & QwtInterval.ExcludeMaximum:
         r.adjust(0, 0, 0, -1)
     return r
Exemple #4
0
 def toRect(self):
     r = QRectF(self.hInterval.minValue(), self.vInterval.minValue(),
                self.hInterval.maxValue()-self.hInterval.minValue(),
                self.vInterval.maxValue()-self.vInterval.minValue())
     r = r.normalized()
     if self.hInterval.borderFlags() & QwtInterval.ExcludeMinimum:
         r.adjust(1, 0, 0, 0)
     if self.hInterval.borderFlags() & QwtInterval.ExcludeMaximum:
         r.adjust(0, 0, -1, 0)
     if self.vInterval.borderFlags() & QwtInterval.ExcludeMinimum:
         r.adjust(0, 1, 0, 0)
     if self.vInterval.borderFlags() & QwtInterval.ExcludeMaximum:
         r.adjust(0, 0, 0, -1)
     return r
 def invTransform(self, *args):
     """Transform from paint to scale coordinates
     
     Scalar: scalemap.invTransform(scalar)
     Point (QPointF): scalemap.invTransform(xMap, yMap, pos)
     Rectangle (QRectF): scalemap.invTransform(xMap, yMap, rect)
     """
     if len(args) == 1:
         # Scalar transform
         return self.invTransform_scalar(args[0])
     elif isinstance(args[2], QPointF):
         xMap, yMap, pos = args
         return QPointF(xMap.invTransform(pos.x()),
                        yMap.invTransform(pos.y()))
     elif isinstance(args[2], QRectF):
         xMap, yMap, rect = args
         x1 = xMap.invTransform(rect.left())
         x2 = xMap.invTransform(rect.right() - 1)
         y1 = yMap.invTransform(rect.top())
         y2 = yMap.invTransform(rect.bottom() - 1)
         r = QRectF(x1, y1, x2 - x1, y2 - y1)
         return r.normalized()
Exemple #6
0
 def invTransform(self, *args):
     """Transform from paint to scale coordinates
     
     Scalar: scalemap.invTransform(scalar)
     Point (QPointF): scalemap.invTransform(xMap, yMap, pos)
     Rectangle (QRectF): scalemap.invTransform(xMap, yMap, rect)
     """
     if len(args) == 1:
         # Scalar transform
         return self.invTransform_scalar(args[0])
     elif isinstance(args[2], QPointF):
         xMap, yMap, pos = args
         return QPointF(xMap.invTransform(pos.x()),
                        yMap.invTransform(pos.y()))
     elif isinstance(args[2], QRectF):
         xMap, yMap, rect = args
         x1 = xMap.invTransform(rect.left())
         x2 = xMap.invTransform(rect.right()-1)
         y1 = yMap.invTransform(rect.top())
         y2 = yMap.invTransform(rect.bottom()-1)
         r = QRectF(x1, y1, x2-x1, y2-y1)
         return r.normalized()