当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QTransform类代码示例

本文整理汇总了Python中PyQt5.QtGui.QTransform的典型用法代码示例。如果您正苦于以下问题:Python QTransform类的具体用法?Python QTransform怎么用?Python QTransform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QTransform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setupMatrix

    def setupMatrix(self):
        scale = 2.0 ** ((self.zoomLevel - 250) / 50.0)

        transform = QTransform()
        transform.scale(scale, scale)

        self.graphicsView.setTransform(transform)
开发者ID:rinsewester,项目名称:SDFkit,代码行数:7,代码来源:graphicsview.py

示例2: resizeEvent

 def resizeEvent(self, event):
     sceneWidth = min(event.size().width(), event.size().height())
     trans = QTransform()
     trans.scale(sceneWidth / self.initialSceneWidth,
                 sceneWidth / self.initialSceneWidth)
     self.setTransform(trans)
     self.centerOn(sceneWidth / 2.0, sceneWidth / 2.0)
开发者ID:thesmartwon,项目名称:OpenChess-Python,代码行数:7,代码来源:board.py

示例3: ParseTransformAttrib

def ParseTransformAttrib(s):
  # where s is an SVG transform attribute such as "translate(-2,1) matrix(0 1 2 3 4 5)"
  # return a list of QTransforms
  xforms = []
  s = s.lower()
  while s:
    s = re.sub(r'^\s+,?\s+', '', s)  # remove leading WS,WS
    m = re.match(r'\s*(\w+)\s*\(((\s*[0-9e.+-]+\s*,?)+)\)', s) # match identifier(numbers) clause
    if m:
      values = SplitFloatValues(m.group(2))
      if m.group(1) == 'translate':
        if len(values) == 1: values.append(0)
        xforms.append( QTransform.fromTranslate(*values) )
      elif m.group(1) == 'scale':
        if len(values) == 1: values.append(values[0])
        xforms.append( QTransform.fromScale(*values) )
      elif m.group(1) == 'rotate':
        xforms.append( QTransform().rotate(values[0]) )  # TODO: handle cx,cy values
      elif m.group(1) == 'matrix':
        logger.trace('matrix({}): m.group(2) = {}', values, m.group(2))
        xforms.append( QTransform( values[0], values[1], 0
                                 , values[2], values[3], 0
                                 , values[4], values[5], 1) )
      # TODO: handle skewX and skewY
      else: logger.warning('unrecognized transform: {}', m.group())
      s = s[m.end()+1:]
    else:
      if s: logger.warning('unparsed transform: {}', s)
      break
  return xforms
开发者ID:benignvulcan,项目名称:tiles,代码行数:30,代码来源:svgparsing.py

示例4: _image

def _image(file, sub_folder, rotate=None):
    pixmap = QPixmap(os_path_join(_BASE_PATH, sub_folder, file))
    if rotate is None:
        return pixmap
    transform = QTransform()
    transform.rotate(rotate)
    return pixmap.transformed(transform)
开发者ID:petervaro,项目名称:coublet,代码行数:7,代码来源:vars.py

示例5: init

    def init (self):
        self.m_scaleX = self.width() / self.m_originalWidth
        self.m_scaleY = self.height() / self.m_originalHeight


        self.m_itemHand = QGraphicsSvgItem(":/qfi/images/vsi/vsi_hand.svg")
        self.m_itemHand.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemHand.setZValue( self.m_handZ )
        self.m_itemHand.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemHand.setTransformOriginPoint( self.m_originalVsiCtr )
        self.m_scene.addItem (self.m_itemHand)

        self.m_itemFace = QGraphicsSvgItem(":/qfi/images/vsi/vsi_face.svg")
        self.m_itemFace.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemFace.setZValue( self.m_faceZ )
        self.m_itemFace.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemFace.setTransformOriginPoint( self.m_originalVsiCtr )
        self.m_scene.addItem (self.m_itemFace)


        self.m_itemCase = QGraphicsSvgItem(":/qfi/images/vsi/vsi_case.svg")
        self.m_itemCase.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemCase.setZValue( self.m_caseZ )
        self.m_itemCase.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemCase.setTransformOriginPoint( self.m_originalVsiCtr )
        self.m_scene.addItem (self.m_itemCase)

        self.centerOn (self.width()/2, self.height()/2)

        self.updateView()
开发者ID:JdeRobot,项目名称:ThirdParty,代码行数:30,代码来源:qfi_VSI.py

示例6: wind_icon_direction

 def wind_icon_direction(self):
     transf = QTransform()
     angle = self.weatherdata['Wind'][2]
     logging.debug('Wind degrees direction: ' + angle)
     transf.rotate(int(float(angle)))
     rotated = self.wind_icon.transformed(transf, mode=Qt.SmoothTransformation)
     self.wind_icon_label.setPixmap(rotated)
开发者ID:pmattern,项目名称:meteo-qt,代码行数:7,代码来源:overview.py

示例7: paintEvent

    def paintEvent(self, event):
        """QToolBar.paintEvent reimplementation
        Draws buttons, dock icon and text
        """
        rect = self._spacer.rect()

        painter = QPainter(self)

        transform = QTransform()
        transform.translate(self._spacer.pos().x(), self._spacer.pos().y())
        painter.setTransform(transform)

        """ Not supported currently
        if  self._dock.features() & QDockWidget.DockWidgetVerticalTitleBar :
            transform = QTransform()

            rect.setSize(QSize(rect.height(), rect.width()))
            transform.rotate(-90)
            transform.translate(-rect.width(), 0)

            painter.setTransform(transform)
        """

        # icon / title
        optionB = QStyleOptionButton()
        optionB.initFrom(self._dock)
        optionB.rect = rect
        optionB.text = self._dock.windowTitle()
        optionB.iconSize = self.iconSize()
        optionB.icon = self._dock.windowIcon()

        self.style().drawControl(QStyle.CE_PushButtonLabel, optionB, painter, self._dock)
