Medical Imaging Interaction Toolkit  2018.4.99-87d68d9f
Medical Imaging Interaction Toolkit
mitkUSVideoDeviceCustomControls.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 
16  : mitk::USAbstractControlInterface(device.GetPointer()), m_IsActive(false)
17 {
18  m_ImageSource = dynamic_cast<mitk::USImageVideoSource*>(m_Device->GetUSImageSource().GetPointer());
19 }
20 
22 {
23 }
24 
26 {
27  m_IsActive = isActive;
28 }
29 
31 {
32  return m_IsActive;
33 }
34 
36 {
37  MITK_INFO << "Set Crop Area L:" << newArea.left << " R:" << newArea.right
38  << " T:" << newArea.top << " B:" << newArea.bottom;
39 
40  if (m_ImageSource.IsNotNull())
41  {
42  // if area is empty, remove region
43  if ((newArea.bottom == 0) && (newArea.top == 0) &&
44  (newArea.left == 0) && (newArea.right == 0))
45  {
46  m_ImageSource->RemoveRegionOfInterest();
47  }
48  else
49  {
50  m_ImageSource->SetCropping(newArea);
51  }
52  }
53  else
54  {
55  MITK_WARN << "Cannot set crop are, source is not initialized!";
56  }
57 }
58 
60 {
61  if (m_Device.IsNotNull())
62  {
63  if( m_Device->GetCurrentProbe().IsNotNull() )
64  {
65  m_Device->GetCurrentProbe()->SetCurrentDepth(depth);
66  MITK_INFO << "SetCurrentDepth of currentProbe: " << depth;
67  }
68  }
69  m_Device->DepthChanged(depth);
70 }
71 
73 {
74  if( m_Device.IsNotNull() )
75  {
76  m_Device->SetCurrentProbe(probename);
77  }
78  m_Device->ProbeChanged(probename);
79 }
80 
82 {
83  // just return the crop area set at the image source
84  mitk::USVideoDevice::Pointer device = dynamic_cast<mitk::USVideoDevice*>(m_Device.GetPointer());
85  if (device.IsNotNull())
86  {
87  mitk::USProbe::Pointer probe = device->GetCurrentProbe();
88  if (probe.IsNotNull())
89  {
90  return probe->GetProbeCropping();
91  }
92  }
93  mitk::USProbe::USProbeCropping defaultCropping;
94  return defaultCropping;
95 }
96 
98 {
99  mitk::USVideoDevice::Pointer device = dynamic_cast<mitk::USVideoDevice*>(m_Device.GetPointer());
100  if (device.IsNotNull())
101  {
102  mitk::USProbe::Pointer probe = device->GetCurrentProbe();
103  if( probe.IsNotNull() )
104  {
105  probe->SetProbeCropping(cropping.top, cropping.bottom, cropping.left, cropping.right);
106  }
107  }
108 }
109 
110 std::vector<mitk::USProbe::Pointer> mitk::USVideoDeviceCustomControls::GetProbes()
111 {
112  return m_Device->GetAllProbes();
113 }
114 
116 {
117  mitk::USProbe::Pointer probe = m_Device->GetProbeByName(name);
118  std::map<int, mitk::Vector3D> depthsAndSpacings = probe->GetDepthsAndSpacing();
119  std::vector<int> depths;
120  for (std::map<int, mitk::Vector3D>::iterator it = depthsAndSpacings.begin(); it != depthsAndSpacings.end(); it++)
121  {
122  depths.push_back((it->first));
123  }
124  return depths;
125 }
126 
128 {
129  m_Device->SetDefaultProbeAsCurrentProbe();
130 }
Superclass for all ultrasound device control interfaces. Defines an interface for activating and deac...
void SetCropArea(USImageVideoSource::USImageCropping newArea)
Sets the area that will be cropped from the US image. Set [0,0,0,0] to disable it, which is also default.
#define MITK_INFO
Definition: mitkLogMacros.h:18
Defines a region of interest by distances to the four image borders.
void SetNewDepth(double depth)
Sets a new depth value to the current probe.
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< mitk::USProbe::Pointer > GetProbes()
Get all the probes for the current device.
std::vector< int > GetDepthsForProbe(std::string name)
Get the scanning dephts of the given probe.
This class can be pointed to a video file or a videodevice and delivers USImages. ...
void SetDefaultProbeAsCurrentProbe()
Sets the first existing probe or the default probe of a USVideoDevice as the current probe of the USV...
#define MITK_WARN
Definition: mitkLogMacros.h:19
mitk::USProbe::USProbeCropping GetCropArea()
USVideoDeviceCustomControls(itk::SmartPointer< USDevice > device)
void UpdateProbeCropping(mitk::USImageVideoSource::USImageCropping cropping)
Updates the cropping of the current probe given by the crop area of the USImageVideoSource.
A mitk::USVideoDevice is the common class for video only devices. They capture video input either fro...
Struct to define a probe specific ultrasound image cropping.
Definition: mitkUSProbe.h:41