Quantum GIS API Documentation  1.8
src/analysis/raster/qgsrastercalcnode.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           qgsrastercalcnode.h
00003             Node for raster calculator tree
00004                           --------------------
00005     begin                : 2010-10-23
00006     copyright            : (C) 20010 by Marco Hugentobler
00007     email                : marco dot hugentobler at sourcepole dot ch
00008 ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #ifndef QGSRASTERCALCNODE_H
00020 #define QGSRASTERCALCNODE_H
00021 
00022 #include "qgsrastermatrix.h"
00023 #include <QMap>
00024 #include <QString>
00025 
00026 class ANALYSIS_EXPORT QgsRasterCalcNode
00027 {
00028   public:
00030     enum Type
00031     {
00032       tOperator = 1,
00033       tNumber,
00034       tRasterRef
00035     };
00036 
00038     enum Operator
00039     {
00040       opPLUS,
00041       opMINUS,
00042       opMUL,
00043       opDIV,
00044       opPOW,
00045       opSQRT,
00046       opSIN,
00047       opCOS,
00048       opTAN,
00049       opASIN,
00050       opACOS,
00051       opATAN,
00052       opEQ,         // =
00053       opNE,         
00054       opGT,         // >
00055       opLT,         // <
00056       opGE,         // >=
00057       opLE,         // <=
00058       opAND,
00059       opOR,
00060       opSIGN    //change sign
00061     };
00062 
00063     QgsRasterCalcNode();
00064     QgsRasterCalcNode( double number );
00065     QgsRasterCalcNode( Operator op, QgsRasterCalcNode* left, QgsRasterCalcNode* right );
00066     QgsRasterCalcNode( const QString& rasterName );
00067     ~QgsRasterCalcNode();
00068 
00069     Type type() const { return mType; }
00070 
00071     //set left node
00072     void setLeft( QgsRasterCalcNode* left ) { delete mLeft; mLeft = left; }
00073     void setRight( QgsRasterCalcNode* right ) { delete mRight; mRight = right; }
00074 
00076     bool calculate( QMap<QString, QgsRasterMatrix*>& rasterData, QgsRasterMatrix& result ) const;
00077 
00078     static QgsRasterCalcNode* parseRasterCalcString( const QString& str, QString& parserErrorMsg );
00079 
00080   private:
00081     Type mType;
00082     QgsRasterCalcNode* mLeft;
00083     QgsRasterCalcNode* mRight;
00084     QgsRasterMatrix* mRasterMatrix;
00085     double mNumber;
00086     QString mRasterName;
00087     Operator mOperator;
00088 };
00089 
00090 
00091 #endif // QGSRASTERCALCNODE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines