當前位置: 首頁>>代碼示例>>Python>>正文


Python QtCore.QPointF方法代碼示例

本文整理匯總了Python中PyQt4.QtCore.QPointF方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QPointF方法的具體用法?Python QtCore.QPointF怎麽用?Python QtCore.QPointF使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt4.QtCore的用法示例。


在下文中一共展示了QtCore.QPointF方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generatePicture

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
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='w', 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() 
開發者ID:sunshinelover,項目名稱:chanlun,代碼行數:18,代碼來源:demoUi.py

示例2: generatePicture

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
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() 
開發者ID:zhengwsh,項目名稱:InplusTrader_Linux,代碼行數:18,代碼來源:uiBasicWidget.py

示例3: doAction

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
def doAction(self, redo):

        if (redo and self.addGuide) or (not redo and not self.addGuide):
            self.scene.guides.append(self.guide)
            self.scene.addItem(self.guide)
            
            if self.scene.guides.__len__() > 1:
                cg = self.guide.pos() 
                for g in self.scene.guides:
                    lg = g.pos()  
                    if self.guide.orientation == g.orientation:
                        if g.orientation == LicLayout.Horizontal:
                            if cg[1] == lg[1]:
                                cg = QPointF(cg[0], cg[1] + LicLayout.PageDefaultMargin)
                        elif g.orientation == LicLayout.Vertical:
                            if cg[0] == lg[0]:
                                cg = QPointF(cg[0] + LicLayout.PageDefaultMargin, cg[1])
                self.guide.setPos(cg)
        else:
            self.scene.removeItem(self.guide)
            self.scene.guides.remove(self.guide) 
開發者ID:remig,項目名稱:lic,代碼行數:23,代碼來源:LicUndoActions.py

示例4: getPolygon

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
def getPolygon(self, obj):
        poly = QtGui.QPolygonF()
        for pt in obj.polygon:
            point = QtCore.QPointF(pt.x,pt.y)
            poly.append( point )
        return poly

    # Draw the labels in the given QPainter qp
    # optionally provide a list of labels to ignore 
開發者ID:pierluigiferrari,項目名稱:fcn8s_tensorflow,代碼行數:11,代碼來源:cityscapesLabelTool.py

示例5: updateMousePos

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
def updateMousePos( self, mousePosOrig ):
        if self.config.zoomFactor <= 1 or (self.drawPolyClosed or self.drawPoly.isEmpty()):
            sens = 1.0
        else :
            sens = 1.0/pow(self.config.zoomFactor, 3);

        if self.config.zoom and self.mousePosOnZoom is not None:
            mousePos       = QtCore.QPointF(round((1-sens)*self.mousePosOnZoom.x() + (sens)*mousePosOrig.x()), round((1-sens)*self.mousePosOnZoom.y() + sens*mousePosOrig.y()))
        else :
            mousePos       = mousePosOrig
        mousePosScaled = QtCore.QPointF( float(mousePos.x() - self.xoff) / self.scale , float(mousePos.y() - self.yoff) / self.scale )
        mouseOutsideImage = not self.image.rect().contains( mousePosScaled.toPoint() )

        mousePosScaled.setX( max( mousePosScaled.x() , 0. ) )
        mousePosScaled.setY( max( mousePosScaled.y() , 0. ) )
        mousePosScaled.setX( min( mousePosScaled.x() , self.image.rect().right() ) )
        mousePosScaled.setY( min( mousePosScaled.y() , self.image.rect().bottom() ) )

        if not self.image.rect().contains( mousePosScaled.toPoint() ):
            self.mousePos = None
            self.mousePosScaled = None
            self.mousePosOrig = None
            self.updateMouseObject()
            self.update()
            return

        self.mousePos          = mousePos
        self.mousePosScaled    = mousePosScaled
        self.mousePosOrig      = mousePosOrig
        self.mouseOutsideImage = mouseOutsideImage

    # Toggle the zoom and update all mouse positions 
開發者ID:pierluigiferrari,項目名稱:fcn8s_tensorflow,代碼行數:34,代碼來源:cityscapesLabelTool.py

