Skip to content

Commit b4d7e02

Browse files
committed
fix windows build (also syncs QgsComposition sip binding)
1 parent 4fd3b1f commit b4d7e02

File tree

3 files changed

+95
-31
lines changed

3 files changed

+95
-31
lines changed

python/core/composer/qgscomposition.sip

+83-21
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@ class QgsComposition : QGraphicsScene
2727
Dots,
2828
Crosses
2929
};
30-
30+
31+
enum ZValueDirection
32+
{
33+
ZValueBelow,
34+
ZValueAbove
35+
};
36+
3137
/**Composition atlas modes*/
3238
enum AtlasMode
3339
{
3440
AtlasOff, // Composition is not being controlled by an atlas
3541
PreviewAtlas, // An atlas composition is being previewed in the app
3642
ExportAtlas // The composition is being exported as an atlas
37-
};
43+
};
3844

3945
QgsComposition( QgsMapRenderer* mapRenderer );
4046
~QgsComposition();
@@ -55,23 +61,55 @@ class QgsComposition : QGraphicsScene
5561
/**Note: added in version 1.9*/
5662
int numPages() const;
5763

64+
/**Note: added in version 2.1*/
65+
void setPageStyleSymbol( QgsFillSymbolV2* symbol /Transfer/ );
66+
/**Note: added in version 2.1*/
67+
QgsFillSymbolV2* pageStyleSymbol();
68+
69+
/**Returns the position within a page of a point in the composition
70+
@note Added in QGIS 2.1
71+
*/
72+
QPointF positionOnPage( const QPointF & position ) const;
73+
74+
/**Returns the page number corresponding to a point in the composition
75+
@note Added in QGIS 2.1
76+
*/
77+
int pageNumberForPoint( const QPointF & position ) const;
78+
79+
/**Sets the status bar message for the composer window
80+
@note Added in QGIS 2.1
81+
*/
82+
void setStatusMessage( const QString & message );
83+
84+
/**Refreshes the composition when composer related options change
85+
*Note: added in version 2.1*/
86+
void updateSettings();
87+
5888
void setSnapToGridEnabled( bool b );
5989
bool snapToGridEnabled() const;
6090

6191
void setGridVisible( bool b );
6292
bool gridVisible() const;
6393

64-
/**Toggles state of smart guides*/
94+
/**Hides / shows custom snap lines*/
95+
void setSnapLinesVisible( bool visible );
96+
bool snapLinesVisible() const;
97+
98+
void setAlignmentSnap( bool s );
99+
bool alignmentSnap() const;
100+
65101
void setSmartGuidesEnabled( bool b );
66-
/**Returns true if smart guides are enabled*/
67-
bool smartGuidesEnabled() const;
68-
102+
bool smartGuidesEnabled() const;
103+
69104
/**Removes all snap lines*/
70-
void clearSnapLines();
105+
void clearSnapLines();
71106

72107
void setSnapGridResolution( double r );
73108
double snapGridResolution() const;
74109

110+
void setSnapGridTolerance( double tolerance );
111+
double snapGridTolerance() const;
112+
75113
void setSnapGridOffsetX( double offset );
76114
double snapGridOffsetX() const;
77115

@@ -84,9 +122,6 @@ class QgsComposition : QGraphicsScene
84122
void setGridStyle( GridStyle s );
85123
GridStyle gridStyle() const;
86124

87-
void setAlignmentSnap( bool s );
88-
bool alignmentSnap() const;
89-
90125
void setAlignmentSnapTolerance( double t );
91126
double alignmentSnapTolerance() const;
92127

@@ -96,6 +131,11 @@ class QgsComposition : QGraphicsScene
96131
/**Returns the topmost composer item. Ignores mPaperItem*/
97132
QgsComposerItem* composerItemAt( const QPointF & position );
98133

134+
/**Returns the highest composer item at a specified position which is below a specified item. Ignores mPaperItem
135+
@note Added in QGIS 2.1
136+
*/
137+
QgsComposerItem* composerItemAt( const QPointF & position, const QgsComposerItem* belowItem );
138+
99139
/** Returns the page number (0-bsaed) given a coordinate */
100140
int pageNumberAt( const QPointF& position ) const;
101141

@@ -145,19 +185,19 @@ class QgsComposition : QGraphicsScene
145185
bool printAsRaster() const;
146186
void setPrintAsRaster( bool enabled );
147187

