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();
107 bool QgsMeshCalcNode::calculate(
const QgsMeshCalcUtils &dsu, QgsMeshMemoryDatasetGroup &result )
const 109 if ( mType == tDatasetGroupRef )
111 dsu.copy( result, mDatasetGroupName );
114 else if ( mType == tOperator )
116 QgsMeshMemoryDatasetGroup leftDatasetGroup(
"left" );
117 QgsMeshMemoryDatasetGroup rightDatasetGroup(
"right" );
119 if ( !mLeft || !mLeft->calculate( dsu, leftDatasetGroup ) )
123 if ( mRight && !mRight->calculate( dsu, rightDatasetGroup ) )
128 QgsMeshMemoryDatasetGroup condition(
"condition" );
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 );