@@ -33,16 +33,20 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
33
33
Q_OBJECT
34
34
public:
35
35
36
+ /* ! Controls how pictures are scaled within the item's frame
37
+ */
36
38
enum ResizeMode
37
39
{
38
- Zoom,
39
- Stretch,
40
- Clip,
41
- ZoomResizeFrame,
42
- FrameToImageSize
40
+ Zoom, /* !< enlarges image to fit frame while maintaining aspect ratio of picture */
41
+ Stretch, /* !< stretches image to fit frame, ignores aspect ratio */
42
+ Clip, /* !< draws image at original size and clips any portion which falls outside frame */
43
+ ZoomResizeFrame, /* !< enlarges image to fit frame, then resizes frame to fit resultant image */
44
+ FrameToImageSize /* !< sets size of frame to match original size of image without scaling */
43
45
};
44
46
45
- enum Mode // SVG or raster graphic format
47
+ /* ! Format of source image
48
+ */
49
+ enum Mode
46
50
{
47
51
SVG,
48
52
RASTER,
@@ -58,8 +62,20 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
58
62
/* *Reimplementation of QCanvasItem::paint*/
59
63
void paint ( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
60
64
61
- /* *Sets the source file of the image (may be svg or a raster format)*/
65
+ /* *Sets the source file of the image (may be svg or a raster format). This is only used if
66
+ * usePictureExpression() is false.
67
+ * @param path full path to the source image
68
+ * @see usePictureExpression
69
+ * @see pictureFile
70
+ */
62
71
void setPictureFile ( const QString& path );
72
+
73
+ /* *Returns the path of the source image file. This is only used if
74
+ * usePictureExpression() is false.
75
+ * @returns path to the source image
76
+ * @see usePictureExpression
77
+ * @see setPictureFile
78
+ */
63
79
QString pictureFile () const ;
64
80
65
81
/* *Sets this items bound in scene coordinates such that 1 item size units
@@ -81,26 +97,48 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
81
97
/* *Returns the rotation used for drawing the picture within the composer item
82
98
* @deprecated Use pictureRotation() instead
83
99
*/
84
- Q_DECL_DEPRECATED double rotation () const { return mPictureRotation ;};
100
+ Q_DECL_DEPRECATED double rotation () const { return mPictureRotation ; }
85
101
86
- /* *Returns the rotation used for drawing the picture within the item
87
- @note this function was added in version 2.1*/
88
- double pictureRotation () const { return mPictureRotation ;};
89
-
90
- /* *Sets the map object for rotation (by id). A value of -1 disables the map rotation*/
102
+ /* *Returns the rotation used for drawing the picture within the item's frame
103
+ * @returns picture rotation in degrees
104
+ * @note added in 2.2
105
+ * @see setPictureRotation
106
+ * @see rotationMap
107
+ */
108
+ double pictureRotation () const { return mPictureRotation ; }
109
+
110
+ /* *Sets the map object for rotation (by id). A value of -1 disables the map rotation.
111
+ * If this is set then the picture will be rotated by the same amount as the specified
112
+ * map object. This is useful especially for syncing north arrows with a map item.
113
+ * @param id composer map id to sync rotation with
114
+ * @see setPictureRotation
115
+ * @see rotationMap
116
+ */
91
117
void setRotationMap ( int composerMapId );
92
- /* *Returns the id of the rotation map*/
118
+
119
+ /* *Returns the id of the rotation map. A value of -1 means map rotation is disabled.
120
+ * If this is set then the picture is rotated by the same amount as the specified
121
+ * map object.
122
+ * @returns id of map object
123
+ * @see setRotationMap
124
+ * @see useRotationMap
125
+ */
93
126
int rotationMap () const ;
94
- /* *True if the rotation is taken from a map item*/
95
- bool useRotationMap () const {return mRotationMap ;}
127
+
128
+ /* *True if the picture rotation is matched to a map item.
129
+ * @returns true if rotation map is in use
130
+ * @see rotationMap
131
+ * @see setRotationMap
132
+ */
133
+ bool useRotationMap () const { return mRotationMap ; }
96
134
97
135
/* *Returns the resize mode used for drawing the picture within the composer item's
98
136
* frame.
99
137
* @returns resize mode of picture
100
138
* @note added in 2.3
101
139
* @see setResizeMode
102
140
*/
103
- ResizeMode resizeMode () const { return mResizeMode ;}
141
+ ResizeMode resizeMode () const { return mResizeMode ; }
104
142
105
143
/* *Returns whether the picture item is using an expression for the image source.
106
144
* @returns true if the picture is using an expression for the source, false if
@@ -110,7 +148,7 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
110
148
* @see pictureFile
111
149
* @see pictureExpression
112
150
*/
113
- bool usePictureExpression () const { return mUseSourceExpression ;}
151
+ bool usePictureExpression () const { return mUseSourceExpression ; }
114
152
115
153
/* *Returns the expression the item is using for the picture source. This is only
116
154
* used if usePictureExpression() is true.
@@ -119,7 +157,7 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
119
157
* @see setPictureExpression
120
158
* @see usePictureExpression
121
159
*/
122
- QString pictureExpression () const { return mSourceExpression ;}
160
+ QString pictureExpression () const { return mSourceExpression ; }
123
161
124
162
/* *Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation
125
163
* @deprecated Use bool QgsComposerItem::imageSizeConsideringRotation( double& width, double& height, double rotation )
@@ -137,7 +175,11 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
137
175
*/
138
176
Q_DECL_DEPRECATED void sizeChangedByRotation ( double & width, double & height );
139
177
140
- Mode mode () const { return mMode ; };
178
+ /* *Returns the current picture mode (image format).
179
+ * @returns picture mode
180
+ * @note added in 2.3
181
+ */
182
+ Mode mode () const { return mMode ; }
141
183
142
184
public slots:
143
185
/* *Sets the picture rotation within the item bounds. This does not affect the item rectangle,
@@ -146,9 +188,12 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
146
188
*/
147
189
virtual void setRotation ( double r );
148
190
149
- /* *Sets the picture rotation within the item bounds. This does not affect the item rectangle,
150
- only the way the picture is drawn within the item.
151
- @note this function was added in version 2.1*/
191
+ /* *Sets the picture rotation within the item bounds. This does not affect the item's frame,
192
+ * only the way the picture is drawn within the item.
193
+ * @param r rotation in degrees clockwise
194
+ * @see pictureRotation
195
+ * @note added in 2.2
196
+ */
152
197
virtual void setPictureRotation ( double r );
153
198
154
199
/* *Sets the resize mode used for drawing the picture within the item bounds.
@@ -177,10 +222,21 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
177
222
*/
178
223
virtual void setPictureExpression ( QString expression );
179
224
225
+ /* *Recalculates the source image (if using an expression for picture's source)
226
+ * and reloads and redraws the picture.
227
+ * @note added in 2.3
228
+ */
180
229
void refreshPicture ();
181
230
231
+ /* *Prepares the picture's source expression after it is altered or the compositions
232
+ * atlas coverage layer changes.
233
+ * @note added in 2.3
234
+ */
182
235
void updatePictureExpression ();
183
236
237
+ /* *Forces a recalculation of the picture's frame size
238
+ * @note added in 2.3
239
+ */
184
240
void recalculateSize ();
185
241
186
242
signals:
@@ -221,9 +277,13 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
221
277
222
278
QgsExpression* mPictureExpr ;
223
279
280
+ /* *loads an image file into the picture item and redraws the item*/
224
281
void loadPicture ( const QFile &file );
225
282
283
+ /* *evaluates the picture expression and returns the calculated image path*/
226
284
QString evalPictureExpression ();
285
+
286
+ /* *sets up the picture item and connects to relevant signals*/
227
287
void init ();
228
288
};
229
289
0 commit comments