MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
QmitkUSAbstractNavigationStep.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
14#include "ui_QmitkUSAbstractNavigationStep.h"
15
17
19const char* QmitkUSAbstractNavigationStep::DATANAME_IMAGESTREAM = "US Image Stream";
21
23 QWidget(parent), m_NavigationStepState(State_Stopped)
24{
25}
26
30
32{
33 return this->OnStopStep() && this->OnStartStep();
34}
35
40
45
47{
48 m_DataStorage = dataStorage;
49}
50
52{
53 m_CombinedModality = combinedModality;
54 MITK_INFO << "Combined modality set to NULL: " << m_CombinedModality.IsNull();
55
57}
58
60{
61 if ( this->GetNavigationStepState() == State_Stopped && this->OnStartStep() )
62 {
63 m_NavigationStepState = State_Started;
64 return true;
65 }
66
67 return false;
68}
69
71{
72 if ( this->GetNavigationStepState() == State_Started ||
73 ( this->GetNavigationStepState() > State_Started && this->DeactivateStep() ) )
74 {
75 if ( this->OnStopStep() )
76 {
77 m_NavigationStepState = State_Stopped;
78 return true;
79 }
80 }
81
82 return false;
83}
84
89
91{
92 if ( this->GetNavigationStepState() > State_Started && this->DeactivateStep() )
93 {
94 if ( this->OnFinishStep() )
95 {
96 m_NavigationStepState = State_Started;
97 return true;
98 }
99 }
100
101 return false;
102}
103
105{
106 if ( this->GetNavigationStepState() == State_Started ||
107 ( this->GetNavigationStepState() < State_Started && this->StartStep() ) )
108 {
109 if ( this->OnActivateStep() )
110 {
111 m_NavigationStepState = State_Active;
112 return true;
113 }
114 }
115
116 return false;
117}
118
120{
121 if ( this->GetNavigationStepState() == State_Active )
122 {
123 if ( this->OnDeactivateStep() )
124 {
125 m_NavigationStepState = State_Started;
126 return true;
127 }
128 }
129
130 return false;
131}
132
137
142
144{
145 if ( throwNull && m_DataStorage.IsNull() )
146 {
147 MITK_ERROR << "Data storage must be set to step widget before.";
148 mitkThrow() << "Data storage must be set to step widget before.";
149 }
150
151 return m_DataStorage;
152}
153
155{
156 if ( throwNull && m_CombinedModality.IsNull() )
157 {
158 MITK_INFO << "Combined modality is not set yet for this widget.";
159 mitkThrow() << "Combined modality is not set yet for this widget.";
160 }
161
162 return m_CombinedModality;
163}
164
166{
167 if ( m_DataStorage.IsNull() )
168 {
169 MITK_ERROR << "Data storage must be set to step widget before.";
170 mitkThrow() << "Data storage must be set to step widget before.";
171 }
172
173 mitk::DataNode::Pointer sourceNode = m_DataStorage->GetNamedNode(sourceName);
174 if ( sourceNode.IsNull() )
175 {
176 MITK_WARN << "Source node cannot be found in data storage. Returning null.";
177 return nullptr;
178 }
179
180 return m_DataStorage->GetNamedDerivedNode(name, m_DataStorage->GetNamedNode(sourceName));
181}
182
184{
185 if ( m_DataStorage.IsNull() )
186 {
187 MITK_ERROR << "Data storage must be set to step widget before.";
188 mitkThrow() << "Data storage must be set to step widget before.";
189 }
190
191 mitk::DataNode::Pointer sourceNode = m_DataStorage->GetNamedNode(sourceName);
192 mitk::DataNode::Pointer dataNode = m_DataStorage->GetNamedDerivedNode(name, sourceNode);
193
194 if ( dataNode.IsNull() )
195 {
196 dataNode = mitk::DataNode::New();
197 dataNode->SetName(name);
198 if ( sourceNode.IsNotNull() )
199 {this->GetDataStorage()->Add(dataNode, sourceNode);}
200 else
201 {this->GetDataStorage()->Add(dataNode);}
202 }
203
204 return dataNode;
205}
itk::SmartPointer< mitk::DataStorage > GetDataStorage(bool throwNull=true)
Returns the data storage set for the navigation step.
NavigationStepState GetNavigationStepState()
Get the current state of the navigation step.
bool DeactivateStep()
Should be called to deactivate the navigation step.
virtual FilterVector GetFilter()
Getter for navigation data filters of the navigation step. This method may be implemented by a concre...
QmitkUSAbstractNavigationStep(QWidget *parent=nullptr)
void Update()
Should be called periodically while the navigation step is active. Internal, the method OnUpdate() is...
virtual bool OnDeactivateStep()
Called when the navigation step gets deactivated (-> state started). This method may be implemented b...
bool StopStep()
Should be called to stop the navigation step.
void SetCombinedModality(itk::SmartPointer< mitk::AbstractUltrasoundTrackerDevice > combinedModality)
Sets the combined modality for the navigation step. OnSetCombinedModality() is called internal.
virtual bool OnStartStep()=0
Called when the navigation step gets started. This method has to be implemented by a concrete subclas...
itk::SmartPointer< mitk::DataNode > GetNamedDerivedNodeAndCreate(const char *name, const char *sourceName)
Returns node with the given name and the given source node (parent) from the data storage....
bool RestartStep()
Should be called to restart the navigation step.
itk::SmartPointer< mitk::AbstractUltrasoundTrackerDevice > GetCombinedModality(bool throwNull=true)
Returns the combined modality set for the navigation step.
virtual void OnUpdate()=0
Called periodically while a navigation step is active. This method has to be implemented by a concret...
bool StartStep()
Should be called to start the navigation step.
virtual bool OnActivateStep()=0
Called when the navigation step gets activated. This method has to be implemented by a concrete subcl...
virtual bool GetIsRestartable()
Indicates if it makes sense to be able to restart the step. This method must be implemented by concre...
std::vector< itk::SmartPointer< mitk::NavigationDataToNavigationDataFilter > > FilterVector
virtual bool OnFinishStep()=0
Called when all necessary actions for the step where done. This method has to be implemented by a con...
bool ActivateStep()
Should be called to activate the navigation step. The step gets started before if it was stopped.
virtual bool OnRestartStep()
Called when restarting a navigation step. This method may be implemented by a concrete subclass to ha...
bool FinishStep()
Should be called to finish the navigation step. The state has to be 'active' before and is 'started' ...
void SetDataStorage(itk::SmartPointer< mitk::DataStorage > dataStorage)
Sets the data storage for the exchange of results between navigation steps.
itk::SmartPointer< mitk::DataNode > GetNamedDerivedNode(const char *name, const char *sourceName)
Returns node with the given name and the given source node (parent) from the data storage.
virtual bool OnStopStep()
Callen when the navigation step gets stopped. This method may be implemented by a concrete subclass t...
virtual void OnSetCombinedModality()
Called every time SetCombinedModality() was called. This method may be implemented by a concrete subc...