From 710542d121c2cabce05561591cfb00ef3b6e745c Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Fri, 25 Oct 2024 19:50:07 +0200 Subject: [PATCH] Assembly: Refactor get/setDraggerPlacement It seems that Base has very handy helpers for converting between various types. This simplifies code of ViewProviderAssembly::get/setDraggerPlacement a lot. --- src/Mod/Assembly/Gui/ViewProviderAssembly.cpp | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp b/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp index 674fc5dcf517..5eeae897761e 100644 --- a/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp @@ -71,6 +71,8 @@ #include "ViewProviderAssembly.h" #include "ViewProviderAssemblyPy.h" +#include + using namespace Assembly; using namespace AssemblyGui; @@ -1154,27 +1156,14 @@ bool ViewProviderAssembly::getDraggerVisibility() void ViewProviderAssembly::setDraggerPlacement(Base::Placement plc) { - double q0, q1, q2, q3; - plc.getRotation().getValue(q0, q1, q2, q3); - Base::Vector3d pos = plc.getPosition(); - asmDragger->rotation.setValue(q0, q1, q2, q3); - asmDragger->translation.setValue(pos.x, pos.y, pos.z); + asmDragger->rotation.setValue(Base::convertTo(plc.getRotation())); + asmDragger->translation.setValue(Base::convertTo(plc.getPosition())); } Base::Placement ViewProviderAssembly::getDraggerPlacement() { - Base::Placement plc; - SbVec3f pos = asmDragger->translation.getValue(); - plc.setPosition(Base::Vector3d(pos[0], pos[1], pos[2])); - - SbVec3f axis; - float angle; - asmDragger->rotation.getValue(axis, angle); - Base::Vector3d axisV = Base::Vector3d(axis[0], axis[1], axis[2]); - Base::Rotation rot(axisV, angle); - plc.setRotation(rot); - - return plc; + return {Base::convertTo(asmDragger->translation.getValue()), + Base::convertTo(asmDragger->rotation.getValue())}; } Gui::SoFCCSysDragger* ViewProviderAssembly::getDragger()