QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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:
115
117 QgsColorRampShader colorRampShader() const;
119 void setColorRampShader( const QgsColorRampShader &shader );
120
122 double classificationMinimum() const;
124 double classificationMaximum() const;
126 void setClassificationMinimumMaximum( double minimum, double maximum );
127
129 double opacity() const;
131 void setOpacity( double opacity );
132
140 DataResamplingMethod dataResamplingMethod() const;
141
147 void setDataResamplingMethod( const DataResamplingMethod &dataResamplingMethod );
148
154 QgsInterpolatedLineWidth edgeStrokeWidth() const;
155
161 void setEdgeStrokeWidth( const QgsInterpolatedLineWidth &strokeWidth );
162
168 Qgis::RenderUnit edgeStrokeWidthUnit() const;
169
175 void setEdgeStrokeWidthUnit( Qgis::RenderUnit edgeStrokeWidthUnit );
176
182 void setLimits( Qgis::MeshRangeLimit limits ) { mRangeLimit = limits; }
183
189 Qgis::MeshRangeLimit limits() const { return mRangeLimit; }
190
196 void setExtent( Qgis::MeshRangeExtent extent ) { mRangeExtent = extent; }
197
203 Qgis::MeshRangeExtent extent() const { return mRangeExtent; }
204
206 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
208 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
209
210 private:
211 void updateShader();
212
213 QgsColorRampShader mColorRampShader;
214 DataResamplingMethod mDataResamplingMethod = DataResamplingMethod::NoResampling;
215 double mClassificationMinimum = 0;
216 double mClassificationMaximum = 0;
217 double mOpacity = 1;
218
219 QgsInterpolatedLineWidth mEdgeStrokeWidth;
220 Qgis::RenderUnit mEdgeStrokeWidthUnit = Qgis::RenderUnit::Millimeters;
221
224};
225
236{
237 public:
240 {
241
246
251
256 };
257
261 void setShaftLengthMethod( ArrowScalingMethod shaftLengthMethod );
262
268 double minShaftLength() const;
269
275 void setMinShaftLength( double minShaftLength );
276
282 double maxShaftLength() const;
283
289 void setMaxShaftLength( double maxShaftLength );
290
296 double scaleFactor() const;
297
303 void setScaleFactor( double scaleFactor );
304
310 double fixedShaftLength() const;
311
317 void setFixedShaftLength( double fixedShaftLength );
318
320 double arrowHeadWidthRatio() const;
322 void setArrowHeadWidthRatio( double arrowHeadWidthRatio );
323
325 double arrowHeadLengthRatio() const;
327 void setArrowHeadLengthRatio( double arrowHeadLengthRatio );
328
330 QDomElement writeXml( QDomDocument &doc ) const;
332 void readXml( const QDomElement &elem );
333
334 private:
336 double mMinShaftLength = 0.8; //in millimeters
337 double mMaxShaftLength = 10; //in millimeters
338 double mScaleFactor = 10;
339 double mFixedShaftLength = 20; //in millimeters
340 double mArrowHeadWidthRatio = 0.15;
341 double mArrowHeadLengthRatio = 0.40;
342};
343
354{
355 public:
370
372 SeedingStartPointsMethod seedingMethod() const;
374 void setSeedingMethod( const SeedingStartPointsMethod &seedingMethod );
376 double seedingDensity() const;
378 void setSeedingDensity( double seedingDensity );
380 void readXml( const QDomElement &elem );
382 QDomElement writeXml( QDomDocument &doc ) const;
383
384 private:
386 double mSeedingDensity = 0.15;
387};
388
399{
400 public:
402 double maximumTailLength() const;
406 int particlesCount() const;
408 void setParticlesCount( int value );
413
415 void readXml( const QDomElement &elem );
417 QDomElement writeXml( QDomDocument &doc ) const;
418
419 private:
420 int mParticlesCount = 1000;
421 double mMaximumTailLength = 100;
422 Qgis::RenderUnit mMaximumTailLengthUnit = Qgis::RenderUnit::Millimeters;
423};
424
435{
436 public:
438 enum class WindSpeedUnit
439 {
440 MetersPerSecond = 0,
441 KilometersPerHour,
442 Knots,
443 MilesPerHour,
444 FeetPerSecond,
445 OtherUnit
446 };
447
452 double magnitudeMultiplier() const;
453
457 void setMagnitudeMultiplier( double magnitudeMultiplier );
458
462 double shaftLength() const;
463
467 void setShaftLength( double shaftLength );
468
474 Qgis::RenderUnit shaftLengthUnits() const;
475
481 void setShaftLengthUnits( Qgis::RenderUnit shaftLengthUnit );
482
486 WindSpeedUnit magnitudeUnits() const;
487
491 void setMagnitudeUnits( WindSpeedUnit units );
492
494 QDomElement writeXml( QDomDocument &doc ) const;
496 void readXml( const QDomElement &elem );
497
498 private:
499 double mShaftLength = 10;
501 WindSpeedUnit mMagnitudeUnits = WindSpeedUnit::MetersPerSecond;
502 double mMagnitudeMultiplier = 1;
503};
504
515{
516 public:
532
534 double lineWidth() const;
536 void setLineWidth( double lineWidth );
537
539 QColor color() const;
541 void setColor( const QColor &color );
542
549 double filterMin() const;
550
555 void setFilterMin( double filterMin );
556
563 double filterMax() const;
564
569 void setFilterMax( double filterMax );
570
572 bool isOnUserDefinedGrid() const;
574 void setOnUserDefinedGrid( bool enabled );
576 int userGridCellWidth() const;
578 void setUserGridCellWidth( int width );
580 int userGridCellHeight() const;
582 void setUserGridCellHeight( int height );
583
588 Symbology symbology() const;
589
594 void setSymbology( const Symbology &symbology );
595
600 QgsInterpolatedLineColor::ColoringMethod coloringMethod() const;
601
606 void setColoringMethod( const QgsInterpolatedLineColor::ColoringMethod &coloringMethod );
607
612 QgsColorRampShader colorRampShader() const;
613
618 void setColorRampShader( const QgsColorRampShader &colorRampShader );
619
624 QgsInterpolatedLineColor vectorStrokeColoring() const;
625
630 QgsMeshRendererVectorArrowSettings arrowSettings() const;
631
636 void setArrowsSettings( const QgsMeshRendererVectorArrowSettings &arrowSettings );
637
642 QgsMeshRendererVectorStreamlineSettings streamLinesSettings() const;
643
648 void setStreamLinesSettings( const QgsMeshRendererVectorStreamlineSettings &streamLinesSettings );
649
654 QgsMeshRendererVectorTracesSettings tracesSettings() const;
655
660 void setTracesSettings( const QgsMeshRendererVectorTracesSettings &tracesSettings );
661
666 QgsMeshRendererVectorWindBarbSettings windBarbSettings() const;
667
672 void setWindBarbSettings( const QgsMeshRendererVectorWindBarbSettings &windBarbSettings );
673
675 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
677 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
678
679 private:
680 Symbology mDisplayingMethod = Arrows;
681
682 double mLineWidth = Qgis::DEFAULT_LINE_WIDTH; //in millimeters
683 QgsColorRampShader mColorRampShader;
684 QColor mColor = Qt::black;
686 double mFilterMin = -1; //disabled
687 double mFilterMax = -1; //disabled
688 int mUserGridCellWidth = 10; // in pixels
689 int mUserGridCellHeight = 10; // in pixels
690 bool mOnUserDefinedGrid = false;
691
693 QgsMeshRendererVectorStreamlineSettings mStreamLinesSettings;
696};
697
707class CORE_EXPORT QgsMeshRendererSettings
708{
709 public:
716
719
721
723 QgsMeshRendererMeshSettings nativeMeshSettings() const { return mRendererNativeMeshSettings; }
725 void setNativeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererNativeMeshSettings = settings; }
726
728 QgsMeshRendererMeshSettings triangularMeshSettings() const { return mRendererTriangularMeshSettings; }
730 void setTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererTriangularMeshSettings = settings; }
731
736 QgsMeshRendererMeshSettings edgeMeshSettings() const { return mRendererEdgeMeshSettings; }
737
742 void setEdgeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererEdgeMeshSettings = settings; }
743
745 QgsMeshRendererScalarSettings scalarSettings( int groupIndex ) const { return mRendererScalarSettings.value( groupIndex ); }
746
748 void setScalarSettings( int groupIndex, const QgsMeshRendererScalarSettings &settings ) { mRendererScalarSettings[groupIndex] = settings; }
749
754 bool hasScalarSettings( int groupIndex ) const { return mRendererScalarSettings.contains( groupIndex ); }
755
760 bool removeScalarSettings( int groupIndex ) { return mRendererScalarSettings.remove( groupIndex ); }
761
763 QgsMeshRendererVectorSettings vectorSettings( int groupIndex ) const { return mRendererVectorSettings.value( groupIndex ); }
765 void setVectorSettings( int groupIndex, const QgsMeshRendererVectorSettings &settings ) { mRendererVectorSettings[groupIndex] = settings; }
766
771 bool hasVectorSettings( int groupIndex ) const { return mRendererVectorSettings.contains( groupIndex ); }
772
777 bool removeVectorSettings( int groupIndex ) { return mRendererVectorSettings.remove( groupIndex ); }
778
784 QgsMesh3DAveragingMethod *averagingMethod() const;
785
791 void setAveragingMethod( QgsMesh3DAveragingMethod *method );
792
794 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
796 void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
797
802 int activeScalarDatasetGroup() const;
803
808 void setActiveScalarDatasetGroup( int activeScalarDatasetGroup );
809
814 int activeVectorDatasetGroup() const;
815
820 void setActiveVectorDatasetGroup( int activeVectorDatasetGroup );
821
827 bool hasSettings( int datasetGroupIndex ) const;
828
829 private:
830 QgsMeshRendererMeshSettings mRendererNativeMeshSettings;
831 QgsMeshRendererMeshSettings mRendererTriangularMeshSettings;
832 QgsMeshRendererMeshSettings mRendererEdgeMeshSettings;
833
834 QHash<int, QgsMeshRendererScalarSettings> mRendererScalarSettings;
835 QHash<int, QgsMeshRendererVectorSettings> mRendererVectorSettings;
836
838 int mActiveScalarDatasetGroup = -1;
839
841 int mActiveVectorDatasetGroup = -1;
842
844 std::shared_ptr<QgsMesh3DAveragingMethod> mAveragingMethod;
845};
846
847#endif //QGSMESHRENDERERSETTINGS_H
static const double DEFAULT_LINE_WIDTH
The default width (in millimeters) for line symbols.
Definition qgis.h:6612
MeshRangeLimit
Describes the limits used to compute mesh ranges (min/max values).
Definition qgis.h:6406
@ NotSet
User defined.
Definition qgis.h:6407
MeshRangeExtent
Describes the extent used to compute mesh ranges (min/max values).
Definition qgis.h:6418
@ WholeMesh
Whole mesh is used to compute statistics.
Definition qgis.h:6419
RenderUnit
Rendering size units.
Definition qgis.h:5340
@ Millimeters
Millimeters.
Definition qgis.h:5341
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:133