23 m_IsActive(false), m_TelemedDevice(device),
24 m_ProbesCollection(0), m_Probe(0)
35 if ( ! m_TelemedDevice )
37 MITK_WARN(
"USTelemedProbesControls")(
"USControlInterfaceProbes")
38 <<
"Cannot activate probe controls while device is not set.";
42 if ( isActive && m_ProbesCollection == 0 )
44 this->CreateProbesCollection();
45 this->CreateProbesSet();
51 m_IsActive = isActive;
63 std::vector<mitk::USProbe::Pointer> usProbes(m_ProbesSet.size(), 0);
64 for (
unsigned int n = 0; n < m_ProbesSet.size(); ++n)
66 usProbes.at(n) = m_ProbesSet.at(n).GetPointer();
73 if (index >= m_ProbesSet.size())
75 MITK_ERROR(
"USTelemedProbesControls")(
"USControlInterfaceProbes")
76 <<
"Cannot select probe with index " << index <<
". Maximum possible index is " << m_ProbesSet.size()-1 <<
".";
77 mitkThrow() <<
"Cannot select probe with index " << index <<
78 ". Maximum possible index is " << m_ProbesSet.size()-1 <<
".";
81 m_TelemedDevice->SetActiveDataView(m_ProbesSet.at(index)->GetUsgDataView());
83 m_SelectedProbeIndex = index;
92 if (m_SelectedProbeIndex >= m_ProbesSet.size())
94 MITK_ERROR(
"USTelemedProbesControls")(
"USControlInterfaceProbes")
95 <<
"Cannot get active probe as the current index is" << m_SelectedProbeIndex <<
96 ". Maximum possible index is " << m_ProbesSet.size()-1 <<
".";
97 mitkThrow() <<
"Cannot get active probe as the current index is" << m_SelectedProbeIndex <<
98 ". Maximum possible index is " << m_ProbesSet.size()-1 <<
".";
101 return m_ProbesSet.at(m_SelectedProbeIndex).GetPointer();
106 return m_ProbesSet.size();
118 if ( m_ProbesSet.size() > index )
120 m_ProbesSet.erase(m_ProbesSet.begin() + index);
128 this->CreateProbesCollection();
129 this->CreateProbesSet();
132 if (m_ProbesSet.size() == 1)
134 m_TelemedDevice->SetActiveDataView(m_ProbesSet.at(0)->GetUsgDataView());
140 IUnknown* tmp_obj = NULL;
144 Usgfw2Lib::IUsgfw2* usgMainInterface = m_TelemedDevice->GetUsgMainInterface();
145 if ( ! usgMainInterface )
147 MITK_ERROR(
"USTelemedProbesControls")(
"USControlInterfaceProbes")
148 <<
"Main interface of Telemed device must not be null.";
149 mitkThrow() <<
"Main interface of Telemed device must not be null.";
153 hr = usgMainInterface->get_ProbesCollection(&tmp_obj);
154 if (FAILED(hr) || ! tmp_obj)
156 MITK_WARN(
"USTelemedProbesControls")(
"USControlInterfaceProbes")
157 <<
"Error on getting probes collection (" << hr <<
").";
163 hr = tmp_obj->QueryInterface(Usgfw2Lib::IID_IUsgCollection,(
void**)&m_ProbesCollection);
165 if (FAILED(hr) || ! m_ProbesCollection)
167 MITK_WARN(
"USTelemedProbesControls")(
"USControlInterfaceProbes")
168 <<
"Error on querying interface for probes collection (" << hr <<
").";
177 if ( ! m_ProbesCollection)
179 MITK_ERROR(
"USTelemedProbesControls")(
"USControlInterfaceProbes")
180 <<
"Cannot get probe set without ProbesCollection being initialized before.";
181 mitkThrow() <<
"Cannot get probe set without ProbesCollection being initialized before.";
185 LONG probes_count = 0;
186 HRESULT hr = m_ProbesCollection->get_Count(&probes_count);
187 if (FAILED(hr)) {
mitkThrow() <<
"Could not get probes count (" << hr <<
")."; }
189 if ( ! m_TelemedDevice )
191 MITK_ERROR(
"USTelemedProbesControls")(
"USControlInterfaceProbes")
192 <<
"Telemed device must not be null when creating probes set.";
193 mitkThrow() <<
"Telemed device must not be null when creating probes set.";
197 Usgfw2Lib::IUsgfw2* usgMainInterface = m_TelemedDevice->GetUsgMainInterface();
198 if ( ! usgMainInterface )
200 MITK_ERROR(
"USTelemedProbesControls")(
"USControlInterfaceProbes")
201 <<
"Usg main interface must not be null when creating probes set.";
202 mitkThrow() <<
"Usg main interface must not be null when creating probes set.";
206 m_ProbesSet = std::vector<mitk::USTelemedProbe::Pointer>(probes_count, 0);
208 for (
unsigned int n = 0; n < probes_count; ++n)
211 IUnknown* tmp_obj = NULL;
212 hr = m_ProbesCollection->Item(n,&tmp_obj);
215 MITK_ERROR(
"USTelemedProbesControls")(
"USControlInterfaceProbes")
216 <<
"Could not get probe with index " << n <<
".";
217 mitkThrow() <<
"Could not get probe with index " << n <<
".";
221 Usgfw2Lib::IProbe* probe;
222 hr = tmp_obj->QueryInterface(Usgfw2Lib::IID_IProbe,(
void**)&probe);
225 MITK_ERROR(
"USTelemedProbesControls")(
"USControlInterfaceProbes")
226 <<
"Error on querying interface for probe with index "<< n <<
".";
227 mitkThrow() <<
"Error on querying interface for probe with index "<< n <<
".";
231 Usgfw2Lib::IUsgDataView* usgDataView;
232 Usgfw2Lib::IUsgDataViewPtr usgDataViewTmp;
233 usgDataViewTmp = usgMainInterface->CreateDataView(probe);
234 usgDataViewTmp->QueryInterface(Usgfw2Lib::IID_IUsgDataView, (
void**)&usgDataView);
237 MITK_ERROR(
"USTelemedProbesControls")(
"USControlInterfaceProbes")
238 <<
"Could not create data view for selected probe.";
239 mitkThrow() <<
"Could not create data view for selected probe.";
virtual void OnSelectProbe(unsigned int index)
Virtual method which is called inside mitk::USControlInterfaceProbes::SelectProbe(). Implement this method to handle the actual selecting of the probe at the device api.
virtual bool GetIsActive()
void ProbeRemoved(unsigned int index)
itk::SmartPointer< Self > Pointer
virtual ~USTelemedProbesControls()
Interface defining methods for probe selection of ultrasound devices. It consists of methods for gett...
virtual std::vector< USProbe::Pointer > GetProbeSet()
DataCollection - Class to facilitate loading/accessing structured data.
USTelemedProbesControls(itk::SmartPointer< USTelemedDevice > device)
virtual USProbe::Pointer GetSelectedProbe()
bool CreateProbesCollection()
virtual void SetIsActive(bool)
void ProbeAdded(unsigned int index)
virtual unsigned int GetProbesCount() const