QGIS API Documentation  3.6.0-Noosa (5873452)
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 <limits>
23 
24 #include "qgis_core.h"
25 #include "qgis.h"
26 #include "qgscolorrampshader.h"
27 #include "qgsmeshdataprovider.h"
28 
29 
39 class CORE_EXPORT QgsMeshRendererMeshSettings
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 
58  QDomElement writeXml( QDomDocument &doc ) const;
60  void readXml( const QDomElement &elem );
61 
62  private:
63  bool mEnabled = false;
64  double mLineWidth = DEFAULT_LINE_WIDTH;
65  QColor mColor = Qt::black;
66 };
67 
78 {
79  public:
81  QgsColorRampShader colorRampShader() const;
83  void setColorRampShader( const QgsColorRampShader &shader );
84 
86  double classificationMinimum() const;
88  double classificationMaximum() const;
90  void setClassificationMinimumMaximum( double minimum, double maximum );
91 
93  double opacity() const;
95  void setOpacity( double opacity );
96 
98  QDomElement writeXml( QDomDocument &doc ) const;
100  void readXml( const QDomElement &elem );
101 
102  private:
103  QgsColorRampShader mColorRampShader;
104  double mClassificationMinimum = 0;
105  double mClassificationMaximum = 0;
106  double mOpacity = 1;
107 };
108 
119 {
120  public:
121 
124  {
125 
129  MinMax = 0,
130 
135 
139  Fixed
140  };
141 
143  double lineWidth() const;
145  void setLineWidth( double lineWidth );
146 
148  QColor color() const;
150  void setColor( const QColor &color );
151 
158  double filterMin() const;
159 
164  void setFilterMin( double filterMin );
165 
172  double filterMax() const;
173 
178  void setFilterMax( double filterMax );
179 
181  QgsMeshRendererVectorSettings::ArrowScalingMethod shaftLengthMethod() const;
183  void setShaftLengthMethod( ArrowScalingMethod shaftLengthMethod );
184 
190  double minShaftLength() const;
191 
197  void setMinShaftLength( double minShaftLength );
198 
204  double maxShaftLength() const;
205 
211  void setMaxShaftLength( double maxShaftLength );
212 
218  double scaleFactor() const;
219 
225  void setScaleFactor( double scaleFactor );
226 
232  double fixedShaftLength() const;
233 
239  void setFixedShaftLength( double fixedShaftLength );
240 
242  double arrowHeadWidthRatio() const;
244  void setArrowHeadWidthRatio( double arrowHeadWidthRatio );
245 
247  double arrowHeadLengthRatio() const;
249  void setArrowHeadLengthRatio( double arrowHeadLengthRatio );
250 
252  bool isOnUserDefinedGrid() const;
254  void setOnUserDefinedGrid( bool enabled );
256  int userGridCellWidth() const;
258  void setUserGridCellWidth( int width );
260  int userGridCellHeight() const;
262  void setUserGridCellHeight( int height );
263 
265  QDomElement writeXml( QDomDocument &doc ) const;
267  void readXml( const QDomElement &elem );
268 
269  private:
270  double mLineWidth = DEFAULT_LINE_WIDTH; //in milimeters
271  QColor mColor = Qt::black;
272  double mFilterMin = -1; //disabled
273  double mFilterMax = -1; //disabled
274  QgsMeshRendererVectorSettings::ArrowScalingMethod mShaftLengthMethod = QgsMeshRendererVectorSettings::ArrowScalingMethod::MinMax;
275  double mMinShaftLength = 0.8; //in milimeters
276  double mMaxShaftLength = 10; //in milimeters
277  double mScaleFactor = 10;
278  double mFixedShaftLength = 20; //in milimeters
279  double mArrowHeadWidthRatio = 0.15;
280  double mArrowHeadLengthRatio = 0.40;
281  bool mOnUserDefinedGrid = false;
282  int mUserGridCellWidth = 10; // in pixels
283  int mUserGridCellHeight = 10; // in pixels
284 };
285 
286 
296 class CORE_EXPORT QgsMeshRendererSettings
297 {
298  public:
299 
301  QgsMeshRendererMeshSettings nativeMeshSettings() const { return mRendererNativeMeshSettings; }
303  void setNativeMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererNativeMeshSettings = settings; }
304 
306  QgsMeshRendererMeshSettings triangularMeshSettings() const { return mRendererTriangularMeshSettings; }
308  void setTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings ) { mRendererTriangularMeshSettings = settings; }
309 
311  QgsMeshRendererScalarSettings scalarSettings( int groupIndex ) const { return mRendererScalarSettings.value( groupIndex ); }
313  void setScalarSettings( int groupIndex, const QgsMeshRendererScalarSettings &settings ) { mRendererScalarSettings[groupIndex] = settings; }
314 
316  QgsMeshRendererVectorSettings vectorSettings( int groupIndex ) const { return mRendererVectorSettings.value( groupIndex ); }
318  void setVectorSettings( int groupIndex, const QgsMeshRendererVectorSettings &settings ) { mRendererVectorSettings[groupIndex] = settings; }
319 
321  QgsMeshDatasetIndex activeScalarDataset() const { return mActiveScalarDataset; }
323  void setActiveScalarDataset( QgsMeshDatasetIndex index = QgsMeshDatasetIndex() ) { mActiveScalarDataset = index; }
324 
326  QgsMeshDatasetIndex activeVectorDataset() const { return mActiveVectorDataset; }
328  void setActiveVectorDataset( QgsMeshDatasetIndex index = QgsMeshDatasetIndex() ) { mActiveVectorDataset = index; }
329 
331  QDomElement writeXml( QDomDocument &doc ) const;
333  void readXml( const QDomElement &elem );
334 
335  private:
336  QgsMeshRendererMeshSettings mRendererNativeMeshSettings;
337  QgsMeshRendererMeshSettings mRendererTriangularMeshSettings;
338 
339  QHash<int, QgsMeshRendererScalarSettings> mRendererScalarSettings;
340  QHash<int, QgsMeshRendererVectorSettings> mRendererVectorSettings;
341 
343  QgsMeshDatasetIndex mActiveScalarDataset;
344 
346  QgsMeshDatasetIndex mActiveVectorDataset;
347 };
348 
349 #endif //QGSMESHRENDERERSETTINGS_H
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.
QgsMeshDatasetIndex activeVectorDataset() const
Returns active vector dataset.
Represents all mesh renderer settings.
Represents a mesh renderer settings for vector datasets.
void setTriangularMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new renderer settings.
void setActiveVectorDataset(QgsMeshDatasetIndex index=QgsMeshDatasetIndex())
Sets active vector dataset for rendering.
Scale vector magnitude by factor scaleFactor()
QgsMeshRendererVectorSettings vectorSettings(int groupIndex) const
Returns renderer settings.
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:570
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.
ArrowScalingMethod
Algorithm how to transform vector magnitude to length of arrow on the device in pixels.
QgsMeshDatasetIndex activeScalarDataset() const
Returns active scalar dataset.