Python PyQt4.QtCore 模块,QRectF() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt4.QtCore.QRectF()

项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def save_View(self):
        outputimg = QtGui.QPixmap(self.view.width(), self.view.height())
        painter = QtGui.QPainter(outputimg)
        targetrect = QtCore.QRectF(0, 0, self.view.width(), self.view.height())
        sourcerect = QtCore.QRect(0, 0, self.view.width(), self.view.height())
        self.view.render(painter, targetrect, sourcerect)
        fname = self.new_scenario[:self.new_scenario.rfind('.')] + '.png'
        fname = QtGui.QFileDialog.getSaveFileName(self, 'Save image file',
                self.scenarios + fname, 'Image Files (*.png *.jpg *.bmp)')
        if fname != '':
            fname = str(fname)
            i = fname.rfind('.')
            if i < 0:
                fname = fname + '.png'
                i = fname.rfind('.')
            outputimg.save(fname, fname[i + 1:])
            try:
                comment = 'View saved to ' + fname[fname.rfind('/') + 1:]
            except:
                comment = 'View saved to ' + fname
            self.view.emit(QtCore.SIGNAL('statusmsg'), comment)
        painter.end()
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def __init__(self):
        QtGui.QGraphicsScene.__init__(self)
        self.exitLoop = False
        self.loopMax = 0
        self.get_config()
        self._gridGroup = None
        self._mgridGroup = None
        self.setBackgroundBrush(QtGui.QColor(self.colors['background']))
        if os.path.exists(self.map_file):
            war = QtGui.QImageReader(self.map_file)
            wa = war.read()
            pixMap = QtGui.QPixmap.fromImage(wa)
        else:
            ratio = abs(self.map_upper_left[1] - self.map_lower_right[1]) / \
                     abs(self.map_upper_left[0] - self.map_lower_right[0])
            pixMap = QtGui.QPixmap(200 * ratio, 200)
            if self.map != '':
                painter = QtGui.QPainter(pixMap)
                brush = QtGui.QBrush(QtGui.QColor('white'))
                painter.fillRect(QtCore.QRectF(0, 0, 200 * ratio, 200), brush)
                painter.setPen(QtGui.QColor('lightgray'))
                painter.drawText(QtCore.QRectF(0, 0, 200 * ratio, 200), QtCore.Qt.AlignCenter,
                                 'Map not found.')
                painter.end()
        self.addPixmap(pixMap)
        w = self.width()
        h = self.height()
        if isinstance(self.line_width, float):
            if self.line_width < 1:
                self.line_width = w * self.line_width
        self.upper_left = [0, 0, self.map_upper_left[1], self.map_upper_left[0]]
        self.lower_right = [w, h, self.map_lower_right[1], self.map_lower_right[0]]
        self.setSceneRect(-w * 0.05, -h * 0.05, w * 1.1, h * 1.1)
        self._positions = {}
        self._setupCoordTransform()
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def save_View(self):
        outputimg = QtGui.QPixmap(self.view.width(), self.view.height())
        painter = QtGui.QPainter(outputimg)
        targetrect = QtCore.QRectF(0, 0, self.view.width(), self.view.height())
        sourcerect = QtCore.QRect(0, 0, self.view.width(), self.view.height())
        self.view.render(painter, targetrect, sourcerect)
        fname = 'worldwindow_view.png'
        fname = QtGui.QFileDialog.getSaveFileName(self, 'Save image file',
                fname, 'Image Files (*.png *.jpg *.bmp)')
        if fname != '':
            fname = str(fname)
            i = fname.rfind('.')
            if i < 0:
                fname = fname + '.png'
                i = fname.rfind('.')
            outputimg.save(fname, fname[i + 1:])
            try:
                comment = 'View saved to ' + fname[fname.rfind('/') + 1:]
            except:
                comment = 'View saved to ' + fname
            self.view.emit(QtCore.SIGNAL('statusmsg'), comment)
        painter.end()
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def __init__(self):
        super(MainWindow, self).__init__()

        self.createActions()
        self.createMenus()
        self.createToolBox()

        self.scene = DiagramScene(self.itemMenu)
        self.scene.setSceneRect(QtCore.QRectF(0, 0, 500, 400))
        self.scene.itemInserted.connect(self.itemInserted)
        self.scene.textInserted.connect(self.textInserted)
        self.scene.itemSelected.connect(self.itemSelected)

        self.createToolbars()

        layout = QtGui.QHBoxLayout()
        layout.addWidget(self.toolBox)
        self.view = QtGui.QGraphicsView(self.scene)
        layout.addWidget(self.view)

        self.widget = QtGui.QWidget()
        self.widget.setLayout(layout)

        self.setCentralWidget(self.widget)
        self.setWindowTitle("Diagramscene")
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def boundingRect(self):
        """
        Override inherited function to enlarge selection of Arrow to include all
        @param flag: The flag to enable or disable Selection
        """
        if not self.sc:  # since this function is called before paint; and scale is unknown
            return QtCore.QRectF(self.startp.x(), self.startp.y(), 1e-9, 1e-9)

        arrowSize = self.arrowSize / self.sc
        extra = arrowSize  # self.pen.width() +

        if self.endp is None:
            dx = cos(self.angle) * self.length / self.sc
            dy = sin(self.angle) * self.length / self.sc

            endp = QtCore.QPointF(self.startp.x() - dx, self.startp.y() + dy)
        else:
            endp = QtCore.QPointF(self.endp.x, -self.endp.y)

        brect = QtCore.QRectF(self.startp,
                              QtCore.QSizeF(endp.x()-self.startp.x(),
                                            endp.y()-self.startp.y())).normalized().adjusted(-extra, -extra, extra, extra)
        return brect
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def paint(self, painter, option, widget=None):
        """
        paint()
        """
        painter.setPen(self.pen)
        demat = painter.deviceTransform()
        self.sc = demat.m11()

        diameter1 = self.diameter / self.sc
        diameter2 = (self.diameter - 4) / self.sc

        rectangle1 = QtCore.QRectF(-diameter1 / 2, -diameter1 / 2, diameter1, diameter1)
        rectangle2 = QtCore.QRectF(-diameter2 / 2, -diameter2 / 2, diameter2, diameter2)
        startAngle1 = 90 * 16
        spanAngle = 90 * 16
        startAngle2 = 270 * 16

        painter.drawEllipse(rectangle1)
        painter.drawEllipse(rectangle2)
        painter.drawPie(rectangle2, startAngle1, spanAngle)

        painter.setBrush(self.color)
        painter.drawPie(rectangle2, startAngle2, spanAngle)
