Skip to content

Commit 0575c71

Browse files
committed
Merge pull request #1320 from manisandro/minmax
min-max map unit scale support
2 parents 620220d + 53ac675 commit 0575c71

File tree

63 files changed

+3003
-1319
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3003
-1319
lines changed

python/core/core.sip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
%Include qgsmaprendererjob.sip
5353
%Include qgsmapsettings.sip
5454
%Include qgsmaptopixel.sip
55+
%Include qgsmapunitscale.sip
5556
%Include qgsmessagelog.sip
5657
%Include qgsmessageoutput.sip
5758
%Include qgsmimedatautils.sip
@@ -217,3 +218,5 @@
217218
%Include symbology-ng/qgssymbologyv2conversion.sip
218219

219220
%Include dxf/qgsdxfexport.sip
221+
222+

python/core/qgsmapunitscale.sip

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*!
2+
* \class QgsMapUnitScale
3+
* \brief Struct for storing maximum and minimum scales for measurements in map units
4+
*
5+
* For measurements in map units, a minimum and a maximum scale can be defined.
6+
* Outside this range, the measurements aren't scaled anymore proportionally to
7+
* the map scale.
8+
*/
9+
10+
class QgsMapUnitScale
11+
{
12+
%TypeHeaderCode
13+
#include <qgsmapunitscale.h>
14+
%End
15+
public:
16+
QgsMapUnitScale();
17+
18+
/** The minimum scale, or 0.0 if unset */
19+
double minScale;
20+
/** The maximum scale, or 0.0 if unset */
21+
double maxScale;
22+
23+
double computeMapUnitsPerPixel(const QgsRenderContext& c) const;
24+
};
25+
26+
27+

python/core/symbology-ng/qgsellipsesymbollayerv2.sip

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,27 @@ class QgsEllipseSymbolLayerV2 : QgsMarkerSymbolLayerV2
4646

4747
void setSymbolWidthUnit( QgsSymbolV2::OutputUnit unit );
4848
QgsSymbolV2::OutputUnit symbolWidthUnit() const;
49+
50+
void setSymbolWidthMapUnitScale( const QgsMapUnitScale& scale);
51+
const QgsMapUnitScale& symbolWidthMapUnitScale() const;
4952

5053
void setSymbolHeightUnit( QgsSymbolV2::OutputUnit unit );
5154
QgsSymbolV2::OutputUnit symbolHeightUnit() const;
55+
56+
void setSymbolHeightMapUnitScale( const QgsMapUnitScale& scale);
57+
const QgsMapUnitScale& symbolHeightMapUnitScale() const;
5258

5359
void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
5460
QgsSymbolV2::OutputUnit outlineWidthUnit() const;
61+
62+
void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale);
63+
const QgsMapUnitScale& outlineWidthMapUnitScale() const;
5564

5665
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
5766
QgsSymbolV2::OutputUnit outputUnit() const;
67+
68+
void setMapUnitScale( const QgsMapUnitScale& scale);
69+
QgsMapUnitScale mapUnitScale() const;
5870
};
71+
72+

python/core/symbology-ng/qgsfillsymbollayerv2.sip

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,21 @@ class QgsSimpleFillSymbolLayerV2 : QgsFillSymbolLayerV2
7070

7171
void setBorderWidthUnit( QgsSymbolV2::OutputUnit unit );
7272
QgsSymbolV2::OutputUnit borderWidthUnit() const;
73+
74+
void setBorderWidthMapUnitScale( const QgsMapUnitScale& scale);
75+
const QgsMapUnitScale& borderWidthMapUnitScale() const;
7376

7477
void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
7578
QgsSymbolV2::OutputUnit offsetUnit() const;
79+
80+
void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
81+
const QgsMapUnitScale& offsetMapUnitScale() const;
7682

7783
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
7884
QgsSymbolV2::OutputUnit outputUnit() const;
85+
86+
void setMapUnitScale(const QgsMapUnitScale &scale);
87+
QgsMapUnitScale mapUnitScale() const;
7988

8089
double estimateMaxBleed() const;
8190

@@ -199,6 +208,15 @@ class QgsGradientFillSymbolLayerV2 : QgsFillSymbolLayerV2
199208
/**Units for gradient fill offset*/
200209
void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
201210
QgsSymbolV2::OutputUnit offsetUnit() const;
211+
212+
void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
213+
const QgsMapUnitScale& offsetMapUnitScale() const;
214+
215+
void setOutputUnit(QgsSymbolV2::OutputUnit unit);
216+
QgsSymbolV2::OutputUnit outputUnit() const;
217+
218+
void setMapUnitScale(const QgsMapUnitScale &scale);
219+
QgsMapUnitScale mapUnitScale() const;
202220

