Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class BeamAdapterActionController : public sofa::component::controller::Mechanic
/// Method to control the Beam using keyboard and save the actions in @sa d_actions
void onKeyPressedEvent(core::objectmodel::KeypressedEvent* kev) override;

void onKeyReleasedEvent(core::objectmodel::KeyreleasedEvent* kev) override;

/// Unused metho for mouse event
void onMouseEvent(core::objectmodel::MouseEvent* ev) override { SOFA_UNUSED(ev);}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <BeamAdapter/component/controller/BeamAdapterActionController.h>
#include <sofa/core/objectmodel/MouseEvent.h>
#include <sofa/core/objectmodel/KeypressedEvent.h>
#include <sofa/core/objectmodel/KeyreleasedEvent.h>

namespace beamadapter
{
Expand Down Expand Up @@ -69,10 +70,11 @@ void BeamAdapterActionController<DataTypes>::onKeyPressedEvent(core::objectmodel
{
if (!d_writeMode.getValue())
return;

/// Control keys for interventonal Radiology simulations:
switch (kev->getKey())
{

case 'E':
m_currAction = BeamAdapterAction::NO_ACTION;
m_exportActions = !m_exportActions;
Expand Down Expand Up @@ -108,6 +110,16 @@ void BeamAdapterActionController<DataTypes>::onKeyPressedEvent(core::objectmodel
}


template <class DataTypes>
void BeamAdapterActionController<DataTypes>::onKeyReleasedEvent(core::objectmodel::KeyreleasedEvent* kev)
{
if (!d_writeMode.getValue())
return;

m_currAction = BeamAdapterAction::NO_ACTION;
}


template <class DataTypes>
void BeamAdapterActionController<DataTypes>::onBeginAnimationStep(const double /*dt*/)
{
Expand All @@ -133,7 +145,6 @@ void BeamAdapterActionController<DataTypes>::onBeginAnimationStep(const double /
}

m_lastAction = m_currAction;
m_currAction = BeamAdapterAction::NO_ACTION;
}
else
{
Expand Down
Loading