Skip to content
Permalink
Browse files
Mask renderer: rename to inverted polygon renderer
  • Loading branch information
Hugo Mercier committed May 23, 2014
1 parent 84b1577 commit 0ff587c7a0da00c23d50339471f405a1bf00844e
@@ -36,7 +36,7 @@ SET(QGIS_CORE_SRCS
symbology-ng/qgscategorizedsymbolrendererv2.cpp
symbology-ng/qgsgraduatedsymbolrendererv2.cpp
symbology-ng/qgsrulebasedrendererv2.cpp
symbology-ng/qgsmaskrendererv2.cpp
symbology-ng/qgsinvertedpolygonrenderer.cpp
symbology-ng/qgsvectorcolorrampv2.cpp
symbology-ng/qgscptcityarchive.cpp
symbology-ng/qgsstylev2.cpp
@@ -584,7 +584,7 @@ SET(QGIS_CORE_HDRS
symbology-ng/qgsrendererv2registry.h
symbology-ng/qgsrulebasedrendererv2.h
symbology-ng/qgssinglesymbolrendererv2.h
symbology-ng/qgsmaskrendererv2.h
symbology-ng/qgsinvertedpolygonrenderer.h
symbology-ng/qgsstylev2.h
symbology-ng/qgssvgcache.h
symbology-ng/qgssymbollayerv2.h
@@ -1,5 +1,5 @@
/***************************************************************************
qgsmaskrendererv2.cpp
qgsinvertedpolygonrenderer.cpp
---------------------
begin : April 2014
copyright : (C) 2014 Hugo Mercier / Oslandia
@@ -13,7 +13,7 @@
* *
***************************************************************************/

#include "qgsmaskrendererv2.h"
#include "qgsinvertedpolygonrenderer.h"

#include "qgssymbolv2.h"
#include "qgssymbollayerv2utils.h"
@@ -27,8 +27,8 @@
#include <QDomDocument>
#include <QDomElement>

QgsMaskRendererV2::QgsMaskRendererV2( const QgsFeatureRendererV2* subRenderer )
: QgsFeatureRendererV2( "maskRenderer" )
QgsInvertedPolygonRenderer::QgsInvertedPolygonRenderer( const QgsFeatureRendererV2* subRenderer )
: QgsFeatureRendererV2( "invertedPolygonRenderer" )
{
if ( subRenderer ) {
setEmbeddedRenderer( subRenderer );
@@ -38,11 +38,11 @@ QgsMaskRendererV2::QgsMaskRendererV2( const QgsFeatureRendererV2* subRenderer )
}
}

QgsMaskRendererV2::~QgsMaskRendererV2()
QgsInvertedPolygonRenderer::~QgsInvertedPolygonRenderer()
{
}

void QgsMaskRendererV2::setEmbeddedRenderer( const QgsFeatureRendererV2* subRenderer )
void QgsInvertedPolygonRenderer::setEmbeddedRenderer( const QgsFeatureRendererV2* subRenderer )
{
if ( subRenderer ) {
mSubRenderer.reset( const_cast<QgsFeatureRendererV2*>(subRenderer)->clone() );
@@ -52,12 +52,12 @@ void QgsMaskRendererV2::setEmbeddedRenderer( const QgsFeatureRendererV2* subRend
}
}

const QgsFeatureRendererV2* QgsMaskRendererV2::embeddedRenderer() const
const QgsFeatureRendererV2* QgsInvertedPolygonRenderer::embeddedRenderer() const
{
return mSubRenderer.data();
}

void QgsMaskRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
void QgsInvertedPolygonRenderer::startRender( QgsRenderContext& context, const QgsFields& fields )
{
if ( !mSubRenderer ) {
return;
@@ -100,7 +100,7 @@ void QgsMaskRendererV2::startRender( QgsRenderContext& context, const QgsFields&
mExtentPolygon.append(exteriorRing);
}

bool QgsMaskRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
bool QgsInvertedPolygonRenderer::renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
{
Q_UNUSED( context );

@@ -218,7 +218,7 @@ bool QgsMaskRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext& co
return true;
}

void QgsMaskRendererV2::stopRender( QgsRenderContext& context )
void QgsInvertedPolygonRenderer::stopRender( QgsRenderContext& context )
{
if ( !mSubRenderer ) {
return;
@@ -258,27 +258,27 @@ void QgsMaskRendererV2::stopRender( QgsRenderContext& context )
}
}

QString QgsMaskRendererV2::dump() const
QString QgsInvertedPolygonRenderer::dump() const
{
if ( !mSubRenderer ) {
return "MASK: NULL";
return "INVERTED: NULL";
}
return "MASK [" + mSubRenderer->dump() + "]";
return "INVERTED [" + mSubRenderer->dump() + "]";
}

QgsFeatureRendererV2* QgsMaskRendererV2::clone()
QgsFeatureRendererV2* QgsInvertedPolygonRenderer::clone()
{
if ( mSubRenderer.isNull() )
{
return new QgsMaskRendererV2( 0 );
return new QgsInvertedPolygonRenderer( 0 );
}
// else
return new QgsMaskRendererV2( mSubRenderer->clone() );
return new QgsInvertedPolygonRenderer( mSubRenderer->clone() );
}

QgsFeatureRendererV2* QgsMaskRendererV2::create( QDomElement& element )
QgsFeatureRendererV2* QgsInvertedPolygonRenderer::create( QDomElement& element )
{
QgsMaskRendererV2* r = new QgsMaskRendererV2();
QgsInvertedPolygonRenderer* r = new QgsInvertedPolygonRenderer();
//look for an embedded renderer <renderer-v2>
QDomElement embeddedRendererElem = element.firstChildElement( "renderer-v2" );
if ( !embeddedRendererElem.isNull() )
@@ -288,10 +288,10 @@ QgsFeatureRendererV2* QgsMaskRendererV2::create( QDomElement& element )
return r;
}

QDomElement QgsMaskRendererV2::save( QDomDocument& doc )
QDomElement QgsInvertedPolygonRenderer::save( QDomDocument& doc )
{
QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME );
rendererElem.setAttribute( "type", "maskRenderer" );
rendererElem.setAttribute( "type", "invertedPolygonRenderer" );

if ( mSubRenderer )
{
@@ -302,63 +302,63 @@ QDomElement QgsMaskRendererV2::save( QDomDocument& doc )
return rendererElem;
}

QgsSymbolV2* QgsMaskRendererV2::symbolForFeature( QgsFeature& feature )
QgsSymbolV2* QgsInvertedPolygonRenderer::symbolForFeature( QgsFeature& feature )
{
if ( !mSubRenderer ) {
return 0;
}
return mSubRenderer->symbolForFeature( feature );
}

QgsSymbolV2List QgsMaskRendererV2::symbolsForFeature( QgsFeature& feature )
QgsSymbolV2List QgsInvertedPolygonRenderer::symbolsForFeature( QgsFeature& feature )
{
if ( !mSubRenderer ) {
return QgsSymbolV2List();
}
return mSubRenderer->symbolsForFeature( feature );
}

QgsSymbolV2List QgsMaskRendererV2::symbols()
QgsSymbolV2List QgsInvertedPolygonRenderer::symbols()
{
if ( !mSubRenderer ) {
return QgsSymbolV2List();
}
return mSubRenderer->symbols();
}

int QgsMaskRendererV2::capabilities()
int QgsInvertedPolygonRenderer::capabilities()
{
if ( !mSubRenderer ) {
return 0;
}
return mSubRenderer->capabilities();
}

QList<QString> QgsMaskRendererV2::usedAttributes()
QList<QString> QgsInvertedPolygonRenderer::usedAttributes()
{
if ( !mSubRenderer ) {
return QList<QString>();
}
return mSubRenderer->usedAttributes();
}

QgsLegendSymbologyList QgsMaskRendererV2::legendSymbologyItems( QSize iconSize )
QgsLegendSymbologyList QgsInvertedPolygonRenderer::legendSymbologyItems( QSize iconSize )
{
if ( !mSubRenderer ) {
return QgsLegendSymbologyList();
}
return mSubRenderer->legendSymbologyItems( iconSize );
}

QgsLegendSymbolList QgsMaskRendererV2::legendSymbolItems( double scaleDenominator, QString rule )
QgsLegendSymbolList QgsInvertedPolygonRenderer::legendSymbolItems( double scaleDenominator, QString rule )
{
if ( !mSubRenderer ) {
return QgsLegendSymbolList();
}
return mSubRenderer->legendSymbolItems( scaleDenominator, rule );
}

bool QgsMaskRendererV2::willRenderFeature( QgsFeature& feat )
bool QgsInvertedPolygonRenderer::willRenderFeature( QgsFeature& feat )
{
if ( !mSubRenderer ) {
return false;
@@ -1,5 +1,5 @@
/***************************************************************************
qgsmaskrendererv2.h
qgsinvertedpolygonrenderer.h
---------------------
begin : April 2014
copyright : (C) 2014 Hugo Mercier / Oslandia
@@ -12,8 +12,8 @@
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSMASKRENDERERV2_H
#define QGSMASKRENDERERV2_H
#ifndef QGSINVERTEDPOLYGONRENDERER_H
#define QGSINVERTEDPOLYGONRENDERER_H

#include "qgis.h"
#include "qgsrendererv2.h"
@@ -24,7 +24,7 @@
#include <QScopedPointer>

/**
* QgsMaskRendererV2 is a polygon-only feature renderer used to
* QgsInvertedPolygonRenderer is a polygon-only feature renderer used to
* display features inverted, where the exterior is turned to an interior
* and where the exterior theoretically spans the entire plane, allowing
* to mask the surroundings of some features.
@@ -35,15 +35,15 @@
* Features are collected to form one "inverted" polygon
* during renderFeature() and rendered on stopRender().
*/
class CORE_EXPORT QgsMaskRendererV2 : public QgsFeatureRendererV2
class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRendererV2
{
public:

/** Constructor
* @param embeddedRenderer optional embeddedRenderer. If null, a default one will be assigned
*/
QgsMaskRendererV2( const QgsFeatureRendererV2* embeddedRenderer = 0 );
virtual ~QgsMaskRendererV2();
QgsInvertedPolygonRenderer( const QgsFeatureRendererV2* embeddedRenderer = 0 );
virtual ~QgsInvertedPolygonRenderer();

/** Used to clone this feature renderer.*/
virtual QgsFeatureRendererV2* clone();
@@ -106,9 +106,9 @@ class CORE_EXPORT QgsMaskRendererV2 : public QgsFeatureRendererV2

private:
/** Private copy constructor. @see clone() */
QgsMaskRendererV2( const QgsMaskRendererV2& );
QgsInvertedPolygonRenderer( const QgsInvertedPolygonRenderer& );
/** Private assignment operator. @see clone() */
QgsMaskRendererV2& operator=( const QgsMaskRendererV2& );
QgsInvertedPolygonRenderer& operator=( const QgsInvertedPolygonRenderer& );

/** Embedded renderer */
QScopedPointer<QgsFeatureRendererV2> mSubRenderer;
@@ -20,7 +20,7 @@
#include "qgsgraduatedsymbolrendererv2.h"
#include "qgsrulebasedrendererv2.h"
#include "qgspointdisplacementrenderer.h"
#include "qgsmaskrendererv2.h"
#include "qgsinvertedpolygonrenderer.h"

QgsRendererV2Registry::QgsRendererV2Registry()
{
@@ -46,9 +46,9 @@ QgsRendererV2Registry::QgsRendererV2Registry()
QObject::tr( "Point displacement" ),
QgsPointDisplacementRenderer::create ) );

addRenderer( new QgsRendererV2Metadata( "maskRenderer",
QObject::tr( "Mask" ),
QgsMaskRendererV2::create ) );
addRenderer( new QgsRendererV2Metadata( "invertedPolygonRenderer",
QObject::tr( "Inverted polygons" ),
QgsInvertedPolygonRenderer::create ) );
}

QgsRendererV2Registry::~QgsRendererV2Registry()
@@ -20,7 +20,7 @@ symbology-ng/qgssinglesymbolrendererv2widget.cpp
symbology-ng/qgscategorizedsymbolrendererv2widget.cpp
symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp
symbology-ng/qgsrulebasedrendererv2widget.cpp
symbology-ng/qgsmaskrendererv2widget.cpp
symbology-ng/qgsinvertedpolygonrendererwidget.cpp
symbology-ng/qgsrendererv2propertiesdialog.cpp
symbology-ng/qgsstylev2managerdialog.cpp
symbology-ng/qgssymbollevelsv2dialog.cpp
@@ -181,7 +181,7 @@ symbology-ng/qgscategorizedsymbolrendererv2widget.h
symbology-ng/qgsdatadefinedsymboldialog.h
symbology-ng/qgsgraduatedsymbolrendererv2widget.h
symbology-ng/qgsrulebasedrendererv2widget.h
symbology-ng/qgsmaskrendererv2widget.h
symbology-ng/qgsinvertedpolygonrendererwidget.h
symbology-ng/qgsrendererv2widget.h
symbology-ng/qgsrendererv2propertiesdialog.h
symbology-ng/qgsstylev2managerdialog.h

0 comments on commit 0ff587c

Please sign in to comment.