Medical Imaging Interaction Toolkit  2018.4.99-1bab67a2
Medical Imaging Interaction Toolkit
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 (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 
13 #include "mitkDataInteractor.h"
14 #include "mitkDataNode.h"
15 #include "mitkStateMachineState.h"
16 
17 // Predefined internal events/signals
18 const std::string mitk::DataInteractor::IntDeactivateMe = "DeactivateMe";
19 const std::string mitk::DataInteractor::IntLeaveWidget = "LeaveWidget";
20 const std::string mitk::DataInteractor::IntEnterWidget = "EnterWidget";
21 
23 {
24 }
25 
27 {
28  if (!m_DataNode.IsExpired())
29  {
30  auto dataNode = m_DataNode.Lock();
31 
32  if (dataNode->GetDataInteractor() == this)
33  dataNode->SetDataInteractor(nullptr);
34  }
35 }
36 
38 {
39  return m_DataNode.Lock();
40 }
41 
43 {
44  if (dataNode == m_DataNode)
45  return;
46 
47  if (!m_DataNode.IsExpired())
48  m_DataNode.Lock()->SetDataInteractor(nullptr);
49 
50  m_DataNode = dataNode;
51 
52  if (dataNode != nullptr)
53  m_DataNode.Lock()->SetDataInteractor(this);
54 
55  this->DataNodeChanged();
56 }
57 
59 {
60  int layer = -1;
61 
62  if (!m_DataNode.IsExpired())
63  m_DataNode.Lock()->GetIntProperty("layer", layer);
64 
65  return layer;
66 }
67 
69 {
70  MITK_WARN << "DataInteractor::ConnectActionsAndFunctions() is not implemented.";
71 }
72 
74 {
75  auto mode = this->GetCurrentState()->GetMode();
76 
77  if (mode == "PREFER_INPUT")
78  return PREFERINPUT;
79 
80  if (mode == "GRAB_INPUT")
81  return GRABINPUT;
82 
83  return REGULAR;
84 }
85 
87 {
88  this->GetDataNode()->InvokeEvent(StartInteraction());
89 }
90 
92 {
93  this->GetDataNode()->InvokeEvent(ResultReady());
94 }
95 
97 {
98 }
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...
DataNode * GetDataNode() const
#define MITK_WARN
Definition: mitkLogMacros.h:19
StateMachineState * GetCurrentState() const
static const std::string IntDeactivateMe
virtual void NotifyStart()
Sends StartInteraction event via the mitk::DataNode.
void ConnectActionsAndFunctions() override
Overwrite this function to connect actions from StateMachine description with functions.
virtual void SetDataNode(DataNode *dataNode)
virtual void NotifyResultReady()
NotifyResultReady Sends ResultReady event via the mitk::DataNode.
ProcessEventMode GetMode() const
static const std::string IntEnterWidget
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57