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


Python core.QgsFillSymbolV2類代碼示例

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


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

示例1: setUp

    def setUp(self):
        self.iface = get_iface()
        myShpFile = os.path.join(TEST_DATA_DIR, 'rectangles.shp')
        layer = QgsVectorLayer(myShpFile, 'Points', 'ogr')
        QgsMapLayerRegistry.instance().addMapLayer(layer)

        # Create rulebased style
        sym1 = QgsFillSymbolV2.createSimple({'color': '#fdbf6f'})
        sym2 = QgsFillSymbolV2.createSimple({'color': '#71bd6c'})
        sym3 = QgsFillSymbolV2.createSimple({'color': '#1f78b4'})

        self.r1 = QgsRuleBasedRendererV2.Rule(sym1, 0, 0, '"id" = 1')
        self.r2 = QgsRuleBasedRendererV2.Rule(sym2, 0, 0, '"id" = 2')
        self.r3 = QgsRuleBasedRendererV2.Rule(sym3, 0, 0, 'ELSE')

        self.rootrule = QgsRuleBasedRendererV2.Rule(None)
        self.rootrule.appendChild(self.r1)
        self.rootrule.appendChild(self.r2)
        self.rootrule.appendChild(self.r3)

        self.renderer = QgsRuleBasedRendererV2(self.rootrule)
        layer.setRendererV2(self.renderer)
        self.mapsettings = self.iface.mapCanvas().mapSettings()
        self.mapsettings.setOutputSize(QSize(400, 400))
        self.mapsettings.setOutputDpi(96)
        self.mapsettings.setExtent(QgsRectangle(-163, 22, -70, 52))

        rendered_layers = [layer.id()]
        self.mapsettings.setLayers(rendered_layers)
開發者ID:AM7000000,項目名稱:QGIS,代碼行數:29,代碼來源:test_qgsrulebasedrenderer.py

示例2: geraMapaBacia

 def geraMapaBacia(self, cotrecho, cobacia, dist):
     # manda gerar a tabela montante_jusante.area_mont_x na base de dados (x é o código do trecho)
     # gera o string sql
     string_sql = 'SELECT gera_tabela_topologica(\'area_mont\', ' + str(cotrecho) + ', \'' + cobacia + '\', ' + '{0:.6f}'.format(dist) + ')'
     # estabelece uma conexão com a base de dados PostGIS com dados da conexao da camada hidrografia armazenados em self.uri_ex
     conn = psycopg2.connect(host=self.uri_ex.host(), port=self.uri_ex.port(), database=self.uri_ex.database(), user=self.uri_ex.username(), password=self.uri_ex.password())
     # executa o comando sql, que gera a tabela montante_jusante.area_montante_xxx, onde xxx é o id do trecho
     cur = conn.cursor()
     cur.execute(string_sql)
     # se assegura que as alterações da base de dados foram feitas e fecha o cursor e a conexão
     conn.commit()
     cur.close()
     conn.close()
     # seleciona a tabela montante_jusante.area_mont_xxx - coluna geomproj
     self.uri.setDataSource('montante_jusante', 'area_mont_' + str(cotrecho) , 'geomproj')
     #gera o titulo do mapa
     titulo = 'Area a montante de ' + str(cotrecho)
     #gera o mapa e acrescenta ao projeto
     mapa = QgsVectorLayer(self.uri.uri(), titulo, 'postgres')
     if not mapa.isValid():
         raise ErroMapaInvalido
     QgsMapLayerRegistry.instance().addMapLayer(mapa)
     # faz com que a cor das bordas das areas de contribuicao seja a do interior e refresca o mapa
     propriedades = mapa.rendererV2().symbol().symbolLayers()[0].properties()
     propriedades['outline_color'] = propriedades['color']
     mapa.rendererV2().setSymbol(QgsFillSymbolV2.createSimple(propriedades))
開發者ID:flaviolyra,項目名稱:wis-framework,代碼行數:26,代碼來源:ferramenta_montante_jusante_tabela.py

示例3: setUp

    def setUp(self):
        self.iface = get_iface()

        polys_shp = os.path.join(TEST_DATA_DIR, 'polys.shp')
        points_shp = os.path.join(TEST_DATA_DIR, 'points.shp')
        lines_shp = os.path.join(TEST_DATA_DIR, 'lines.shp')
        self.polys_layer = QgsVectorLayer(polys_shp, 'Polygons', 'ogr')
        self.points_layer = QgsVectorLayer(points_shp, 'Points', 'ogr')
        self.lines_layer = QgsVectorLayer(lines_shp, 'Lines', 'ogr')
        QgsMapLayerRegistry.instance().addMapLayer(self.polys_layer)
        QgsMapLayerRegistry.instance().addMapLayer(self.lines_layer)
        QgsMapLayerRegistry.instance().addMapLayer(self.points_layer)

        # Create style
        sym1 = QgsFillSymbolV2.createSimple({'color': '#fdbf6f'})
        sym2 = QgsLineSymbolV2.createSimple({'color': '#fdbf6f'})
        sym3 = QgsMarkerSymbolV2.createSimple({'color': '#fdbf6f'})

        self.polys_layer.setRendererV2(QgsSingleSymbolRendererV2(sym1))
        self.lines_layer.setRendererV2(QgsSingleSymbolRendererV2(sym2))
        self.points_layer.setRendererV2(QgsSingleSymbolRendererV2(sym3))

        self.mapsettings = self.iface.mapCanvas().mapSettings()
        self.mapsettings.setOutputSize(QSize(400, 400))
        self.mapsettings.setOutputDpi(96)
        self.mapsettings.setExtent(QgsRectangle(-133, 22, -70, 52))
開發者ID:Naisha634,項目名稱:QGIS,代碼行數:26,代碼來源:test_qgsgeometrygeneratorsymbollayerv2.py

示例4: __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)
        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 = QgsFillSymbolV2.createSimple(props)
        self.mComposerPolygon.setPolygonStyleSymbol(style)
開發者ID:Clayton-Davis,項目名稱:QGIS,代碼行數:31,代碼來源:test_qgscomposerpolygon.py

示例5: create_qlayer

 def create_qlayer(self):
     layer=QgsVectorLayer("Polygon"+self.crs,self.prefix+"-cells","memory")
     # transparent red, no border
     # but this is the wrong class...
     symbol = QgsFillSymbolV2.createSimple({'outline_style':'no',
                                            'style':'solid',
                                            'color': '249,0,0,78'})
     layer.rendererV2().setSymbol(symbol)
     return layer
開發者ID:rustychris,項目名稱:umbra,代碼行數:9,代碼來源:umbra_layer.py

示例6: testSymbolColor

    def testSymbolColor(self):
        # Create rulebased style
        sym1 = QgsFillSymbolV2.createSimple({'color': '#ff0000'})

        renderer = QgsSingleSymbolRendererV2(sym1)
        renderer.symbols()[0].symbolLayers()[0].setDataDefinedProperty('color', 'set_color_part( @symbol_color, \'value\', "Value" * 4)')
        self.layer.setRendererV2(renderer)

        # Setup rendering check
        renderchecker = QgsMultiRenderChecker()
        renderchecker.setMapSettings(self.mapsettings)
        renderchecker.setControlName('expected_symbol_color_variable')
        result = renderchecker.runTest('symbol_color_variable', 50)

        self.assertTrue(result)
開發者ID:dudds6699,項目名稱:QGIS,代碼行數:15,代碼來源:test_qgssymbolexpressionvariables.py

示例7: testPartCount

    def testPartCount(self):
        # Create rulebased style
        sym1 = QgsFillSymbolV2.createSimple({'color': '#fdbf6f'})

        renderer = QgsSingleSymbolRendererV2(sym1)
        renderer.symbols()[0].symbolLayers()[0].setDataDefinedProperty('color', 'color_rgb( (@geometry_part_count - 1) * 200, 0, 0 )')
        self.layer.setRendererV2(renderer)

        # Setup rendering check
        renderchecker = QgsMultiRenderChecker()
        renderchecker.setMapSettings(self.mapsettings)
        renderchecker.setControlName('expected_geometry_part_count')
        result = renderchecker.runTest('part_geometry_part_count')

        self.assertTrue(result)
