Medical Imaging Interaction Toolkit  2016.11.0
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,
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 
18 #include "mitkUSTelemedDevice.h"
19 #include <mitkException.h>
20 
21 #define TELEMED_FREQUENCY_FACTOR 1000000
22 
24 : mitk::USControlInterfaceBMode(device.GetPointer()),
25  m_UsgDataView(0), m_PowerControl(0), m_FrequencyControl(0),
26  m_DepthControl(0), m_GainControl(0), m_RejectionControl(0),
27  m_DynamicRangeControl(0),
28  m_Active(false), m_PowerSteps(new double[3]),
29  m_GainSteps(new double[3]), m_RejectionSteps(new double[3]),
30  m_DynamicRangeSteps(new double[3])
31 {
32 }
33 
35 {
36  this->ReleaseControls();
37 
38  delete[] m_PowerSteps;
39  delete[] m_GainSteps;
40  delete[] m_RejectionSteps;
41  delete[] m_DynamicRangeSteps;
42 }
43 
44 void mitk::USTelemedBModeControls::SetUsgDataView( Usgfw2Lib::IUsgDataView* usgDataView)
45 {
46  m_UsgDataView = usgDataView;
47 }
48 
50 {
51  this->ReleaseControls();
52  this->CreateControls();
53 }
54 
56 {
57  if (active)
58  {
59  HRESULT hr = m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_STOP);
60  if (FAILED(hr)) { mitkThrow() << "Could not stop scanning (" << hr << ")."; }
61 
62  // make sure that current scan mode is b mode now
63  hr = m_UsgDataView->put_ScanMode(Usgfw2Lib::SCAN_MODE_B);
64  if (FAILED(hr)) { mitkThrow() << "Could not set scan mode b (" << hr << ")."; }
65 
66  hr = m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_RUN);
67  if (FAILED(hr)) { mitkThrow() << "Could not start scanning (" << hr << ")."; }
68 
69  this->CreateControls();
70 
71  m_Active = true;
72  }
73  else
74  {
75  this->ReleaseControls();
76 
77  m_Active = false;
78  }
79 }
80 
82 {
83  // get scan mode, because scan mode must be B mode
84  // for this interface being active
85  ULONG scanMode;
86  HRESULT hr = m_UsgDataView->get_ScanMode(&scanMode);
87  if (FAILED(hr)) { mitkThrow() << "Could not get scan mode (" << hr << ")."; }
88 
89  return m_Active && scanMode == Usgfw2Lib::SCAN_MODE_B;
90 }
91 
93 {
94  RETURN_TelemedValue(m_FrequencyControl);
95 }
96 
98 {
99  return this->GetScanningFrequencyAPI() / TELEMED_FREQUENCY_FACTOR;
100 }
101 
103 {
104  SET_TelemedValue(m_FrequencyControl, value * TELEMED_FREQUENCY_FACTOR);
105 }
106 
108 {
110 }
111 
113 {
114  RETURN_TelemedValue(m_PowerControl);
115 }
116 
118 {
119  SET_TelemedValue(m_PowerControl, value);
120 }
121 
123 {
124  return m_PowerSteps[0];
125 }
126 
128 {
129  return m_PowerSteps[1];
130 }
131 
133 {
134  return m_PowerSteps[2];
135 }
136 
138 {
139  RETURN_TelemedValue(m_DepthControl);
140 }
141 
143 {
144  SET_TelemedValue(m_DepthControl,value);
145 }
146 
148 {
149  RETURN_TelemedAvailableValues(m_DepthControl);
150 }
151 
153 {
154  RETURN_TelemedValue(m_GainControl);
155 }
156 
158 {
159  SET_TelemedValue(m_GainControl, value);
160 }
161 
163 {
164  return m_GainSteps[0];
165 }
166 
168 {
169  return m_GainSteps[1];
170 }
171 
173 {
174  return m_GainSteps[2];
175 }
176 
178 {
179  RETURN_TelemedValue(m_RejectionControl);
180 }
181 
183 {
184  SET_TelemedValue(m_RejectionControl, value);
185 }
186 
188 {
189  return m_RejectionSteps[0];
190 }
191 
193 {
194  return m_RejectionSteps[1];
195 }
196 
198 {
199  return m_RejectionSteps[2];
200 }
201 
203 {
204  RETURN_TelemedValue(m_DynamicRangeControl);
205 }
206 
208 {
209  SET_TelemedValue(m_DynamicRangeControl, value);
210 }
211 
213 {
214  return m_DynamicRangeSteps[0];
215 }
216 
218 {
219  return m_DynamicRangeSteps[1];
220 }
221 
223 {
224  return m_DynamicRangeSteps[2];
225 }
226 
228 {
229  // create frequency control
230  CREATE_TelemedControl(m_FrequencyControl, m_UsgDataView, Usgfw2Lib::IID_IUsgProbeFrequency2, Usgfw2Lib::IUsgProbeFrequency2, Usgfw2Lib::SCAN_MODE_B);
231 
232  // create power control
233  CREATE_TelemedControl(m_PowerControl, m_UsgDataView, Usgfw2Lib::IID_IUsgPower, Usgfw2Lib::IUsgPower, Usgfw2Lib::SCAN_MODE_B);
234  GETINOUTPUT_TelemedAvailableValuesBounds(m_PowerControl, m_PowerSteps); // get min, max and tick for gain
235 
236  // create B mode depth control
237  CREATE_TelemedControl(m_DepthControl, m_UsgDataView, Usgfw2Lib::IID_IUsgDepth, Usgfw2Lib::IUsgDepth, Usgfw2Lib::SCAN_MODE_B);
238 
239  // create B mode gain control
240  CREATE_TelemedControl(m_GainControl, m_UsgDataView, Usgfw2Lib::IID_IUsgGain, Usgfw2Lib::IUsgGain, Usgfw2Lib::SCAN_MODE_B);
241  GETINOUTPUT_TelemedAvailableValuesBounds(m_GainControl, m_GainSteps); // get min, max and tick for gain
242 
243  // create B mode rejection control
244  CREATE_TelemedControl(m_RejectionControl, m_UsgDataView, Usgfw2Lib::IID_IUsgRejection2, Usgfw2Lib::IUsgRejection2, Usgfw2Lib::SCAN_MODE_B);
245  GETINOUTPUT_TelemedAvailableValuesBounds(m_RejectionControl, m_RejectionSteps); // get min, max and tick for rejection
246 
247  // create B mode dynamic range control
248  CREATE_TelemedControl(m_DynamicRangeControl, m_UsgDataView, Usgfw2Lib::IID_IUsgDynamicRange, Usgfw2Lib::IUsgDynamicRange, Usgfw2Lib::SCAN_MODE_B);
249  GETINOUTPUT_TelemedAvailableValuesBounds(m_DynamicRangeControl, m_DynamicRangeSteps); // get min, max and tick for dynamic range
250 }
251 
253 {
254  // remove all controls and delete their objects
255  SAFE_RELEASE(m_PowerControl);
256  SAFE_RELEASE(m_FrequencyControl);
257  SAFE_RELEASE(m_DepthControl);
258  SAFE_RELEASE(m_GainControl);
259  SAFE_RELEASE(m_RejectionControl);
260  SAFE_RELEASE(m_DynamicRangeControl);
261 }
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()
#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()
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)
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