Skip to content
Permalink
Browse files

[FEATURE] Add geometry generator symbols

  • Loading branch information
m-kuhn committed Dec 10, 2015
1 parent 554b41d commit 17f9d554f8a4375ae06af40521ffa3a012eac331
@@ -290,6 +290,9 @@
%Include symbology-ng/qgslinesymbollayerv2.sip
%Include symbology-ng/qgsmarkersymbollayerv2.sip
%Include symbology-ng/qgssymbollayerv2registry.sip
%Include symbology-ng/qgspolygongeneratorsymbollayerv2.sip
%Include symbology-ng/qgslinegeneratorsymbollayerv2.sip
%Include symbology-ng/qgspointgeneratorsymbollayerv2.sip

%Include symbology-ng/qgssymbologyv2conversion.sip

@@ -0,0 +1,56 @@
/***************************************************************************
qgslinegeneratorsymbollayerv2.sip
---------------------
begin : November 2015
copyright : (C) 2015 by Matthias Kuhn
email : matthias at opengis dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
class QgsLineGeneratorSymbolLayerV2 : QgsLineSymbolLayerV2
{
%TypeHeaderCode
#include "qgslinegeneratorsymbollayerv2.h"
%End
public:
static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );

QgsLineGeneratorSymbolLayerV2( QgsLineSymbolV2* symbol, const QgsStringMap& properties = QgsStringMap() );

QString layerType() const;

void startRender( QgsSymbolV2RenderContext& context );

void stopRender( QgsSymbolV2RenderContext& context );

QgsSymbolLayerV2* clone() const;

QgsStringMap properties() const;

void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );

void setGeometryExpression( const QString& exp );

QString geometryExpression() const;

virtual QgsSymbolV2* subSymbol();

virtual bool setSubSymbol( QgsSymbolV2* symbol );

virtual QSet<QString> usedAttributes() const;

//! Will always return true.
//! This is a hybrid layer, it constructs its own geometry so it does not
//! care about the geometry of its parents.
bool isCompatibleWithSymbol( QgsSymbolV2* symbol );

virtual void renderPolyline( const QPolygonF& point, QgsSymbolV2RenderContext& context );

private:
QgsLineGeneratorSymbolLayerV2( const QgsLineGeneratorSymbolLayerV2& copy );
};
@@ -0,0 +1,56 @@
/***************************************************************************
qgspointgeneratorsymbollayerv2.sip
---------------------
begin : November 2015
copyright : (C) 2015 by Matthias Kuhn
email : matthias at opengis dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
class QgsPointGeneratorSymbolLayerV2 : QgsMarkerSymbolLayerV2
{
%TypeHeaderCode
#include "qgspointgeneratorsymbollayerv2.h"
%End
public:
static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );

QgsPointGeneratorSymbolLayerV2( QgsMarkerSymbolV2* symbol, const QgsStringMap& properties = QgsStringMap() );

QString layerType() const;

void startRender( QgsSymbolV2RenderContext& context );

void stopRender( QgsSymbolV2RenderContext& context );

QgsSymbolLayerV2* clone() const;

QgsStringMap properties() const;

void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );

void setGeometryExpression( const QString& exp );

QString geometryExpression() const;

virtual QgsSymbolV2* subSymbol();

virtual bool setSubSymbol( QgsSymbolV2* symbol );

virtual QSet<QString> usedAttributes() const;

//! Will always return true.
//! This is a hybrid layer, it constructs its own geometry so it does not
//! care about the geometry of its parents.
bool isCompatibleWithSymbol( QgsSymbolV2* symbol );

void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );

private:
QgsPointGeneratorSymbolLayerV2( const QgsPointGeneratorSymbolLayerV2& copy );
};
@@ -0,0 +1,56 @@
/***************************************************************************
qgspolygongeneratorsymbollayerv2.sip
---------------------
begin : November 2015
copyright : (C) 2015 by Matthias Kuhn
email : matthias at opengis dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
class QgsPolygonGeneratorSymbolLayerV2 : QgsFillSymbolLayerV2
{
%TypeHeaderCode
#include "qgspolygongeneratorsymbollayerv2.h"
%End
public:
static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );

QgsPolygonGeneratorSymbolLayerV2( QgsFillSymbolV2* symbol, const QgsStringMap& properties = QgsStringMap() );

QString layerType() const;

void startRender( QgsSymbolV2RenderContext& context );

void stopRender( QgsSymbolV2RenderContext& context );

QgsSymbolLayerV2* clone() const;

QgsStringMap properties() const;

void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );

void setGeometryExpression( const QString& exp );

QString geometryExpression() const;

virtual QgsSymbolV2* subSymbol();

virtual bool setSubSymbol( QgsSymbolV2* symbol );

virtual QSet<QString> usedAttributes() const;

//! Will always return true.
//! This is a hybrid layer, it constructs its own geometry so it does not
//! care about the geometry of its parents.
bool isCompatibleWithSymbol( QgsSymbolV2* symbol );

void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );

private:
QgsPolygonGeneratorSymbolLayerV2( const QgsPolygonGeneratorSymbolLayerV2& copy );
};
@@ -1470,6 +1470,9 @@ void QgsProjectProperties::populateStyles()
case QgsSymbolV2::Fill :
cbo = cboStyleFill;
break;
case QgsSymbolV2::Hybrid:
// Shouldn't get here
break;
}
if ( cbo )
{
@@ -40,6 +40,7 @@ SET(QGIS_CORE_SRCS
symbology-ng/qgspointdisplacementrenderer.cpp
symbology-ng/qgsvectorfieldsymbollayer.cpp
symbology-ng/qgscolorbrewerpalette.cpp
symbology-ng/qgsgeometrygeneratorsymbollayerv2.cpp

diagram/qgsdiagram.cpp
diagram/qgspiediagram.cpp
@@ -755,6 +756,7 @@ SET(QGIS_CORE_HDRS
symbology-ng/qgssymbolv2.h
symbology-ng/qgsvectorcolorrampv2.h
symbology-ng/qgsvectorfieldsymbollayer.h
symbology-ng/qgsgeometrygeneratorsymbollayerv2.h

layertree/qgslayertree.h
layertree/qgslayertreeutils.h

2 comments on commit 17f9d55

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Dec 11, 2015

@m-kuhn , Geometry Generator doesn't work for line layers. Steps to reproduce:

  1. Load a line layer
  2. Open symbology, add a Geometry Generator layer, set it to polygon, and use a buffer expression (e.g. buffer($geometry, 200) )
  3. Apply the symbology, and note the generated polygon isn't drawn
@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Dec 11, 2015

Fixed in c9fa334
I added some tests to check for fill generators on points and line layers to avoid such issues in the future.

Please sign in to comment.
You can’t perform that action at this time.