~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to python/gui/qgsmapcanvas.sip

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
 
 
4
/** \class QgsMapCanvasLayer
 
5
  \brief class that stores additional layer's flags together with pointer to the layer
 
6
*/
 
7
class QgsMapCanvasLayer
 
8
{
 
9
%TypeHeaderCode
 
10
#include <qgsmapcanvas.h>
 
11
%End
 
12
 
 
13
public:
 
14
  QgsMapCanvasLayer(QgsMapLayer* layer, bool visible = TRUE, bool isInOverview = FALSE);
 
15
  
 
16
  void setVisible(bool visible);
 
17
  void setInOverview(bool isInOverview);
 
18
  
 
19
  bool isVisible() const;
 
20
  bool isInOverview() const;
 
21
  
 
22
  QgsMapLayer* layer();
 
23
  //const QgsMapLayer* layer() const;
 
24
  
 
25
};
 
26
 
 
27
 
 
28
/*! \class QgsMapCanvas
 
29
 * \brief Map canvas class for displaying all GIS data types.
 
30
 */
 
31
 
 
32
class QgsMapCanvas : QGraphicsView
 
33
{
 
34
%TypeHeaderCode
 
35
#include <qgsmapcanvas.h>
 
36
%End
 
37
 
 
38
%ConvertToSubClassCode
 
39
  if (dynamic_cast<QgsMapCanvas*>(sipCpp) != NULL)
 
40
    sipClass = sipClass_QgsMapCanvas;
 
41
  else
 
42
    sipClass = NULL;
 
43
%End
 
44
 
 
45
 public:
 
46
 
 
47
    enum WheelAction { WheelZoom, WheelZoomAndRecenter, WheelZoomToMouseCursor, WheelNothing };
 
48
 
 
49
    //! Constructor
 
50
    QgsMapCanvas(QWidget * parent /TransferThis/ = 0, const char *name = 0);
 
51
 
 
52
    //! Destructor
 
53
    ~QgsMapCanvas();
 
54
 
 
55
    void setLayerSet(QList<QgsMapCanvasLayer>& layers);
 
56
    
 
57
    void setCurrentLayer(QgsMapLayer* layer);
 
58
    
 
59
    void updateOverview();
 
60
    
 
61
    void enableOverviewMode(QgsMapOverviewCanvas* overview);
 
62
    
 
63
    QgsMapCanvasMap* map();
 
64
    
 
65
    QgsMapRenderer* mapRenderer();
 
66
    
 
67
    //! Accessor for the canvas pixmap
 
68
    QPixmap& canvasPixmap();
 
69
 
 
70
    //! Get the last reported scale of the canvas
 
71
    double scale();
 
72
 
 
73
    //! Clear the map canvas
 
74
    void clear();
 
75
 
 
76
    //! Returns the mapUnitsPerPixel (map units per pixel) for the canvas
 
77
    double mapUnitsPerPixel() const;
 
78
 
 
79
    //! Returns the current zoom exent of the map canvas
 
80
    QgsRectangle extent() const;
 
81
    //! Returns the combined exent for all layers on the map canvas
 
82
    QgsRectangle fullExtent() const;
 
83
 
 
84
    //! Set the extent of the map canvas
 
85
    void setExtent(const QgsRectangle & r);
 
86
 
 
87
    //! Zoom to the full extent of all layers
 
88
    void zoomToFullExtent();
 
89
 
 
90
    //! Zoom to the previous extent (view)
 
91
    void zoomToPreviousExtent();
 
92
 
 
93
    //! Zoom to the next extent (view)
 
94
    void zoomToNextExtent();
 
95
 
 
96
    // ! Clears the list of extents and sets current extent as first item
 
97
    void clearExtentHistory();
 
98
 
 
99
    /** Zoom to the extent of the selected features of current (vector) layer.
 
100
      Added in version 1.2: optionally specify different than current layer */
 
101
    void zoomToSelected(QgsVectorLayer* layer = NULL);
 
102
 
 
103
    /** \brief Sets the map tool currently being used on the canvas */
 
104
    void setMapTool(QgsMapTool* mapTool);
 
105
    
 
106
    /** \brief Unset the current mapset tool or last non zoom tool if 
 
107
     *         it the same as passed map tool pointer. The tool is not 
 
108
     *         referenced/used any more, but the instance is not deleted 
 
109
     *         by this method.
 
110
     */
 
111
    void unsetMapTool(QgsMapTool* mapTool);
 
112
 
 
113
    /**Returns the currently active tool*/
 
114
    QgsMapTool* mapTool();
 
115
    
 
116
    /** Write property of QColor bgColor. */
 
117
    virtual void setCanvasColor(const QColor & _newVal);
 
118
 
 
119
    /** Emits signal scalChanged to update scale in main window */
 
120
    void updateScale();
 
121
 
 
122
    /** Updates the full extent */
 
123
    void updateFullExtent();
 
124
 
 
125
    //! return the map layer at position index in the layer stack
 
126
    QgsMapLayer *layer(int index);
 
127
    
 
128
    //! return number of layers on the map
 
129
    int layerCount() const;
 
130
 
 
131
    /*! Freeze/thaw the map canvas. This is used to prevent the canvas from
 
132
     * responding to events while layers are being added/removed etc.
 
133
     * @param frz Boolean specifying if the canvas should be frozen (true) or
 
134
     * thawed (false). Default is true.
 
135
     */
 
136
    void freeze(bool frz = true);
 
137
 
 
138
    /*! Accessor for frozen status of canvas */
 
139
    bool isFrozen();
 
140
 
 
141
    //! Flag the canvas as dirty and needed a refresh
 
142
    void setDirty(bool _dirty);
 
143
 
 
144
    //! Return the state of the canvas (dirty or not)
 
145
    bool isDirty() const;
 
146
 
 
147
    //! Set map units (needed by project properties dialog)
 
148
    void setMapUnits(QGis::UnitType mapUnits);
 
149
    //! Get the current canvas map units
 
150
 
 
151
    QGis::UnitType mapUnits() const;
 
152
 
 
153
    //! Get the current coordinate transform
 
154
    const QgsMapToPixel * getCoordinateTransform();
 
155
 
 
156
    //! true if canvas currently drawing
 
157
    bool isDrawing();
 
158
    
 
159
    //! returns current layer (set by legend widget)
 
160
    QgsMapLayer* currentLayer();
 
161
    
 
162
    //! set wheel action and zoom factor (should be greater than 1)
 
163
    void setWheelAction(WheelAction action, double factor = 2);
 
164
 
 
165
    //! Zoom in with fixed factor
 
166
    void zoomIn( );
 
167
 
 
168
    //! Zoom out with fixed factor
 
169
    void zoomOut( );
 
170
    
 
171
    //! Zoom with the factor supplied. Factor > 1 zooms in
 
172
    void zoomByFactor( double scaleFactor );
 
173
 
 
174
    //! Zooms in/out with a given center
 
175
    void zoomWithCenter(int x, int y, bool zoomIn);
 
176
 
 
177
    //! used to determine if anti-aliasing is enabled or not
 
178
    void enableAntiAliasing(bool theFlag);
 
179
    
 
180
    //! Select which Qt class to render with
 
181
    void useImageToRender(bool theFlag);
 
182
 
 
183
    // following 2 methods should be moved elsewhere or changed to private
 
184
    // currently used by pan map tool
 
185
    //! Ends pan action and redraws the canvas.
 
186
    void panActionEnd(QPoint releasePoint);
 
187
    //! Called when mouse is moving and pan is activated
 
188
    void panAction(QMouseEvent * event);
 
189
    
 
190
    //! returns last position of mouse cursor
 
191
    QPoint mouseLastXY();
 
192
  
 
193
  public slots:
 
194
 
 
195
    /**Sets dirty=true and calls render()*/
 
196
    void refresh();
 
197
 
 
198
    //! Save the convtents of the map canvas to disk as an image
 
199
    void saveAsImage(QString theFileName,QPixmap * QPixmap=0, QString="PNG" );
 
200
 
 
201
    //! This slot is connected to the visibility change of one or more layers
 
202
    void layerStateChange();
 
203
 
 
204
    //! Whether to suppress rendering or not
 
205
    void setRenderFlag(bool theFlag);
 
206
    //! State of render suppression flag
 
207
    bool renderFlag();
 
208
 
 
209
    /** A simple helper method to find out if on the fly projections are enabled or not */
 
210
    bool hasCrsTransformEnabled();
 
211
 
 
212
    /** The map units may have changed, so cope with that */
 
213
    void mapUnitsChanged();
 
214
    
 
215
    /** updates pixmap on render progress */
 
216
    void updateMap();
 
217
    
 
218
    //! show whatever error is exposed by the QgsMapLayer.
 
219
    void showError(QgsMapLayer * mapLayer);
 
220
    
 
221
    //! called to read map canvas settings from project
 
222
    void readProject(const QDomDocument &);
 
223
    
 
224
    //! called to write map canvas settings to project
 
225
    void writeProject(QDomDocument &);
 
226
    
 
227
  signals:
 
228
    /** Let the owner know how far we are with render operations */
 
229
    void setProgress(int,int);
 
230
 
 
231
    /** emits current mouse position
 
232
      \note changed in 1.3 */
 
233
    void xyCoordinates(const QgsPoint &p);
 
234
 
 
235
    //! Emitted when the scale of the map changes
 
236
    void scaleChanged(QString);
 
237
 
 
238
    //! Emitted when the extents of the map change
 
239
    void extentsChanged();
 
240
 
 
241
    /** Emitted when the canvas has rendered.
 
242
 
 
243
     Passes a pointer to the painter on which the map was drawn. This is
 
244
     useful for plugins that wish to draw on the map after it has been
 
245
     rendered.  Passing the painter allows plugins to work when the map is
 
246
     being rendered onto a pixmap other than the mapCanvas own pixmap member.
 
247
 
 
248
    */
 
249
    void renderComplete(QPainter *);
 
250
    
 
251
    //! Emitted when a new set of layers has been received
 
252
    void layersChanged();
 
253
 
 
254
    //! Emit key press event
 
255
    void keyPressed(QKeyEvent * e);
 
256
 
 
257
    //! Emit key release event
 
258
    void keyReleased(QKeyEvent * e);
 
259
   
 
260
    //! Emit map tool changed event
 
261
    void mapToolSet(QgsMapTool *tool);
 
262
 
 
263
    //! Emitted when zoom last status changed
 
264
    //! @note: this signal was added in version 1.4
 
265
    void zoomLastStatusChanged( bool );
 
266
 
 
267
    //! Emitted when zoom next status changed
 
268
    //! @note: this signal was added in version 1.4
 
269
    void zoomNextStatusChanged( bool );
 
270
 
 
271
  protected:
 
272
 
 
273
    //! Overridden key press event
 
274
    void keyPressEvent(QKeyEvent * e);
 
275
 
 
276
    //! Overridden key release event
 
277
    void keyReleaseEvent(QKeyEvent * e);
 
278
 
 
279
    //! Overridden mouse move event
 
280
    void mouseMoveEvent(QMouseEvent * e);
 
281
 
 
282
    //! Overridden mouse press event
 
283
    void mousePressEvent(QMouseEvent * e);
 
284
 
 
285
    //! Overridden mouse release event
 
286
    void mouseReleaseEvent(QMouseEvent * e);
 
287
 
 
288
    //! Overridden mouse wheel event
 
289
    void wheelEvent(QWheelEvent * e);
 
290
 
 
291
    //! Overridden resize event
 
292
    void resizeEvent(QResizeEvent * e);
 
293
 
 
294
    //! called when panning is in action, reset indicates end of panning
 
295
    void moveCanvasContents(bool reset = FALSE);
 
296
 
 
297
    //! called on resize or changed extent to notify canvas items to change their rectangle
 
298
    void updateCanvasItemPositions();
 
299
 
 
300
 
 
301
}; // class QgsMapCanvas
 
302
 
 
303