本文整理汇总了Python中qwt.qt.QtCore.QRectF.size方法的典型用法代码示例。如果您正苦于以下问题:Python QRectF.size方法的具体用法?Python QRectF.size怎么用?Python QRectF.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qwt.qt.QtCore.QRectF
的用法示例。
在下文中一共展示了QRectF.size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: qwtDrawSvgSymbols
# 需要导入模块: from qwt.qt.QtCore import QRectF [as 别名]
# 或者: from qwt.qt.QtCore.QRectF import size [as 别名]
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()))
示例2: boundingRect
# 需要导入模块: from qwt.qt.QtCore import QRectF [as 别名]
# 或者: from qwt.qt.QtCore.QRectF import size [as 别名]
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