本文整理汇总了Python中PyQt4.QtGui.QTransform.rotate方法的典型用法代码示例。如果您正苦于以下问题:Python QTransform.rotate方法的具体用法?Python QTransform.rotate怎么用?Python QTransform.rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QTransform
的用法示例。
在下文中一共展示了QTransform.rotate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _plat_get_blocks
# 需要导入模块: from PyQt4.QtGui import QTransform [as 别名]
# 或者: from PyQt4.QtGui.QTransform import rotate [as 别名]
def _plat_get_blocks(self, block_count_per_side, orientation):
image = QImage(str(self.path))
image = image.convertToFormat(QImage.Format_RGB888)
# MYSTERY TO SOLVE: For reasons I cannot explain, orientations 5 and 7 don't work for
# duplicate scanning. The transforms seems to work fine (if I try to save the image after
# the transform, we see that the image has been correctly flipped and rotated), but the
# analysis part yields wrong blocks. I spent enought time with this feature, so I'll leave
# like that for now. (by the way, orientations 5 and 7 work fine under Cocoa)
if 2 <= orientation <= 8:
t = QTransform()
if orientation == 2:
t.scale(-1, 1)
elif orientation == 3:
t.rotate(180)
elif orientation == 4:
t.scale(1, -1)
elif orientation == 5:
t.scale(-1, 1)
t.rotate(90)
elif orientation == 6:
t.rotate(90)
elif orientation == 7:
t.scale(-1, 1)
t.rotate(270)
elif orientation == 8:
t.rotate(270)
image = image.transformed(t)
return getblocks(image, block_count_per_side)
示例2: __updateText
# 需要导入模块: from PyQt4.QtGui import QTransform [as 别名]
# 或者: from PyQt4.QtGui.QTransform import rotate [as 别名]
def __updateText(self):
self.prepareGeometryChange()
if self.__sourceName or self.__sinkName:
if self.__sourceName != self.__sinkName:
text = u"{0} \u2192 {1}".format(self.__sourceName,
self.__sinkName)
else:
# If the names are the same show only one.
# Is this right? If the sink has two input channels of the
# same type having the name on the link help elucidate
# the scheme.
text = self.__sourceName
else:
text = ""
self.linkTextItem.setPlainText(text)
path = self.curveItem.path()
if not path.isEmpty():
center = path.pointAtPercent(0.5)
angle = path.angleAtPercent(0.5)
brect = self.linkTextItem.boundingRect()
transform = QTransform()
transform.translate(center.x(), center.y())
transform.rotate(-angle)
# Center and move above the curve path.
transform.translate(-brect.width() / 2, -brect.height())
self.linkTextItem.setTransform(transform)
示例3: get_nametag
# 需要导入模块: from PyQt4.QtGui import QTransform [as 别名]
# 或者: from PyQt4.QtGui.QTransform import rotate [as 别名]
def get_nametag(char_id, x, y, color, vertical = False):
w = IMG_W
h = IMG_H
nametag = get_char_name(char_id, common.editor_config.data01_dir)
if nametag == None:
nametag = "NAMETAG MISSING"
if vertical:
nametag_img = QImage(h, w, QImage.Format_ARGB32_Premultiplied)
new_x = h - y
new_y = x
x = new_x
y = new_y
else:
nametag_img = QImage(w, h, QImage.Format_ARGB32_Premultiplied)
format = TextFormat(x = x, y = y, w = 25, h = 25, align = TEXT_ALIGN.left, orient = TEXT_ORIENT.hor, clt = 0)
nametag_img = print_text(nametag_img, nametag, None, format = format, mangle = False)
if vertical:
matrix = QTransform()
matrix.rotate(-90)
nametag_img = nametag_img.transformed(matrix)
nametag_img = replace_all_colors(nametag_img, color)
return nametag_img
示例4: __init__
# 需要导入模块: from PyQt4.QtGui import QTransform [as 别名]
# 或者: from PyQt4.QtGui.QTransform import rotate [as 别名]
def __init__(self, *args, **kwargs):
QDockWidget.__init__(self, *args, **kwargs)
self.__expandedWidget = None
self.__collapsedWidget = None
self.__expanded = True
self.__trueMinimumWidth = -1
self.setFeatures(QDockWidget.DockWidgetClosable | \
QDockWidget.DockWidgetMovable)
self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.featuresChanged.connect(self.__onFeaturesChanged)
self.dockLocationChanged.connect(self.__onDockLocationChanged)
# Use the toolbar horizontal extension button icon as the default
# for the expand/collapse button
pm = self.style().standardPixmap(
QStyle.SP_ToolBarHorizontalExtensionButton
)
# Rotate the icon
transform = QTransform()
transform.rotate(180)
pm_rev = pm.transformed(transform)
self.__iconRight = QIcon(pm)
self.__iconLeft = QIcon(pm_rev)
close = self.findChild(QAbstractButton,
name="qt_dockwidget_closebutton")
close.installEventFilter(self)
self.__closeButton = close
self.__stack = AnimatedStackedWidget()
self.__stack.setSizePolicy(QSizePolicy.Fixed,
QSizePolicy.Expanding)
self.__stack.transitionStarted.connect(self.__onTransitionStarted)
self.__stack.transitionFinished.connect(self.__onTransitionFinished)
QDockWidget.setWidget(self, self.__stack)
self.__closeButton.setIcon(self.__iconLeft)
示例5: data
# 需要导入模块: from PyQt4.QtGui import QTransform [as 别名]
# 或者: from PyQt4.QtGui.QTransform import rotate [as 别名]
def data(self, index, role):
if not index.isValid():
return QVariant()
if index.row() >= len(self.list):
return QVariant()
if role == Qt.DecorationRole:
card = self.list[index.row()]
pixmap = card.pixmap()
pixmap = pixmap.scaledToHeight(self.preferredCardHeight)
if card.tapped:
transform = QTransform()
transform.rotate(90)
pixmap = pixmap.transformed(transform)
return pixmap
return QVariant()
示例6: updateStandardIcons
# 需要导入模块: from PyQt4.QtGui import QTransform [as 别名]
# 或者: from PyQt4.QtGui.QTransform import rotate [as 别名]
def updateStandardIcons(self):
size = QSize(16, 16)
rect = QRect(QPoint(), self.iconSize())
transform = QTransform()
transform.rotate(90)
pixmap = self.style().standardIcon(QStyle.SP_TitleBarNormalButton, None, self.widgetForAction(self.aFloat)).pixmap(size)
rect.moveCenter(pixmap.rect().center())
pixmap = pixmap.copy(rect)
self.aFloat.setIcon(QIcon(pixmap))
pixmap = self.style().standardIcon(QStyle.SP_TitleBarCloseButton, None, self.widgetForAction(self.aClose)).pixmap(size)
rect.moveCenter(pixmap.rect().center())
pixmap = pixmap.copy(rect)
self.aClose.setIcon(QIcon(pixmap))
示例7: setImageMove
# 需要导入模块: from PyQt4.QtGui import QTransform [as 别名]
# 或者: from PyQt4.QtGui.QTransform import rotate [as 别名]
def setImageMove(self, scale, pos, angle):
log_debug("New scale = %s" % (scale,))
self.scale = scale
self.min_scale = self.data_manager.minScale()
self.img_scale = (scale[0]/self.min_scale, scale[1]/self.min_scale)
back_matrix = QTransform()
back_matrix.scale(*self.img_scale)
back_matrix.translate(pos.x(), pos.y())
back_matrix.rotate(angle)
self.back_matrix = back_matrix
rect = back_matrix.mapRect(QRectF(self.background_image.rect()))
inv, ok = back_matrix.inverted()
if not ok:
raise ValueError("The movement is not invertible !?!")
self.invert_back_matrix = inv
self.real_scene_rect = rect
示例8: _define_symbols
# 需要导入模块: from PyQt4.QtGui import QTransform [as 别名]
# 或者: from PyQt4.QtGui.QTransform import rotate [as 别名]
def _define_symbols():
"""
Add symbol ? to ScatterPlotItemSymbols,
reflect the triangle to point upwards
"""
symbols = pyqtgraph.graphicsItems.ScatterPlotItem.Symbols
path = QPainterPath()
path.addEllipse(QRectF(-0.35, -0.35, 0.7, 0.7))
path.moveTo(-0.5, 0.5)
path.lineTo(0.5, -0.5)
path.moveTo(-0.5, -0.5)
path.lineTo(0.5, 0.5)
symbols["?"] = path
tr = QTransform()
tr.rotate(180)
symbols['t'] = tr.map(symbols['t'])
示例9: saveSlice
# 需要导入模块: from PyQt4.QtGui import QTransform [as 别名]
# 或者: from PyQt4.QtGui.QTransform import rotate [as 别名]
def saveSlice(self, filename):
"""Legacy code."""
#print "Saving in ", filename, "slice #", self.sliceNumber, "axis", self._axis
result_image = QImage(self.scene().image.size(), self.scene().image.format())
p = QPainter(result_image)
for patchNr in range(self.patchAccessor.patchCount):
bounds = self.patchAccessor.getPatchBounds(patchNr)
if self.openglWidget is None:
p.drawImage(0, 0, self.scene().image)
else:
p.drawImage(bounds[0], bounds[2], self.imagePatches[patchNr])
p.end()
#horrible way to transpose an image. but it works.
transform = QTransform()
transform.rotate(90)
result_image = result_image.mirrored()
result_image = result_image.transformed(transform)
result_image.save(QString(filename))
示例10: _newAxes
# 需要导入模块: from PyQt4.QtGui import QTransform [as 别名]
# 或者: from PyQt4.QtGui.QTransform import rotate [as 别名]
def _newAxes(self):
"""Given self._rotation and self._swapped, calculates and sets
the appropriate data2scene transformation.
"""
# TODO: this function works, but it is not elegant. There must
# be a simpler way to calculate the appropriate transformation.
w, h = self.dataShape
assert self._rotation in range(0, 4)
# unlike self._rotation, the local variable 'rotation'
# indicates how many times to rotate clockwise after swapping
# axes.
# t1 : do axis swap
t1 = QTransform()
if self._swapped:
t1 = QTransform(0, 1, 0,
1, 0, 0,
0, 0, 1)
h, w = w, h
# t2 : do rotation
t2 = QTransform()
t2.rotate(self._rotation * 90)
# t3: shift to re-center
rot2trans = {0 : (0, 0),
1 : (h, 0),
2 : (w, h),
3 : (0, w)}
trans = rot2trans[self._rotation]
t3 = QTransform.fromTranslate(*trans)
self.data2scene = t1 * t2 * t3
if self._tileProvider:
self._tileProvider.axesSwapped = self._swapped
self.axesChanged.emit(self._rotation, self._swapped)
示例11: overlay_for
# 需要导入模块: from PyQt4.QtGui import QTransform [as 别名]
# 或者: from PyQt4.QtGui.QTransform import rotate [as 别名]
def overlay_for(pt1, pt2, frequency):
# Construct the line-geometry, we'll use this to construct the ellipsoid
line = QLineF(pt1, pt2)
# Determine the radius for the ellipsoid
radius = fresnel_radius(line.length(), frequency)
# Draw the ellipsoid
zone = QPainterPath()
zone.addEllipse(QPointF(0., 0.), line.length() / 2, radius)
# Rotate the ellipsoid - same angle as the line
transform = QTransform()
transform.rotate(-line.angle())
zone = transform.map(zone)
# Center the zone over the line
lc = QRectF(pt1, pt2).center()
zc = zone.boundingRect().center()
zone.translate(lc.x() - zc.x(), lc.y() - zc.y())
return line, zone