QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsrastercalcnode.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrastercalcnode.h
3  Node for raster calculator tree
4  --------------------
5  begin : 2010-10-23
6  copyright : (C) 20010 by Marco Hugentobler
7  email : marco dot hugentobler at sourcepole dot ch
8 ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef QGSRASTERCALCNODE_H
20 #define QGSRASTERCALCNODE_H
21 
22 #include <QMap>
23 #include "qgis_sip.h"
24 #include "qgis.h"
25 #include <QString>
26 #include "qgis_analysis.h"
27 
28 class QgsRasterBlock;
29 class QgsRasterMatrix;
30 
36 class ANALYSIS_EXPORT QgsRasterCalcNode
37 {
38  public:
40  enum Type
41  {
42  tOperator = 1,
45  tMatrix
46  };
47 
49  enum Operator
50  {
63  opEQ, // =
64  opNE,
65  opGT, // >
66  opLT, // <
67  opGE, // >=
68  opLE, // <=
71  opSIGN, // change sign
78  };
79 
83  QgsRasterCalcNode() = default;
84 
85  QgsRasterCalcNode( double number );
88  QgsRasterCalcNode( const QString &rasterName );
90 
92  QgsRasterCalcNode( const QgsRasterCalcNode &rh ) = delete;
95 
96  Type type() const { return mType; }
97 
98  //set left node
99  void setLeft( QgsRasterCalcNode *left ) { delete mLeft; mLeft = left; }
100  void setRight( QgsRasterCalcNode *right ) { delete mRight; mRight = right; }
101 
111  bool calculate( QMap<QString, QgsRasterBlock * > &rasterData, QgsRasterMatrix &result, int row = -1 ) const SIP_SKIP;
112 
118  QString toString( bool cStyle = false ) const;
119 
124  QList<const QgsRasterCalcNode *> findNodes( const QgsRasterCalcNode::Type type ) const;
125 
126  static QgsRasterCalcNode *parseRasterCalcString( const QString &str, QString &parserErrorMsg ) SIP_FACTORY;
127 
128  private:
129 #ifdef SIP_RUN
131 #endif
132 
133  Type mType = tNumber;
134  QgsRasterCalcNode *mLeft = nullptr;
135  QgsRasterCalcNode *mRight = nullptr;
136  double mNumber = 0;
137  QString mRasterName;
138  QgsRasterMatrix *mMatrix = nullptr;
139  Operator mOperator = opNONE;
140 
141 };
142 
143 
144 #endif // QGSRASTERCALCNODE_H
Raster data container.
Represents a node in a raster calculator.
void setLeft(QgsRasterCalcNode *left)
Operator
possible operators
QgsRasterCalcNode()=default
Constructor for QgsRasterCalcNode.
QgsRasterCalcNode(const QgsRasterCalcNode &rh)=delete
QgsRasterCalcNode cannot be copied.
void setRight(QgsRasterCalcNode *right)
QgsRasterCalcNode & operator=(const QgsRasterCalcNode &rh)=delete
QgsRasterCalcNode cannot be copied.
Type
defines possible types of node
Represents a matrix in a raster calculator operation.
#define str(x)
Definition: qgis.cpp:37
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_FACTORY
Definition: qgis_sip.h:76