| 589 | } |
| 590 | |
| 591 | void DlgExpressionInput::applyImpliedUnit() |
| 592 | { |
| 593 | if (!expression || impliedUnit == Base::Unit::One) { |
| 594 | return; |
| 595 | } |
| 596 | |
| 597 | std::unique_ptr<App::Expression> evaluated(expression->eval()); |
| 598 | const auto* numberExpr = toNumberExpr(evaluated.get()); |
| 599 | if (!numberExpr || !numberExpr->getQuantity().isDimensionless()) { |
| 600 | return; |
| 601 | } |
| 602 | |
| 603 | double factor = 1.0; |
| 604 | std::string unitString; |
| 605 | Base::Quantity(1.0, impliedUnit).getUserString(factor, unitString); |
| 606 | if (unitString.empty()) { |
| 607 | return; |
| 608 | } |
| 609 | |
| 610 | auto left = expression->copy(); |
| 611 | auto right = std::make_unique<App::UnitExpression>( |
| 612 | path.getDocumentObject(), |
| 613 | Base::Quantity(factor, impliedUnit), |
| 614 | unitString |
| 615 | ); |
| 616 | expression = std::make_shared<App::OperatorExpression>( |
| 617 | path.getDocumentObject(), |
| 618 | left.release(), |
| 619 | App::OperatorExpression::Operator::UNIT, |
| 620 | right.release() |
| 621 | ); |
| 622 | } |
| 623 | |
| 624 | void DlgExpressionInput::createBindingVarSet(App::Property* propVarSet, App::DocumentObject* varSet) |
| 625 | { |
nothing calls this directly
no test coverage detected