• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python QtCore.QRectF类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中qwt.qt.QtCore.QRectF的典型用法代码示例。如果您正苦于以下问题:Python QRectF类的具体用法?Python QRectF怎么用?Python QRectF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了QRectF类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: renderItem

    def renderItem(self, painter, widget, rect, fillBackground):
        """
        Render a legend entry into a given rectangle.

        :param QPainter painter: Painter
        :param QWidget widget: Widget representing a legend entry
        :param QRectF rect: Bounding rectangle
        :param bool fillBackground: When true, fill rect with the widget background
        """
        if fillBackground:
            if widget.autoFillBackground() or\
               widget.testAttribute(Qt.WA_StyledBackground):
                QwtPainter.drawBackground(painter, rect, widget)
        label = widget  #TODO: cast to QwtLegendLabel
        if label is not None:
            icon = label.data().icon()
            sz = icon.defaultSize()
            iconRect = QRectF(rect.x()+label.margin(),
                              rect.center().y()-.5*sz.height(),
                              sz.width(), sz.height())
            icon.render(painter, iconRect, Qt.KeepAspectRatio)
            titleRect = QRectF(rect)
            titleRect.setX(iconRect.right()+2*label.spacing())
            painter.setFont(label.font())
            painter.setPen(label.palette().color(QPalette.Text))
            label.drawText(painter, titleRect)  #TODO: cast label to QwtLegendLabel
开发者ID:gyenney,项目名称:Tools,代码行数:26,代码来源:legend.py


示例2: drawLines

 def drawLines(self, painter, xMap, yMap, canvasRect, from_, to):
     """
     Draw lines
     
     :param QPainter painter: Painter
     :param qwt.scale_map.QwtScaleMap xMap: Maps x-values into pixel coordinates.
     :param qwt.scale_map.QwtScaleMap yMap: Maps y-values into pixel coordinates.
     :param QRectF canvasRect: Contents rectangle of the canvas
     :param int from_: Index of the first point to be painted
     :param int to: Index of the last point to be painted. If to < 0 the curve will be painted to its last point.
     
     .. seealso::
     
         :py:meth:`draw()`, :py:meth:`drawDots()`, 
         :py:meth:`drawSteps()`, :py:meth:`drawSticks()`
     """
     if from_ > to:
         return
     doAlign = QwtPainter.roundingAlignment(painter)
     doFill = self.__data.brush.style() != Qt.NoBrush\
              and self.__data.brush.color().alpha() > 0
     clipRect = QRectF()
     if self.__data.paintAttributes & self.ClipPolygons:
         pw = max([1., painter.pen().widthF()])
         clipRect = canvasRect.adjusted(-pw, -pw, pw, pw)
     doIntegers = False
     if QT_VERSION < 0x040800:
         if painter.paintEngine().type() == QPaintEngine.Raster:
             if not doFill:
                 doIntegers = True
     noDuplicates = self.__data.paintAttributes & self.FilterPoints
     mapper = QwtPointMapper()
     mapper.setFlag(QwtPointMapper.RoundPoints, doAlign)
     mapper.setFlag(QwtPointMapper.WeedOutPoints, noDuplicates)
     mapper.setBoundingRect(canvasRect)
     if doIntegers:
         polyline = mapper.toPolygon(xMap, yMap, self.data(), from_, to)
         if self.__data.paintAttributes & self.ClipPolygons:
             polyline = QwtClipper().clipPolygon(clipRect.toAlignedRect(),
                                                polyline, False)
         QwtPainter.drawPolyline(painter, polyline)
     else:
         polyline = mapper.toPolygonF(xMap, yMap, self.data(), from_, to)
         if doFill:
             if painter.pen().style() != Qt.NoPen:
                 filled = QPolygonF(polyline)
                 self.fillCurve(painter, xMap, yMap, canvasRect, filled)
                 filled.clear()
                 if self.__data.paintAttributes & self.ClipPolygons:
                     polyline = QwtClipper().clipPolygonF(clipRect,
                                                          polyline, False)
                 QwtPainter.drawPolyline(painter, polyline)
             else:
                 self.fillCurve(painter, xMap, yMap, canvasRect, polyline)
         else:
             if self.__data.paintAttributes & self.ClipPolygons:
                 polyline = QwtClipper().clipPolygonF(clipRect, polyline,
                                                      False)
             QwtPainter.drawPolyline(painter, polyline)