项目:quantdigger    作者:andyzsf    | 项目源码 | 文件源码
def drawSpan(self, painter, rect):
        opt = QStyleOptionSlider()
        QSlider.initStyleOption(self, opt)

        # area
        groove = self.style().subControlRect(QStyle.CC_Slider, opt, QStyle.SC_SliderGroove, self)
        if opt.orientation == QtCore.Qt.Horizontal:
            groove.adjust(0, 0, -1, 0);
        else:
            groove.adjust(0, 0, 0, -1);

        # pen & brush
        painter.setPen(QPen(self.gradientLeftColor, 0))
        if opt.orientation == QtCore.Qt.Horizontal:
            self.setupPainter(painter, opt.orientation, groove.center().x(), groove.top(), groove.center().x(), groove.bottom())
        else:
            self.setupPainter(painter, opt.orientation, groove.left(), groove.center().y(), groove.right(), groove.center().y())

        # draw groove
        intersected = QtCore.QRectF(rect.intersected(groove))
        gradient = QLinearGradient(intersected.topLeft(), intersected.topRight())
        gradient.setColorAt(0, self.gradientLeft)
        gradient.setColorAt(1, self.gradientRight)
        painter.fillRect(intersected, gradient)
项目:cityscapesScripts    作者:mcordts    | 项目源码 | 文件源码
def readFromXMLNode(self, correctionNode):
        if not correctionNode.tag == 'correction':
            return

        typeNode        = correctionNode.find('type')
        self.type       = int(typeNode.text)
        annotationNode  = correctionNode.find('annotation')
        self.annotation = annotationNode.text
        bboxNode        = correctionNode.find('bbox')
        x = float(bboxNode.find('x').text)
        y = float(bboxNode.find('y').text)
        width  = float(bboxNode.find('width').text)
        height = float(bboxNode.find('height').text)
        self.bbox       = QtCore.QRectF(x,y,width,height)

    # Append the information to a node of an XML file
    # Creates an object node with all children and appends to the given node
    # Usually the given node is the root
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def resizeEventVertical(self, event):
        if self.label_pos == TOP:
            y = self.label_font_metrics.height()+self.spacing
            height = y
            self.label_rect = QtCore.QRect(0, 0, self.width(), height)
        elif self.label_pos == BOTTOM:
            y = 0
            height = self.label_font_metrics.height()+self.spacing
            self.label_rect = QtCore.QRect(0, self.height()-height, self.width(), height)
        else:
            y = height = 0
        self.range_rect = QtCore.QRectF((self.width()-self.range_size)/2., self.range_size/2.+y, self.range_size, self.height()-self.range_size-height)
        self.range_range = self.range_rect.y()+4, self.range_rect.height()-8
        pos = QtCore.QPointF(self.range_rect.center().x(), self.get_pos())
        self.slider_rect.moveCenter(pos)
        self.cursor.move(pos.x(), pos.y())
项目:CPNSimulatorGui    作者:chris-kuhr    | 项目源码 | 文件源码
def __init__(self, direction, parent=None):
        '''Create a port

        :param direction:  Port direction: (i)nput, (o)utput, (io) bidirectional.
        :param parent: Parent port place.
        '''
        super(PortItem, self).__init__(QtCore.QRectF(-4.0,-4.0,17.0,17.0), parent)
        self.posChangeCallbacks = []
        self.setBrush(QtGui.QBrush(QtCore.Qt.white))
        self.setFlags(self.ItemIsSelectable | self.ItemIsMovable | self.ItemSendsScenePositionChanges)
        self.label = QtGui.QGraphicsTextItem("", self)
        self.label.setPos(QtCore.QPointF( -4, -7))
        self.direction = direction
        self.setZValue(9)
    #------------------------------------------------------------------------------------------------
