22 #include "qgsmeshmemorydataprovider.h"
24 QgsMeshCalcNode::QgsMeshCalcNode()
29 QgsMeshCalcNode::QgsMeshCalcNode(
double number )
36 QgsMeshCalcNode::QgsMeshCalcNode( Operator op, QgsMeshCalcNode *left, QgsMeshCalcNode *right )
44 QgsMeshCalcNode::QgsMeshCalcNode( QgsMeshCalcNode *condition ,
45 QgsMeshCalcNode *left ,
46 QgsMeshCalcNode *right )
50 , mCondition( condition )
55 QgsMeshCalcNode::QgsMeshCalcNode(
const QString &datasetGroupName )
56 : mType( tDatasetGroupRef )
57 , mDatasetGroupName( datasetGroupName )
59 if ( mDatasetGroupName.startsWith(
'"' ) && mDatasetGroupName.endsWith(
'"' ) )
60 mDatasetGroupName = mDatasetGroupName.mid( 1, mDatasetGroupName.size() - 2 );
63 QgsMeshCalcNode::~QgsMeshCalcNode() =
default;
65 QgsMeshCalcNode::Type QgsMeshCalcNode::type()
const
70 void QgsMeshCalcNode::setLeft( QgsMeshCalcNode *left )
75 void QgsMeshCalcNode::setRight( QgsMeshCalcNode *right )
77 mRight.reset( right );
80 QStringList QgsMeshCalcNode::usedDatasetGroupNames()
const
84 if ( mType == tDatasetGroupRef )
86 res.append( mDatasetGroupName );
91 res += mLeft->usedDatasetGroupNames();
96 res += mRight->usedDatasetGroupNames();
101 res += mCondition->usedDatasetGroupNames();
109 if ( mType == tDatasetGroupRef )
111 dsu.copy( result, mDatasetGroupName );
114 else if ( mType == tOperator )
119 if ( !mLeft || !mLeft->calculate( dsu, leftDatasetGroup ) )
123 if ( mRight && !mRight->calculate( dsu, rightDatasetGroup ) )
133 if ( !mCondition->calculate( dsu, condition ) )
138 dsu.addIf( leftDatasetGroup, rightDatasetGroup, condition );
142 dsu.add( leftDatasetGroup, rightDatasetGroup );
145 dsu.subtract( leftDatasetGroup, rightDatasetGroup );
148 dsu.multiply( leftDatasetGroup, rightDatasetGroup );
151 dsu.divide( leftDatasetGroup, rightDatasetGroup );
154 dsu.power( leftDatasetGroup, rightDatasetGroup );
157 dsu.equal( leftDatasetGroup, rightDatasetGroup );
160 dsu.notEqual( leftDatasetGroup, rightDatasetGroup );
163 dsu.greaterThan( leftDatasetGroup, rightDatasetGroup );
166 dsu.lesserThan( leftDatasetGroup, rightDatasetGroup );
169 dsu.greaterEqual( leftDatasetGroup, rightDatasetGroup );
172 dsu.lesserEqual( leftDatasetGroup, rightDatasetGroup );
175 dsu.logicalAnd( leftDatasetGroup, rightDatasetGroup );
178 dsu.logicalOr( leftDatasetGroup, rightDatasetGroup );
181 dsu.logicalNot( leftDatasetGroup );
184 dsu.minimum( leftDatasetGroup, rightDatasetGroup );
187 dsu.maximum( leftDatasetGroup, rightDatasetGroup );
190 dsu.abs( leftDatasetGroup );
193 dsu.sumAggregated( leftDatasetGroup );
196 dsu.minimumAggregated( leftDatasetGroup );
199 dsu.maximumAggregated( leftDatasetGroup );
202 dsu.averageAggregated( leftDatasetGroup );
205 dsu.changeSign( leftDatasetGroup );
210 dsu.transferDatasets( result, leftDatasetGroup );
213 else if ( mType == tNumber )
215 dsu.number( result, mNumber );
218 else if ( mType == tNoData )
220 dsu.nodata( result );
228 QgsMeshCalcNode *QgsMeshCalcNode::parseMeshCalcString(
const QString &str, QString &parserErrorMsg )
230 extern QgsMeshCalcNode *localParseMeshCalcString(
const QString & str, QString & parserErrorMsg );
231 return localParseMeshCalcString( str, parserErrorMsg );
234 bool QgsMeshCalcNode::isNonTemporal()
const
236 if ( mType == tNoData || mType == tNumber )
239 if ( mType == tDatasetGroupRef )
244 case QgsMeshCalcNode::opPLUS:
245 case QgsMeshCalcNode::opMINUS:
246 case QgsMeshCalcNode::opMUL:
247 case QgsMeshCalcNode::opDIV:
248 case QgsMeshCalcNode::opPOW:
249 case QgsMeshCalcNode::opEQ:
250 case QgsMeshCalcNode::opNE:
251 case QgsMeshCalcNode::opGT:
252 case QgsMeshCalcNode::opLT:
253 case QgsMeshCalcNode::opGE:
254 case QgsMeshCalcNode::opLE:
255 case QgsMeshCalcNode::opAND:
256 case QgsMeshCalcNode::opOR:
257 case QgsMeshCalcNode::opNOT:
258 case QgsMeshCalcNode::opIF:
259 case QgsMeshCalcNode::opSIGN:
260 case QgsMeshCalcNode::opMIN:
261 case QgsMeshCalcNode::opMAX:
262 case QgsMeshCalcNode::opABS:
263 return ( mLeft && mLeft->isNonTemporal() ) &&
264 ( mRight && mRight->isNonTemporal() );
266 case QgsMeshCalcNode::opSUM_AGGR:
267 case QgsMeshCalcNode::opMAX_AGGR:
268 case QgsMeshCalcNode::opMIN_AGGR:
269 case QgsMeshCalcNode::opAVG_AGGR:
270 case QgsMeshCalcNode::opNONE: