本文整理汇总了Python中PyQt5.QtGui.QTransform方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QTransform方法的具体用法?Python QtGui.QTransform怎么用?Python QtGui.QTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui
的用法示例。
在下文中一共展示了QtGui.QTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepareDimensions
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def prepareDimensions(self):
#set scene size and view scale
scene = self.scene()
scene.setSize()
vw = float(self.width())
vh = float(self.height())
iw = float(scene.im.size[0])
ih = float(scene.im.size[1])
ratio = min(vw/iw, vh/ih)
# TODO: check this - there was QMatrix
# self.setMatrix(QTransform(.95*ratio, 0., 0., .95*ratio, 0., 0.))
OcrArea.resizeBorder = 5 / ratio
self.areaBorder = 2 / ratio
self.areaTextSize = 10 / ratio
#show image
scene.generateQtImage()
self.resetCachedContent()
scene.isModified = False
示例2: drawForeground
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def drawForeground(self, painter, rectF):
super(CodeView, self).drawForeground(painter, rectF)
if self.isFrameSelectMode:
if self.mousePressPnt and self.mouseCurPnt:
topLeftX = min(self.mousePressPnt.x(), self.mouseCurPnt.x())
topLeftY = min(self.mousePressPnt.y(), self.mouseCurPnt.y())
width = abs(self.mousePressPnt.x()-self.mouseCurPnt.x())
height= abs(self.mousePressPnt.y()-self.mouseCurPnt.y())
painter.setPen(QtGui.QPen(QtGui.QColor(100,164,230),1.0))
painter.setBrush(QtGui.QBrush(QtGui.QColor(100,164,230,100)))
painter.setTransform(QtGui.QTransform())
painter.drawRect(topLeftX, topLeftY, width, height)
self.drawScheme(painter, rectF)
self.drawLegend(painter, rectF)
示例3: mirror_pixmap
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def mirror_pixmap(pixmap):
transform = QTransform()
transform.scale(-1, 1)
return QPixmap(pixmap.transformed(transform))
示例4: mouseMoveEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def mouseMoveEvent(self, event):
global now, w
if w.input_rect:
if now is None:
now = event.scenePos()
else:
self.removeItem(self.itemAt(now, QTransform()))
p = event.scenePos()
self.addRect(now.x(), now.y(), abs(now.x() - p.x()), abs(now.y() - p.y()))
示例5: clipping
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def clipping(win):
buf = win.scene.itemAt(now, QTransform()).rect()
win.clip = [buf.left(), buf.right(), buf.top(), buf.bottom()]
for b in win.lines:
pass
win.pen.setColor(blue)
cohen_sutherland(b, win.clip, win)
win.pen.setColor(red)
示例6: setZoomLevel
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def setZoomLevel(self, zoom, mapposx, mapposy):
self.mapItem.setTransform(QtGui.QTransform.fromScale(zoom, zoom))
self.gwidget.mapScene.setSceneRect(self.mapItem.sceneBoundingRect())
if mapposx >= 0 and mapposy >=0:
self.gwidget.mapView.centerOn(mapposx * zoom, mapposy * zoom)
示例7: get_transform
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def get_transform(self, w, h, x, y):
return QTransform().rotate(self.theta * 180 / np.pi).translate(x, y)
示例8: get_tile_ranges
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def get_tile_ranges(self, imw, imh, w, h, tr: QTransform):
""" Calculates the number of tiles depending on the transform.
Parameters
----------
imw
imh
w
h
tr
Returns
-------
"""
# we find where the display surface is in the coordinate system of a single tile
corner_points = [
np.array([0.0, 0.0]),
np.array([w, 0.0]),
np.array([w, h]),
np.array([0.0, h]),
]
points_transformed = np.array(
[tr.inverted()[0].map(*cp) for cp in corner_points]
)
# calculate the rectangle covering the transformed display surface
min_x, min_y = np.min(points_transformed, 0)
max_x, max_y = np.max(points_transformed, 0)
# count which tiles need to be drawn
x_start, x_end = (int(np.floor(min_x / imw)), int(np.ceil(max_x / imw)))
y_start, y_end = (int(np.floor(min_y / imh)), int(np.ceil(max_y / imh)))
return range(x_start, x_end + 1), range(y_start, y_end + 1)
示例9: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def __init__(self, text, parent=None, position=QtCore.QPointF(0, 0), transform=QtGui.QTransform(), selectable=True):
super(TextItem, self).__init__(parent=parent)
if selectable:
self.setFlags(QtWidgets.QGraphicsItem.ItemIsSelectable | QtWidgets.QGraphicsItem.ItemIsMovable |
QtWidgets.QGraphicsItem.ItemSendsGeometryChanges | QtWidgets.QGraphicsItem.ItemIsFocusable)
else:
self.setFlags(QtWidgets.QGraphicsItem.ItemIsMovable)
self.setHtml(text)
self.setPos(position)
self.setTransform(transform)
self.selectable = selectable
示例10: readItemFromStream
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def readItemFromStream(self, stream):
type = QtCore.QString()
matrix = QtGui.QTransform()
stream >> type >> matrix
if type == "txt":
text = QtCore.QString()
stream >> text
item = TextItem(text)
elif type == "square":
rect = QtCore.QRectF()
pen = QtGui.QPen()
stream >> rect >> pen
item = RectItem()
item.setRect(rect)
item.setPen(pen)
elif type == "ellipse":
rect = QtCore.QRectF()
pen = QtGui.QPen()
stream >> rect >> pen
item = EllipseItem()
item.setRect(rect)
item.setPen(pen)
elif type == "equip":
name = QtCore.QString()
stream >> name
dialogoid = stream.readInt32()
item = EquipmentItem(name, dialogoid)
item.setTransform(matrix)
return item
示例11: draw
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def draw(self, painter: QPainter) -> None:
if self.sourceIsPixmap():
pixmap, offset = self.sourcePixmap(Qt.LogicalCoordinates, QGraphicsEffect.PadToEffectiveBoundingRect)
else:
pixmap, offset = self.sourcePixmap(Qt.DeviceCoordinates, QGraphicsEffect.PadToEffectiveBoundingRect)
painter.setWorldTransform(QTransform())
painter.setBrush(Qt.black)
painter.drawRect(pixmap.rect())
painter.setOpacity(self.opacity)
painter.drawPixmap(offset, pixmap)
示例12: fit_to_window
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def fit_to_window(self):
if not self._pixmap or not self._pixmap.pixmap():
return
self.resetTransform()
self.setTransform(QtGui.QTransform())
self.fitInView(self._pixmap, QtCore.Qt.KeepAspectRatio)
示例13: mouseMoveEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def mouseMoveEvent(self, event: qg.QMouseEvent) -> None:
pos = self.mapToScene(event.pos())
self._current_item = self.scene().itemAt(pos, qg.QTransform())
self.element_selected.emit(self._current_item, pos)
self.scene().invalidate(self.sceneRect(), qw.QGraphicsScene.ForegroundLayer)
super().mouseMoveEvent(event)
示例14: _get_x_scale
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def _get_x_scale(t: qg.QTransform) -> float:
return math.sqrt(t.m11() * t.m11() + t.m21() * t.m21())
示例15: _matrix_to_qtransform
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QTransform [as 别名]
def _matrix_to_qtransform(matrix: Matrix44) -> qg.QTransform:
""" Qt also uses row-vectors so the translation elements are placed in the bottom row
This is only a simple conversion which assumes that although the transformation is 4x4,
it does not involve the z axis.
A more correct transformation could be implemented like so:
https://stackoverflow.com/questions/10629737/convert-3d-4x4-rotation-matrix-into-2d
"""
return qg.QTransform(*matrix.get_2d_transformation())