From 8d9d34c283415498990bf89d11d1c7557763e49b Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Wed, 18 Sep 2024 12:10:15 +0200 Subject: [PATCH 1/2] Rename igtLinkMouseInteractor to PickingInteractor because it can be used outside IGTLink --- scenes/PickingInteractor.log | 17 ++++++++++++++ ...nge.scn => PickingInteractor_Lagrange.scn} | 2 +- ...pring.scn => PickingInteractor_Spring.scn} | 2 +- src/sofa/igtlink/utils/PickingInteractor.cpp | 11 ++++++++++ ...kMouseInteractor.h => PickingInteractor.h} | 8 +++---- ...seInteractor.inl => PickingInteractor.inl} | 22 +++++++++---------- .../igtlink/utils/iGTLinkMouseInteractor.cpp | 11 ---------- 7 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 scenes/PickingInteractor.log rename scenes/{iGTLinkMouseInteractor_Lagrange.scn => PickingInteractor_Lagrange.scn} (97%) rename scenes/{iGTLinkMouseInteractor_Spring.scn => PickingInteractor_Spring.scn} (97%) create mode 100644 src/sofa/igtlink/utils/PickingInteractor.cpp rename src/sofa/igtlink/utils/{iGTLinkMouseInteractor.h => PickingInteractor.h} (79%) rename src/sofa/igtlink/utils/{iGTLinkMouseInteractor.inl => PickingInteractor.inl} (88%) delete mode 100644 src/sofa/igtlink/utils/iGTLinkMouseInteractor.cpp diff --git a/scenes/PickingInteractor.log b/scenes/PickingInteractor.log new file mode 100644 index 0000000..252a13f --- /dev/null +++ b/scenes/PickingInteractor.log @@ -0,0 +1,17 @@ + +--- NEW SESSION: 27/03/2024 17:20:11 --- +/FEM/Surface/contactMouse/AttachedPoint.showColor = 1 1 1 1 + +--- NEW SESSION: 27/03/2024 17:32:29 --- +/FEM/Surface/contactMouse/AttachedPoint.showColor = 1 1 1 1 + +--- NEW SESSION: 27/03/2024 17:48:48 --- +/AttachPoint/mstate.showColor = 1 1 1 1 + +--- NEW SESSION: 27/03/2024 17:54:25 --- +/FEM/mstate.mappingJacobian = Constraint ID : 0 dof ID : 174 value : 0 0 0 dof ID : 298 value : 0 0 0 dof ID : 299 value : 0 0 0 dof ID : 324 value : 1 0 0 +Constraint ID : 1 dof ID : 174 value : 0 0 0 dof ID : 298 value : 0 0 0 dof ID : 299 value : 0 0 0 dof ID : 324 value : 0 1 0 +Constraint ID : 2 dof ID : 174 value : 0 0 0 dof ID : 298 value : 0 0 0 dof ID : 299 value : 0 0 0 dof ID : 324 value : 0 0 1 + +/FEM/mstate.showColor = 1 1 1 1 +/AttachPoint/mstate.showColor = 1 1 1 1 diff --git a/scenes/iGTLinkMouseInteractor_Lagrange.scn b/scenes/PickingInteractor_Lagrange.scn similarity index 97% rename from scenes/iGTLinkMouseInteractor_Lagrange.scn rename to scenes/PickingInteractor_Lagrange.scn index dfb6a55..faeacd3 100755 --- a/scenes/iGTLinkMouseInteractor_Lagrange.scn +++ b/scenes/PickingInteractor_Lagrange.scn @@ -96,7 +96,7 @@ - + diff --git a/scenes/iGTLinkMouseInteractor_Spring.scn b/scenes/PickingInteractor_Spring.scn similarity index 97% rename from scenes/iGTLinkMouseInteractor_Spring.scn rename to scenes/PickingInteractor_Spring.scn index 2557ac1..1c9d32b 100755 --- a/scenes/iGTLinkMouseInteractor_Spring.scn +++ b/scenes/PickingInteractor_Spring.scn @@ -92,7 +92,7 @@ - + diff --git a/src/sofa/igtlink/utils/PickingInteractor.cpp b/src/sofa/igtlink/utils/PickingInteractor.cpp new file mode 100644 index 0000000..fe13c15 --- /dev/null +++ b/src/sofa/igtlink/utils/PickingInteractor.cpp @@ -0,0 +1,11 @@ +#include +#include + +namespace sofa::openigtlink { + +SOFA_DECL_CLASS(PickingInteractor) + +int PickingInteractorClass = core::RegisterObject("") + .add>(true); + +} \ No newline at end of file diff --git a/src/sofa/igtlink/utils/iGTLinkMouseInteractor.h b/src/sofa/igtlink/utils/PickingInteractor.h similarity index 79% rename from src/sofa/igtlink/utils/iGTLinkMouseInteractor.h rename to src/sofa/igtlink/utils/PickingInteractor.h index e17becf..92c6d53 100644 --- a/src/sofa/igtlink/utils/iGTLinkMouseInteractor.h +++ b/src/sofa/igtlink/utils/PickingInteractor.h @@ -19,9 +19,9 @@ namespace sofa::openigtlink { template -class iGTLinkMouseInteractor : public sofa::gui::component::performer::MouseInteractor { +class PickingInteractor : public sofa::gui::component::performer::MouseInteractor { public: - SOFA_CLASS(SOFA_TEMPLATE(iGTLinkMouseInteractor,DataTypes), SOFA_TEMPLATE(sofa::gui::component::performer::MouseInteractor,DataTypes)); + SOFA_CLASS(SOFA_TEMPLATE(PickingInteractor,DataTypes), SOFA_TEMPLATE(sofa::gui::component::performer::MouseInteractor,DataTypes)); typedef typename DataTypes::Coord Coord; typedef typename DataTypes::VecCoord VecCoord; @@ -32,10 +32,10 @@ class iGTLinkMouseInteractor : public sofa::gui::component::performer::MouseInte Data< double > d_springStiffness; Data< unsigned > d_reactionTime; - SingleLink l_destCollisionModel; + SingleLink l_destCollisionModel; - iGTLinkMouseInteractor(); + PickingInteractor(); virtual void updatePosition( SReal dt) override; diff --git a/src/sofa/igtlink/utils/iGTLinkMouseInteractor.inl b/src/sofa/igtlink/utils/PickingInteractor.inl similarity index 88% rename from src/sofa/igtlink/utils/iGTLinkMouseInteractor.inl rename to src/sofa/igtlink/utils/PickingInteractor.inl index db34bc3..bf90a07 100644 --- a/src/sofa/igtlink/utils/iGTLinkMouseInteractor.inl +++ b/src/sofa/igtlink/utils/PickingInteractor.inl @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -15,7 +15,7 @@ namespace sofa::openigtlink { template -iGTLinkMouseInteractor::iGTLinkMouseInteractor() +PickingInteractor::PickingInteractor() : d_pickingType(initData(&d_pickingType,"pickingType","Mouse interaction type, could be \'constraint\' or \'spring\'")) , d_positions(initData(&d_positions, "position", "Position")) , d_springStiffness(initData(&d_springStiffness,10.0,"springStiffness","Stiffness of attachment spring used for interaction")) @@ -31,10 +31,10 @@ iGTLinkMouseInteractor::iGTLinkMouseInteractor() this->f_listening.setValue(true); c_positions.addInput(&d_positions); - c_positions.addCallback(std::bind(&iGTLinkMouseInteractor::positionChanged,this)); + c_positions.addCallback(std::bind(&PickingInteractor::positionChanged,this)); c_attachmentType.addInput(&d_pickingType); - c_attachmentType.addCallback(std::bind(&iGTLinkMouseInteractor::attachmentChanged,this)); + c_attachmentType.addCallback(std::bind(&PickingInteractor::attachmentChanged,this)); m_lastChange = std::chrono::high_resolution_clock::now(); //Make sure the constraint is inactive @@ -43,13 +43,13 @@ iGTLinkMouseInteractor::iGTLinkMouseInteractor() template -void iGTLinkMouseInteractor::positionChanged() +void PickingInteractor::positionChanged() { m_lastChange = std::chrono::high_resolution_clock::now(); } template -void iGTLinkMouseInteractor::attachmentChanged() +void PickingInteractor::attachmentChanged() { if(m_performer) { @@ -66,14 +66,14 @@ void iGTLinkMouseInteractor::attachmentChanged() } template -void iGTLinkMouseInteractor::updatePosition( SReal dt) +void PickingInteractor::updatePosition( SReal dt) { SOFA_UNUSED(dt); //Do nothing, see handleEvent } template -void iGTLinkMouseInteractor::startPerformer() +void PickingInteractor::startPerformer() { if(!m_performer || m_performerStarted || !d_positions.getValue().size()) return; @@ -95,7 +95,7 @@ void iGTLinkMouseInteractor::startPerformer() template -void iGTLinkMouseInteractor::stopPerformer() +void PickingInteractor::stopPerformer() { if(!m_performer || !m_performerStarted) return; @@ -106,7 +106,7 @@ void iGTLinkMouseInteractor::stopPerformer() } template -sofa::Index iGTLinkMouseInteractor::findCollidingElem(const type::Vec3& pos) const +sofa::Index PickingInteractor::findCollidingElem(const type::Vec3& pos) const { sofa::Index closestElem = l_destCollisionModel->begin().getIndex(); double closestDist = std::numeric_limits::max(); @@ -155,7 +155,7 @@ sofa::Index iGTLinkMouseInteractor::findCollidingElem(const type::Vec template -void iGTLinkMouseInteractor::handleEvent(sofa::core::objectmodel::Event *event) +void PickingInteractor::handleEvent(sofa::core::objectmodel::Event *event) { if (dynamic_cast(event)) { diff --git a/src/sofa/igtlink/utils/iGTLinkMouseInteractor.cpp b/src/sofa/igtlink/utils/iGTLinkMouseInteractor.cpp deleted file mode 100644 index da65a21..0000000 --- a/src/sofa/igtlink/utils/iGTLinkMouseInteractor.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -namespace sofa::openigtlink { - -SOFA_DECL_CLASS(iGTLinkMouseInteractor) - -int iGTLinkMouseInteractorClass = core::RegisterObject("") - .add>(true); - -} \ No newline at end of file From dabf30a60c84e95f3acdb6fac18937b1a9decd41 Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Wed, 18 Sep 2024 12:11:29 +0200 Subject: [PATCH 2/2] remove log --- scenes/PickingInteractor.log | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 scenes/PickingInteractor.log diff --git a/scenes/PickingInteractor.log b/scenes/PickingInteractor.log deleted file mode 100644 index 252a13f..0000000 --- a/scenes/PickingInteractor.log +++ /dev/null @@ -1,17 +0,0 @@ - ---- NEW SESSION: 27/03/2024 17:20:11 --- -/FEM/Surface/contactMouse/AttachedPoint.showColor = 1 1 1 1 - ---- NEW SESSION: 27/03/2024 17:32:29 --- -/FEM/Surface/contactMouse/AttachedPoint.showColor = 1 1 1 1 - ---- NEW SESSION: 27/03/2024 17:48:48 --- -/AttachPoint/mstate.showColor = 1 1 1 1 - ---- NEW SESSION: 27/03/2024 17:54:25 --- -/FEM/mstate.mappingJacobian = Constraint ID : 0 dof ID : 174 value : 0 0 0 dof ID : 298 value : 0 0 0 dof ID : 299 value : 0 0 0 dof ID : 324 value : 1 0 0 -Constraint ID : 1 dof ID : 174 value : 0 0 0 dof ID : 298 value : 0 0 0 dof ID : 299 value : 0 0 0 dof ID : 324 value : 0 1 0 -Constraint ID : 2 dof ID : 174 value : 0 0 0 dof ID : 298 value : 0 0 0 dof ID : 299 value : 0 0 0 dof ID : 324 value : 0 0 1 - -/FEM/mstate.showColor = 1 1 1 1 -/AttachPoint/mstate.showColor = 1 1 1 1