@@ -18,298 +18,82 @@ 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
65
33
void setParallelRenderingEnabled( bool enabled );
66
-
67
- //! Check whether the layers are rendered in parallel or sequentially
68
- //! @note added in 2.4
69
34
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
35
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
36
int mapUpdateInterval() const;
78
-
79
- //! Get the last reported scale of the canvas
80
37
double scale();
81
-
82
- //! Returns the mapUnitsPerPixel (map units per pixel) for the canvas
83
38
double mapUnitsPerPixel() const;
84
-
85
- //! Returns the current zoom extent of the map canvas
86
39
QgsRectangle extent() const;
87
- //! Returns the combined extent for all layers on the map canvas
88
40
QgsRectangle fullExtent() const;
89
-
90
- //! Set the extent of the map canvas
91
41
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
42
double rotation() const;
96
-
97
- //! Set the rotation of the map canvas in clockwise degrees
98
- //! @note added in 2.8
99
43
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
44
+ void setCenter( const QgsPoint ¢er );
107
45
QgsPoint center() const;
108
-
109
- //! Zoom to the full extent of all layers
110
46
void zoomToFullExtent();
111
-
112
- //! Zoom to the previous extent (view)
113
47
void zoomToPreviousExtent();
114
-
115
- //! Zoom to the next extent (view)
116
48
void zoomToNextExtent();
117
-
118
- // ! Clears the list of extents and sets current extent as first item
119
49
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.
50
+ void zoomToSelected( QgsVectorLayer *layer = 0 );
51
+ void zoomToFeatureIds( QgsVectorLayer *layer, const QgsFeatureIds &ids );
52
+ void panToFeatureIds( QgsVectorLayer *layer, const QgsFeatureIds &ids );
53
+ void panToSelected( QgsVectorLayer *layer = 0 );
54
+ void setMapTool( QgsMapTool *mapTool );
55
+ void unsetMapTool( QgsMapTool *mapTool );
56
+ QgsMapTool *mapTool();
57
+ void setCanvasColor( const QColor &_newVal );
156
58
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
59
+ void setSelectionColor( const QColor &color );
163
60
void updateScale();
164
-
165
- //! return the map layer at position index in the layer stack
166
61
QgsMapLayer *layer( int index );
167
-
168
- //! return number of layers on the map
169
62
int layerCount() const;
170
-
171
- //! return list of layers within map canvas.
172
- QList<QgsMapLayer*> layers() const;
63
+ QList<QgsMapLayer *> layers() const;
173
64
void freeze( bool frozen = true );
174
65
bool isFrozen() const;
175
66
bool renderFlag() const;
176
-
177
- //! Get the current canvas map units
178
67
QgsUnitTypes::DistanceUnit mapUnits() const;
179
-
180
- //! Getter for stored overrides of styles for layers.
181
- //! @note added in 2.12
182
68
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
-
69
+ void setLayerStyleOverrides( const QMap<QString, QString> &overrides );
188
70
void setTheme( const QString &theme );
189
71
QString theme() const;
190
72
const QgsMapToPixel *getCoordinateTransform();
191
73
bool isDrawing();
192
74
QgsMapLayer *currentLayer();
193
75
void setWheelFactor( double factor );
194
-
195
- //! Zoom to a specific scale
196
76
void zoomScale( double scale );
197
-
198
- //! Zoom with the factor supplied. Factor > 1 zooms out, interval (0,1) zooms in
199
- //! If point is given, re-center on it
200
77
void zoomByFactor( double scaleFactor, const QgsPoint *center = 0 );
201
-
202
- //! Zooms in/out with a given center
203
78
void zoomWithCenter( int x, int y, bool zoomIn );
204
-
205
- //! Zooms to feature extent. Adds a small margin around the extent
206
- //! and does a pan if rect is empty (point extent)
207
- void zoomToFeatureExtent( QgsRectangle& rect );
208
-
209
- //! Returns whether the scale is locked, so zooming can be performed using magnication.
210
- //! @note added in 2.16
211
- //! @see setScaleLocked()
79
+ void zoomToFeatureExtent( QgsRectangle &rect );
212
80
bool scaleLocked() const;
213
-
214
- //! used to determine if anti-aliasing is enabled or not
215
81
void enableAntiAliasing( bool flag );
216
-
217
- //! true if antialising is enabled
218
82
bool antiAliasingEnabled() const;
219
-
220
- //! sets map tile rendering flag
221
83
void enableMapTileRendering( bool flag );
222
-
223
- // following 2 methods should be moved elsewhere or changed to private
224
- // currently used by pan map tool
225
- //! Ends pan action and redraws the canvas.
226
84
void panActionEnd( QPoint releasePoint );
227
-
228
- //! Called when mouse is moving and pan is activated
229
- void panAction( QMouseEvent * event );
230
-
231
- //! returns last position of mouse cursor
85
+ void panAction( QMouseEvent *event );
232
86
QPoint mouseLastXY();
233
-
234
- /** Enables a preview mode for the map canvas
235
- * @param previewEnabled set to true to enable a preview mode
236
- * @see setPreviewMode
237
- * @note added in 2.3 */
238
87
void setPreviewModeEnabled( bool previewEnabled );
239
-
240
- /** Returns whether a preview mode is enabled for the map canvas
241
- * @returns true if a preview mode is currently enabled
242
- * @see setPreviewModeEnabled
243
- * @see previewMode
244
- * @note added in 2.3 */
245
88
bool previewModeEnabled() const;
246
-
247
- /** Sets a preview mode for the map canvas. This setting only has an effect if
248
- * previewModeEnabled is true.
249
- * @param mode preview mode for the canvas
250
- * @see previewMode
251
- * @see setPreviewModeEnabled
252
- * @see previewModeEnabled
253
- * @note added in 2.3 */
254
89
void setPreviewMode( QgsPreviewEffect::PreviewMode mode );
255
-
256
- /** Returns the current preview mode for the map canvas. This setting only has an effect if
257
- * previewModeEnabled is true.
258
- * @returns preview mode for map canvas
259
- * @see setPreviewMode
260
- * @see previewModeEnabled
261
- * @note added in 2.3 */
262
90
QgsPreviewEffect::PreviewMode previewMode() const;
263
-
264
- /** Return snapping utility class that is associated with map canvas.
265
- * If no snapping utils instance has been associated previously, an internal will be created for convenience
266
- * (so map tools do not need to test for existence of the instance).
267
- *
268
- * Main canvas in QGIS returns an instance which is always up-to-date with the project's snapping configuration.
269
- * @note added in 2.8
270
- */
271
- QgsSnappingUtils* snappingUtils() const;
272
-
273
- /** Assign an instance of snapping utils to the map canvas.
274
- * The instance is not owned by the canvas, so it is possible to use one instance in multiple canvases.
275
- *
276
- * For main canvas in QGIS, do not associate a different instance from the existing one (it is updated from
277
- * the project's snapping configuration).
278
- * @note added in 2.8
279
- */
280
- void setSnappingUtils( QgsSnappingUtils* utils );
281
-
282
- /** Sets an expression context scope for the map canvas. This scope is injected into the expression
283
- * context used for rendering the map, and can be used to apply specific variable overrides for
284
- * expression evaluation for the map canvas render. This method will overwrite the existing expression
285
- * context scope for the canvas.
286
- * @param scope new expression context scope
287
- * @note added in QGIS 2.12
288
- * @see expressionContextScope()
289
- */
290
- void setExpressionContextScope( const QgsExpressionContextScope& scope );
291
-
292
- /** Returns a reference to the expression context scope for the map canvas. This scope is injected
293
- * into the expression context used for rendering the map, and can be used to apply specific variable
294
- * overrides for expression evaluation for the map canvas render.
295
- * @note added in QGIS 2.12
296
- * @see setExpressionContextScope()
297
- */
298
- QgsExpressionContextScope& expressionContextScope();
299
-
300
- /** Returns a const reference to the expression context scope for the map canvas.
301
- * @note added in QGIS 2.12
302
- * @see setExpressionContextScope()
303
- * @note not available in python bindings
304
- */
305
- // const QgsExpressionContextScope& expressionContextScope() const;
306
-
307
- /** Sets the segmentation tolerance applied when rendering curved geometries
308
- @param tolerance the segmentation tolerance*/
91
+ QgsSnappingUtils *snappingUtils() const;
92
+ void setSnappingUtils( QgsSnappingUtils *utils );
93
+ void setExpressionContextScope( const QgsExpressionContextScope &scope );
94
+ QgsExpressionContextScope &expressionContextScope();
95
+ // const QgsExpressionContextScope &expressionContextScope() const;
309
96
void setSegmentationTolerance( double tolerance );
310
-
311
- /** Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation)
312
- @param type the segmentation tolerance typename*/
313
97
void setSegmentationToleranceType( QgsAbstractGeometry::SegmentationToleranceType type );
314
98
315
99
public slots:
0 commit comments