当前位置: 首页>>代码示例>>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;未经允许,请勿转载。