/
qgisappinterface.h
316 lines (269 loc) · 11.6 KB
/
qgisappinterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
/***************************************************************************
qgisappinterface.h
Interface class for exposing functions in QgisApp for use by plugins
-------------------
begin : 2004-02-11
copyright : (C) 2004 by Gary E.Sherman
email : sherman at mrcc.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#ifndef QGISIFACE_H
#define QGISIFACE_H
#include "qgisinterface.h"
#include "qgsapplegendinterface.h"
class QgisApp;
#ifdef _MSC_VER
# pragma warning( push )
# pragma warning( disable: 4996 ) // declared deprecated
#endif
/** \class QgisAppInterface
* \brief Interface class to provide access to private methods in QgisApp
* for use by plugins.
*
* Only those functions "exposed" by QgisInterface can be called from within a
* plugin.
*/
class QgisAppInterface : public QgisInterface
{
Q_OBJECT
public:
/**
* Constructor.
* @param qgis Pointer to the QgisApp object
*/
QgisAppInterface( QgisApp *qgisapp );
~QgisAppInterface();
QgsLegendInterface* legendInterface();
/* Exposed functions */
//! Zoom map to full extent
void zoomFull();
//! Zoom map to previous extent
void zoomToPrevious();
//! Zoom map to next extent
void zoomToNext();
//! Zoom to active layer
void zoomToActiveLayer();
//! Add a vector layer
QgsVectorLayer* addVectorLayer( QString vectorLayerPath, QString baseName, QString providerKey );
//! Add a raster layer given its file name
QgsRasterLayer* addRasterLayer( QString rasterLayerPath, QString baseName );
//! Add a WMS layer
QgsRasterLayer* addRasterLayer( const QString& url, const QString& baseName, const QString& providerKey,
const QStringList& layers, const QStringList& styles, const QString& format, const QString& crs );
//! Add a project
bool addProject( QString theProjectName );
//! Start a new blank project
void newProject( bool thePromptToSaveFlag = false );
//! Get pointer to the active layer (layer selected in the legend)
QgsMapLayer *activeLayer();
//! set the active layer (layer selected in the legend)
bool setActiveLayer( QgsMapLayer *layer );
//! Add an icon to the plugins toolbar
int addToolBarIcon( QAction *qAction );
//! Remove an icon (action) from the plugin toolbar
void removeToolBarIcon( QAction *qAction );
//! Add toolbar with specified name
QToolBar* addToolBar( QString name );
/** Open a url in the users browser. By default the QGIS doc directory is used
* as the base for the URL. To open a URL that is not relative to the installed
* QGIS documentation, set useQgisDocDirectory to false.
* @param url URL to open
* @param useQgisDocDirectory If true, the URL will be formed by concatenating
* url to the QGIS documentation directory path (<prefix>/share/doc)
*/
void openURL( QString url, bool useQgisDocDirectory = true );
/** Return a pointer to the map canvas used by qgisapp */
QgsMapCanvas * mapCanvas();
/** Gives access to main QgisApp object
Plugins don't need to know about QgisApp, as we pass it as QWidget,
it can be used for connecting slots and using as widget's parent
*/
QWidget * mainWindow();
QList<QgsComposerView*> activeComposers();
/** Add action to the plugins menu */
void addPluginToMenu( QString name, QAction* action );
/** Remove action from the plugins menu */
void removePluginMenu( QString name, QAction* action );
/** Add action to the Database menu */
void addPluginToDatabaseMenu( QString name, QAction* action );
/** Remove action from the Database menu */
void removePluginDatabaseMenu( QString name, QAction* action );
/** Add a dock widget to the main window */
void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget );
/** Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. */
void removeDockWidget( QDockWidget * dockwidget );
virtual void refreshLegend( QgsMapLayer *l );
/** show layer properties dialog for layer
* @param l layer to show properties table for
* @note added in added in 1.5
*/
virtual void showLayerProperties( QgsMapLayer *l );
/** show layer attribute dialog for layer
* @param l layer to show attribute table for
* @note added in added in 1.7
*/
virtual void showAttributeTable( QgsVectorLayer *l );
/** Add window to Window menu. The action title is the window title
* and the action should raise, unminimize and activate the window. */
virtual void addWindow( QAction *action );
/** Remove window from Window menu. Calling this is necessary only for
* windows which are hidden rather than deleted when closed. */
virtual void removeWindow( QAction *action );
/** Register action to the shortcuts manager so its shortcut can be changed in GUI.
@note added in version 1.2. */
virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut );
/** Unregister a previously registered action. (e.g. when plugin is going to be unloaded.
@note added in version 1.2. */
virtual bool unregisterMainWindowAction( QAction* action );
/** Accessors for inserting items into menus and toolbars.
* An item can be inserted before any existing action.
*/
//! Menus
virtual QMenu *fileMenu();
virtual QMenu *editMenu();
virtual QMenu *viewMenu();
virtual QMenu *layerMenu();
virtual QMenu *settingsMenu();
virtual QMenu *pluginMenu();
virtual QMenu *databaseMenu();
virtual QMenu *firstRightStandardMenu();
virtual QMenu *windowMenu();
virtual QMenu *helpMenu();
//! ToolBars
virtual QToolBar *fileToolBar();
virtual QToolBar *layerToolBar();
virtual QToolBar *mapNavToolToolBar();
virtual QToolBar *digitizeToolBar();
virtual QToolBar *advancedDigitizeToolBar();
virtual QToolBar *attributesToolBar();
virtual QToolBar *pluginToolBar();
virtual QToolBar *helpToolBar();
//! File menu actions
virtual QAction *actionNewProject();
virtual QAction *actionOpenProject();
virtual QAction *actionFileSeparator1();
virtual QAction *actionSaveProject();
virtual QAction *actionSaveProjectAs();
virtual QAction *actionSaveMapAsImage();
virtual QAction *actionFileSeparator2();
virtual QAction *actionProjectProperties();
virtual QAction *actionFileSeparator3();
virtual QAction *actionPrintComposer();
virtual QAction *actionFileSeparator4();
virtual QAction *actionExit();
//! Edit menu actions
virtual QAction *actionCutFeatures();
virtual QAction *actionCopyFeatures();
virtual QAction *actionPasteFeatures();
virtual QAction *actionEditSeparator1();
virtual QAction *actionCapturePoint();
virtual QAction *actionCaptureLine();
virtual QAction *actionCapturePolygon();
virtual QAction *actionDeleteSelected();
virtual QAction *actionMoveFeature();
virtual QAction *actionSplitFeatures();
virtual QAction *actionAddVertex();
virtual QAction *actionDeleteVertex();
virtual QAction *actionMoveVertex();
virtual QAction *actionAddRing();
virtual QAction *actionAddIsland();
virtual QAction *actionSimplifyFeature();
virtual QAction *actionDeleteRing();
virtual QAction *actionDeletePart();
virtual QAction *actionNodeTool();
virtual QAction *actionEditSeparator2();
//! View menu actions
virtual QAction *actionPan();
virtual QAction *actionZoomIn();
virtual QAction *actionZoomOut();
virtual QAction *actionSelect();
virtual QAction *actionSelectRectangle();
virtual QAction *actionSelectPolygon();
virtual QAction *actionSelectFreehand();
virtual QAction *actionSelectRadius();
virtual QAction *actionIdentify();
virtual QAction *actionMeasure();
virtual QAction *actionMeasureArea();
virtual QAction *actionViewSeparator1();
virtual QAction *actionZoomFullExtent();
virtual QAction *actionZoomToLayer();
virtual QAction *actionZoomToSelected();
virtual QAction *actionZoomLast();
virtual QAction *actionZoomNext();
virtual QAction *actionZoomActualSize();
virtual QAction *actionViewSeparator2();
virtual QAction *actionMapTips();
virtual QAction *actionNewBookmark();
virtual QAction *actionShowBookmarks();
virtual QAction *actionDraw();
virtual QAction *actionViewSeparator3();
//! Layer menu actions
virtual QAction *actionNewVectorLayer();
virtual QAction *actionAddOgrLayer();
virtual QAction *actionAddRasterLayer();
virtual QAction *actionAddPgLayer();
virtual QAction *actionAddWmsLayer();
virtual QAction *actionLayerSeparator1();
virtual QAction *actionOpenTable();
virtual QAction *actionToggleEditing();
virtual QAction *actionLayerSaveAs();
virtual QAction *actionLayerSelectionSaveAs();
virtual QAction *actionRemoveLayer();
virtual QAction *actionLayerProperties();
virtual QAction *actionLayerSeparator2();
virtual QAction *actionAddToOverview();
virtual QAction *actionAddAllToOverview();
virtual QAction *actionRemoveAllFromOverview();
virtual QAction *actionLayerSeparator3();
virtual QAction *actionHideAllLayers();
virtual QAction *actionShowAllLayers();
//! Plugin menu actions
virtual QAction *actionManagePlugins();
virtual QAction *actionPluginSeparator1();
virtual QAction *actionPluginListSeparator();
virtual QAction *actionPluginSeparator2();
virtual QAction *actionPluginPythonSeparator();
virtual QAction *actionShowPythonDialog();
//! Settings menu actions
virtual QAction *actionToggleFullScreen();
virtual QAction *actionSettingsSeparator1();
virtual QAction *actionOptions();
virtual QAction *actionCustomProjection();
//! Help menu actions
virtual QAction *actionHelpContents();
virtual QAction *actionHelpSeparator1();
virtual QAction *actionQgisHomePage();
virtual QAction *actionCheckQgisVersion();
virtual QAction *actionHelpSeparator2();
virtual QAction *actionAbout();
//! open feature form
// returns true when dialog was accepted
// @param l vector layer
// @param f feature to show/modify
// @param updateFeatureOnly only update the feature update (don't change any attributes of the layer)
// @added in 1.6
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false );
signals:
void currentThemeChanged( QString );
private:
/// QgisInterface aren't copied
QgisAppInterface( QgisAppInterface const & );
/// QgisInterface aren't copied
QgisAppInterface & operator=( QgisAppInterface const & );
//! Pointer to the QgisApp object
QgisApp *qgis;
//! Pointer to the LegendInterface object
QgsAppLegendInterface legendIface;
};
#ifdef _MSC_VER
# pragma warning( pop )
#endif
#endif //#define QGISAPPINTERFACE_H