1
/***************************************************************************
3
Import tool for various worldmap analysis output files
8
copyright : (C) 2004 by Tim Sutton
9
email : tim@linfiniti.com
11
***************************************************************************/
13
/***************************************************************************
15
* This program is free software; you can redistribute it and/or modify *
16
* it under the terms of the GNU General Public License as published by *
17
* the Free Software Foundation; either version 2 of the License, or *
18
* (at your option) any later version. *
20
***************************************************************************/
21
/* $Id: plugin.cpp 6301 2006-12-22 07:43:47Z g_j_m $ */
27
#include "qgsmaplayer.h"
36
#include "plugingui.h"
38
// xpm for creating the toolbar icon
42
#define QGISEXTERN extern "C" __declspec( dllexport )
44
#define QGISEXTERN extern "C"
48
static const char * const ident_ = "$Id: plugin.cpp 6301 2006-12-22 07:43:47Z g_j_m $";
50
static const QString name_ = QObject::tr("Graticule Creator");
51
static const QString description_ = QObject::tr("Builds a graticule");
52
static const QString version_ = QObject::tr("Version 0.1");
53
static const QgisPlugin::PLUGINTYPE type_ = QgisPlugin::UI;
55
* Constructor for the plugin. The plugin is passed a pointer to the main app
56
* and an interface object that provides access to exposed functions in QGIS.
57
* @param qgis Pointer to the QGIS main window
58
* @param _qI Pointer to the QGIS interface object
60
QgsGridMakerPlugin::QgsGridMakerPlugin(QgisApp * theQGisApp,
61
QgisIface * theQgisInterFace):
62
QgisPlugin(name_,description_,version_,type_),
63
qgisMainWindowPointer(theQGisApp),
64
qGisInterface(theQgisInterFace)
68
QgsGridMakerPlugin::~QgsGridMakerPlugin()
73
/* Following functions return name, description, version, and type for the plugin */
74
QString QgsGridMakerPlugin::name()
76
return pluginNameQString;
79
QString QgsGridMakerPlugin::version()
81
return pluginVersionQString;
85
QString QgsGridMakerPlugin::description()
87
return pluginDescriptionQString;
91
int QgsGridMakerPlugin::type()
93
return QgisPlugin::UI;
97
* Initialize the GUI interface for the plugin
99
void QgsGridMakerPlugin::initGui()
101
// Create the action for tool
102
myQActionPointer = new QAction(QIcon(icon), tr("&Graticule Creator"), this);
103
myQActionPointer->setWhatsThis(tr("Creates a graticule (grid) and stores the result as a shapefile"));
104
// Connect the action to the run
105
connect(myQActionPointer, SIGNAL(activated()), this, SLOT(run()));
107
// Add the icon to the toolbar
108
qGisInterface->addToolBarIcon(myQActionPointer);
109
qGisInterface->addPluginMenu(tr("&Graticules"), myQActionPointer);
112
//method defined in interface
113
void QgsGridMakerPlugin::help()
118
// Slot called when the buffer menu item is activated
119
void QgsGridMakerPlugin::run()
121
QgsGridMakerPluginGui *myPluginGui=new QgsGridMakerPluginGui(qgisMainWindowPointer, QgisGui::ModalDialogFlags);
122
//listen for when the layer has been made so we can draw it
123
connect(myPluginGui, SIGNAL(drawRasterLayer(QString)), this, SLOT(drawRasterLayer(QString)));
124
connect(myPluginGui, SIGNAL(drawVectorLayer(QString,QString,QString)), this, SLOT(drawVectorLayer(QString,QString,QString)));
127
//!draw a raster layer in the qui - intended to respond to signal sent by diolog when it as finished creating
129
void QgsGridMakerPlugin::drawRasterLayer(QString theQString)
131
qGisInterface->addRasterLayer(theQString);
133
//!draw a vector layer in the qui - intended to respond to signal sent by diolog when it as finished creating a layer
134
////needs to be given vectorLayerPath, baseName, providerKey ("ogr" or "postgres");
135
void QgsGridMakerPlugin::drawVectorLayer(QString thePathNameQString, QString theBaseNameQString, QString theProviderQString)
137
qGisInterface->addVectorLayer( thePathNameQString, theBaseNameQString, theProviderQString);
140
// Unload the plugin by cleaning up the GUI
141
void QgsGridMakerPlugin::unload()
144
qGisInterface->removePluginMenu(tr("&Graticules"),myQActionPointer);
145
qGisInterface->removeToolBarIcon(myQActionPointer);
146
delete myQActionPointer;
149
* Required extern functions needed for every plugin
150
* These functions can be called prior to creating an instance
151
* of the plugin class
153
// Class factory to return a new instance of the plugin class
154
QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer)
156
return new QgsGridMakerPlugin(theQGisAppPointer, theQgisInterfacePointer);
159
// Return the name of the plugin - note that we do not user class members as
160
// the class may not yet be insantiated when this method is called.
161
QGISEXTERN QString name()
166
// Return the description
167
QGISEXTERN QString description()
172
// Return the type (either UI or MapLayer plugin)
173
QGISEXTERN int type()
178
// Return the version number for the plugin
179
QGISEXTERN QString version()
185
QGISEXTERN void unload(QgisPlugin * thePluginPointer)
187
delete thePluginPointer;