Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkUSDiPhASProbesControls.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 <string>
15 #include "mitkUSDiPhASDevice.h"
16 #include <mitkException.h>
17 
19  : mitk::USControlInterfaceProbes(device.GetPointer()),
20  m_IsActive(false), m_DiPhASDevice(device)
21 {
22 }
23 
25 {
26 }
27 
28 
30 {
31  this->CreateProbesSet();
32  m_IsActive = isActive;
33 }
34 
36 {
37  return m_IsActive;
38 }
39 
40 std::vector<mitk::USProbe::Pointer> mitk::USDiPhASProbesControls::GetProbeSet()
41 {
42  // create a new vector of base class (USProbe) objects, because
43  // interface wants a vector of this type
44  std::vector<mitk::USProbe::Pointer> usProbes(m_ProbesSet.size(), 0);
45  for (unsigned int n = 0; n < m_ProbesSet.size(); ++n)
46  {
47  usProbes.at(n) = m_ProbesSet.at(n).GetPointer();
48  }
49  return usProbes;
50 }
51 
53 {
54  if (index >= m_ProbesSet.size())
55  {
56  MITK_ERROR("USDiPhASProbesControls")("USControlInterfaceProbes")
57  << "Cannot select probe with index " << index << ". Maximum possible index is " << m_ProbesSet.size() - 1 << ".";
58  mitkThrow() << "Cannot select probe with index " << index <<
59  ". Maximum possible index is " << m_ProbesSet.size() - 1 << ".";
60  }
61 
62  m_SelectedProbeIndex = index;
63 }
64 
65 void mitk::USDiPhASProbesControls::OnSelectProbe(mitk::USProbe::Pointer probe)
66 {
67 }
68 
70 {
71  if (m_SelectedProbeIndex >= m_ProbesSet.size())
72  {
73  MITK_ERROR("USDiPhASProbesControls")("USControlInterfaceProbes")
74  << "Cannot get active probe as the current index is" << m_SelectedProbeIndex <<
75  ". Maximum possible index is " << m_ProbesSet.size() - 1 << ".";
76  mitkThrow() << "Cannot get active probe as the current index is" << m_SelectedProbeIndex <<
77  ". Maximum possible index is " << m_ProbesSet.size() - 1 << ".";
78  }
79 
80  return m_ProbesSet.at(m_SelectedProbeIndex).GetPointer();
81 }
82 
84 {
85  return m_ProbesSet.size();
86 }
87 
88 
90 {
91  MITK_INFO << "Probe removed...";
92 
93  if (m_ProbesSet.size() > index)
94  {
95  m_ProbesSet.erase(m_ProbesSet.begin() + index);
96  }
97 }
98 
100 {
101  MITK_INFO << "Probe arrived...";
102 
103  this->CreateProbesSet();
104 }
105 
107 {
108  m_ProbesSet.push_back(mitk::USDiPhASProbe::New( m_DiPhASDevice->GetScanMode().transducerName ));
109 }
virtual USProbe::Pointer GetSelectedProbe()
virtual unsigned int GetProbesCount() const
Interface defining methods for probe selection of ultrasound devices. It consists of methods for gett...
#define MITK_INFO
Definition: mitkLogMacros.h:18
#define MITK_ERROR
Definition: mitkLogMacros.h:20
USDiPhASProbesControls(itk::SmartPointer< USDiPhASDevice > device)
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< USDiPhASProbe::Pointer > m_ProbesSet
#define mitkThrow()
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.
itk::SmartPointer< USDiPhASDevice > m_DiPhASDevice
static Pointer New()
virtual std::vector< USProbe::Pointer > GetProbeSet()