项目:CPNSimulatorGui    作者:chris-kuhr    | 项目源码 | 文件源码
def newTokenValue(self):
        '''Accept new token.'''
        if self.portClone is None:
            pos = self.scenePos()
            rect = self.boundingRect()  
            self.tmpToken = None
            self.tokens.append( TokenItem( self.editor, self.tokenDiag.getListEntry(), self.tokenDiag.getCountToken(), QtCore.QRectF( pos.x() + rect.width(), pos.y() , 15.0, 15.0 ),  parent=self ) )
            if self.tokenDiag.getInitMarking():
                self.initMarking = self.tokens[-1].token
            self.place.add(self.tokens[-1].token)
            self.editor.mainWindow.simulator.tokenAdded()
            self.editor.diagramScene.addItem(self.tokens[-1])
    #------------------------------------------------------------------------------------------------
项目:CPNSimulatorGui    作者:chris-kuhr    | 项目源码 | 文件源码
def __init__(self):
        super(QtGui.QMainWindow, self).__init__()    
        self.diagramScene = QtGui.QGraphicsScene(self)  
        uic.loadUi('arrow.ui', self)  
        self.graphicsView.setScene( self.diagramScene )
        t1 = QtGui.QGraphicsRectItem(QtCore.QRectF(20,20,100,50 )) 
        t1.setBrush(QtGui.QBrush(QtCore.Qt.white))
#         t1.setFlag( QtGui.QGraphicsItem.ItemIsSelectable | QtGui.QGraphicsItem.ItemIsMoveable )
        self.diagramScene.addItem(t1) 
        p1 = QtGui.QGraphicsEllipseItem(QtCore.QRectF(200,200,100,50))
        p1.setBrush(QtGui.QBrush(QtCore.Qt.white))
#         p1.setFlags( QtGui.QGraphicsItem.ItemIsSelectable | QtGui.QGraphicsItem.ItemIsMoveable )
        arc1 = ArcItem(self, self.diagramScene)
        arc1.arcLine.setLine(20,20,200,200)
        arc1.setPolygon()
        self.diagramScene.addItem(p1)
        self.show()
        pass
项目:InplusTrader_Linux    作者:zhengwsh    | 项目源码 | 文件源码
def generatePicture(self):
            ## pre-computing a QPicture object allows paint() to run much more quickly,
            ## rather than re-drawing the shapes every time.
            self.picture = QtGui.QPicture()
            p = QtGui.QPainter(self.picture)
            p.setPen(pg.mkPen(color='r', width=0.4))  # 0.4 means w*2
            # w = (self.data[1][0] - self.data[0][0]) / 3.
            w = 0.2
            for (t, open, close, min, max) in self.data:
                p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
                if open > close:
                    p.setBrush(pg.mkBrush('g'))
                else:
                    p.setBrush(pg.mkBrush('r'))
                p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
            p.end()
项目:InplusTrader_Linux    作者:zhengwsh    | 项目源码 | 文件源码
def boundingRect(self):
            ## boundingRect _must_ indicate the entire area that will be drawn on
            ## or else we will get artifacts and possibly crashing.
            ## (in this case, QPicture does all the work of computing the bouning rect for us)
            return QtCore.QRectF(self.picture.boundingRect())

    #----------------------------------------------------------------------
项目:InplusTrader_Linux    作者:zhengwsh    | 项目源码 | 文件源码
def generatePicture(self):
        ## pre-computing a QPicture object allows paint() to run much more quickly,
        ## rather than re-drawing the shapes every time.
        self.picture = QtGui.QPicture()
        p = QtGui.QPainter(self.picture)
        p.setPen(pg.mkPen(color='r', width=0.4))  # 0.4 means w*2
        # w = (self.data[1][0] - self.data[0][0]) / 3.
        w = 0.2
        for (t, open, close, min, max) in self.data:
            p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
            if open > close:
                p.setBrush(pg.mkBrush('g'))
            else:
                p.setBrush(pg.mkBrush('r'))
            p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
        p.end()
项目:InplusTrader_Linux    作者:zhengwsh    | 项目源码 | 文件源码
def boundingRect(self):
        ## boundingRect _must_ indicate the entire area that will be drawn on
        ## or else we will get artifacts and possibly crashing.
        ## (in this case, QPicture does all the work of computing the bouning rect for us)
        return QtCore.QRectF(self.picture.boundingRect())
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def autodRange(self):
        self.plot.setRange(QtCore.QRectF(0, -2, self.maxT, 16))
项目:rec-attend-public    作者:renmengye    | 项目源码 | 文件源码
def drawZoom(self,qp,overlay):
        # Zoom disabled?
        if not self.zoom:
            return
        # No image
        if self.image.isNull() or not self.w or not self.h:
            return
        # No mouse
        if not self.mousePosOrig:
            return

        # Abbrevation for the zoom window size
        zoomSize = self.zoomSize
        # Abbrevation for the mouse position
        mouse = self.mousePosOrig

        # The pixel that is the zoom center
        pix = self.mousePosScaled
        # The size of the part of the image that is drawn in the zoom window
        selSize = zoomSize / ( self.zoomFactor * self.zoomFactor )
        # The selection window for the image
        sel  = QtCore.QRectF(pix.x()  -selSize/2 ,pix.y()  -selSize/2 ,selSize,selSize  )
        # The selection window for the widget
        view = QtCore.QRectF(mouse.x()-zoomSize/2,mouse.y()-zoomSize/2,zoomSize,zoomSize)
        if overlay :
            overlay_scaled = overlay.scaled(self.image.width(), self.image.height())
        else :
            overlay_scaled = QtGui.QImage( self.image.width(), self.image.height(), QtGui.QImage.Format_ARGB32_Premultiplied )

        # Show the zoom image
        qp.save()
        qp.drawImage(view,self.image,sel)
        qp.setOpacity(self.transp)
        qp.drawImage(view,overlay_scaled,sel)
        qp.restore()

    # Draw disparities