开发者ID:gyenney,项目名称:Tools,代码行数:59,代码来源:plot_curve.py


示例3: minLabelDist

 def minLabelDist(self, font):
     if not self.hasComponent(QwtAbstractScaleDraw.Labels):
         return 0
     
     ticks = self.scaleDiv().ticks(QwtScaleDiv.MajorTick)
     if not ticks:
         return 0
     
     fm = QFontMetrics(font)
     vertical = self.orientation() == Qt.Vertical
     
     bRect1 = QRectF()
     bRect2 = self.labelRect(font, ticks[0])
     if vertical:
         bRect2.setRect(-bRect2.bottom(), 0.,
                        bRect2.height(), bRect2.width())
     
     maxDist = 0.
     
     for tick in ticks:
         bRect1 = bRect2
         bRect2 = self.labelRect(font, tick)
         if vertical:
             bRect2.setRect(-bRect2.bottom(), 0.,
                            bRect2.height(), bRect2.width())
         
         dist = fm.leading()
         if bRect1.right() > 0:
             dist += bRect1.right()
         if bRect2.left() < 0:
             dist += -bRect2.left()
         
         if dist > maxDist:
             maxDist = dist
         
     angle = qwtRadians(self.labelRotation())
     if vertical:
         angle += np.pi/2
     
     sinA = np.sin(angle)
     if qFuzzyCompare(sinA+1., 1.):
         return np.ceil(maxDist)
     
     fmHeight = fm.ascent()-2
     
     labelDist = fmHeight/np.sin(angle)*np.cos(angle)
     if labelDist < 0:
         labelDist = -labelDist
     
     if labelDist > maxDist:
         labelDist = maxDist
     
     if labelDist < fmHeight:
         labelDist = fmHeight
     
     return np.ceil(labelDist)
开发者ID:petebachant,项目名称:python-qwt,代码行数:56,代码来源:scale_draw.py


示例4: drawPath

 def drawPath(self, path):
     rect = QRectF(QPointF(0., 0.), self.__size)
     if path.controlPointRect().contains(rect.center()):
         self.setCornerRects(path)
         self.alignCornerRects(rect)
         self.background.path = path
         self.background.brush = self.__brush
         self.background.origin = self.__origin
     else:
         self.border.pathlist += [path]
开发者ID:petebachant,项目名称:python-qwt,代码行数:10,代码来源:plot_canvas.py


示例5: renderDocument

 def renderDocument(self, plot, filename, sizeMM=(300, 200), resolution=85,
                    format_=None):
     if isinstance(sizeMM, tuple):
         sizeMM = QSizeF(*sizeMM)
     if format_ is None:
         ext = osp.splitext(filename)[1]
         if not ext:
             raise TypeError("Unable to determine target format from filename")
         format_ = ext[1:]
     if plot is None or sizeMM.isEmpty() or resolution <= 0:
         return
     title = plot.title().text()
     if not title:
         title = "Plot Document"
     mmToInch = 1./25.4
     size = sizeMM * mmToInch * resolution
     documentRect = QRectF(0.0, 0.0, size.width(), size.height())
     fmt = format_.lower()
     if fmt in ("pdf", "ps"):
         printer = QPrinter()
         if fmt == "pdf":
             printer.setOutputFormat(QPrinter.PdfFormat)
         else:
             printer.setOutputFormat(QPrinter.PostScriptFormat)
         printer.setColorMode(QPrinter.Color)
         printer.setFullPage(True)
         printer.setPaperSize(sizeMM, QPrinter.Millimeter)
         printer.setDocName(title)
         printer.setOutputFileName(filename)
         printer.setResolution(resolution)
         painter = QPainter(printer)
         self.render(plot, painter, documentRect)
         painter.end()
     elif fmt == "svg":
         generator = QSvgGenerator()
         generator.setTitle(title)
         generator.setFileName(filename)
         generator.setResolution(resolution)
         generator.setViewBox(documentRect)
         painter = QPainter(generator)
         self.render(plot, painter, documentRect)
         painter.end()
     elif fmt in QImageWriter.supportedImageFormats():
         imageRect = documentRect.toRect()
         dotsPerMeter = int(round(resolution*mmToInch*1000.))
         image = QImage(imageRect.size(), QImage.Format_ARGB32)
         image.setDotsPerMeterX(dotsPerMeter)
         image.setDotsPerMeterY(dotsPerMeter)
         image.fill(QColor(Qt.white).rgb())
         painter = QPainter(image)
         self.render(plot, painter, imageRect)
         painter.end()
         image.save(filename, fmt)
     else:
         raise TypeError("Unsupported file format '%s'" % fmt)
