Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkDataInteractor.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 
17 #include "mitkDataInteractor.h"
18 #include "mitkDataNode.h"
19 #include "mitkStateMachineState.h"
20 
21 // Predefined internal events/signals
22 const std::string mitk::DataInteractor::IntDeactivateMe = "DeactivateMe";
23 const std::string mitk::DataInteractor::IntLeaveWidget = "LeaveWidget";
24 const std::string mitk::DataInteractor::IntEnterWidget = "EnterWidget";
25 
27 {
28 }
29 
31 {
32  if (m_DataNode.IsNotNull())
33  {
34  if (m_DataNode->GetDataInteractor() == this)
35  m_DataNode->SetDataInteractor(nullptr);
36  }
37 }
38 
40 {
41  return m_DataNode;
42 }
43 
45 {
46  if (dataNode == m_DataNode)
47  return;
48 
49  if (m_DataNode.IsNotNull())
50  m_DataNode->SetDataInteractor(nullptr);
51 
52  m_DataNode = dataNode;
53 
54  if (dataNode != nullptr)
55  m_DataNode->SetDataInteractor(this);
56 
57  this->DataNodeChanged();
58 }
59 
61 {
62  int layer = -1;
63 
64  if (m_DataNode.IsNotNull())
65  m_DataNode->GetIntProperty("layer", layer);
66 
67  return layer;
68 }
69 
71 {
72  MITK_WARN << "DataInteractor::ConnectActionsAndFunctions() is not implemented.";
73 }
74 
75 mitk::ProcessEventMode mitk::DataInteractor::GetMode() const
76 {
77  auto mode = this->GetCurrentState()->GetMode();
78 
79  if (mode == "PREFER_INPUT")
80  return PREFERINPUT;
81 
82  if (mode == "GRAB_INPUT")
83  return GRABINPUT;
84 
85  return REGULAR;
86 }
87 
89 {
90  this->GetDataNode()->InvokeEvent(StartInteraction());
91 }
92 
94 {
95  this->GetDataNode()->InvokeEvent(ResultReady());
96 }
97 
99 {
100 }
static const std::string IntLeaveWidget
virtual void DataNodeChanged()
Is called when a DataNode is initially set or changed To be implemented by sub-classes for initializa...
virtual void DataNodeChanged() override
Called when a DataNode has been set/changed.
#define MITK_WARN
Definition: mitkLogMacros.h:23
static const std::string IntDeactivateMe
ProcessEventMode GetMode() const
virtual void NotifyStart()
Sends StartInteraction event via the mitk::DataNode.
virtual void ConnectActionsAndFunctions() override
Overwrite this function to connect actions from StateMachine description with functions.
DataNode * GetDataNode() const
virtual void SetDataNode(DataNode *dataNode)
virtual void NotifyResultReady()
NotifyResultReady Sends ResultReady event via the mitk::DataNode.
virtual void SetDataInteractor(const DataInteractor::Pointer interactor)
Set the Interactor.
static const std::string IntEnterWidget
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66