Skip to content

Commit

Permalink
[FEATURE]: Add point displacement renderer plugin
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13139 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Mar 21, 2010
1 parent 00bdcdc commit 7b578ed
Show file tree
Hide file tree
Showing 9 changed files with 1,501 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/plugins/CMakeLists.txt
Expand Up @@ -12,6 +12,7 @@ SUBDIRS (copyright_label
diagram_overlay
evis
labeling
point_displacement_renderer
)

IF (POSTGRES_FOUND)
Expand Down
55 changes: 55 additions & 0 deletions src/plugins/point_displacement_renderer/CMakeLists.txt
@@ -0,0 +1,55 @@
########################################################
# Files

SET (POINT_DISPLACEMENT_SRCS
qgsdisplacementplugin.cpp
qgspointdisplacementrenderer.cpp
qgspointdisplacementrendererwidget.cpp
)

SET (POINT_DISPLACEMENT_UIS
qgspointdisplacementrendererwidgetbase.ui
)

SET (POINT_DISPLACEMENT_MOC_HDRS
qgspointdisplacementrendererwidget.h
)

########################################################
# Build

QT4_WRAP_UI (POINT_DISPLACEMENT_UIS_H ${POINT_DISPLACEMENT_UIS})

QT4_WRAP_CPP (POINT_DISPLACEMENT_MOC_SRCS ${POINT_DISPLACEMENT_MOC_HDRS})

ADD_LIBRARY (displacementplugin MODULE
${POINT_DISPLACEMENT_SRCS}
${POINT_DISPLACEMENT_UIS_H}
${POINT_DISPLACEMENT_MOC_SRCS}
)

INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../../ui
../../core
../../core/symbology-ng
../../core/spatialindex
../../gui
../../gui/symbology-ng
..
.
)

TARGET_LINK_LIBRARIES(displacementplugin
qgis_core
qgis_gui
)


########################################################
# Install

INSTALL(TARGETS displacementplugin
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}
)
86 changes: 86 additions & 0 deletions src/plugins/point_displacement_renderer/qgsdisplacementplugin.cpp
@@ -0,0 +1,86 @@
/***************************************************************************
qgsdisplacementplugin.cpp
-------------------------
begin : January 26, 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco at hugis dot net
***************************************************************************/

/***************************************************************************
* *
* 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. *
* *
***************************************************************************/

#include "qgsdisplacementplugin.h"
#include "qgisinterface.h"
#include "qgspointdisplacementrenderer.h"
#include "qgspointdisplacementrendererwidget.h"
#include "qgsrendererv2registry.h"
#include "qgssymbollayerv2registry.h"
#include <QObject>

static const QString name_ = QObject::tr( "Displacement plugin" );
static const QString description_ = QObject::tr( "Adds a new renderer that automatically handles point displacement in case they have the same position" );
static const QString version_ = QObject::tr( "Version 0.1" );

QgsDisplacementPlugin::QgsDisplacementPlugin( QgisInterface* iface ): mIface( iface )
{

}

QgsDisplacementPlugin::~QgsDisplacementPlugin()
{

}

void QgsDisplacementPlugin::initGui()
{
//Add new renderer to the registry

QgsRendererV2Registry::instance()->addRenderer( new QgsRendererV2Metadata( "pointDisplacement",
QObject::tr( "point Displacement" ),
QgsPointDisplacementRenderer::create, QIcon(),
QgsPointDisplacementRendererWidget::create ) );
}

void QgsDisplacementPlugin::unload()
{
//Remove renderer type from the registry
QgsRendererV2Registry::instance()->removeRenderer( "pointDisplacement" );
}

QGISEXTERN QgisPlugin * classFactory( QgisInterface * theQgisInterfacePointer )
{
return new QgsDisplacementPlugin( theQgisInterfacePointer );
}

QGISEXTERN QString name()
{
return name_;
}

QGISEXTERN QString description()
{
return description_;
}

QGISEXTERN QString version()
{
return version_;
}

QGISEXTERN int type()
{
return QgisPlugin::UI;
}

QGISEXTERN void unload( QgisPlugin* thePluginPointer )
{
delete thePluginPointer;
}


40 changes: 40 additions & 0 deletions src/plugins/point_displacement_renderer/qgsdisplacementplugin.h
@@ -0,0 +1,40 @@
/***************************************************************************
qgsdisplacementplugin.h
-----------------------
begin : January 26, 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco at hugis dot net
***************************************************************************/

/***************************************************************************
* *
* 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. *
* *
***************************************************************************/

#ifndef QGSDISPLACEMENTPLUGIN_H
#define QGSDISPLACEMENTPLUGIN_H

#include "qgisplugin.h"

class QgisInterface;

/**A plugin that adds a point displacement renderer to the symbol registry*/
class QgsDisplacementPlugin: public QgisPlugin
{
public:
QgsDisplacementPlugin( QgisInterface* iface );
~QgsDisplacementPlugin();
/**Adds renderer to the registry*/
void initGui();
/**Removes renderer from the registry*/
void unload();

private:
QgisInterface* mIface;
};

#endif // QGSDISPLACEMENTPLUGIN_H

0 comments on commit 7b578ed

Please sign in to comment.