diff --git a/Modules/Core/include/mitkSinglePointDataInteractor.h b/Modules/Core/include/mitkSinglePointDataInteractor.h index d29f51ffd8..bf6b9ab5bb 100644 --- a/Modules/Core/include/mitkSinglePointDataInteractor.h +++ b/Modules/Core/include/mitkSinglePointDataInteractor.h @@ -1,61 +1,61 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef mitkSinglePointDataInteractor_h_ #define mitkSinglePointDataInteractor_h_ #include "itkObject.h" #include "itkObjectFactory.h" #include "itkSmartPointer.h" #include "mitkCommon.h" #include "mitkPointSetDataInteractor.h" #include #include namespace mitk { /** * Class SinglePointDataInteractor * \brief Implementation of the single point interaction * * Interactor operates on a single point set, when a data node is set, its containing point set is clear for * initialization. */ // Inherit from DataInteratcor, this provides functionality of a state machine and configurable inputs. class MITKCORE_EXPORT SinglePointDataInteractor : public PointSetDataInteractor { public: mitkClassMacro(SinglePointDataInteractor, PointSetDataInteractor); itkFactorylessNewMacro(Self); itkCloneMacro(Self); protected : SinglePointDataInteractor(); ~SinglePointDataInteractor() override; /** Adds a point at the given coordinates. * This function overwrites the behavior of PointSetDataInteractor such that instead of adding new points * the first points position is updated. All other interaction (move,delete) is still handled by * PointSetDataInteractor. */ void AddPoint(StateMachineAction *, InteractionEvent *event) override; /** * @brief SetMaxPoints Sets the maximal number of points for the pointset * Overwritten, per design this class will always have a maximal number of one. * @param maxNumber */ - virtual void SetMaxPoints(unsigned int maxNumber = 0) {} + virtual void SetMaxPoints(unsigned int maxNumber = 0); void DataNodeChanged() override; }; } #endif diff --git a/Modules/Core/src/Interactions/mitkSinglePointDataInteractor.cpp b/Modules/Core/src/Interactions/mitkSinglePointDataInteractor.cpp index de8540d84d..d15c92a1df 100644 --- a/Modules/Core/src/Interactions/mitkSinglePointDataInteractor.cpp +++ b/Modules/Core/src/Interactions/mitkSinglePointDataInteractor.cpp @@ -1,102 +1,106 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "mitkSinglePointDataInteractor.h" #include "mitkMouseMoveEvent.h" #include "mitkInteractionConst.h" // TODO: refactor file #include "mitkInternalEvent.h" #include "mitkOperationEvent.h" #include "mitkRenderingManager.h" #include // #include "mitkBaseRenderer.h" #include "mitkDispatcher.h" #include "mitkUndoController.h" mitk::SinglePointDataInteractor::SinglePointDataInteractor() { this->SetMaxPoints(1); } mitk::SinglePointDataInteractor::~SinglePointDataInteractor() { } void mitk::SinglePointDataInteractor::AddPoint(StateMachineAction * /*stateMachineAction*/, InteractionEvent *interactionEvent) { unsigned int timeStep = interactionEvent->GetSender()->GetTimeStep(GetDataNode()->GetData()); ScalarType timeInMs = interactionEvent->GetSender()->GetTime(); // To add a point the minimal information is the position, this method accepts all InteractionsPositionEvents auto *positionEvent = dynamic_cast(interactionEvent); if (positionEvent != nullptr) { PointOperation *doOp; PointOperation *undoOp; if (m_PointSet->IndexExists(0, timeStep)) { PointSet::PointType pt = m_PointSet->GetPoint(0, timeStep); Point3D itkPoint; itkPoint[0] = pt[0]; itkPoint[1] = pt[1]; itkPoint[2] = pt[2]; doOp = new mitk::PointOperation(OpMOVE, timeInMs, positionEvent->GetPositionInWorld(), 0); undoOp = new mitk::PointOperation(OpMOVE, timeInMs, itkPoint, 0); } else { doOp = new mitk::PointOperation(OpINSERT, timeInMs, positionEvent->GetPositionInWorld(), 0); undoOp = new mitk::PointOperation(OpREMOVE, timeInMs, positionEvent->GetPositionInWorld(), 0); } if (m_UndoEnabled) { OperationEvent *operationEvent = new OperationEvent(m_PointSet, doOp, undoOp, "Move point"); OperationEvent::IncCurrObjectEventId(); m_UndoController->SetOperationEvent(operationEvent); } // execute the Operation m_PointSet->ExecuteOperation(doOp); if (!m_UndoEnabled) delete doOp; RenderingManager::GetInstance()->RequestUpdateAll(); } } /* * Check whether the DataNode contains a pointset, if not create one and add it. */ void mitk::SinglePointDataInteractor::DataNodeChanged() { if (GetDataNode() != nullptr) { auto *points = dynamic_cast(GetDataNode()->GetData()); if (points == nullptr) { m_PointSet = PointSet::New(); GetDataNode()->SetData(m_PointSet); } else { points->Clear(); m_PointSet = points; } } } + +void mitk::SinglePointDataInteractor::SetMaxPoints(unsigned int) +{ +}