项目:cityscapes-api    作者:renmengye    | 项目源码 | 文件源码
def drawZoom(self,qp,overlay):
        # Zoom disabled?
        if not self.zoom:
            return
        # No image
        if self.image.isNull() or not self.w or not self.h:
            return
        # No mouse
        if not self.mousePosOrig:
            return

        # Abbrevation for the zoom window size
        zoomSize = self.zoomSize
        # Abbrevation for the mouse position
        mouse = self.mousePosOrig

        # The pixel that is the zoom center
        pix = self.mousePosScaled
        # The size of the part of the image that is drawn in the zoom window
        selSize = zoomSize / ( self.zoomFactor * self.zoomFactor )
        # The selection window for the image
        sel  = QtCore.QRectF(pix.x()  -selSize/2 ,pix.y()  -selSize/2 ,selSize,selSize  )
        # The selection window for the widget
        view = QtCore.QRectF(mouse.x()-zoomSize/2,mouse.y()-zoomSize/2,zoomSize,zoomSize)
        if overlay :
            overlay_scaled = overlay.scaled(self.image.width(), self.image.height())
        else :
            overlay_scaled = QtGui.QImage( self.image.width(), self.image.height(), QtGui.QImage.Format_ARGB32_Premultiplied )

        # Show the zoom image
        qp.save()
        qp.drawImage(view,self.image,sel)
        qp.setOpacity(self.transp)
        qp.drawImage(view,overlay_scaled,sel)
        qp.restore()

    # Draw disparities
项目:PySCUBA    作者:GGiecold    | 项目源码 | 文件源码
def fitInView(self):
        rect = QtCore.QRectF(self.pixMap.rect())
        if not rect.isNull():
            unity = self.graphicsView.transform().mapRect(
                QtCore.QRectF(0, 0, 1, 1))
            self.graphicsView.scale(1.0 / unity.width(), 1.0 / unity.height())
            view_rect = self.graphicsView.viewport().rect()
            scene_rect = self.graphicsView.transform().mapRect(rect)
            factor = min(view_rect.width() / scene_rect.width(), 
                view_rect.height() / scene_rect.height())
            self.graphicsView.scale(factor, factor)
            self.graphicsView.centerOn(rect.center())
            self.zoom = 0
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def boundingRect(self):
        extra = (self.pen().width() + 20) / 2.0
        p1 = self.line().p1()
        p2 = self.line().p2()
        return QtCore.QRectF(p1, QtCore.QSizeF(p2.x() - p1.x(), p2.y() - p1.y())).normalized().adjusted(-extra, -extra, extra, extra)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def boundingRect(self):
        """
        Override inherited function to enlarge selection of Arrow to include all
        @param flag: The flag to enable or disable Selection
        """
        if not self.sc:  # since this function is called before paint; and scale is unknown
            return QtCore.QRectF(0, 0, 1e-9, 1e-9)

        diameter = self.diameter / self.sc
        return QtCore.QRectF(-diameter / 2, -diameter / 2, diameter, diameter)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def boundingRect(self):
        """
        Required method for painting. Inherited by Painterpath
        @return: Gives the Bounding Box
        """
        rect = self.path.boundingRect().getRect()

        newrect = QtCore.QRectF(self.startp.x()+rect[0]/self.sc,
                                self.startp.y()+rect[1]/self.sc,
                                rect[2]/self.sc,
                                rect[3]/self.sc)
        return newrect
项目:quantdigger    作者:andyzsf    | 项目源码 | 文件源码
def __init__(self):
        super(WindowedPixMapModel, self).__init__()
        #
        self._widget_window = QtCore.QRectF()
        self._pix_map_window = QtCore.QRectF()
        #
        self._pix_map = None
项目:ImgAnnotaPyQt4    作者:ZhengRui    | 项目源码 | 文件源码
def initUI(self):
        self.setGeometry(300, 300, 500, 500)
        self.setWindowTitle('Select by stroke')
        self.gv = QTestView(self)
        self.gv.setMouseTracking(True)
        self.pen = QtGui.QPen(QtGui.QColor(255, 0, 0), 4, QtCore.Qt.SolidLine)
        self.gv.scene.addRect(QtCore.QRectF(0,0,400,400), self.pen)
        self.gv.scene.addItem(QStrokeRect(QtCore.QRectF(100,100,100,100)))
        self.gv.scene.addItem(QStrokeRect(QtCore.QRectF(150,150,100,100)))
