39 #include <QDomElement> 40 #include <QDomDocument> 69 ms->
setScaleMethod( static_cast< QgsSymbolV2::ScaleMethod >( scaleMethod ) );
178 return "UNKNOWN RENDERER\n";
220 if ( !effectElem.
isNull() )
260 if ( userStyleElem.
isNull() )
263 errorMessage =
"Info: UserStyle element not found.";
269 if ( featTypeStyleElem.
isNull() )
271 errorMessage =
"Info: FeatureTypeStyle element not found.";
278 bool needRuleRenderer =
false;
282 while ( !ruleElem.
isNull() )
289 QgsDebugMsg(
"more Rule elements found: need a RuleRenderer" );
290 needRuleRenderer =
true;
295 while ( !ruleChildElem.
isNull() )
298 if ( ruleChildElem.
localName() ==
"Filter" ||
299 ruleChildElem.
localName() ==
"MinScaleDenominator" ||
300 ruleChildElem.
localName() ==
"MaxScaleDenominator" )
302 QgsDebugMsg(
"Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" );
303 needRuleRenderer =
true;
310 if ( needRuleRenderer )
319 if ( needRuleRenderer )
321 rendererType =
"RuleRenderer";
325 rendererType =
"singleSymbol";
333 errorMessage =
QString(
"Error: Unable to get metadata for '%1' renderer." ).
arg( rendererType );
356 toSld( doc, featureTypeStyleElem, props );
359 return userStyleElem;
364 Q_UNUSED( iconSize );
394 Q_UNUSED( scaleDenominator );
449 Q_FOREACH (
const QPolygonF& ring, *rings )
static QgsConstWkbPtr _getPolygon(QPolygonF &pts, QList< QPolygonF > &holes, QgsRenderContext &context, QgsConstWkbPtr &wkb, bool clipToExtent=true)
Creates a polygon in screen coordinates from a wkb string in map coordinates.
static QgsRendererV2Registry * instance()
Returns a pointer to the QgsRendererV2Registry singleton.
#define RENDERER_TAG_NAME
virtual QSet< QString > legendKeysForFeature(QgsFeature &feature, QgsRenderContext &context)
Return legend keys matching a specified feature.
double angle() const
Returns the marker angle for the whole symbol.
void setEnabled(const bool enabled)
Sets whether the effect is enabled.
void setDataDefinedAngle(const QgsDataDefined &dd)
Set data defined angle for whole symbol (including all symbol layers).
A container class for data source field mapping or expression.
QgsFeatureRendererV2(const QString &type)
QDomNode appendChild(const QDomNode &newChild)
static QgsFeatureRendererV2 * loadSld(const QDomNode &node, QGis::GeometryType geomType, QString &errorMessage)
Create a new renderer according to the information contained in the UserStyle element of a SLD style ...
Q_DECL_DEPRECATED void copyPaintEffect(QgsFeatureRendererV2 *destRenderer) const
Copies paint effect of this renderer to another renderer.
QString attribute(const QString &name, const QString &defValue) const
void setForceRasterRender(bool forceRaster)
Sets whether the renderer should be rendered to a raster destination.
void setDataDefinedSize(const QgsDataDefined &dd)
Set data defined size for whole symbol (including all symbol layers).
virtual Q_DECL_DEPRECATED QgsSymbolV2 * originalSymbolForFeature(QgsFeature &feature)
Return symbol for feature.
static QgsExpressionContext createFeatureBasedContext(const QgsFeature &feature, const QgsFields &fields)
Helper function for creating an expression context which contains just a feature and fields collectio...
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
Calculate scale by the diameter.
VertexMarkerType
Editing vertex markers.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
#define Q_NOWARN_DEPRECATED_PUSH
Base class for visual effects which can be applied to QPicture drawings.
QDomElement nextSiblingElement(const QString &tagName) const
static void _getPoint(QPointF &pt, QgsRenderContext &context, const QgsPointV2 *point)
Creates a point in screen coordinates from a QgsPointV2 in map coordinates.
void renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false, int currentVertexMarkerType=0, int currentVertexMarkerSize=0)
Render a feature.
Container of fields for a vector layer.
void CORE_EXPORT load(const QDomElement &elem)
Deserialize from XML.
virtual ~QgsFeatureRendererV2()
void renderVertexMarkerPolyline(QPolygonF &pts, QgsRenderContext &context)
render editing vertex marker for a polyline
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const
Return a list of symbology items for the legend.
double size() const
Returns the size for the whole symbol, which is the maximum size of all marker symbol layers in the s...
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual void toSld(QDomDocument &doc, QDomElement &element) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
virtual Q_DECL_DEPRECATED bool willRenderFeature(QgsFeature &feat)
Returns whether the renderer will render a feature or not.
virtual bool legendSymbolItemChecked(const QString &key)
items of symbology items in legend is checked
QgsRendererV2AbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
QgsPaintEffect * mPaintEffect
virtual void checkLegendSymbolItem(const QString &key, bool state=true)
item in symbology was checked
static QgsConstWkbPtr _getLineString(QPolygonF &pts, QgsRenderContext &context, QgsConstWkbPtr &wkb, bool clipToExtent=true)
Creates a line string in screen coordinates from a wkb string in map coordinates. ...
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize)
return a list of symbology items for the legend
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
QgsFields fields() const
Returns the list of fields of this layer.
void renderFeatureWithSymbol(QgsFeature &feature, QgsSymbolV2 *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker)
QDomElement toElement() const
void renderVertexMarker(QPointF pt, QgsRenderContext &context)
render editing vertex marker at specified point
virtual Q_DECL_DEPRECATED QgsSymbolV2List originalSymbolsForFeature(QgsFeature &feat)
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
virtual bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
Render a feature using this renderer in the given context.
QString number(int n, int base)
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden.
void append(const T &value)
QString localName() const
virtual QString dump() const
for debugging
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects. ...
static QgsPaintEffectRegistry * instance()
Returns a reference to the singleton instance of the paint effect registry.
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, const QString &rule="")
return a list of item text / symbol
int mCurrentVertexMarkerSize
The current size of editing marker.
void setAttribute(const QString &name, const QString &value)
void setOrderByEnabled(bool enabled)
Sets whether custom ordering should be applied before features are processed by this renderer...
int toInt(bool *ok, int base) const
int mCurrentVertexMarkerType
The current type of editing marker.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the renderer.
static QgsFeatureRendererV2 * defaultRenderer(QGis::GeometryType geomType)
return a new renderer - used by default in vector layers
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
static void drawVertexMarker(double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize)
Draws a vertex symbol at (screen) coordinates x, y.
static void convertSymbolSizeScale(QgsSymbolV2 *symbol, QgsSymbolV2::ScaleMethod method, const QString &field)
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
QDomText createTextNode(const QString &value)
virtual bool filterNeedsGeometry() const
Returns true if this renderer requires the geometry to apply the filter.
#define Q_NOWARN_DEPRECATED_POP
void setDataDefinedWidth(const QgsDataDefined &dd)
Set data defined width for whole symbol (including all symbol layers).
void setUsingSymbolLevels(bool usingSymbolLevels)
QgsFeatureRequest::OrderBy orderBy() const
Get the order in which features shall be processed by this renderer.
void copyRendererData(QgsFeatureRendererV2 *destRenderer) const
Clones generic renderer data to another renderer.
Contains information about the context of a rendering operation.
void setOrderBy(const QgsFeatureRequest::OrderBy &orderBy)
Define the order in which features shall be processed by this renderer.
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer...
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
Returns list of symbols used for rendering the feature.
static QgsFeatureRendererV2 * load(QDomElement &symbologyElem)
create a renderer from XML element
virtual Q_DECL_DEPRECATED QDomElement writeSld(QDomDocument &doc, const QgsVectorLayer &layer) const
create the SLD UserStyle element following the SLD v1.1 specs
QgsFeatureRequest::OrderBy mOrderBy
void setVertexMarkerAppearance(int type, int size)
set type and size of editing vertex markers for subsequent rendering
QDomElement firstChildElement(const QString &tagName) const
void setScaleMethodToSymbol(QgsSymbolV2 *symbol, int scaleMethod)
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
void renderVertexMarkerPolygon(QPolygonF &pts, QList< QPolygonF > *rings, QgsRenderContext &context)
render editing vertex marker for a polygon
static QgsConstWkbPtr _getPolygon(QPolygonF &pts, QList< QPolygonF > &holes, QgsRenderContext &context, QgsConstWkbPtr &wkb, bool clipToExtent=true)
Creates a polygon in screen coordinates from a wkb string in map coordinates.
QString name
Read property of QString layerName.
static QgsConstWkbPtr _getPoint(QPointF &pt, QgsRenderContext &context, QgsConstWkbPtr &wkb)
Creates a point in screen coordinates from a wkb string in map coordinates.
Calculate scale by the area.
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
QDomElement createElement(const QString &tagName)
Represents a vector layer which manages a vector based data sets.
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
virtual void setLegendSymbolItem(const QString &key, QgsSymbolV2 *symbol)
Sets the symbol to be used for a legend symbol item.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
Represents a list of OrderByClauses, with the most important first and the least important last...
static QgsConstWkbPtr _getLineString(QPolygonF &pts, QgsRenderContext &context, QgsConstWkbPtr &wkb, bool clipToExtent=true)
Creates a line string in screen coordinates from a wkb string in map coordinates. ...
static void convertSymbolRotation(QgsSymbolV2 *symbol, const QString &field)
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.