203221
};
204222

@@ -400,6 +418,9 @@ class QgsShapeburstFillSymbolLayerV2 : QgsFillSymbolLayerV2
400418
* @see setOffsetUnit
401419
*/
402420
QgsSymbolV2::OutputUnit offsetUnit() const;
421+
422+
void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
423+
const QgsMapUnitScale& offsetMapUnitScale() const;
403424

404425
};
405426

@@ -420,6 +441,15 @@ class QgsImageFillSymbolLayer: QgsFillSymbolLayerV2
420441

421442
void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
422443
QgsSymbolV2::OutputUnit outlineWidthUnit() const;
444+
445+
void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale);
446+
const QgsMapUnitScale& outlineWidthMapUnitScale() const;
447+
448+
void setOutputUnit(QgsSymbolV2::OutputUnit unit);
449+
QgsSymbolV2::OutputUnit outputUnit() const;
450+
451+
void setMapUnitScale(const QgsMapUnitScale &scale);
452+
QgsMapUnitScale mapUnitScale() const;
423453

424454
virtual double estimateMaxBleed() const;
425455

@@ -472,9 +502,15 @@ class QgsSVGFillSymbolLayer: QgsImageFillSymbolLayer
472502

473503
void setPatternWidthUnit( QgsSymbolV2::OutputUnit unit );
474504
QgsSymbolV2::OutputUnit patternWidthUnit() const;
505+
506+
void setPatternWidthMapUnitScale( const QgsMapUnitScale& scale);
507+
const QgsMapUnitScale& patternWidthMapUnitScale() const;
475508

476509
void setSvgOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
477510
QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const;
511+
512+
void setSvgOutlineWidthMapUnitScale( const QgsMapUnitScale& scale);
513+
const QgsMapUnitScale& svgOutlineWidthMapUnitScale() const;
478514

479515
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
480516
QgsSymbolV2::OutputUnit outputUnit() const;
@@ -525,15 +561,27 @@ class QgsLinePatternFillSymbolLayer: QgsImageFillSymbolLayer
525561

526562
void setDistanceUnit( QgsSymbolV2::OutputUnit unit );
527563
QgsSymbolV2::OutputUnit distanceUnit() const;
564+
565+
void setDistanceMapUnitScale( const QgsMapUnitScale& scale);
566+
const QgsMapUnitScale& distanceMapUnitScale() const;
528567

529568
void setLineWidthUnit( QgsSymbolV2::OutputUnit unit );
530569
QgsSymbolV2::OutputUnit lineWidthUnit() const;
570+
571+
void setLineWidthMapUnitScale( const QgsMapUnitScale& scale);
572+
const QgsMapUnitScale& lineWidthMapUnitScale() const;
531573

532574
void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
533575
QgsSymbolV2::OutputUnit offsetUnit() const;
576+
577+
void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
578+
const QgsMapUnitScale& offsetMapUnitScale() const;
534579

535580
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
536581
QgsSymbolV2::OutputUnit outputUnit() const;
582+
583+
void setMapUnitScale( const QgsMapUnitScale& scale);
584+
QgsMapUnitScale mapUnitScale() const;
537585

538586
bool setSubSymbol( QgsSymbolV2* symbol );
539587
QgsSymbolV2* subSymbol();
@@ -584,18 +632,33 @@ class QgsPointPatternFillSymbolLayer : QgsImageFillSymbolLayer
584632

585633
void setDistanceXUnit( QgsSymbolV2::OutputUnit unit );
586634
QgsSymbolV2::OutputUnit distanceXUnit() const;
635+
636+
void setDistanceXMapUnitScale( const QgsMapUnitScale& scale);
637+
const QgsMapUnitScale& distanceXMapUnitScale() const;
587638

588639
void setDistanceYUnit( QgsSymbolV2::OutputUnit unit );
589640
QgsSymbolV2::OutputUnit distanceYUnit() const;
641+
642+
void setDistanceYMapUnitScale( const QgsMapUnitScale& scale);
643+
const QgsMapUnitScale& distanceYMapUnitScale() const;
590644