示例6: getClosestPoint

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
def getClosestPoint( self, poly, pt ):
        closest = (-1,-1)
        distTh    = 4.0
        dist      = 1e9 # should be enough
        for i in range(poly.size()):
            curDist = self.ptDist(poly[i],pt)
            if curDist < dist:
                closest = (i,i)
                dist = curDist
        # Close enough?
        if dist <= distTh:
            return closest

        # Otherwise see if the polygon is closed, but a line is close enough
        if self.drawPolyClosed and poly.size() >= 2:
            for i in range(poly.size()):
                pt1 = poly[i]
                j = i+1
                if j == poly.size():
                    j = 0
                pt2 = poly[j]
                edge = QtCore.QLineF(pt1,pt2)
                normal = edge.normalVector()
                normalThroughMouse = QtCore.QLineF( pt.x(),pt.y(),pt.x()+normal.dx(),pt.y()+normal.dy() )
                intersectionPt = QtCore.QPointF()
                intersectionType = edge.intersect( normalThroughMouse , intersectionPt )
                if intersectionType == QtCore.QLineF.BoundedIntersection:
                    curDist = self.ptDist(intersectionPt,pt)
                    if curDist < dist:
                        closest = (i,j)
                        dist = curDist

        # Close enough?
        if dist <= distTh:
            return closest

        # If we didnt return yet, we didnt find anything
        return (-1,-1)

    # Get distance between two points 
開發者ID:pierluigiferrari,項目名稱:fcn8s_tensorflow,代碼行數:42,代碼來源:cityscapesLabelTool.py

示例7: mouseMoveEvent

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
def mouseMoveEvent(self,event):
        if self.image.isNull() or self.w == 0 or self.h == 0:
            return

        mousePosOrig = QtCore.QPointF( event.x() , event.y() )
        mousePosScaled = QtCore.QPointF( float(mousePosOrig.x() - self.xoff) / self.scale , float(mousePosOrig.y() - self.yoff) / self.scale )
        mouseOutsideImage = not self.image.rect().contains( mousePosScaled.toPoint() )

        mousePosScaled.setX( max( mousePosScaled.x() , 0. ) )
        mousePosScaled.setY( max( mousePosScaled.y() , 0. ) )
        mousePosScaled.setX( min( mousePosScaled.x() , self.image.rect().right() ) )
        mousePosScaled.setY( min( mousePosScaled.y() , self.image.rect().bottom() ) )

        if not self.image.rect().contains( mousePosScaled.toPoint() ):
            print(self.image.rect())
            print(mousePosScaled.toPoint())
            self.mousePosScaled = None
            self.mousePosOrig = None
            self.updateMouseObject()
            self.update()
            return

        self.mousePosScaled    = mousePosScaled
        self.mousePosOrig      = mousePosOrig
        self.mouseOutsideImage = mouseOutsideImage

        # Redraw
        self.updateMouseObject()
        self.update()

    # Mouse left the widget 
開發者ID:pierluigiferrari,項目名稱:fcn8s_tensorflow,代碼行數:33,代碼來源:cityscapesViewer.py

示例8: mouseMoveEvent

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
def mouseMoveEvent(self,event):
        if self.image.isNull() or self.w == 0 or self.h == 0:
            return

        mousePosOrig = QtCore.QPointF( event.x() , event.y() )
        mousePosScaled = QtCore.QPointF( float(mousePosOrig.x() - self.xoff) / self.scale , float(mousePosOrig.y() - self.yoff) / self.scale )
        mouseOutsideImage = not self.image.rect().contains( mousePosScaled.toPoint() )

        mousePosScaled.setX( max( mousePosScaled.x() , 0. ) )
        mousePosScaled.setY( max( mousePosScaled.y() , 0. ) )
        mousePosScaled.setX( min( mousePosScaled.x() , self.image.rect().right() ) )
        mousePosScaled.setY( min( mousePosScaled.y() , self.image.rect().bottom() ) )

        if not self.image.rect().contains( mousePosScaled.toPoint() ):
            print self.image.rect()
            print mousePosScaled.toPoint()
            self.mousePosScaled = None
            self.mousePosOrig = None
            self.updateMouseObject()
            self.update()
            return

        self.mousePosScaled    = mousePosScaled
        self.mousePosOrig      = mousePosOrig
        self.mouseOutsideImage = mouseOutsideImage

        # Redraw
        self.updateMouseObject()
        self.update()

    # Mouse left the widget 
開發者ID:renmengye,項目名稱:rec-attend-public,代碼行數:33,代碼來源:cityscapesViewer.py

示例9: findPointF

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
def findPointF(self, name):
		return self._findPoint(name, QPointF, float) 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:4,代碼來源:xmlelement.py

