Medical Imaging Interaction Toolkit  2018.4.99-87d68d9f
Medical Imaging Interaction Toolkit
mitkUSTelemedBModeControls.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 
14 #include "mitkUSTelemedDevice.h"
15 #include <mitkException.h>
16 
17 #define TELEMED_FREQUENCY_FACTOR 1000000
18 
20 : mitk::USControlInterfaceBMode(device.GetPointer()),
21  m_UsgDataView(0), m_PowerControl(0), m_FrequencyControl(0),
22  m_DepthControl(0), m_GainControl(0), m_RejectionControl(0),
23  m_DynamicRangeControl(0),
24  m_Active(false), m_PowerSteps(new double[3]),
25  m_GainSteps(new double[3]), m_RejectionSteps(new double[3]),
26  m_DynamicRangeSteps(new double[3])
27 {
28 }
29 
31 {
32  this->ReleaseControls();
33 
34  delete[] m_PowerSteps;
35  delete[] m_GainSteps;
36  delete[] m_RejectionSteps;
37  delete[] m_DynamicRangeSteps;
38 }
39 
40 void mitk::USTelemedBModeControls::SetUsgDataView( Usgfw2Lib::IUsgDataView* usgDataView)
41 {
42  m_UsgDataView = usgDataView;
43 }
44 
46 {
47  this->ReleaseControls();
48  this->CreateControls();
49 }
50 
52 {
53  if (active)
54  {
55  HRESULT hr = m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_STOP);
56  if (FAILED(hr)) { mitkThrow() << "Could not stop scanning (" << hr << ")."; }
57 
58  // make sure that current scan mode is b mode now
59  hr = m_UsgDataView->put_ScanMode(Usgfw2Lib::SCAN_MODE_B);
60  if (FAILED(hr)) { mitkThrow() << "Could not set scan mode b (" << hr << ")."; }
61 
62  hr = m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_RUN);
63  if (FAILED(hr)) { mitkThrow() << "Could not start scanning (" << hr << ")."; }
64 
65  this->CreateControls();
66 
67  m_Active = true;
68  }
69  else
70  {
71  this->ReleaseControls();
72 
73  m_Active = false;
74  }
75 }
76 
78 {
79  // get scan mode, because scan mode must be B mode
80  // for this interface being active
81  ULONG scanMode;
82  HRESULT hr = m_UsgDataView->get_ScanMode(&scanMode);
83  if (FAILED(hr)) { mitkThrow() << "Could not get scan mode (" << hr << ")."; }
84 
85  return m_Active && scanMode == Usgfw2Lib::SCAN_MODE_B;
86 }
87 
89 {
91 }
92 
94 {
96 }
97 
99 {
101 }
102 
104 {
106 }
107 
109 {
111 }
112 
114 {
116 }
117 
119 {
120  return m_PowerSteps[0];
121 }
122 
124 {
125  return m_PowerSteps[1];
126 }
127 
129 {
130  return m_PowerSteps[2];
131 }
132 
134 {
136 }
137 
139 {
141 }
142 
144 {
146 }
147 
149 {
151 }
152 
154 {
156 }
157 
159 {
160  return m_GainSteps[0];
161 }
162 
164 {
165  return m_GainSteps[1];
166 }
167 
169 {
170  return m_GainSteps[2];
171 }
172 
174 {
176 }
177 
179 {
181 }
182 
184 {
185  return m_RejectionSteps[0];
186 }
187 
189 {
190  return m_RejectionSteps[1];
191 }
192 
194 {
195  return m_RejectionSteps[2];
196 }
197 
199 {
201 }
202 
204 {
206 }
207 
209 {
210  return m_DynamicRangeSteps[0];
211 }
212 
214 {
215  return m_DynamicRangeSteps[1];
216 }
217 
219 {
220  return m_DynamicRangeSteps[2];
221 }
222 
224 {
225  // create frequency control
226  CREATE_TelemedControl(m_FrequencyControl, m_UsgDataView, Usgfw2Lib::IID_IUsgProbeFrequency2, Usgfw2Lib::IUsgProbeFrequency2, Usgfw2Lib::SCAN_MODE_B);
227 
228  // create power control
229  CREATE_TelemedControl(m_PowerControl, m_UsgDataView, Usgfw2Lib::IID_IUsgPower, Usgfw2Lib::IUsgPower, Usgfw2Lib::SCAN_MODE_B);
230  GETINOUTPUT_TelemedAvailableValuesBounds(m_PowerControl, m_PowerSteps); // get min, max and tick for gain
231 
232  // create B mode depth control
233  CREATE_TelemedControl(m_DepthControl, m_UsgDataView, Usgfw2Lib::IID_IUsgDepth, Usgfw2Lib::IUsgDepth, Usgfw2Lib::SCAN_MODE_B);
234 
235  // create B mode gain control
236  CREATE_TelemedControl(m_GainControl, m_UsgDataView, Usgfw2Lib::IID_IUsgGain, Usgfw2Lib::IUsgGain, Usgfw2Lib::SCAN_MODE_B);
237  GETINOUTPUT_TelemedAvailableValuesBounds(m_GainControl, m_GainSteps); // get min, max and tick for gain
238 
239  // create B mode rejection control
240  CREATE_TelemedControl(m_RejectionControl, m_UsgDataView, Usgfw2Lib::IID_IUsgRejection2, Usgfw2Lib::IUsgRejection2, Usgfw2Lib::SCAN_MODE_B);
241  GETINOUTPUT_TelemedAvailableValuesBounds(m_RejectionControl, m_RejectionSteps); // get min, max and tick for rejection
242 
243  // create B mode dynamic range control
244  CREATE_TelemedControl(m_DynamicRangeControl, m_UsgDataView, Usgfw2Lib::IID_IUsgDynamicRange, Usgfw2Lib::IUsgDynamicRange, Usgfw2Lib::SCAN_MODE_B);
245  GETINOUTPUT_TelemedAvailableValuesBounds(m_DynamicRangeControl, m_DynamicRangeSteps); // get min, max and tick for dynamic range
246 }
247 
249 {
250  // remove all controls and delete their objects
257 }
virtual void OnSetScanningGain(double)
Virtual method which is called inside mitk::USControlInterfaceBMode::SetScanningGain. Implement this method to handle the actual setting of the value at the device api.
USTelemedBModeControls(itk::SmartPointer< USTelemedDevice > device)
#define CREATE_TelemedControl(control, dataView, iidType, type, scanMode)
virtual void OnSetScanningPower(double power)
Virtual method which is called inside mitk::USControlInterfaceBMode::SetScanningPower. Implement this method to handle the actual setting of the value at the device api.
virtual std::vector< double > GetScanningFrequencyValues()
Usgfw2Lib::IUsgDynamicRange * m_DynamicRangeControl
#define RETURN_TelemedValue(control)
DataCollection - Class to facilitate loading/accessing structured data.
#define RETURN_TelemedAvailableValues(control)
virtual void OnSetScanningRejection(double)
Virtual method which is called inside mitk::USControlInterfaceBMode::SetScanningRejection. Implement this method to handle the actual setting of the value at the device api.
#define SET_TelemedValue(control, value)
virtual void OnSetScanningDynamicRange(double)
Virtual method which is called inside mitk::USControlInterfaceBMode::SetScanningDynamicRange. Implement this method to handle the actual setting of the value at the device api.
#define mitkThrow()
Usgfw2Lib::IUsgDataView * m_UsgDataView
virtual void OnSetScanningFrequency(double frequency)
Virtual method which is called inside mitk::USControlInterfaceBMode::SetScanningFrequency.
Interface defining methods for scanning mode b of ultrasound devices. It consists of methods for scan...
virtual std::vector< double > GetScanningDepthValues()
#define SAFE_RELEASE(x)
Usgfw2Lib::IUsgRejection2 * m_RejectionControl
Usgfw2Lib::IUsgProbeFrequency2 * m_FrequencyControl
void SetUsgDataView(Usgfw2Lib::IUsgDataView *)
Setter for the IUsgDataView necesary for communicating with the Telemed API. This method is just for ...
virtual void OnSetScanningDepth(double)
Virtual method which is called inside mitk::USControlInterfaceBMode::SetScanningDepth. Implement this method to handle the actual setting of the value at the device api.
#define RETURN_TelemedAvailableValuesWithFactor(control, factor)
#define GETINOUTPUT_TelemedAvailableValuesBounds(control, output)
#define TELEMED_FREQUENCY_FACTOR