This commit is contained in:
Nyall Dawson 2018-10-15 11:15:00 +10:00
parent f07462b69a
commit a1a35e91cc
2 changed files with 250 additions and 40 deletions

View File

@ -1308,6 +1308,9 @@ Returns the map unit scale for the pattern's stroke.
class QgsLinePatternFillSymbolLayer: QgsImageFillSymbolLayer
{
%Docstring
A symbol fill consisting of repeated parallel lines.
%End
%TypeHeaderCode
#include "qgsfillsymbollayer.h"
@ -1317,33 +1320,51 @@ class QgsLinePatternFillSymbolLayer: QgsImageFillSymbolLayer
~QgsLinePatternFillSymbolLayer();
static QgsSymbolLayer *create( const QgsStringMap &properties = QgsStringMap() ) /Factory/;
%Docstring
Creates a new QgsLinePatternFillSymbolLayer from a ``properties`` map. The caller takes
ownership of the returned object.
%End
static QgsSymbolLayer *createFromSld( QDomElement &element ) /Factory/;
%Docstring
Creates a new QgsLinePatternFillSymbolLayer from a SLD ``element``. The caller takes
ownership of the returned object.
%End
virtual QString layerType() const;
virtual void startRender( QgsSymbolRenderContext &context );
virtual void stopRender( QgsSymbolRenderContext &context );
virtual QgsStringMap properties() const;
virtual QgsLinePatternFillSymbolLayer *clone() const /Factory/;
virtual void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props ) const;
virtual double estimateMaxBleed( const QgsRenderContext &context ) const;
QString ogrFeatureStyleWidth( double widthScaleFactor ) const;
void setLineAngle( double a );
%Docstring
Sets the angle for the parallel lines used to fill the symbol.
Angles are in degrees, clockwise from North.
.. seealso:: :py:func:`lineAngle`
%End
double lineAngle() const;
%Docstring
Returns the angle for the parallel lines used to fill the symbol.
Angles are in degrees, clockwise from North.
.. seealso:: :py:func:`setLineAngle`
%End
void setDistance( double d );
%Docstring
@ -1366,19 +1387,59 @@ Returns the distance between lines in the fill pattern. Units are retrieved by d
%End
void setLineWidth( double w );
%Docstring
Sets the width of the line subsymbol used to render the parallel lines
in the fill.
.. seealso:: :py:func:`lineWidth`
%End
double lineWidth() const;
%Docstring
Returns the width of the line subsymbol used to render the parallel lines
in the fill.
.. seealso:: :py:func:`setLineWidth`
%End
virtual void setColor( const QColor &c );
virtual QColor color() const;
void setOffset( double offset );
%Docstring
Sets the ``offset`` distance for lines within the fill, which is
the distance to offset the parallel lines from their normal
position.
Units are specified via setOffsetUnit().
.. seealso:: :py:func:`offset`
.. seealso:: :py:func:`setOffsetUnit`
.. seealso:: :py:func:`setOffsetMapUnitScale`
%End
double offset() const;
%Docstring
Returns the offset distance for lines within the fill, which is
the distance to offset the parallel lines from their normal
position.
Units are retrieved via offsetUnit().
.. seealso:: :py:func:`setOffset`
.. seealso:: :py:func:`offsetUnit`
.. seealso:: :py:func:`offsetMapUnitScale`
%End
void setDistanceUnit( QgsUnitTypes::RenderUnit unit );
%Docstring
Sets the units for the distance between lines in the fill pattern.
:param unit: distance units
Sets the ``unit`` for the distance between lines in the fill pattern.
.. seealso:: :py:func:`distanceUnit`
@ -1395,13 +1456,30 @@ Returns the units for the distance between lines in the fill pattern.
%End
void setDistanceMapUnitScale( const QgsMapUnitScale &scale );
%Docstring
Sets the map unit ``scale`` for the pattern's line distance.
.. seealso:: :py:func:`distanceMapUnitScale`
.. seealso:: :py:func:`setDistance`
.. seealso:: :py:func:`setDistanceUnit`
%End
const QgsMapUnitScale &distanceMapUnitScale() const;
%Docstring
Returns the map unit scale for the pattern's line distance.
.. seealso:: :py:func:`setDistanceMapUnitScale`
.. seealso:: :py:func:`distance`
.. seealso:: :py:func:`distanceUnit`
%End
void setLineWidthUnit( QgsUnitTypes::RenderUnit unit );
%Docstring
Sets the units for the line's width.
:param unit: width units
Sets the ``unit`` for the line's width.
.. seealso:: :py:func:`lineWidthUnit`
%End
@ -1414,13 +1492,30 @@ Returns the units for the line's width.
%End
void setLineWidthMapUnitScale( const QgsMapUnitScale &scale );
%Docstring
Sets the map unit ``scale`` for the pattern's line width.
.. seealso:: :py:func:`lineWidthMapUnitScale`
.. seealso:: :py:func:`setLineWidth`
.. seealso:: :py:func:`setLineWidthUnit`
%End
const QgsMapUnitScale &lineWidthMapUnitScale() const;
%Docstring
Returns the map unit scale for the pattern's line width.
.. seealso:: :py:func:`setLineWidthMapUnitScale`
.. seealso:: :py:func:`lineWidth`
.. seealso:: :py:func:`lineWidthUnit`
%End
void setOffsetUnit( QgsUnitTypes::RenderUnit unit );
%Docstring
Sets the units for the line pattern's offset.
:param unit: offset units
Sets the ``unit`` for the line pattern's offset.
.. seealso:: :py:func:`offsetUnit`
%End
@ -1433,23 +1528,39 @@ Returns the units for the line pattern's offset.
%End
void setOffsetMapUnitScale( const QgsMapUnitScale &scale );
%Docstring
Sets the map unit ``scale`` for the pattern's line offset.
.. seealso:: :py:func:`offsetMapUnitScale`
.. seealso:: :py:func:`setOffset`
.. seealso:: :py:func:`setOffsetUnit`
%End
const QgsMapUnitScale &offsetMapUnitScale() const;
%Docstring
Returns the map unit scale for the pattern's line offset.
.. seealso:: :py:func:`setOffsetMapUnitScale`
.. seealso:: :py:func:`offset`
.. seealso:: :py:func:`offsetUnit`
%End
virtual void setOutputUnit( QgsUnitTypes::RenderUnit unit );
virtual QgsUnitTypes::RenderUnit outputUnit() const;
virtual void setMapUnitScale( const QgsMapUnitScale &scale );
virtual QgsMapUnitScale mapUnitScale() const;
virtual bool setSubSymbol( QgsSymbol *symbol /Transfer/ );
virtual QgsSymbol *subSymbol();
virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;
@ -1457,9 +1568,6 @@ Returns the units for the line pattern's offset.
virtual void applyDataDefinedSettings( QgsSymbolRenderContext &context );
%Docstring
Offset perpendicular to line direction
%End
private:
QgsLinePatternFillSymbolLayer( const QgsLinePatternFillSymbolLayer &other );