188+
bool generateWorldFile() const;
189+
void setGenerateWorldFile( bool enabled );
190+
191+
QgsComposerMap* worldFileMap();
192+
void setWorldFileMap( QgsComposerMap* map );
193+
148194
/**Returns true if a composition should use advanced effects such as blend modes
149195
@note added in 1.9*/
150196
bool useAdvancedEffects() const;
151197
/**Used to enable or disable advanced effects such as blend modes in a composition
152198
@note: added in version 1.9*/
153199
void setUseAdvancedEffects( bool effectsEnabled );
154200

155-
bool generateWorldFile() const;
156-
void setGenerateWorldFile( bool enabled );
157-
158-
QgsComposerMap* worldFileMap();
159-
void setWorldFileMap( QgsComposerMap* map );
160-
161201
/**Returns pointer to map renderer of qgis map canvas*/
162202
QgsMapRenderer* mapRenderer();
163203

@@ -214,6 +254,11 @@ class QgsComposition : QGraphicsScene
214254
void moveSelectedItemsToBottom();
215255
void moveItemToBottom( QgsComposerItem* item );
216256

257+
//functions to find items by their position in the z list
258+
void selectNextByZOrder( ZValueDirection direction );
259+
QgsComposerItem* getComposerItemBelow( QgsComposerItem* item );
260+
QgsComposerItem* getComposerItemAbove( QgsComposerItem* item );
261+
217262
//functions to align selected items
218263
void alignSelectedItemsLeft();
219264
void alignSelectedItemsHCenter();
@@ -222,13 +267,25 @@ class QgsComposition : QGraphicsScene
222267
void alignSelectedItemsVCenter();
223268
void alignSelectedItemsBottom();
224269

270+
//functions to lock and unlock items
271+
/**Lock the selected items*/
272+
void lockSelectedItems();
273+
/**Unlock all items*/
274+
void unlockAllItems();
275+
225276
/**Sorts the zList. The only time where this function needs to be called is from QgsComposer
226277
after reading all the items from xml file*/
227278
void sortZList();
228279

229280
/**Snaps a scene coordinate point to grid*/
230281
QPointF snapPointToGrid( const QPointF& scenePoint ) const;
231282

283+
/**Returns pointer to snap lines collection*/
284+
QList< QGraphicsLineItem* >* snapLines();
285+
286+
/**Returns pointer to selection handles*/
287+
// QgsComposerMouseHandles* selectionHandles();
288+
232289
/**Add a custom snap line (can be horizontal or vertical)*/
233290
QGraphicsLineItem* addSnapLine();
234291
/**Remove custom snap line (and delete the object)*/
@@ -237,10 +294,6 @@ class QgsComposition : QGraphicsScene
237294
* @note not available in python bindings
238295
*/
239296
// QGraphicsLineItem* nearestSnapLine( bool horizontal, double x, double y, double tolerance, QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode > >& snappedItems );
240-
/**Hides / shows custom snap lines*/
241-
void setSnapLinesVisible( bool visible );
242-
/**Returns visibility of custom snap lines*/
243-
bool snapLinesVisible() const;
244297

245298
/**Allocates new item command and saves initial state in it
246299
@param item target item
@@ -286,6 +339,10 @@ class QgsComposition : QGraphicsScene
286339
/**Convenience function to create a QgsAddRemoveItemCommand, connect its signals and push it to the undo stack*/
287340
void pushAddRemoveCommand( QgsComposerItem* item, const QString& text, QgsAddRemoveItemCommand::State state = QgsAddRemoveItemCommand::Added );
288341

342+
/**If true, prevents any mouse cursor changes by the composition or by any composer items
343+
Used by QgsComposer and QgsComposerView to prevent unwanted cursor changes*/
344+
void setPreventCursorChange( bool preventChange );
345+
bool preventCursorChange();
289346

290347
//printing
291348

@@ -314,7 +371,12 @@ class QgsComposition : QGraphicsScene
314371
void computeWorldFileParameters( double& a, double& b, double& c, double& d, double& e, double& f ) const;
315372

316373
QgsAtlasComposition& atlasComposition();
317-
374+
375+
/**Resizes a QRectF relative to the change from boundsBefore to boundsAfter*/
376+
static void relativeResizeRect( QRectF& rectToResize, const QRectF& boundsBefore, const QRectF& boundsAfter );
377+
/**Returns a scaled position given a before and after range*/
378+
static double relativePosition( double position, double beforeMin, double beforeMax, double afterMin, double afterMax );
379+
318380
/** Returns the current atlas mode of the composition */
319381
QgsComposition::AtlasMode atlasMode() const;
320382
/** Sets the current atlas mode of the composition. Returns false if the mode could not be changed. */

