本文整理匯總了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