开发者ID:petebachant,项目名称:python-qwt,代码行数:55,代码来源:plot_renderer.py


示例6: drawSymbol

    def drawSymbol(self, painter, point_or_rect):
        """
        Draw the symbol into a rectangle

        The symbol is painted centered and scaled into the target rectangle.
        It is always painted uncached and the pin point is ignored.

        This method is primarily intended for drawing a symbol to the legend.

        :param QPainter painter: Painter
        :param point_or_rect: Position or target rectangle of the symbol in screen coordinates
        :type point_or_rect: QPointF or QPoint or QRectF
        """
        if isinstance(point_or_rect, (QPointF, QPoint)):
            # drawSymbol( QPainter *, const QPointF & )
            self.drawSymbols(painter, [point_or_rect])
            return
        # drawSymbol( QPainter *, const QRectF & )
        rect = point_or_rect
        assert isinstance(rect, QRectF)
        if self.__data.style == QwtSymbol.NoSymbol:
            return
        if self.__data.style == QwtSymbol.Graphic:
            self.__data.graphic.graphic.render(painter, rect,
                                               Qt.KeepAspectRatio)
        elif self.__data.style == QwtSymbol.Path:
            if self.__data.path.graphic.isNull():
                self.__data.path.graphic = qwtPathGraphic(
                    self.__data.path.path, self.__data.pen, self.__data.brush)
            self.__data.path.graphic.render(painter, rect, Qt.KeepAspectRatio)
            return
        elif self.__data.style == QwtSymbol.SvgDocument:
            if self.__data.svg.renderer is not None:
                scaledRect = QRectF()
                sz = QSizeF(self.__data.svg.renderer.viewBoxF().size())
                if not sz.isEmpty():
                    sz.scale(rect.size(), Qt.KeepAspectRatio)
                    scaledRect.setSize(sz)
                    scaledRect.moveCenter(rect.center())
                else:
                    scaledRect = rect
                self.__data.svg.renderer.render(painter, scaledRect)
        else:
            br = QRect(self.boundingRect())
            ratio = min([rect.width()/br.width(), rect.height()/br.height()])
            painter.save()
            painter.translate(rect.center())
            painter.scale(ratio, ratio)
            isPinPointEnabled = self.__data.isPinPointEnabled
            self.__data.isPinPointEnabled = False
            pos = QPointF()
            self.renderSymbols(painter, pos, 1)
            self.__data.isPinPointEnabled = isPinPointEnabled
            painter.restore()
开发者ID:gyenney,项目名称:Tools,代码行数:54,代码来源:symbol.py


示例7: draw

 def draw(self, painter, xMap, yMap, canvasRect):
     pos = QPointF(xMap.transform(self.__data.xValue),
                   yMap.transform(self.__data.yValue))
     self.drawLines(painter, canvasRect, pos)
     if self.__data.symbol and\
        self.__data.symbol.style() != QwtSymbol.NoSymbol:
         sz = self.__data.symbol.size()
         clipRect = QRectF(canvasRect.adjusted(-sz.width(), -sz.height(),
                                               sz.width(), sz.height()))
         if clipRect.contains(pos):
             self.__data.symbol.drawSymbols(painter, [pos])
     self.drawLabel(painter, canvasRect, pos)
开发者ID:petebachant,项目名称:python-qwt,代码行数:12,代码来源:plot_marker.py


示例8: toRect

 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
开发者ID:gyenney,项目名称:Tools,代码行数:14,代码来源:column_symbol.py


