QGIS API Documentation  2.9.0-Master
qgisinterface.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgisinterface.h
3  Interface class for exposing functions in QgisApp for use by plugins
4  -------------------
5  begin : 2004-02-11
6  copyright : (C) 2004 by Gary E.Sherman
7  email : sherman at mrcc.com
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 #ifndef QGISINTERFACE_H
19 #define QGISINTERFACE_H
20 
21 class QAction;
22 class QMenu;
23 class QToolBar;
24 class QDockWidget;
25 class QMainWindow;
26 class QWidget;
27 
28 class QgsAttributeDialog;
29 class QgsComposerView;
30 class QgsFeature;
31 class QgsLayerTreeView;
32 class QgsLegendInterface;
33 class QgsMapCanvas;
34 class QgsMapLayer;
35 class QgsMessageBar;
37 class QgsRasterLayer;
38 class QgsSnappingUtils;
39 class QgsVectorLayer;
41 
42 #include <QObject>
43 #include <QFont>
44 #include <QPair>
45 #include <map>
46 
47 #include <qgis.h>
48 
49 
62 class GUI_EXPORT QgisInterface : public QObject
63 {
64  Q_OBJECT
65 
66  public:
67 
69  QgisInterface();
70 
72  virtual ~QgisInterface();
73 
75  virtual QgsLegendInterface* legendInterface() = 0;
76 
77  virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
78 
79  virtual QgsLayerTreeView* layerTreeView() = 0;
80 
81  public slots: // TODO: do these functions really need to be slots?
82 
83  /* Exposed functions */
84 
86  virtual void zoomFull() = 0;
87 
89  virtual void zoomToPrevious() = 0;
90 
92  virtual void zoomToNext() = 0;
93 
95  virtual void zoomToActiveLayer() = 0;
96 
98  virtual QgsVectorLayer* addVectorLayer( QString vectorLayerPath, QString baseName, QString providerKey ) = 0;
99 
101  virtual QgsRasterLayer* addRasterLayer( QString rasterLayerPath, QString baseName = QString() ) = 0;
102 
104  virtual QgsRasterLayer* addRasterLayer( const QString& url, const QString& layerName, const QString& providerKey ) = 0;
105 
107  virtual bool addProject( QString theProject ) = 0;
109  virtual void newProject( bool thePromptToSaveFlag = false ) = 0;
110 
112  virtual QgsMapLayer *activeLayer() = 0;
113 
116  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
117 
119  virtual int addToolBarIcon( QAction *qAction ) = 0;
120 
129  virtual QAction* addToolBarWidget( QWidget* widget ) = 0;
130 
132  virtual void removeToolBarIcon( QAction *qAction ) = 0;
133 
142  virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;
143 
145  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
146 
148  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
149 
151  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
152 
161  virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
162 
164  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
165 
167  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
168 
177  virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
178 
180  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
181 
183  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
184 
193  virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
194 
196  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
197 
199  virtual QToolBar *addToolBar( QString name ) = 0;
200 
203  virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
204 
206  virtual QgsMapCanvas * mapCanvas() = 0;
207 
209  virtual QWidget * mainWindow() = 0;
210 
212  virtual QgsMessageBar * messageBar() = 0;
213 
215  virtual void addUserInputWidget( QWidget* widget ) = 0;
216 
218  virtual QList<QgsComposerView*> activeComposers() = 0;
219 
225  virtual QgsComposerView* createNewComposer( QString title = QString( "" ) ) = 0;
226 
233  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, QString title = QString( "" ) ) = 0;
234 
236  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
237 
239  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
240 
244  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
245 
247  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
248 
250  virtual QFont defaultStyleSheetFont() = 0;
251 
253  virtual void addPluginToMenu( QString name, QAction* action ) = 0;
254 
256  virtual void removePluginMenu( QString name, QAction* action ) = 0;
257 
259  virtual void insertAddLayerAction( QAction *action ) = 0;
260 
262  virtual void removeAddLayerAction( QAction *action ) = 0;
263 
265  virtual void addPluginToDatabaseMenu( QString name, QAction* action ) = 0;
266 
268  virtual void removePluginDatabaseMenu( QString name, QAction* action ) = 0;
269 
271  virtual void addPluginToRasterMenu( QString name, QAction* action ) = 0;
272 
274  virtual void removePluginRasterMenu( QString name, QAction* action ) = 0;
275 
277  virtual void addPluginToVectorMenu( QString name, QAction* action ) = 0;
278 
280  virtual void removePluginVectorMenu( QString name, QAction* action ) = 0;
281 
283  virtual void addPluginToWebMenu( QString name, QAction* action ) = 0;
284 
286  virtual void removePluginWebMenu( QString name, QAction* action ) = 0;
287 
289  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
290 
292  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
293 
295  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
296 
298  virtual void showAttributeTable( QgsVectorLayer *l ) = 0;
299 
302  virtual void addWindow( QAction *action ) = 0;
303 
306  virtual void removeWindow( QAction *action ) = 0;
307 
309  virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut ) = 0;
310 
312  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
313 
314  // @todo is this deprecated in favour of QgsContextHelp?
323 #ifndef Q_MOC_RUN
324  Q_DECL_DEPRECATED
325 #endif
326  virtual void openURL( QString url, bool useQgisDocDirectory = true ) = 0;
327 
328 
333  // Menus
334 #ifndef Q_MOC_RUN
335  Q_DECL_DEPRECATED
336 #endif
337  virtual QMenu *fileMenu() = 0;
338  virtual QMenu *projectMenu() = 0;
339  virtual QMenu *editMenu() = 0;
340  virtual QMenu *viewMenu() = 0;
341  virtual QMenu *layerMenu() = 0;
342  virtual QMenu *newLayerMenu() = 0;
344  virtual QMenu *addLayerMenu() = 0;
345  virtual QMenu *settingsMenu() = 0;
346  virtual QMenu *pluginMenu() = 0;
347  virtual QMenu *rasterMenu() = 0;
348  virtual QMenu *databaseMenu() = 0;
349  virtual QMenu *vectorMenu() = 0;
350  virtual QMenu *webMenu() = 0;
351  virtual QMenu *firstRightStandardMenu() = 0;
352  virtual QMenu *windowMenu() = 0;
353  virtual QMenu *helpMenu() = 0;
354 
355  // ToolBars
356  virtual QToolBar *fileToolBar() = 0;
357  virtual QToolBar *layerToolBar() = 0;
358  virtual QToolBar *mapNavToolToolBar() = 0;
359  virtual QToolBar *digitizeToolBar() = 0;
360  virtual QToolBar *advancedDigitizeToolBar() = 0;
361  virtual QToolBar *attributesToolBar() = 0;
362  virtual QToolBar *pluginToolBar() = 0;
363  virtual QToolBar *helpToolBar() = 0;
364  virtual QToolBar *rasterToolBar() = 0;
365  virtual QToolBar *vectorToolBar() = 0;
366  virtual QToolBar *databaseToolBar() = 0;
367  virtual QToolBar *webToolBar() = 0;
368 
369  // Project menu actions
370  virtual QAction *actionNewProject() = 0;
371  virtual QAction *actionOpenProject() = 0;
372  virtual QAction *actionSaveProject() = 0;
373  virtual QAction *actionSaveProjectAs() = 0;
374  virtual QAction *actionSaveMapAsImage() = 0;
375  virtual QAction *actionProjectProperties() = 0;
376  virtual QAction *actionPrintComposer() = 0;
377  virtual QAction *actionShowComposerManager() = 0;
378  virtual QAction *actionExit() = 0;
379 
380  // Edit menu actions
381  virtual QAction *actionCutFeatures() = 0;
382  virtual QAction *actionCopyFeatures() = 0;
383  virtual QAction *actionPasteFeatures() = 0;
384  virtual QAction *actionAddFeature() = 0;
385  virtual QAction *actionDeleteSelected() = 0;
386  virtual QAction *actionMoveFeature() = 0;
387  virtual QAction *actionSplitFeatures() = 0;
388  virtual QAction *actionSplitParts() = 0;
389  virtual QAction *actionAddRing() = 0;
390  virtual QAction *actionAddPart() = 0;
391  virtual QAction *actionSimplifyFeature() = 0;
392  virtual QAction *actionDeleteRing() = 0;
393  virtual QAction *actionDeletePart() = 0;
394  virtual QAction *actionNodeTool() = 0;
395 
396  // View menu actions
398  virtual QAction *actionPan() = 0;
400  virtual QAction *actionTouch() = 0;
402  virtual QAction *actionPanToSelected() = 0;
404  virtual QAction *actionZoomIn() = 0;
406  virtual QAction *actionZoomOut() = 0;
408  virtual QAction *actionSelect() = 0;
410  virtual QAction *actionSelectRectangle() = 0;
412  virtual QAction *actionSelectPolygon() = 0;
414  virtual QAction *actionSelectFreehand() = 0;
416  virtual QAction *actionSelectRadius() = 0;
418  virtual QAction *actionIdentify() = 0;
420  virtual QAction *actionFeatureAction() = 0;
422  virtual QAction *actionMeasure() = 0;
424  virtual QAction *actionMeasureArea() = 0;
426  virtual QAction *actionZoomFullExtent() = 0;
428  virtual QAction *actionZoomToLayer() = 0;
430  virtual QAction *actionZoomToSelected() = 0;
432  virtual QAction *actionZoomLast() = 0;
434  virtual QAction *actionZoomNext() = 0;
436  virtual QAction *actionZoomActualSize() = 0;
438  virtual QAction *actionMapTips() = 0;
440  virtual QAction *actionNewBookmark() = 0;
442  virtual QAction *actionShowBookmarks() = 0;
444  virtual QAction *actionDraw() = 0;
445 
446  // Layer menu actions
447  virtual QAction *actionNewVectorLayer() = 0;
448  virtual QAction *actionAddOgrLayer() = 0;
449  virtual QAction *actionAddRasterLayer() = 0;
450  virtual QAction *actionAddPgLayer() = 0;
451  virtual QAction *actionAddWmsLayer() = 0;
452  virtual QAction *actionCopyLayerStyle() = 0;
453  virtual QAction *actionPasteLayerStyle() = 0;
454  virtual QAction *actionOpenTable() = 0;
455  virtual QAction *actionOpenFieldCalculator() = 0;
456  virtual QAction *actionToggleEditing() = 0;
457  virtual QAction *actionSaveActiveLayerEdits() = 0;
458  virtual QAction *actionAllEdits() = 0;
459  virtual QAction *actionSaveEdits() = 0;
460  virtual QAction *actionSaveAllEdits() = 0;
461  virtual QAction *actionRollbackEdits() = 0;
462  virtual QAction *actionRollbackAllEdits() = 0;
463  virtual QAction *actionCancelEdits() = 0;
464  virtual QAction *actionCancelAllEdits() = 0;
465  virtual QAction *actionLayerSaveAs() = 0;
467 #ifndef Q_MOC_RUN
468  Q_DECL_DEPRECATED
469 #endif
470  virtual QAction *actionLayerSelectionSaveAs() = 0;
471  virtual QAction *actionRemoveLayer() = 0;
472  virtual QAction *actionDuplicateLayer() = 0;
473  virtual QAction *actionLayerProperties() = 0;
474  virtual QAction *actionAddToOverview() = 0;
475  virtual QAction *actionAddAllToOverview() = 0;
476  virtual QAction *actionRemoveAllFromOverview() = 0;
477  virtual QAction *actionHideAllLayers() = 0;
478  virtual QAction *actionShowAllLayers() = 0;
479  virtual QAction *actionHideSelectedLayers() = 0;
480  virtual QAction *actionShowSelectedLayers() = 0;
481 
482  // Plugin menu actions
483  virtual QAction *actionManagePlugins() = 0;
484  virtual QAction *actionPluginListSeparator() = 0;
485  virtual QAction *actionShowPythonDialog() = 0;
486 
487  // Settings menu actions
488  virtual QAction *actionToggleFullScreen() = 0;
489  virtual QAction *actionOptions() = 0;
490  virtual QAction *actionCustomProjection() = 0;
491 
492  // Help menu actions
493  virtual QAction *actionHelpContents() = 0;
494  virtual QAction *actionQgisHomePage() = 0;
495  virtual QAction *actionCheckQgisVersion() = 0;
496  virtual QAction *actionAbout() = 0;
497 
505  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
506 
515  virtual QgsAttributeDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
516 
524  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
525 
537  virtual void preloadForm( QString uifile ) = 0;
538 
542  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
543 
545  virtual int messageTimeout() = 0;
546 
547  signals:
551  void currentLayerChanged( QgsMapLayer * layer );
552 
556  void composerAdded( QgsComposerView* v );
557 
561  void composerWillBeRemoved( QgsComposerView* v );
562 
565  void composerRemoved( QgsComposerView* v );
566 
570  void initializationCompleted();
577  void projectRead();
586  void newProjectCreated();
587 
592  void layerSavedAs( QgsMapLayer* l, QString path );
593 };
594 
595 // FIXME: also in core/qgis.h
596 #ifndef QGISEXTERN
597 #ifdef WIN32
598 # define QGISEXTERN extern "C" __declspec( dllexport )
599 #else
600 # define QGISEXTERN extern "C"
601 #endif
602 #endif
603 
604 #endif //#ifndef QGISINTERFACE_H
Methods in this class are used to handle basic operations on vector layers.
QgsLegendInterface Abstract base class to make QgsLegend available to plugins.
Base class for all map layer types.
Definition: qgsmaplayer.h:49
The QgsLayerTreeView class extends QTreeView and provides some additional functionality when working ...
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:42
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:119
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:105
Widget to display the composer items.
QgisInterface Abstract base class defining interfaces exposed by QgisApp and made available to plugin...
Definition: qgisinterface.h:62
This class has all the configuration of snapping and can return answers to snapping queries...
Represents a vector layer which manages a vector based data sets.