Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkSegmentationInteractor.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
15 #include "mitkLabelSetImage.h"
16 #include "mitkToolManager.h"
19 
20 #include <cstring>
21 
23 {
25 
26  // CONNECT_FUNCTION("change_active_label", ChangeActiveLabel);
27 }
28 
30 {
31  BaseRenderer::Pointer sender = interactionEvent->GetSender();
32  auto *positionEvent = static_cast<InteractionPositionEvent *>(interactionEvent);
33 
34  // MLI TODO
35  // m_LastDisplayCoordinate = m_CurrentDisplayCoordinate;
36  // m_CurrentDisplayCoordinate = positionEvent->GetPointerPositionOnScreen();
37 
39  assert(toolManager);
40 
41  DataNode *workingNode(toolManager->GetWorkingData(0));
42  if (workingNode)
43  {
44  auto *workingImage = dynamic_cast<mitk::LabelSetImage *>(workingNode->GetData());
45  assert(workingImage);
46 
47  int timestep = positionEvent->GetSender()->GetTimeStep();
48  int pixelValue = static_cast<int>(workingImage->GetPixelValueByWorldCoordinate(positionEvent->GetPositionInWorld(), timestep));
49 
50  workingImage->GetActiveLabelSet()->SetActiveLabel(pixelValue); // can be the background
51 
52  // Call Events
53  // workingImage->ActiveLabelEvent.Send(pixelValue);
54 
55  // MLI TODO
56  // toolManager->WorkingDataModified.Send();
57  }
58 
60  return true;
61 }
Super class for all position events.
virtual mitk::ToolManager * GetToolManager()
Returns ToolManager object.
bool ChangeActiveLabel(StateMachineAction *, InteractionEvent *)
BaseRenderer * GetSender() const
static RenderingManager * GetInstance()
Represents an action, that is executed after a certain event (in statemachine-mechanism) TODO: implem...
LabelSetImage class for handling labels and layers in a segmentation session.
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
DataVectorType GetWorkingData()
static mitk::ToolManagerProvider * GetInstance()
Returns an instance of ToolManagerProvider service.
Manages and coordinates instances of mitk::Tool.