QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgsmeshrenderersettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmeshrenderersettings.h
3 -------------------------
4 begin : May 2018
5 copyright : (C) 2018 by Peter Petrik
6 email : zilolv at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSMESHRENDERERSETTINGS_H
19#define QGSMESHRENDERERSETTINGS_H
20
21#include <QColor>
22#include <QDomElement>
23#include <limits>
24
25#include "qgis_core.h"
26#include "qgis.h"
27#include "qgscolorrampshader.h"
28#include "qgsmesh3daveraging.h"
30
41{
42 public:
44 bool isEnabled() const;
46 void setEnabled( bool enabled );
47
49 double lineWidth() const;
51 void setLineWidth( double lineWidth );
52
54 QColor color() const;
56 void setColor( const QColor &color );
57
63 Qgis::RenderUnit lineWidthUnit() const;
64
70 void setLineWidthUnit( Qgis::RenderUnit lineWidthUnit );
71
73 QDomElement writeXml( QDomDocument &doc ) const;
75 void readXml( const QDomElement &elem );
76
77 private:
78 bool mEnabled = false;
79 double mLineWidth = DEFAULT_LINE_WIDTH;
80 Qgis::RenderUnit mLineWidthUnit = Qgis::RenderUnit::Millimeters;
81 QColor mColor = Qt::black;
82};
83
94{
95 public:
96
105 {
106
110 None = 0,
111
116 };
117
119 QgsColorRampShader colorRampShader() const;
121 void setColorRampShader( const QgsColorRampShader &shader );
122
124 double classificationMinimum() const;
126 double classificationMaximum() const;
128 void setClassificationMinimumMaximum( double minimum, double maximum );
129
131 double opacity() const;
133 void setOpacity( double opacity );
134
142 DataResamplingMethod dataResamplingMethod() const;
143
149 void setDataResamplingMethod( const DataResamplingMethod &dataResamplingMethod );
150
156 QgsInterpolatedLineWidth edgeStrokeWidth() const;
157
163 void setEdgeStrokeWidth( const QgsInterpolatedLineWidth &strokeWidth );
164
170 Qgis::RenderUnit edgeStrokeWidthUnit() const;
171
177 void setEdgeStrokeWidthUnit( Qgis::RenderUnit edgeStrokeWidthUnit );
178
180 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
182 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
183
184 private:
185 QgsColorRampShader mColorRampShader;
186 DataResamplingMethod mDataResamplingMethod = DataResamplingMethod::None;
187 double mClassificationMinimum = 0;
188 double mClassificationMaximum = 0;
189 double mOpacity = 1;
190
191 QgsInterpolatedLineWidth mEdgeStrokeWidth;
192 Qgis::RenderUnit mEdgeStrokeWidthUnit = Qgis::RenderUnit::Millimeters;
193};
194
205{
206 public:
207
210 {
211
215 MinMax = 0,
216
221
225 Fixed
226 };
227
231 void setShaftLengthMethod( ArrowScalingMethod shaftLengthMethod );
232
238 double minShaftLength() const;
239
245 void setMinShaftLength( double minShaftLength );
246
252 double maxShaftLength() const;
253
259 void setMaxShaftLength( double maxShaftLength );
260
266 double scaleFactor() const;
267
273 void setScaleFactor( double scaleFactor );
274
280 double fixedShaftLength() const;
281
287 void setFixedShaftLength( double fixedShaftLength );
288
290 double arrowHeadWidthRatio() const;
292 void setArrowHeadWidthRatio( double arrowHeadWidthRatio );
293
295 double arrowHeadLengthRatio() const;
297 void setArrowHeadLengthRatio( double arrowHeadLengthRatio );
298
300 QDomElement writeXml( QDomDocument &doc ) const;
302 void readXml( const QDomElement &elem );
303
304 private:
305 QgsMeshRendererVectorArrowSettings::ArrowScalingMethod mShaftLengthMethod = QgsMeshRendererVectorArrowSettings::ArrowScalingMethod::MinMax;
306 double mMinShaftLength = 0.8; //in millimeters
307 double mMaxShaftLength = 10; //in millimeters
308 double mScaleFactor = 10;
309 double mFixedShaftLength = 20; //in millimeters
310 double mArrowHeadWidthRatio = 0.15;
311 double mArrowHeadLengthRatio = 0.40;
312};
313
324{
325 public:
328 {
329
333 MeshGridded = 0,
334
338 Random
339 };
340
342 SeedingStartPointsMethod seedingMethod() const;
344 void setSeedingMethod( const SeedingStartPointsMethod &seedingMethod );
346 double seedingDensity() const;
348 void setSeedingDensity( double seedingDensity );
350 void readXml( const QDomElement &elem );
352 QDomElement writeXml( QDomDocument &doc ) const;
353
354 private:
355
357 double mSeedingDensity = 0.15;
358};
359
370{
371 public:
372
374 double maximumTailLength() const;
376 void setMaximumTailLength( double maximumTailLength );
378 int particlesCount() const;
380 void setParticlesCount( int value );
382 Qgis::RenderUnit maximumTailLengthUnit() const;
384 void setMaximumTailLengthUnit( Qgis::RenderUnit maximumTailLengthUnit );
385
387 void readXml( const QDomElement &elem );
389 QDomElement writeXml( QDomDocument &doc ) const;
390
391 private:
392 int mParticlesCount = 1000;
393 double mMaximumTailLength = 100;
394 Qgis::RenderUnit mMaximumTailLengthUnit = Qgis::RenderUnit::Millimeters;
395
396};
397
408{
409 public:
410
416 {
418 Arrows = 0,
422 Traces
423 };
424
426 double lineWidth() const;
428 void setLineWidth( double lineWidth );
429
431 QColor color() const;
433 void setColor( const QColor &color );
434
441 double filterMin() const;
442
447 void setFilterMin( double filterMin );
448
455 double filterMax() const;
456
461 void setFilterMax( double filterMax );
462
464 bool isOnUserDefinedGrid() const;
466 void setOnUserDefinedGrid( bool enabled );
468 int userGridCellWidth() const;
470 void setUserGridCellWidth( int width );
472 int userGridCellHeight() const;
474 void setUserGridCellHeight( int height );
475
480 Symbology symbology() const;
481
486 void setSymbology( const Symbology &symbology );
487
492 QgsInterpolatedLineColor::ColoringMethod coloringMethod() const;
493
498 void setColoringMethod( const QgsInterpolatedLineColor::ColoringMethod &coloringMethod );
499
504 QgsColorRampShader colorRampShader() const;
505
510 void setColorRampShader( const QgsColorRampShader &colorRampShader );
511
516 QgsInterpolatedLineColor vectorStrokeColoring() const;
517
522 QgsMeshRendererVectorArrowSettings arrowSettings() const;
523
528 void setArrowsSettings( const QgsMeshRendererVectorArrowSettings &arrowSettings );
529
534 QgsMeshRendererVectorStreamlineSettings streamLinesSettings() const;
535
540 void setStreamLinesSettings( const QgsMeshRendererVectorStreamlineSettings &streamLinesSettings );
541
546 QgsMeshRendererVectorTracesSettings tracesSettings() const;
547
552 void setTracesSettings( const QgsMeshRendererVectorTracesSettings &tracesSettings );
553
555 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
557 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
558
559 private:
560
561 Symbology mDisplayingMethod = Arrows;
562
563 double mLineWidth = DEFAULT_LINE_WIDTH; //in millimeters
564 QgsColorRampShader mColorRampShader;
565 QColor mColor = Qt::black;
567 double mFilterMin = -1; //disabled
568 double mFilterMax = -1; //disabled
569 int mUserGridCellWidth = 10; // in pixels
570 int mUserGridCellHeight = 10; // in pixels
571 bool mOnUserDefinedGrid = false;
572
574 QgsMeshRendererVectorStreamlineSettings mStreamLinesSettings;
576};
577
587class CORE_EXPORT QgsMeshRendererSettings
588{
589 public:
590
597
599 QgsMeshRendererMeshSettings nativeMeshSettings() const { return mRendererNativeMeshSettings; }
601 void setNativeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererNativeMeshSettings = settings; }
602
604 QgsMeshRendererMeshSettings triangularMeshSettings() const { return mRendererTriangularMeshSettings; }
606 void setTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererTriangularMeshSettings = settings; }
607
612 QgsMeshRendererMeshSettings edgeMeshSettings() const { return mRendererEdgeMeshSettings; }
613
618 void setEdgeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererEdgeMeshSettings = settings; }
619
621 QgsMeshRendererScalarSettings scalarSettings( int groupIndex ) const { return mRendererScalarSettings.value( groupIndex ); }
622
624 void setScalarSettings( int groupIndex, const QgsMeshRendererScalarSettings &settings ) { mRendererScalarSettings[groupIndex] = settings; }
625
630 bool hasScalarSettings( int groupIndex ) const {return mRendererScalarSettings.contains( groupIndex );}
631
636 bool removeScalarSettings( int groupIndex ) {return mRendererScalarSettings.remove( groupIndex );}
637
639 QgsMeshRendererVectorSettings vectorSettings( int groupIndex ) const { return mRendererVectorSettings.value( groupIndex ); }
641 void setVectorSettings( int groupIndex, const QgsMeshRendererVectorSettings &settings ) { mRendererVectorSettings[groupIndex] = settings; }
642
647 bool hasVectorSettings( int groupIndex ) const {return mRendererVectorSettings.contains( groupIndex );}
648
653 bool removeVectorSettings( int groupIndex ) {return mRendererVectorSettings.remove( groupIndex );}
654
660 QgsMesh3dAveragingMethod *averagingMethod() const;
661
667 void setAveragingMethod( QgsMesh3dAveragingMethod *method );
668
670 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
672 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
673
678 int activeScalarDatasetGroup() const;
679
684 void setActiveScalarDatasetGroup( int activeScalarDatasetGroup );
685
690 int activeVectorDatasetGroup() const;
691
696 void setActiveVectorDatasetGroup( int activeVectorDatasetGroup );
697
703 bool hasSettings( int datasetGroupIndex ) const;
704
705 private:
706 QgsMeshRendererMeshSettings mRendererNativeMeshSettings;
707 QgsMeshRendererMeshSettings mRendererTriangularMeshSettings;
708 QgsMeshRendererMeshSettings mRendererEdgeMeshSettings;
709
710 QHash<int, QgsMeshRendererScalarSettings> mRendererScalarSettings;
711 QHash<int, QgsMeshRendererVectorSettings> mRendererVectorSettings;
712
714 int mActiveScalarDatasetGroup = -1;
715
717 int mActiveVectorDatasetGroup = -1;
718
720 std::shared_ptr<QgsMesh3dAveragingMethod> mAveragingMethod;
721};
722
723#endif //QGSMESHRENDERERSETTINGS_H
RenderUnit
Rendering size units.
Definition: qgis.h:3441
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Class defining color to render mesh datasets.
ColoringMethod
Defines how the color is defined.
@ SingleColor
Render with a single color.
Represents a width than can vary depending on values.
Abstract class to interpolate 3d stacked mesh data to 2d data.
Represents a mesh renderer settings for mesh object.
Represents a mesh renderer settings for scalar datasets.
DataResamplingMethod
Resampling of value from dataset.
@ NeighbourAverage
Does a simple average of values defined for all surrounding faces/vertices.
Represents all mesh renderer settings.
QgsMeshRendererScalarSettings scalarSettings(int groupIndex) const
Returns renderer settings.
bool hasVectorSettings(int groupIndex) const
Returns whether groupIndex has existing vector settings.
void setEdgeMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new edge mesh renderer settings.
bool removeVectorSettings(int groupIndex)
Removes vector settings for groupIndex.
QgsMeshRendererVectorSettings vectorSettings(int groupIndex) const
Returns renderer settings.
void setVectorSettings(int groupIndex, const QgsMeshRendererVectorSettings &settings)
Sets new renderer settings.
void setTriangularMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new triangular mesh renderer settings.
QgsMeshRendererMeshSettings edgeMeshSettings() const
Returns edge mesh renderer settings.
QgsMeshRendererMeshSettings nativeMeshSettings() const
Returns native mesh renderer settings.
bool hasScalarSettings(int groupIndex) const
Returns whether groupIndex has existing scalar settings.
bool removeScalarSettings(int groupIndex)
Removes scalar settings with groupIndex.
void setScalarSettings(int groupIndex, const QgsMeshRendererScalarSettings &settings)
Sets new renderer settings.
QgsMeshRendererMeshSettings triangularMeshSettings() const
Returns triangular mesh renderer settings.
~QgsMeshRendererSettings()
Destructor.
void setNativeMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new native mesh renderer settings, triggers repaint.
Represents a mesh renderer settings for vector datasets displayed with arrows.
ArrowScalingMethod
Algorithm how to transform vector magnitude to length of arrow on the device in pixels.
@ Scaled
Scale vector magnitude by factor scaleFactor()
Represents a renderer settings for vector datasets.
Symbology
Defines the symbology of vector rendering.
@ Streamlines
Displaying vector dataset with streamlines.
Represents a streamline renderer settings for vector datasets displayed by streamlines.
SeedingStartPointsMethod
Method used to define start points that are used to draw streamlines.
Represents a trace renderer settings for vector datasets displayed by particle traces.
The class is used as a container of context for various read/write operations on other objects.
const double DEFAULT_LINE_WIDTH
Definition: qgis.h:4528