项目:ImgAnnotaPyQt4    作者:ZhengRui    | 项目源码 | 文件源码
def mouseMoveEvent(self, event):
        if self._pan:
            self.horizontalScrollBar().setValue(self.horizontalScrollBar().value() - (event.x() - self._panStartX))
            self.verticalScrollBar().setValue(self.verticalScrollBar().value() - (event.y() - self._panStartY))
            self._panStartX = event.x()
            self._panStartY = event.y()

        if self._draw:
            self.scene.removeItem(self._lstRect)
            sceneCoord = self.mapToScene(event.pos())
            tl = QtCore.QPointF(max(min(self._drawStartX, sceneCoord.x())-2, 0), max(min(self._drawStartY, sceneCoord.y())-2, 0))
            br = QtCore.QPointF(min(max(self._drawStartX, sceneCoord.x()-1)+2, self.scene.sceneRect().width()), min(max(self._drawStartY, sceneCoord.y()-1)+2, self.scene.sceneRect().height()))
            self._lstRect = QStrokeRect(QtCore.QRectF(tl, br))
            self._lstRect.setPen(self.pen)
            self._lstRect.setStrokeWidth(6)
            self.scene.addItem(self._lstRect)
            self._moved = True

        event.accept()
        QtGui.QGraphicsView.mouseMoveEvent(self, event)

        sceneCoord = self.mapToScene(event.pos())
        sceneRect = self.scene.sceneRect()
        if sceneRect.contains(sceneCoord):
            self.emit(QtCore.SIGNAL("sendSceneCoord(QString)"), QtCore.QString('{:04.2f}, {:04.2f}'.format(sceneCoord.x(), sceneCoord.y())))
            if not self._pan and not self._draw:
                self.selItem = self.scene.itemAt(sceneCoord)
                if self.selItem is not None and self.selItem.type() != 7:   # 7 is QGraphicsPixmapItem
                    self.viewport().setCursor(QtCore.Qt.ArrowCursor)
                    self._sel = True
                else:
                    self.viewport().setCursor(QtCore.Qt.CrossCursor)
                    self._sel = False
        else:
            self.emit(QtCore.SIGNAL("sendSceneCoord(QString)"), '')
