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,v 1.12.2.1 2005/09/17 23:32:11 timlinux Exp $ */
26
#include <qgsmaplayer.h>
27
#include <qgsrasterlayer.h>
33
#include <qmessagebox.h>
34
#include <qpopupmenu.h>
35
#include <qlineedit.h>
37
#include <qapplication.h>
44
#include "plugingui.h"
46
// xpm for creating the toolbar icon
49
#define QGISEXTERN extern "C" __declspec( dllexport )
51
#define QGISEXTERN extern "C"
54
static const char * const sIdent = "$Id: plugin.cpp,v 1.12.2.1 2005/09/17 23:32:11 timlinux Exp $";
55
static const char * const sName = "[menuitemname]";
56
static const char * const sDescription = "[plugindescription]";
57
static const char * const sPluginVersion = "Version 0.1";
58
static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
60
//////////////////////////////////////////////////////////////////////
62
// THE FOLLOWING METHODS ARE MANDATORY FOR ALL PLUGINS
64
//////////////////////////////////////////////////////////////////////
67
* Constructor for the plugin. The plugin is passed a pointer to the main app
68
* and an interface object that provides access to exposed functions in QGIS.
69
* @param theQGisApp - Pointer to the QGIS main window
70
* @param theQGisInterface - Pointer to the QGIS interface object
72
[pluginname]::[pluginname](QgisApp * theQGisApp,
73
QgisIface * theQgisInterface):
75
mQGisIface(theQgisInterface),
76
QgisPlugin(sName,sDescription,sPluginVersion,sPluginType)
80
[pluginname]::~[pluginname]()
86
* Initialize the GUI interface for the plugin
88
void [pluginname]::initGui()
90
QPopupMenu *pluginMenu = mQGisIface->getPluginMenu("&[menuname]");
91
mMenuId = pluginMenu->insertItem(QIconSet(icon),"&[menuitemname]", this, SLOT(run()));
93
pluginMenu->setWhatsThis(mMenuId, tr("Replace this with a short description of the what the plugin does"));
95
// Create the action for tool
96
mQActionPointer = new QAction("[menuitemname]", QIconSet(icon), "&icon",0, this, "run");
97
// Connect the action to the run
98
connect(mQActionPointer, SIGNAL(activated()), this, SLOT(run()));
100
mToolBarPointer = new QToolBar((QMainWindow *) mQGisApp, "[menuname]");
101
mToolBarPointer->setLabel("[menuitemname]");
102
// Add the to the toolbar
103
mQGisIface->addToolBarIcon(mQActionPointer);
106
//method defined in interface
107
void [pluginname]::help()
112
// Slot called when the buffer menu item is activated
113
void [pluginname]::run()
115
[pluginname]Gui *myPluginGui=new [pluginname]Gui(mQGisApp,"[menuitemname]",true,0);
116
//listen for when the layer has been made so we can draw it
117
connect(myPluginGui, SIGNAL(drawRasterLayer(QString)), this, SLOT(drawRasterLayer(QString)));
118
connect(myPluginGui, SIGNAL(drawVectorLayer(QString,QString,QString)), this, SLOT(drawVectorLayer(QString,QString,QString)));
122
// Unload the plugin by cleaning up the GUI
123
void [pluginname]::unload()
126
mQGisIface->removePluginMenuItem("&[menuname]",mMenuId);
127
mQGisIface->removeToolBarIcon(mQActionPointer);
128
delete mQActionPointer;
131
//////////////////////////////////////////////////////////////////////
133
// END OF MANDATORY PLUGIN METHODS
135
//////////////////////////////////////////////////////////////////////
137
// The following methods are provided to demonstrate how you can
138
// load a vector or raster layer into the main gui. Please delete
139
// if you are not intending to use these. Note also that there are
140
// ways in which layers can be loaded.
143
//!draw a raster layer in the qui - intended to respond to signal sent by diolog when it as finished creating
145
void [pluginname]::drawRasterLayer(QString theQString)
147
mQGisIface->addRasterLayer(theQString);
150
//!draw a vector layer in the qui - intended to respond to signal sent by
151
// dialog when it as finished creating a layer. It needs to be given
152
// vectorLayerPath, baseName, providerKey ("ogr" or "postgres");
153
void [pluginname]::drawVectorLayer(QString thePathNameQString, QString theBaseNameQString, QString theProviderQString)
155
mQGisIface->addVectorLayer( thePathNameQString, theBaseNameQString, theProviderQString);
159
//////////////////////////////////////////////////////////////////////////
162
// THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT
163
// YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN
164
// MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY
167
//////////////////////////////////////////////////////////////////////////
171
* Required extern functions needed for every plugin
172
* These functions can be called prior to creating an instance
173
* of the plugin class
175
// Class factory to return a new instance of the plugin class
176
QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer)
178
return new [pluginname](theQGisAppPointer, theQgisInterfacePointer);
180
// Return the name of the plugin - note that we do not user class members as
181
// the class may not yet be insantiated when this method is called.
182
QGISEXTERN QString name()
187
// Return the description
188
QGISEXTERN QString description()
193
// Return the type (either UI or MapLayer plugin)
194
QGISEXTERN int type()
199
// Return the version number for the plugin
200
QGISEXTERN QString version()
202
return sPluginVersion;
206
QGISEXTERN void unload(QgisPlugin * thePluginPointer)
208
delete thePluginPointer;