示例9: drawLines

 def drawLines(self, painter, xMap, yMap, canvasRect, from_, to):
     if from_ > to:
         return
     doAlign = QwtPainter.roundingAlignment(painter)
     doFit = (self.__data.attributes & self.Fitted)\
             and self.__data.curveFitter
     doFill = self.__data.brush.style() != Qt.NoBrush\
              and self.__data.brush.color().alpha() > 0
     clipRect = QRectF()
     if self.__data.paintAttributes & self.ClipPolygons:
         pw = max([1., painter.pen().widthF()])
         clipRect = canvasRect.adjusted(-pw, -pw, pw, pw)
     doIntegers = False
     if QT_VERSION < 0x040800:
         if painter.paintEngine().type() == QPaintEngine.Raster:
             if not doFit and not doFill:
                 doIntegers = True
     noDuplicates = self.__data.paintAttributes & self.FilterPoints
     mapper = QwtPointMapper()
     mapper.setFlag(QwtPointMapper.RoundPoints, doAlign)
     mapper.setFlag(QwtPointMapper.WeedOutPoints, noDuplicates)
     mapper.setBoundingRect(canvasRect)
     if doIntegers:
         polyline = mapper.toPolygon(xMap, yMap, self.data(), from_, to)
         if self.__data.paintAttributes & self.ClipPolygons:
             polyline = QwtClipper().clipPolygon(clipRect.toAlignedRect(),
                                                polyline, False)
         QwtPainter.drawPolyline(painter, polyline)
     else:
         polyline = mapper.toPolygonF(xMap, yMap, self.data(), from_, to)
         if doFit:
             polyline = self.__data.curveFitter.fitCurve(polyline)
         if doFill:
             if painter.pen().style() != Qt.NoPen:
                 filled = QPolygonF(polyline)
                 self.fillCurve(painter, xMap, yMap, canvasRect, filled)
                 filled.clear()
                 if self.__data.paintAttributes & self.ClipPolygons:
                     polyline = QwtClipper().clipPolygonF(clipRect,
                                                          polyline, False)
                 QwtPainter.drawPolyline(painter, polyline)
             else:
                 self.fillCurve(painter, xMap, yMap, canvasRect, polyline)
         else:
             if self.__data.paintAttributes & self.ClipPolygons:
                 polyline = QwtClipper().clipPolygonF(clipRect, polyline,
                                                      False)
             QwtPainter.drawPolyline(painter, polyline)
开发者ID:petebachant,项目名称:python-qwt,代码行数:48,代码来源:plot_curve.py


示例10: renderItem

 def renderItem(self, painter, widget, rect, fillBackground):
     if fillBackground:
         if widget.autoFillBackground() or\
            widget.testAttribute(Qt.WA_StyledBackground):
             QwtPainter.drawBackground(painter, rect, widget)
     label = widget  #TODO: cast to QwtLegendLabel
     if label is not None:
         icon = label.data().icon()
         sz = icon.defaultSize()
         iconRect = QRectF(rect.x()+label.margin(),
                           rect.center().y()-.5*sz.height(),
                           sz.width(), sz.height())
         icon.render(painter, iconRect, Qt.KeepAspectRatio)
         titleRect = QRectF(rect)
         titleRect.setX(iconRect.right()+2*label.spacing())
         painter.setFont(label.font())
         painter.setPen(label.palette().color(QPalette.Text))
         label.drawText(painter, titleRect)  #TODO: cast label to QwtLegendLabel
开发者ID:petebachant,项目名称:python-qwt,代码行数:18,代码来源:legend.py


