@@ -18,303 +18,83 @@ class QgsMapCanvas : QGraphicsView
18
18
public:
19
19
20
20
//! Constructor
21
- QgsMapCanvas( QWidget * parent /TransferThis/ = 0 );
22
-
21
+ QgsMapCanvas( QWidget *parent /TransferThis/ = 0 );
23
22
~QgsMapCanvas();
24
-
25
- //! Returns the magnification factor
26
- //! @note added in 2.16
27
23
double magnificationFactor() const;
28
-
29
- //! Set list of layers that should be shown in the canvas
30
- //! @note added in 3.0
31
- void setLayers( const QList<QgsMapLayer*>& layers );
32
-
33
- void setCurrentLayer( QgsMapLayer* layer );
34
-
35
- //! Get access to properties used for map rendering
36
- //! @note added in 2.4
37
- const QgsMapSettings& mapSettings() const /KeepReference/;
38
-
39
- //! sets destination coordinate reference system
40
- //! @note added in 2.4
41
- void setDestinationCrs( const QgsCoordinateReferenceSystem& crs );
42
-
43
- //! Get access to the labeling results (may be null)
44
- //! @note added in 2.4
45
- const QgsLabelingResults* labelingResults() const;
46
-
47
- //! Set whether to cache images of rendered layers
48
- //! @note added in 2.4
24
+ void setLayers( const QList<QgsMapLayer *> &layers );
25
+ void setCurrentLayer( QgsMapLayer *layer );
26
+ const QgsMapSettings &mapSettings() const /KeepReference/;
27
+ void setDestinationCrs( const QgsCoordinateReferenceSystem &crs );
28
+ const QgsLabelingResults *labelingResults() const;
49
29
void setCachingEnabled( bool enabled );
50
-
51
- //! Check whether images of rendered layers are curerently being cached
52
- //! @note added in 2.4
53
30
bool isCachingEnabled() const;
54
-
55
- //! Make sure to remove any rendered images from cache (does nothing if cache is not enabled)
56
- //! @note added in 2.4
57
31
void clearCache();
58
-
59
- //! Reload all layers, clear the cache and refresh the canvas
60
- //! @note added in 2.9
61
32
void refreshAllLayers();
62
-
63
- //! Set whether the layers are rendered in parallel or sequentially
64
- //! @note added in 2.4
33
+ void waitWhileRendering();
65
34
void setParallelRenderingEnabled( bool enabled );
66
-
67
- //! Check whether the layers are rendered in parallel or sequentially
68
- //! @note added in 2.4
69
35
bool isParallelRenderingEnabled() const;
70
-
71
- //! Set how often map preview should be updated while it is being rendered (in milliseconds)
72
- //! @note added in 2.4
73
36
void setMapUpdateInterval( int timeMilliseconds );
74
-
75
- //! Find out how often map preview should be updated while it is being rendered (in milliseconds)
76
- //! @note added in 2.4
77
37
int mapUpdateInterval() const;
78
-
79
- //! Get the last reported scale of the canvas
80
38
double scale();
81
-
82
- //! Returns the mapUnitsPerPixel (map units per pixel) for the canvas
83
39
double mapUnitsPerPixel() const;
84
-
85
- //! Returns the current zoom extent of the map canvas
86
40
QgsRectangle extent() const;
87
- //! Returns the combined extent for all layers on the map canvas
88
41
QgsRectangle fullExtent() const;
89
-
90
- //! Set the extent of the map canvas
91
42
void setExtent( const QgsRectangle &r, bool magnified = false );
92
-
93
- //! Get the current map canvas rotation in clockwise degrees
94
- //! @note added in 2.8
95
43
double rotation() const;
96
-
97
- //! Set the rotation of the map canvas in clockwise degrees
98
- //! @note added in 2.8
99
44
void setRotation( double degrees );
100
-
101
- //! Set the center of the map canvas, in geographical coordinates
102
- //! @note added in 2.8
103
- void setCenter( const QgsPoint& center );
104
-
105
- //! Get map center, in geographical coordinates
106
- //! @note added in 2.8
45
+ void setCenter( const QgsPoint ¢er );
107
46
QgsPoint center() const;
108
-
109
- //! Zoom to the full extent of all layers
110
47
void zoomToFullExtent();
111
-
112
- //! Zoom to the previous extent (view)
113
48
void zoomToPreviousExtent();
114
-
115
- //! Zoom to the next extent (view)
116
49
void zoomToNextExtent();
117
-
118
- // ! Clears the list of extents and sets current extent as first item
119
50
void clearExtentHistory();
120
-
121
- /** Zoom to the extent of the selected features of current (vector) layer.
122
- * @param layer optionally specify different than current layer
123
- */
124
- void zoomToSelected( QgsVectorLayer* layer = 0 );
125
-
126
- /** Set canvas extent to the bounding box of a set of features
127
- @param layer the vector layer
128
- @param ids the feature ids*/
129
- void zoomToFeatureIds( QgsVectorLayer* layer, const QgsFeatureIds& ids );
130
-
131
- /** Centers canvas extent to feature ids
132
- @param layer the vector layer
133
- @param ids the feature ids*/
134
- void panToFeatureIds( QgsVectorLayer* layer, const QgsFeatureIds& ids );
135
-
136
- //! Pan to the selected features of current (vector) layer keeping same extent.
137
- void panToSelected( QgsVectorLayer* layer = 0 );
138
-
139
- //! \brief Sets the map tool currently being used on the canvas
140
- void setMapTool( QgsMapTool* mapTool );
141
-
142
- /** \brief Unset the current map tool or last non zoom tool
143
- *
144
- * This is called from destructor of map tools to make sure
145
- * that this map tool won't be used any more.
146
- * You don't have to call it manualy, QgsMapTool takes care of it.
147
- */
148
- void unsetMapTool( QgsMapTool* mapTool );
149
-
150
- //! Returns the currently active tool
151
- QgsMapTool* mapTool();
152
-
153
- //! Write property of QColor bgColor.
154
- void setCanvasColor( const QColor & _newVal );
155
- //! Read property of QColor bgColor.
51
+ void zoomToSelected( QgsVectorLayer *layer = 0 );
52
+ void zoomToFeatureIds( QgsVectorLayer *layer, const QgsFeatureIds &ids );
53
+ void panToFeatureIds( QgsVectorLayer *layer, const QgsFeatureIds &ids );
54
+ void panToSelected( QgsVectorLayer *layer = 0 );
55
+ void setMapTool( QgsMapTool *mapTool );
56
+ void unsetMapTool( QgsMapTool *mapTool );
57
+ QgsMapTool *mapTool();
58
+ void setCanvasColor( const QColor &_newVal );
156
59
QColor canvasColor() const;
157
-
158
- //! Set color of selected vector features
159
- //! @note added in 2.4
160
- void setSelectionColor( const QColor& color );
161
-
162
- //! Emits signal scaleChanged to update scale in main window
60
+ void setSelectionColor( const QColor &color );
163
61
void updateScale();
164
-
165
- //! return the map layer at position index in the layer stack
166
62
QgsMapLayer *layer( int index );
167
-
168
- //! return number of layers on the map
169
63
int layerCount() const;
170
-
171
- //! return list of layers within map canvas.
172
- QList<QgsMapLayer*> layers() const;
64
+ QList<QgsMapLayer *> layers() const;
173
65
void freeze( bool frozen = true );
174
66
bool isFrozen() const;
175
67
bool renderFlag() const;
176
-
177
- //! Get the current canvas map units
178
68
QgsUnitTypes::DistanceUnit mapUnits() const;
179
-
180
- //! Getter for stored overrides of styles for layers.
181
- //! @note added in 2.12
182
69
QMap<QString, QString> layerStyleOverrides() const;
183
-
184
- //! Setter for stored overrides of styles for layers.
185
- //! @note added in 2.12
186
- void setLayerStyleOverrides( const QMap<QString, QString>& overrides );
187
-
188
- //! Get the current coordinate transform
189
- const QgsMapToPixel* getCoordinateTransform();
190
-
191
- //! Find out whether rendering is in progress
70
+ void setLayerStyleOverrides( const QMap<QString, QString> &overrides );
71
+ void setTheme( const QString &theme );
72
+ QString theme() const;
73
+ const QgsMapToPixel *getCoordinateTransform();
192
74
bool isDrawing();
193
-
194
- //! returns current layer (set by legend widget)
195
- QgsMapLayer* currentLayer();
196
-
197
- //! set wheel zoom factor (should be greater than 1)
75
+ QgsMapLayer *currentLayer();
198
76
void setWheelFactor( double factor );
199
-
200
- //! Zoom to a specific scale
201
77
void zoomScale( double scale );
202
-
203
- //! Zoom with the factor supplied. Factor > 1 zooms out, interval (0,1) zooms in
204
- //! If point is given, re-center on it
205
78
void zoomByFactor( double scaleFactor, const QgsPoint *center = 0 );
206
-
207
- //! Zooms in/out with a given center
208
79
void zoomWithCenter( int x, int y, bool zoomIn );
209
-
210
- //! Zooms to feature extent. Adds a small margin around the extent
211
- //! and does a pan if rect is empty (point extent)
212
- void zoomToFeatureExtent( QgsRectangle& rect );
213
-
214
- //! Returns whether the scale is locked, so zooming can be performed using magnication.
215
- //! @note added in 2.16
216
- //! @see setScaleLocked()
80
+ void zoomToFeatureExtent( QgsRectangle &rect );
217
81
bool scaleLocked() const;
218
-
219
- //! used to determine if anti-aliasing is enabled or not
220
82
void enableAntiAliasing( bool flag );
221
-
222
- //! true if antialising is enabled
223
83
bool antiAliasingEnabled() const;
224
-
225
- //! sets map tile rendering flag
226
84
void enableMapTileRendering( bool flag );
227
-
228
- // following 2 methods should be moved elsewhere or changed to private
229
- // currently used by pan map tool
230
- //! Ends pan action and redraws the canvas.
231
85
void panActionEnd( QPoint releasePoint );
232
-
233
- //! Called when mouse is moving and pan is activated
234
- void panAction( QMouseEvent * event );
235
-
236
- //! returns last position of mouse cursor
86
+ void panAction( QMouseEvent *event );
237
87
QPoint mouseLastXY();
238
-
239
- /** Enables a preview mode for the map canvas
240
- * @param previewEnabled set to true to enable a preview mode
241
- * @see setPreviewMode
242
- * @note added in 2.3 */
243
88
void setPreviewModeEnabled( bool previewEnabled );
244
-
245
- /** Returns whether a preview mode is enabled for the map canvas
246
- * @returns true if a preview mode is currently enabled
247
- * @see setPreviewModeEnabled
248
- * @see previewMode
249
- * @note added in 2.3 */
250
89
bool previewModeEnabled() const;
251
-
252
- /** Sets a preview mode for the map canvas. This setting only has an effect if
253
- * previewModeEnabled is true.
254
- * @param mode preview mode for the canvas
255
- * @see previewMode
256
- * @see setPreviewModeEnabled
257
- * @see previewModeEnabled
258
- * @note added in 2.3 */
259
90
void setPreviewMode( QgsPreviewEffect::PreviewMode mode );
260
-
261
- /** Returns the current preview mode for the map canvas. This setting only has an effect if
262
- * previewModeEnabled is true.
263
- * @returns preview mode for map canvas
264
- * @see setPreviewMode
265
- * @see previewModeEnabled
266
- * @note added in 2.3 */
267
91
QgsPreviewEffect::PreviewMode previewMode() const;
268
-
269
- /** Return snapping utility class that is associated with map canvas.
270
- * If no snapping utils instance has been associated previously, an internal will be created for convenience
271
- * (so map tools do not need to test for existence of the instance).
272
- *
273
- * Main canvas in QGIS returns an instance which is always up-to-date with the project's snapping configuration.
274
- * @note added in 2.8
275
- */
276
- QgsSnappingUtils* snappingUtils() const;
277
-
278
- /** Assign an instance of snapping utils to the map canvas.
279
- * The instance is not owned by the canvas, so it is possible to use one instance in multiple canvases.
280
- *
281
- * For main canvas in QGIS, do not associate a different instance from the existing one (it is updated from
282
- * the project's snapping configuration).
283
- * @note added in 2.8
284
- */
285
- void setSnappingUtils( QgsSnappingUtils* utils );
286
-
287
- /** Sets an expression context scope for the map canvas. This scope is injected into the expression
288
- * context used for rendering the map, and can be used to apply specific variable overrides for
289
- * expression evaluation for the map canvas render. This method will overwrite the existing expression
290
- * context scope for the canvas.
291
- * @param scope new expression context scope
292
- * @note added in QGIS 2.12
293
- * @see expressionContextScope()
294
- */
295
- void setExpressionContextScope( const QgsExpressionContextScope& scope );
296
-
297
- /** Returns a reference to the expression context scope for the map canvas. This scope is injected
298
- * into the expression context used for rendering the map, and can be used to apply specific variable
299
- * overrides for expression evaluation for the map canvas render.
300
- * @note added in QGIS 2.12
301
- * @see setExpressionContextScope()
302
- */
303
- QgsExpressionContextScope& expressionContextScope();
304
-
305
- /** Returns a const reference to the expression context scope for the map canvas.
306
- * @note added in QGIS 2.12
307
- * @see setExpressionContextScope()
308
- * @note not available in python bindings
309
- */
310
- // const QgsExpressionContextScope& expressionContextScope() const;
311
-
312
- /** Sets the segmentation tolerance applied when rendering curved geometries
313
- @param tolerance the segmentation tolerance*/
92
+ QgsSnappingUtils *snappingUtils() const;
93
+ void setSnappingUtils( QgsSnappingUtils *utils );
94
+ void setExpressionContextScope( const QgsExpressionContextScope &scope );
95
+ QgsExpressionContextScope &expressionContextScope();
96
+ // const QgsExpressionContextScope &expressionContextScope() const;
314
97
void setSegmentationTolerance( double tolerance );
315
-
316
- /** Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation)
317
- @param type the segmentation tolerance typename*/
318
98
void setSegmentationToleranceType( QgsAbstractGeometry::SegmentationToleranceType type );
319
99
320
100
public slots:
@@ -434,12 +214,9 @@ class QgsMapCanvas : QGraphicsView
434
214
//! @note added in 2.8
435
215
void currentLayerChanged( QgsMapLayer* layer );
436
216
437
- //! Emitted when the configuration of overridden layer styles changes
438
- //! @note added in 2.12
439
217
void layerStyleOverridesChanged();
440
-
441
- //! emit a message (usually to be displayed in a message bar)
442
- void messageEmitted( const QString& title, const QString& message, QgsMessageBar::MessageLevel = QgsMessageBar::INFO );
218
+ void themeChanged( const QString &theme );
219
+ void messageEmitted( const QString &title, const QString &message, QgsMessageBar::MessageLevel = QgsMessageBar::INFO );
443
220
444
221
protected:
445
222
0 commit comments