Skip to content

Commit

Permalink
show expressions in axis of placement in property editor
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Dec 22, 2016
1 parent 26c635a commit 938daf5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/Gui/propertyeditor/PropertyItem.cpp
Expand Up @@ -478,6 +478,15 @@ void PropertyItem::bind(const App::Property& prop) {
propertyBound();
}

QString PropertyItem::expressionAsString() const
{
if (hasExpression()) {
std::unique_ptr<App::Expression> result(getExpression()->eval());
return QString::fromStdString(result->toString());
}

return QString();
}

// --------------------------------------------------------------------

Expand Down Expand Up @@ -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<PropertyPlacementItem*>(this)->rot_angle = str.toDouble();
}
else {
const_cast<PropertyPlacementItem*>(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<PropertyPlacementItem*>(this)->rot_axis = dir;
const_cast<PropertyPlacementItem*>(this)->rot_angle = Base::toDegrees(angle);
const_cast<PropertyPlacementItem*>(this)->init_axis = true;
}
return QVariant::fromValue<Base::Placement>(value);
Expand Down
1 change: 1 addition & 0 deletions src/Gui/propertyeditor/PropertyItem.h
Expand Up @@ -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;
Expand Down

0 comments on commit 938daf5

Please sign in to comment.