示例11: drawSymbol

 def drawSymbol(self, painter, point_or_rect):
     if isinstance(point_or_rect, (QPointF, QPoint)):
         # drawSymbol( QPainter *, const QPointF & )
         self.drawSymbols(painter, [point_or_rect], 1)
         return
     # drawSymbol( QPainter *, const QRectF & )
     rect = point_or_rect
     assert isinstance(rect, QRectF)
     if self.__data.style == QwtSymbol.NoSymbol:
         return
     if self.__data.style == QwtSymbol.Graphic:
         self.__data.graphic.graphic.render(painter, rect,
                                            Qt.KeepAspectRatio)
     elif self.__data.style == QwtSymbol.Path:
         if self.__data.path.graphic.isNull():
             self.__data.path.graphic = qwtPathGraphic(
                 self.__data.path.path, self.__data.pen, self.__data.brush)
         self.__data.path.graphic.render(painter, rect, Qt.KeepAspectRatio)
         return
     elif self.__data.style == QwtSymbol.SvgDocument:
         if self.__data.svg.renderer is not None:
             scaledRect = QRectF()
             sz = QSizeF(self.__data.svg.renderer.viewBoxF().size())
             if not sz.isEmpty():
                 sz.scale(rect.size(), Qt.KeepAspectRatio)
                 scaledRect.setSize(sz)
                 scaledRect.moveCenter(rect.center())
             else:
                 scaledRect = rect
             self.__data.svg.renderer.render(painter, scaledRect)
     else:
         br = QRect(self.boundingRect())
         ratio = min([rect.width()/br.width(), rect.height()/br.height()])
         painter.save()
         painter.translate(rect.center())
         painter.scale(ratio, ratio)
         isPinPointEnabled = self.__data.isPinPointEnabled
         self.__data.isPinPointEnabled = False
         pos = QPointF()
         self.renderSymbols(painter, pos, 1)
         self.__data.isPinPointEnabled = isPinPointEnabled
         painter.restore()
开发者ID:petebachant,项目名称:python-qwt,代码行数:42,代码来源:symbol.py


示例12: draw

 def draw(self, painter, xMap, yMap, canvasRect):
     """
     Draw the marker
     
     :param QPainter painter: Painter
     :param qwt.scale_map.QwtScaleMap xMap: x Scale Map
     :param qwt.scale_map.QwtScaleMap yMap: y Scale Map
     :param QRectF canvasRect: Contents rectangle of the canvas in painter coordinates
     """
     pos = QPointF(xMap.transform(self.__data.xValue),
                   yMap.transform(self.__data.yValue))
     self.drawLines(painter, canvasRect, pos)
     if self.__data.symbol and\
        self.__data.symbol.style() != QwtSymbol.NoSymbol:
         sz = self.__data.symbol.size()
         clipRect = QRectF(canvasRect.adjusted(-sz.width(), -sz.height(),
                                               sz.width(), sz.height()))
         if clipRect.contains(pos):
             self.__data.symbol.drawSymbols(painter, [pos])
     self.drawLabel(painter, canvasRect, pos)
开发者ID:berrosse,项目名称:PythonQwt,代码行数:20,代码来源:plot_marker.py


示例13: drawSimpleRichText

 def drawSimpleRichText(self, painter, rect, flags, text):
     txt = text.clone()
     painter.save()
     unscaledRect = QRectF(rect)
     if painter.font().pixelSize() < 0:
         res = qwtScreenResolution()
         pd = painter.device()
         if pd.logicalDpiX() != res.width()\
            or pd.logicalDpiY() != res.height():
             transform = QTransform()
             transform.scale(res.width()/float(pd.logicalDpiX()),
                             res.height()/float(pd.logicalDpiY()))
             painter.setWorldTransform(transform, True)
             invtrans, _ok = transform.inverted()
             unscaledRect = invtrans.mapRect(rect)
     txt.setDefaultFont(painter.font())
     txt.setPageSize(QSizeF(unscaledRect.width(), QWIDGETSIZE_MAX))
     layout = txt.documentLayout()
     height = layout.documentSize().height()
     y = unscaledRect.y()
     if flags & Qt.AlignBottom:
         y += unscaledRect.height()-height
     elif flags & Qt.AlignVCenter:
         y += (unscaledRect.height()-height)/2
     context = QAbstractTextDocumentLayout.PaintContext()
     context.palette.setColor(QPalette.Text, painter.pen().color())
     painter.translate(unscaledRect.x(), y)
     layout.draw(painter, context)
     painter.restore()
开发者ID:petebachant,项目名称:python-qwt,代码行数:29,代码来源:painter.py


示例14: qwtDrawGraphicSymbols

