QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
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 "qgis.h"
22#include "qgis_core.h"
23#include "qgscolorrampshader.h"
25#include "qgsmesh3daveraging.h"
26
27#include <QColor>
28#include <QDomElement>
29
40{
41 public:
43 bool isEnabled() const;
45 void setEnabled( bool enabled );
46
48 double lineWidth() const;
50 void setLineWidth( double lineWidth );
51
53 QColor color() const;
55 void setColor( const QColor &color );
56
63
70
72 QDomElement writeXml( QDomDocument &doc ) const;
74 void readXml( const QDomElement &elem );
75
76 private:
77 bool mEnabled = false;
78 double mLineWidth = Qgis::DEFAULT_LINE_WIDTH;
80 QColor mColor = Qt::black;
81};
82
93{
94 public:
95
116
118 QgsColorRampShader colorRampShader() const;
120 void setColorRampShader( const QgsColorRampShader &shader );
121
123 double classificationMinimum() const;
125 double classificationMaximum() const;
127 void setClassificationMinimumMaximum( double minimum, double maximum );
128
130 double opacity() const;
132 void setOpacity( double opacity );
133
141 DataResamplingMethod dataResamplingMethod() const;
142
148 void setDataResamplingMethod( const DataResamplingMethod &dataResamplingMethod );
149
155 QgsInterpolatedLineWidth edgeStrokeWidth() const;
156
162 void setEdgeStrokeWidth( const QgsInterpolatedLineWidth &strokeWidth );
163
169 Qgis::RenderUnit edgeStrokeWidthUnit() const;
170
176 void setEdgeStrokeWidthUnit( Qgis::RenderUnit edgeStrokeWidthUnit );
177
183 void setLimits( Qgis::MeshRangeLimit limits ) { mRangeLimit = limits; }
184
190 Qgis::MeshRangeLimit limits() const { return mRangeLimit; }
191
197 void setExtent( Qgis::MeshRangeExtent extent ) { mRangeExtent = extent; }
198
204 Qgis::MeshRangeExtent extent() const { return mRangeExtent; }
205
207 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
209 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
210
211 private:
212 void updateShader();
213
214 QgsColorRampShader mColorRampShader;
215 DataResamplingMethod mDataResamplingMethod = DataResamplingMethod::NoResampling;
216 double mClassificationMinimum = 0;
217 double mClassificationMaximum = 0;
218 double mOpacity = 1;
219
220 QgsInterpolatedLineWidth mEdgeStrokeWidth;
221 Qgis::RenderUnit mEdgeStrokeWidthUnit = Qgis::RenderUnit::Millimeters;
222
225};
226
237{
238 public:
239
242 {
243
248
253
258 };
259
263 void setShaftLengthMethod( ArrowScalingMethod shaftLengthMethod );
264
270 double minShaftLength() const;
271
277 void setMinShaftLength( double minShaftLength );
278
284 double maxShaftLength() const;
285
291 void setMaxShaftLength( double maxShaftLength );
292
298 double scaleFactor() const;
299
305 void setScaleFactor( double scaleFactor );
306
312 double fixedShaftLength() const;
313
319 void setFixedShaftLength( double fixedShaftLength );
320
322 double arrowHeadWidthRatio() const;
324 void setArrowHeadWidthRatio( double arrowHeadWidthRatio );
325
327 double arrowHeadLengthRatio() const;
329 void setArrowHeadLengthRatio( double arrowHeadLengthRatio );
330
332 QDomElement writeXml( QDomDocument &doc ) const;
334 void readXml( const QDomElement &elem );
335
336 private:
338 double mMinShaftLength = 0.8; //in millimeters
339 double mMaxShaftLength = 10; //in millimeters
340 double mScaleFactor = 10;
341 double mFixedShaftLength = 20; //in millimeters
342 double mArrowHeadWidthRatio = 0.15;
343 double mArrowHeadLengthRatio = 0.40;
344};
345
356{
357 public:
372
374 SeedingStartPointsMethod seedingMethod() const;
376 void setSeedingMethod( const SeedingStartPointsMethod &seedingMethod );
378 double seedingDensity() const;
380 void setSeedingDensity( double seedingDensity );
382 void readXml( const QDomElement &elem );
384 QDomElement writeXml( QDomDocument &doc ) const;
385
386 private:
387
389 double mSeedingDensity = 0.15;
390};
391
402{
403 public:
404
406 double maximumTailLength() const;
410 int particlesCount() const;
412 void setParticlesCount( int value );
417
419 void readXml( const QDomElement &elem );
421 QDomElement writeXml( QDomDocument &doc ) const;
422
423 private:
424 int mParticlesCount = 1000;
425 double mMaximumTailLength = 100;
426 Qgis::RenderUnit mMaximumTailLengthUnit = Qgis::RenderUnit::Millimeters;
427
428};
429
440{
441 public:
443 enum class WindSpeedUnit
444 {
445 MetersPerSecond = 0,
446 KilometersPerHour,
447 Knots,
448 MilesPerHour,
449 FeetPerSecond,
450 OtherUnit
451 };
452
457 double magnitudeMultiplier() const;
458
462 void setMagnitudeMultiplier( double magnitudeMultiplier );
463
467 double shaftLength() const;
468
472 void setShaftLength( double shaftLength );
473
479 Qgis::RenderUnit shaftLengthUnits() const;
480
486 void setShaftLengthUnits( Qgis::RenderUnit shaftLengthUnit );
487
491 WindSpeedUnit magnitudeUnits() const;
492
496 void setMagnitudeUnits( WindSpeedUnit units );
497
499 QDomElement writeXml( QDomDocument &doc ) const;
501 void readXml( const QDomElement &elem );
502
503 private:
504 double mShaftLength = 10;
506 WindSpeedUnit mMagnitudeUnits = WindSpeedUnit::MetersPerSecond;
507 double mMagnitudeMultiplier = 1;
508};
509
520{
521 public:
522
538
540 double lineWidth() const;
542 void setLineWidth( double lineWidth );
543
545 QColor color() const;
547 void setColor( const QColor &color );
548
555 double filterMin() const;
556
561 void setFilterMin( double filterMin );
562
569 double filterMax() const;
570
575 void setFilterMax( double filterMax );
576
578 bool isOnUserDefinedGrid() const;
580 void setOnUserDefinedGrid( bool enabled );
582 int userGridCellWidth() const;
584 void setUserGridCellWidth( int width );
586 int userGridCellHeight() const;
588 void setUserGridCellHeight( int height );
589
594 Symbology symbology() const;
595
600 void setSymbology( const Symbology &symbology );
601
606 QgsInterpolatedLineColor::ColoringMethod coloringMethod() const;
607
612 void setColoringMethod( const QgsInterpolatedLineColor::ColoringMethod &coloringMethod );
613
618 QgsColorRampShader colorRampShader() const;
619
624 void setColorRampShader( const QgsColorRampShader &colorRampShader );
625
630 QgsInterpolatedLineColor vectorStrokeColoring() const;
631
636 QgsMeshRendererVectorArrowSettings arrowSettings() const;
637
642 void setArrowsSettings( const QgsMeshRendererVectorArrowSettings &arrowSettings );
643
648 QgsMeshRendererVectorStreamlineSettings streamLinesSettings() const;
649
654 void setStreamLinesSettings( const QgsMeshRendererVectorStreamlineSettings &streamLinesSettings );
655
660 QgsMeshRendererVectorTracesSettings tracesSettings() const;
661
666 void setTracesSettings( const QgsMeshRendererVectorTracesSettings &tracesSettings );
667
672 QgsMeshRendererVectorWindBarbSettings windBarbSettings() const;
673
678 void setWindBarbSettings( const QgsMeshRendererVectorWindBarbSettings &windBarbSettings );
679
681 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
683 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
684
685 private:
686
687 Symbology mDisplayingMethod = Arrows;
688
689 double mLineWidth = Qgis::DEFAULT_LINE_WIDTH; //in millimeters
690 QgsColorRampShader mColorRampShader;
691 QColor mColor = Qt::black;
693 double mFilterMin = -1; //disabled
694 double mFilterMax = -1; //disabled
695 int mUserGridCellWidth = 10; // in pixels
696 int mUserGridCellHeight = 10; // in pixels
697 bool mOnUserDefinedGrid = false;
698
700 QgsMeshRendererVectorStreamlineSettings mStreamLinesSettings;
703};
704
714class CORE_EXPORT QgsMeshRendererSettings
715{
716 public:
717
724
727
729
731 QgsMeshRendererMeshSettings nativeMeshSettings() const { return mRendererNativeMeshSettings; }
733 void setNativeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererNativeMeshSettings = settings; }
734
736 QgsMeshRendererMeshSettings triangularMeshSettings() const { return mRendererTriangularMeshSettings; }
738 void setTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererTriangularMeshSettings = settings; }
739
744 QgsMeshRendererMeshSettings edgeMeshSettings() const { return mRendererEdgeMeshSettings; }
745
750 void setEdgeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererEdgeMeshSettings = settings; }
751
753 QgsMeshRendererScalarSettings scalarSettings( int groupIndex ) const { return mRendererScalarSettings.value( groupIndex ); }
754
756 void setScalarSettings( int groupIndex, const QgsMeshRendererScalarSettings &settings ) { mRendererScalarSettings[groupIndex] = settings; }
757
762 bool hasScalarSettings( int groupIndex ) const {return mRendererScalarSettings.contains( groupIndex );}
763
768 bool removeScalarSettings( int groupIndex ) {return mRendererScalarSettings.remove( groupIndex );}
769
771 QgsMeshRendererVectorSettings vectorSettings( int groupIndex ) const { return mRendererVectorSettings.value( groupIndex ); }
773 void setVectorSettings( int groupIndex, const QgsMeshRendererVectorSettings &settings ) { mRendererVectorSettings[groupIndex] = settings; }
774
779 bool hasVectorSettings( int groupIndex ) const {return mRendererVectorSettings.contains( groupIndex );}
780
785 bool removeVectorSettings( int groupIndex ) {return mRendererVectorSettings.remove( groupIndex );}
786
792 QgsMesh3DAveragingMethod *averagingMethod() const;
793
799 void setAveragingMethod( QgsMesh3DAveragingMethod *method );
800
802 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
804 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
805
810 int activeScalarDatasetGroup() const;
811
816 void setActiveScalarDatasetGroup( int activeScalarDatasetGroup );
817
822 int activeVectorDatasetGroup() const;
823
828 void setActiveVectorDatasetGroup( int activeVectorDatasetGroup );
829
835 bool hasSettings( int datasetGroupIndex ) const;
836
837 private:
838 QgsMeshRendererMeshSettings mRendererNativeMeshSettings;
839 QgsMeshRendererMeshSettings mRendererTriangularMeshSettings;
840 QgsMeshRendererMeshSettings mRendererEdgeMeshSettings;
841
842 QHash<int, QgsMeshRendererScalarSettings> mRendererScalarSettings;
843 QHash<int, QgsMeshRendererVectorSettings> mRendererVectorSettings;
844
846 int mActiveScalarDatasetGroup = -1;
847
849 int mActiveVectorDatasetGroup = -1;
850
852 std::shared_ptr<QgsMesh3DAveragingMethod> mAveragingMethod;
853};
854
855#endif //QGSMESHRENDERERSETTINGS_H
static const double DEFAULT_LINE_WIDTH
The default width (in millimeters) for line symbols.
Definition qgis.h:6243
MeshRangeLimit
Describes the limits used to compute mesh ranges (min/max values).
Definition qgis.h:6048
@ NotSet
User defined.
Definition qgis.h:6049
MeshRangeExtent
Describes the extent used to compute mesh ranges (min/max values).
Definition qgis.h:6060
@ WholeMesh
Whole mesh is used to compute statistics.
Definition qgis.h:6061
RenderUnit
Rendering size units.
Definition qgis.h:5183
@ Millimeters
Millimeters.
Definition qgis.h:5184
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Defines color interpolation for rendering mesh datasets.
ColoringMethod
Defines how the color is defined.
@ SingleColor
Render with a single color.
Represents a width that can vary depending on values.
Abstract class for interpolating 3d stacked mesh data to 2d data.
Represents a mesh renderer settings for mesh objects.
void setLineWidthUnit(Qgis::RenderUnit lineWidthUnit)
Sets units of the width of the mesh frame.
void setEnabled(bool enabled)
Sets whether mesh structure rendering is enabled.
QColor color() const
Returns color used for rendering.
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element.
double lineWidth() const
Returns line width used for rendering (in millimeters).
void setLineWidth(double lineWidth)
Sets line width used for rendering (in millimeters).
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
Qgis::RenderUnit lineWidthUnit() const
Returns units of the width of the mesh frame.
bool isEnabled() const
Returns whether mesh structure rendering is enabled.
void setColor(const QColor &color)
Sets color used for rendering of the mesh.
Represents a mesh renderer settings for scalar datasets.
Qgis::MeshRangeExtent extent() const
Returns the mesh extent for minimum maximum calculation.
Qgis::MeshRangeLimit limits() const
Returns the range limits type for minimum maximum calculation.
void setExtent(Qgis::MeshRangeExtent extent)
Sets the mesh extent for minimum maximum calculation.
DataResamplingMethod
Resampling of value from dataset.
@ NoResampling
Does not use resampling.
@ NeighbourAverage
Does a simple average of values defined for all surrounding faces/vertices.
void setLimits(Qgis::MeshRangeLimit limits)
Sets the range limits type for minimum maximum calculation.
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.
QgsMeshRendererSettings()
Constructs renderer with default single layer averaging method.
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 & operator=(const QgsMeshRendererSettings &other)
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().
@ MinMax
Scale vector magnitude linearly to fit in range of vectorFilterMin() and vectorFilterMax().
@ Fixed
Use fixed length fixedShaftLength() regardless of vector's magnitude.
Represents a renderer settings for vector datasets.
Symbology
Defines the symbology of vector rendering.
@ Traces
Displaying vector dataset with particle traces.
@ Arrows
Displaying vector dataset with arrows.
@ WindBarbs
Displaying vector dataset with wind barbs.
@ 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.
@ Random
Seeds start points randomly on the mesh.
@ MeshGridded
Seeds start points on the vertices mesh or user regular grid.
Represents a trace renderer settings for vector datasets displayed by particle traces.
Qgis::RenderUnit maximumTailLengthUnit() const
Returns the maximum tail length unit.
void setMaximumTailLength(double maximumTailLength)
Sets the maximums tail length.
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element.
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
void setMaximumTailLengthUnit(Qgis::RenderUnit maximumTailLengthUnit)
Sets the maximum tail length unit.
double maximumTailLength() const
Returns the maximum tail length.
int particlesCount() const
Returns particles count.
void setParticlesCount(int value)
Sets particles count.
Represents a mesh renderer settings for vector datasets displayed with wind barbs.
WindSpeedUnit
Wind speed units. Wind barbs use knots so we use this enum for preset conversion values.
A container for the context for various read/write operations on objects.
#define SIP_SKIP
Definition qgis_sip.h:134