Skip to content
Permalink
Browse files

[FEATURE] Raster image symbol fill type

Allows for filling polygons with a tiled raster image. Options
include (data defined) file name, opacity, image size (in pixels,
mm or map units), coordinate mode (feature or view) and rotation.
  • Loading branch information
nyalldawson committed Nov 17, 2014
1 parent 66ffb2a commit 52159851bf1d0a5dd2152244e2d9336f391dec90
@@ -461,6 +461,175 @@ class QgsImageFillSymbolLayer: QgsFillSymbolLayerV2
virtual Qt::PenStyle dxfPenStyle() const;
};

/** \ingroup core
* \class QgsRasterFillSymbolLayer
* \brief A class for filling symbols with a repeated raster image.
* \note Added in version 2.7
*/
class QgsRasterFillSymbolLayer: QgsImageFillSymbolLayer
{
%TypeHeaderCode
#include <qgsfillsymbollayerv2.h>
%End
public:

enum FillCoordinateMode
{
Feature,
Viewport
};

QgsRasterFillSymbolLayer( const QString& imageFilePath = QString() );
~QgsRasterFillSymbolLayer();

static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );

// implemented from base classes
QString layerType() const;
void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
void startRender( QgsSymbolV2RenderContext& context );
void stopRender( QgsSymbolV2RenderContext& context );
QgsStringMap properties() const;
QgsSymbolLayerV2* clone() const;
virtual double estimateMaxBleed() const;

//override QgsImageFillSymbolLayer's support for sub symbols
virtual QgsSymbolV2* subSymbol();
virtual bool setSubSymbol( QgsSymbolV2* symbol );

/**Sets the path to the raster image used for the fill.
* @param imagePath path to image file
* @see imageFilePath
*/
void setImageFilePath( const QString& imagePath );
/**The path to the raster image used for the fill.
* @returns path to image file
* @see setImageFilePath
*/
QString imageFilePath() const;

/**Set the coordinate mode for fill. Controls how the top left corner of the image
* fill is positioned relative to the feature.
* @param mode coordinate mode
* @see coordinateMode
*/
void setCoordinateMode( const FillCoordinateMode mode );
/**Coordinate mode for fill. Controls how the top left corner of the image
* fill is positioned relative to the feature.
* @returns coordinate mode
* @see setCoordinateMode
*/
FillCoordinateMode coordinateMode() const;

/**Sets the opacity for the raster image used in the fill.
* @param alpha opacity value between 0 (fully transparent) and 1 (fully opaque)
* @see alpha
*/
void setAlpha( const double alpha );
/**The opacity for the raster image used in the fill.
* @returns opacity value between 0 (fully transparent) and 1 (fully opaque)
* @see setAlpha
*/
double alpha() const;

/**Sets the offset for the fill.
* @param offset offset for fill
* @see offset
* @see setOffsetUnit
* @see setOffsetMapUnitScale
*/
void setOffset( const QPointF& offset );
/**Returns the offset for the fill.
* @returns offset for fill
* @see setOffset
* @see offsetUnit
* @see offsetMapUnitScale
*/
QPointF offset() const;

/**Sets the units for the fill's offset.
* @param unit units for offset
* @see offsetUnit
* @see setOffset
* @see setOffsetMapUnitScale
*/
void setOffsetUnit( const QgsSymbolV2::OutputUnit unit );
/**Returns the units for the fill's offset.
* @returns units for offset
* @see setOffsetUnit
* @see offset
* @see offsetMapUnitScale
*/
QgsSymbolV2::OutputUnit offsetUnit() const;

/**Sets the map unit scale for the fill's offset.
* @param scale map unit scale for offset
* @see offsetMapUnitScale
* @see setOffset
* @see setOffsetUnit
*/
void setOffsetMapUnitScale( const QgsMapUnitScale& scale );
/**Returns the map unit scale for the fill's offset.
* @returns map unit scale for offset
* @see setOffsetMapUnitScale
* @see offset
* @see offsetUnit
*/
const QgsMapUnitScale& offsetMapUnitScale() const;

/**Sets the width for scaling the image used in the fill. The image's height will also be
* scaled to maintain the image's aspect ratio.
* @param width width for scaling the image
* @see width
* @see setWidthUnit
* @see setWidthMapUnitScale
*/
void setWidth( const double width );
/**Returns the width used for scaling the image used in the fill. The image's height is
* scaled to maintain the image's aspect ratio.
* @returns width used for scaling the image
* @see setWidth
* @see widthUnit
* @see widthMapUnitScale
*/
double width() const;

/**Sets the units for the image's width.
* @param unit units for width
* @see widthUnit
* @see setWidth
* @see setWidthMapUnitScale
*/
void setWidthUnit( const QgsSymbolV2::OutputUnit unit );
/**Returns the units for the image's width.
* @returns units for width
* @see setWidthUnit
* @see width
* @see widthMapUnitScale
*/
QgsSymbolV2::OutputUnit widthUnit() const;

/**Sets the map unit scale for the image's width.
* @param scale map unit scale for width
* @see widthMapUnitScale
* @see setWidth
* @see setWidthUnit
*/
void setWidthMapUnitScale( const QgsMapUnitScale& scale );
/**Returns the map unit scale for the image's width.
* @returns map unit scale for width
* @see setWidthMapUnitScale
* @see width
* @see widthUnit
*/
const QgsMapUnitScale& widthMapUnitScale() const;

protected:

void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context );

};

/**A class for svg fill patterns. The class automatically scales the pattern to
the appropriate pixel dimensions of the output device*/
class QgsSVGFillSymbolLayer: QgsImageFillSymbolLayer
@@ -23,7 +23,8 @@ class QgsSymbolV2
{
MM,
MapUnit,
Mixed //mixed units in symbol layers
Mixed, //mixed units in symbol layers
Pixel
};

enum SymbolType

0 comments on commit 5215985

Please sign in to comment.
You can’t perform that action at this time.