QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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;
32 class QgsLayerTreeView;
33 class QgsLegendInterface;
34 class QgsMapCanvas;
35 class QgsMapLayer;
36 class QgsMessageBar;
38 class QgsRasterLayer;
39 class QgsSnappingUtils;
40 class QgsVectorLayer;
42 
43 #include <QObject>
44 #include <QFont>
45 #include <QPair>
46 #include <map>
47 
48 #include "qgis.h"
49 
50 
63 class GUI_EXPORT QgisInterface : public QObject
64 {
65  Q_OBJECT
66 
67  public:
68 
70  QgisInterface();
71 
73  virtual ~QgisInterface();
74 
76  virtual QgsLegendInterface* legendInterface() = 0;
77 
78  virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
79 
80  virtual QgsLayerTreeView* layerTreeView() = 0;
81 
82  public slots: // TODO: do these functions really need to be slots?
83 
84  /* Exposed functions */
85 
87  virtual void zoomFull() = 0;
88 
90  virtual void zoomToPrevious() = 0;
91 
93  virtual void zoomToNext() = 0;
94 
96  virtual void zoomToActiveLayer() = 0;
97 
99  virtual QgsVectorLayer* addVectorLayer( QString vectorLayerPath, QString baseName, QString providerKey ) = 0;
100 
102  virtual QgsRasterLayer* addRasterLayer( QString rasterLayerPath, QString baseName = QString() ) = 0;
103 
105  virtual QgsRasterLayer* addRasterLayer( const QString& url, const QString& layerName, const QString& providerKey ) = 0;
106 
108  virtual bool addProject( QString theProject ) = 0;
110  virtual void newProject( bool thePromptToSaveFlag = false ) = 0;
111 
113  virtual QgsMapLayer *activeLayer() = 0;
114 
117  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
118 
120  virtual int addToolBarIcon( QAction *qAction ) = 0;
121 
130  virtual QAction* addToolBarWidget( QWidget* widget ) = 0;
131 
133  virtual void removeToolBarIcon( QAction *qAction ) = 0;
134 
143  virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;
144 
146  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
147 
149  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
150 
152  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
153 
162  virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
163 
165  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
166 
168  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
169 
178  virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
179 
181  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
182 
184  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
185 
194  virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
195 
197  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
198 
200  virtual QToolBar *addToolBar( QString name ) = 0;
201 
204  virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
205 
207  virtual QgsMapCanvas * mapCanvas() = 0;
208 
214  virtual QgsLayerTreeMapCanvasBridge* layerTreeCanvasBridge() = 0;
215 
217  virtual QWidget * mainWindow() = 0;
218 
220  virtual QgsMessageBar * messageBar() = 0;
221 
223  virtual void addUserInputWidget( QWidget* widget ) = 0;
224 
226  virtual QList<QgsComposerView*> activeComposers() = 0;
227 
233  virtual QgsComposerView* createNewComposer( QString title = QString( "" ) ) = 0;
234 
241  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, QString title = QString( "" ) ) = 0;
242 
244  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
245 
247  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
248 
252  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
253 
255  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
256 
258  virtual QFont defaultStyleSheetFont() = 0;
259 
261  virtual void addPluginToMenu( QString name, QAction* action ) = 0;
262 
264  virtual void removePluginMenu( QString name, QAction* action ) = 0;
265 
267  virtual void insertAddLayerAction( QAction *action ) = 0;
268 
270  virtual void removeAddLayerAction( QAction *action ) = 0;
271 
273  virtual void addPluginToDatabaseMenu( QString name, QAction* action ) = 0;
274 
276  virtual void removePluginDatabaseMenu( QString name, QAction* action ) = 0;
277 
279  virtual void addPluginToRasterMenu( QString name, QAction* action ) = 0;
280 
282  virtual void removePluginRasterMenu( QString name, QAction* action ) = 0;
283 
285  virtual void addPluginToVectorMenu( QString name, QAction* action ) = 0;
286 
288  virtual void removePluginVectorMenu( QString name, QAction* action ) = 0;
289 
291  virtual void addPluginToWebMenu( QString name, QAction* action ) = 0;
292 
294  virtual void removePluginWebMenu( QString name, QAction* action ) = 0;
295 
297  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
298 
300  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
301 
303  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
304 
306  virtual void showAttributeTable( QgsVectorLayer *l ) = 0;
307 
310  virtual void addWindow( QAction *action ) = 0;
311 
314  virtual void removeWindow( QAction *action ) = 0;
315 
317  virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut ) = 0;
318 
320  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
321 
322  // @todo is this deprecated in favour of QgsContextHelp?
331 #ifndef Q_MOC_RUN
332  Q_DECL_DEPRECATED
333 #endif
334  virtual void openURL( QString url, bool useQgisDocDirectory = true ) = 0;
335 
336 
341  // Menus
342 #ifndef Q_MOC_RUN
343  Q_DECL_DEPRECATED
344 #endif
345  virtual QMenu *fileMenu() = 0;
346  virtual QMenu *projectMenu() = 0;
347  virtual QMenu *editMenu() = 0;
348  virtual QMenu *viewMenu() = 0;
349  virtual QMenu *layerMenu() = 0;
350  virtual QMenu *newLayerMenu() = 0;
352  virtual QMenu *addLayerMenu() = 0;
353  virtual QMenu *settingsMenu() = 0;
354  virtual QMenu *pluginMenu() = 0;
355  virtual QMenu *rasterMenu() = 0;
356  virtual QMenu *databaseMenu() = 0;
357  virtual QMenu *vectorMenu() = 0;
358  virtual QMenu *webMenu() = 0;
359  virtual QMenu *firstRightStandardMenu() = 0;
360  virtual QMenu *windowMenu() = 0;
361  virtual QMenu *helpMenu() = 0;
362 
363  // ToolBars
364  virtual QToolBar *fileToolBar() = 0;
365  virtual QToolBar *layerToolBar() = 0;
366  virtual QToolBar *mapNavToolToolBar() = 0;
367  virtual QToolBar *digitizeToolBar() = 0;
368  virtual QToolBar *advancedDigitizeToolBar() = 0;
369  virtual QToolBar *attributesToolBar() = 0;
370  virtual QToolBar *pluginToolBar() = 0;
371  virtual QToolBar *helpToolBar() = 0;
372  virtual QToolBar *rasterToolBar() = 0;
373  virtual QToolBar *vectorToolBar() = 0;
374  virtual QToolBar *databaseToolBar() = 0;
375  virtual QToolBar *webToolBar() = 0;
376 
377  // Project menu actions
378  virtual QAction *actionNewProject() = 0;
379  virtual QAction *actionOpenProject() = 0;
380  virtual QAction *actionSaveProject() = 0;
381  virtual QAction *actionSaveProjectAs() = 0;
382  virtual QAction *actionSaveMapAsImage() = 0;
383  virtual QAction *actionProjectProperties() = 0;
384  virtual QAction *actionPrintComposer() = 0;
385  virtual QAction *actionShowComposerManager() = 0;
386  virtual QAction *actionExit() = 0;
387 
388  // Edit menu actions
389  virtual QAction *actionCutFeatures() = 0;
390  virtual QAction *actionCopyFeatures() = 0;
391  virtual QAction *actionPasteFeatures() = 0;
392  virtual QAction *actionAddFeature() = 0;
393  virtual QAction *actionDeleteSelected() = 0;
394  virtual QAction *actionMoveFeature() = 0;
395  virtual QAction *actionSplitFeatures() = 0;
396  virtual QAction *actionSplitParts() = 0;
397  virtual QAction *actionAddRing() = 0;
398  virtual QAction *actionAddPart() = 0;
399  virtual QAction *actionSimplifyFeature() = 0;
400  virtual QAction *actionDeleteRing() = 0;
401  virtual QAction *actionDeletePart() = 0;
402  virtual QAction *actionNodeTool() = 0;
403 
404  // View menu actions
406  virtual QAction *actionPan() = 0;
408  virtual QAction *actionTouch() = 0;
410  virtual QAction *actionPanToSelected() = 0;
412  virtual QAction *actionZoomIn() = 0;
414  virtual QAction *actionZoomOut() = 0;
416  virtual QAction *actionSelect() = 0;
418  virtual QAction *actionSelectRectangle() = 0;
420  virtual QAction *actionSelectPolygon() = 0;
422  virtual QAction *actionSelectFreehand() = 0;
424  virtual QAction *actionSelectRadius() = 0;
426  virtual QAction *actionIdentify() = 0;
428  virtual QAction *actionFeatureAction() = 0;
430  virtual QAction *actionMeasure() = 0;
432  virtual QAction *actionMeasureArea() = 0;
434  virtual QAction *actionZoomFullExtent() = 0;
436  virtual QAction *actionZoomToLayer() = 0;
438  virtual QAction *actionZoomToSelected() = 0;
440  virtual QAction *actionZoomLast() = 0;
442  virtual QAction *actionZoomNext() = 0;
444  virtual QAction *actionZoomActualSize() = 0;
446  virtual QAction *actionMapTips() = 0;
448  virtual QAction *actionNewBookmark() = 0;
450  virtual QAction *actionShowBookmarks() = 0;
452  virtual QAction *actionDraw() = 0;
453 
454  // Layer menu actions
455  virtual QAction *actionNewVectorLayer() = 0;
456  virtual QAction *actionAddOgrLayer() = 0;
457  virtual QAction *actionAddRasterLayer() = 0;
458  virtual QAction *actionAddPgLayer() = 0;
459  virtual QAction *actionAddWmsLayer() = 0;
460  virtual QAction *actionCopyLayerStyle() = 0;
461  virtual QAction *actionPasteLayerStyle() = 0;
462  virtual QAction *actionOpenTable() = 0;
463  virtual QAction *actionOpenFieldCalculator() = 0;
464  virtual QAction *actionToggleEditing() = 0;
465  virtual QAction *actionSaveActiveLayerEdits() = 0;
466  virtual QAction *actionAllEdits() = 0;
467  virtual QAction *actionSaveEdits() = 0;
468  virtual QAction *actionSaveAllEdits() = 0;
469  virtual QAction *actionRollbackEdits() = 0;
470  virtual QAction *actionRollbackAllEdits() = 0;
471  virtual QAction *actionCancelEdits() = 0;
472  virtual QAction *actionCancelAllEdits() = 0;
473  virtual QAction *actionLayerSaveAs() = 0;
475 #ifndef Q_MOC_RUN
476  Q_DECL_DEPRECATED
477 #endif
478  virtual QAction *actionLayerSelectionSaveAs() = 0;
479  virtual QAction *actionRemoveLayer() = 0;
480  virtual QAction *actionDuplicateLayer() = 0;
481  virtual QAction *actionLayerProperties() = 0;
482  virtual QAction *actionAddToOverview() = 0;
483  virtual QAction *actionAddAllToOverview() = 0;
484  virtual QAction *actionRemoveAllFromOverview() = 0;
485  virtual QAction *actionHideAllLayers() = 0;
486  virtual QAction *actionShowAllLayers() = 0;
487  virtual QAction *actionHideSelectedLayers() = 0;
488  virtual QAction *actionShowSelectedLayers() = 0;
489 
490  // Plugin menu actions
491  virtual QAction *actionManagePlugins() = 0;
492  virtual QAction *actionPluginListSeparator() = 0;
493  virtual QAction *actionShowPythonDialog() = 0;
494 
495  // Settings menu actions
496  virtual QAction *actionToggleFullScreen() = 0;
497  virtual QAction *actionOptions() = 0;
498  virtual QAction *actionCustomProjection() = 0;
499 
500  // Help menu actions
501  virtual QAction *actionHelpContents() = 0;
502  virtual QAction *actionQgisHomePage() = 0;
503  virtual QAction *actionCheckQgisVersion() = 0;
504  virtual QAction *actionAbout() = 0;
505 
513  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
514 
523  virtual QgsAttributeDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
524 
532  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
533 
545  virtual void preloadForm( QString uifile ) = 0;
546 
550  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
551 
553  virtual int messageTimeout() = 0;
554 
555  signals:
559  void currentLayerChanged( QgsMapLayer * layer );
560 
564  void composerAdded( QgsComposerView* v );
565 
569  void composerWillBeRemoved( QgsComposerView* v );
570 
573  void composerRemoved( QgsComposerView* v );
574 
578  void initializationCompleted();
585  void projectRead();
594  void newProjectCreated();
595 
600  void layerSavedAs( QgsMapLayer* l, QString path );
601 };
602 
603 #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 ...
The QgsLayerTreeMapCanvasBridge class takes care of updates of layer set for QgsMapCanvas from a laye...
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:162
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:63
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.