Skip to content
Permalink
Browse files

[FEATURE]: Add point displacement renderer plugin

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13139 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Mar 21, 2010
1 parent 399d42c commit e97c28c6226c3ea9c706202823ce42f27baf18c0
@@ -12,6 +12,7 @@ SUBDIRS (copyright_label
diagram_overlay
evis
labeling
point_displacement_renderer
)

IF (POSTGRES_FOUND)
@@ -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}
)
@@ -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;
}


@@ -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 e97c28c

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