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::opIF:
245 return ( mLeft && mLeft->isNonTemporal() ) &&
246 ( mRight && mRight->isNonTemporal() &&
247 mCondition->isNonTemporal() );
249 case QgsMeshCalcNode::opPLUS:
250 case QgsMeshCalcNode::opMINUS:
251 case QgsMeshCalcNode::opMUL:
252 case QgsMeshCalcNode::opDIV:
253 case QgsMeshCalcNode::opPOW:
254 case QgsMeshCalcNode::opEQ:
255 case QgsMeshCalcNode::opNE:
256 case QgsMeshCalcNode::opGT:
257 case QgsMeshCalcNode::opLT:
258 case QgsMeshCalcNode::opGE:
259 case QgsMeshCalcNode::opLE:
260 case QgsMeshCalcNode::opAND:
261 case QgsMeshCalcNode::opOR:
262 case QgsMeshCalcNode::opNOT:
263 case QgsMeshCalcNode::opSIGN:
264 case QgsMeshCalcNode::opMIN:
265 case QgsMeshCalcNode::opMAX:
266 case QgsMeshCalcNode::opABS:
267 return ( mLeft && mLeft->isNonTemporal() ) &&
268 ( mRight && mRight->isNonTemporal() );
270 case QgsMeshCalcNode::opSUM_AGGR:
271 case QgsMeshCalcNode::opMAX_AGGR:
272 case QgsMeshCalcNode::opMIN_AGGR:
273 case QgsMeshCalcNode::opAVG_AGGR:
274 case QgsMeshCalcNode::opNONE:
Class that represents a dataset group stored in memory.