QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 <QColor>
22#include <QDomElement>
23
24#include "qgis_core.h"
25#include "qgis.h"
26#include "qgscolorrampshader.h"
27#include "qgsmesh3daveraging.h"
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
62 Qgis::RenderUnit lineWidthUnit() const;
63
69 void setLineWidthUnit( Qgis::RenderUnit lineWidthUnit );
70
72 QDomElement writeXml( QDomDocument &doc ) const;
74 void readXml( const QDomElement &elem );
75
76 private:
77 bool mEnabled = false;
78 double mLineWidth = DEFAULT_LINE_WIDTH;
80 QColor mColor = Qt::black;
81};
82
93{
94 public:
95
104 {
105
109 NoResampling = 0,
110
115 };
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
215 static QString limitsString( Qgis::MeshRangeLimit limits );
216
218 static Qgis::MeshRangeLimit limitsFromString( const QString &limits );
219
221 static QString extentString( Qgis::MeshRangeExtent extent );
222
224 static Qgis::MeshRangeExtent extentFromString( const QString &extent );
225
226
227 QgsColorRampShader mColorRampShader;
228 DataResamplingMethod mDataResamplingMethod = DataResamplingMethod::NoResampling;
229 double mClassificationMinimum = 0;
230 double mClassificationMaximum = 0;
231 double mOpacity = 1;
232
233 QgsInterpolatedLineWidth mEdgeStrokeWidth;
234 Qgis::RenderUnit mEdgeStrokeWidthUnit = Qgis::RenderUnit::Millimeters;
235
238};
239
250{
251 public:
252
255 {
256
260 MinMax = 0,
261
266
270 Fixed
271 };
272
276 void setShaftLengthMethod( ArrowScalingMethod shaftLengthMethod );
277
283 double minShaftLength() const;
284
290 void setMinShaftLength( double minShaftLength );
291
297 double maxShaftLength() const;
298
304 void setMaxShaftLength( double maxShaftLength );
305
311 double scaleFactor() const;
312
318 void setScaleFactor( double scaleFactor );
319
325 double fixedShaftLength() const;
326
332 void setFixedShaftLength( double fixedShaftLength );
333
335 double arrowHeadWidthRatio() const;
337 void setArrowHeadWidthRatio( double arrowHeadWidthRatio );
338
340 double arrowHeadLengthRatio() const;
342 void setArrowHeadLengthRatio( double arrowHeadLengthRatio );
343
345 QDomElement writeXml( QDomDocument &doc ) const;
347 void readXml( const QDomElement &elem );
348
349 private:
351 double mMinShaftLength = 0.8; //in millimeters
352 double mMaxShaftLength = 10; //in millimeters
353 double mScaleFactor = 10;
354 double mFixedShaftLength = 20; //in millimeters
355 double mArrowHeadWidthRatio = 0.15;
356 double mArrowHeadLengthRatio = 0.40;
357};
358
369{
370 public:
373 {
374
378 MeshGridded = 0,
379
383 Random
384 };
385
387 SeedingStartPointsMethod seedingMethod() const;
389 void setSeedingMethod( const SeedingStartPointsMethod &seedingMethod );
391 double seedingDensity() const;
393 void setSeedingDensity( double seedingDensity );
395 void readXml( const QDomElement &elem );
397 QDomElement writeXml( QDomDocument &doc ) const;
398
399 private:
400
402 double mSeedingDensity = 0.15;
403};
404
415{
416 public:
417
419 double maximumTailLength() const;
421 void setMaximumTailLength( double maximumTailLength );
423 int particlesCount() const;
425 void setParticlesCount( int value );
427 Qgis::RenderUnit maximumTailLengthUnit() const;
429 void setMaximumTailLengthUnit( Qgis::RenderUnit maximumTailLengthUnit );
430
432 void readXml( const QDomElement &elem );
434 QDomElement writeXml( QDomDocument &doc ) const;
435
436 private:
437 int mParticlesCount = 1000;
438 double mMaximumTailLength = 100;
439 Qgis::RenderUnit mMaximumTailLengthUnit = Qgis::RenderUnit::Millimeters;
440
441};
442
453{
454 public:
456 enum class WindSpeedUnit
457 {
458 MetersPerSecond = 0,
459 KilometersPerHour,
460 Knots,
461 MilesPerHour,
462 FeetPerSecond,
463 OtherUnit
464 };
465
470 double magnitudeMultiplier() const;
471
475 void setMagnitudeMultiplier( double magnitudeMultiplier );
476
480 double shaftLength() const;
481
485 void setShaftLength( double shaftLength );
486
492 Qgis::RenderUnit shaftLengthUnits() const;
493
499 void setShaftLengthUnits( Qgis::RenderUnit shaftLengthUnit );
500
504 WindSpeedUnit magnitudeUnits() const;
505
509 void setMagnitudeUnits( WindSpeedUnit units );
510
512 QDomElement writeXml( QDomDocument &doc ) const;
514 void readXml( const QDomElement &elem );
515
516 private:
517 double mShaftLength = 10;
519 WindSpeedUnit mMagnitudeUnits = WindSpeedUnit::MetersPerSecond;
520 double mMagnitudeMultiplier = 1;
521};
522
533{
534 public:
535
541 {
543 Arrows = 0,
549 WindBarbs
550 };
551
553 double lineWidth() const;
555 void setLineWidth( double lineWidth );
556
558 QColor color() const;
560 void setColor( const QColor &color );
561
568 double filterMin() const;
569
574 void setFilterMin( double filterMin );
575
582 double filterMax() const;
583
588 void setFilterMax( double filterMax );
589
591 bool isOnUserDefinedGrid() const;
593 void setOnUserDefinedGrid( bool enabled );
595 int userGridCellWidth() const;
597 void setUserGridCellWidth( int width );
599 int userGridCellHeight() const;
601 void setUserGridCellHeight( int height );
602
607 Symbology symbology() const;
608
613 void setSymbology( const Symbology &symbology );
614
619 QgsInterpolatedLineColor::ColoringMethod coloringMethod() const;
620
625 void setColoringMethod( const QgsInterpolatedLineColor::ColoringMethod &coloringMethod );
626
631 QgsColorRampShader colorRampShader() const;
632
637 void setColorRampShader( const QgsColorRampShader &colorRampShader );
638
643 QgsInterpolatedLineColor vectorStrokeColoring() const;
644
649 QgsMeshRendererVectorArrowSettings arrowSettings() const;
650
655 void setArrowsSettings( const QgsMeshRendererVectorArrowSettings &arrowSettings );
656
661 QgsMeshRendererVectorStreamlineSettings streamLinesSettings() const;
662
667 void setStreamLinesSettings( const QgsMeshRendererVectorStreamlineSettings &streamLinesSettings );
668
673 QgsMeshRendererVectorTracesSettings tracesSettings() const;
674
679 void setTracesSettings( const QgsMeshRendererVectorTracesSettings &tracesSettings );
680
685 QgsMeshRendererVectorWindBarbSettings windBarbSettings() const;
686
691 void setWindBarbSettings( const QgsMeshRendererVectorWindBarbSettings &windBarbSettings );
692
694 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
696 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
697
698 private:
699
700 Symbology mDisplayingMethod = Arrows;
701
702 double mLineWidth = DEFAULT_LINE_WIDTH; //in millimeters
703 QgsColorRampShader mColorRampShader;
704 QColor mColor = Qt::black;
706 double mFilterMin = -1; //disabled
707 double mFilterMax = -1; //disabled
708 int mUserGridCellWidth = 10; // in pixels
709 int mUserGridCellHeight = 10; // in pixels
710 bool mOnUserDefinedGrid = false;
711
713 QgsMeshRendererVectorStreamlineSettings mStreamLinesSettings;
716};
717
727class CORE_EXPORT QgsMeshRendererSettings
728{
729 public:
730
736
738 QgsMeshRendererMeshSettings nativeMeshSettings() const { return mRendererNativeMeshSettings; }
740 void setNativeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererNativeMeshSettings = settings; }
741
743 QgsMeshRendererMeshSettings triangularMeshSettings() const { return mRendererTriangularMeshSettings; }
745 void setTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererTriangularMeshSettings = settings; }
746
751 QgsMeshRendererMeshSettings edgeMeshSettings() const { return mRendererEdgeMeshSettings; }
752
757 void setEdgeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererEdgeMeshSettings = settings; }
758
760 QgsMeshRendererScalarSettings scalarSettings( int groupIndex ) const { return mRendererScalarSettings.value( groupIndex ); }
761
763 void setScalarSettings( int groupIndex, const QgsMeshRendererScalarSettings &settings ) { mRendererScalarSettings[groupIndex] = settings; }
764
769 bool hasScalarSettings( int groupIndex ) const {return mRendererScalarSettings.contains( groupIndex );}
770
775 bool removeScalarSettings( int groupIndex ) {return mRendererScalarSettings.remove( groupIndex );}
776
778 QgsMeshRendererVectorSettings vectorSettings( int groupIndex ) const { return mRendererVectorSettings.value( groupIndex ); }
780 void setVectorSettings( int groupIndex, const QgsMeshRendererVectorSettings &settings ) { mRendererVectorSettings[groupIndex] = settings; }
781
786 bool hasVectorSettings( int groupIndex ) const {return mRendererVectorSettings.contains( groupIndex );}
787
792 bool removeVectorSettings( int groupIndex ) {return mRendererVectorSettings.remove( groupIndex );}
793
799 QgsMesh3DAveragingMethod *averagingMethod() const;
800
806 void setAveragingMethod( QgsMesh3DAveragingMethod *method );
807
809 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
811 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
812
817 int activeScalarDatasetGroup() const;
818
823 void setActiveScalarDatasetGroup( int activeScalarDatasetGroup );
824
829 int activeVectorDatasetGroup() const;
830
835 void setActiveVectorDatasetGroup( int activeVectorDatasetGroup );
836
842 bool hasSettings( int datasetGroupIndex ) const;
843
844 private:
845 QgsMeshRendererMeshSettings mRendererNativeMeshSettings;
846 QgsMeshRendererMeshSettings mRendererTriangularMeshSettings;
847 QgsMeshRendererMeshSettings mRendererEdgeMeshSettings;
848
849 QHash<int, QgsMeshRendererScalarSettings> mRendererScalarSettings;
850 QHash<int, QgsMeshRendererVectorSettings> mRendererVectorSettings;
851
853 int mActiveScalarDatasetGroup = -1;
854
856 int mActiveVectorDatasetGroup = -1;
857
859 std::shared_ptr<QgsMesh3DAveragingMethod> mAveragingMethod;
860};
861
862#endif //QGSMESHRENDERERSETTINGS_H
MeshRangeLimit
Describes the limits used to compute mesh ranges (min/max values).
Definition qgis.h:5705
@ NotSet
User defined.
MeshRangeExtent
Describes the extent used to compute mesh ranges (min/max values).
Definition qgis.h:5717
@ WholeMesh
Whole mesh is used to compute statistics.
RenderUnit
Rendering size units.
Definition qgis.h:4910
@ Millimeters
Millimeters.
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.
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.
@ 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.
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.
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()
Represents a renderer settings for vector datasets.
Symbology
Defines the symbology of vector rendering.
@ Traces
Displaying vector dataset with particle traces.
@ 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.
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.
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:6599