Skip to content

Commit e97c28c

Browse files
author
mhugent
committed
[FEATURE]: Add point displacement renderer plugin
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13139 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 399d42c commit e97c28c

9 files changed

+1501
-0
lines changed

src/plugins/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ SUBDIRS (copyright_label
1212
diagram_overlay
1313
evis
1414
labeling
15+
point_displacement_renderer
1516
)
1617

1718
IF (POSTGRES_FOUND)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
########################################################
2+
# Files
3+
4+
SET (POINT_DISPLACEMENT_SRCS
5+
qgsdisplacementplugin.cpp
6+
qgspointdisplacementrenderer.cpp
7+
qgspointdisplacementrendererwidget.cpp
8+
)
9+
10+
SET (POINT_DISPLACEMENT_UIS
11+
qgspointdisplacementrendererwidgetbase.ui
12+
)
13+
14+
SET (POINT_DISPLACEMENT_MOC_HDRS
15+
qgspointdisplacementrendererwidget.h
16+
)
17+
18+
########################################################
19+
# Build
20+
21+
QT4_WRAP_UI (POINT_DISPLACEMENT_UIS_H ${POINT_DISPLACEMENT_UIS})
22+
23+
QT4_WRAP_CPP (POINT_DISPLACEMENT_MOC_SRCS ${POINT_DISPLACEMENT_MOC_HDRS})
24+
25+
ADD_LIBRARY (displacementplugin MODULE
26+
${POINT_DISPLACEMENT_SRCS}
27+
${POINT_DISPLACEMENT_UIS_H}
28+
${POINT_DISPLACEMENT_MOC_SRCS}
29+
)
30+
31+
INCLUDE_DIRECTORIES(
32+
${CMAKE_CURRENT_BINARY_DIR}
33+
${CMAKE_CURRENT_BINARY_DIR}/../../ui
34+
../../core
35+
../../core/symbology-ng
36+
../../core/spatialindex
37+
../../gui
38+
../../gui/symbology-ng
39+
..
40+
.
41+
)
42+
43+
TARGET_LINK_LIBRARIES(displacementplugin
44+
qgis_core
45+
qgis_gui
46+
)
47+
48+
49+
########################################################
50+
# Install
51+
52+
INSTALL(TARGETS displacementplugin
53+
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
54+
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}
55+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/***************************************************************************
2+
qgsdisplacementplugin.cpp
3+
-------------------------
4+
begin : January 26, 2010
5+
copyright : (C) 2010 by Marco Hugentobler
6+
email : marco at hugis dot net
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#include "qgsdisplacementplugin.h"
19+
#include "qgisinterface.h"
20+
#include "qgspointdisplacementrenderer.h"
21+
#include "qgspointdisplacementrendererwidget.h"
22+
#include "qgsrendererv2registry.h"
23+
#include "qgssymbollayerv2registry.h"
24+
#include <QObject>
25+
26+
static const QString name_ = QObject::tr( "Displacement plugin" );
27+
static const QString description_ = QObject::tr( "Adds a new renderer that automatically handles point displacement in case they have the same position" );
28+
static const QString version_ = QObject::tr( "Version 0.1" );
29+
30+
QgsDisplacementPlugin::QgsDisplacementPlugin( QgisInterface* iface ): mIface( iface )
31+
{
32+
33+
}
34+
35+
QgsDisplacementPlugin::~QgsDisplacementPlugin()
36+
{
37+
38+
}
39+
40+
void QgsDisplacementPlugin::initGui()
41+
{
42+
//Add new renderer to the registry
43+
44+
QgsRendererV2Registry::instance()->addRenderer( new QgsRendererV2Metadata( "pointDisplacement",
45+
QObject::tr( "point Displacement" ),
46+
QgsPointDisplacementRenderer::create, QIcon(),
47+
QgsPointDisplacementRendererWidget::create ) );
48+
}
49+
50+
void QgsDisplacementPlugin::unload()
51+
{
52+
//Remove renderer type from the registry
53+
QgsRendererV2Registry::instance()->removeRenderer( "pointDisplacement" );
54+
}
55+
56+
QGISEXTERN QgisPlugin * classFactory( QgisInterface * theQgisInterfacePointer )
57+
{
58+
return new QgsDisplacementPlugin( theQgisInterfacePointer );
59+
}
60+
61+
QGISEXTERN QString name()
62+
{
63+
return name_;
64+
}
65+
66+
QGISEXTERN QString description()
67+
{
68+
return description_;
69+
}
70+
71+
QGISEXTERN QString version()
72+
{
73+
return version_;
74+
}
75+
76+
QGISEXTERN int type()
77+
{
78+
return QgisPlugin::UI;
79+
}
80+
81+
QGISEXTERN void unload( QgisPlugin* thePluginPointer )
82+
{
83+
delete thePluginPointer;
84+
}
85+
86+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/***************************************************************************
2+
qgsdisplacementplugin.h
3+
-----------------------
4+
begin : January 26, 2010
5+
copyright : (C) 2010 by Marco Hugentobler
6+
email : marco at hugis dot net
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#ifndef QGSDISPLACEMENTPLUGIN_H
19+
#define QGSDISPLACEMENTPLUGIN_H
20+
21+
#include "qgisplugin.h"
22+
23+
class QgisInterface;
24+
25+
/**A plugin that adds a point displacement renderer to the symbol registry*/
26+
class QgsDisplacementPlugin: public QgisPlugin
27+
{
28+
public:
29+
QgsDisplacementPlugin( QgisInterface* iface );
30+
~QgsDisplacementPlugin();
31+
/**Adds renderer to the registry*/
32+
void initGui();
33+
/**Removes renderer from the registry*/
34+
void unload();
35+
36+
private:
37+
QgisInterface* mIface;
38+
};
39+
40+
#endif // QGSDISPLACEMENTPLUGIN_H

0 commit comments

Comments
 (0)