diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 5f65b52a3a52..bb1277cf6b82 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -478,6 +478,15 @@ void PropertyItem::bind(const App::Property& prop) { propertyBound(); } +QString PropertyItem::expressionAsString() const +{ + if (hasExpression()) { + std::unique_ptr result(getExpression()->eval()); + return QString::fromStdString(result->toString()); + } + + return QString(); +} // -------------------------------------------------------------------- @@ -1863,8 +1872,30 @@ QVariant PropertyPlacementItem::value(const App::Property* prop) const Base::Vector3d dir; value.getRotation().getValue(dir, angle); if (!init_axis) { + if (m_a->hasExpression()) { + QString str = m_a->expressionAsString(); + const_cast(this)->rot_angle = str.toDouble(); + } + else { + const_cast(this)->rot_angle = Base::toDegrees(angle); + } + + PropertyItem* x = m_d->child(0); + PropertyItem* y = m_d->child(1); + PropertyItem* z = m_d->child(2); + if (x->hasExpression()) { + QString str = x->expressionAsString(); + dir.x = str.toDouble(); + } + if (y->hasExpression()) { + QString str = y->expressionAsString(); + dir.y = str.toDouble(); + } + if (z->hasExpression()) { + QString str = z->expressionAsString(); + dir.z = str.toDouble(); + } const_cast(this)->rot_axis = dir; - const_cast(this)->rot_angle = Base::toDegrees(angle); const_cast(this)->init_axis = true; } return QVariant::fromValue(value); diff --git a/src/Gui/propertyeditor/PropertyItem.h b/src/Gui/propertyeditor/PropertyItem.h index 972b8019db16..3afe6240a00f 100644 --- a/src/Gui/propertyeditor/PropertyItem.h +++ b/src/Gui/propertyeditor/PropertyItem.h @@ -130,6 +130,7 @@ class GuiExport PropertyItem : public QObject, public ExpressionBinding virtual void bind(const App::Property& prop); virtual void bind(const App::ObjectIdentifier& _path); virtual void propertyBound() {} + QString expressionAsString() const; void setParent(PropertyItem* parent); PropertyItem *parent() const;