Medical Imaging Interaction Toolkit  2016.11.0
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,
6  Division of Medical and Biological Informatics.
7  All rights reserved.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without
10  even the implied warranty of MERCHANTABILITY or FITNESS FOR
11  A PARTICULAR PURPOSE.
12 
13  See LICENSE.txt or http://www.mitk.org for details.
14 
15  ===================================================================*/
16 
19 #include "mitkLabelSetImage.h"
20 #include "mitkToolManager.h"
22 
23 #include <string.h>
24 
26 {
28 
29  // CONNECT_FUNCTION("change_active_label", ChangeActiveLabel);
30 }
31 
33 {
34  BaseRenderer::Pointer sender = interactionEvent->GetSender();
35  InteractionPositionEvent *positionEvent = static_cast<InteractionPositionEvent *>(interactionEvent);
36 
37  // MLI TODO
38  // m_LastDisplayCoordinate = m_CurrentDisplayCoordinate;
39  // m_CurrentDisplayCoordinate = positionEvent->GetPointerPositionOnScreen();
40 
42  assert(toolManager);
43 
44  DataNode *workingNode(toolManager->GetWorkingData(0));
45  if (workingNode)
46  {
47  mitk::LabelSetImage *workingImage = dynamic_cast<mitk::LabelSetImage *>(workingNode->GetData());
48  assert(workingImage);
49 
50  int timestep = positionEvent->GetSender()->GetTimeStep();
51  int pixelValue = workingImage->GetPixelValueByWorldCoordinate(positionEvent->GetPositionInWorld(), timestep);
52  workingImage->GetActiveLabelSet()->SetActiveLabel(pixelValue); // can be the background
53 
54  // Call Events
55  // workingImage->ActiveLabelEvent.Send(pixelValue);
56 
57  // MLI TODO
58  // toolManager->WorkingDataModified.Send();
59  }
60 
61  sender->GetRenderingManager()->RequestUpdateAll();
62  return true;
63 }
Super class for all position events.
BaseRenderer * GetSender() const
virtual mitk::ToolManager * GetToolManager()
Returns ToolManager object.
bool ChangeActiveLabel(StateMachineAction *, InteractionEvent *)
double GetPixelValueByWorldCoordinate(const mitk::Point3D &position, unsigned int timestep=0, unsigned int component=0)
Get the pixel value at one specific world position.
Definition: mitkImage.cpp:203
Represents an action, that is executed after a certain event (in statemachine-mechanism) TODO: implem...
mitk::LabelSet * GetActiveLabelSet()
Returns the currently active mitk::LabelSet.
virtual unsigned int GetTimeStep() const
LabelSetImage class for handling labels and layers in a segmentation session.
void SetActiveLabel(PixelType)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
DataVectorType GetWorkingData()
static mitk::ToolManagerProvider * GetInstance()
Returns an instance of ToolManagerProvider service.
Manages and coordinates instances of mitk::Tool.