QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
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"
30 
40 class CORE_EXPORT QgsMeshRendererMeshSettings
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 
59  QDomElement writeXml( QDomDocument &doc ) const;
61  void readXml( const QDomElement &elem );
62 
63  private:
64  bool mEnabled = false;
65  double mLineWidth = DEFAULT_LINE_WIDTH;
66  QColor mColor = Qt::black;
67 };
68 
79 {
80  public:
83  {
84 
88  None = 0,
89 
95  };
96 
98  QgsColorRampShader colorRampShader() const;
100  void setColorRampShader( const QgsColorRampShader &shader );
101 
103  double classificationMinimum() const;
105  double classificationMaximum() const;
107  void setClassificationMinimumMaximum( double minimum, double maximum );
108 
110  double opacity() const;
112  void setOpacity( double opacity );
113 
121  DataInterpolationMethod dataInterpolationMethod() const;
122 
128  void setDataInterpolationMethod( const DataInterpolationMethod &dataInterpolationMethod );
129 
131  QDomElement writeXml( QDomDocument &doc ) const;
133  void readXml( const QDomElement &elem );
134 
135  private:
136  QgsColorRampShader mColorRampShader;
137  DataInterpolationMethod mDataInterpolationMethod = DataInterpolationMethod::None;
138  double mClassificationMinimum = 0;
139  double mClassificationMaximum = 0;
140  double mOpacity = 1;
141 
142 };
143 
154 {
155  public:
156 
159  {
160 
164  MinMax = 0,
165 
170 
174  Fixed
175  };
176 
180  void setShaftLengthMethod( ArrowScalingMethod shaftLengthMethod );
181 
187  double minShaftLength() const;
188 
194  void setMinShaftLength( double minShaftLength );
195 
201  double maxShaftLength() const;
202 
208  void setMaxShaftLength( double maxShaftLength );
209 
215  double scaleFactor() const;
216 
222  void setScaleFactor( double scaleFactor );
223 
229  double fixedShaftLength() const;
230 
236  void setFixedShaftLength( double fixedShaftLength );
237 
239  double arrowHeadWidthRatio() const;
241  void setArrowHeadWidthRatio( double arrowHeadWidthRatio );
242 
244  double arrowHeadLengthRatio() const;
246  void setArrowHeadLengthRatio( double arrowHeadLengthRatio );
247 
249  QDomElement writeXml( QDomDocument &doc ) const;
251  void readXml( const QDomElement &elem );
252 
253  private:
254  QgsMeshRendererVectorArrowSettings::ArrowScalingMethod mShaftLengthMethod = QgsMeshRendererVectorArrowSettings::ArrowScalingMethod::MinMax;
255  double mMinShaftLength = 0.8; //in millimeters
256  double mMaxShaftLength = 10; //in millimeters
257  double mScaleFactor = 10;
258  double mFixedShaftLength = 20; //in millimeters
259  double mArrowHeadWidthRatio = 0.15;
260  double mArrowHeadLengthRatio = 0.40;
261 };
262 
273 {
274  public:
277  {
278 
282  MeshGridded = 0,
283 
288  };
289 
291  SeedingStartPointsMethod seedingMethod() const;
293  void setSeedingMethod( const SeedingStartPointsMethod &seedingMethod );
295  double seedingDensity() const;
297  void setSeedingDensity( double seedingDensity );
299  void readXml( const QDomElement &elem );
301  QDomElement writeXml( QDomDocument &doc ) const;
302 
303  private:
304 
306  double mSeedingDensity = 0.15;
307 };
308 
319 {
320  public:
321 
323  double maximumTailLength() const;
325  void setMaximumTailLength( double maximumTailLength );
327  int particlesCount() const;
329  void setParticlesCount( int value );
331  QgsUnitTypes::RenderUnit maximumTailLengthUnit() const;
333  void setMaximumTailLengthUnit( const QgsUnitTypes::RenderUnit &maximumTailLengthUnit );
334 
336  void readXml( const QDomElement &elem );
338  QDomElement writeXml( QDomDocument &doc ) const;
339 
340 
341 
342  private:
343  int mParticlesCount = 1000;
344  double mMaximumTailLength = 100;
346 
347 };
348 
359 {
360  public:
361 
367  {
369  Arrows = 0,
373  Traces
374  };
375 
376 
378  double lineWidth() const;
380  void setLineWidth( double lineWidth );
381 
383  QColor color() const;
385  void setColor( const QColor &color );
386 
393  double filterMin() const;
394 
399  void setFilterMin( double filterMin );
400 
407  double filterMax() const;
408 
413  void setFilterMax( double filterMax );
414 
416  bool isOnUserDefinedGrid() const;
418  void setOnUserDefinedGrid( bool enabled );
420  int userGridCellWidth() const;
422  void setUserGridCellWidth( int width );
424  int userGridCellHeight() const;
426  void setUserGridCellHeight( int height );
427 
432  Symbology symbology() const;
433 
438  void setSymbology( const Symbology &symbology );
439 
444  QgsMeshRendererVectorArrowSettings arrowSettings() const;
445 
450  void setArrowsSettings( const QgsMeshRendererVectorArrowSettings &arrowSettings );
451 
456  QgsMeshRendererVectorStreamlineSettings streamLinesSettings() const;
457 
462  void setStreamLinesSettings( const QgsMeshRendererVectorStreamlineSettings &streamLinesSettings );
463 
468  QgsMeshRendererVectorTracesSettings tracesSettings() const;
469 
474  void setTracesSettings( const QgsMeshRendererVectorTracesSettings &tracesSettings );
475 
477  QDomElement writeXml( QDomDocument &doc ) const;
479  void readXml( const QDomElement &elem );
480 
481 
482  private:
483 
484  Symbology mDisplayingMethod = Arrows;
485 
486  double mLineWidth = DEFAULT_LINE_WIDTH; //in millimeters
487  QColor mColor = Qt::black;
488  double mFilterMin = -1; //disabled
489  double mFilterMax = -1; //disabled
490  int mUserGridCellWidth = 10; // in pixels
491  int mUserGridCellHeight = 10; // in pixels
492  bool mOnUserDefinedGrid = false;
493 
494  QgsMeshRendererVectorArrowSettings mArrowsSettings;
495  QgsMeshRendererVectorStreamlineSettings mStreamLinesSettings;
496  QgsMeshRendererVectorTracesSettings mTracesSettings;
497 };
498 
508 class CORE_EXPORT QgsMeshRendererSettings
509 {
510  public:
511 
518 
520  QgsMeshRendererMeshSettings nativeMeshSettings() const { return mRendererNativeMeshSettings; }
522  void setNativeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererNativeMeshSettings = settings; }
523 
525  QgsMeshRendererMeshSettings triangularMeshSettings() const { return mRendererTriangularMeshSettings; }
527  void setTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererTriangularMeshSettings = settings; }
528 
530  QgsMeshRendererScalarSettings scalarSettings( int groupIndex ) const { return mRendererScalarSettings.value( groupIndex ); }
532  void setScalarSettings( int groupIndex, const QgsMeshRendererScalarSettings &settings ) { mRendererScalarSettings[groupIndex] = settings; }
533 
535  QgsMeshRendererVectorSettings vectorSettings( int groupIndex ) const { return mRendererVectorSettings.value( groupIndex ); }
537  void setVectorSettings( int groupIndex, const QgsMeshRendererVectorSettings &settings ) { mRendererVectorSettings[groupIndex] = settings; }
538 
544  QgsMesh3dAveragingMethod *averagingMethod() const;
545 
551  void setAveragingMethod( QgsMesh3dAveragingMethod *method );
552 
554  QgsMeshDatasetIndex activeScalarDataset() const { return mActiveScalarDataset; }
556  void setActiveScalarDataset( QgsMeshDatasetIndex index = QgsMeshDatasetIndex() ) { mActiveScalarDataset = index; }
557 
559  QgsMeshDatasetIndex activeVectorDataset() const { return mActiveVectorDataset; }
561  void setActiveVectorDataset( QgsMeshDatasetIndex index = QgsMeshDatasetIndex() ) { mActiveVectorDataset = index; }
562 
564  QDomElement writeXml( QDomDocument &doc ) const;
566  void readXml( const QDomElement &elem );
567 
568  private:
569  QgsMeshRendererMeshSettings mRendererNativeMeshSettings;
570  QgsMeshRendererMeshSettings mRendererTriangularMeshSettings;
571 
572  QHash<int, QgsMeshRendererScalarSettings> mRendererScalarSettings;
573  QHash<int, QgsMeshRendererVectorSettings> mRendererVectorSettings;
574 
576  QgsMeshDatasetIndex mActiveScalarDataset;
577 
579  QgsMeshDatasetIndex mActiveVectorDataset;
580 
582  std::shared_ptr<QgsMesh3dAveragingMethod> mAveragingMethod;
583 };
584 
585 #endif //QGSMESHRENDERERSETTINGS_H
Displaying vector dataset with streamlines.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Represents a mesh renderer settings for mesh object.
Represents a mesh renderer settings for scalar datasets.
void setVectorSettings(int groupIndex, const QgsMeshRendererVectorSettings &settings)
Sets new renderer settings.
QgsMeshRendererScalarSettings scalarSettings(int groupIndex) const
Returns renderer settings.
void setScalarSettings(int groupIndex, const QgsMeshRendererScalarSettings &settings)
Sets new renderer settings.
For each vertex does a simple average of values defined for all faces that contains given vertex...
QgsMeshDatasetIndex activeVectorDataset() const
Returns active vector dataset.
Represents all mesh renderer settings.
Represents a streamline renderer settings for vector datasets.
void setTriangularMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new renderer settings.
Seeds start points randomly on the mesh.
DataInterpolationMethod
Interpolation of value defined on vertices from datasets with data defined on faces.
SeedingStartPointsMethod
Method used to define start points that are used to draw streamlines.
void setActiveVectorDataset(QgsMeshDatasetIndex index=QgsMeshDatasetIndex())
Sets active vector dataset for rendering.
Symbology
Defines the symbology of vector rendering.
QgsMeshRendererVectorSettings vectorSettings(int groupIndex) const
Returns renderer settings.
ArrowScalingMethod
Algorithm how to transform vector magnitude to length of arrow on the device in pixels.
Scale vector magnitude by factor scaleFactor()
QgsMeshRendererMeshSettings nativeMeshSettings() const
Returns renderer settings.
void setNativeMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new renderer settings, triggers repaint.
const double DEFAULT_LINE_WIDTH
Definition: qgis.h:689
void setActiveScalarDataset(QgsMeshDatasetIndex index=QgsMeshDatasetIndex())
Sets active scalar dataset for rendering.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
QgsMeshRendererMeshSettings triangularMeshSettings() const
Returns renderer settings.
Abstract class to interpolate 3d stacked mesh data to 2d data.
Represents a trace renderer settings for vector datasets displayed by particle traces.
Represents a mesh renderer settings for vector datasets displayed with arrows.
Represents a streamline renderer settings for vector datasets displayed by streamlines.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:145
QgsMeshDatasetIndex activeScalarDataset() const
Returns active scalar dataset.