QGIS API Documentation 3.37.0-Master (684a802617f)
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
445 Qgis::RenderUnit shaftLengthUnits();
446
450 void setShaftLengthUnits( Qgis::RenderUnit shaftLengthUnit );
451
455 WindSpeedUnit magnitudeUnits() const;
456
460 void setMagnitudeUnits( WindSpeedUnit units );
461
463 QDomElement writeXml( QDomDocument &doc ) const;
465 void readXml( const QDomElement &elem );
466
467 private:
468 double mShaftLength = 10;
470 WindSpeedUnit mMagnitudeUnits = WindSpeedUnit::MetersPerSecond;
471 double mMagnitudeMultiplier = 1;
472};
473
484{
485 public:
486
492 {
494 Arrows = 0,
500 WindBarbs
501 };
502
504 double lineWidth() const;
506 void setLineWidth( double lineWidth );
507
509 QColor color() const;
511 void setColor( const QColor &color );
512
519 double filterMin() const;
520
525 void setFilterMin( double filterMin );
526
533 double filterMax() const;
534
539 void setFilterMax( double filterMax );
540
542 bool isOnUserDefinedGrid() const;
544 void setOnUserDefinedGrid( bool enabled );
546 int userGridCellWidth() const;
548 void setUserGridCellWidth( int width );
550 int userGridCellHeight() const;
552 void setUserGridCellHeight( int height );
553
558 Symbology symbology() const;
559
564 void setSymbology( const Symbology &symbology );
565
570 QgsInterpolatedLineColor::ColoringMethod coloringMethod() const;
571
576 void setColoringMethod( const QgsInterpolatedLineColor::ColoringMethod &coloringMethod );
577
582 QgsColorRampShader colorRampShader() const;
583
588 void setColorRampShader( const QgsColorRampShader &colorRampShader );
589
594 QgsInterpolatedLineColor vectorStrokeColoring() const;
595
600 QgsMeshRendererVectorArrowSettings arrowSettings() const;
601
606 void setArrowsSettings( const QgsMeshRendererVectorArrowSettings &arrowSettings );
607
612 QgsMeshRendererVectorStreamlineSettings streamLinesSettings() const;
613
618 void setStreamLinesSettings( const QgsMeshRendererVectorStreamlineSettings &streamLinesSettings );
619
624 QgsMeshRendererVectorTracesSettings tracesSettings() const;
625
630 void setTracesSettings( const QgsMeshRendererVectorTracesSettings &tracesSettings );
631
636 QgsMeshRendererVectorWindBarbSettings windBarbSettings() const;
637
642 void setWindBarbSettings( const QgsMeshRendererVectorWindBarbSettings &windBarbSettings );
643
645 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
647 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
648
649 private:
650
651 Symbology mDisplayingMethod = Arrows;
652
653 double mLineWidth = DEFAULT_LINE_WIDTH; //in millimeters
654 QgsColorRampShader mColorRampShader;
655 QColor mColor = Qt::black;
657 double mFilterMin = -1; //disabled
658 double mFilterMax = -1; //disabled
659 int mUserGridCellWidth = 10; // in pixels
660 int mUserGridCellHeight = 10; // in pixels
661 bool mOnUserDefinedGrid = false;
662
664 QgsMeshRendererVectorStreamlineSettings mStreamLinesSettings;
667};
668
678class CORE_EXPORT QgsMeshRendererSettings
679{
680 public:
681
688
690 QgsMeshRendererMeshSettings nativeMeshSettings() const { return mRendererNativeMeshSettings; }
692 void setNativeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererNativeMeshSettings = settings; }
693
695 QgsMeshRendererMeshSettings triangularMeshSettings() const { return mRendererTriangularMeshSettings; }
697 void setTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererTriangularMeshSettings = settings; }
698
703 QgsMeshRendererMeshSettings edgeMeshSettings() const { return mRendererEdgeMeshSettings; }
704
709 void setEdgeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererEdgeMeshSettings = settings; }
710
712 QgsMeshRendererScalarSettings scalarSettings( int groupIndex ) const { return mRendererScalarSettings.value( groupIndex ); }
713
715 void setScalarSettings( int groupIndex, const QgsMeshRendererScalarSettings &settings ) { mRendererScalarSettings[groupIndex] = settings; }
716
721 bool hasScalarSettings( int groupIndex ) const {return mRendererScalarSettings.contains( groupIndex );}
722
727 bool removeScalarSettings( int groupIndex ) {return mRendererScalarSettings.remove( groupIndex );}
728
730 QgsMeshRendererVectorSettings vectorSettings( int groupIndex ) const { return mRendererVectorSettings.value( groupIndex ); }
732 void setVectorSettings( int groupIndex, const QgsMeshRendererVectorSettings &settings ) { mRendererVectorSettings[groupIndex] = settings; }
733
738 bool hasVectorSettings( int groupIndex ) const {return mRendererVectorSettings.contains( groupIndex );}
739
744 bool removeVectorSettings( int groupIndex ) {return mRendererVectorSettings.remove( groupIndex );}
745
751 QgsMesh3DAveragingMethod *averagingMethod() const;
752
758 void setAveragingMethod( QgsMesh3DAveragingMethod *method );
759
761 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
763 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
764
769 int activeScalarDatasetGroup() const;
770
775 void setActiveScalarDatasetGroup( int activeScalarDatasetGroup );
776
781 int activeVectorDatasetGroup() const;
782
787 void setActiveVectorDatasetGroup( int activeVectorDatasetGroup );
788
794 bool hasSettings( int datasetGroupIndex ) const;
795
796 private:
797 QgsMeshRendererMeshSettings mRendererNativeMeshSettings;
798 QgsMeshRendererMeshSettings mRendererTriangularMeshSettings;
799 QgsMeshRendererMeshSettings mRendererEdgeMeshSettings;
800
801 QHash<int, QgsMeshRendererScalarSettings> mRendererScalarSettings;
802 QHash<int, QgsMeshRendererVectorSettings> mRendererVectorSettings;
803
805 int mActiveScalarDatasetGroup = -1;
806
808 int mActiveVectorDatasetGroup = -1;
809
811 std::shared_ptr<QgsMesh3DAveragingMethod> mAveragingMethod;
812};
813
814#endif //QGSMESHRENDERERSETTINGS_H
RenderUnit
Rendering size units.
Definition qgis.h:4489
@ 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.
~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()
@ 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:5978