项目:ImgAnnotaPyQt4    作者:ZhengRui    | 项目源码 | 文件源码
def showBaseRects(self):
        for rect in self._baseRects:
            self._lstRect = QStrokeRect(QtCore.QRectF(rect[1], rect[2], rect[3], rect[4]))
            cateid = int(rect[0])
            self._lstRect.setPen(QtGui.QPen(QtGui.QColor(int(255*self.cmap[cateid][0]), int(255*self.cmap[cateid][1]), int(255*self.cmap[cateid][2])), self.penwidth, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
            self._lstRect.cateid = cateid
            self._lstRect.setStrokeWidth(6)
            self.scene.addItem(self._lstRect)
项目:cityscapesScripts    作者:mcordts    | 项目源码 | 文件源码
def drawZoom(self,qp,overlay):
        # Zoom disabled?
        if not self.zoom:
            return
        # No image
        if self.image.isNull() or not self.w or not self.h:
            return
        # No mouse
        if not self.mousePosOrig:
            return

        # Abbrevation for the zoom window size
        zoomSize = self.zoomSize
        # Abbrevation for the mouse position
        mouse = self.mousePosOrig

        # The pixel that is the zoom center
        pix = self.mousePosScaled
        # The size of the part of the image that is drawn in the zoom window
        selSize = zoomSize / ( self.zoomFactor * self.zoomFactor )
        # The selection window for the image
        sel  = QtCore.QRectF(pix.x()  -selSize/2 ,pix.y()  -selSize/2 ,selSize,selSize  )
        # The selection window for the widget
        view = QtCore.QRectF(mouse.x()-zoomSize/2,mouse.y()-zoomSize/2,zoomSize,zoomSize)
        if overlay :
            overlay_scaled = overlay.scaled(self.image.width(), self.image.height())
        else :
            overlay_scaled = QtGui.QImage( self.image.width(), self.image.height(), QtGui.QImage.Format_ARGB32_Premultiplied )

        # Show the zoom image
        qp.save()
        qp.drawImage(view,self.image,sel)
        qp.setOpacity(self.transp)
        qp.drawImage(view,overlay_scaled,sel)
        qp.restore()

    # Draw disparities
项目:cityscapesScripts    作者:mcordts    | 项目源码 | 文件源码
def mouseMoveEvent(self,event):
        if self.image.isNull() or self.w == 0 or self.h == 0:
            return

        self.updateMousePos( event.posF() )

        if not self.config.correctionMode:
            # If we are dragging a point, update
            if self.draggedPt >= 0:
                # Update the dragged point
                self.drawPoly.replace( self.draggedPt , self.mousePosScaled )
                # If the polygon is the polygon of the selected object,
                # update the object polygon and
                # keep track of the changes we do
                if self.selObjs:
                    obj = self.annotation.objects[self.selObjs[-1]]
                    obj.polygon[self.draggedPt] = Point(self.mousePosScaled.x(),self.mousePosScaled.y())
                    # Check if we changed the object's polygon the first time
                    if not obj.id in self.changedPolygon:
                        self.changedPolygon.append(obj.id)
                        self.addChange( "Changed polygon of object {0} with label {1}".format( obj.id, obj.label ) )
        else:
            if self.in_progress_bbox is not None:
                p0 = (self.mousePosScaled.x(), self.mousePosScaled.y())
                p1 = (self.mousePressEvent.x(), self.mousePressEvent.y())
                xy = min(p0[0], p1[0]), min(p0[1], p1[1])
                w, h = abs(p0[0] - p1[0]), abs(p0[1] - p1[1])
                self.in_progress_bbox = QtCore.QRectF(xy[0], xy[1], w, h)
            #p.set_x(xy[0])
            #p.set_y(xy[1])
            #p.set_width(w)
            #p.set_height(h)

        # Update the object selected by the mouse
        self.updateMouseObject()

        # Redraw
        self.update()

    # Mouse left the widget
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        QtGui.QCheckBox.__init__(self, *args, **kwargs)
        self.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Minimum)
        self.square = QtCore.QRectF()
        self.setChecked(True)
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def resizeEvent(self, event):
        self.square = QtCore.QRectF(self.width()/2.-5, self.height()/2.-5, 10, 10)
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def pageUpdate(self):
        size = self.device.paperRect(1)
        margins = self.device.getPageMargins(1)
        self.setRect(QtCore.QRectF(0, 0, size.width(), size.height()))
        self.text_rect = self.rect().adjusted(margins[0], margins[1], -margins[2], -margins[3])
        self.compute_metrics()
        self.update()
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def __init__(self):
        QtGui.QWidget.__init__(self)
        size = 24
        self.setFixedSize(size, size)
        self.pen_width = 5
        top = left = self.pen_width / 2.
        bottom = right = size - 1 - self.pen_width
        self.area = QtCore.QRectF(top, left, right, bottom)
        self.brush = QtGui.QConicalGradient(.5, .5, 0)
        self.brush.setCoordinateMode(QtGui.QConicalGradient.ObjectBoundingMode)
        self.brush.setColorAt(0, QtCore.Qt.darkGray)
        self.brush.setColorAt(1, QtCore.Qt.lightGray)
        self.pen = QtGui.QPen(self.brush, self.pen_width)

        self.loading_timer = QtCore.QTimer()
        self.loading_timer.setInterval(20)
        self.loading_timer.timeout.connect(self.rotate)
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def boundingRect(self):
        return QtCore.QRectF(0, 0, self.base_x+self.base_width+1, self.base_height)
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def resizeEvent(self, event):
        full_rect = self.label_rect.united(self.path_rect)
        diff = QtCore.QRectF(0, 0, self.width(), self.height()).center()-full_rect.center()
        self.base_translate = QtCore.QPointF(diff.x(), diff.y())
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def resizeEvent(self, event):
        if self.max_width:
            x = (self.width()-1-self.max_width)/2.
            width = self.max_width
        else:
            x = 0
            width = self.width()-1
        if self.max_height:
            y = (self.height()-1-self.max_height)/2.
            height = self.max_height
        else:
            y = 0
            height = self.height()-1
        self.rect = QtCore.QRectF(x, y, width, height)
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def resizeEventHorizontal(self, event):
        if self.label_pos == TOP:
            y = self.label_font_metrics.height()+self.spacing
            height = y
            self.label_rect = QtCore.QRect(0, 0, self.width(), height)
        elif self.label_pos == BOTTOM:
            y = 0
            height = self.label_font_metrics.height()+self.spacing
            self.label_rect = QtCore.QRect(0, self.height()-height, self.width(), height)
        else:
            y = height = 0
            x = width = 0
        self.range_rect = QtCore.QRectF(self.range_size/2.+x, (self.height()-self.range_size)/2., self.width()-self.range_size-width, self.range_size)
        self.range_range = self.range_rect.x()+4, self.range_rect.width()-8
        pos = QtCore.QPointF(self.get_pos(), self.range_rect.center().y())
        self.slider_rect.moveCenter(pos)
        self.cursor.move(pos.x(), pos.y())
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def resizeEvent(self, event):
        self.fgd_rect = QtCore.QRectF(1, 1, self.width()-self.padding*2-1, self.height()-self.padding*2-1)
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def __init__(self, parent, mode=ADSR, show_points=True):
        QtGui.QWidget.__init__(self, parent)
        self.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Preferred)
        self.mode = mode
        self.show_points = show_points
        self.setContentsMargins(2, 2, 2, 2)
        self.setMinimumSize(68, 40)
        self.attack = 127
        self.attack_level = 127
        self.decay = 127
        self.sustain = 64
        self.decay2 = 127
        self.sustain2 = 64
        self.release = 64
        self.attack_point = None
        self.decay_point = None
        self.sustain_point = None
        self.decay2_point = None
        self.sustain2_point = None
        self.release_end = None
        self.envelope = None
        self.current_cursor = self.current_delta = self.hover_point = None
        self.font_metrics = QtGui.QFontMetrics(QtGui.QFont('Droid Sans', 10, QtGui.QFont.Bold))
        self.create_cursors()
        self.reset_envelope()
        self.env_rect = QtCore.QRectF(12, 4, self.width()-25, self.height()-9)
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def resizeEvent(self, event):
#        print self.height(), event.size().height()
        self.outer = QtCore.QRectF(0, 0, self.width()-1, self.height()-1)
        self.display = QtCore.QRectF(2, 2, self.width()-5, self.height()-5)
        self.env_rect = QtCore.QRectF(12, 4, self.width()-25, self.height()-9)

        self.attack_limit = self.env_rect.width()*self.attack_range
        self.compute_envelope()
        self.decay_limit = self.env_rect.width()*self.attack_range+self.env_rect.width()*self.decay_range
#        if self.decay2_point is not None:
        if self.mode in [ADS1DS2R, LOOPALL, LOOPS1S2]:
            self.decay2_limit = self.env_rect.width()*self.attack_range+self.env_rect.width()*2*self.decay_range
        else:
            self.decay2_limit = 0
