26 #include <QDomDocument>
27 #include <QDomElement>
31 mSizeScaleFieldIdx( -1 ), mTempSymbol( NULL )
142 QSet<QString> attributes;
155 return attributes.toList();
180 return QString(
"SINGLE: %1" ).arg(
mSymbol->
dump() );
202 props[
"angle" ] = QString(
mRotationField ).append(
"\"" ).prepend(
"\"" );
204 props[
"scale" ] = QString(
mSizeScaleField ).append(
"\"" ).prepend(
"\"" );
206 QDomElement ruleElem = doc.createElement(
"se:Rule" );
207 element.appendChild( ruleElem );
209 QDomElement nameElem = doc.createElement(
"se:Name" );
210 nameElem.appendChild( doc.createTextNode(
"Single symbol" ) );
211 ruleElem.appendChild( nameElem );
225 QDomElement symbolsElem = element.firstChildElement(
"symbols" );
226 if ( symbolsElem.isNull() )
231 if ( !symbolMap.contains(
"0" ) )
239 QDomElement rotationElem = element.firstChildElement(
"rotation" );
240 if ( !rotationElem.isNull() )
243 QDomElement sizeScaleElem = element.firstChildElement(
"sizescale" );
244 if ( !sizeScaleElem.isNull() )
259 QDomElement ruleElem = element.firstChildElement(
"Rule" );
260 if ( ruleElem.isNull() )
266 QString label, description;
270 QDomElement childElem = ruleElem.firstChildElement();
271 while ( !childElem.isNull() )
273 if ( childElem.localName() ==
"Name" )
277 if ( label.isEmpty() )
278 label = childElem.firstChild().nodeValue();
280 else if ( childElem.localName() ==
"Description" )
283 QDomElement titleElem = childElem.firstChildElement(
"Title" );
284 if ( !titleElem.isNull() )
286 label = titleElem.firstChild().nodeValue();
289 QDomElement abstractElem = childElem.firstChildElement(
"Abstract" );
290 if ( !abstractElem.isNull() )
292 description = abstractElem.firstChild().nodeValue();
295 else if ( childElem.localName() ==
"Abstract" )
298 description = childElem.firstChild().nodeValue();
300 else if ( childElem.localName() ==
"Title" )
303 label = childElem.firstChild().nodeValue();
305 else if ( childElem.localName().endsWith(
"Symbolizer" ) )
311 childElem = childElem.nextSiblingElement();
314 if ( layers.size() == 0 )
334 QgsDebugMsg( QString(
"invalid geometry type: found %1" ).arg( geomType ) );
345 rendererElem.setAttribute(
"type",
"singleSymbol" );
351 rendererElem.appendChild( symbolsElem );
353 QDomElement rotationElem = doc.createElement(
"rotation" );
355 rendererElem.appendChild( rotationElem );
357 QDomElement sizeScaleElem = doc.createElement(
"sizescale" );
360 rendererElem.appendChild( sizeScaleElem );
371 lst << qMakePair( QString(), pix );
379 lst << qMakePair( QString(),
mSymbol );
QMap< QString, QgsSymbolV2 * > QgsSymbolV2Map
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
QSet< QString > usedAttributes() const
virtual QgsSymbolV2 * clone() const =0
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
static QgsFeatureRendererV2 * createFromSld(QDomElement &element, QGis::GeometryType geomType)
virtual void startRender(QgsRenderContext &context, const QgsVectorLayer *vlayer)
QString rotationField() const
QgsSymbolV2::ScaleMethod scaleMethod() const
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
void setRotationField(QString fieldName)
static bool createSymbolLayerV2ListFromSld(QDomElement &element, QGis::GeometryType geomType, QgsSymbolLayerV2List &layers)
void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
#define DEFAULT_SCALE_METHOD
static QDomElement saveSymbols(QgsSymbolV2Map &symbols, QString tagName, QDomDocument &doc)
QgsSingleSymbolRendererV2(QgsSymbolV2 *symbol)
void setAngle(double angle)
void setSize(double size)
virtual QgsLegendSymbolList legendSymbolItems()
return a list of item text / symbol
virtual QString dump() const
for debugging
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
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
void stopRender(QgsRenderContext &context)
QList< QgsSymbolLayerV2 * > QgsSymbolLayerV2List
static QString encodeScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
bool usingSymbolLevels() const
void setScaleMethodToSymbol(QgsSymbolV2 *symbol, int scaleMethod)
void startRender(QgsRenderContext &context, const QgsVectorLayer *layer=0)
virtual QgsSymbolV2List symbols()
for symbol levels
static QPixmap symbolPreviewPixmap(QgsSymbolV2 *symbol, QSize size)
void setRenderHints(int hints)
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
Represents a vector layer which manages a vector based data sets.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
virtual QList< QString > usedAttributes()
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
QgsSymbolV2 * mTempSymbol
void setSizeScaleField(QString fieldName)