本文整理汇总了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()
示例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()
示例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)
示例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
示例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
示例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
示例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
示例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
示例9: findPointF
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QPointF [as 别名]
def findPointF(self, name):
return self._findPoint(name, QPointF, float)
示例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))
示例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)
示例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
示例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)