54 QDomElement elem = doc.createElement( QStringLiteral(
"mesh-settings" ) );
55 elem.setAttribute( QStringLiteral(
"enabled" ), mEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
56 elem.setAttribute( QStringLiteral(
"line-width" ), mLineWidth );
63 mEnabled = elem.attribute( QStringLiteral(
"enabled" ) ).toInt();
64 mLineWidth = elem.attribute( QStringLiteral(
"line-width" ) ).toDouble();
72 return mColorRampShader;
77 mColorRampShader = shader;
86 mClassificationMinimum = minimum;
87 mClassificationMaximum = maximum;
96 QDomElement elem = doc.createElement( QStringLiteral(
"scalar-settings" ) );
97 elem.setAttribute( QStringLiteral(
"min-val" ), mClassificationMinimum );
98 elem.setAttribute( QStringLiteral(
"max-val" ), mClassificationMaximum );
99 elem.setAttribute( QStringLiteral(
"opacity" ), mOpacity );
100 QDomElement elemShader = mColorRampShader.writeXml( doc );
101 elem.appendChild( elemShader );
107 mClassificationMinimum = elem.attribute( QStringLiteral(
"min-val" ) ).toDouble();
108 mClassificationMaximum = elem.attribute( QStringLiteral(
"max-val" ) ).toDouble();
109 mOpacity = elem.attribute( QStringLiteral(
"opacity" ) ).toDouble();
110 QDomElement elemShader = elem.firstChildElement( QStringLiteral(
"colorrampshader" ) );
111 mColorRampShader.readXml( elemShader );
133 mColor = vectorColor;
143 mFilterMin = vectorFilterMin;
153 mFilterMax = vectorFilterMax;
158 return mShaftLengthMethod;
163 mShaftLengthMethod = shaftLengthMethod;
168 return mMinShaftLength;
173 mMinShaftLength = minShaftLength;
178 return mMaxShaftLength;
183 mMaxShaftLength = maxShaftLength;
193 mScaleFactor = scaleFactor;
198 return mFixedShaftLength;
203 mFixedShaftLength = fixedShaftLength;
208 return mArrowHeadWidthRatio;
213 mArrowHeadWidthRatio = vectorHeadWidthRatio;
218 return mArrowHeadLengthRatio;
223 mArrowHeadLengthRatio = vectorHeadLengthRatio;
228 return mOnUserDefinedGrid;
233 mOnUserDefinedGrid = enabled;
238 return mUserGridCellWidth;
243 mUserGridCellWidth = width;
248 return mUserGridCellHeight;
253 mUserGridCellHeight = height;
258 QDomElement elem = doc.createElement( QStringLiteral(
"vector-settings" ) );
259 elem.setAttribute( QStringLiteral(
"line-width" ), mLineWidth );
261 elem.setAttribute( QStringLiteral(
"filter-min" ), mFilterMin );
262 elem.setAttribute( QStringLiteral(
"filter-max" ), mFilterMax );
263 elem.setAttribute( QStringLiteral(
"arrow-head-width-ratio" ), mArrowHeadWidthRatio );
264 elem.setAttribute( QStringLiteral(
"arrow-head-length-ratio" ), mArrowHeadLengthRatio );
265 elem.setAttribute( QStringLiteral(
"user-grid-enabled" ), mOnUserDefinedGrid ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
266 elem.setAttribute( QStringLiteral(
"user-grid-width" ), mUserGridCellWidth );
267 elem.setAttribute( QStringLiteral(
"user-grid-height" ), mUserGridCellHeight );
269 QDomElement elemShaft = doc.createElement( QStringLiteral(
"shaft-length" ) );
271 switch ( mShaftLengthMethod )
274 methodTxt = QStringLiteral(
"minmax" );
275 elemShaft.setAttribute( QStringLiteral(
"min" ), mMinShaftLength );
276 elemShaft.setAttribute( QStringLiteral(
"max" ), mMaxShaftLength );
279 methodTxt = QStringLiteral(
"scaled" );
280 elemShaft.setAttribute( QStringLiteral(
"scale-factor" ), mScaleFactor );
283 methodTxt = QStringLiteral(
"fixed" ) ;
284 elemShaft.setAttribute( QStringLiteral(
"fixed-length" ), mFixedShaftLength );
287 elemShaft.setAttribute( QStringLiteral(
"method" ), methodTxt );
288 elem.appendChild( elemShaft );
294 mLineWidth = elem.attribute( QStringLiteral(
"line-width" ) ).toDouble();
296 mFilterMin = elem.attribute( QStringLiteral(
"filter-min" ) ).toDouble();
297 mFilterMax = elem.attribute( QStringLiteral(
"filter-max" ) ).toDouble();
298 mArrowHeadWidthRatio = elem.attribute( QStringLiteral(
"arrow-head-width-ratio" ) ).toDouble();
299 mArrowHeadLengthRatio = elem.attribute( QStringLiteral(
"arrow-head-length-ratio" ) ).toDouble();
300 mOnUserDefinedGrid = elem.attribute( QStringLiteral(
"user-grid-enabled" ) ).toInt();
301 mUserGridCellWidth = elem.attribute( QStringLiteral(
"user-grid-width" ) ).toInt();
302 mUserGridCellHeight = elem.attribute( QStringLiteral(
"user-grid-height" ) ).toInt();
304 QDomElement elemShaft = elem.firstChildElement( QStringLiteral(
"shaft-length" ) );
305 QString methodTxt = elemShaft.attribute( QStringLiteral(
"method" ) );
306 if ( QStringLiteral(
"minmax" ) == methodTxt )
308 mShaftLengthMethod = MinMax;
309 mMinShaftLength = elemShaft.attribute( QStringLiteral(
"min" ) ).toDouble();
310 mMaxShaftLength = elemShaft.attribute( QStringLiteral(
"max" ) ).toDouble();
312 else if ( QStringLiteral(
"scaled" ) == methodTxt )
314 mShaftLengthMethod = Scaled;
315 mScaleFactor = elemShaft.attribute( QStringLiteral(
"scale-factor" ) ).toDouble();
319 mShaftLengthMethod = Fixed;
320 mFixedShaftLength = elemShaft.attribute( QStringLiteral(
"fixed-length" ) ).toDouble();
328 QDomElement elem = doc.createElement( QStringLiteral(
"mesh-renderer-settings" ) );
330 QDomElement elemActiveDataset = doc.createElement( QStringLiteral(
"active-dataset" ) );
331 if ( mActiveScalarDataset.isValid() )
332 elemActiveDataset.setAttribute( QStringLiteral(
"scalar" ), QStringLiteral(
"%1,%2" ).arg( mActiveScalarDataset.group() ).arg( mActiveScalarDataset.dataset() ) );
333 if ( mActiveVectorDataset.isValid() )
334 elemActiveDataset.setAttribute( QStringLiteral(
"vector" ), QStringLiteral(
"%1,%2" ).arg( mActiveVectorDataset.group() ).arg( mActiveVectorDataset.dataset() ) );
335 elem.appendChild( elemActiveDataset );
337 for (
int groupIndex : mRendererScalarSettings.keys() )
340 QDomElement elemScalar = scalarSettings.
writeXml( doc );
341 elemScalar.setAttribute( QStringLiteral(
"group" ), groupIndex );
342 elem.appendChild( elemScalar );
345 for (
int groupIndex : mRendererVectorSettings.keys() )
348 QDomElement elemVector = vectorSettings.
writeXml( doc );
349 elemVector.setAttribute( QStringLiteral(
"group" ), groupIndex );
350 elem.appendChild( elemVector );
353 QDomElement elemNativeMesh = mRendererNativeMeshSettings.writeXml( doc );
354 elemNativeMesh.setTagName( QStringLiteral(
"mesh-settings-native" ) );
355 elem.appendChild( elemNativeMesh );
357 QDomElement elemTriangularMesh = mRendererTriangularMeshSettings.writeXml( doc );
358 elemTriangularMesh.setTagName( QStringLiteral(
"mesh-settings-triangular" ) );
359 elem.appendChild( elemTriangularMesh );
366 mRendererScalarSettings.clear();
367 mRendererVectorSettings.clear();
369 QDomElement elemActiveDataset = elem.firstChildElement( QStringLiteral(
"active-dataset" ) );
370 if ( elemActiveDataset.hasAttribute( QStringLiteral(
"scalar" ) ) )
372 QStringList lst = elemActiveDataset.attribute( QStringLiteral(
"scalar" ) ).split( QChar(
',' ) );
373 if ( lst.count() == 2 )
376 if ( elemActiveDataset.hasAttribute( QStringLiteral(
"vector" ) ) )
378 QStringList lst = elemActiveDataset.attribute( QStringLiteral(
"vector" ) ).split( QChar(
',' ) );
379 if ( lst.count() == 2 )
383 QDomElement elemScalar = elem.firstChildElement( QStringLiteral(
"scalar-settings" ) );
384 while ( !elemScalar.isNull() )
386 int groupIndex = elemScalar.attribute( QStringLiteral(
"group" ) ).toInt();
388 scalarSettings.
readXml( elemScalar );
389 mRendererScalarSettings.insert( groupIndex, scalarSettings );
391 elemScalar = elemScalar.nextSiblingElement( QStringLiteral(
"scalar-settings" ) );
394 QDomElement elemVector = elem.firstChildElement( QStringLiteral(
"vector-settings" ) );
395 while ( !elemVector.isNull() )
397 int groupIndex = elemVector.attribute( QStringLiteral(
"group" ) ).toInt();
399 vectorSettings.
readXml( elemVector );
400 mRendererVectorSettings.insert( groupIndex, vectorSettings );
402 elemVector = elemVector.nextSiblingElement( QStringLiteral(
"vector-settings" ) );
405 QDomElement elemNativeMesh = elem.firstChildElement( QStringLiteral(
"mesh-settings-native" ) );
406 mRendererNativeMeshSettings.readXml( elemNativeMesh );
408 QDomElement elemTriangularMesh = elem.firstChildElement( QStringLiteral(
"mesh-settings-triangular" ) );
409 mRendererTriangularMeshSettings.readXml( elemTriangularMesh );
void setClassificationMinimumMaximum(double minimum, double maximum)
Sets min/max values used for creation of the color ramp shader.
void setFilterMax(double filterMax)
Sets filter value for vector magnitudes.
void setLineWidth(double lineWidth)
Sets line width used for rendering (in millimeters)
void setMaxShaftLength(double maxShaftLength)
Sets maximum shaft length (in millimeters)
double minShaftLength() const
Returns mininimum shaft length (in millimeters)
void setArrowHeadWidthRatio(double arrowHeadWidthRatio)
Sets ratio of the head width of the arrow (range 0-1)
double fixedShaftLength() const
Returns fixed arrow length (in millimeters)
void setUserGridCellHeight(int height)
Sets height of user grid cell (in pixels)
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
void setFilterMin(double filterMin)
Sets filter value for vector magnitudes.
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element.
Represents a mesh renderer settings for scalar datasets.
bool isEnabled() const
Returns whether mesh structure rendering is enabled.
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
double arrowHeadLengthRatio() const
Returns ratio of the head length of the arrow (range 0-1)
QgsMeshRendererVectorSettings::ArrowScalingMethod shaftLengthMethod() const
Returns method used for drawing arrows.
void setMinShaftLength(double minShaftLength)
Sets mininimum shaft length (in millimeters)
void setOnUserDefinedGrid(bool enabled)
Toggles drawing of vectors on user defined grid.
double filterMin() const
Returns filter value for vector magnitudes.
static QString encodeColor(const QColor &color)
double opacity() const
Returns opacity.
double lineWidth() const
Returns line width used for rendering (in millimeters)
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element.
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
Represents a mesh renderer settings for vector datasets.
void setColorRampShader(const QgsColorRampShader &shader)
Sets color ramp shader function.
void setColor(const QColor &color)
Sets color used for drawing arrows.
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
QColor color() const
Returns color used for drawing arrows.
void setShaftLengthMethod(ArrowScalingMethod shaftLengthMethod)
Sets method used for drawing arrows.
double filterMax() const
Returns filter value for vector magnitudes.
void setArrowHeadLengthRatio(double arrowHeadLengthRatio)
Sets ratio of the head length of the arrow (range 0-1)
double arrowHeadWidthRatio() const
Returns ratio of the head width of the arrow (range 0-1)
void setEnabled(bool enabled)
Sets whether mesh structure rendering is enabled.
QgsColorRampShader colorRampShader() const
Returns color ramp shader function.
void setLineWidth(double lineWidth)
Sets line width of the arrow in pixels (in millimeters)
double maxShaftLength() const
Returns maximum shaft length (in millimeters)
void setScaleFactor(double scaleFactor)
Sets scale factor.
void setOpacity(double opacity)
Sets opacity.
int userGridCellWidth() const
Returns width in pixels of user grid cell.
void setFixedShaftLength(double fixedShaftLength)
Sets fixed length (in millimeters)
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element.
bool isOnUserDefinedGrid() const
Returns whether vectors are drawn on user-defined grid.
QColor color() const
Returns color used for rendering.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element.
int userGridCellHeight() const
Returns height in pixels of user grid cell.
double scaleFactor() const
Returns scale factor.
double lineWidth() const
Returns line width of the arrow (in millimeters)
void setUserGridCellWidth(int width)
Sets width of user grid cell (in pixels)
ArrowScalingMethod
Algorithm how to transform vector magnitude to length of arrow on the device in pixels.
void setColor(const QColor &color)
Sets color used for rendering of the mesh.
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
double classificationMaximum() const
Returns max value used for creation of the color ramp shader.
static QColor decodeColor(const QString &str)
double classificationMinimum() const
Returns min value used for creation of the color ramp shader.