本文整理汇总了Python中PyQt4.QtGui.QPolygonF.moveTo方法的典型用法代码示例。如果您正苦于以下问题:Python QPolygonF.moveTo方法的具体用法?Python QPolygonF.moveTo怎么用?Python QPolygonF.moveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QPolygonF
的用法示例。
在下文中一共展示了QPolygonF.moveTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import moveTo [as 别名]
#.........这里部分代码省略.........
fillColor = QString(polygon.xpath('./@fill', namespaces=ns)[0])
# parse root polygon path
path = QPolygonF()
for pair in pointStr.split(' '):
dims = pair.split(',')
point = QPointF( float(dims[0]), float(dims[1]) )
path.append(point)
self.setPolygon(path)
# fill in root node colors
if QColor.isValidColor(penColor):
self.setPen( QColor(penColor) )
if QColor.isValidColor(fillColor):
self.setBrush( QColor(fillColor) )
# build each graph node
for xmlNode in rootNode.xpath('./svg:g', namespaces=ns):
group = QGraphicsRectItem(self)
group.setPen( Qt.transparent )
group.setBrush( Qt.transparent )
if xmlNode.attrib['class'] == 'node':
# find the area object
name = xmlNode.xpath('./svg:title', namespaces=ns)[0].text
group.setData( 0, QString(world.areas[world.areaLookup[name]].id) )
# get the ellipse info
ellipseNode = xmlNode.xpath('./svg:ellipse', namespaces=ns)[0]
elProps = { k: float(ellipseNode.attrib[k]) for k in ['cx', 'cy', 'rx', 'ry']}
rect = QRectF( elProps['cx']-elProps['rx'], elProps['cy']-elProps['ry'], 2*elProps['rx'], 2*elProps['ry'])
penColor = QString(ellipseNode.attrib['stroke'])
ellipseItem = QGraphicsEllipseItem(rect, group)
if QColor.isValidColor(penColor):
ellipseItem.setPen( QColor(penColor) )
# get the text info
textNode = xmlNode.xpath('./svg:text', namespaces=ns)[0]
text = textNode.text
textItem = QGraphicsTextItem(text, group)
penColor = textNode.attrib.get('fill', 'black')
nodePoint = QPointF(float(textNode.attrib['x']), float(textNode.attrib['y']))
textItem.setPos( nodePoint - textItem.boundingRect().center() + QPointF(0.0,-4.0))
if QColor.isValidColor(penColor):
textItem.setDefaultTextColor( QColor(penColor) )
group.setRect( ellipseItem.boundingRect() )
group.setFlags( QGraphicsRectItem.ItemIsSelectable )
elif xmlNode.attrib['class'] == 'edge':
# parse the line portion of the arrow
line = xmlNode.xpath('./svg:path', namespaces=ns)[0]
path = QPainterPath()
# pull info from xml file
linePath = line.attrib['d']
lineColor = line.attrib['stroke']
# parse path coords
points = re.findall( '(-?\d+\.\d+),(-?\d+\.\d+)', linePath )
if len(points) != 4:
continue
startPoint = QPointF( float(points[0][0]), float(points[0][1]) )
path.moveTo(startPoint)
curvePoints = []
for pointCoord in points[1:]:
curvePoints.append( QPointF(float(pointCoord[0]), float(pointCoord[1])) )
path.cubicTo( curvePoints[0], curvePoints[1], curvePoints[2] )
# construct path item
pathItem = QGraphicsPathItem(path, group)
if QColor.isValidColor(lineColor):
pathItem.setPen( QColor(lineColor) )
polyNode = xmlNode.xpath('./svg:polygon', namespaces=ns)[0]
# pull info from xml file
pointStr = polyNode.xpath('./@points', namespaces=ns)[0]
penColor = QString(polyNode.xpath('./@stroke', namespaces=ns)[0])
fillColor = QString(polyNode.xpath('./@fill', namespaces=ns)[0])
# parse polygon path
path = QPolygonF()
for pair in pointStr.split(' '):
dims = pair.split(',')
point = QPointF( float(dims[0]), float(dims[1]) )
path.append(point)
# construct polygon item
polygonItem = QGraphicsPolygonItem(path, group)
if QColor.isValidColor(penColor):
polygonItem.setPen( QColor(penColor) )
if QColor.isValidColor(fillColor):
polygonItem.setBrush( QColor(fillColor) )
group.setRect( pathItem.boundingRect() and polygonItem.boundingRect() )