開發者ID:dudds6699,項目名稱:QGIS,代碼行數:15,代碼來源:test_qgssymbolexpressionvariables.py

示例8: test_2

    def test_2(self):
        sym = self.lines_layer.rendererV2().symbol()
        # double headed
        sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '5', 'head_length': '4', 'head_thickness': '6', 'head_type': '2'})
        fill_sym = QgsFillSymbolV2.createSimple({'color': '#8bcfff', 'outline_color': '#000000', 'outline_style': 'solid', 'outline_width': '1'})
        sym_layer.setSubSymbol(fill_sym)
        sym.changeSymbolLayer(0, sym_layer)

        rendered_layers = [self.lines_layer.id()]
        self.mapsettings.setLayers(rendered_layers)

        renderchecker = QgsMultiRenderChecker()
        renderchecker.setMapSettings(self.mapsettings)
        renderchecker.setControlName('expected_arrowsymbollayer_2')
        self.assertTrue(renderchecker.runTest('arrowsymbollayer_2'))
開發者ID:NyakudyaA,項目名稱:QGIS,代碼行數:15,代碼來源:test_qgsarrowsymbollayer.py

示例9: geraMapaBacia

 def geraMapaBacia(self, cotrecho, cobacia, dist, id_trecho):
     # seleciona a tabela area_contrib_eq - coluna geomproj
     self.uri.setDataSource('public', 'area_contrib', 'geomproj')
     # gera o string sql
     string_sql = '"cotrecho" IN (SELECT * FROM tr_md(\'' + cobacia + '\', ' + '{0:f}'.format(dist) + '))'
     self.uri.setSql(string_sql)
     #gera o titulo do mapa
     titulo = 'Area a montante de ' + str(cotrecho)
     #gera o mapa e acrescenta ao projeto
     mapa = QgsVectorLayer(self.uri.uri(), titulo, 'postgres')
     if not mapa.isValid():
         raise ErroMapaInvalido
     QgsMapLayerRegistry.instance().addMapLayer(mapa)
     # faz com que a cor das bordas das areas de contribuicao seja a do interior e refresca o mapa
     propriedades = mapa.rendererV2().symbol().symbolLayers()[0].properties()
     propriedades['outline_color'] = propriedades['color']
     mapa.rendererV2().setSymbol(QgsFillSymbolV2.createSimple(propriedades))
開發者ID:flaviolyra,項目名稱:wis-framework,代碼行數:17,代碼來源:ferramenta_montante_jusante.py

示例10: setUp

    def setUp(self):
        myShpFile = os.path.join(TEST_DATA_DIR, 'polys_overlapping.shp')
        layer = QgsVectorLayer(myShpFile, 'Polygons', 'ogr')
        QgsMapLayerRegistry.instance().addMapLayer(layer)

        # Create style
        sym1 = QgsFillSymbolV2.createSimple({'color': '#fdbf6f'})

        self.renderer = QgsSingleSymbolRendererV2(sym1)
        layer.setRendererV2(self.renderer)
        self.mapsettings = CANVAS.mapSettings()
        self.mapsettings.setOutputSize(QSize(400, 400))
        self.mapsettings.setOutputDpi(96)
        self.mapsettings.setExtent(QgsRectangle(-133, 22, -70, 52))

        rendered_layers = [layer.id()]
        self.mapsettings.setLayers(rendered_layers)
開發者ID:supergis,項目名稱:QGIS,代碼行數:17,代碼來源:test_qgsgeometrygeneratorsymbollayerv2.py

