当前位置: 首页>>代码示例>>Python>>正文


Python QGraphicsPolygonItem.__init__方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QGraphicsPolygonItem.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsPolygonItem.__init__方法的具体用法?Python QGraphicsPolygonItem.__init__怎么用?Python QGraphicsPolygonItem.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QGraphicsPolygonItem的用法示例。


在下文中一共展示了QGraphicsPolygonItem.__init__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PyQt4.QtGui import QGraphicsPolygonItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsPolygonItem import __init__ [as 别名]
 def __init__(self, parent, fromView, toView, distributedObjects):
     """ Constructor
     @param parent                parent for the QGraphicsPolygonItem-Constructor
     @param fromView              datagraph.htmlvariableview.HtmlVariableView, starting point of the Pointer
     @param toView                datagraph.htmlvariableview.HtmlVariableView, end point of the Pointer
     @param distributedObjects    distributedobjects.DistributedObjects, the DistributedObjects-Instance
     fromView and toView are QGraphicsWebViews
     """
     QGraphicsPolygonItem.__init__(self, parent)
     self.fromView = fromView
     fromView.addOutgoingPointer(self)
     self.toView = toView
     toView.addIncomingPointer(self)
     self.distributedObjects = distributedObjects
     self.setBrush( QBrush( self.bgcolor  ) )
     self.setPen( QPen(self.fgcolor,1) )
     QObject.connect(self.fromView, SIGNAL('geometryChanged()'), self.render)
     QObject.connect(self.toView, SIGNAL('geometryChanged()'), self.render)
     QObject.connect(self.fromView, SIGNAL('xChanged()'), self.render)
     QObject.connect(self.fromView, SIGNAL('yChanged()'), self.render)
     QObject.connect(self.toView, SIGNAL('xChanged()'), self.render)
     QObject.connect(self.toView, SIGNAL('yChanged()'), self.render)
     QObject.connect(self.fromView, SIGNAL('deleting()'), self.delete)
     QObject.connect(self.toView, SIGNAL('deleting()'), self.delete)
     
     self.render()
开发者ID:bschen,项目名称:ricodebug,代码行数:28,代码来源:pointer.py

示例2: __init__

# 需要导入模块: from PyQt4.QtGui import QGraphicsPolygonItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsPolygonItem import __init__ [as 别名]
 def __init__(self, parent):
     points = QPolygonF()
     self._mediator = ArrowMediator()
     for poly in (QPointF(7,0), QPointF(-7,7), QPointF(-5,2), QPointF(-11,2),
                  QPointF(-11,-2), QPointF(-5,-2), QPointF(-7,-7)):
         points.append(poly)
     QGraphicsPolygonItem.__init__(self, points, parent)
     self.setPen(Qt.darkCyan)
     self.setBrush(Qt.cyan)
开发者ID:richardmurri,项目名称:Query-Browser,代码行数:11,代码来源:scene.py

示例3: __init__

# 需要导入模块: from PyQt4.QtGui import QGraphicsPolygonItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsPolygonItem import __init__ [as 别名]
	def __init__(self, poly = None, dim = None):
		if not poly:
			if not dim:
				raise ValueError("need to set bounding rect!")
			else:
				poly = []
				for i in range(10):
					poly.append(planar.Point(
						random.randint(dim.left(),dim.right()),
						random.randint(dim.top(),dim.bottom())))
				poly = planar.Polygon.convex_hull(poly)
				poly = QPolygonF([QPointF(p.x,p.y) for p in poly])
			
		QGraphicsPolygonItem.__init__(self, poly)
		self.setConnectors([(0,random.random()),(len(poly)//2,random.random())])
开发者ID:nmeyering,项目名称:squiggly,代码行数:17,代码来源:subregion.py

示例4: __init__

# 需要导入模块: from PyQt4.QtGui import QGraphicsPolygonItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsPolygonItem import __init__ [as 别名]
	def __init__(self, world):

		QGraphicsPolygonItem.__init__(self)
		
		#############################
		### Build graph
		#############################

		graph = pydot.Dot()
		graph.set_node_defaults(color = 'red', fontcolor = 'red', label = '\<orphan\>')
		graph.set('overlap', 'prism')
		
		# build adjacency graph from world
		for area in world.areas:
		
			# create node for each room
			node = pydot.Node(area.id)
			node.set( 'label', area.name )
			if area == world.player.currentArea:
				node.set( 'color', 'blue' )
				node.set( 'fontcolor', 'blue' )
			else:
				node.set( 'color', 'black' )
				node.set( 'fontcolor', 'black' )

			graph.add_node(node)

			# link to adjacent rooms
			for feature in area.features:
				for action in feature.actions:
					finalEvent = None
					for event in action.events:
						if type(event) == events.PlayerMoveEvent:
							finalEvent = pydot.Edge( src=area.id, dst=event.properties['destination'] )

					if finalEvent is not None:
						graph.add_edge( finalEvent )
	
		################################
		### Generate SVG from graph
		################################

		ps = graph.create_svg(prog='neato')

		#########################################
		### Build graphics items from SVG
		#########################################

		# build xml tree
		ns = {'svg': 'http://www.w3.org/2000/svg'}
		doc = ET.fromstring(ps)

		# grab the root node properties
		rootNode = doc.xpath('/svg:svg/svg:g[1]', namespaces=ns)[0]
		polygon = rootNode.xpath('./svg:polygon', namespaces=ns)[0]
		pointStr = polygon.xpath('./@points', namespaces=ns)[0]
		penColor = QString(polygon.xpath('./@stroke', namespaces=ns)[0])
		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)
#.........这里部分代码省略.........
开发者ID:stevenvergenz,项目名称:pyVenture,代码行数:103,代码来源:svgsubitem.py


注:本文中的PyQt4.QtGui.QGraphicsPolygonItem.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。