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


Python QgsRendererRegistry.instance方法代码示例

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


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

示例1: testAddRenderer

# 需要导入模块: from qgis.core import QgsRendererRegistry [as 别名]
# 或者: from qgis.core.QgsRendererRegistry import instance [as 别名]
    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:,项目名称:,代码行数:13,代码来源:

示例2: testInstance

# 需要导入模块: from qgis.core import QgsRendererRegistry [as 别名]
# 或者: from qgis.core.QgsRendererRegistry import instance [as 别名]
    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:,项目名称:,代码行数:13,代码来源:

示例3: testRetrieveRenderer

# 需要导入模块: from qgis.core import QgsRendererRegistry [as 别名]
# 或者: from qgis.core.QgsRendererRegistry import instance [as 别名]
    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:,项目名称:,代码行数:17,代码来源:

示例4: testRenderersByLayerType

# 需要导入模块: from qgis.core import QgsRendererRegistry [as 别名]
# 或者: from qgis.core.QgsRendererRegistry import instance [as 别名]
    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:,项目名称:,代码行数:28,代码来源:

示例5: testRenderersList

# 需要导入模块: from qgis.core import QgsRendererRegistry [as 别名]
# 或者: from qgis.core.QgsRendererRegistry import instance [as 别名]
    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:,项目名称:,代码行数:41,代码来源:

示例6: testRemoveRenderer

# 需要导入模块: from qgis.core import QgsRendererRegistry [as 别名]
# 或者: from qgis.core.QgsRendererRegistry import instance [as 别名]
    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:,项目名称:,代码行数:19,代码来源:

示例7: clearRegistry

# 需要导入模块: from qgis.core import QgsRendererRegistry [as 别名]
# 或者: from qgis.core.QgsRendererRegistry import instance [as 别名]
def clearRegistry():
    # clear registry to start with
    for r in QgsRendererRegistry.instance().renderersList():
        if r == 'singleSymbol':
            continue
        QgsRendererRegistry.instance().removeRenderer(r)
开发者ID:,项目名称:,代码行数:8,代码来源:


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