本文整理汇总了Python中PySide.QtGui.QPainterPath.currentPosition方法的典型用法代码示例。如果您正苦于以下问题:Python QPainterPath.currentPosition方法的具体用法?Python QPainterPath.currentPosition怎么用?Python QPainterPath.currentPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPainterPath
的用法示例。
在下文中一共展示了QPainterPath.currentPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reshape
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import currentPosition [as 别名]
def reshape(self):
''' Update the shape of the edge (redefined function) '''
path = QPainterPath()
# If there is a starting point, draw a line to the first curve point
if self.start_point:
path.moveTo(self.source_connection.center)
path.lineTo(self.bezier[0])
else:
path.moveTo(self.source_connection.center)
# Loop over the curve points:
for group in self.bezier[1:]:
path.cubicTo(*[point.center for point in group])
# If there is an ending point, draw a line to it
if self.end_point:
path.lineTo(self.end_connection.center)
end_point = path.currentPosition()
arrowhead = self.angle_arrow(path)
path.lineTo(arrowhead[0])
path.moveTo(end_point)
path.lineTo(arrowhead[1])
path.moveTo(end_point)
try:
# Add the transition label, if any (none for the START edge)
font = QFont('arial', pointSize=8)
metrics = QFontMetrics(font)
label = self.edge.get('label', '') or ''
lines = label.split('\n')
width = metrics.width(max(lines)) # longest line
height = metrics.height() * len(lines)
# lp is the position of the center of the text
pos = self.mapFromScene(*self.edge['lp'])
if not self.text_label:
self.text_label = QGraphicsTextItem(
self.edge.get('label', ''), parent=self)
self.text_label.setX(pos.x() - width / 2)
self.text_label.setY(pos.y() - height / 2)
self.text_label.setFont(font)
# Make horizontal center alignment, as dot does
self.text_label.setTextWidth(
self.text_label.boundingRect().width())
fmt = QTextBlockFormat()
fmt.setAlignment(Qt.AlignHCenter)
cursor = self.text_label.textCursor()
cursor.select(QTextCursor.Document)
cursor.mergeBlockFormat(fmt)
cursor.clearSelection()
self.text_label.setTextCursor(cursor)
self.text_label.show()
except KeyError:
# no label
pass
self.setPath(path)
示例2: reshape
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import currentPosition [as 别名]
def reshape(self):
''' Update the shape of the edge (redefined function) '''
path = QPainterPath()
# If there is a starting point, draw a line to the first curve point
if self.start_point:
path.moveTo(self.source_connection.center)
path.lineTo(self.bezier[0])
else:
path.moveTo(self.source_connection.center)
# Loop over the curve points:
for group in self.bezier[1:]:
path.cubicTo(*[point.center for point in group])
# If there is an ending point, draw a line to it
if self.end_point:
path.lineTo(self.end_connection.center)
end_point = path.currentPosition()
arrowhead = self.angle_arrow(path)
path.lineTo(arrowhead[0])
path.moveTo(end_point)
path.lineTo(arrowhead[1])
path.moveTo(end_point)
try:
# Add the transition label, if any (none for the START edge)
font = QFont('arial', pointSize=8)
width = QFontMetrics(font).width(
self.edge.get('label', 0))
pos = self.mapFromScene(*self.edge['lp'])
#path.addText(pos.x() - width/2, pos.y(),
# font, self.edge['label'])
if not self.text_label:
self.text_label = QGraphicsTextItem(
self.edge.get('label', ''), parent=self)
self.text_label.setX(pos.x() - width / 2)
self.text_label.setY(pos.y())
self.text_label.setFont(font)
self.text_label.show()
except KeyError:
# no label
pass
self.setPath(path)
示例3: PolylineObject
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import currentPosition [as 别名]
#.........这里部分代码省略.........
:param `widget`: TOWRITE
:type `widget`: `QWidget`_
"""
objScene = self.scene() # QGraphicsScene*
if not objScene:
return
paintPen = self.pen() # QPen
painter.setPen(paintPen)
self.updateRubber(painter)
if option.state & QStyle.State_Selected:
paintPen.setStyle(Qt.DashLine)
if objScene.property(ENABLE_LWT): # .toBool()
paintPen = self.lineWeightPen()
painter.setPen(paintPen)
painter.drawPath(self.normalPath)
if (objScene.property(ENABLE_LWT) and objScene.property(ENABLE_REAL)): # .toBool()
self.realRender(painter, self.normalPath)
def updateRubber(self, painter=None):
"""
TOWRITE
:param `painter`: TOWRITE
:type `painter`: `QPainter`_
"""
rubberMode = self.objectRubberMode() # int
if rubberMode == OBJ_RUBBER_POLYLINE:
self.setObjectPos(self.objectRubberPoint("POLYLINE_POINT_0"))
rubberLine = QLineF(self.normalPath.currentPosition(), self.mapFromScene(self.objectRubberPoint("")))
if painter:
self.drawRubberLine(rubberLine, painter, "VIEW_COLOR_CROSSHAIR")
ok = False # bool
numStr = self.objectRubberText("POLYLINE_NUM_POINTS") # QString
if not numStr:
return
try:
num = int(numStr)
except ValueError:
return
appendStr = '' # QString
rubberPath = QPainterPath()
for i in range(1, num): # for(int i = 1; i <= num; i++)
appendStr = "POLYLINE_POINT_" + "%s" % i # QString().setNum(i);
appendPoint = self.mapFromScene(self.objectRubberPoint(appendStr)) # QPointF
rubberPath.lineTo(appendPoint)
self.updatePath(rubberPath)
# Ensure the path isn't updated until the number of points is changed again.
self.setObjectRubberText("POLYLINE_NUM_POINTS", "")
elif rubberMode == OBJ_RUBBER_GRIP:
if painter:
elemCount = self.normalPath.elementCount() # int
gripPoint = self.objectRubberPoint("GRIP_POINT") # QPointF