#        self.sustain_limit = self.attack_limit+self.decay_limit+self.decay2_limit
        self.move_cursors()
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def __init__(self, parent=None):
        QtGui.QGraphicsWidget.__init__(self, parent)
        self.setAcceptHoverEvents(True)
        self.rect = QtCore.QRectF(0, 35, 40, 10)
        self.top_rect = QtCore.QRectF(0, 25, 40, 10)
        self.bottom_rect = QtCore.QRectF(0, 45, 40, 10)
        self.left_rect = QtCore.QRectF(0, 35, 10, 10)
        self.right_rect = QtCore.QRectF(30, 35, 10, 10)
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def boundingRect(self):
        return QtCore.QRectF(0, 0, 820, self.height)
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def boundaries(self):
        return QtCore.QRectF(self.bound_ref[0].x(), 0, self.bound_ref[1].x()+self.bound_ref[1].boundingRect().width(), self.bound_ref[1].y()+self.bound_ref[1].boundingRect().height())
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def resizeEvent(self, event):
        width = self.width()
        height = self.height()
        self.border_rect = QtCore.QRect(0, 0, width-1, height-1)
#        self.display_rect = self.border_rect.adjusted(2, 2, -2, -2)
        self.panel.setGeometry(QtCore.QRectF(0, 0, width-2, height-2))
        self.panel.layout().setGeometry(QtCore.QRectF(0, -10, width-2, height-2))

        self.length_widget.setReference(self.layout.itemAt(1, 1), self.layout.itemAt(1, 2))

        self.arp_widget.setY(self.layout.itemAt(1, 1).y())
        self.scene.setSceneRect(self.boundaries())
        ratio = self.step_ratio()
        self.arp_widget.setTransform(QtGui.QTransform.fromScale(ratio, 60/90.))
        self.arp_widget.setX(self.layout.itemAt(1, 1).x()-self.reference_step.x()*ratio)
        self.update()
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def resizeEvent(self, event):
        width = self.width()
        height = self.height()
        self.panel.layout().setGeometry(QtCore.QRectF(0, 0, width-2, height-2))
        self.border_rect = QtCore.QRect(0, 0, width-1, height-1)
        self.display_rect = self.border_rect.adjusted(2, 2, -2, -2)
        self.setSceneRect(0, 0, width-1, height-1)
        bank_geo = self.bank_layout.geometry()
        self.bank_rect = QtCore.QRectF(bank_geo.x()-3, bank_geo.y()-1, bank_geo.width()+6, bank_geo.height()+4)
        prog_geo = self.prog_layout.geometry()
        self.prog_rect = QtCore.QRectF(prog_geo.x()-3, prog_geo.y()-1, prog_geo.width()+6, prog_geo.height()+4)
        cat_geo = self.cat_layout.geometry()
        self.cat_rect = QtCore.QRectF(cat_geo.x()-5, cat_geo.y()-2, cat_geo.width()+7, cat_geo.height()+4)
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        QtGui.QGraphicsView.__init__(self, *args, **kwargs)
        self.setScene(QtGui.QGraphicsScene())
        self.setRenderHints(QtGui.QPainter.Antialiasing)
        self.setBackgroundBrush(QtGui.QColor(32, 32, 32))
        self.boundingRect = QtCore.QRectF()
        self.slice_transform = QtGui.QTransform().shear(0, 1)
        self.delta_x = 8192
        self.delta_y = 12288
        slice0 = QtGui.QGraphicsRectItem(0, 0, 128 * self.delta_x, pow21)
        slice0.setPen(self.cube_pen)
        slice0.setTransform(self.slice_transform)
        slice1 = QtGui.QGraphicsRectItem(0, 0, 128 * self.delta_x, pow21)
        slice1.setPen(self.cube_pen)
        slice1.setZValue(-200)
        slice1.setTransform(self.slice_transform)
        slice1.setPos(63 * self.delta_x, -63 * self.delta_y)
        self.boundingRect = slice0.sceneBoundingRect().united(slice1.sceneBoundingRect())
        height = self.boundingRect.height()
        self.boundingRect.setTop(-height * .25)
        self.boundingRect.setBottom(height * .85)
        self.scene().setSceneRect(self.boundingRect)

        #add nice 3D cube
        self.scene().addItem(slice0)
        self.scene().addItem(slice1)
        l = self.scene().addLine(slice0.sceneBoundingRect().x(), slice0.sceneBoundingRect().y(), slice1.sceneBoundingRect().x(), slice1.sceneBoundingRect().y())
        l.setPen(self.cube_pen)
        l = self.scene().addLine(QtCore.QLineF(slice0.mapToScene(slice0.boundingRect().topRight()), slice1.mapToScene(slice1.boundingRect().topRight())))
        l.setPen(self.cube_pen)
        l = self.scene().addLine(QtCore.QLineF(slice0.mapToScene(slice0.boundingRect().bottomRight()), slice1.mapToScene(slice1.boundingRect().bottomRight())))
        l.setPen(self.cube_pen)
        l = self.scene().addLine(QtCore.QLineF(slice0.mapToScene(slice0.boundingRect().bottomLeft()), slice1.mapToScene(slice1.boundingRect().bottomLeft())))
        l.setZValue(-200)
        l.setPen(self.cube_pen)

        self.currentWave = None