591645
void setDisplacementXUnit( QgsSymbolV2::OutputUnit unit );
592646
QgsSymbolV2::OutputUnit displacementXUnit() const;
647+
648+
void setDisplacementXMapUnitScale( const QgsMapUnitScale& scale);
649+
const QgsMapUnitScale& displacementXMapUnitScale() const;
593650

594651
void setDisplacementYUnit( QgsSymbolV2::OutputUnit unit );
595652
QgsSymbolV2::OutputUnit displacementYUnit() const;
653+
654+
void setDisplacementYMapUnitScale( const QgsMapUnitScale& scale);
655+
const QgsMapUnitScale& displacementYMapUnitScale() const;
596656

597657
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
598658
QgsSymbolV2::OutputUnit outputUnit() const;
659+
660+
void setMapUnitScale(const QgsMapUnitScale &scale);
661+
QgsMapUnitScale mapUnitScale() const;
599662

600663
virtual QSet<QString> usedAttributes() const;
601664

@@ -641,6 +704,11 @@ class QgsCentroidFillSymbolLayerV2 : QgsFillSymbolLayerV2
641704

642705
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
643706
QgsSymbolV2::OutputUnit outputUnit() const;
707+
708+
void setMapUnitScale(const QgsMapUnitScale &scale);
709+
QgsMapUnitScale mapUnitScale() const;
644710

645711
virtual QSet<QString> usedAttributes() const;
646712
};
713+
714+

python/core/symbology-ng/qgslinesymbollayerv2.sip

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class QgsSimpleLineSymbolLayerV2 : QgsLineSymbolLayerV2
3434

3535
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
3636
QgsSymbolV2::OutputUnit outputUnit() const;
37+
38+
void setMapUnitScale(const QgsMapUnitScale &scale);
39+
QgsMapUnitScale mapUnitScale() const;
3740

3841
double estimateMaxBleed() const;
3942

@@ -51,14 +54,20 @@ class QgsSimpleLineSymbolLayerV2 : QgsLineSymbolLayerV2
5154
double offset() const;
5255
void setOffset( double offset );
5356

54-
QgsSymbolV2::OutputUnit offsetUnit() const;
5557
void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
58+
QgsSymbolV2::OutputUnit offsetUnit() const;
59+
60+
void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
61+
const QgsMapUnitScale& offsetMapUnitScale() const;
5662

5763
bool useCustomDashPattern() const;
5864
void setUseCustomDashPattern( bool b );
5965

6066
QgsSymbolV2::OutputUnit customDashPatternUnit() const;
6167
void setCustomDashPatternUnit( QgsSymbolV2::OutputUnit unit );
68+
69+
const QgsMapUnitScale& customDashPatternMapUnitScale() const;
70+
void setCustomDashPatternMapUnitScale( const QgsMapUnitScale& scale);
6271

6372
QVector<qreal> customDashVector() const;
6473
void setCustomDashVector( const QVector<qreal>& vector );
@@ -180,15 +189,34 @@ class QgsMarkerLineSymbolLayerV2 : QgsLineSymbolLayerV2
180189
* @see setOffsetAlongLine
181190
*/
182191
void setOffsetAlongLineUnit( QgsSymbolV2::OutputUnit unit );
192+
193+
/**Returns the map unit scale used for calculating the offset in map units along line for markers.
194+
* @returns Offset along line map unit scale.
195+
*/
196+
const QgsMapUnitScale& offsetAlongLineMapUnitScale() const;
197+
198+
/**Sets the map unit scale used for calculating the offset in map units along line for markers.
199+
* @param scale Offset along line map unit scale.
200+
*/
201+
void setOffsetAlongLineMapUnitScale(const QgsMapUnitScale& scale);
183202

184203
QgsSymbolV2::OutputUnit intervalUnit() const;
185204
void setIntervalUnit( QgsSymbolV2::OutputUnit unit );
205+
206+
void setIntervalMapUnitScale( const QgsMapUnitScale& scale);
207+
const QgsMapUnitScale& intervalMapUnitScale() const;
186208

187209
QgsSymbolV2::OutputUnit offsetUnit() const;
188210
void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
211+
212+
void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
213+
const QgsMapUnitScale& offsetMapUnitScale() const;
189214

190215
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
191216
QgsSymbolV2::OutputUnit outputUnit() const;
217+
218+
void setMapUnitScale( const QgsMapUnitScale& scale);
219+
QgsMapUnitScale mapUnitScale() const;
192220

193221
protected:
194222