def qwtDrawGraphicSymbols(painter, points, numPoint, graphic, symbol):
    pointRect = QRectF(graphic.controlPointRect())
    if pointRect.isEmpty():
        return
    sx = 1.
    sy = 1.
    sz = symbol.size()
    if sz.isValid():
        sx = sz.width()/pointRect.width()
        sy = sz.height()/pointRect.height()
    pinPoint = QPointF(pointRect.center())
    if symbol.isPinPointEnabled():
        pinPoint = symbol.pinPoint()
    transform = QTransform(painter.transform())
    for pos in points:
        tr = QTransform(transform)
        tr.translate(pos.x(), pos.y())
        tr.scale(sx, sy)
        tr.translate(-pinPoint.x(), -pinPoint.y())
        painter.setTransform(tr)
        graphic.render(painter)
    painter.setTransform(transform)
开发者ID:gyenney,项目名称:Tools,代码行数:22,代码来源:symbol.py


示例15: invTransform

 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()
开发者ID:berrosse,项目名称:PythonQwt,代码行数:22,代码来源:scale_map.py


示例16: setCornerRects

 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()
开发者ID:petebachant,项目名称:python-qwt,代码行数:21,代码来源:plot_canvas.py


示例17: qwtDrawSvgSymbols

def qwtDrawSvgSymbols(painter, points, numPoints, renderer, symbol):
    if renderer is None or not renderer.isValid():
        return
    viewBox = QRectF(renderer.viewBoxF())
    if viewBox.isEmpty():
        return
    sz = QSizeF(symbol.size())
    if not sz.isValid():
        sz = viewBox.size()
    sx = sz.width()/viewBox.width()
    sy = sz.height()/viewBox.height()
    pinPoint = QPointF(viewBox.center())
    if symbol.isPinPointEnabled():
        pinPoint = symbol.pinPoint()
    dx = sx*(pinPoint.x()-viewBox.left())
    dy = sy*(pinPoint.y()-viewBox.top())
    for pos in points:
        x = pos.x()-dx
        y = pos.y()-dy
        renderer.render(painter, QRectF(x, y, sz.width(), sz.height()))
开发者ID:gyenney,项目名称:Tools,代码行数:20,代码来源:symbol.py


示例18: colorBarRect

 def colorBarRect(self, rect):
     cr = QRectF(rect)
     if self.__data.scaleDraw.orientation() == Qt.Horizontal:
         cr.setLeft(cr.left() + self.__data.borderDist[0])
         cr.setWidth(cr.width() - self.__data.borderDist[1] + 1)
     else:
         cr.setTop(cr.top() + self.__data.borderDist[0])
         cr.setHeight(cr.height() - self.__data.borderDist[1] + 1)
     sda = self.__data.scaleDraw.alignment()
     if sda == QwtScaleDraw.LeftScale:
         cr.setLeft(cr.right()-self.__data.margin-self.__data.colorBar.width)
         cr.setWidth(self.__data.colorBar.width)
     elif sda == QwtScaleDraw.RightScale:
         cr.setLeft(cr.left()+self.__data.margin)
         cr.setWidth(self.__data.colorBar.width)
     elif sda == QwtScaleDraw.BottomScale:
         cr.setTop(cr.top()+self.__data.margin)
         cr.setHeight(self.__data.colorBar.width)
     elif sda == QwtScaleDraw.TopScale:
         cr.setTop(cr.bottom()-self.__data.margin-self.__data.colorBar.width)
         cr.setHeight(self.__data.colorBar.width)
     return cr
开发者ID:petebachant,项目名称:python-qwt,代码行数:22,代码来源:scale_widget.py


