2004-01-19 18:17:13 +00:00
|
|
|
#ifndef QGISEXAMPLEPLUGIN_H
|
|
|
|
#define QGISEXAMPLEPLUGIN_H
|
|
|
|
#include "../qgisplugin.h"
|
|
|
|
#include <qwidget.h>
|
|
|
|
#include <qmainwindow.h>
|
2004-01-19 20:22:02 +00:00
|
|
|
|
|
|
|
class QMessageBox;
|
|
|
|
class QToolBar;
|
|
|
|
class QMenuBar;
|
|
|
|
class QPopupMenu;
|
2004-01-19 18:17:13 +00:00
|
|
|
//#include "qgsworkerclass.h"
|
|
|
|
#include "../../src/qgisapp.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \class ExamplePlugin
|
2004-01-19 20:22:02 +00:00
|
|
|
* \brief Example plugin for QGIS
|
|
|
|
*
|
|
|
|
* This code is an example plugin for QGIS and a demonstration of the API
|
|
|
|
* All QGIS plugins must inherit from the abstract base class QgisPlugin. A
|
|
|
|
* plugin must implement the virtual functions defined in QgisPlugin:
|
|
|
|
* *name
|
|
|
|
* *version
|
|
|
|
* *description
|
|
|
|
* *type
|
2004-01-19 18:17:13 +00:00
|
|
|
*
|
2004-01-19 20:22:02 +00:00
|
|
|
* In addition, a plugin must implement a the classFactory and unload
|
|
|
|
* functions. Note that these functions must be declared as extern "C"
|
2004-01-19 18:17:13 +00:00
|
|
|
*
|
2004-01-19 20:22:02 +00:00
|
|
|
* This plugin is not very useful. When loaded, it installs a new menu with two
|
|
|
|
* items and illustrates how to connect the items to slots which handle menu events.
|
|
|
|
* It also installs a toolbar with one button. When clicked, the button zooms the
|
|
|
|
* map to the previous extent.
|
|
|
|
*
|
|
|
|
* After the UI elements are initialized the plugin zooms the map canvas to the
|
|
|
|
* full extent of all layers.
|
2004-01-19 18:17:13 +00:00
|
|
|
*/
|
2004-03-08 23:50:05 +00:00
|
|
|
class ExamplePlugin:public QObject, public QgisPlugin
|
|
|
|
{
|
|
|
|
Q_OBJECT public:
|
2004-01-19 18:17:13 +00:00
|
|
|
/**
|
|
|
|
* Constructor for a plugin. The QgisApp and QgisIface pointers are passed by
|
|
|
|
* QGIS when it attempts to instantiate the plugin.
|
|
|
|
* @param qgis Pointer to the QgisApp object
|
|
|
|
* @param qI Pointer to the QgisIface object.
|
|
|
|
*/
|
2004-03-08 23:50:05 +00:00
|
|
|
ExamplePlugin(QgisApp * qgis, QgisIface * qI);
|
2004-01-19 18:17:13 +00:00
|
|
|
//! init the gui
|
|
|
|
virtual void initGui();
|
|
|
|
//! Destructor
|
2004-03-08 23:50:05 +00:00
|
|
|
virtual ~ ExamplePlugin();
|
|
|
|
public slots:
|
2004-01-19 20:22:02 +00:00
|
|
|
//! open something
|
2004-03-08 23:50:05 +00:00
|
|
|
void open();
|
2004-01-19 20:22:02 +00:00
|
|
|
//! create something new
|
2004-03-08 23:50:05 +00:00
|
|
|
void newThing();
|
2004-01-19 20:22:02 +00:00
|
|
|
//! zoom the map to the previous extent
|
2004-03-08 23:50:05 +00:00
|
|
|
void zoomPrevious();
|
2004-01-19 20:22:02 +00:00
|
|
|
//! unload the plugin
|
|
|
|
void unload();
|
2004-01-19 18:17:13 +00:00
|
|
|
private:
|
2004-03-08 23:50:05 +00:00
|
|
|
int ptype;
|
2004-01-19 20:22:02 +00:00
|
|
|
//! Id of the plugin's menu. Used for unloading
|
|
|
|
int menuId;
|
|
|
|
//! Pointer to our toolbar
|
|
|
|
QToolBar *toolBar;
|
|
|
|
//! Pointer to our menu
|
2004-03-08 23:50:05 +00:00
|
|
|
QMenuBar *menu;
|
2004-01-19 20:22:02 +00:00
|
|
|
//! Pionter to QGIS main application object
|
2004-03-08 23:50:05 +00:00
|
|
|
QgisApp *qgisMainWindow;
|
2004-01-19 20:22:02 +00:00
|
|
|
//! Pointer to the QGIS interface object
|
2004-03-08 23:50:05 +00:00
|
|
|
QgisIface *qI;
|
2004-01-19 18:17:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|