View File

@ -1193,6 +1193,7 @@ class CORE_EXPORT QgsSVGFillSymbolLayer: public QgsImageFillSymbolLayer
/**
* \ingroup core
* \class QgsLinePatternFillSymbolLayer
* A symbol fill consisting of repeated parallel lines.
*/
class CORE_EXPORT QgsLinePatternFillSymbolLayer: public QgsImageFillSymbolLayer
{
@ -1200,27 +1201,44 @@ class CORE_EXPORT QgsLinePatternFillSymbolLayer: public QgsImageFillSymbolLayer
QgsLinePatternFillSymbolLayer();
~QgsLinePatternFillSymbolLayer() override;
/**
* Creates a new QgsLinePatternFillSymbolLayer from a \a properties map. The caller takes
* ownership of the returned object.
*/
static QgsSymbolLayer *create( const QgsStringMap &properties = QgsStringMap() ) SIP_FACTORY;
/**
* Creates a new QgsLinePatternFillSymbolLayer from a SLD \a element. The caller takes
* ownership of the returned object.
*/
static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
QString layerType() const override;
void startRender( QgsSymbolRenderContext &context ) override;
void stopRender( QgsSymbolRenderContext &context ) override;
QgsStringMap properties() const override;
QgsLinePatternFillSymbolLayer *clone() const override SIP_FACTORY;
void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props ) const override;
double estimateMaxBleed( const QgsRenderContext &context ) const override;
QString ogrFeatureStyleWidth( double widthScaleFactor ) const;
//getters and setters
/**
* Sets the angle for the parallel lines used to fill the symbol.
*
* Angles are in degrees, clockwise from North.
*
* \see lineAngle()
*/
void setLineAngle( double a ) { mLineAngle = a; }
/**
* Returns the angle for the parallel lines used to fill the symbol.
*
* Angles are in degrees, clockwise from North.
*
* \see setLineAngle()
*/
double lineAngle() const { return mLineAngle; }
/**
@ -1238,16 +1256,54 @@ class CORE_EXPORT QgsLinePatternFillSymbolLayer: public QgsImageFillSymbolLayer
*/
double distance() const { return mDistance; }
/**
* Sets the width of the line subsymbol used to render the parallel lines
* in the fill.
*
* \see lineWidth()
*/
void setLineWidth( double w );
/**
* Returns the width of the line subsymbol used to render the parallel lines
* in the fill.
*
* \see setLineWidth()
*/
double lineWidth() const { return mLineWidth; }
void setColor( const QColor &c ) override;
QColor color() const override;
/**
* Sets the \a offset distance for lines within the fill, which is
* the distance to offset the parallel lines from their normal
* position.
*
* Units are specified via setOffsetUnit().
*
* \see offset()
* \see setOffsetUnit()
* \see setOffsetMapUnitScale()
*/
void setOffset( double offset ) { mOffset = offset; }
/**
* Returns the offset distance for lines within the fill, which is
* the distance to offset the parallel lines from their normal
* position.
*
* Units are retrieved via offsetUnit().
*
* \see setOffset()
* \see offsetUnit()
* \see offsetMapUnitScale()
*/
double offset() const { return mOffset; }
/**
* Sets the units for the distance between lines in the fill pattern.
* \param unit distance units
* Sets the \a unit for the distance between lines in the fill pattern.
*
* \see distanceUnit()
* \see setDistance()
*/
@ -1255,58 +1311,107 @@ class CORE_EXPORT QgsLinePatternFillSymbolLayer: public QgsImageFillSymbolLayer
/**
* Returns the units for the distance between lines in the fill pattern.
*
* \see setDistanceUnit()
* \see distance()
*/
QgsUnitTypes::RenderUnit distanceUnit() const { return mDistanceUnit; }
/**
* Sets the map unit \a scale for the pattern's line distance.
*
* \see distanceMapUnitScale()
* \see setDistance()
* \see setDistanceUnit()
*/
void setDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mDistanceMapUnitScale = scale; }
/**
* Returns the map unit scale for the pattern's line distance.
*
* \see setDistanceMapUnitScale()
* \see distance()
* \see distanceUnit()
*/
const QgsMapUnitScale &distanceMapUnitScale() const { return mDistanceMapUnitScale; }
/**
* Sets the units for the line's width.
* \param unit width units
* Sets the \a unit for the line's width.
*
* \see lineWidthUnit()
*/
void setLineWidthUnit( QgsUnitTypes::RenderUnit unit ) { mLineWidthUnit = unit; }
/**
* Returns the units for the line's width.
*
* \see setLineWidthUnit()
*/
QgsUnitTypes::RenderUnit lineWidthUnit() const { return mLineWidthUnit; }
/**
* Sets the map unit \a scale for the pattern's line width.
*
* \see lineWidthMapUnitScale()
* \see setLineWidth()
* \see setLineWidthUnit()
*/
void setLineWidthMapUnitScale( const QgsMapUnitScale &scale ) { mLineWidthMapUnitScale = scale; }
/**
* Returns the map unit scale for the pattern's line width.
*
* \see setLineWidthMapUnitScale()
* \see lineWidth()
* \see lineWidthUnit()
*/
const QgsMapUnitScale &lineWidthMapUnitScale() const { return mLineWidthMapUnitScale; }
/**
* Sets the units for the line pattern's offset.
* \param unit offset units
* Sets the \a unit for the line pattern's offset.
* \see offsetUnit()
*/
void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
/**
* Returns the units for the line pattern's offset.
*
* \see setOffsetUnit()
*/
QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
/**
* Sets the map unit \a scale for the pattern's line offset.
*
* \see offsetMapUnitScale()
* \see setOffset()
* \see setOffsetUnit()
*/
void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
/**
* Returns the map unit scale for the pattern's line offset.
*
* \see setOffsetMapUnitScale()
* \see offset()
* \see offsetUnit()
*/
const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
QgsUnitTypes::RenderUnit outputUnit() const override;
void setMapUnitScale( const QgsMapUnitScale &scale ) override;
QgsMapUnitScale mapUnitScale() const override;
bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
QgsSymbol *subSymbol() override;
QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
protected:
void applyDataDefinedSettings( QgsSymbolRenderContext &context ) override;
private:
//! Distance (in mm or map units) between lines
double mDistance = 5.0;
QgsUnitTypes::RenderUnit mDistanceUnit = QgsUnitTypes::RenderMillimeters;
@ -1322,9 +1427,6 @@ class CORE_EXPORT QgsLinePatternFillSymbolLayer: public QgsImageFillSymbolLayer
QgsUnitTypes::RenderUnit mOffsetUnit = QgsUnitTypes::RenderMillimeters;
QgsMapUnitScale mOffsetMapUnitScale;
void applyDataDefinedSettings( QgsSymbolRenderContext &context ) override;
private:
#ifdef SIP_RUN
QgsLinePatternFillSymbolLayer( const QgsLinePatternFillSymbolLayer &other );
#endif