示例10: __init__

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
def __init__(self, parent=None, collapsed=False):
            QtGui.QFrame.__init__(self, parent=parent)

            self.setMaximumSize(24, 24)

            # horizontal == 0
            self._arrow_horizontal = (QtCore.QPointF(7.0, 8.0), QtCore.QPointF(17.0, 8.0), QtCore.QPointF(12.0, 13.0))
            # vertical == 1
            self._arrow_vertical = (QtCore.QPointF(8.0, 7.0), QtCore.QPointF(13.0, 12.0), QtCore.QPointF(8.0, 17.0))
            # arrow
            self._arrow = None
            self.setArrow(int(collapsed)) 
開發者ID:By0ute,項目名稱:pyqt-collapsible-widget,代碼行數:14,代碼來源:FrameLayout.py

示例11: initImgSize

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
def initImgSize(size, glDispID, filename, scale, rotation, partRotation):
    """
    Draw this piece to the already initialized GL Frame Buffer Object, in order to calculate
    its displayed width and height.  These dimensions are required to properly lay out PLIs and CSIs.
    
    Parameters:
        size: Width & height of buffer to render to, in pixels (always square).
        glDispID: The GL Display List ID to be rendered and dimensioned.
        filename: String name of this thing to draw.
        rotation: An [x, y, z] rotation to use for this rendering's default rotation
        partRotation: An extra [x, y, z] rotation to use when rendering this part, or None.
    
    Returns:
        None, if the rendered image has been rendered partially or wholly out of frame.
        Otherwise, returns the (width, height, centerPoint, leftInset, bottomInset) parameters of this image.
    """
    
    # Draw piece to frame buffer, then calculate bounding box
    left, top, right, bottom, leftInset, bottomInset = _getBounds(size, glDispID, filename, scale, rotation, partRotation)
    
    if _checkImgBounds(top, bottom, left, right, size):
        return None  # Drew at least one edge out of bounds - try next buffer size
    
    imgWidth = right - left + 1
    imgHeight = bottom - top
    
    w = (left + (imgWidth / 2)) - (size / 2)
    h = (top + (imgHeight / 2)) - (size / 2)
    imgCenter = QPointF(-w, h - 1)

    return (imgWidth, imgHeight, imgCenter, leftInset, bottomInset) 
開發者ID:remig,項目名稱:lic,代碼行數:33,代碼來源:LicGLHelpers.py

示例12: polygonToCurvedPath

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
def polygonToCurvedPath(polygon, radius):
    
    path = QPainterPath()
    for i, pt in enumerate(polygon):
        
        #TODO: if two points are too close to draw the desired radius, either remove those points or draw at smaller radius
        px, py = polygon[i - 1] if i > 0 else polygon[-1]
        nx, ny = polygon[i + 1] if i < len(polygon) - 1 else polygon[0]
        x, y = pt
        
        if px == x:
            dy = y - py
            r = radius if dy < 0 else -radius
            p1 = QPointF(x, y + r)
        else:
            dx = x - px
            r = radius if dx < 0 else -radius
            p1 = QPointF(x + r, y)
        
        if x == nx:
            dy = y - ny
            r = radius if dy < 0 else -radius
            p2 = QPointF(x, y + r)
        else:
            dx = x - nx
            r = radius if dx < 0 else -radius
            p2 = QPointF(x + r, y)
        
        if i == 0:
            path.moveTo(p1)
        else:
            path.lineTo(p1)
        path.cubicTo(pt, pt, p2)

    path.closeSubpath()
    return path 
開發者ID:remig,項目名稱:lic,代碼行數:38,代碼來源:LicHelpers.py

示例13: round

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QPointF [as 別名]
def round(self):
        bmp = QBitmap(self.size())
        p = QPainter()
        p.begin(bmp)
        p.fillRect(bmp.rect(), Qt.white)
        p.setBrush(QColor(0,0,0))
        p.drawRoundedRect(bmp.rect(), 5, 5)
        p.setPen(QColor(255,255,255,255))
        p.drawPoints(QPointF(self.width()-2,self.height()-1), QPointF(self.width()-1,self.height()-2))
        p.setPen(QColor(0,0,0))
        p.drawPoints(QPointF(0,2),QPointF(3,0),QPointF(2,0),QPointF(1,1))
        p.end()
        self.setMask(bmp) 
開發者ID:l7dpi,項目名稱:openQPA,代碼行數:15,代碼來源:RoundWindow.py


注:本文中的PyQt4.QtCore.QPointF方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。