本文整理汇总了Python中PyQt5.QtGui.QTransform.mapRect方法的典型用法代码示例。如果您正苦于以下问题:Python QTransform.mapRect方法的具体用法?Python QTransform.mapRect怎么用?Python QTransform.mapRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QTransform
的用法示例。
在下文中一共展示了QTransform.mapRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visibleIn
# 需要导入模块: from PyQt5.QtGui import QTransform [as 别名]
# 或者: from PyQt5.QtGui.QTransform import mapRect [as 别名]
def visibleIn(area, object, renderer):
boundingRect = renderer.boundingRect(object)
if (object.rotation() != 0):
# Rotate around object position
pos = renderer.pixelToScreenCoords_(object.position())
boundingRect.translate(-pos)
transform = QTransform()
transform.rotate(object.rotation())
boundingRect = transform.mapRect(boundingRect)
boundingRect.translate(pos)
return intersects(area, boundingRect)
示例2: syncWithMapObject
# 需要导入模块: from PyQt5.QtGui import QTransform [as 别名]
# 或者: from PyQt5.QtGui.QTransform import mapRect [as 别名]
def syncWithMapObject(self, renderer):
nameVisible = self.mObject.isVisible() and self.mObject.name()!=''
self.setVisible(nameVisible)
if (not nameVisible):
return
metrics = QFontMetricsF(QGuiApplication.font())
boundingRect = metrics.boundingRect(self.mObject.name())
boundingRect.translate(-boundingRect.width() / 2, -labelDistance)
boundingRect.adjust(-labelMargin*2, -labelMargin, labelMargin*2, labelMargin)
pixelPos = renderer.pixelToScreenCoords_(self.mObject.position())
bounds = objectBounds(self.mObject, renderer)
# Adjust the bounding box for object rotation
transform = QTransform()
transform.translate(pixelPos.x(), pixelPos.y())
transform.rotate(self.mObject.rotation())
transform.translate(-pixelPos.x(), -pixelPos.y())
bounds = transform.mapRect(bounds)
# Center the object name on the object bounding box
pos = QPointF((bounds.left() + bounds.right()) / 2, bounds.top())
self.setPos(pos + self.mObject.objectGroup().offset())
if (self.mBoundingRect != boundingRect):
self.prepareGeometryChange()
self.mBoundingRect = boundingRect
示例3: _itemsAt
# 需要导入模块: from PyQt5.QtGui import QTransform [as 别名]
# 或者: from PyQt5.QtGui.QTransform import mapRect [as 别名]
#.........这里部分代码省略.........
This is useful to find out whether an item was clicked on canvas.
"""
scale = self._inverseScale
# TODO: export this from drawing or use QSettings.
# anchor
anchorSize = 6 * scale
anchorHalfSize = anchorSize / 2
# offCurve
offWidth = 5 * scale
offHalf = offWidth / 2
offStrokeWidth = 3 * scale
# onCurve
onWidth = 7 * scale
onHalf = onWidth / 2
onStrokeWidth = 1.5 * scale
# onCurve smooth
smoothWidth = 8 * scale
smoothHalf = smoothWidth / 2
# guideline pt
guidelineStrokeWidth = 1 * scale
if not justOne:
ret = dict(
anchors=[],
contours=[],
points=[],
components=[],
guidelines=[],
image=None,
)
# anchors
for anchor in reversed(self._glyph.anchors):
path = QPainterPath()
path.addEllipse(anchor.x - anchorHalfSize,
anchor.y - anchorHalfSize, anchorSize, anchorSize)
if func(path, obj):
if justOne:
return (anchor, None)
ret["anchors"].append(anchor)
# points
for contour in reversed(self._glyph):
for point in contour:
path = QPainterPath()
if point.segmentType is None:
x = point.x - offHalf
y = point.y - offHalf
path.addEllipse(x, y, offWidth, offWidth)
strokeWidth = offStrokeWidth
else:
if point.smooth:
x = point.x - smoothHalf
y = point.y - smoothHalf
path.addEllipse(x, y, smoothWidth, smoothWidth)
else:
x = point.x - onHalf
y = point.y - onHalf
path.addRect(x, y, onWidth, onWidth)
strokeWidth = onStrokeWidth
path = _shapeFromPath(path, strokeWidth)
if func(path, obj):
if justOne:
return (point, contour)
ret["contours"].append(contour)
ret["points"].append(point)
# components
for component in reversed(self._glyph.components):
path = component.getRepresentation("TruFont.QPainterPath")
if func(path, obj):
if justOne:
return (component, None)
ret["components"].append(component)
# guideline
for guideline in UIGlyphGuidelines(self._glyph):
if None not in (guideline.x, guideline.y):
# point
x = guideline.x - smoothHalf
y = guideline.y - smoothHalf
path = QPainterPath()
path.addEllipse(x, y, smoothWidth, smoothWidth)
path = _shapeFromPath(path, guidelineStrokeWidth)
if func(path, obj):
if justOne:
return (guideline, None)
ret["guidelines"].append(guideline)
# TODO: catch line if selected
# image
image = self._glyph.image
pixmap = image.getRepresentation("defconQt.QPixmap")
if pixmap is not None:
path = QPainterPath()
transform = QTransform(*image.transformation)
rect = transform.mapRect(QRectF(pixmap.rect()))
path.addRect(*rect.getCoords())
if func(path, obj):
if justOne:
return (image, None)
ret["image"] = image
if not justOne:
return ret
return None