/usr/include/qgis/qgssymbollayerv2.h is in libqgis-dev 2.8.6+dfsg-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | /***************************************************************************
qgssymbollayerv2.h
---------------------
begin : November 2009
copyright : (C) 2009 by Martin Dobias
email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSSYMBOLLAYERV2_H
#define QGSSYMBOLLAYERV2_H
// MSVC compiler doesn't have defined M_PI in math.h
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define DEG2RAD(x) ((x)*M_PI/180)
#define DEFAULT_SCALE_METHOD QgsSymbolV2::ScaleArea
#include <QColor>
#include <QMap>
#include <QPointF>
#include <QSet>
#include <QDomDocument>
#include <QDomElement>
#include "qgssymbolv2.h"
#include "qgssymbollayerv2utils.h" // QgsStringMap
class QPainter;
class QSize;
class QPolygonF;
class QgsDxfExport;
class QgsExpression;
class QgsRenderContext;
class CORE_EXPORT QgsSymbolLayerV2
{
public:
// not necessarily supported by all symbol layers...
virtual QColor color() const { return mColor; }
virtual void setColor( const QColor& color ) { mColor = color; }
/** Set outline color. Supported by marker and fill layers.
* @note added in 2.1 */
virtual void setOutlineColor( const QColor& color ) { Q_UNUSED( color ); }
/** Get outline color. Supported by marker and fill layers.
* @note added in 2.1 */
virtual QColor outlineColor() const { return QColor(); }
/** Set fill color. Supported by marker and fill layers.
* @note added in 2.1 */
virtual void setFillColor( const QColor& color ) { Q_UNUSED( color ); }
/** Get fill color. Supported by marker and fill layers.
* @note added in 2.1 */
virtual QColor fillColor() const { return QColor(); }
virtual ~QgsSymbolLayerV2() { removeDataDefinedProperties(); }
virtual QString layerType() const = 0;
virtual void startRender( QgsSymbolV2RenderContext& context ) = 0;
virtual void stopRender( QgsSymbolV2RenderContext& context ) = 0;
virtual QgsSymbolLayerV2* clone() const = 0;
virtual void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
{ Q_UNUSED( props ); element.appendChild( doc.createComment( QString( "SymbolLayerV2 %1 not implemented yet" ).arg( layerType() ) ) ); }
virtual QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const { Q_UNUSED( mmScaleFactor ); Q_UNUSED( mapUnitScaleFactor ); return QString(); }
virtual QgsStringMap properties() const = 0;
virtual void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ) = 0;
virtual QgsSymbolV2* subSymbol() { return NULL; }
// set layer's subsymbol. takes ownership of the passed symbol
virtual bool setSubSymbol( QgsSymbolV2* symbol ) { delete symbol; return false; }
QgsSymbolV2::SymbolType type() const { return mType; }
void setLocked( bool locked ) { mLocked = locked; }
bool isLocked() const { return mLocked; }
/**Returns the estimated maximum distance which the layer style will bleed outside
the drawn shape. Eg, polygons drawn with an outline will draw half the width
of the outline outside of the polygon. This amount is estimated, since it may
be affected by data defined symbology rules.*/
virtual double estimateMaxBleed() const { return 0; }
virtual void setOutputUnit( QgsSymbolV2::OutputUnit unit ) { Q_UNUSED( unit ); } //= 0;
virtual QgsSymbolV2::OutputUnit outputUnit() const { return QgsSymbolV2::Mixed; } //= 0;
virtual void setMapUnitScale( const QgsMapUnitScale& scale ) { Q_UNUSED( scale ); } //= 0;
virtual QgsMapUnitScale mapUnitScale() const { return QgsMapUnitScale(); } //= 0;
// used only with rending with symbol levels is turned on (0 = first pass, 1 = second, ...)
void setRenderingPass( int renderingPass ) { mRenderingPass = renderingPass; }
int renderingPass() const { return mRenderingPass; }
// symbol layers normally only use additional attributes to provide data defined settings
virtual QSet<QString> usedAttributes() const;
virtual const QgsExpression* dataDefinedProperty( const QString& property ) const;
virtual QString dataDefinedPropertyString( const QString& property ) const;
virtual void setDataDefinedProperty( const QString& property, const QString& expressionString );
virtual void removeDataDefinedProperty( const QString& property );
virtual void removeDataDefinedProperties();
bool hasDataDefinedProperties() const { return mDataDefinedProperties.size() > 0; }
virtual bool writeDxf( QgsDxfExport& e,
double mmMapUnitScaleFactor,
const QString& layerName,
const QgsSymbolV2RenderContext* context,
const QgsFeature* f,
const QPointF& shift = QPointF( 0.0, 0.0 ) ) const;
virtual double dxfWidth( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const;
virtual double dxfOffset( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const;
virtual QColor dxfColor( const QgsSymbolV2RenderContext& context ) const;
virtual QVector<qreal> dxfCustomDashPattern( QgsSymbolV2::OutputUnit& unit ) const;
virtual Qt::PenStyle dxfPenStyle() const;
virtual QColor dxfBrushColor( const QgsSymbolV2RenderContext& context ) const;
virtual Qt::BrushStyle dxfBrushStyle() const;
protected:
QgsSymbolLayerV2( QgsSymbolV2::SymbolType type, bool locked = false )
: mType( type ), mLocked( locked ), mRenderingPass( 0 ) {}
QgsSymbolV2::SymbolType mType;
bool mLocked;
QColor mColor;
int mRenderingPass;
QMap< QString, QgsExpression* > mDataDefinedProperties;
// Configuration of selected symbology implementation
static const bool selectionIsOpaque = true; // Selection ignores symbol alpha
static const bool selectFillBorder = false; // Fill symbol layer also selects border symbology
static const bool selectFillStyle = false; // Fill symbol uses symbol layer style..
virtual void prepareExpressions( const QgsFields* fields, double scale = -1.0 );
virtual QgsExpression* expression( const QString& property ) const;
/**Saves data defined properties to string map*/
void saveDataDefinedProperties( QgsStringMap& stringMap ) const;
/**Copies data defined properties of this layer to another symbol layer*/
void copyDataDefinedProperties( QgsSymbolLayerV2* destLayer ) const;
};
//////////////////////
class CORE_EXPORT QgsMarkerSymbolLayerV2 : public QgsSymbolLayerV2
{
public:
enum HorizontalAnchorPoint
{
Left,
HCenter,
Right
};
enum VerticalAnchorPoint
{
Top,
VCenter,
Bottom
};
void startRender( QgsSymbolV2RenderContext& context ) override;
virtual void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ) = 0;
void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ) override;
void setAngle( double angle ) { mAngle = angle; }
double angle() const { return mAngle; }
void setSize( double size ) { mSize = size; }
double size() const { return mSize; }
void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod ) { mScaleMethod = scaleMethod; }
QgsSymbolV2::ScaleMethod scaleMethod() const { return mScaleMethod; }
void setOffset( QPointF offset ) { mOffset = offset; }
QPointF offset() { return mOffset; }
virtual void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const override;
virtual void writeSldMarker( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
{ Q_UNUSED( props ); element.appendChild( doc.createComment( QString( "QgsMarkerSymbolLayerV2 %1 not implemented yet" ).arg( layerType() ) ) ); }
void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
void setSizeUnit( QgsSymbolV2::OutputUnit unit ) { mSizeUnit = unit; }
QgsSymbolV2::OutputUnit sizeUnit() const { return mSizeUnit; }
void setSizeMapUnitScale( const QgsMapUnitScale& scale ) { mSizeMapUnitScale = scale; }
const QgsMapUnitScale& sizeMapUnitScale() const { return mSizeMapUnitScale; }
void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
QgsSymbolV2::OutputUnit outputUnit() const override;
void setMapUnitScale( const QgsMapUnitScale& scale ) override;
QgsMapUnitScale mapUnitScale() const override;
void setHorizontalAnchorPoint( HorizontalAnchorPoint h ) { mHorizontalAnchorPoint = h; }
HorizontalAnchorPoint horizontalAnchorPoint() const { return mHorizontalAnchorPoint; }
void setVerticalAnchorPoint( VerticalAnchorPoint v ) { mVerticalAnchorPoint = v; }
VerticalAnchorPoint verticalAnchorPoint() const { return mVerticalAnchorPoint; }
protected:
QgsMarkerSymbolLayerV2( bool locked = false );
//handles marker offset and anchor point shift together
void markerOffset( const QgsSymbolV2RenderContext& context, double& offsetX, double& offsetY ) const;
void markerOffset( const QgsSymbolV2RenderContext& context, double width, double height, double& offsetX, double& offsetY ) const;
//! @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 QgsMapUnitScale &widthMapUnitScale, const QgsMapUnitScale &heightMapUnitScale ) const;
static QPointF _rotatedOffset( const QPointF& offset, double angle );
double mAngle;
double mSize;
QgsSymbolV2::OutputUnit mSizeUnit;
QgsMapUnitScale mSizeMapUnitScale;
QPointF mOffset;
QgsSymbolV2::OutputUnit mOffsetUnit;
QgsMapUnitScale mOffsetMapUnitScale;
QgsSymbolV2::ScaleMethod mScaleMethod;
HorizontalAnchorPoint mHorizontalAnchorPoint;
VerticalAnchorPoint mVerticalAnchorPoint;
private:
static QgsMarkerSymbolLayerV2::HorizontalAnchorPoint decodeHorizontalAnchorPoint( const QString& str );
static QgsMarkerSymbolLayerV2::VerticalAnchorPoint decodeVerticalAnchorPoint( const QString& str );
QgsExpression* mOffsetExpression;
QgsExpression* mHorizontalAnchorExpression;
QgsExpression* mVerticalAnchorExpression;
};
class CORE_EXPORT QgsLineSymbolLayerV2 : public QgsSymbolLayerV2
{
public:
virtual void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ) = 0;
virtual void renderPolygonOutline( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
virtual void setWidth( double width ) { mWidth = width; }
virtual double width() const { return mWidth; }
double offset() const { return mOffset; }
void setOffset( double offset ) { mOffset = offset; }
void setWidthUnit( QgsSymbolV2::OutputUnit unit ) { mWidthUnit = unit; }
QgsSymbolV2::OutputUnit widthUnit() const { return mWidthUnit; }
void setWidthMapUnitScale( const QgsMapUnitScale& scale ) { mWidthMapUnitScale = scale; }
const QgsMapUnitScale& widthMapUnitScale() const { return mWidthMapUnitScale; }
void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
QgsSymbolV2::OutputUnit outputUnit() const override;
void setMapUnitScale( const QgsMapUnitScale& scale ) override;
QgsMapUnitScale mapUnitScale() const override;
void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ) override;
virtual double dxfWidth( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const override;
protected:
QgsLineSymbolLayerV2( bool locked = false );
double mWidth;
QgsSymbolV2::OutputUnit mWidthUnit;
QgsMapUnitScale mWidthMapUnitScale;
double mOffset;
QgsSymbolV2::OutputUnit mOffsetUnit;
QgsMapUnitScale mOffsetMapUnitScale;
};
class CORE_EXPORT QgsFillSymbolLayerV2 : public QgsSymbolLayerV2
{
public:
virtual void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) = 0;
void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ) override;
void setAngle( double angle ) { mAngle = angle; }
double angle() const { return mAngle; }
protected:
QgsFillSymbolLayerV2( bool locked = false );
/**Default method to render polygon*/
void _renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
double mAngle;
};
class QgsSymbolLayerV2Widget; // why does SIP fail, when this isn't here
#endif
|