本文整理匯總了Python中qgis.core.QgsComposerPolygon.unselectNode方法的典型用法代碼示例。如果您正苦於以下問題:Python QgsComposerPolygon.unselectNode方法的具體用法?Python QgsComposerPolygon.unselectNode怎麽用?Python QgsComposerPolygon.unselectNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qgis.core.QgsComposerPolygon
的用法示例。
在下文中一共展示了QgsComposerPolygon.unselectNode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestQgsComposerPolygon
# 需要導入模塊: from qgis.core import QgsComposerPolygon [as 別名]
# 或者: from qgis.core.QgsComposerPolygon import unselectNode [as 別名]
class TestQgsComposerPolygon(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)
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.mComposerPolygon = QgsComposerPolygon(polygon, self.mComposition)
self.mComposition.addComposerPolygon(self.mComposerPolygon)
# style
props = {}
props["color"] = "green"
props["style"] = "solid"
props["style_border"] = "solid"
props["color_border"] = "black"
props["width_border"] = "10.0"
props["joinstyle"] = "miter"
style = QgsFillSymbol.createSimple(props)
self.mComposerPolygon.setPolygonStyleSymbol(style)
def testDisplayName(self):
"""Test if displayName is valid"""
self.assertEqual(self.mComposerPolygon.displayName(), "<polygon>")
def testType(self):
"""Test if type is valid"""
self.assertEqual(
self.mComposerPolygon.type(), QgsComposerItem.ComposerPolygon)
def testDefaultStyle(self):
"""Test polygon rendering with default style."""
self.mComposerPolygon.setDisplayNodes(False)
checker = QgsCompositionChecker(
'composerpolygon_defaultstyle', self.mComposition)
checker.setControlPathPrefix("composer_polygon")
myTestResult, myMessage = checker.testComposition()
assert myTestResult, myMessage
def testDisplayNodes(self):
"""Test displayNodes method"""
self.mComposerPolygon.setDisplayNodes(True)
checker = QgsCompositionChecker(
'composerpolygon_displaynodes', self.mComposition)
checker.setControlPathPrefix("composer_polygon")
myTestResult, myMessage = checker.testComposition()
assert myTestResult, myMessage
self.mComposerPolygon.setDisplayNodes(False)
checker = QgsCompositionChecker(
'composerpolygon_defaultstyle', self.mComposition)
checker.setControlPathPrefix("composer_polygon")
myTestResult, myMessage = checker.testComposition()
assert myTestResult, myMessage
def testSelectedNode(self):
"""Test selectedNode and unselectNode methods"""
self.mComposerPolygon.setDisplayNodes(True)
self.mComposerPolygon.setSelectedNode(3)
checker = QgsCompositionChecker(
'composerpolygon_selectednode', self.mComposition)
checker.setControlPathPrefix("composer_polygon")
myTestResult, myMessage = checker.testComposition()
assert myTestResult, myMessage
self.mComposerPolygon.unselectNode()
self.mComposerPolygon.setDisplayNodes(False)
checker = QgsCompositionChecker(
'composerpolygon_defaultstyle', self.mComposition)
checker.setControlPathPrefix("composer_polygon")
myTestResult, myMessage = checker.testComposition()
assert myTestResult, myMessage
def testRemoveNode(self):
"""Test removeNode method"""
rc = self.mComposerPolygon.removeNode(100)
self.assertEqual(rc, False)
checker = QgsCompositionChecker(
'composerpolygon_defaultstyle', self.mComposition)
#.........這裏部分代碼省略.........