27 #include <QDomDocument>
28 #include <QDomElement>
46 const double rotation =
mRotation.data() ?
mRotation->evaluate( feature ).toDouble() : 0;
74 mSymbol->startRender( context, &fields );
109 mSymbol->stopRender( context );
121 QSet<QString> attributes;
122 if (
mSymbol.data() ) attributes.unite(
mSymbol->usedAttributes() );
125 return attributes.toList();
167 return mSymbol.data() ? QString(
"SINGLE: %1" ).arg(
mSymbol->dump() ) :
"" ;
185 props[
"angle" ] =
mRotation->expression();
189 QDomElement ruleElem = doc.createElement(
"se:Rule" );
190 element.appendChild( ruleElem );
192 QDomElement nameElem = doc.createElement(
"se:Name" );
193 nameElem.appendChild( doc.createTextNode(
"Single symbol" ) );
194 ruleElem.appendChild( nameElem );
208 QDomElement symbolsElem = element.firstChildElement(
"symbols" );
209 if ( symbolsElem.isNull() )
214 if ( !symbolMap.contains(
"0" ) )
222 QDomElement rotationElem = element.firstChildElement(
"rotation" );
223 if ( !rotationElem.isNull() )
226 QDomElement sizeScaleElem = element.firstChildElement(
"sizescale" );
227 if ( !sizeScaleElem.isNull() )
242 QDomElement ruleElem = element.firstChildElement(
"Rule" );
243 if ( ruleElem.isNull() )
249 QString label, description;
253 QDomElement childElem = ruleElem.firstChildElement();
254 while ( !childElem.isNull() )
256 if ( childElem.localName() ==
"Name" )
260 if ( label.isEmpty() )
261 label = childElem.firstChild().nodeValue();
263 else if ( childElem.localName() ==
"Description" )
266 QDomElement titleElem = childElem.firstChildElement(
"Title" );
267 if ( !titleElem.isNull() )
269 label = titleElem.firstChild().nodeValue();
272 QDomElement abstractElem = childElem.firstChildElement(
"Abstract" );
273 if ( !abstractElem.isNull() )
275 description = abstractElem.firstChild().nodeValue();
278 else if ( childElem.localName() ==
"Abstract" )
281 description = childElem.firstChild().nodeValue();
283 else if ( childElem.localName() ==
"Title" )
286 label = childElem.firstChild().nodeValue();
288 else if ( childElem.localName().endsWith(
"Symbolizer" ) )
294 childElem = childElem.nextSiblingElement();
297 if ( layers.size() == 0 )
317 QgsDebugMsg( QString(
"invalid geometry type: found %1" ).arg( geomType ) );
328 rendererElem.setAttribute(
"type",
"singleSymbol" );
334 rendererElem.appendChild( symbolsElem );
336 QDomElement rotationElem = doc.createElement(
"rotation" );
339 rendererElem.appendChild( rotationElem );
341 QDomElement sizeScaleElem = doc.createElement(
"sizescale" );
345 rendererElem.appendChild( sizeScaleElem );
356 lst << qMakePair( QString(), pix );
363 Q_UNUSED( scaleDenominator );
366 lst << qMakePair( QString(),
mSymbol.data() );
QMap< QString, QgsSymbolV2 * > QgsSymbolV2Map
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
static QgsSymbolV2Map loadSymbols(QDomElement &element)
#define RENDERER_TAG_NAME
QgsSymbolV2 * symbol() const
QList< QgsSymbolV2 * > QgsSymbolV2List
virtual ~QgsSingleSymbolRendererV2()
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
void setSizeScaleField(QString fieldOrExpression)
static QgsFeatureRendererV2 * createFromSld(QDomElement &element, QGis::GeometryType geomType)
QString rotationField() const
QgsSymbolV2::ScaleMethod scaleMethod() const
Container of fields for a vector layer.
QScopedPointer< QgsSymbolV2 > mSymbol
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual void stopRender(QgsRenderContext &context)
QMap< QString, QString > QgsStringMap
QgsSymbolV2::ScaleMethod mScaleMethod
void setWidth(double width)
void setAngle(double angle)
virtual void toSld(QDomDocument &doc, QDomElement &element) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
static bool createSymbolLayerV2ListFromSld(QDomElement &element, QGis::GeometryType geomType, QgsSymbolLayerV2List &layers)
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, QString rule=QString())
return a list of item text / symbol
#define DEFAULT_SCALE_METHOD
void setRotationField(QString fieldOrExpression)
static QDomElement saveSymbols(QgsSymbolV2Map &symbols, QString tagName, QDomDocument &doc)
QgsSingleSymbolRendererV2(QgsSymbolV2 *symbol)
void setAngle(double angle)
void setSize(double size)
QScopedPointer< QgsExpression > mSizeScale
virtual QString dump() const
for debugging
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
virtual QgsFeatureRendererV2 * clone()
void setUsingSymbolLevels(bool usingSymbolLevels)
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
QString sizeScaleField() const
Contains information about the context of a rendering operation.
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize)
return a list of symbology items for the legend
static QgsExpression * fieldOrExpressionToExpression(const QString &fieldOrExpression)
Return a new valid expression instance for given field or expression string.
QList< QgsSymbolLayerV2 * > QgsSymbolLayerV2List
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)
virtual QgsSymbolV2List symbols()
for symbol levels
static QPixmap symbolPreviewPixmap(QgsSymbolV2 *symbol, QSize size)
static void clearSymbolMap(QgsSymbolV2Map &symbols)
void setSymbol(QgsSymbolV2 *s)
static QgsSymbolV2::ScaleMethod decodeScaleMethod(QString str)
static QgsFeatureRendererV2 * create(QDomElement &element)
create renderer from XML element
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
to be overridden
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
QScopedPointer< QgsSymbolV2 > mTempSymbol
virtual QList< QString > usedAttributes()
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
QScopedPointer< QgsExpression > mRotation