示例11: test_3

    def test_3(self):
        sym = self.lines_layer.rendererV2().symbol()
        # double headed
        sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '7', 'head_length': '6', 'head_thickness': '8', 'head_type': '0', 'arrow_type': '1', 'is_curved': '0'})
        fill_sym = QgsFillSymbolV2.createSimple({'color': '#8bcfff', 'outline_color': '#000000', 'outline_style': 'solid', 'outline_width': '1'})
        sym_layer.setSubSymbol(fill_sym)
        sym.changeSymbolLayer(0, sym_layer)

        rendered_layers = [self.lines_layer.id()]
        self.mapsettings.setLayers(rendered_layers)

        renderchecker = QgsMultiRenderChecker()
        ms = self.mapsettings
        ms.setExtent(QgsRectangle(-101, 35, -99, 37))
        renderchecker.setMapSettings(ms)
        renderchecker.setControlName('expected_arrowsymbollayer_3')
        self.assertTrue(renderchecker.runTest('arrowsymbollayer_3'))
開發者ID:NyakudyaA,項目名稱:QGIS,代碼行數:17,代碼來源:test_qgsarrowsymbollayer.py

示例12: test_1

    def test_1(self):
        sym = self.lines_layer.rendererV2().symbol()
        sym_layer = QgsArrowSymbolLayer.create({'head_size': '6.5'})
        dd = QgsDataDefined("(@geometry_point_num % 4) * 2")
        sym_layer.setDataDefinedProperty("arrow_width", dd)
        dd2 = QgsDataDefined("(@geometry_point_num % 4) * 2")
        sym_layer.setDataDefinedProperty("head_size", dd2)
        fill_sym = QgsFillSymbolV2.createSimple({'color': '#8bcfff', 'outline_color': '#000000', 'outline_style': 'solid', 'outline_width': '1'})
        sym_layer.setSubSymbol(fill_sym)
        sym.changeSymbolLayer(0, sym_layer)

        rendered_layers = [self.lines_layer.id()]
        self.mapsettings.setLayers(rendered_layers)

        renderchecker = QgsMultiRenderChecker()
        renderchecker.setMapSettings(self.mapsettings)
        renderchecker.setControlName('expected_arrowsymbollayer_1')
        self.assertTrue(renderchecker.runTest('arrowsymbollayer_1'))
開發者ID:PeterTFS,項目名稱:QGIS,代碼行數:18,代碼來源:test_qgsarrowsymbollayer.py

示例13: test_unrepeated

    def test_unrepeated(self):
        sym = self.lines_layer.rendererV2().symbol()
        # double headed
        sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '7', 'head_width': '6', 'head_height': '8', 'head_type': '0', 'arrow_type': '0'})
        # no repetition
        sym_layer.setIsRepeated(False)
        fill_sym = QgsFillSymbolV2.createSimple({'color': '#8bcfff', 'outline_color': '#000000', 'outline_style': 'solid', 'outline_width': '1'})
        sym_layer.setSubSymbol(fill_sym)
        sym.changeSymbolLayer(0, sym_layer)

        rendered_layers = [self.lines_layer.id()]
        self.mapsettings.setLayers(rendered_layers)

        renderchecker = QgsMultiRenderChecker()
        ms = self.mapsettings
        ms.setExtent(QgsRectangle(-119, 17, -82, 50))
        renderchecker.setMapSettings(ms)
        renderchecker.setControlName('expected_arrowsymbollayer_4')
        self.assertTrue(renderchecker.runTest('arrowsymbollayer_4'))
開發者ID:AM7000000,項目名稱:QGIS,代碼行數:19,代碼來源:test_qgsarrowsymbollayer.py

示例14: setUp

 def setUp(self):
     # Create some simple symbols
     self.fill_symbol = QgsFillSymbolV2.createSimple({"color": "#ffffff"})
     self.line_symbol = QgsLineSymbolV2.createSimple({"color": "#ffffff", "line_width": "3"})
     self.marker_symbol = QgsMarkerSymbolV2.createSimple({"color": "#ffffff", "size": "3"})
     self.report = "<h1>Python QgsSymbolV2 Tests</h1>\n"
開發者ID:Zakui,項目名稱:QGIS,代碼行數:6,代碼來源:test_qgssymbolv2.py