开发者ID:gpa14,项目名称:enki,代码行数:32,代码来源:dockwidget.py

示例8: _get_selected_edge

    def _get_selected_edge(self, pos: QPointF, transform: QTransform, horizontal_selection: bool):
        x1, x2 = self.x, self.x + self.width
        y1, y2 = self.y, self.y + self.height
        x, y = pos.x(), pos.y()

        spacing = 5
        spacing /= transform.m11() if horizontal_selection else transform.m22()

        if horizontal_selection:
            x1a, x1b = x1 - spacing, x1 + spacing
            y1a, y1b = y1, y2
            x2a, x2b = x2 - spacing, x2 + spacing
            y2a, y2b = y1, y2
        else:
            x1a, x1b, x2a, x2b = x1, x2, x1, x2
            y1a, y1b = min(y1 - spacing, y1 + spacing), max(y1 - spacing, y1 + spacing)
            y2a, y2b = min(y2 - spacing, y2 + spacing), max(y2 - spacing, y2 + spacing)

        if x1a < x < x1b and y1a < y < y1b:
            self.selected_edge = 0
            return 0

        if x2a < x < x2b and y2a < y < y2b:
            self.selected_edge = 1
            return 1

        self.selected_edge = None
        return None
开发者ID:jopohl,项目名称:urh,代码行数:28,代码来源:Selection.py

示例9: rotate

    def rotate(self):
        t = QTransform()

        # for x in range (0, 150):
        t.rotate(-1)
        self.label.setPixmap(self.label.pixmap().transformed(t))


        print("FINISHED")
开发者ID:MHiggs13,项目名称:pBlob,代码行数:9,代码来源:TestGUI.py

示例10: mapTextureBasedOnZoom

 def mapTextureBasedOnZoom(self, brush):
     if brush.texture().width() > 0 and brush.texture().height() > 0:
         brush_trans = QTransform()
         brush_trans.translate(self.__center_x - self.__width * 0.5,
                 self.__center_y - self.__height * 0.5)
         brush_trans.scale(self.__width/float(brush.texture().width()),
                 self.__height/float(brush.texture().height()))
         brush.setTransform(brush_trans)
 
     self.setBrush(brush)
开发者ID:dtdavi1,项目名称:acs_dashboards,代码行数:10,代码来源:mapGraphicsIcon.py

示例11: zoom

 def zoom(self, factor, pos):
     self.recenter(pos)
     p = self._transform.inverted()[0].map(self.rect().center())
     test = QTransform(self._transform)
     test.scale(factor, factor)
     # check if the bounding rectangle does not enclose the view
     # refuse to zoom out (factor < 1) if this is the case
     # XXX TODO
     self._transform.scale(factor, factor)
     self.recenter(p, True)
开发者ID:olegizyumin1987,项目名称:pyschem,代码行数:10,代码来源:view.py

示例12: rotatePlayer

    def rotatePlayer(self, direction):
        """
        Function responsible for rotating players icon.
        """

        rotation = QTransform()

        if direction == 'up':
            rotation.rotate(0)
        elif direction == 'right':
            rotation.rotate(90)
        elif direction == 'down':
            rotation.rotate(180)
        elif direction == 'left':
            rotation.rotate(270)

        self.use_this_pixmap = \
            self.nurse_pixmap_base.transformed(rotation)
        self.nurse_pixmap = \
            self.nurse_pixmap_base.transformed(rotation)
        self.nurse_left_pixmap = \
            self.nurse_left_pixmap_base.transformed(rotation)
        self.nurse_right_pixmap = \
            self.nurse_right_pixmap_base.transformed(rotation)

        """
开发者ID:wieloranski,项目名称:experiNurse,代码行数:26,代码来源:board.py

示例13: resizeEvent

 def resizeEvent(self, event):
     self.setUpdatesEnabled(False)
     super().resizeEvent(event)
     # center scene in viewport
     r = self.rect()
     t = QTransform()
     t.translate(-r.width() / 2, -r.height() / 2)
     r = QRectF(QPointF(r.x(), r.y()) * t, QSizeF(r.width(), r.height()))
     self.setSceneRect(r)
     self.__resizeDelayTimer.start(self.resizeUpdateDelay)
     self.setUpdatesEnabled(True)
开发者ID:Manko10,项目名称:WekaVisualizer,代码行数:11,代码来源:StarPlot.py

示例14: transform

 def transform(self):
     try:
         return self.__dict__['transform'] if self.scale else QTransform()
     except KeyError:
         transform = QTransform()
         image = self.client.image
         if image is not None and not image.isNull():
             scale = min(self.width()/image.width(), self.height()/image.height())
             transform.translate((self.width() - image.width()*scale)/2, (self.height() - image.height()*scale)/2)
             transform.scale(scale, scale)
             transform = self.__dict__.setdefault('transform', transform)
         return transform
开发者ID:AGProjects,项目名称:blink-qt,代码行数:12,代码来源:vncviewer.py

示例15: visibleIn

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)
开发者ID:theall,项目名称:Python-Tiled,代码行数:12,代码来源:mapdocument.py


注:本文中的PyQt5.QtGui.QTransform类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。