@@ -27,6 +27,7 @@ class QPaintEvent;
27
27
28
28
/* * \ingroup gui
29
29
* A class for drawing transient features (e.g. digitising lines) on the map.
30
+ * It may be used
30
31
*/
31
32
class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
32
33
{
@@ -36,109 +37,175 @@ class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
36
37
* Added in 1.9 */
37
38
enum IconType
38
39
{
40
+ /* *
41
+ * No icon is used
42
+ */
39
43
ICON_NONE,
44
+ /* *
45
+ * A cross is used to highlight points (+)
46
+ */
40
47
ICON_CROSS,
48
+ /* *
49
+ * A cross is used to highlight points (x)
50
+ */
41
51
ICON_X,
52
+ /* *
53
+ * A box is used to highlight points (□)
54
+ */
42
55
ICON_BOX,
56
+ /* *
57
+ * A circle is used to highlight points (○)
58
+ */
43
59
ICON_CIRCLE
44
60
};
45
61
46
62
/* *
47
63
* Creates a new RubberBand.
48
- * @param mapCanvas The map canvas to draw onto. It's CRS will be used map points onto screen coordinates.
49
- * @param geometryType Defines how the data should be drawn onto the screen. (Use QGis::Line, QGis::Polygon or QGis::Point)
50
- * Added in 1.9.
64
+ * @param mapCanvas The map canvas to draw onto. It's CRS will be used map points onto screen coordinates.
65
+ * @param geometryType Defines how the data should be drawn onto the screen. (Use QGis::Line, QGis::Polygon or QGis::Point)
66
+ * @note Added in 1.9.
51
67
*/
52
68
QgsRubberBand ( QgsMapCanvas* mapCanvas, QGis::GeometryType geometryType = QGis::Line );
53
69
/* *
54
70
* Creates a new RubberBand.
55
- * @deprecated
56
- * @param mapCanvas The map canvas to draw onto. It's CRS will be used map points onto screen coordinates.
57
- * @param isPolygon true: draw as (multi-)polygon, false draw as (multi-)linestring
71
+ * @deprecated Use the constructor which takes QGis::GeometryType as second argument instead
72
+ * @param mapCanvas The map canvas to draw onto. It's CRS will be used map points onto screen coordinates.
73
+ * @param isPolygon true: draw as (multi-)polygon, false draw as (multi-)linestring
58
74
*/
59
75
QgsRubberBand ( QgsMapCanvas* mapCanvas, bool isPolygon );
60
76
~QgsRubberBand ();
61
77
62
- /* * Set the color for the rubberband */
78
+ /* *
79
+ * Set the color for the rubberband
80
+ * @param color The color used to render this rubberband
81
+ */
63
82
void setColor ( const QColor & color );
64
83
65
- /* * Set the width of the line. Outline width for polygon. */
84
+ /* *
85
+ * Set the width of the line. Outline width for polygon.
86
+ * @param width The width for any lines painted for this rubberband
87
+ */
66
88
void setWidth ( int width );
67
89
68
- /* * Set the icon type to highlight point geometries.
69
- * Added in 1.9 */
90
+ /* *
91
+ * Set the icon type to highlight point geometries.
92
+ * @param icon The icon to visualize point geometries
93
+ * @note Added in 1.9
94
+ */
70
95
void setIcon ( IconType icon );
71
96
72
- /* * Set the size of the point icons
73
- * Added in 1.9 */
97
+ /* *
98
+ * Set the size of the point icons
99
+ * @note Added in 1.9
100
+ */
74
101
void setIconSize ( int iconSize );
75
102
76
103
/* *
77
104
* Clears all the geometries in this rubberband.
78
105
* Sets the representation type according to geometryType.
79
- * @param geometryType Defines how the data should be drawn onto the screen. (Use QGis::Line, QGis::Polygon or QGis::Point)
80
- * Added in 1.9.
106
+ * @param geometryType Defines how the data should be drawn onto the screen. (Use QGis::Line, QGis::Polygon or QGis::Point)
107
+ * @note Added in 1.9.
81
108
*/
82
109
void reset ( QGis::GeometryType geometryType = QGis::Line );
110
+
83
111
/* *
84
- * @deprecated
112
+ * @deprecated Use the reset method which takes QGis::GeometryType as second argument instead
85
113
* Clears all the geometries in this rubberband.
86
114
* Sets the representation type according to isPolygon.
87
- * @param isPolygon true: draw as (multi-)polygon, false draw as (multi-)linestring
115
+ * @param isPolygon true: draw as (multi-)polygon, false draw as (multi-)linestring
88
116
*/
89
117
void reset ( bool isPolygon );
90
118
91
- // ! Add point to rubberband and update canvas
92
- // ! If adding more points consider using update=false for better performance
93
- // ! geometryIndex is the index of the feature part (in case of multipart geometries)
94
- void addPoint ( const QgsPoint & p, bool update = true , int geometryIndex = 0 );
119
+ /* *
120
+ * Add a vertex to the rubberband and update canvas.
121
+ * The rendering of the vertex depends on the current GeometryType and icon.
122
+ * If adding more points consider using update=false for better performance
123
+ * @param p The vertex/point to add
124
+ * @param doUpdate Should the map canvas be updated immediately?
125
+ * @param geometryIndex The index of the feature part (in case of multipart geometries)
126
+ */
127
+ void addPoint ( const QgsPoint & p, bool doUpdate = true , int geometryIndex = 0 );
95
128
96
- // !Removes the last point. Most useful in connection with undo operations
129
+ /* *
130
+ * Removes the last point. Most useful in connection with undo operations
131
+ */
97
132
void removeLastPoint ( int geometryIndex = 0 );
98
133
134
+ /* *
135
+ * Moves the rubber band point specified by index. Note that if the rubber band is
136
+ * not used to track the last mouse position, the first point of the rubber band has two vertices
137
+ */
99
138
void movePoint ( const QgsPoint & p, int geometryIndex = 0 );
100
- /* *Moves the rubber band point specified by index. Note that if the rubber band is
101
- not used to track the last mouse position, the first point of the rubber band has two vertices*/
139
+
140
+ /* *
141
+ * Moves the rubber band point specified by index. Note that if the rubber band is
142
+ * not used to track the last mouse position, the first point of the rubber band has two vertices
143
+ */
102
144
void movePoint ( int index, const QgsPoint& p, int geometryIndex = 0 );
103
145
104
- /* *Sets this rubber band to the geometry of an existing feature.
105
- This is useful for feature highlighting.
106
- In contrast to addGeometry, this method does also change the geometry type of the rubberband.
107
- @param geom the geometry object
108
- @param layer the layer containing the feature, used for coord transformation to map
109
- crs. In case of 0 pointer, the coordinates are not going to be transformed.
110
- */
146
+ /* *
147
+ * Sets this rubber band to the geometry of an existing feature.
148
+ * This is useful for feature highlighting.
149
+ * In contrast to {@link addGeometry}, this method does also change the geometry type of the rubberband.
150
+ * @param geom the geometry object
151
+ * @param layer the layer containing the feature, used for coord transformation to map
152
+ * crs. In case of 0 pointer, the coordinates are not going to be transformed.
153
+ */
111
154
void setToGeometry ( QgsGeometry* geom, QgsVectorLayer* layer );
112
155
113
- /* *Sets this rubber band to a map canvas rectangle
114
- @param rect rectangle in canvas coordinates
115
- @note added in version 1.7*/
156
+ /* *
157
+ * Sets this rubber band to a map canvas rectangle
158
+ * @param rect rectangle in canvas coordinates
159
+ * @note added in version 1.7
160
+ */
116
161
void setToCanvasRectangle ( const QRect& rect );
117
162
118
- /* *Add the geometry of an existing feature to a rubberband
119
- This is useful for multi feature highlighting.
120
- @param geom the geometry object
121
- @param layer the layer containing the feature, used for coord transformation to map
122
- crs. In case of 0 pointer, the coordinates are not going to be transformed.
123
- @note added in 1.5
124
- */
163
+ /* *
164
+ * Add the geometry of an existing feature to a rubberband
165
+ * This is useful for multi feature highlighting.
166
+ * As of 2.0, this method does not change the GeometryType any more. You need to set the GeometryType
167
+ * of the rubberband explicitly by calling {@link reset} or {@link setToGeometry} with appropriate arguments.
168
+ * {@link setToGeometry} is also to be preferred for backwards-compatibility.
169
+ *
170
+ * @param geom the geometry object. Will be treated as a collection of vertices.
171
+ * @param layer the layer containing the feature, used for coord transformation to map
172
+ * crs. In case of 0 pointer, the coordinates are not going to be transformed.
173
+ * @note added in 1.5
174
+ */
125
175
void addGeometry ( QgsGeometry* geom, QgsVectorLayer* layer );
126
176
127
- /* *Adds translation to original coordinates (all in map coordinates)*/
177
+ /* *
178
+ * Adds translation to original coordinates (all in map coordinates)
179
+ * @param dx x translation
180
+ * @param dy y translation
181
+ */
128
182
void setTranslationOffset ( double dx, double dy );
129
183
130
- /* *Returns number of geometries
131
- * added in 1.5 */
184
+ /* *
185
+ * Returns number of geometries
186
+ * @return number of geometries
187
+ * @note added in 1.5
188
+ */
132
189
int size () const ;
133
190
134
- /* *Returns count of vertices in all lists of mPoint*/
191
+ /* *
192
+ * Returns count of vertices in all lists of mPoint
193
+ * @return The total number of vertices
194
+ */
135
195
int numberOfVertices () const ;
136
196
137
- /* *Return vertex*/
197
+ /* *
198
+ * Return vertex
199
+ * @param i The geometry index
200
+ * @param j The vertex index within geometry i
201
+ */
138
202
const QgsPoint *getPoint ( int i, int j = 0 ) const ;
139
203
140
- /* *Returns the rubberband as a Geometry.
141
- * added in 1.6 */
204
+ /* *
205
+ * Returns the rubberband as a Geometry.
206
+ * @return A geometry object which reflects the current state of the rubberband.
207
+ * @note Added in 1.6
208
+ */
142
209
QgsGeometry* asGeometry ();
143
210
144
211
protected:
@@ -155,14 +222,16 @@ class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
155
222
int mWidth ;
156
223
157
224
/* * The size of the icon for points.
158
- * Added in 1.9 */
225
+ * @note Added in 1.9 */
159
226
int mIconSize ;
160
227
161
228
/* * Icon to be shown.
162
- * Added in 1.9 */
229
+ * @note Added in 1.9 */
163
230
IconType mIconType ;
164
231
165
- /* *Nested lists used for multitypes*/
232
+ /* *
233
+ * Nested lists used for multitypes
234
+ */
166
235
QList< QList <QgsPoint> > mPoints ;
167
236
QGis::GeometryType mGeometryType ;
168
237
double mTranslationOffsetX ;
0 commit comments