示例15: testCase

    def testCase(self):
        self.TEST_DATA_DIR = unitTestDataPath()
        vectorFileInfo = QFileInfo( self.TEST_DATA_DIR + "/france_parts.shp")
        mVectorLayer = QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), "ogr" )

        QgsMapLayerRegistry.instance().addMapLayers( [mVectorLayer] )

        # create composition with composer map
        mMapRenderer = QgsMapRenderer()
        layerStringList = []
        layerStringList.append( mVectorLayer.id() )
        mMapRenderer.setLayerSet( layerStringList )
        mMapRenderer.setProjectionsEnabled( True )
        mMapRenderer.setMapUnits( QGis.Meters )

        # select epsg:2154
        crs = QgsCoordinateReferenceSystem()
        crs.createFromSrid( 2154 )
        mMapRenderer.setDestinationCrs( crs )

        self.mComposition = QgsComposition( mMapRenderer )
        self.mComposition.setPaperSize( 297, 210 )

        # fix the renderer, fill with green
        props = { "color": "0,127,0" }
        fillSymbol = QgsFillSymbolV2.createSimple( props )
        renderer = QgsSingleSymbolRendererV2( fillSymbol )
        mVectorLayer.setRendererV2( renderer )

        # the atlas map
        self.mAtlasMap = QgsComposerMap( self.mComposition, 20, 20, 130, 130 )
        self.mAtlasMap.setFrameEnabled( True )
        self.mComposition.addComposerMap( self.mAtlasMap )

        # the atlas
        self.mAtlas = self.mComposition.atlasComposition()
        self.mAtlas.setCoverageLayer( mVectorLayer )
        self.mAtlas.setEnabled( True )
        self.mComposition.setAtlasMode( QgsComposition.ExportAtlas )

        # an overview
        mOverview = QgsComposerMap( self.mComposition, 180, 20, 50, 50 )
        mOverview.setFrameEnabled( True )
        mOverview.setOverviewFrameMap( self.mAtlasMap.id() )
        self.mComposition.addComposerMap( mOverview )
        nextent = QgsRectangle( 49670.718, 6415139.086, 699672.519, 7065140.887 )
        mOverview.setNewExtent( nextent )

        # set the fill symbol of the overview map
        props2 = { "color": "127,0,0,127" }
        fillSymbol2 = QgsFillSymbolV2.createSimple( props2 )
        mOverview.setOverviewFrameMapSymbol( fillSymbol2 )

        # header label
        self.mLabel1 = QgsComposerLabel( self.mComposition )
        self.mComposition.addComposerLabel( self.mLabel1 )
        self.mLabel1.setText( "[% \"NAME_1\" %] area" )
        self.mLabel1.setFont( QgsFontUtils.getStandardTestFont() )
        self.mLabel1.adjustSizeToText()
        self.mLabel1.setSceneRect( QRectF( 150, 5, 60, 15 ) )

        qWarning( "header label font: %s exactMatch:%s" % ( self.mLabel1.font().toString(), self.mLabel1.font().exactMatch() ) )

        # feature number label
        self.mLabel2 = QgsComposerLabel( self.mComposition )
        self.mComposition.addComposerLabel( self.mLabel2 )
        self.mLabel2.setText( "# [%$feature || ' / ' || $numfeatures%]" )
        self.mLabel2.setFont( QgsFontUtils.getStandardTestFont() )
        self.mLabel2.adjustSizeToText()
        self.mLabel2.setSceneRect( QRectF( 150, 200, 60, 15 ) )

        qWarning( "feature number label font: %s exactMatch:%s" % ( self.mLabel2.font().toString(), self.mLabel2.font().exactMatch() ) )

        self.filename_test()
        self.autoscale_render_test()
        self.autoscale_render_test_old_api()
        self.fixedscale_render_test()
        self.predefinedscales_render_test()
        self.hidden_render_test()
開發者ID:Ariki,項目名稱:QGIS,代碼行數:79,代碼來源:test_qgsatlascomposition.py


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