示例19: boundingRect

    def boundingRect(self):
        """
        Calculate the bounding rectangle for a symbol at position (0,0).

        :return: Bounding rectangle
        """
        rect = QRectF()
        pinPointTranslation = False
        if self.__data.style in (QwtSymbol.Ellipse, QwtSymbol.Rect,
                                 QwtSymbol.Hexagon):
            pw = 0.
            if self.__data.pen.style() != Qt.NoPen:
                pw = max([self.__data.pen.widthF(), 1.])
            rect.setSize(self.__data.size+QSizeF(pw, pw))
            rect.moveCenter(QPointF(0., 0.))
        elif self.__data.style in (QwtSymbol.XCross, QwtSymbol.Diamond,
                                   QwtSymbol.Triangle, QwtSymbol.UTriangle,
                                   QwtSymbol.DTriangle, QwtSymbol.RTriangle,
                                   QwtSymbol.LTriangle, QwtSymbol.Star1,
                                   QwtSymbol.Star2):
            pw = 0.
            if self.__data.pen.style() != Qt.NoPen:
                pw = max([self.__data.pen.widthF(), 1.])
            rect.setSize(QSizeF(self.__data.size)+QSizeF(2*pw, 2*pw))
            rect.moveCenter(QPointF(0., 0.))
        elif self.__data.style == QwtSymbol.Path:
            if self.__data.path.graphic.isNull():
                self.__data.path.graphic = qwtPathGraphic(
                    self.__data.path.path, self.__data.pen, self.__data.brush)
            rect = qwtScaleBoundingRect(self.__data.path.graphic,
                                        self.__data.size)
            pinPointTranslation = True
        elif self.__data.style == QwtSymbol.Pixmap:
            if self.__data.size.isEmpty():
                rect.setSize(self.__data.pixmap.pixmap.size())
            else:
                rect.setSize(self.__data.size)
            pinPointTranslation = True
        elif self.__data.style == QwtSymbol.Graphic:
            rect = qwtScaleBoundingRect(self.__data.graphic.graphic,
                                        self.__data.size)
            pinPointTranslation = True
        elif self.__data.style == QwtSymbol.SvgDocument:
            if self.__data.svg.renderer is not None:
                rect = self.__data.svg.renderer.viewBoxF()
            if self.__data.size.isValid() and not rect.isEmpty():
                sz = QSizeF(rect.size())
                sx = self.__data.size.width()/sz.width()
                sy = self.__data.size.height()/sz.height()
                transform = QTransform()
                transform.scale(sx, sy)
                rect = transform.mapRect(rect)
            pinPointTranslation = True
        else:
            rect.setSize(self.__data.size)
            rect.moveCenter(QPointF(0., 0.))
        if pinPointTranslation:
            pinPoint = QPointF(0., 0.)
            if self.__data.isPinPointEnabled:
                pinPoint = rect.center()-self.__data.pinPoint
            rect.moveCenter(pinPoint)
        r = QRect()
        r.setLeft(np.floor(rect.left()))
        r.setTop(np.floor(rect.top()))
        r.setRight(np.floor(rect.right()))
        r.setBottom(np.floor(rect.bottom()))
        if self.__data.style != QwtSymbol.Pixmap:
            r.adjust(-1, -1, 1, 1)
        return r
开发者ID:gyenney,项目名称:Tools,代码行数:69,代码来源:symbol.py


示例20: layoutLegend

 def layoutLegend(self, options, rect):
     """
     Find the geometry for the legend
     
     :param options: Options how to layout the legend
     :param QRectF rect: Rectangle where to place the legend
     :return: Geometry for the legend
     """
     hint = self.__data.layoutData.legend.hint
     if self.__data.legendPos in (QwtPlot.LeftLegend, QwtPlot.RightLegend):
         dim = min([hint.width(), int(rect.width()*self.__data.legendRatio)])
         if not (options & self.IgnoreScrollbars):
             if hint.height() > rect.height():
                 dim += self.__data.layoutData.legend.hScrollExtent
     else:
         dim = min([hint.height(), int(rect.height()*self.__data.legendRatio)])
         dim = max([dim, self.__data.layoutData.legend.vScrollExtent])
     legendRect = QRectF(rect)
     if self.__data.legendPos == QwtPlot.LeftLegend:
         legendRect.setWidth(dim)
     elif self.__data.legendPos == QwtPlot.RightLegend:
         legendRect.setX(rect.right()-dim)
         legendRect.setWidth(dim)
     elif self.__data.legendPos == QwtPlot.TopLegend:
         legendRect.setHeight(dim)
     elif self.__data.legendPos == QwtPlot.BottomLegend:
         legendRect.setY(rect.bottom()-dim)
         legendRect.setHeight(dim)
     return legendRect
开发者ID:berrosse,项目名称:PythonQwt,代码行数:29,代码来源:plot_layout.py



注:本文中的qwt.qt.QtCore.QRectF类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python QtGui.QApplication类代码示例发布时间:2022-05-26
下一篇:
Python painter.QwtPainter类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap