當前位置: 首頁>>代碼示例>>Python>>正文


Python core.QgsRendererRegistry類代碼示例

本文整理匯總了Python中qgis.core.QgsRendererRegistry的典型用法代碼示例。如果您正苦於以下問題:Python QgsRendererRegistry類的具體用法?Python QgsRendererRegistry怎麽用?Python QgsRendererRegistry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了QgsRendererRegistry類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testAddRenderer

    def testAddRenderer(self):
        """ test adding renderers to registry """
        clearRegistry()

        # add a renderer
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(TestRenderer('test2')))
        self.assertTrue('test2' in QgsRendererRegistry.instance().renderersList())

        # try adding it again - should be rejected due to duplicate name
        self.assertFalse(QgsRendererRegistry.instance().addRenderer(TestRenderer('test2')))
        self.assertTrue('test2' in QgsRendererRegistry.instance().renderersList())
開發者ID:,項目名稱:,代碼行數:11,代碼來源:

示例2: testInstance

    def testInstance(self):
        """ test retrieving global instance """
        self.assertTrue(QgsRendererRegistry.instance())

        # instance should be initially populated with some default renderers
        self.assertTrue('singleSymbol' in QgsRendererRegistry.instance().renderersList())

        # register a renderer to the singleton, to test that the same instance is always returned
        self.assertFalse('test' in QgsRendererRegistry.instance().renderersList())
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(TestRenderer('test')))
        self.assertTrue('test' in QgsRendererRegistry.instance().renderersList())
開發者ID:,項目名稱:,代碼行數:11,代碼來源:

示例3: testRetrieveRenderer

    def testRetrieveRenderer(self):
        """ test retrieving renderer by name """
        clearRegistry()

        # try non-existant renderer
        self.assertFalse(QgsRendererRegistry.instance().rendererMetadata('test4'))

        # now add it
        r = TestRenderer('test4')
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r))

        # try retrieving it
        result = QgsRendererRegistry.instance().rendererMetadata('test4')
        self.assertTrue(result)
        self.assertEqual(result.name(), 'test4')
開發者ID:,項目名稱:,代碼行數:15,代碼來源:

示例4: testRenderersByLayerType

    def testRenderersByLayerType(self):
        """ test retrieving compatible renderers by layer type """
        clearRegistry()

        # add some renderers
        r1 = TestRenderer('test1', QgsRendererAbstractMetadata.PointLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r1))
        r2 = TestRenderer('test2', QgsRendererAbstractMetadata.LineLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r2))
        r3 = TestRenderer('test3', QgsRendererAbstractMetadata.PolygonLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r3))
        r4 = TestRenderer('test4', QgsRendererAbstractMetadata.PointLayer | QgsRendererAbstractMetadata.LineLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r4))

        # make some layers
        point_layer = QgsVectorLayer("Point?field=fldtxt:string",
                                     "pointlayer", "memory")
        line_layer = QgsVectorLayer("LineString?field=fldtxt:string",
                                    "linelayer", "memory")
        polygon_layer = QgsVectorLayer("Polygon?field=fldtxt:string",
                                       "polylayer", "memory")

        # test subsets
        self.assertEqual(QgsRendererRegistry.instance().renderersList(point_layer), ['singleSymbol', 'test1', 'test4'])
        self.assertEqual(QgsRendererRegistry.instance().renderersList(line_layer), ['singleSymbol', 'test2', 'test4'])
        self.assertEqual(QgsRendererRegistry.instance().renderersList(polygon_layer), ['singleSymbol', 'test3'])
開發者ID:,項目名稱:,代碼行數:26,代碼來源:

示例5: testRenderersList

    def testRenderersList(self):
        """ test getting list of renderers from registry """
        clearRegistry()

        self.assertEqual(QgsRendererRegistry.instance().renderersList(), ["singleSymbol"])

        # add some renderers
        r1 = TestRenderer("test1", QgsRendererAbstractMetadata.PointLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r1))
        r2 = TestRenderer("test2", QgsRendererAbstractMetadata.LineLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r2))
        r3 = TestRenderer("test3", QgsRendererAbstractMetadata.PolygonLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r3))
        r4 = TestRenderer("test4", QgsRendererAbstractMetadata.PointLayer | QgsRendererAbstractMetadata.LineLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r4))

        self.assertEqual(
            QgsRendererRegistry.instance().renderersList(), ["singleSymbol", "test1", "test2", "test3", "test4"]
        )

        # test subsets
        self.assertEqual(
            QgsRendererRegistry.instance().renderersList(QgsRendererAbstractMetadata.PointLayer),
            ["singleSymbol", "test1", "test4"],
        )
        self.assertEqual(
            QgsRendererRegistry.instance().renderersList(QgsRendererAbstractMetadata.LineLayer),
            ["singleSymbol", "test2", "test4"],
        )
        self.assertEqual(
            QgsRendererRegistry.instance().renderersList(QgsRendererAbstractMetadata.PolygonLayer),
            ["singleSymbol", "test3"],
        )
        self.assertEqual(
            QgsRendererRegistry.instance().renderersList(
                QgsRendererAbstractMetadata.LineLayer | QgsRendererAbstractMetadata.PolygonLayer
            ),
            ["singleSymbol", "test2", "test3", "test4"],
        )
開發者ID:,項目名稱:,代碼行數:39,代碼來源:

示例6: testRemoveRenderer

    def testRemoveRenderer(self):
        """ test removing renderers from registry """
        clearRegistry()

        # try removing non-existant renderer
        self.assertFalse(QgsRendererRegistry.instance().removeRenderer('test3'))

        # now add it
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(TestRenderer('test3')))
        self.assertTrue('test3' in QgsRendererRegistry.instance().renderersList())

        # try removing it again - should be ok this time
        self.assertTrue(QgsRendererRegistry.instance().removeRenderer('test3'))
        self.assertFalse('test3' in QgsRendererRegistry.instance().renderersList())

        # try removing it again - should be false since already removed
        self.assertFalse(QgsRendererRegistry.instance().removeRenderer('test3'))
開發者ID:,項目名稱:,代碼行數:17,代碼來源:

示例7: clearRegistry

def clearRegistry():
    # clear registry to start with
    for r in QgsRendererRegistry.instance().renderersList():
        if r == 'singleSymbol':
            continue
        QgsRendererRegistry.instance().removeRenderer(r)
開發者ID:,項目名稱:,代碼行數:6,代碼來源:


注:本文中的qgis.core.QgsRendererRegistry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。