QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 QgsComposerView;
29 class QgsMapLayer;
30 class QgsMapCanvas;
31 class QgsRasterLayer;
32 class QgsVectorLayer;
33 class QgsLegendInterface;
35 class QgsFeature;
36 class QgsMessageBar;
38 
39 #include <QObject>
40 #include <QFont>
41 #include <QPair>
42 #include <map>
43 
44 #include <qgis.h>
45 
46 
59 class GUI_EXPORT QgisInterface : public QObject
60 {
61  Q_OBJECT
62 
63  public:
64 
66  QgisInterface();
67 
69  virtual ~QgisInterface();
70 
74  virtual QgsLegendInterface* legendInterface() = 0;
75 
76  virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
77 
78  public slots: // TODO: do these functions really need to be slots?
79 
80  /* Exposed functions */
81 
83  virtual void zoomFull() = 0;
84 
86  virtual void zoomToPrevious() = 0;
87 
89  virtual void zoomToNext() = 0;
90 
92  virtual void zoomToActiveLayer() = 0;
93 
95  virtual QgsVectorLayer* addVectorLayer( QString vectorLayerPath, QString baseName, QString providerKey ) = 0;
96 
98  virtual QgsRasterLayer* addRasterLayer( QString rasterLayerPath, QString baseName = QString() ) = 0;
99 
101  virtual QgsRasterLayer* addRasterLayer( const QString& url, const QString& layerName, const QString& providerKey ) = 0;
102 
104  virtual bool addProject( QString theProject ) = 0;
106  virtual void newProject( bool thePromptToSaveFlag = false ) = 0;
107 
109  virtual QgsMapLayer *activeLayer() = 0;
110 
114  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
115 
117  virtual int addToolBarIcon( QAction *qAction ) = 0;
118 
127  virtual QAction* addToolBarWidget( QWidget* widget ) = 0;
128 
130  virtual void removeToolBarIcon( QAction *qAction ) = 0;
131 
140  virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;
141 
144  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
145 
148  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
149 
152 
153  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
154 
163  virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
164 
167  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
168 
171  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
172 
181  virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
182 
185  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
186 
189  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
190 
199  virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
200 
203  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
204 
206  virtual QToolBar *addToolBar( QString name ) = 0;
207 
209  virtual QgsMapCanvas * mapCanvas() = 0;
210 
212  virtual QWidget * mainWindow() = 0;
213 
215  virtual QgsMessageBar * messageBar() = 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 
238  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
239 
243  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
244 
249  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
250 
254  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
255 
259  virtual QFont defaultStyleSheetFont() = 0;
260 
262  virtual void addPluginToMenu( QString name, QAction* action ) = 0;
263 
265  virtual void removePluginMenu( QString name, QAction* action ) = 0;
266 
270  virtual void insertAddLayerAction( QAction *action ) = 0;
271 
275  virtual void removeAddLayerAction( QAction *action ) = 0;
276 
280  virtual void addPluginToDatabaseMenu( QString name, QAction* action ) = 0;
281 
285  virtual void removePluginDatabaseMenu( QString name, QAction* action ) = 0;
286 
290  virtual void addPluginToRasterMenu( QString name, QAction* action ) = 0;
291 
295  virtual void removePluginRasterMenu( QString name, QAction* action ) = 0;
296 
300  virtual void addPluginToVectorMenu( QString name, QAction* action ) = 0;
301 
305  virtual void removePluginVectorMenu( QString name, QAction* action ) = 0;
306 
310  virtual void addPluginToWebMenu( QString name, QAction* action ) = 0;
311 
315  virtual void removePluginWebMenu( QString name, QAction* action ) = 0;
316 
318  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
319 
323  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
324 
328  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
329 
333  virtual void showAttributeTable( QgsVectorLayer *l ) = 0;
334 
337  virtual void addWindow( QAction *action ) = 0;
338 
341  virtual void removeWindow( QAction *action ) = 0;
342 
346  virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut ) = 0;
347 
351  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
352 
353  // @todo is this deprecated in favour of QgsContextHelp?
362 #ifndef Q_MOC_RUN
363  Q_DECL_DEPRECATED
364 #endif
365  virtual void openURL( QString url, bool useQgisDocDirectory = true ) = 0;
366 
367 
372  // Menus
373 #ifndef Q_MOC_RUN
374  Q_DECL_DEPRECATED
375 #endif
376  virtual QMenu *fileMenu() = 0;
377  virtual QMenu *projectMenu() = 0;
378  virtual QMenu *editMenu() = 0;
379  virtual QMenu *viewMenu() = 0;
380  virtual QMenu *layerMenu() = 0;
383  virtual QMenu *newLayerMenu() = 0;
384  virtual QMenu *settingsMenu() = 0;
385  virtual QMenu *pluginMenu() = 0;
386  virtual QMenu *rasterMenu() = 0;
389  virtual QMenu *databaseMenu() = 0;
392  virtual QMenu *vectorMenu() = 0;
395  virtual QMenu *webMenu() = 0;
396  virtual QMenu *firstRightStandardMenu() = 0;
397  virtual QMenu *windowMenu() = 0;
398  virtual QMenu *helpMenu() = 0;
399 
400  // ToolBars
401  virtual QToolBar *fileToolBar() = 0;
402  virtual QToolBar *layerToolBar() = 0;
403  virtual QToolBar *mapNavToolToolBar() = 0;
404  virtual QToolBar *digitizeToolBar() = 0;
405  virtual QToolBar *advancedDigitizeToolBar() = 0; // added in v1.5
406  virtual QToolBar *attributesToolBar() = 0;
407  virtual QToolBar *pluginToolBar() = 0;
408  virtual QToolBar *helpToolBar() = 0;
411  virtual QToolBar *rasterToolBar() = 0;
414  virtual QToolBar *vectorToolBar() = 0;
417  virtual QToolBar *databaseToolBar() = 0;
420  virtual QToolBar *webToolBar() = 0;
421 
422  // Project menu actions
423  virtual QAction *actionNewProject() = 0;
424  virtual QAction *actionOpenProject() = 0;
425  virtual QAction *actionSaveProject() = 0;
426  virtual QAction *actionSaveProjectAs() = 0;
427  virtual QAction *actionSaveMapAsImage() = 0;
428  virtual QAction *actionProjectProperties() = 0;
429  virtual QAction *actionPrintComposer() = 0;
430  virtual QAction *actionShowComposerManager() = 0;
431  virtual QAction *actionExit() = 0;
432 
433  // Edit menu actions
434  virtual QAction *actionCutFeatures() = 0;
435  virtual QAction *actionCopyFeatures() = 0;
436  virtual QAction *actionPasteFeatures() = 0;
437  virtual QAction *actionAddFeature() = 0;
438  virtual QAction *actionDeleteSelected() = 0;
439  virtual QAction *actionMoveFeature() = 0;
440  virtual QAction *actionSplitFeatures() = 0;
441  virtual QAction *actionSplitParts() = 0;
442  virtual QAction *actionAddRing() = 0;
443  virtual QAction *actionAddPart() = 0;
444  virtual QAction *actionSimplifyFeature() = 0;
445  virtual QAction *actionDeleteRing() = 0;
446  virtual QAction *actionDeletePart() = 0;
447  virtual QAction *actionNodeTool() = 0;
448 
449  // View menu actions
451  virtual QAction *actionPan() = 0;
453  virtual QAction *actionTouch() = 0;
455  virtual QAction *actionPanToSelected() = 0;
457  virtual QAction *actionZoomIn() = 0;
459  virtual QAction *actionZoomOut() = 0;
461  virtual QAction *actionSelect() = 0;
463  virtual QAction *actionSelectRectangle() = 0;
465  virtual QAction *actionSelectPolygon() = 0;
467  virtual QAction *actionSelectFreehand() = 0;
469  virtual QAction *actionSelectRadius() = 0;
471  virtual QAction *actionIdentify() = 0;
473  virtual QAction *actionFeatureAction() = 0;
475  virtual QAction *actionMeasure() = 0;
477  virtual QAction *actionMeasureArea() = 0;
479  virtual QAction *actionZoomFullExtent() = 0;
481  virtual QAction *actionZoomToLayer() = 0;
483  virtual QAction *actionZoomToSelected() = 0;
485  virtual QAction *actionZoomLast() = 0;
487  virtual QAction *actionZoomNext() = 0;
489  virtual QAction *actionZoomActualSize() = 0;
491  virtual QAction *actionMapTips() = 0;
493  virtual QAction *actionNewBookmark() = 0;
495  virtual QAction *actionShowBookmarks() = 0;
497  virtual QAction *actionDraw() = 0;
498 
499  // Layer menu actions
500  virtual QAction *actionNewVectorLayer() = 0;
501  virtual QAction *actionAddOgrLayer() = 0;
502  virtual QAction *actionAddRasterLayer() = 0;
503  virtual QAction *actionAddPgLayer() = 0;
504  virtual QAction *actionAddWmsLayer() = 0;
506  virtual QAction *actionCopyLayerStyle() = 0;
508  virtual QAction *actionPasteLayerStyle() = 0;
509  virtual QAction *actionOpenTable() = 0;
510  virtual QAction *actionOpenFieldCalculator() = 0;
511  virtual QAction *actionToggleEditing() = 0;
513  virtual QAction *actionSaveActiveLayerEdits() = 0;
515  virtual QAction *actionAllEdits() = 0;
517  virtual QAction *actionSaveEdits() = 0;
519  virtual QAction *actionSaveAllEdits() = 0;
521  virtual QAction *actionRollbackEdits() = 0;
523  virtual QAction *actionRollbackAllEdits() = 0;
525  virtual QAction *actionCancelEdits() = 0;
527  virtual QAction *actionCancelAllEdits() = 0;
528  virtual QAction *actionLayerSaveAs() = 0;
530 #ifndef Q_MOC_RUN
531  Q_DECL_DEPRECATED
532 #endif
533  virtual QAction *actionLayerSelectionSaveAs() = 0;
534  virtual QAction *actionRemoveLayer() = 0;
536  virtual QAction *actionDuplicateLayer() = 0;
537  virtual QAction *actionLayerProperties() = 0;
538  virtual QAction *actionAddToOverview() = 0;
539  virtual QAction *actionAddAllToOverview() = 0;
540  virtual QAction *actionRemoveAllFromOverview() = 0;
541  virtual QAction *actionHideAllLayers() = 0;
542  virtual QAction *actionShowAllLayers() = 0;
543 
544  // Plugin menu actions
545  virtual QAction *actionManagePlugins() = 0;
546  virtual QAction *actionPluginListSeparator() = 0;
547  virtual QAction *actionShowPythonDialog() = 0;
548 
549  // Settings menu actions
550  virtual QAction *actionToggleFullScreen() = 0;
551  virtual QAction *actionOptions() = 0;
552  virtual QAction *actionCustomProjection() = 0;
553 
554  // Help menu actions
555  virtual QAction *actionHelpContents() = 0;
556  virtual QAction *actionQgisHomePage() = 0;
557  virtual QAction *actionCheckQgisVersion() = 0;
558  virtual QAction *actionAbout() = 0;
559 
565  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false ) = 0;
566 
567  virtual QDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
568 
569  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
570 
571  virtual void preloadForm( QString uifile ) = 0;
572 
577  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
578 
581  virtual int messageTimeout() = 0;
582 
583  signals:
587  void currentLayerChanged( QgsMapLayer * layer );
588 
593  void composerAdded( QgsComposerView* v );
594 
599  void composerWillBeRemoved( QgsComposerView* v );
604  void initializationCompleted();
613  void projectRead();
624  void newProjectCreated();
625 };
626 
627 // FIXME: also in core/qgis.h
628 #ifndef QGISEXTERN
629 #ifdef WIN32
630 # define QGISEXTERN extern "C" __declspec( dllexport )
631 #else
632 # define QGISEXTERN extern "C"
633 #endif
634 #endif
635 
636 #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:47
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:43
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:114
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:59
Represents a vector layer which manages a vector based data sets.