项目:Lookup-Dictionary    作者:GDGVIT    | 项目源码 | 文件源码
def paintEvent(self, ev):
        painter = QtGui.QPainter(self)
    painter.setPen(QtGui.QColor(250, 250, 250))
        gradient = QtGui.QLinearGradient(QtCore.QRectF(self.rect()).topLeft(),QtCore.QRectF(self.rect()).bottomLeft())
        gradient.setColorAt(0.0,QColor(250, 240, 240))#Qt.white)
        gradient.setColorAt(0.4,QColor(250, 240, 240))# QtCore.Qt.white)
        gradient.setColorAt(0.7,QColor(250, 240, 240))# QtCore.Qt.white)
        painter.setBrush(gradient)
        painter.drawRoundedRect(0, 0, 340, 150, 15.0, 15.0)
项目:BTCeTrader    作者:ch3ll0v3k    | 项目源码 | 文件源码
def DRAW_CLASSIC_POINTS(self, Painter):

        # -------------------------------------------------------------------
        Painter.setPen( QPen( QColor("#FFF"), 2 ) );
        Painter.drawPolyline( self.poly( self.CANDLES_POINTS ) );

        Painter.setBrush(QBrush(QColor(255, 255, 255))) # color
        Painter.setPen(QPen(QColor("#F00"), 2)) # circle border diameter

        p = self.CANDLES_POINT_W;

        for x, y in self.CANDLES_POINTS:
            Painter.drawEllipse(QRectF(x - p/2, y - p/2, p, p));

        # -------------------------------------------------------------------

    # =======================================================================
项目:j3dview    作者:blank63    | 项目源码 | 文件源码
def paintGL(self):
        glClearColor(0,0,0,1)
        glClear(GL_COLOR_BUFFER_BIT)
        if self.texture is not None and self.height() != 0 and self.width() != 0:
            s = self.width()/self.height()*self.texture.height/self.texture.width
            if s < 1:
                self.drawTexture(QtCore.QRectF(-1,-s,2,2*s),self.texture.gl_texture)
            else:
                s = self.height()/self.width()*self.texture.width/self.texture.height
                self.drawTexture(QtCore.QRectF(-s,-1,2*s,2),self.texture.gl_texture)
项目:CPNSimulatorGui    作者:chris-kuhr    | 项目源码 | 文件源码
def findItemsInPlanes(self):
        '''Finds the orientation of any other item in the `gui.DiagramScene`.'''
        rect = self.boundingRect()

        sceneRect = self.editor.diagramScene.itemsBoundingRect() 

        for item in self.editor.diagramScene.items( self.mapToScene( QtCore.QRectF( 0, -rect.height(), -sceneRect.width(), -sceneRect.height() ) ), mode=QtCore.Qt.ContainsItemShape ):
            self.checkItem( item, "northWest")
        for item in self.editor.diagramScene.items( self.mapToScene( QtCore.QRectF( 0, -rect.height(), rect.width(), -sceneRect.height() ) ), mode=QtCore.Qt.IntersectsItemShape ):
            self.checkItem( item, "north")     
        for item in self.editor.diagramScene.items( self.mapToScene( QtCore.QRectF( rect.width(), -rect.height(), sceneRect.width(), -sceneRect.height() ) ), mode=QtCore.Qt.ContainsItemShape ):
            self.checkItem( item, "northEast")            
        for item in self.editor.diagramScene.items( self.mapToScene( QtCore.QRectF( rect.width(), 0, sceneRect.width(), -rect.height() ) ), mode=QtCore.Qt.IntersectsItemShape ):
            self.checkItem( item, "east")     
        for item in self.editor.diagramScene.items( self.mapToScene( QtCore.QRectF( rect.width(), 0, +sceneRect.width(), +sceneRect.height() ) ), mode=QtCore.Qt.ContainsItemShape ):
            self.checkItem( item, "southEast") 
        for item in self.editor.diagramScene.items( self.mapToScene( QtCore.QRectF( 0, 0, rect.width(), +sceneRect.height() ) ), mode=QtCore.Qt.IntersectsItemShape ):
            self.checkItem( item, "south") 
        for item in self.editor.diagramScene.items( self.mapToScene( QtCore.QRectF(  0, 0, -sceneRect.width(), +sceneRect.height() ) ), mode=QtCore.Qt.ContainsItemShape ):
            self.checkItem( item, "southWest")
        for item in self.editor.diagramScene.items( self.mapToScene( QtCore.QRectF( 0, 0, -sceneRect.width(), -rect.height() ) ), mode=QtCore.Qt.IntersectsItemShape  ):
            self.checkItem( item, "west")

#         logging.debug("----------------------------------------------------------")
#         logging.debug(self.planeMap)        
#         logging.debug( "---------------------------------------------Planes of %s"%( self.name  ))
#         logging.debug( "plane northWest" )
#         for item in self.planeMap["northWest"]:            
#             logging.debug( item.name )
#         logging.debug( "plane north" )
#         for item in self.planeMap["north"]:
#             logging.debug( item.name )
#         logging.debug( "plane northEast" )
#         for item in self.planeMap["northEast"]:
#             logging.debug( item.name )
#         logging.debug( "plane east" )
#         for item in self.planeMap["east"]:
#             logging.debug( item.name )
#         logging.debug( "plane southEast" )
#         for item in self.planeMap["southEast"]:
#             logging.debug( item.name )
#         logging.debug( "plane south" )
#         for item in self.planeMap["south"]:
#             logging.debug( item.name )
#         logging.debug( "plane southWest" )
#         for item in self.planeMap["southWest"]:
#             logging.debug( item.name )
#         logging.debug( "plane west" )
#         for item in self.planeMap["west"]:
#             logging.debug( item.name )

    #------------------------------------------------------------------------------------------------