QGIS API Documentation  2.17.0-Master (3a3b9ab7)
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 
29 class QgsAttributeDialog;
30 class QgsComposerView;
31 class QgsFeature;
33 class QgsLayerTreeView;
34 class QgsLegendInterface;
35 class QgsMapCanvas;
36 class QgsMapLayer;
38 class QgsMessageBar;
40 class QgsRasterLayer;
41 class QgsSnappingUtils;
42 class QgsVectorLayer;
44 
45 #include <QObject>
46 #include <QFont>
47 #include <QPair>
48 #include <map>
49 
50 #include "qgis.h"
51 
52 
65 class GUI_EXPORT QgisInterface : public QObject
66 {
67  Q_OBJECT
68 
69  public:
70 
72  QgisInterface();
73 
75  virtual ~QgisInterface();
76 
78  virtual QgsLegendInterface* legendInterface() = 0;
79 
80  virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
81 
82  virtual QgsLayerTreeView* layerTreeView() = 0;
83 
84  public slots: // TODO: do these functions really need to be slots?
85 
86  /* Exposed functions */
87 
89  virtual void zoomFull() = 0;
90 
92  virtual void zoomToPrevious() = 0;
93 
95  virtual void zoomToNext() = 0;
96 
98  virtual void zoomToActiveLayer() = 0;
99 
101  virtual QgsVectorLayer* addVectorLayer( const QString& vectorLayerPath, const QString& baseName, const QString& providerKey ) = 0;
102 
104  virtual QgsRasterLayer* addRasterLayer( const QString& rasterLayerPath, const QString& baseName = QString() ) = 0;
105 
107  virtual QgsRasterLayer* addRasterLayer( const QString& url, const QString& layerName, const QString& providerKey ) = 0;
108 
110  virtual bool addProject( const QString& theProject ) = 0;
112  virtual void newProject( bool thePromptToSaveFlag = false ) = 0;
113 
115  virtual QgsMapLayer *activeLayer() = 0;
116 
119  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
120 
122  virtual int addToolBarIcon( QAction *qAction ) = 0;
123 
132  virtual QAction* addToolBarWidget( QWidget* widget ) = 0;
133 
135  virtual void removeToolBarIcon( QAction *qAction ) = 0;
136 
145  virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;
146 
148  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
149 
151  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
152 
154  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
155 
164  virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
165 
167  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
168 
170  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
171 
180  virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
181 
183  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
184 
186  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
187 
196  virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
197 
199  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
200 
202  virtual QToolBar *addToolBar( const QString& name ) = 0;
203 
206  virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
207 
209  virtual QgsMapCanvas * mapCanvas() = 0;
210 
216  virtual QgsLayerTreeMapCanvasBridge* layerTreeCanvasBridge() = 0;
217 
219  virtual QWidget * mainWindow() = 0;
220 
222  virtual QgsMessageBar * messageBar() = 0;
223 
225  virtual void openMessageLog() = 0;
226 
228  virtual void addUserInputWidget( QWidget* widget ) = 0;
229 
231  virtual QList<QgsComposerView*> activeComposers() = 0;
232 
238  virtual QgsComposerView* createNewComposer( const QString& title = QString() ) = 0;
239 
246  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, const QString& title = QString() ) = 0;
247 
249  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
250 
252  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
253 
257  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
258 
260  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
261 
263  virtual QFont defaultStyleSheetFont() = 0;
264 
266  virtual void addPluginToMenu( const QString& name, QAction* action ) = 0;
267 
269  virtual void removePluginMenu( const QString& name, QAction* action ) = 0;
270 
272  virtual void insertAddLayerAction( QAction *action ) = 0;
273 
275  virtual void removeAddLayerAction( QAction *action ) = 0;
276 
278  virtual void addPluginToDatabaseMenu( const QString& name, QAction* action ) = 0;
279 
281  virtual void removePluginDatabaseMenu( const QString& name, QAction* action ) = 0;
282 
284  virtual void addPluginToRasterMenu( const QString& name, QAction* action ) = 0;
285 
287  virtual void removePluginRasterMenu( const QString& name, QAction* action ) = 0;
288 
290  virtual void addPluginToVectorMenu( const QString& name, QAction* action ) = 0;
291 
293  virtual void removePluginVectorMenu( const QString& name, QAction* action ) = 0;
294 
296  virtual void addPluginToWebMenu( const QString& name, QAction* action ) = 0;
297 
299  virtual void removePluginWebMenu( const QString& name, QAction* action ) = 0;
300 
302  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
303 
305  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
306 
310  virtual QgsAdvancedDigitizingDockWidget* cadDockWidget() = 0;
311 
313  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
314 
316  virtual QDialog* showAttributeTable( QgsVectorLayer *l, const QString& filterExpression = QString() ) = 0;
317 
320  virtual void addWindow( QAction *action ) = 0;
321 
324  virtual void removeWindow( QAction *action ) = 0;
325 
327  virtual bool registerMainWindowAction( QAction* action, const QString& defaultShortcut ) = 0;
328 
330  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
331 
337  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;
338 
343  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;
344 
345  // @todo is this deprecated in favour of QgsContextHelp?
354 #ifndef Q_MOC_RUN
355  Q_DECL_DEPRECATED
356 #endif
357  virtual void openURL( const QString& url, bool useQgisDocDirectory = true ) = 0;
358 
359 
364  // Menus
365 #ifndef Q_MOC_RUN
366  Q_DECL_DEPRECATED
367 #endif
368  virtual QMenu *fileMenu() = 0;
369  virtual QMenu *projectMenu() = 0;
370  virtual QMenu *editMenu() = 0;
371  virtual QMenu *viewMenu() = 0;
372  virtual QMenu *layerMenu() = 0;
373  virtual QMenu *newLayerMenu() = 0;
375  virtual QMenu *addLayerMenu() = 0;
376  virtual QMenu *settingsMenu() = 0;
377  virtual QMenu *pluginMenu() = 0;
378  virtual QMenu *rasterMenu() = 0;
379  virtual QMenu *databaseMenu() = 0;
380  virtual QMenu *vectorMenu() = 0;
381  virtual QMenu *webMenu() = 0;
382  virtual QMenu *firstRightStandardMenu() = 0;
383  virtual QMenu *windowMenu() = 0;
384  virtual QMenu *helpMenu() = 0;
385 
386  // ToolBars
387  virtual QToolBar *fileToolBar() = 0;
388  virtual QToolBar *layerToolBar() = 0;
389  virtual QToolBar *mapNavToolToolBar() = 0;
390  virtual QToolBar *digitizeToolBar() = 0;
391  virtual QToolBar *advancedDigitizeToolBar() = 0;
392  virtual QToolBar *attributesToolBar() = 0;
393  virtual QToolBar *pluginToolBar() = 0;
394  virtual QToolBar *helpToolBar() = 0;
395  virtual QToolBar *rasterToolBar() = 0;
396  virtual QToolBar *vectorToolBar() = 0;
397  virtual QToolBar *databaseToolBar() = 0;
398  virtual QToolBar *webToolBar() = 0;
399 
400  // Project menu actions
401  virtual QAction *actionNewProject() = 0;
402  virtual QAction *actionOpenProject() = 0;
403  virtual QAction *actionSaveProject() = 0;
404  virtual QAction *actionSaveProjectAs() = 0;
405  virtual QAction *actionSaveMapAsImage() = 0;
406  virtual QAction *actionProjectProperties() = 0;
407  virtual QAction *actionPrintComposer() = 0;
408  virtual QAction *actionShowComposerManager() = 0;
409  virtual QAction *actionExit() = 0;
410 
411  // Edit menu actions
412  virtual QAction *actionCutFeatures() = 0;
413  virtual QAction *actionCopyFeatures() = 0;
414  virtual QAction *actionPasteFeatures() = 0;
415  virtual QAction *actionAddFeature() = 0;
416  virtual QAction *actionDeleteSelected() = 0;
417  virtual QAction *actionMoveFeature() = 0;
418  virtual QAction *actionSplitFeatures() = 0;
419  virtual QAction *actionSplitParts() = 0;
420  virtual QAction *actionAddRing() = 0;
421  virtual QAction *actionAddPart() = 0;
422  virtual QAction *actionSimplifyFeature() = 0;
423  virtual QAction *actionDeleteRing() = 0;
424  virtual QAction *actionDeletePart() = 0;
425  virtual QAction *actionNodeTool() = 0;
426 
427  // View menu actions
429  virtual QAction *actionPan() = 0;
431  virtual QAction *actionTouch() = 0;
433  virtual QAction *actionPanToSelected() = 0;
435  virtual QAction *actionZoomIn() = 0;
437  virtual QAction *actionZoomOut() = 0;
439  virtual QAction *actionSelect() = 0;
441  virtual QAction *actionSelectRectangle() = 0;
443  virtual QAction *actionSelectPolygon() = 0;
445  virtual QAction *actionSelectFreehand() = 0;
447  virtual QAction *actionSelectRadius() = 0;
449  virtual QAction *actionIdentify() = 0;
451  virtual QAction *actionFeatureAction() = 0;
453  virtual QAction *actionMeasure() = 0;
455  virtual QAction *actionMeasureArea() = 0;
457  virtual QAction *actionZoomFullExtent() = 0;
459  virtual QAction *actionZoomToLayer() = 0;
461  virtual QAction *actionZoomToSelected() = 0;
463  virtual QAction *actionZoomLast() = 0;
465  virtual QAction *actionZoomNext() = 0;
467  virtual QAction *actionZoomActualSize() = 0;
469  virtual QAction *actionMapTips() = 0;
471  virtual QAction *actionNewBookmark() = 0;
473  virtual QAction *actionShowBookmarks() = 0;
475  virtual QAction *actionDraw() = 0;
476 
477  // Layer menu actions
478  virtual QAction *actionNewVectorLayer() = 0;
479  virtual QAction *actionAddOgrLayer() = 0;
480  virtual QAction *actionAddRasterLayer() = 0;
481  virtual QAction *actionAddPgLayer() = 0;
482  virtual QAction *actionAddWmsLayer() = 0;
484  virtual QAction *actionAddAfsLayer() = 0;
486  virtual QAction *actionAddAmsLayer() = 0;
487  virtual QAction *actionCopyLayerStyle() = 0;
488  virtual QAction *actionPasteLayerStyle() = 0;
489  virtual QAction *actionOpenTable() = 0;
490  virtual QAction *actionOpenFieldCalculator() = 0;
491  virtual QAction *actionToggleEditing() = 0;
492  virtual QAction *actionSaveActiveLayerEdits() = 0;
493  virtual QAction *actionAllEdits() = 0;
494  virtual QAction *actionSaveEdits() = 0;
495  virtual QAction *actionSaveAllEdits() = 0;
496  virtual QAction *actionRollbackEdits() = 0;
497  virtual QAction *actionRollbackAllEdits() = 0;
498  virtual QAction *actionCancelEdits() = 0;
499  virtual QAction *actionCancelAllEdits() = 0;
500  virtual QAction *actionLayerSaveAs() = 0;
502 #ifndef Q_MOC_RUN
503  Q_DECL_DEPRECATED
504 #endif
505  virtual QAction *actionLayerSelectionSaveAs() = 0;
506  virtual QAction *actionRemoveLayer() = 0;
507  virtual QAction *actionDuplicateLayer() = 0;
508  virtual QAction *actionLayerProperties() = 0;
509  virtual QAction *actionAddToOverview() = 0;
510  virtual QAction *actionAddAllToOverview() = 0;
511  virtual QAction *actionRemoveAllFromOverview() = 0;
512  virtual QAction *actionHideAllLayers() = 0;
513  virtual QAction *actionShowAllLayers() = 0;
514  virtual QAction *actionHideSelectedLayers() = 0;
515  virtual QAction *actionShowSelectedLayers() = 0;
516 
517  // Plugin menu actions
518  virtual QAction *actionManagePlugins() = 0;
519  virtual QAction *actionPluginListSeparator() = 0;
520  virtual QAction *actionShowPythonDialog() = 0;
521 
522  // Settings menu actions
523  virtual QAction *actionToggleFullScreen() = 0;
524  virtual QAction *actionOptions() = 0;
525  virtual QAction *actionCustomProjection() = 0;
526 
527  // Help menu actions
528  virtual QAction *actionHelpContents() = 0;
529  virtual QAction *actionQgisHomePage() = 0;
530  virtual QAction *actionCheckQgisVersion() = 0;
531  virtual QAction *actionAbout() = 0;
532 
540  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
541 
550  virtual QgsAttributeDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
551 
559  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
560 
572  virtual void preloadForm( const QString& uifile ) = 0;
573 
577  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
578 
580  virtual int messageTimeout() = 0;
581 
582  signals:
586  void currentLayerChanged( QgsMapLayer * layer );
587 
591  void composerAdded( QgsComposerView* v );
592 
596  void composerWillBeRemoved( QgsComposerView* v );
597 
601  void composerRemoved( QgsComposerView* v );
602 
606  void initializationCompleted();
613  void projectRead();
622  void newProjectCreated();
623 
628  void layerSavedAs( QgsMapLayer* l, const QString& path );
629 };
630 
631 #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:187
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:109
Widget to display the composer items.
QgisInterface Abstract base class defining interfaces exposed by QgisApp and made available to plugin...
Definition: qgisinterface.h:65
This class has all the configuration of snapping and can return answers to snapping queries...
The QgsAdvancedDigitizingDockWidget class is a dockable widget used to handle the CAD tools on top of...
Represents a vector layer which manages a vector based data sets.