Skip to content

Commit

Permalink
Merge pull request #8 from bakpaul/rename_igtlinkmouseinteractor
Browse files Browse the repository at this point in the history
Rename igtlinkmouseinteractor
  • Loading branch information
bakpaul authored Dec 10, 2024
2 parents 345e19d + dabf30a commit 75bcb62
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<PointSetTopologyContainer name="Container" />
<PointSetTopologyModifier name="Modifier"/>
<MechanicalObject name="mstate" template="Vec3d" position="0.5 0.05 0.05" drawMode="2" showObjectScale="0.01" showObject="false"/>
<iGTLinkMouseInteractor pickingType="constraint" position="0 0 0" reactionTime="20000" destCollisionModel="@../FEM/Surface/Torus8CMT"/>
<PickingInteractor pickingType="constraint" position="0 0 0" reactionTime="20000" destCollisionModel="@../FEM/Surface/Torus8CMT"/>

</Node>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<PointSetTopologyContainer name="Container" />
<PointSetTopologyModifier name="Modifier"/>
<MechanicalObject name="mstate" template="Vec3d" drawMode="2" showObjectScale="0.01" showObject="false"/>
<iGTLinkMouseInteractor pickingType="spring" reactionTime="20000" destCollisionModel="@../FEM/Surface/Torus8CMT"/>
<PickingInteractor pickingType="spring" reactionTime="20000" destCollisionModel="@../FEM/Surface/Torus8CMT"/>

</Node>

Expand Down
11 changes: 11 additions & 0 deletions src/sofa/igtlink/utils/PickingInteractor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <sofa/igtlink/utils/PickingInteractor.inl>
#include <sofa/core/ObjectFactory.h>

namespace sofa::openigtlink {

SOFA_DECL_CLASS(PickingInteractor)

int PickingInteractorClass = core::RegisterObject("")
.add<PickingInteractor<defaulttype::Vec3Types>>(true);

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
namespace sofa::openigtlink {

template<class DataTypes>
class iGTLinkMouseInteractor : public sofa::gui::component::performer::MouseInteractor<DataTypes> {
class PickingInteractor : public sofa::gui::component::performer::MouseInteractor<DataTypes> {
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;
Expand All @@ -32,10 +32,10 @@ class iGTLinkMouseInteractor : public sofa::gui::component::performer::MouseInte
Data< double > d_springStiffness;
Data< unsigned > d_reactionTime;

SingleLink<iGTLinkMouseInteractor, core::CollisionModel, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_destCollisionModel;
SingleLink<PickingInteractor, core::CollisionModel, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_destCollisionModel;


iGTLinkMouseInteractor();
PickingInteractor();

virtual void updatePosition( SReal dt) override;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <sofa/igtlink/utils/iGTLinkMouseInteractor.h>
#include <sofa/igtlink/utils/PickingInteractor.h>
#include <sofa/simulation/AnimateBeginEvent.h>
#include <sofa/simulation/AnimateEndEvent.h>
#include <sofa/gui/component/performer/ConstraintAttachBodyPerformer.h>
Expand All @@ -15,7 +15,7 @@ namespace sofa::openigtlink
{

template<class DataTypes>
iGTLinkMouseInteractor<DataTypes>::iGTLinkMouseInteractor()
PickingInteractor<DataTypes>::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"))
Expand All @@ -31,10 +31,10 @@ iGTLinkMouseInteractor<DataTypes>::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
Expand All @@ -43,13 +43,13 @@ iGTLinkMouseInteractor<DataTypes>::iGTLinkMouseInteractor()


template<class DataTypes>
void iGTLinkMouseInteractor<DataTypes>::positionChanged()
void PickingInteractor<DataTypes>::positionChanged()
{
m_lastChange = std::chrono::high_resolution_clock::now();
}

template<class DataTypes>
void iGTLinkMouseInteractor<DataTypes>::attachmentChanged()
void PickingInteractor<DataTypes>::attachmentChanged()
{
if(m_performer)
{
Expand All @@ -66,14 +66,14 @@ void iGTLinkMouseInteractor<DataTypes>::attachmentChanged()
}

template<class DataTypes>
void iGTLinkMouseInteractor<DataTypes>::updatePosition( SReal dt)
void PickingInteractor<DataTypes>::updatePosition( SReal dt)
{
SOFA_UNUSED(dt);
//Do nothing, see handleEvent
}

template<class DataTypes>
void iGTLinkMouseInteractor<DataTypes>::startPerformer()
void PickingInteractor<DataTypes>::startPerformer()
{
if(!m_performer || m_performerStarted || !d_positions.getValue().size())
return;
Expand All @@ -95,7 +95,7 @@ void iGTLinkMouseInteractor<DataTypes>::startPerformer()


template<class DataTypes>
void iGTLinkMouseInteractor<DataTypes>::stopPerformer()
void PickingInteractor<DataTypes>::stopPerformer()
{
if(!m_performer || !m_performerStarted)
return;
Expand All @@ -106,7 +106,7 @@ void iGTLinkMouseInteractor<DataTypes>::stopPerformer()
}

template<class DataTypes>
sofa::Index iGTLinkMouseInteractor<DataTypes>::findCollidingElem(const type::Vec3& pos) const
sofa::Index PickingInteractor<DataTypes>::findCollidingElem(const type::Vec3& pos) const
{
sofa::Index closestElem = l_destCollisionModel->begin().getIndex();
double closestDist = std::numeric_limits<double>::max();
Expand Down Expand Up @@ -155,7 +155,7 @@ sofa::Index iGTLinkMouseInteractor<DataTypes>::findCollidingElem(const type::Vec


template<class DataTypes>
void iGTLinkMouseInteractor<DataTypes>::handleEvent(sofa::core::objectmodel::Event *event)
void PickingInteractor<DataTypes>::handleEvent(sofa::core::objectmodel::Event *event)
{
if (dynamic_cast<sofa::simulation::AnimateEndEvent*>(event))
{
Expand Down
11 changes: 0 additions & 11 deletions src/sofa/igtlink/utils/iGTLinkMouseInteractor.cpp

This file was deleted.

0 comments on commit 75bcb62

Please sign in to comment.