QGIS API Documentation  3.6.0-Noosa (5873452)
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;
32 class QgsFeature;
34 class QgsLayerTreeView;
35 class QgsLayout;
38 class QgsMapCanvas;
39 class QgsMapLayer;
41 class QgsMessageBar;
43 class QgsRasterLayer;
44 class QgsSnappingUtils;
45 class QgsVectorLayer;
48 class QgsLocatorFilter;
49 class QgsStatusBar;
50 class QgsMeshLayer;
51 class QgsBrowserModel;
52 
53 #include <QObject>
54 #include <QFont>
55 #include <QPair>
56 #include <map>
57 
58 #include "qgis_sip.h"
59 #include "qgsmaplayer.h"
60 #include "qgis_gui.h"
61 
62 
77 class GUI_EXPORT QgisInterface : public QObject
78 {
79  Q_OBJECT
80 
81  public:
82 
84  QgisInterface() = default;
85 
86  virtual QgsPluginManagerInterface *pluginManagerInterface() = 0;
87 
88  virtual QgsLayerTreeView *layerTreeView() = 0;
89 
102  virtual void addCustomActionForLayerType( QAction *action, QString menu,
103  QgsMapLayer::LayerType type, bool allLayers ) = 0;
104 
111  virtual void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) = 0;
112 
117  virtual bool removeCustomActionForLayerType( QAction *action ) = 0;
118 
123  virtual QList< QgsMapCanvas * > mapCanvases() = 0;
124 
130  virtual QgsMapCanvas *createNewMapCanvas( const QString &name ) = 0;
131 
137  virtual void closeMapCanvas( const QString &name ) = 0;
138 
143  virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
144 
149  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
150 
152  virtual QgsMapLayer *activeLayer() = 0;
153 
155  virtual QgsMapCanvas *mapCanvas() = 0;
156 
162  virtual QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() = 0;
163 
165  virtual QWidget *mainWindow() = 0;
166 
168  virtual QgsMessageBar *messageBar() = 0;
169 
174  virtual QList<QgsLayoutDesignerInterface *> openLayoutDesigners() = 0;
175 
176 
178  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
179 
181  virtual QFont defaultStyleSheetFont() = 0;
182 
187  virtual QgsAdvancedDigitizingDockWidget *cadDockWidget() = 0;
188 
189  /*
190  * Accessors for inserting items into menus and toolbars.
191  * An item can be inserted before any existing action.
192  */
193 
197  virtual QMenu *projectMenu() = 0;
198 
202  virtual QMenu *editMenu() = 0;
203 
207  virtual QMenu *viewMenu() = 0;
208 
212  virtual QMenu *layerMenu() = 0;
213 
217  virtual QMenu *newLayerMenu() = 0;
218 
223  virtual QMenu *addLayerMenu() = 0;
224 
228  virtual QMenu *settingsMenu() = 0;
229 
233  virtual QMenu *pluginMenu() = 0;
234 
238  virtual QMenu *rasterMenu() = 0;
239 
243  virtual QMenu *databaseMenu() = 0;
244 
248  virtual QMenu *vectorMenu() = 0;
249 
253  virtual QMenu *webMenu() = 0;
254 
262  virtual QMenu *firstRightStandardMenu() = 0;
263 
267  virtual QMenu *windowMenu() = 0;
268 
272  virtual QMenu *helpMenu() = 0;
273 
274  // ToolBars
275 
279  virtual QToolBar *fileToolBar() = 0;
280 
284  virtual QToolBar *layerToolBar() = 0;
285 
290  virtual QToolBar *dataSourceManagerToolBar() = 0;
291 
295  virtual QToolBar *mapNavToolToolBar() = 0;
296 
300  virtual QToolBar *digitizeToolBar() = 0;
301 
305  virtual QToolBar *advancedDigitizeToolBar() = 0;
306 
311  virtual QToolBar *shapeDigitizeToolBar() = 0;
312 
316  virtual QToolBar *attributesToolBar() = 0;
317 
321  virtual QToolBar *pluginToolBar() = 0;
322 
326  virtual QToolBar *helpToolBar() = 0;
327 
331  virtual QToolBar *rasterToolBar() = 0;
332 
336  virtual QToolBar *vectorToolBar() = 0;
337 
341  virtual QToolBar *databaseToolBar() = 0;
342 
346  virtual QToolBar *webToolBar() = 0;
347 
348  // Project menu actions
350  virtual QAction *actionNewProject() = 0;
352  virtual QAction *actionOpenProject() = 0;
354  virtual QAction *actionSaveProject() = 0;
356  virtual QAction *actionSaveProjectAs() = 0;
358  virtual QAction *actionSaveMapAsImage() = 0;
360  virtual QAction *actionProjectProperties() = 0;
361 
363  virtual QAction *actionCreatePrintLayout() = 0;
364 
366  virtual QAction *actionShowLayoutManager() = 0;
368  virtual QAction *actionExit() = 0;
369 
370  // Edit menu actions
371 
373  virtual QAction *actionCutFeatures() = 0;
375  virtual QAction *actionCopyFeatures() = 0;
377  virtual QAction *actionPasteFeatures() = 0;
379  virtual QAction *actionAddFeature() = 0;
381  virtual QAction *actionDeleteSelected() = 0;
383  virtual QAction *actionMoveFeature() = 0;
385  virtual QAction *actionSplitFeatures() = 0;
387  virtual QAction *actionSplitParts() = 0;
389  virtual QAction *actionAddRing() = 0;
391  virtual QAction *actionAddPart() = 0;
393  virtual QAction *actionSimplifyFeature() = 0;
395  virtual QAction *actionDeleteRing() = 0;
397  virtual QAction *actionDeletePart() = 0;
398 
403  virtual QAction *actionVertexTool() = 0;
404 
410  virtual QAction *actionVertexToolActiveLayer() = 0;
411 
412  // View menu actions
414  virtual QAction *actionPan() = 0;
416  virtual QAction *actionPanToSelected() = 0;
418  virtual QAction *actionZoomIn() = 0;
420  virtual QAction *actionZoomOut() = 0;
422  virtual QAction *actionSelect() = 0;
424  virtual QAction *actionSelectRectangle() = 0;
426  virtual QAction *actionSelectPolygon() = 0;
428  virtual QAction *actionSelectFreehand() = 0;
430  virtual QAction *actionSelectRadius() = 0;
432  virtual QAction *actionIdentify() = 0;
434  virtual QAction *actionFeatureAction() = 0;
436  virtual QAction *actionMeasure() = 0;
438  virtual QAction *actionMeasureArea() = 0;
440  virtual QAction *actionZoomFullExtent() = 0;
442  virtual QAction *actionZoomToLayer() = 0;
444  virtual QAction *actionZoomToSelected() = 0;
446  virtual QAction *actionZoomLast() = 0;
448  virtual QAction *actionZoomNext() = 0;
450  virtual QAction *actionZoomActualSize() = 0;
452  virtual QAction *actionMapTips() = 0;
454  virtual QAction *actionNewBookmark() = 0;
456  virtual QAction *actionShowBookmarks() = 0;
458  virtual QAction *actionDraw() = 0;
459 
460  // Layer menu actions
461  virtual QAction *actionNewVectorLayer() = 0;
462  virtual QAction *actionAddOgrLayer() = 0;
463  virtual QAction *actionAddRasterLayer() = 0;
464  virtual QAction *actionAddPgLayer() = 0;
465  virtual QAction *actionAddWmsLayer() = 0;
467  virtual QAction *actionAddAfsLayer() = 0;
469  virtual QAction *actionAddAmsLayer() = 0;
470  virtual QAction *actionCopyLayerStyle() = 0;
471  virtual QAction *actionPasteLayerStyle() = 0;
472  virtual QAction *actionOpenTable() = 0;
473  virtual QAction *actionOpenFieldCalculator() = 0;
474 
479  virtual QAction *actionOpenStatisticalSummary() = 0;
480 
481  virtual QAction *actionToggleEditing() = 0;
482  virtual QAction *actionSaveActiveLayerEdits() = 0;
483  virtual QAction *actionAllEdits() = 0;
484  virtual QAction *actionSaveEdits() = 0;
485  virtual QAction *actionSaveAllEdits() = 0;
486  virtual QAction *actionRollbackEdits() = 0;
487  virtual QAction *actionRollbackAllEdits() = 0;
488  virtual QAction *actionCancelEdits() = 0;
489  virtual QAction *actionCancelAllEdits() = 0;
490  virtual QAction *actionLayerSaveAs() = 0;
491  virtual QAction *actionDuplicateLayer() = 0;
492  virtual QAction *actionLayerProperties() = 0;
493  virtual QAction *actionAddToOverview() = 0;
494  virtual QAction *actionAddAllToOverview() = 0;
495  virtual QAction *actionRemoveAllFromOverview() = 0;
496  virtual QAction *actionHideAllLayers() = 0;
497  virtual QAction *actionShowAllLayers() = 0;
498  virtual QAction *actionHideSelectedLayers() = 0;
499 
504  virtual QAction *actionHideDeselectedLayers() = 0;
505  virtual QAction *actionShowSelectedLayers() = 0;
506 
507  // Plugin menu actions
508  virtual QAction *actionManagePlugins() = 0;
509  virtual QAction *actionPluginListSeparator() = 0;
510  virtual QAction *actionShowPythonDialog() = 0;
511 
512  // Settings menu actions
513  virtual QAction *actionToggleFullScreen() = 0;
514  virtual QAction *actionOptions() = 0;
515  virtual QAction *actionCustomProjection() = 0;
516 
517  // Help menu actions
518  virtual QAction *actionHelpContents() = 0;
519  virtual QAction *actionQgisHomePage() = 0;
520  virtual QAction *actionCheckQgisVersion() = 0;
521  virtual QAction *actionAbout() = 0;
522 
530  virtual QgsVectorLayerTools *vectorLayerTools() = 0;
531 
533  virtual int messageTimeout() = 0;
534 
541  virtual QgsStatusBar *statusBarIface() = 0;
542 
549  virtual void takeAppScreenShots( const QString &saveDirectory, const int categories = 0 ) {Q_UNUSED( saveDirectory ); Q_UNUSED( categories );}
550 
551  public slots: // TODO: do these functions really need to be slots?
552 
553  /* Exposed functions */
554 
558  virtual void zoomFull() = 0;
559 
563  virtual void zoomToPrevious() = 0;
564 
568  virtual void zoomToNext() = 0;
569 
573  virtual void zoomToActiveLayer() = 0;
574 
578  virtual QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) = 0;
579 
583  virtual QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName = QString() ) = 0;
584 
588  virtual QgsRasterLayer *addRasterLayer( const QString &url, const QString &layerName, const QString &providerKey ) = 0;
589 
593  virtual QgsMeshLayer *addMeshLayer( const QString &url, const QString &baseName, const QString &providerKey ) = 0;
594 
596  virtual bool addProject( const QString &project ) = 0;
598  virtual void newProject( bool promptToSaveFlag = false ) = 0;
599 
607  virtual void reloadConnections( ) = 0;
608 
613  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
614 
619  virtual void copySelectionToClipboard( QgsMapLayer * ) = 0;
620 
625  virtual void pasteFromClipboard( QgsMapLayer * ) = 0;
626 
628  virtual int addToolBarIcon( QAction *qAction ) = 0;
629 
638  virtual QAction *addToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
639 
641  virtual void removeToolBarIcon( QAction *qAction ) = 0;
642 
651  virtual QAction *addRasterToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
652 
654  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
655 
657  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
658 
660  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
661 
670  virtual QAction *addVectorToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
671 
673  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
674 
676  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
677 
686  virtual QAction *addDatabaseToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
687 
689  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
690 
692  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
693 
702  virtual QAction *addWebToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
703 
705  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
706 
708  virtual QToolBar *addToolBar( const QString &name ) = 0 SIP_FACTORY;
709 
714  virtual void addToolBar( QToolBar *toolbar SIP_TRANSFER, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
715 
719  virtual void openMessageLog() = 0;
720 
722  virtual void addUserInputWidget( QWidget *widget ) = 0;
723 
728  virtual void showLayoutManager() = 0;
729 
736  virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsMasterLayoutInterface *layout ) = 0;
737 
743  virtual void showOptionsDialog( QWidget *parent = nullptr, const QString &currentPage = QString() ) = 0;
744 
749  virtual void buildStyleSheet( const QMap<QString, QVariant> &opts ) = 0;
750 
752  virtual void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) = 0;
753 
755  virtual void addPluginToMenu( const QString &name, QAction *action ) = 0;
756 
758  virtual void removePluginMenu( const QString &name, QAction *action ) = 0;
759 
761  virtual void insertAddLayerAction( QAction *action ) = 0;
762 
764  virtual void removeAddLayerAction( QAction *action ) = 0;
765 
767  virtual void addPluginToDatabaseMenu( const QString &name, QAction *action ) = 0;
768 
770  virtual void removePluginDatabaseMenu( const QString &name, QAction *action ) = 0;
771 
773  virtual void addPluginToRasterMenu( const QString &name, QAction *action ) = 0;
774 
776  virtual void removePluginRasterMenu( const QString &name, QAction *action ) = 0;
777 
779  virtual void addPluginToVectorMenu( const QString &name, QAction *action ) = 0;
780 
782  virtual void removePluginVectorMenu( const QString &name, QAction *action ) = 0;
783 
785  virtual void addPluginToWebMenu( const QString &name, QAction *action ) = 0;
786 
788  virtual void removePluginWebMenu( const QString &name, QAction *action ) = 0;
789 
795  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) = 0;
796 
802  virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;
803 
805  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
806 
808  virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
809 
813  virtual void addWindow( QAction *action ) = 0;
814 
818  virtual void removeWindow( QAction *action ) = 0;
819 
821  virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) = 0;
822 
824  virtual bool unregisterMainWindowAction( QAction *action ) = 0;
825 
834  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
835 
842  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
843 
852  virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
853 
860  virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
861 
870  virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
871 
878  virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
879 
888  virtual void registerCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
889 
896  virtual void unregisterCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
897 
898  // TODO is this deprecated in favour of QgsContextHelp?
899 
909 #ifndef Q_MOC_RUN
910  Q_DECL_DEPRECATED
911 #endif
912  virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0 SIP_DEPRECATED;
913 
922  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
923 
932  virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
933 
946  virtual void preloadForm( const QString &uifile ) = 0;
947 
956  virtual void registerLocatorFilter( QgsLocatorFilter *filter SIP_TRANSFER ) = 0;
957 
968  virtual void deregisterLocatorFilter( QgsLocatorFilter *filter ) = 0;
969 
977  virtual void invalidateLocatorResults() = 0;
978 
985  virtual bool askForDatumTransform( QgsCoordinateReferenceSystem sourceCrs, QgsCoordinateReferenceSystem destinationCrs ) = 0;
986 
992  virtual QgsBrowserModel *browserModel() = 0;
993 
994  signals:
995 
1000  void currentLayerChanged( QgsMapLayer *layer );
1001 
1007  void currentThemeChanged( const QString &theme );
1008 
1014  void layoutDesignerOpened( QgsLayoutDesignerInterface *designer );
1015 
1023  void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer );
1024 
1031  void layoutDesignerClosed();
1032 
1036  void initializationCompleted();
1037 
1044  void projectRead();
1045 
1054  void newProjectCreated();
1055 
1060  void layerSavedAs( QgsMapLayer *l, const QString &path );
1061 
1062 };
1064 
1065 #endif //#ifndef QGISINTERFACE_H
Methods in this class are used to handle basic operations on vector layers.
Base class for all map layer types.
Definition: qgsmaplayer.h:64
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.
Factory class for creating custom map layer property pages.
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:624
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:45
A common interface for layout designer dialogs and widgets.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
Abstract base class that may be implemented to handle new types of data to be dropped in QGIS layouts...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:73
Abstract base class that may be implemented to handle new types of data to be dropped in QGIS...
LayerType
Types of layers that can be added to a map.
Definition: qgsmaplayer.h:106
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Abstract base class for filters which collect locator results.
#define SIP_FACTORY
Definition: qgis_sip.h:69
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
#define SIP_DEPRECATED
Definition: qgis_sip.h:99
QgisInterface Abstract base class defining interfaces exposed by QgisApp and made available to plugin...
Definition: qgisinterface.h:77
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:625
This class represents a coordinate reference system (CRS).
A factory class for creating custom options pages.
This class has all the configuration of snapping and can return answers to snapping queries...
A model for showing available data sources and other items in a structured tree.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:89
Interface for master layout type objects, such as print layouts and reports.
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.
virtual void takeAppScreenShots(const QString &saveDirectory, const int categories=0)
Take screenshots for user documentation.
A proxy widget for QStatusBar.
Definition: qgsstatusbar.h:45