QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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#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;
81 QColor mColor = Qt::black;
82};
83
94{
95 public:
96
105 {
106
110 NoResampling = 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::NoResampling;
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:
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:
411 enum class WindSpeedUnit
412 {
413 MetersPerSecond = 0,
414 KilometersPerHour,
415 Knots,
416 MilesPerHour,
417 FeetPerSecond,
418 OtherUnit
419 };
420
425 double magnitudeMultiplier() const;
426
430 void setMagnitudeMultiplier( double magnitudeMultiplier );
431
435 double shaftLength() const;
436
440 void setShaftLength( double shaftLength );
441
447 Qgis::RenderUnit shaftLengthUnits() const;
448
454 void setShaftLengthUnits( Qgis::RenderUnit shaftLengthUnit );
455
459 WindSpeedUnit magnitudeUnits() const;
460
464 void setMagnitudeUnits( WindSpeedUnit units );
465
467 QDomElement writeXml( QDomDocument &doc ) const;
469 void readXml( const QDomElement &elem );
470
471 private:
472 double mShaftLength = 10;
474 WindSpeedUnit mMagnitudeUnits = WindSpeedUnit::MetersPerSecond;
475 double mMagnitudeMultiplier = 1;
476};
477
488{
489 public:
490
496 {
498 Arrows = 0,
504 WindBarbs
505 };
506
508 double lineWidth() const;
510 void setLineWidth( double lineWidth );
511
513 QColor color() const;
515 void setColor( const QColor &color );
516
523 double filterMin() const;
524
529 void setFilterMin( double filterMin );
530
537 double filterMax() const;
538
543 void setFilterMax( double filterMax );
544
546 bool isOnUserDefinedGrid() const;
548 void setOnUserDefinedGrid( bool enabled );
550 int userGridCellWidth() const;
552 void setUserGridCellWidth( int width );
554 int userGridCellHeight() const;
556 void setUserGridCellHeight( int height );
557
562 Symbology symbology() const;
563
568 void setSymbology( const Symbology &symbology );
569
574 QgsInterpolatedLineColor::ColoringMethod coloringMethod() const;
575
580 void setColoringMethod( const QgsInterpolatedLineColor::ColoringMethod &coloringMethod );
581
586 QgsColorRampShader colorRampShader() const;
587
592 void setColorRampShader( const QgsColorRampShader &colorRampShader );
593
598 QgsInterpolatedLineColor vectorStrokeColoring() const;
599
604 QgsMeshRendererVectorArrowSettings arrowSettings() const;
605
610 void setArrowsSettings( const QgsMeshRendererVectorArrowSettings &arrowSettings );
611
616 QgsMeshRendererVectorStreamlineSettings streamLinesSettings() const;
617
622 void setStreamLinesSettings( const QgsMeshRendererVectorStreamlineSettings &streamLinesSettings );
623
628 QgsMeshRendererVectorTracesSettings tracesSettings() const;
629
634 void setTracesSettings( const QgsMeshRendererVectorTracesSettings &tracesSettings );
635
640 QgsMeshRendererVectorWindBarbSettings windBarbSettings() const;
641
646 void setWindBarbSettings( const QgsMeshRendererVectorWindBarbSettings &windBarbSettings );
647
649 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
651 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
652
653 private:
654
655 Symbology mDisplayingMethod = Arrows;
656
657 double mLineWidth = DEFAULT_LINE_WIDTH; //in millimeters
658 QgsColorRampShader mColorRampShader;
659 QColor mColor = Qt::black;
661 double mFilterMin = -1; //disabled
662 double mFilterMax = -1; //disabled
663 int mUserGridCellWidth = 10; // in pixels
664 int mUserGridCellHeight = 10; // in pixels
665 bool mOnUserDefinedGrid = false;
666
668 QgsMeshRendererVectorStreamlineSettings mStreamLinesSettings;
671};
672
682class CORE_EXPORT QgsMeshRendererSettings
683{
684 public:
685
691
693 QgsMeshRendererMeshSettings nativeMeshSettings() const { return mRendererNativeMeshSettings; }
695 void setNativeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererNativeMeshSettings = settings; }
696
698 QgsMeshRendererMeshSettings triangularMeshSettings() const { return mRendererTriangularMeshSettings; }
700 void setTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererTriangularMeshSettings = settings; }
701
706 QgsMeshRendererMeshSettings edgeMeshSettings() const { return mRendererEdgeMeshSettings; }
707
712 void setEdgeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererEdgeMeshSettings = settings; }
713
715 QgsMeshRendererScalarSettings scalarSettings( int groupIndex ) const { return mRendererScalarSettings.value( groupIndex ); }
716
718 void setScalarSettings( int groupIndex, const QgsMeshRendererScalarSettings &settings ) { mRendererScalarSettings[groupIndex] = settings; }
719
724 bool hasScalarSettings( int groupIndex ) const {return mRendererScalarSettings.contains( groupIndex );}
725
730 bool removeScalarSettings( int groupIndex ) {return mRendererScalarSettings.remove( groupIndex );}
731
733 QgsMeshRendererVectorSettings vectorSettings( int groupIndex ) const { return mRendererVectorSettings.value( groupIndex ); }
735 void setVectorSettings( int groupIndex, const QgsMeshRendererVectorSettings &settings ) { mRendererVectorSettings[groupIndex] = settings; }
736
741 bool hasVectorSettings( int groupIndex ) const {return mRendererVectorSettings.contains( groupIndex );}
742
747 bool removeVectorSettings( int groupIndex ) {return mRendererVectorSettings.remove( groupIndex );}
748
754 QgsMesh3DAveragingMethod *averagingMethod() const;
755
761 void setAveragingMethod( QgsMesh3DAveragingMethod *method );
762
764 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
766 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
767
772 int activeScalarDatasetGroup() const;
773
778 void setActiveScalarDatasetGroup( int activeScalarDatasetGroup );
779
784 int activeVectorDatasetGroup() const;
785
790 void setActiveVectorDatasetGroup( int activeVectorDatasetGroup );
791
797 bool hasSettings( int datasetGroupIndex ) const;
798
799 private:
800 QgsMeshRendererMeshSettings mRendererNativeMeshSettings;
801 QgsMeshRendererMeshSettings mRendererTriangularMeshSettings;
802 QgsMeshRendererMeshSettings mRendererEdgeMeshSettings;
803
804 QHash<int, QgsMeshRendererScalarSettings> mRendererScalarSettings;
805 QHash<int, QgsMeshRendererVectorSettings> mRendererVectorSettings;
806
808 int mActiveScalarDatasetGroup = -1;
809
811 int mActiveVectorDatasetGroup = -1;
812
814 std::shared_ptr<QgsMesh3DAveragingMethod> mAveragingMethod;
815};
816
817#endif //QGSMESHRENDERERSETTINGS_H
RenderUnit
Rendering size units.
Definition qgis.h:4839
@ 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.
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.
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:6450