29 #include <QDomDocument> 30 #include <QDomElement> 49 const double rotation =
mRotation.data() ?
mRotation->evaluate( feature ).toDouble() : 0;
83 mSymbol->startRender( context, &fields );
118 mSymbol->stopRender( context );
130 QSet<QString> attributes;
131 if (
mSymbol.data() ) attributes.unite(
mSymbol->usedAttributes() );
134 return attributes.toList();
176 return mSymbol.data() ? QString(
"SINGLE: %1" ).arg(
mSymbol->dump() ) :
"";
194 props[
"angle" ] =
mRotation->expression();
198 QDomElement ruleElem = doc.createElement(
"se:Rule" );
199 element.appendChild( ruleElem );
201 QDomElement nameElem = doc.createElement(
"se:Name" );
202 nameElem.appendChild( doc.createTextNode(
"Single symbol" ) );
203 ruleElem.appendChild( nameElem );
217 QDomElement symbolsElem = element.firstChildElement(
"symbols" );
218 if ( symbolsElem.isNull() )
223 if ( !symbolMap.contains(
"0" ) )
231 QDomElement rotationElem = element.firstChildElement(
"rotation" );
232 if ( !rotationElem.isNull() )
235 QDomElement sizeScaleElem = element.firstChildElement(
"sizescale" );
236 if ( !sizeScaleElem.isNull() )
251 QDomElement ruleElem = element.firstChildElement(
"Rule" );
252 if ( ruleElem.isNull() )
258 QString label, description;
262 QDomElement childElem = ruleElem.firstChildElement();
263 while ( !childElem.isNull() )
265 if ( childElem.localName() ==
"Name" )
269 if ( label.isEmpty() )
270 label = childElem.firstChild().nodeValue();
272 else if ( childElem.localName() ==
"Description" )
275 QDomElement titleElem = childElem.firstChildElement(
"Title" );
276 if ( !titleElem.isNull() )
278 label = titleElem.firstChild().nodeValue();
281 QDomElement abstractElem = childElem.firstChildElement(
"Abstract" );
282 if ( !abstractElem.isNull() )
284 description = abstractElem.firstChild().nodeValue();
287 else if ( childElem.localName() ==
"Abstract" )
290 description = childElem.firstChild().nodeValue();
292 else if ( childElem.localName() ==
"Title" )
295 label = childElem.firstChild().nodeValue();
297 else if ( childElem.localName().endsWith(
"Symbolizer" ) )
303 childElem = childElem.nextSiblingElement();
306 if ( layers.size() == 0 )
326 QgsDebugMsg( QString(
"invalid geometry type: found %1" ).arg( geomType ) );
337 rendererElem.setAttribute(
"type",
"singleSymbol" );
343 rendererElem.appendChild( symbolsElem );
345 QDomElement rotationElem = doc.createElement(
"rotation" );
348 rendererElem.appendChild( rotationElem );
350 QDomElement sizeScaleElem = doc.createElement(
"sizescale" );
354 rendererElem.appendChild( sizeScaleElem );
365 lst << qMakePair( QString(), pix );
372 Q_UNUSED( scaleDenominator );
375 lst << qMakePair( QString(),
mSymbol.data() );
388 if ( renderer->
type() ==
"singleSymbol" )
392 if ( renderer->
type() ==
"pointDisplacement" )
395 if ( pointDisplacementRenderer )
398 if ( renderer->
type() ==
"invertedPolygonRenderer" )
401 if ( invertedPolygonRenderer )
406 if ( symbols.size() > 0 )
QMap< QString, QgsSymbolV2 * > QgsSymbolV2Map
static QgsSymbolV2Map loadSymbols(QDomElement &element)
#define RENDERER_TAG_NAME
QgsSymbolV2 * symbol() const
QList< QgsSymbolV2 * > QgsSymbolV2List
virtual QDomElement save(QDomDocument &doc) override
store renderer info to XML element
virtual ~QgsSingleSymbolRendererV2()
virtual void stopRender(QgsRenderContext &context) override
virtual QgsSymbolV2List symbols() override
for symbol levels
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature) override
to be overridden
virtual QgsSymbolV2 * originalSymbolForFeature(QgsFeature &feature) override
Return symbol for feature.
void setSizeScaleField(QString fieldOrExpression)
static QgsFeatureRendererV2 * createFromSld(QDomElement &element, QGis::GeometryType geomType)
QgsSymbolV2::ScaleMethod scaleMethod() const
Container of fields for a vector layer.
static QgsSingleSymbolRendererV2 * convertFromRenderer(const QgsFeatureRendererV2 *renderer)
creates a QgsSingleSymbolRendererV2 from an existing renderer.
QScopedPointer< QgsSymbolV2 > mSymbol
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual QgsFeatureRendererV2 * clone() const override
QMap< QString, QString > QgsStringMap
QgsSymbolV2::ScaleMethod mScaleMethod
void setWidth(double width)
virtual void toSld(QDomDocument &doc, QDomElement &element) const override
used from subclasses to create SLD Rule elements following SLD v1.1 specs
void setAngle(double angle)
static bool createSymbolLayerV2ListFromSld(QDomElement &element, QGis::GeometryType geomType, QgsSymbolLayerV2List &layers)
virtual QgsFeatureRendererV2 * clone() const =0
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted...
#define DEFAULT_SCALE_METHOD
static QDomElement saveSymbols(QgsSymbolV2Map &symbols, QString tagName, QDomDocument &doc)
QgsSingleSymbolRendererV2(QgsSymbolV2 *symbol)
void setAngle(double angle)
virtual QList< QString > usedAttributes() override
void setSize(double size)
QScopedPointer< QgsExpression > mSizeScale
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
QgsFeatureRendererV2 * embeddedRenderer() const
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize) override
return a list of symbology items for the legend
virtual QString dump() const override
for debugging
A renderer that automatically displaces points with the same position.
void setUsingSymbolLevels(bool usingSymbolLevels)
QString rotationField() const override
return rotation field name (or empty string if not set or not supported by renderer) ...
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
QString sizeScaleField() const
Contains information about the context of a rendering operation.
const QgsFeatureRendererV2 * embeddedRenderer() const
static QgsExpression * fieldOrExpressionToExpression(const QString &fieldOrExpression)
Return a new valid expression instance for given field or expression string.
QList< QgsSymbolLayerV2 * > QgsSymbolLayerV2List
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, QString rule=QString()) override
return a list of item text / symbol
static QString encodeScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
static QString fieldOrExpressionFromExpression(QgsExpression *expression)
Return a field name if the whole expression is just a name of the field .
bool usingSymbolLevels() const
void setScaleMethodToSymbol(QgsSymbolV2 *symbol, int scaleMethod)
static void clearSymbolMap(QgsSymbolV2Map &symbols)
void setSymbol(QgsSymbolV2 *s)
static QgsSymbolV2::ScaleMethod decodeScaleMethod(QString str)
QList< QgsLegendSymbolItemV2 > QgsLegendSymbolListV2
static QgsFeatureRendererV2 * create(QDomElement &element)
create renderer from XML element
static QPixmap symbolPreviewPixmap(QgsSymbolV2 *symbol, QSize size, QgsRenderContext *customContext=0)
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
virtual void startRender(QgsRenderContext &context, const QgsFields &fields) override
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
QScopedPointer< QgsSymbolV2 > mTempSymbol
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
void setRotationField(QString fieldOrExpression) override
sets rotation field of renderer (if supported by the renderer)
QScopedPointer< QgsExpression > mRotation
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const override
Return a list of symbology items for the legend.