Skip to content

Commit

Permalink
min-max map unit scale support
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed May 7, 2014
1 parent 620220d commit 53ac675
Show file tree
Hide file tree
Showing 63 changed files with 3,003 additions and 1,319 deletions.
3 changes: 3 additions & 0 deletions python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
%Include qgsmaprendererjob.sip
%Include qgsmapsettings.sip
%Include qgsmaptopixel.sip
%Include qgsmapunitscale.sip
%Include qgsmessagelog.sip
%Include qgsmessageoutput.sip
%Include qgsmimedatautils.sip
Expand Down Expand Up @@ -217,3 +218,5 @@
%Include symbology-ng/qgssymbologyv2conversion.sip

%Include dxf/qgsdxfexport.sip


27 changes: 27 additions & 0 deletions python/core/qgsmapunitscale.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*!
* \class QgsMapUnitScale
* \brief Struct for storing maximum and minimum scales for measurements in map units
*
* For measurements in map units, a minimum and a maximum scale can be defined.
* Outside this range, the measurements aren't scaled anymore proportionally to
* the map scale.
*/

class QgsMapUnitScale
{
%TypeHeaderCode
#include <qgsmapunitscale.h>
%End
public:
QgsMapUnitScale();

/** The minimum scale, or 0.0 if unset */
double minScale;
/** The maximum scale, or 0.0 if unset */
double maxScale;

double computeMapUnitsPerPixel(const QgsRenderContext& c) const;
};



14 changes: 14 additions & 0 deletions python/core/symbology-ng/qgsellipsesymbollayerv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,27 @@ class QgsEllipseSymbolLayerV2 : QgsMarkerSymbolLayerV2

void setSymbolWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit symbolWidthUnit() const;

void setSymbolWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& symbolWidthMapUnitScale() const;

void setSymbolHeightUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit symbolHeightUnit() const;

void setSymbolHeightMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& symbolHeightMapUnitScale() const;

void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outlineWidthUnit() const;

void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& outlineWidthMapUnitScale() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

void setMapUnitScale( const QgsMapUnitScale& scale);
QgsMapUnitScale mapUnitScale() const;
};


68 changes: 68 additions & 0 deletions python/core/symbology-ng/qgsfillsymbollayerv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,21 @@ class QgsSimpleFillSymbolLayerV2 : QgsFillSymbolLayerV2

void setBorderWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit borderWidthUnit() const;

void setBorderWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& borderWidthMapUnitScale() const;

void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit offsetUnit() const;

void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& offsetMapUnitScale() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

void setMapUnitScale(const QgsMapUnitScale &scale);
QgsMapUnitScale mapUnitScale() const;

double estimateMaxBleed() const;

Expand Down Expand Up @@ -199,6 +208,15 @@ class QgsGradientFillSymbolLayerV2 : QgsFillSymbolLayerV2
/**Units for gradient fill offset*/
void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit offsetUnit() const;

void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& offsetMapUnitScale() const;

void setOutputUnit(QgsSymbolV2::OutputUnit unit);
QgsSymbolV2::OutputUnit outputUnit() const;

void setMapUnitScale(const QgsMapUnitScale &scale);
QgsMapUnitScale mapUnitScale() const;

};

Expand Down Expand Up @@ -400,6 +418,9 @@ class QgsShapeburstFillSymbolLayerV2 : QgsFillSymbolLayerV2
* @see setOffsetUnit
*/
QgsSymbolV2::OutputUnit offsetUnit() const;

void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& offsetMapUnitScale() const;

};

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

void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outlineWidthUnit() const;

void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& outlineWidthMapUnitScale() const;

void setOutputUnit(QgsSymbolV2::OutputUnit unit);
QgsSymbolV2::OutputUnit outputUnit() const;

void setMapUnitScale(const QgsMapUnitScale &scale);
QgsMapUnitScale mapUnitScale() const;

virtual double estimateMaxBleed() const;

Expand Down Expand Up @@ -472,9 +502,15 @@ class QgsSVGFillSymbolLayer: QgsImageFillSymbolLayer

void setPatternWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit patternWidthUnit() const;

void setPatternWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& patternWidthMapUnitScale() const;

void setSvgOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const;

void setSvgOutlineWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& svgOutlineWidthMapUnitScale() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;
Expand Down Expand Up @@ -525,15 +561,27 @@ class QgsLinePatternFillSymbolLayer: QgsImageFillSymbolLayer

void setDistanceUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit distanceUnit() const;

void setDistanceMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& distanceMapUnitScale() const;

void setLineWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit lineWidthUnit() const;

void setLineWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& lineWidthMapUnitScale() const;

void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit offsetUnit() const;

void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& offsetMapUnitScale() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

void setMapUnitScale( const QgsMapUnitScale& scale);
QgsMapUnitScale mapUnitScale() const;

bool setSubSymbol( QgsSymbolV2* symbol );
QgsSymbolV2* subSymbol();
Expand Down Expand Up @@ -584,18 +632,33 @@ class QgsPointPatternFillSymbolLayer : QgsImageFillSymbolLayer

void setDistanceXUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit distanceXUnit() const;

void setDistanceXMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& distanceXMapUnitScale() const;

void setDistanceYUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit distanceYUnit() const;

void setDistanceYMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& distanceYMapUnitScale() const;

void setDisplacementXUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit displacementXUnit() const;

void setDisplacementXMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& displacementXMapUnitScale() const;

void setDisplacementYUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit displacementYUnit() const;

void setDisplacementYMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& displacementYMapUnitScale() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

void setMapUnitScale(const QgsMapUnitScale &scale);
QgsMapUnitScale mapUnitScale() const;

virtual QSet<QString> usedAttributes() const;

Expand Down Expand Up @@ -641,6 +704,11 @@ class QgsCentroidFillSymbolLayerV2 : QgsFillSymbolLayerV2

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

void setMapUnitScale(const QgsMapUnitScale &scale);
QgsMapUnitScale mapUnitScale() const;

virtual QSet<QString> usedAttributes() const;
};


32 changes: 31 additions & 1 deletion python/core/symbology-ng/qgslinesymbollayerv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class QgsSimpleLineSymbolLayerV2 : QgsLineSymbolLayerV2

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

void setMapUnitScale(const QgsMapUnitScale &scale);
QgsMapUnitScale mapUnitScale() const;

double estimateMaxBleed() const;

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

QgsSymbolV2::OutputUnit offsetUnit() const;
void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit offsetUnit() const;

void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& offsetMapUnitScale() const;

bool useCustomDashPattern() const;
void setUseCustomDashPattern( bool b );

QgsSymbolV2::OutputUnit customDashPatternUnit() const;
void setCustomDashPatternUnit( QgsSymbolV2::OutputUnit unit );

const QgsMapUnitScale& customDashPatternMapUnitScale() const;
void setCustomDashPatternMapUnitScale( const QgsMapUnitScale& scale);

QVector<qreal> customDashVector() const;
void setCustomDashVector( const QVector<qreal>& vector );
Expand Down Expand Up @@ -180,15 +189,34 @@ class QgsMarkerLineSymbolLayerV2 : QgsLineSymbolLayerV2
* @see setOffsetAlongLine
*/
void setOffsetAlongLineUnit( QgsSymbolV2::OutputUnit unit );

/**Returns the map unit scale used for calculating the offset in map units along line for markers.
* @returns Offset along line map unit scale.
*/
const QgsMapUnitScale& offsetAlongLineMapUnitScale() const;

/**Sets the map unit scale used for calculating the offset in map units along line for markers.
* @param scale Offset along line map unit scale.
*/
void setOffsetAlongLineMapUnitScale(const QgsMapUnitScale& scale);

QgsSymbolV2::OutputUnit intervalUnit() const;
void setIntervalUnit( QgsSymbolV2::OutputUnit unit );

void setIntervalMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& intervalMapUnitScale() const;

QgsSymbolV2::OutputUnit offsetUnit() const;
void setOffsetUnit( QgsSymbolV2::OutputUnit unit );

void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& offsetMapUnitScale() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

void setMapUnitScale( const QgsMapUnitScale& scale);
QgsMapUnitScale mapUnitScale() const;

protected:

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


8 changes: 8 additions & 0 deletions python/core/symbology-ng/qgsmarkersymbollayerv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class QgsSimpleMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2

QgsSymbolV2::OutputUnit outlineWidthUnit() const;
void setOutlineWidthUnit( QgsSymbolV2::OutputUnit u );

void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& outlineWidthMapUnitScale() const;

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

Expand Down Expand Up @@ -124,6 +127,9 @@ class QgsSvgMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2

void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outlineWidthUnit() const;

void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& outlineWidthMapUnitScale() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;
Expand Down Expand Up @@ -173,3 +179,5 @@ class QgsFontMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
QChar character() const;
void setCharacter( QChar ch );
};


20 changes: 19 additions & 1 deletion python/core/symbology-ng/qgssymbollayerv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ class QgsSymbolLayerV2

virtual void setOutputUnit( QgsSymbolV2::OutputUnit unit );
virtual QgsSymbolV2::OutputUnit outputUnit() const;

virtual void setMapUnitScale( const QgsMapUnitScale& mapUnitScale );
virtual QgsMapUnitScale mapUnitScale() const;

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

void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit offsetUnit() const;

void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& offsetMapUnitScale() const;

void setSizeUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit sizeUnit() const;

void setSizeMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& sizeMapUnitScale() const;

virtual void setOutputUnit( QgsSymbolV2::OutputUnit unit );
virtual QgsSymbolV2::OutputUnit outputUnit() const;

void setMapUnitScale( const QgsMapUnitScale& scale);
QgsMapUnitScale mapUnitScale() const;

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

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

void setWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit widthUnit() const;

void setWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& widthMapUnitScale() const;

void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );

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


Loading

0 comments on commit 53ac675

Please sign in to comment.