QGIS API Documentation  3.6.0-Noosa (5873452)
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_analysis.h"
32 
33 #include "qgsmeshcalcutils.h"
34 
35 struct QgsMeshMemoryDatasetGroup;
36 
44 class ANALYSIS_EXPORT QgsMeshCalcNode
45 {
46  public:
48  enum Type
49  {
50  tOperator = 1,
51  tNumber,
52  tNoData,
53  tDatasetGroupRef
54  };
55 
57  enum Operator
58  {
59  opPLUS,
60  opMINUS,
61  opMUL,
62  opDIV,
63  opPOW,
64  opEQ,
65  opNE,
66  opGT,
67  opLT,
68  opGE,
69  opLE,
70  opAND,
71  opOR,
72  opNOT,
73  opIF,
74  opSIGN,
75  opMIN,
76  opMAX,
77  opABS,
78  opSUM_AGGR,
79  opMAX_AGGR,
80  opMIN_AGGR,
81  opAVG_AGGR,
82  opNONE,
83  };
84 
88  QgsMeshCalcNode();
89 
93  QgsMeshCalcNode( double number );
94 
101  QgsMeshCalcNode( Operator op, QgsMeshCalcNode *left, QgsMeshCalcNode *right );
102 
109  QgsMeshCalcNode( QgsMeshCalcNode *condition /* bool condition */,
110  QgsMeshCalcNode *left /*if true */,
111  QgsMeshCalcNode *right /* if false */ );
112 
117  QgsMeshCalcNode( const QString &datasetGroupName );
118 
120  ~QgsMeshCalcNode();
121 
123  Type type() const;
124 
126  void setLeft( QgsMeshCalcNode *left );
127 
129  void setRight( QgsMeshCalcNode *right );
130 
137  bool calculate( const QgsMeshCalcUtils &dsu, QgsMeshMemoryDatasetGroup &result ) const;
138 
140  QStringList usedDatasetGroupNames() const;
141 
148  static QgsMeshCalcNode *parseMeshCalcString( const QString &str, QString &parserErrorMsg );
149 
150  private:
151  Q_DISABLE_COPY( QgsMeshCalcNode )
152 
153  Type mType = tNoData;
154  std::unique_ptr<QgsMeshCalcNode> mLeft;
155  std::unique_ptr<QgsMeshCalcNode> mRight;
156  std::unique_ptr<QgsMeshCalcNode> mCondition;
157  double mNumber = std::numeric_limits<double>::quiet_NaN();
158  QString mDatasetGroupName;
159  Operator mOperator = opNONE;
160 };
161 
163 
164 #endif // QGSMESHCALCNODE_H