QGIS API Documentation  3.0.2-Girona (307d082)
qgsrenderer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrenderer.cpp
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgsrenderer.h"
17 #include "qgssymbol.h"
18 #include "qgssymbollayerutils.h"
19 #include "qgsrulebasedrenderer.h"
20 
21 #include "qgssinglesymbolrenderer.h" // for default renderer
22 
23 #include "qgsrendererregistry.h"
24 
25 #include "qgsrendercontext.h"
26 #include "qgsclipper.h"
27 #include "qgsgeometry.h"
28 #include "qgsgeometrycollection.h"
29 #include "qgsfeature.h"
30 #include "qgslogger.h"
31 #include "qgsvectorlayer.h"
32 #include "qgspainteffect.h"
33 #include "qgseffectstack.h"
34 #include "qgspainteffectregistry.h"
35 #include "qgswkbptr.h"
36 #include "qgspoint.h"
37 #include "qgsproperty.h"
38 
39 #include <QDomElement>
40 #include <QDomDocument>
41 #include <QPolygonF>
42 
43 QPointF QgsFeatureRenderer::_getPoint( QgsRenderContext &context, const QgsPoint &point )
44 {
45  return QgsSymbol::_getPoint( context, point );
46 }
47 
49 {
50  if ( !destRenderer || !mPaintEffect )
51  return;
52 
53  destRenderer->setPaintEffect( mPaintEffect->clone() );
54  destRenderer->mOrderBy = mOrderBy;
55  destRenderer->mOrderByEnabled = mOrderByEnabled;
56 }
57 
59  : mType( type )
60  , mUsingSymbolLevels( false )
63  , mForceRaster( false )
64  , mOrderByEnabled( false )
65 {
67  mPaintEffect->setEnabled( false );
68 }
69 
71 {
72  delete mPaintEffect;
73 }
74 
76 {
77  return new QgsSingleSymbolRenderer( QgsSymbol::defaultSymbol( geomType ) );
78 }
79 
81 {
82  return symbolForFeature( feature, context );
83 }
84 
86 {
87  Q_UNUSED( feature );
88  Q_UNUSED( context );
89  return QSet< QString >();
90 }
91 
93 {
94 #ifdef QGISDEBUG
95  if ( !mThread )
96  {
97  mThread = QThread::currentThread();
98  }
99  else
100  {
101  Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::startRender", "startRender called in a different thread - use a cloned renderer instead" );
102  }
103 #endif
104 }
105 
107 {
108 #ifdef QGISDEBUG
109  Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::stopRender", "stopRender called in a different thread - use a cloned renderer instead" );
110 #endif
111 }
112 
114 {
115  return false;
116 }
117 
118 bool QgsFeatureRenderer::renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
119 {
120 #ifdef QGISDEBUG
121  Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::renderFeature", "renderFeature called in a different thread - use a cloned renderer instead" );
122 #endif
123 
124  QgsSymbol *symbol = symbolForFeature( feature, context );
125  if ( !symbol )
126  return false;
127 
128  renderFeatureWithSymbol( feature, symbol, context, layer, selected, drawVertexMarker );
129  return true;
130 }
131 
132 void QgsFeatureRenderer::renderFeatureWithSymbol( QgsFeature &feature, QgsSymbol *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
133 {
134  symbol->renderFeature( feature, context, layer, selected, drawVertexMarker, mCurrentVertexMarkerType, mCurrentVertexMarkerSize );
135 }
136 
138 {
139  return QStringLiteral( "UNKNOWN RENDERER\n" );
140 }
141 
142 QgsFeatureRenderer *QgsFeatureRenderer::load( QDomElement &element, const QgsReadWriteContext &context )
143 {
144  // <renderer-v2 type=""> ... </renderer-v2>
145 
146  if ( element.isNull() )
147  return nullptr;
148 
149  // load renderer
150  QString rendererType = element.attribute( QStringLiteral( "type" ) );
151 
153  if ( !m )
154  return nullptr;
155 
156  QgsFeatureRenderer *r = m->createRenderer( element, context );
157  if ( r )
158  {
159  r->setUsingSymbolLevels( element.attribute( QStringLiteral( "symbollevels" ), QStringLiteral( "0" ) ).toInt() );
160  r->setForceRasterRender( element.attribute( QStringLiteral( "forceraster" ), QStringLiteral( "0" ) ).toInt() );
161 
162  //restore layer effect
163  QDomElement effectElem = element.firstChildElement( QStringLiteral( "effect" ) );
164  if ( !effectElem.isNull() )
165  {
166  r->setPaintEffect( QgsApplication::paintEffectRegistry()->createEffect( effectElem ) );
167  }
168 
169  // restore order by
170  QDomElement orderByElem = element.firstChildElement( QStringLiteral( "orderby" ) );
171  r->mOrderBy.load( orderByElem );
172  r->setOrderByEnabled( element.attribute( QStringLiteral( "enableorderby" ), QStringLiteral( "0" ) ).toInt() );
173  }
174  return r;
175 }
176 
177 QDomElement QgsFeatureRenderer::save( QDomDocument &doc, const QgsReadWriteContext &context )
178 {
179  Q_UNUSED( context );
180  // create empty renderer element
181  QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME );
182  rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) );
183 
185  mPaintEffect->saveProperties( doc, rendererElem );
186 
187  if ( !mOrderBy.isEmpty() )
188  {
189  QDomElement orderBy = doc.createElement( QStringLiteral( "orderby" ) );
190  mOrderBy.save( orderBy );
191  rendererElem.appendChild( orderBy );
192  }
193  rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) );
194  return rendererElem;
195 }
196 
197 QgsFeatureRenderer *QgsFeatureRenderer::loadSld( const QDomNode &node, QgsWkbTypes::GeometryType geomType, QString &errorMessage )
198 {
199  QDomElement element = node.toElement();
200  if ( element.isNull() )
201  return nullptr;
202 
203  // get the UserStyle element
204  QDomElement userStyleElem = element.firstChildElement( QStringLiteral( "UserStyle" ) );
205  if ( userStyleElem.isNull() )
206  {
207  // UserStyle element not found, nothing will be rendered
208  errorMessage = QStringLiteral( "Info: UserStyle element not found." );
209  return nullptr;
210  }
211 
212  // get the FeatureTypeStyle element
213  QDomElement featTypeStyleElem = userStyleElem.firstChildElement( QStringLiteral( "FeatureTypeStyle" ) );
214  if ( featTypeStyleElem.isNull() )
215  {
216  errorMessage = QStringLiteral( "Info: FeatureTypeStyle element not found." );
217  return nullptr;
218  }
219 
220  // use the RuleRenderer when more rules are present or the rule
221  // has filters or min/max scale denominators set,
222  // otherwise use the SingleSymbol renderer
223  bool needRuleRenderer = false;
224  int ruleCount = 0;
225 
226  QDomElement ruleElem = featTypeStyleElem.firstChildElement( QStringLiteral( "Rule" ) );
227  while ( !ruleElem.isNull() )
228  {
229  ruleCount++;
230 
231  // more rules present, use the RuleRenderer
232  if ( ruleCount > 1 )
233  {
234  QgsDebugMsg( "more Rule elements found: need a RuleRenderer" );
235  needRuleRenderer = true;
236  break;
237  }
238 
239  QDomElement ruleChildElem = ruleElem.firstChildElement();
240  while ( !ruleChildElem.isNull() )
241  {
242  // rule has filter or min/max scale denominator, use the RuleRenderer
243  if ( ruleChildElem.localName() == QLatin1String( "Filter" ) ||
244  ruleChildElem.localName() == QLatin1String( "MinScaleDenominator" ) ||
245  ruleChildElem.localName() == QLatin1String( "MaxScaleDenominator" ) )
246  {
247  QgsDebugMsg( "Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" );
248  needRuleRenderer = true;
249  break;
250  }
251 
252  ruleChildElem = ruleChildElem.nextSiblingElement();
253  }
254 
255  if ( needRuleRenderer )
256  {
257  break;
258  }
259 
260  ruleElem = ruleElem.nextSiblingElement( QStringLiteral( "Rule" ) );
261  }
262 
263  QString rendererType;
264  if ( needRuleRenderer )
265  {
266  rendererType = QStringLiteral( "RuleRenderer" );
267  }
268  else
269  {
270  rendererType = QStringLiteral( "singleSymbol" );
271  }
272  QgsDebugMsg( QString( "Instantiating a '%1' renderer..." ).arg( rendererType ) );
273 
274  // create the renderer and return it
276  if ( !m )
277  {
278  errorMessage = QStringLiteral( "Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
279  return nullptr;
280  }
281 
282  QgsFeatureRenderer *r = m->createRendererFromSld( featTypeStyleElem, geomType );
283  return r;
284 }
285 
286 QDomElement QgsFeatureRenderer::writeSld( QDomDocument &doc, const QString &styleName, const QgsStringMap &props ) const
287 {
288  QDomElement userStyleElem = doc.createElement( QStringLiteral( "UserStyle" ) );
289 
290  QDomElement nameElem = doc.createElement( QStringLiteral( "se:Name" ) );
291  nameElem.appendChild( doc.createTextNode( styleName ) );
292  userStyleElem.appendChild( nameElem );
293 
294  QDomElement featureTypeStyleElem = doc.createElement( QStringLiteral( "se:FeatureTypeStyle" ) );
295  toSld( doc, featureTypeStyleElem, props );
296  userStyleElem.appendChild( featureTypeStyleElem );
297 
298  return userStyleElem;
299 }
300 
302 {
303  return false;
304 }
305 
307 {
308  Q_UNUSED( key );
309  return false;
310 }
311 
312 void QgsFeatureRenderer::checkLegendSymbolItem( const QString &key, bool state )
313 {
314  Q_UNUSED( key );
315  Q_UNUSED( state );
316 }
317 
318 void QgsFeatureRenderer::setLegendSymbolItem( const QString &key, QgsSymbol *symbol )
319 {
320  Q_UNUSED( key );
321  delete symbol;
322 }
323 
325 {
326  return QgsLegendSymbolList();
327 }
328 
330 {
333 }
334 
336 {
337  return nullptr != symbolForFeature( feat, context );
338 }
339 
341 {
342  QgsVectorLayer::drawVertexMarker( pt.x(), pt.y(), *context.painter(),
345 }
346 
348 {
349  Q_FOREACH ( QPointF pt, pts )
350  renderVertexMarker( pt, context );
351 }
352 
353 void QgsFeatureRenderer::renderVertexMarkerPolygon( QPolygonF &pts, QList<QPolygonF> *rings, QgsRenderContext &context )
354 {
355  Q_FOREACH ( QPointF pt, pts )
356  renderVertexMarker( pt, context );
357 
358  if ( rings )
359  {
360  Q_FOREACH ( const QPolygonF &ring, *rings )
361  {
362  Q_FOREACH ( QPointF pt, ring )
363  renderVertexMarker( pt, context );
364  }
365  }
366 }
367 
369 {
370  QgsSymbolList lst;
371  QgsSymbol *s = symbolForFeature( feat, context );
372  if ( s ) lst.append( s );
373  return lst;
374 }
375 
377 {
378  QgsSymbolList lst;
379  QgsSymbol *s = originalSymbolForFeature( feat, context );
380  if ( s ) lst.append( s );
381  return lst;
382 }
383 
385 {
386  return mPaintEffect;
387 }
388 
390 {
391  delete mPaintEffect;
392  mPaintEffect = effect;
393 }
394 
396 {
397  return mOrderBy;
398 }
399 
401 {
402  mOrderBy = orderBy;
403 }
404 
406 {
407  return mOrderByEnabled;
408 }
409 
411 {
412  mOrderByEnabled = enabled;
413 }
414 
416 {
417  if ( symbol->type() == QgsSymbol::Marker )
418  {
419  QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( symbol );
420  if ( QgsSymbol::ScaleArea == QgsSymbol::ScaleMethod( method ) )
421  {
422  s->setDataDefinedSize( QgsProperty::fromExpression( "coalesce(sqrt(" + QString::number( s->size() ) + " * (" + field + ")),0)" ) );
423  }
424  else
425  {
426  s->setDataDefinedSize( QgsProperty::fromExpression( "coalesce(" + QString::number( s->size() ) + " * (" + field + "),0)" ) );
427  }
429  }
430  else if ( symbol->type() == QgsSymbol::Line )
431  {
432  QgsLineSymbol *s = static_cast<QgsLineSymbol *>( symbol );
433  s->setDataDefinedWidth( QgsProperty::fromExpression( "coalesce(" + QString::number( s->width() ) + " * (" + field + "),0)" ) );
434  }
435 }
436 
437 void QgsFeatureRenderer::convertSymbolRotation( QgsSymbol *symbol, const QString &field )
438 {
439  if ( symbol->type() == QgsSymbol::Marker )
440  {
441  QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( symbol );
443  ? QString::number( s->angle() ) + " + "
444  : QString() ) + field );
445  s->setDataDefinedAngle( dd );
446  }
447 }
virtual bool willRenderFeature(QgsFeature &feat, QgsRenderContext &context)
Returns whether the renderer will render a feature or not.
The class is used as a container of context for various read/write operations on other objects...
virtual QgsSymbolList originalSymbolsForFeature(QgsFeature &feat, QgsRenderContext &context)
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
void setEnabled(const bool enabled)
Sets whether the effect is enabled.
void setVertexMarkerAppearance(int type, int size)
set type and size of editing vertex markers for subsequent rendering
QList< QgsLegendSymbolItem > QgsLegendSymbolList
QgsFeatureRequest::OrderBy mOrderBy
Definition: qgsrenderer.h:517
Calculate scale by the diameter.
Definition: qgssymbol.h:97
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props=QgsStringMap()) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
Definition: qgsrenderer.h:297
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
virtual QgsFeatureRenderer * createRendererFromSld(QDomElement &elem, QgsWkbTypes::GeometryType geomType)
QgsFeatureRequest::OrderBy orderBy() const
Get the order in which features shall be processed by this renderer.
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context)
store renderer info to XML element
VertexMarkerType
Editing vertex markers.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
virtual QgsSymbol * originalSymbolForFeature(QgsFeature &feature, QgsRenderContext &context)
Return symbol for feature.
Definition: qgsrenderer.cpp:80
static QPointF _getPoint(QgsRenderContext &context, const QgsPoint &point)
Creates a point in screen coordinates from a QgsPoint in map coordinates.
Definition: qgssymbol.h:336
Base class for visual effects which can be applied to QPicture drawings.
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
Container of fields for a vector layer.
Definition: qgsfields.h:42
void renderVertexMarkerPolyline(QPolygonF &pts, QgsRenderContext &context)
render editing vertex marker for a polyline
#define RENDERER_TAG_NAME
Definition: qgsrenderer.h:49
void CORE_EXPORT load(const QDomElement &elem)
Deserialize from XML.
void setUsingSymbolLevels(bool usingSymbolLevels)
Definition: qgsrenderer.h:269
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1169
QgsPaintEffect * mPaintEffect
Definition: qgsrenderer.h:501
Line symbol.
Definition: qgssymbol.h:86
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:62
static QPointF _getPoint(QgsRenderContext &context, const QgsPoint &point)
Creates a point in screen coordinates from a wkb string in map coordinates.
Definition: qgsrenderer.cpp:43
QMap< QString, QString > QgsStringMap
Definition: qgis.h:479
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application&#39;s paint effect registry, used for managing paint effects. ...
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the renderer.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:43
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
return new default symbol for specified geometry type
Definition: qgssymbol.cpp:266
QString type() const
Definition: qgsrenderer.h:126
virtual QgsSymbolList symbolsForFeature(QgsFeature &feat, QgsRenderContext &context)
Returns list of symbols used for rendering the feature.
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects. ...
void setForceRasterRender(bool forceRaster)
Sets whether the renderer should be rendered to a raster destination.
Definition: qgsrenderer.h:407
static QgsFeatureRenderer * load(QDomElement &symbologyElem, const QgsReadWriteContext &context)
create a renderer from XML element
Calculate scale by the area.
Definition: qgssymbol.h:96
double width() const
Definition: qgssymbol.cpp:1582
virtual QgsFeatureRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Return new instance of the renderer given the DOM element.
virtual ~QgsFeatureRenderer()
Definition: qgsrenderer.cpp:70
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.
Definition: qgssymbol.cpp:698
QgsRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
static void convertSymbolSizeScale(QgsSymbol *symbol, QgsSymbol::ScaleMethod method, const QString &field)
virtual bool legendSymbolItemChecked(const QString &key)
items of symbology items in legend is checked
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
Definition: qgssymbol.cpp:1434
ScaleMethod
Scale method.
Definition: qgssymbol.h:94
A store for object properties.
Definition: qgsproperty.h:229
static void drawVertexMarker(double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize)
Draws a vertex symbol at (screen) coordinates x, y. (Useful to assist vertex editing.)
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer...
virtual void checkLegendSymbolItem(const QString &key, bool state=true)
item in symbology was checked
virtual void setLegendSymbolItem(const QString &key, QgsSymbol *symbol)
Sets the symbol to be used for a legend symbol item.
void setDataDefinedWidth(const QgsProperty &property)
Set data defined width for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1601
void setOrderBy(const QgsFeatureRequest::OrderBy &orderBy)
Define the order in which features shall be processed by this renderer.
void renderVertexMarkerPolygon(QPolygonF &pts, QList< QPolygonF > *rings, QgsRenderContext &context)
render editing vertex marker for a polygon
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:137
static void convertSymbolRotation(QgsSymbol *symbol, const QString &field)
Marker symbol.
Definition: qgssymbol.h:85
virtual QgsSymbol * symbolForFeature(QgsFeature &feature, QgsRenderContext &context)=0
To be overridden.
Contains information about the context of a rendering operation.
QPainter * painter()
Returns the destination QPainter for the render operation.
SymbolType type() const
Definition: qgssymbol.h:113
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
Definition: qgsrenderer.cpp:92
double size() const
Returns the size for the whole symbol, which is the maximum size of all marker symbol layers in the s...
Definition: qgssymbol.cpp:1266
int mCurrentVertexMarkerSize
The current size of editing marker.
Definition: qgsrenderer.h:499
static QgsFeatureRenderer * loadSld(const QDomNode &node, QgsWkbTypes::GeometryType geomType, QString &errorMessage)
Create a new renderer according to the information contained in the UserStyle element of a SLD style ...
Stores metadata about one renderer class.
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
Definition: qgsrenderer.cpp:48
virtual QDomElement writeSld(QDomDocument &doc, const QString &styleName, const QgsStringMap &props=QgsStringMap()) const
create the SLD UserStyle element following the SLD v1.1 specs with the given name ...
virtual QSet< QString > legendKeysForFeature(QgsFeature &feature, QgsRenderContext &context)
Return legend keys matching a specified feature.
Definition: qgsrenderer.cpp:85
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
void setDataDefinedSize(const QgsProperty &property)
Set data defined size for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1343
int mCurrentVertexMarkerType
The current type of editing marker.
Definition: qgsrenderer.h:497
void renderFeatureWithSymbol(QgsFeature &feature, QgsSymbol *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker)
static QgsFeatureRenderer * defaultRenderer(QgsWkbTypes::GeometryType geomType)
return a new renderer - used by default in vector layers
Definition: qgsrenderer.cpp:75
virtual bool filterNeedsGeometry() const
Returns true if this renderer requires the geometry to apply the filter.
Represents a vector layer which manages a vector based data sets.
QgsFeatureRenderer(const QString &type)
Definition: qgsrenderer.cpp:58
void setOrderByEnabled(bool enabled)
Sets whether custom ordering should be applied before features are processed by this renderer...
static QgsRendererRegistry * rendererRegistry()
Returns the application&#39;s renderer registry, used for managing vector layer renderers.
double angle() const
Returns the marker angle for the whole symbol.
Definition: qgssymbol.cpp:1146
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.
Represents a list of OrderByClauses, with the most important first and the least important last...
void renderVertexMarker(QPointF pt, QgsRenderContext &context)
render editing vertex marker at specified point
virtual QString dump() const
Returns debug information about this renderer.
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.