QGIS API Documentation  3.23.0-Master (7c4a6de034)
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 "qgsmeshdataprovider.h"
29 #include "qgsmesh3daveraging.h"
31 
41 class CORE_EXPORT QgsMeshRendererMeshSettings
42 {
43  public:
45  bool isEnabled() const;
47  void setEnabled( bool enabled );
48 
50  double lineWidth() const;
52  void setLineWidth( double lineWidth );
53 
55  QColor color() const;
57  void setColor( const QColor &color );
58 
64  QgsUnitTypes::RenderUnit lineWidthUnit() const;
65 
71  void setLineWidthUnit( const QgsUnitTypes::RenderUnit &lineWidthUnit );
72 
74  QDomElement writeXml( QDomDocument &doc ) const;
76  void readXml( const QDomElement &elem );
77 
78  private:
79  bool mEnabled = false;
80  double mLineWidth = DEFAULT_LINE_WIDTH;
82  QColor mColor = Qt::black;
83 };
84 
95 {
96  public:
97 
106  {
107 
111  None = 0,
112 
117  };
118 
120  QgsColorRampShader colorRampShader() const;
122  void setColorRampShader( const QgsColorRampShader &shader );
123 
125  double classificationMinimum() const;
127  double classificationMaximum() const;
129  void setClassificationMinimumMaximum( double minimum, double maximum );
130 
132  double opacity() const;
134  void setOpacity( double opacity );
135 
143  DataResamplingMethod dataResamplingMethod() const;
144 
150  void setDataResamplingMethod( const DataResamplingMethod &dataResamplingMethod );
151 
157  QgsInterpolatedLineWidth edgeStrokeWidth() const;
158 
164  void setEdgeStrokeWidth( const QgsInterpolatedLineWidth &strokeWidth );
165 
171  QgsUnitTypes::RenderUnit edgeStrokeWidthUnit() const;
172 
178  void setEdgeStrokeWidthUnit( const QgsUnitTypes::RenderUnit &edgeStrokeWidthUnit );
179 
181  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
183  void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
184 
185  private:
186  QgsColorRampShader mColorRampShader;
187  DataResamplingMethod mDataResamplingMethod = DataResamplingMethod::None;
188  double mClassificationMinimum = 0;
189  double mClassificationMaximum = 0;
190  double mOpacity = 1;
191 
192  QgsInterpolatedLineWidth mEdgeStrokeWidth;
194 };
195 
206 {
207  public:
208 
211  {
212 
216  MinMax = 0,
217 
222 
226  Fixed
227  };
228 
232  void setShaftLengthMethod( ArrowScalingMethod shaftLengthMethod );
233 
239  double minShaftLength() const;
240 
246  void setMinShaftLength( double minShaftLength );
247 
253  double maxShaftLength() const;
254 
260  void setMaxShaftLength( double maxShaftLength );
261 
267  double scaleFactor() const;
268 
274  void setScaleFactor( double scaleFactor );
275 
281  double fixedShaftLength() const;
282 
288  void setFixedShaftLength( double fixedShaftLength );
289 
291  double arrowHeadWidthRatio() const;
293  void setArrowHeadWidthRatio( double arrowHeadWidthRatio );
294 
296  double arrowHeadLengthRatio() const;
298  void setArrowHeadLengthRatio( double arrowHeadLengthRatio );
299 
301  QDomElement writeXml( QDomDocument &doc ) const;
303  void readXml( const QDomElement &elem );
304 
305  private:
306  QgsMeshRendererVectorArrowSettings::ArrowScalingMethod mShaftLengthMethod = QgsMeshRendererVectorArrowSettings::ArrowScalingMethod::MinMax;
307  double mMinShaftLength = 0.8; //in millimeters
308  double mMaxShaftLength = 10; //in millimeters
309  double mScaleFactor = 10;
310  double mFixedShaftLength = 20; //in millimeters
311  double mArrowHeadWidthRatio = 0.15;
312  double mArrowHeadLengthRatio = 0.40;
313 };
314 
325 {
326  public:
329  {
330 
334  MeshGridded = 0,
335 
339  Random
340  };
341 
343  SeedingStartPointsMethod seedingMethod() const;
345  void setSeedingMethod( const SeedingStartPointsMethod &seedingMethod );
347  double seedingDensity() const;
349  void setSeedingDensity( double seedingDensity );
351  void readXml( const QDomElement &elem );
353  QDomElement writeXml( QDomDocument &doc ) const;
354 
355  private:
356 
358  double mSeedingDensity = 0.15;
359 };
360 
371 {
372  public:
373 
375  double maximumTailLength() const;
377  void setMaximumTailLength( double maximumTailLength );
379  int particlesCount() const;
381  void setParticlesCount( int value );
383  QgsUnitTypes::RenderUnit maximumTailLengthUnit() const;
385  void setMaximumTailLengthUnit( const QgsUnitTypes::RenderUnit &maximumTailLengthUnit );
386 
388  void readXml( const QDomElement &elem );
390  QDomElement writeXml( QDomDocument &doc ) const;
391 
392 
393 
394  private:
395  int mParticlesCount = 1000;
396  double mMaximumTailLength = 100;
398 
399 };
400 
411 {
412  public:
413 
419  {
421  Arrows = 0,
425  Traces
426  };
427 
429  double lineWidth() const;
431  void setLineWidth( double lineWidth );
432 
434  QColor color() const;
436  void setColor( const QColor &color );
437 
444  double filterMin() const;
445 
450  void setFilterMin( double filterMin );
451 
458  double filterMax() const;
459 
464  void setFilterMax( double filterMax );
465 
467  bool isOnUserDefinedGrid() const;
469  void setOnUserDefinedGrid( bool enabled );
471  int userGridCellWidth() const;
473  void setUserGridCellWidth( int width );
475  int userGridCellHeight() const;
477  void setUserGridCellHeight( int height );
478 
483  Symbology symbology() const;
484 
489  void setSymbology( const Symbology &symbology );
490 
495  QgsInterpolatedLineColor::ColoringMethod coloringMethod() const;
496 
501  void setColoringMethod( const QgsInterpolatedLineColor::ColoringMethod &coloringMethod );
502 
507  QgsColorRampShader colorRampShader() const;
508 
513  void setColorRampShader( const QgsColorRampShader &colorRampShader );
514 
519  QgsInterpolatedLineColor vectorStrokeColoring() const;
520 
525  QgsMeshRendererVectorArrowSettings arrowSettings() const;
526 
531  void setArrowsSettings( const QgsMeshRendererVectorArrowSettings &arrowSettings );
532 
537  QgsMeshRendererVectorStreamlineSettings streamLinesSettings() const;
538 
543  void setStreamLinesSettings( const QgsMeshRendererVectorStreamlineSettings &streamLinesSettings );
544 
549  QgsMeshRendererVectorTracesSettings tracesSettings() const;
550 
555  void setTracesSettings( const QgsMeshRendererVectorTracesSettings &tracesSettings );
556 
558  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
560  void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
561 
562  private:
563 
564  Symbology mDisplayingMethod = Arrows;
565 
566  double mLineWidth = DEFAULT_LINE_WIDTH; //in millimeters
567  QgsColorRampShader mColorRampShader;
568  QColor mColor = Qt::black;
570  double mFilterMin = -1; //disabled
571  double mFilterMax = -1; //disabled
572  int mUserGridCellWidth = 10; // in pixels
573  int mUserGridCellHeight = 10; // in pixels
574  bool mOnUserDefinedGrid = false;
575 
576  QgsMeshRendererVectorArrowSettings mArrowsSettings;
577  QgsMeshRendererVectorStreamlineSettings mStreamLinesSettings;
578  QgsMeshRendererVectorTracesSettings mTracesSettings;
579 };
580 
590 class CORE_EXPORT QgsMeshRendererSettings
591 {
592  public:
593 
600 
602  QgsMeshRendererMeshSettings nativeMeshSettings() const { return mRendererNativeMeshSettings; }
604  void setNativeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererNativeMeshSettings = settings; }
605 
607  QgsMeshRendererMeshSettings triangularMeshSettings() const { return mRendererTriangularMeshSettings; }
609  void setTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererTriangularMeshSettings = settings; }
610 
615  QgsMeshRendererMeshSettings edgeMeshSettings() const { return mRendererEdgeMeshSettings; }
616 
621  void setEdgeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererEdgeMeshSettings = settings; }
622 
624  QgsMeshRendererScalarSettings scalarSettings( int groupIndex ) const { return mRendererScalarSettings.value( groupIndex ); }
626  void setScalarSettings( int groupIndex, const QgsMeshRendererScalarSettings &settings ) { mRendererScalarSettings[groupIndex] = settings; }
627 
629  QgsMeshRendererVectorSettings vectorSettings( int groupIndex ) const { return mRendererVectorSettings.value( groupIndex ); }
631  void setVectorSettings( int groupIndex, const QgsMeshRendererVectorSettings &settings ) { mRendererVectorSettings[groupIndex] = settings; }
632 
638  QgsMesh3dAveragingMethod *averagingMethod() const;
639 
645  void setAveragingMethod( QgsMesh3dAveragingMethod *method );
646 
648  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
650  void readXml( const QDomElement &elem, const QgsReadWriteContext &context = QgsReadWriteContext() );
651 
656  int activeScalarDatasetGroup() const;
657 
662  void setActiveScalarDatasetGroup( int activeScalarDatasetGroup );
663 
668  int activeVectorDatasetGroup() const;
669 
674  void setActiveVectorDatasetGroup( int activeVectorDatasetGroup );
675 
681  bool hasSettings( int datasetGroupIndex ) const;
682 
683  private:
684  QgsMeshRendererMeshSettings mRendererNativeMeshSettings;
685  QgsMeshRendererMeshSettings mRendererTriangularMeshSettings;
686  QgsMeshRendererMeshSettings mRendererEdgeMeshSettings;
687 
688  QHash<int, QgsMeshRendererScalarSettings> mRendererScalarSettings;
689  QHash<int, QgsMeshRendererVectorSettings> mRendererVectorSettings;
690 
692  int mActiveScalarDatasetGroup = -1;
693 
695  int mActiveVectorDatasetGroup = -1;
696 
698  std::shared_ptr<QgsMesh3dAveragingMethod> mAveragingMethod;
699 };
700 
701 #endif //QGSMESHRENDERERSETTINGS_H
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.
void setEdgeMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new edge mesh renderer settings.
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.
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()
Represents a renderer settings for vector datasets.
Symbology
Defines the symbology of vector rendering.
@ 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.
The class is used as a container of context for various read/write operations on other objects.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
const double DEFAULT_LINE_WIDTH
Definition: qgis.h:1998