@@ -197,3 +225,5 @@ class QgsMarkerLineSymbolLayerV2 : QgsLineSymbolLayerV2
197225
void renderPolylineCentral( const QPolygonF& points, QgsSymbolV2RenderContext& context );
198226
double markerAngle( const QPolygonF& points, bool isRing, int vertex );
199227
};
228+
229+

python/core/symbology-ng/qgsmarkersymbollayerv2.sip

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class QgsSimpleMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
6363

6464
QgsSymbolV2::OutputUnit outlineWidthUnit() const;
6565
void setOutlineWidthUnit( QgsSymbolV2::OutputUnit u );
66+
67+
void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale);
68+
const QgsMapUnitScale& outlineWidthMapUnitScale() const;
6669

6770
bool writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f, const QPointF& shift = QPointF( 0.0, 0.0 ) ) const;
6871

@@ -124,6 +127,9 @@ class QgsSvgMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
124127

125128
void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
126129
QgsSymbolV2::OutputUnit outlineWidthUnit() const;
130+
131+
void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale);
132+
const QgsMapUnitScale& outlineWidthMapUnitScale() const;
127133

128134
void setOutputUnit( QgsSymbolV2::OutputUnit unit );
129135
QgsSymbolV2::OutputUnit outputUnit() const;
@@ -173,3 +179,5 @@ class QgsFontMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
173179
QChar character() const;
174180
void setCharacter( QChar ch );
175181
};
182+
183+

python/core/symbology-ng/qgssymbollayerv2.sip

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ class QgsSymbolLayerV2
110110

111111
virtual void setOutputUnit( QgsSymbolV2::OutputUnit unit );
112112
virtual QgsSymbolV2::OutputUnit outputUnit() const;
113+
114+
virtual void setMapUnitScale( const QgsMapUnitScale& mapUnitScale );
115+
virtual QgsMapUnitScale mapUnitScale() const;
113116

114117
// used only with rending with symbol levels is turned on (0 = first pass, 1 = second, ...)
115118
void setRenderingPass( int renderingPass );
@@ -197,12 +200,21 @@ class QgsMarkerSymbolLayerV2 : QgsSymbolLayerV2
197200

198201
void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
199202
QgsSymbolV2::OutputUnit offsetUnit() const;
203+
204+
void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
205+
const QgsMapUnitScale& offsetMapUnitScale() const;
200206

201207
void setSizeUnit( QgsSymbolV2::OutputUnit unit );
202208
QgsSymbolV2::OutputUnit sizeUnit() const;
209+
210+
void setSizeMapUnitScale( const QgsMapUnitScale& scale);
211+
const QgsMapUnitScale& sizeMapUnitScale() const;
203212

204213
virtual void setOutputUnit( QgsSymbolV2::OutputUnit unit );
205214
virtual QgsSymbolV2::OutputUnit outputUnit() const;
215+
216+
void setMapUnitScale( const QgsMapUnitScale& scale);
217+
QgsMapUnitScale mapUnitScale() const;
206218

207219
void setHorizontalAnchorPoint( HorizontalAnchorPoint h );
208220
HorizontalAnchorPoint horizontalAnchorPoint() const;
@@ -219,7 +231,8 @@ class QgsMarkerSymbolLayerV2 : QgsSymbolLayerV2
219231
//! @note available in python bindings as markerOffset2
220232
void markerOffset( const QgsSymbolV2RenderContext& context, double width, double height,
221233
QgsSymbolV2::OutputUnit widthUnit, QgsSymbolV2::OutputUnit heightUnit,
222-
double& offsetX, double& offsetY ) const /PyName=markerOffset2/;
234+
double& offsetX, double& offsetY,
235+
const QgsMapUnitScale& widthMapUnitScale, const QgsMapUnitScale& heightMapUnitScale ) const /PyName=markerOffset2/;
223236

224237
static QPointF _rotatedOffset( const QPointF& offset, double angle );
225238
};
@@ -241,6 +254,9 @@ class QgsLineSymbolLayerV2 : QgsSymbolLayerV2
241254

242255
void setWidthUnit( QgsSymbolV2::OutputUnit unit );
243256
QgsSymbolV2::OutputUnit widthUnit() const;
257+
258+
void setWidthMapUnitScale( const QgsMapUnitScale& scale);
259+
const QgsMapUnitScale& widthMapUnitScale() const;
244260

245261
void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
246262

@@ -269,3 +285,5 @@ class QgsFillSymbolLayerV2 : QgsSymbolLayerV2
269285
/**Default method to render polygon*/
270286
void _renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
271287
};
288+
289+

0 commit comments

Comments
 (0)