1
/***************************************************************************
2
* File Name: plugin.cpp
4
* The georeferencer plugin is a tool for adding projection info to rasters
6
*--------------------------------------------------------------------------
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 $ */
23
/***************************************************************************
24
* QGIS Programming conventions:
26
* mVariableName - a class level member variable
27
* sVariableName - a static class level member variable
28
* variableName() - accessor for a class member (no 'get' in front of name)
29
* setVariableName() - mutator for a class member (prefix with 'set')
31
* Additional useful conventions:
33
* theVariableName - a method parameter (prefix with 'the')
34
* myVariableName - a locally declared variable within a method ('my' prefix)
36
* DO: Use mixed case variable names - myVariableName
37
* DON'T: separate variable names using underscores: my_variable_name (NO!)
39
* **************************************************************************/
42
// Required qgis includes
46
#include <qgsmaplayer.h>
47
#include <qgsrasterlayer.h>
53
#include "plugingui.h"
57
#define QGISEXTERN extern "C" __declspec( dllexport )
59
#define QGISEXTERN extern "C"
62
static const char * const sIdent = "$Id: plugin.cpp 6301 2006-12-22 07:43:47Z g_j_m $";
63
static const QString sName = QObject::tr("Georeferencer");
64
static const QString sDescription = QObject::tr("Adding projection info to rasters");
65
static const QString sPluginVersion = QObject::tr("Version 0.1");
66
static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
68
//////////////////////////////////////////////////////////////////////
70
// THE FOLLOWING METHODS ARE MANDATORY FOR ALL PLUGINS
72
//////////////////////////////////////////////////////////////////////
75
* Constructor for the plugin. The plugin is passed a pointer to the main app
76
* and an interface object that provides access to exposed functions in QGIS.
77
* @param theQGisApp - Pointer to the QGIS main window
78
* @param theQGisInterface - Pointer to the QGIS interface object
80
QgsGeorefPlugin::QgsGeorefPlugin(QgisApp * theQGisApp, QgisIface * theQgisInterface):
81
QgisPlugin(sName,sDescription,sPluginVersion,sPluginType),
83
mQGisIface(theQgisInterface)
87
QgsGeorefPlugin::~QgsGeorefPlugin()
93
* Initialize the GUI interface for the plugin
95
void QgsGeorefPlugin::initGui()
97
// Create the action for tool
98
mQActionPointer = new QAction(QIcon(":/icon.png"), tr("&Georeferencer"), this);
100
// Connect the action to the run
101
connect(mQActionPointer, SIGNAL(activated()), this, SLOT(run()));
103
// Add to the toolbar & menu
104
mQGisIface->addToolBarIcon(mQActionPointer);
105
mQGisIface->addPluginMenu(tr("&Georeferencer"), mQActionPointer);
108
//method defined in interface
109
void QgsGeorefPlugin::help()
114
// Slot called when the buffer menu item is activated
115
void QgsGeorefPlugin::run()
117
QgsGeorefPluginGui *myPluginGui=new QgsGeorefPluginGui(mQGisIface, mQGisApp);
121
// Unload the plugin by cleaning up the GUI
122
void QgsGeorefPlugin::unload()
125
mQGisIface->removePluginMenu(tr("&Georeferencer"),mQActionPointer);
126
mQGisIface->removeToolBarIcon(mQActionPointer);
127
delete mQActionPointer;
130
//////////////////////////////////////////////////////////////////////
132
// END OF MANDATORY PLUGIN METHODS
134
//////////////////////////////////////////////////////////////////////
138
//////////////////////////////////////////////////////////////////////////
141
// THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT
142
// YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN
143
// MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY
146
//////////////////////////////////////////////////////////////////////////
150
* Required extern functions needed for every plugin
151
* These functions can be called prior to creating an instance
152
* of the plugin class
154
// Class factory to return a new instance of the plugin class
155
QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer)
157
return new QgsGeorefPlugin(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()
181
return sPluginVersion;
185
QGISEXTERN void unload(QgisPlugin * thePluginPointer)
187
delete thePluginPointer;