From 7ebfa3632d60592715b3fd1aa8007794c2b437db Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 1 Mar 2014 12:41:29 +0100 Subject: [PATCH] + fixes #0001453: Use string representation for PropertyPlacement editor that presevers double precision --- src/Gui/propertyeditor/PropertyItem.cpp | 22 ++++++++++++---------- src/Gui/propertyeditor/PropertyItem.h | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index f17660755..9d0361539 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -1387,7 +1387,7 @@ void PlacementEditor::updateValue(const QVariant& v, bool incr, bool data) TYPESYSTEM_SOURCE(Gui::PropertyEditor::PropertyPlacementItem, Gui::PropertyEditor::PropertyItem); -PropertyPlacementItem::PropertyPlacementItem() : init_axis(false), changed_value(false), rot_axis(0,0,1) +PropertyPlacementItem::PropertyPlacementItem() : init_axis(false), changed_value(false), rot_angle(0), rot_axis(0,0,1) { m_a = static_cast(PropertyAngleItem::create()); m_a->setParent(this); @@ -1434,6 +1434,7 @@ void PropertyPlacementItem::setAngle(double angle) rot.setValue(this->rot_axis, Base::toRadians(angle)); val.setRotation(rot); changed_value = true; + rot_angle = angle; setValue(QVariant::fromValue(val)); } @@ -1494,6 +1495,7 @@ QVariant PropertyPlacementItem::value(const App::Property* prop) const value.getRotation().getValue(dir, angle); if (!init_axis) { const_cast(this)->rot_axis = dir; + const_cast(this)->rot_angle = Base::toDegrees(angle); const_cast(this)->init_axis = true; } return QVariant::fromValue(value); @@ -1552,17 +1554,17 @@ void PropertyPlacementItem::setValue(const QVariant& value) changed_value = false; const Base::Placement& val = value.value(); Base::Vector3d pos = val.getPosition(); - const Base::Rotation& rt = val.getRotation(); + QString data = QString::fromAscii("App.Placement(" "App.Vector(%1,%2,%3)," - "App.Rotation(%4,%5,%6,%7))") - .arg(pos.x,0,'g',6) - .arg(pos.y,0,'g',6) - .arg(pos.z,0,'g',6) - .arg(rt[0],0,'g',6) - .arg(rt[1],0,'g',6) - .arg(rt[2],0,'g',6) - .arg(rt[3],0,'g',6); + "App.Rotation(App.Vector(%4,%5,%6),%7))") + .arg(pos.x,0,'f',decimals()) + .arg(pos.y,0,'f',decimals()) + .arg(pos.z,0,'f',decimals()) + .arg(rot_axis.x,0,'f',decimals()) + .arg(rot_axis.y,0,'f',decimals()) + .arg(rot_axis.z,0,'f',decimals()) + .arg(rot_angle,0,'f',decimals()); setPropertyValue(data); } diff --git a/src/Gui/propertyeditor/PropertyItem.h b/src/Gui/propertyeditor/PropertyItem.h index e4a551127..ffd65a4cc 100644 --- a/src/Gui/propertyeditor/PropertyItem.h +++ b/src/Gui/propertyeditor/PropertyItem.h @@ -475,6 +475,7 @@ protected: private: bool init_axis; bool changed_value; + double rot_angle; Base::Vector3d rot_axis; PropertyAngleItem * m_a; PropertyVectorItem* m_d;