QGIS API Documentation  3.23.0-Master (dd0cd13a00)
qgsmeshcalcnode.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmeshcalcnode.h
3  --------------------------------
4  begin : December 18th, 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 QGSMESHCALCNODE_H
19 #define QGSMESHCALCNODE_H
20 
21 #define SIP_NO_FILE
22 
24 
25 #include <QMap>
26 #include <QString>
27 #include <QStringList>
28 #include <memory>
29 #include <limits>
30 
31 #include "qgis_core.h"
32 
33 #include "qgsmeshcalcutils.h"
34 
42 class CORE_EXPORT QgsMeshCalcNode
43 {
44  public:
46  enum Type
47  {
48  tOperator = 1,
49  tNumber,
50  tNoData,
51  tDatasetGroupRef
52  };
53 
55  enum Operator
56  {
57  opPLUS,
58  opMINUS,
59  opMUL,
60  opDIV,
61  opPOW,
62  opEQ,
63  opNE,
64  opGT,
65  opLT,
66  opGE,
67  opLE,
68  opAND,
69  opOR,
70  opNOT,
71  opIF,
72  opSIGN,
73  opMIN,
74  opMAX,
75  opABS,
76  opSUM_AGGR,
77  opMAX_AGGR,
78  opMIN_AGGR,
79  opAVG_AGGR,
80  opNONE,
81  };
82 
86  QgsMeshCalcNode();
87 
91  QgsMeshCalcNode( double number );
92 
99  QgsMeshCalcNode( Operator op, QgsMeshCalcNode *left, QgsMeshCalcNode *right );
100 
107  QgsMeshCalcNode( QgsMeshCalcNode *condition /* bool condition */,
108  QgsMeshCalcNode *left /*if true */,
109  QgsMeshCalcNode *right /* if false */ );
110 
115  QgsMeshCalcNode( const QString &datasetGroupName );
116 
118  ~QgsMeshCalcNode();
119 
121  Type type() const;
122 
124  void setLeft( QgsMeshCalcNode *left );
125 
127  void setRight( QgsMeshCalcNode *right );
128 
135  bool calculate( const QgsMeshCalcUtils &dsu, QgsMeshMemoryDatasetGroup &result, bool isAggregate = false ) const;
136 
138  QStringList usedDatasetGroupNames() const;
139 
141  QStringList aggregatedUsedDatasetGroupNames() const;
142 
144  QStringList notAggregatedUsedDatasetGroupNames() const;
145 
152  static QgsMeshCalcNode *parseMeshCalcString( const QString &str, QString &parserErrorMsg );
153 
158  bool isNonTemporal() const;
159 
160  private:
161  Q_DISABLE_COPY( QgsMeshCalcNode )
162 
163  Type mType = tNoData;
164  std::unique_ptr<QgsMeshCalcNode> mLeft;
165  std::unique_ptr<QgsMeshCalcNode> mRight;
166  std::unique_ptr<QgsMeshCalcNode> mCondition;
167  double mNumber = std::numeric_limits<double>::quiet_NaN();
168  QString mDatasetGroupName;
169  Operator mOperator = opNONE;
170 };
171 
173 
174 #endif // QGSMESHCALCNODE_H
Class that represents a dataset group stored in memory.
#define str(x)
Definition: qgis.cpp:37