src/core/composer/qgscomposerscalebar.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ void QgsComposerScaleBar::applyDefaultSize( QgsComposerScaleBar::ScaleBarUnits u
259259
if ( mComposerMap )
260260
{
261261
setUnits( u );
262-
double upperMagnitudeMultiplier;
262+
double upperMagnitudeMultiplier = 1.0;
263263
double widthInSelectedUnits = mapWidth();
264264
double initialUnitsPerSegment = widthInSelectedUnits / 10.0; //default scalebar width equals half the map width
265265
setNumUnitsPerSegment( initialUnitsPerSegment );
@@ -310,8 +310,8 @@ void QgsComposerScaleBar::applyDefaultSize( QgsComposerScaleBar::ScaleBarUnits u
310310

311311
double segmentWidth = initialUnitsPerSegment / upperMagnitudeMultiplier;
312312
int segmentMagnitude = floor( log10( segmentWidth ) );
313-
double unitsPerSegment = upperMagnitudeMultiplier * ( pow( 10, segmentMagnitude ) );
314-
double multiplier = floor(( widthInSelectedUnits / ( unitsPerSegment * 10 ) ) / 2.5 ) * 2.5;
313+
double unitsPerSegment = upperMagnitudeMultiplier * ( pow( 10.0, segmentMagnitude ) );
314+
double multiplier = floor(( widthInSelectedUnits / ( unitsPerSegment * 10.0 ) ) / 2.5 ) * 2.5;
315315

316316
if ( multiplier > 0 )
317317
{

src/core/composer/qgscomposition.h

+9-7
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
154154
void setAlignmentSnap( bool s ) { mAlignmentSnap = s; }
155155
bool alignmentSnap() const { return mAlignmentSnap; }
156156

157-
void setSmartGuidesEnabled( bool b ) { mSmartGuides = b; };
157+
void setSmartGuidesEnabled( bool b ) { mSmartGuides = b; }
158158
bool smartGuidesEnabled() const {return mSmartGuides;}
159159

160160
/**Removes all snap lines*/
@@ -337,10 +337,12 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
337337
QPointF snapPointToGrid( const QPointF& scenePoint ) const;
338338

339339
/**Returns pointer to snap lines collection*/
340-
QList< QGraphicsLineItem* >* snapLines() {return &mSnapLines;};
340+
QList< QGraphicsLineItem* >* snapLines() {return &mSnapLines;}
341341

342-
/**Returns pointer to selection handles*/
343-
QgsComposerMouseHandles* selectionHandles() {return mSelectionHandles;};
342+
/**Returns pointer to selection handles
343+
* @note not available in python bindings
344+
*/
345+
QgsComposerMouseHandles* selectionHandles() {return mSelectionHandles;}
344346

345347
/**Add a custom snap line (can be horizontal or vertical)*/
346348
QGraphicsLineItem* addSnapLine();
@@ -397,8 +399,8 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
397399

398400
/**If true, prevents any mouse cursor changes by the composition or by any composer items
399401
Used by QgsComposer and QgsComposerView to prevent unwanted cursor changes*/
400-
void setPreventCursorChange( bool preventChange ) { mPreventCursorChange = preventChange; };
401-
bool preventCursorChange() { return mPreventCursorChange; };
402+
void setPreventCursorChange( bool preventChange ) { mPreventCursorChange = preventChange; }
403+
bool preventCursorChange() { return mPreventCursorChange; }
402404

403405
//printing
404406

@@ -426,7 +428,7 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
426428
/** Compute world file parameters */
427429
void computeWorldFileParameters( double& a, double& b, double& c, double& d, double& e, double& f ) const;
428430

429-
QgsAtlasComposition& atlasComposition() { return mAtlasComposition; };
431+
QgsAtlasComposition& atlasComposition() { return mAtlasComposition; }
430432

431433
/**Resizes a QRectF relative to the change from boundsBefore to boundsAfter*/
432434
static void relativeResizeRect( QRectF& rectToResize, const QRectF& boundsBefore, const QRectF& boundsAfter );

0 commit comments

Comments
 (0)