本文整理汇总了Python中qgis.core.QgsComposerPolyline类的典型用法代码示例。如果您正苦于以下问题:Python QgsComposerPolyline类的具体用法?Python QgsComposerPolyline怎么用?Python QgsComposerPolyline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QgsComposerPolyline类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, methodName):
"""Run once on class initialization."""
unittest.TestCase.__init__(self, methodName)
self.mapSettings = QgsMapSettings()
# create composition
self.mComposition = QgsComposition(self.mapSettings, QgsProject.instance())
self.mComposition.setPaperSize(297, 210)
# create
polygon = QPolygonF()
polygon.append(QPointF(0.0, 0.0))
polygon.append(QPointF(100.0, 0.0))
polygon.append(QPointF(200.0, 100.0))
polygon.append(QPointF(100.0, 200.0))
self.mComposerPolyline = QgsComposerPolyline(
polygon, self.mComposition)
self.mComposition.addComposerPolyline(self.mComposerPolyline)
# style
props = {}
props["color"] = "0,0,0,255"
props["width"] = "10.0"
props["capstyle"] = "square"
style = QgsLineSymbol.createSimple(props)
self.mComposerPolyline.setPolylineStyleSymbol(style)
示例2: TestQgsComposerPolyline
class TestQgsComposerPolyline(unittest.TestCase):
def __init__(self, methodName):
"""Run once on class initialization."""
unittest.TestCase.__init__(self, methodName)
self.mapSettings = QgsMapSettings()
# create composition
self.mComposition = QgsComposition(self.mapSettings, QgsProject.instance())
self.mComposition.setPaperSize(297, 210)
# create
polygon = QPolygonF()
polygon.append(QPointF(0.0, 0.0))
polygon.append(QPointF(100.0, 0.0))
polygon.append(QPointF(200.0, 100.0))
polygon.append(QPointF(100.0, 200.0))
self.mComposerPolyline = QgsComposerPolyline(
polygon, self.mComposition)
self.mComposition.addComposerPolyline(self.mComposerPolyline)
# style
props = {}
props["color"] = "0,0,0,255"
props["width"] = "10.0"
props["capstyle"] = "square"
style = QgsLineSymbol.createSimple(props)
self.mComposerPolyline.setPolylineStyleSymbol(style)
def testDisplayName(self):
"""Test if displayName is valid"""
self.assertEqual(self.mComposerPolyline.displayName(), "<polyline>")
def testType(self):
"""Test if type is valid"""
self.assertEqual(
self.mComposerPolyline.type(), QgsComposerItem.ComposerPolyline)
def testDefaultStyle(self):
"""Test polygon rendering with default style."""
self.mComposerPolyline.setDisplayNodes(False)
checker = QgsCompositionChecker(
'composerpolyline_defaultstyle', self.mComposition)
checker.setControlPathPrefix("composer_polyline")
myTestResult, myMessage = checker.testComposition()
assert myTestResult, myMessage
def testDisplayNodes(self):
"""Test displayNodes method"""
self.mComposerPolyline.setDisplayNodes(True)
checker = QgsCompositionChecker(
'composerpolyline_displaynodes', self.mComposition)
checker.setControlPathPrefix("composer_polyline")
myTestResult, myMessage = checker.testComposition()
assert myTestResult, myMessage
self.mComposerPolyline.setDisplayNodes(False)
checker = QgsCompositionChecker(
'composerpolyline_defaultstyle', self.mComposition)
checker.setControlPathPrefix("composer_polyline")
myTestResult, myMessage = checker.testComposition()
assert myTestResult, myMessage
def testSelectedNode(self):
"""Test selectedNode and unselectNode methods"""
self.mComposerPolyline.setDisplayNodes(True)
self.mComposerPolyline.setSelectedNode(3)
checker = QgsCompositionChecker(
'composerpolyline_selectednode', self.mComposition)
checker.setControlPathPrefix("composer_polyline")
myTestResult, myMessage = checker.testComposition()
assert myTestResult, myMessage
self.mComposerPolyline.unselectNode()
self.mComposerPolyline.setDisplayNodes(False)
checker = QgsCompositionChecker(
'composerpolyline_defaultstyle', self.mComposition)
checker.setControlPathPrefix("composer_polyline")
myTestResult, myMessage = checker.testComposition()
assert myTestResult, myMessage
def testRemoveNode(self):
"""Test removeNode method"""
rc = self.mComposerPolyline.removeNode(100)
self.assertEqual(rc, False)
checker = QgsCompositionChecker(
'composerpolyline_defaultstyle', self.mComposition)
checker.setControlPathPrefix("composer_polyline")
myTestResult, myMessage = checker.testComposition()
#.........这里部分代码省略.........