Skip to content

Commit

Permalink
[FEATURE] Add 2.5D Renderer
Browse files Browse the repository at this point in the history
This adds a configuration interface and renderer that makes it easy to
put all the pieces together which are required to get a 2.5D effect.

It allow for configuring some of the styling and is meant to create an
easy-to-use setup.

Since every part of the system is built around QGIS' internal rendering
and symbology engine, there is much to fine tune. To get all the
possibilities, just change the renderer to a graduated, categorized or
single symbol renderer upon creation and you will find full access to
improve the style to your needs.

Funded by
 * Regional Council of Picardy
 * ADUGA
 * Ville de Nyon
 * Wetu GIT cc
  • Loading branch information
m-kuhn committed Jan 15, 2016
1 parent 532259f commit 0c02f18
Show file tree
Hide file tree
Showing 17 changed files with 768 additions and 5 deletions.
1 change: 1 addition & 0 deletions python/core/core.sip
Expand Up @@ -279,6 +279,7 @@
%Include symbology-ng/qgscptcityarchive.sip
%Include symbology-ng/qgsvectorcolorrampv2.sip

%Include symbology-ng/qgs25drenderer.sip
%Include symbology-ng/qgscategorizedsymbolrendererv2.sip
%Include symbology-ng/qgsgraduatedsymbolrendererv2.sip
%Include symbology-ng/qgslegendsymbolitemv2.sip
Expand Down
106 changes: 106 additions & 0 deletions python/core/symbology-ng/qgs25drenderer.sip
@@ -0,0 +1,106 @@
/***************************************************************************
qgs25drenderer.sip - Qgs25DRenderer

---------------------
begin : 14.1.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.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 Qgs25DRenderer : QgsFeatureRendererV2
{
%TypeHeaderCode
#include "qgs25drenderer.h"
%End
public:
Qgs25DRenderer();

/**
* Create a new 2.5D renderer from XML
*
* @param element XML information
*/
static QgsFeatureRendererV2* create( QDomElement& element );
QDomElement save( QDomDocument& doc );

void startRender( QgsRenderContext& context, const QgsFields& fields );
void stopRender( QgsRenderContext& context );

QList<QString> usedAttributes();
QgsFeatureRendererV2* clone() const;

virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature, QgsRenderContext& context );
virtual QgsSymbolV2List symbols( QgsRenderContext& context );

/**
* Get the field or expression used to determine the height of extrusion
*/
QgsDataDefined height() const;
/**
* Set the field or expression used to determine the height of extrusion
*/
void setHeight( const QgsDataDefined& height );

/**
* Get the angle for the extrusion effect
*/
int angle() const;
/**
* Set the angle for the extrusion effect
*/
void setAngle( int angle );

/**
* Get the roof color
*/
QColor roofColor() const;

/**
* Set the roof color
*/
void setRoofColor( const QColor& roofColor );

/**
* Get the wall color
*/
QColor wallColor() const;

/**
* Set the wall color
*/
void setWallColor( const QColor& wallColor );

/**
* Get the shadow's color
*/
QColor shadowColor() const;

/**
* Set the shadow's color
*/
void setShadowColor( const QColor& shadowColor );

/**
* Get the shadow's spread distance in map units
*/
double shadowSpread() const;
/**
* Set the shadow's spread distance in map units
*/
void setShadowSpread( double shadowSpread );

/**
* Try to convert from an existing renderer. If it is not of the same type
* we assume that the internals are not compatible and create a new default
* 2.5D renderer.
*/
static Qgs25DRenderer* convertFromRenderer( QgsFeatureRendererV2* renderer );

};
1 change: 1 addition & 0 deletions python/gui/gui.sip
Expand Up @@ -194,6 +194,7 @@
%Include raster/qgssinglebandpseudocolorrendererwidget.sip

%Include symbology-ng/characterwidget.sip
%Include symbology-ng/qgs25drendererwidget.sip
%Include symbology-ng/qgsbrushstylecombobox.sip
%Include symbology-ng/qgscategorizedsymbolrendererv2widget.sip
%Include symbology-ng/qgscolorrampcombobox.sip
Expand Down
38 changes: 38 additions & 0 deletions python/gui/symbology-ng/qgs25drendererwidget.sip
@@ -0,0 +1,38 @@
/***************************************************************************
qgs25drendererwidget.sip - Qgs25DRendererWidget

---------------------
begin : 14.1.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.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 Qgs25DRendererWidget : QgsRendererV2Widget
{
%TypeHeaderCode
#include "qgs25drendererwidget.h"
%End
public:
/** Static creation method
* @param layer the layer where this renderer is applied
* @param style
* @param renderer the mask renderer (will take ownership)
*/
static QgsRendererV2Widget* create( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer );

/** Constructor
* @param layer the layer where this renderer is applied
* @param style
* @param renderer the mask renderer (will take ownership)
*/
Qgs25DRendererWidget( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer );

QgsFeatureRendererV2* renderer();
};
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -15,6 +15,7 @@ SET(QGIS_CORE_SRCS
gps/time.c
gps/tok.c

symbology-ng/qgs25drenderer.cpp
symbology-ng/qgscategorizedsymbolrendererv2.cpp
symbology-ng/qgscolorbrewerpalette.cpp
symbology-ng/qgscptcityarchive.cpp
Expand Down Expand Up @@ -763,6 +764,7 @@ SET(QGIS_CORE_HDRS
raster/qgssinglebandgrayrenderer.h
raster/qgssinglebandpseudocolorrenderer.h

symbology-ng/qgs25drenderer.h
symbology-ng/qgscategorizedsymbolrendererv2.h
symbology-ng/qgscolorbrewerpalette.h
symbology-ng/qgsellipsesymbollayerv2.h
Expand Down

3 comments on commit 0c02f18

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 0c02f18 Jan 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-kuhn loving it. I'm spotting a few issues in terms of polygon z-indexing and stuff, but otherwise working like magic.

One thing I'm not a super fan of is the hard-coded drop shadow; can we a/ make this optional and b/ have its size configurable?

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 0c02f18 Jan 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being able to do that from a pre-existing dataset, in less than a minute, is jaw-dropping:
nice

@m-kuhn
Copy link
Member Author

@m-kuhn m-kuhn commented on 0c02f18 Jan 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the shadow should really become an option. And the solar angle to have wall faces differently colored :)

Please sign in to comment.