QGIS API Documentation 3.41.0-Master (02257426e5a)
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
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
247 MinMax = 0,
248
253
257 Fixed
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:
360 {
361
365 MeshGridded = 0,
366
370 Random
371 };
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;
408 void setMaximumTailLength( double maximumTailLength );
410 int particlesCount() const;
412 void setParticlesCount( int value );
414 Qgis::RenderUnit maximumTailLengthUnit() const;
416 void setMaximumTailLengthUnit( Qgis::RenderUnit maximumTailLengthUnit );
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
528 {
530 Arrows = 0,
536 WindBarbs
537 };
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 = 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
723
725 QgsMeshRendererMeshSettings nativeMeshSettings() const { return mRendererNativeMeshSettings; }
727 void setNativeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererNativeMeshSettings = settings; }
728
730 QgsMeshRendererMeshSettings triangularMeshSettings() const { return mRendererTriangularMeshSettings; }
732 void setTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererTriangularMeshSettings = settings; }
733
738 QgsMeshRendererMeshSettings edgeMeshSettings() const { return mRendererEdgeMeshSettings; }
739
744 void setEdgeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererEdgeMeshSettings = settings; }
745
747 QgsMeshRendererScalarSettings scalarSettings( int groupIndex ) const { return mRendererScalarSettings.value( groupIndex ); }
748
750 void setScalarSettings( int groupIndex, const QgsMeshRendererScalarSettings &settings ) { mRendererScalarSettings[groupIndex] = settings; }
751
756 bool hasScalarSettings( int groupIndex ) const {return mRendererScalarSettings.contains( groupIndex );}
757
762 bool removeScalarSettings( int groupIndex ) {return mRendererScalarSettings.remove( groupIndex );}
763
765 QgsMeshRendererVectorSettings vectorSettings( int groupIndex ) const { return mRendererVectorSettings.value( groupIndex ); }
767 void setVectorSettings( int groupIndex, const QgsMeshRendererVectorSettings &settings ) { mRendererVectorSettings[groupIndex] = settings; }
768
773 bool hasVectorSettings( int groupIndex ) const {return mRendererVectorSettings.contains( groupIndex );}
774
779 bool removeVectorSettings( int groupIndex ) {return mRendererVectorSettings.remove( groupIndex );}
780
786 QgsMesh3DAveragingMethod *averagingMethod() const;
787
793 void setAveragingMethod( QgsMesh3DAveragingMethod *method );
794
796 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
798 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
799
804 int activeScalarDatasetGroup() const;
805
810 void setActiveScalarDatasetGroup( int activeScalarDatasetGroup );
811
816 int activeVectorDatasetGroup() const;
817
822 void setActiveVectorDatasetGroup( int activeVectorDatasetGroup );
823
829 bool hasSettings( int datasetGroupIndex ) const;
830
831 private:
832 QgsMeshRendererMeshSettings mRendererNativeMeshSettings;
833 QgsMeshRendererMeshSettings mRendererTriangularMeshSettings;
834 QgsMeshRendererMeshSettings mRendererEdgeMeshSettings;
835
836 QHash<int, QgsMeshRendererScalarSettings> mRendererScalarSettings;
837 QHash<int, QgsMeshRendererVectorSettings> mRendererVectorSettings;
838
840 int mActiveScalarDatasetGroup = -1;
841
843 int mActiveVectorDatasetGroup = -1;
844
846 std::shared_ptr<QgsMesh3DAveragingMethod> mAveragingMethod;
847};
848
849#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:6624