Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added renderer registry to allow custom renderers. GUI for renderers …
…is still hardcoded. git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11932 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
wonder
committed
Nov 6, 2009
1 parent
d34fb39
commit 910d9e8
Showing
11 changed files
with
229 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "qgsrendererv2registry.h" | ||
|
||
// default renderers | ||
#include "qgssinglesymbolrendererv2.h" | ||
#include "qgscategorizedsymbolrendererv2.h" | ||
#include "qgsgraduatedsymbolrendererv2.h" | ||
|
||
|
||
QgsRendererV2Registry* QgsRendererV2Registry::mInstance = NULL; | ||
|
||
QgsRendererV2Registry::QgsRendererV2Registry() | ||
{ | ||
// add default renderers | ||
addRenderer("singleSymbol", QgsSingleSymbolRendererV2::create); | ||
addRenderer("categorizedSymbol", QgsCategorizedSymbolRendererV2::create); | ||
addRenderer("graduatedSymbol", QgsGraduatedSymbolRendererV2::create); | ||
} | ||
|
||
QgsRendererV2Registry* QgsRendererV2Registry::instance() | ||
{ | ||
if (!mInstance) | ||
mInstance = new QgsRendererV2Registry(); | ||
|
||
return mInstance; | ||
} | ||
|
||
|
||
bool QgsRendererV2Registry::addRenderer(QString rendererName, QgsRendererV2CreateFunc pfCreate) | ||
{ | ||
if (mRenderers.contains(rendererName)) | ||
return false; | ||
mRenderers.insert(rendererName, pfCreate); | ||
return true; | ||
} | ||
|
||
bool QgsRendererV2Registry::removeRenderer(QString rendererName) | ||
{ | ||
if (!mRenderers.contains(rendererName)) | ||
return false; | ||
mRenderers.remove(rendererName); | ||
return true; | ||
} | ||
|
||
QgsRendererV2CreateFunc QgsRendererV2Registry::rendererCreateFunction(QString rendererName) | ||
{ | ||
return mRenderers.value(rendererName, NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef QGSRENDERERV2REGISTRY_H | ||
#define QGSRENDERERV2REGISTRY_H | ||
|
||
#include <QMap> | ||
|
||
class QgsFeatureRendererV2; | ||
class QDomElement; | ||
|
||
typedef QgsFeatureRendererV2* (*QgsRendererV2CreateFunc)(QDomElement&); | ||
|
||
/** | ||
Registry of renderers. | ||
This is a singleton, renderers can be added / removed at any time | ||
*/ | ||
class QgsRendererV2Registry | ||
{ | ||
public: | ||
|
||
static QgsRendererV2Registry* instance(); | ||
|
||
bool addRenderer(QString rendererName, QgsRendererV2CreateFunc pfCreate); | ||
|
||
bool removeRenderer(QString rendererName); | ||
|
||
QgsRendererV2CreateFunc rendererCreateFunction(QString rendererName); | ||
|
||
protected: | ||
//! protected constructor | ||
QgsRendererV2Registry(); | ||
|
||
static QgsRendererV2Registry* mInstance; | ||
|
||
QMap<QString, QgsRendererV2CreateFunc> mRenderers; | ||
}; | ||
|
||
#endif // QGSRENDERERV2REGISTRY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.