show expressions in axis of placement in property editor
This commit is contained in:
parent
26c635a435
commit
938daf5c6d
|
@ -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();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
@ -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);
|
||||
|
|
|
@ -130,6 +130,7 @@ public:
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user