diff --git a/Modules/US/Testing/mitkUSDeviceTest.cpp b/Modules/US/Testing/mitkUSDeviceTest.cpp index 65408f5b8b..bf3f64ba41 100644 --- a/Modules/US/Testing/mitkUSDeviceTest.cpp +++ b/Modules/US/Testing/mitkUSDeviceTest.cpp @@ -1,108 +1,112 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-02-25 17:27:17 +0100 (Mo, 25 Feb 2008) $ Version: $Revision: 7837 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkUSDevice.h" #include "mitkUSProbe.h" #include "mitkTestingMacros.h" +#include class mitkUSDeviceTestClass { public: // Anm: Implementierung der einzelnen Testmethoden static void TestInstantiation() { // let's create an object of our class - mitk::USDevice::Pointer device = mitk::USDevice::New(); + mitk::USDevice::Pointer device = mitk::USDevice::New("Manufacturer", "Model", true); MITK_TEST_CONDITION_REQUIRED(device.IsNotNull(), "USDevice should not be null after instantiation"); + MITK_TEST_CONDITION_REQUIRED((device->GetDeviceManufacturer().compare("Manufacturer") == 0), "Manufacturer should be set correctly"); + MITK_TEST_CONDITION_REQUIRED((device->GetDeviceModel().compare("Model") == 0), "Model should be set correctly"); + MITK_TEST_CONDITION_REQUIRED((device->GetIsVideoOnly() == true), "Device should be VideoOnly"); } static void TestAddProbe() { - mitk::USDevice::Pointer device = mitk::USDevice::New(); + mitk::USDevice::Pointer device = mitk::USDevice::New("Manufacturer", "Model", true); // create probes mitk::USProbe::Pointer usSource = mitk::USProbe::New(); mitk::USProbe::Pointer probeA = mitk::USProbe::New(); mitk::USProbe::Pointer probeB = mitk::USProbe::New(); mitk::USProbe::Pointer identicalProbe = mitk::USProbe::New(); // only this one should be identical // give my babys some names probeA->SetName("ProbeA"); probeB->SetName("ProbeB"); identicalProbe->SetName("ProbeA"); // I'm gonna be a bad father... //right now, list of devices should be empty MITK_TEST_CONDITION_REQUIRED(device->GetConnectedProbes().size() == 0, "Newly created device should have no probes connected"); // Connect Probe A device->AddProbe(probeA); MITK_TEST_CONDITION_REQUIRED(device->GetConnectedProbes().size() == 1, "Device should add one new probe"); // Connect Probe B device->AddProbe(probeB); MITK_TEST_CONDITION_REQUIRED(device->GetConnectedProbes().size() == 2, "Device should add another probe"); // Connect identical Probe device->AddProbe(identicalProbe); MITK_TEST_CONDITION_REQUIRED(device->GetConnectedProbes().size() == 2, "Device should not have added identical probe"); } static void TestActivateProbe() { - mitk::USDevice::Pointer device = mitk::USDevice::New(); + mitk::USDevice::Pointer device = mitk::USDevice::New("Manufacturer", "Model", true); // create probes mitk::USProbe::Pointer usSource = mitk::USProbe::New(); mitk::USProbe::Pointer probeA = mitk::USProbe::New(); mitk::USProbe::Pointer probeB = mitk::USProbe::New(); mitk::USProbe::Pointer identicalProbe = mitk::USProbe::New(); // only this one should be identical // names probeA->SetName("ProbeA"); probeB->SetName("ProbeB"); identicalProbe->SetName("ProbeA"); device->AddProbe(probeA); device->AddProbe(probeB); // We after activation, we expect the device to activate probeA, which is the first-connected identical version. device->ActivateProbe(identicalProbe); MITK_TEST_CONDITION_REQUIRED(device->GetActiveProbe() == probeA, "probe A should be active"); // And we deactivate it again... device->DeactivateProbe(); MITK_TEST_CONDITION_REQUIRED(device->GetActiveProbe().IsNull(), "After deactivation, no probe should be active"); } }; /** * This function is testing methods of the class USDevice. */ int mitkUSDeviceTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("mitkUSDeviceTest"); mitkUSDeviceTestClass::TestInstantiation(); mitkUSDeviceTestClass::TestAddProbe(); mitkUSDeviceTestClass::TestActivateProbe(); MITK_TEST_END(); } \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSDevice.H b/Modules/US/USFilters/mitkUSDevice.H index df17fd7601..81d94e968f 100644 --- a/Modules/US/USFilters/mitkUSDevice.H +++ b/Modules/US/USFilters/mitkUSDevice.H @@ -1,81 +1,94 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKUSDevice_H_HEADER_INCLUDED_ #define MITKUSDevice_H_HEADER_INCLUDED_ #include #include "mitkUSProbe.h" +#include "mitkUSImageMetadata.h" #include #include #include #include + namespace mitk { /**Documentation - * \brief A device holds information about it's model, make and the connected probes. + * \brief A device holds information about it's model, make and the connected probes. It is the + * common superclass for all Devices and acts as an image source for mitk Images as well as openCV Images. + * if one of these functionalities is not supported by a subclass, it will throw an unsupported Operation Exception. * \ingroup US */ class MitkUS_EXPORT USDevice : public itk::Object { public: - mitkClassMacro(USDevice,mitk::ImageSource); - itkNewMacro(Self); + mitkClassMacro(USDevice, mitk::ImageSource); + mitkNewMacro3Param(Self, std::string, std::string, bool); /** * \brief Add a probe to the device without connecting to it. * This should usually be done before connecting to the probe */ virtual void AddProbe(mitk::USProbe::Pointer probe); /** * \brief Connect to a probe and activate it. The probe should be added first. * Usually, a VideoDevice will just add a probe it want's to connect to, * but an SDK Device might require adding a probe first. */ virtual void ActivateProbe(mitk::USProbe::Pointer probe); /** * \brief Deactivates the currently active probe. */ virtual void DeactivateProbe(); /** * \brief Removes a probe from the ist of currently added probes. */ //virtual void removeProbe(mitk::USProbe::Pointer probe); std::vector GetConnectedProbes(); + //########### GETTER & SETTER ##################// + itkGetMacro(ActiveProbe, mitk::USProbe::Pointer); + std::string GetDeviceManufacturer(); + std::string GetDeviceModel(); + std::string GetDeviceComment(); + bool GetIsVideoOnly(); protected: - USDevice(); - virtual ~USDevice(); - mitk::USProbe::Pointer m_ActiveProbe; - std::vector m_ConnectedProbes; - + std::vector m_ConnectedProbes; + mitk::USImageMetadata::Pointer m_Metadata; + + /** + * \brief Enforces minimal Metadata to be set. The isVideoOnly flag indicates that this class + * only handles a videostream and does not recieve Metadata from the physical device itself. + */ + USDevice(std::string manufacturer, std::string model, bool isVideoOnly); + virtual ~USDevice(); - }; } // namespace mitk #endif \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSDevice.cpp b/Modules/US/USFilters/mitkUSDevice.cpp index cb7ca893c1..821f6293f7 100644 --- a/Modules/US/USFilters/mitkUSDevice.cpp +++ b/Modules/US/USFilters/mitkUSDevice.cpp @@ -1,59 +1,81 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkUSDevice.h" +#include "mitkUSImageMetadata.h" -mitk::USDevice::USDevice() : itk::Object() +mitk::USDevice::USDevice(std::string manufacturer, std::string model, bool isVideoOnly) : itk::Object() { - + m_Metadata = mitk::USImageMetadata::New(); + m_Metadata->SetDeviceManufacturer(manufacturer); + m_Metadata->SetDeviceModel(model); + m_Metadata->SetIsVideoOnly(isVideoOnly); } mitk::USDevice::~USDevice() { } void mitk::USDevice::AddProbe(mitk::USProbe::Pointer probe) { for(int i = 0; i < m_ConnectedProbes.size(); i++) { if (m_ConnectedProbes[i]->IsEqualToProbe(probe)) return; } this->m_ConnectedProbes.push_back(probe); } void mitk::USDevice::ActivateProbe(mitk::USProbe::Pointer probe){ - // currently, we can just add the probe. This behaviour must be changed, should more complicated SDK applications emerge + // currently, we may just add the probe. This behaviour must be changed, should more complicated SDK applications emerge AddProbe(probe); int index = -1; for(int i = 0; i < m_ConnectedProbes.size(); i++) { if (m_ConnectedProbes[i]->IsEqualToProbe(probe)) index = i; } // index now contains the position of the original instance of this probe m_ActiveProbe = m_ConnectedProbes[index]; } void mitk::USDevice::DeactivateProbe(){ m_ActiveProbe = 0; } + //########### GETTER & SETTER ##################// + +std::string mitk::USDevice::GetDeviceManufacturer(){ + return this->m_Metadata->GetDeviceManufacturer(); +} + +std::string mitk::USDevice::GetDeviceModel(){ + return this->m_Metadata->GetDeviceModel(); +} + +std::string mitk::USDevice::GetDeviceComment(){ + return this->m_Metadata->GetDeviceComment(); +} + +bool mitk::USDevice::GetIsVideoOnly(){ + return this->m_Metadata->GetIsVideoOnly(); +} + std::vector mitk::USDevice::GetConnectedProbes() { return m_ConnectedProbes; -} \ No newline at end of file +} diff --git a/Modules/US/USFilters/mitkUSImageMetadata.h b/Modules/US/USFilters/mitkUSImageMetadata.h index 4b5e2174c1..87f3920aba 100644 --- a/Modules/US/USFilters/mitkUSImageMetadata.h +++ b/Modules/US/USFilters/mitkUSImageMetadata.h @@ -1,58 +1,71 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKUSIMAGEMETADATA_H_HEADER_INCLUDED_ #define MITKUSIMAGEMETADATA_H_HEADER_INCLUDED_ #include #include #include -#include "mitkUSDevice.h" -#include "mitkUSProbe.h" #include namespace mitk { /**Documentation * \brief TODO * \ingroup US */ class MitkUS_EXPORT USImageMetadata : public itk::Object { public: mitkClassMacro(USImageMetadata, itk::Object); itkNewMacro(Self); //## getter and setter ## - itkGetMacro(Device, mitk::USDevice::Pointer); - itkSetMacro(Device, mitk::USDevice::Pointer); - itkGetMacro(Probe, mitk::USProbe::Pointer); - itkSetMacro(Probe, mitk::USProbe::Pointer); + itkGetMacro(DeviceManufacturer, std::string); + itkSetMacro(DeviceManufacturer, std::string); + itkGetMacro(DeviceModel, std::string); + itkSetMacro(DeviceModel, std::string); + itkGetMacro(DeviceComment, std::string); + itkSetMacro(DeviceComment, std::string); + itkGetMacro(ProbeName, std::string); + itkSetMacro(ProbeName, std::string); + itkGetMacro(ProbeFrequency, std::string); + itkSetMacro(ProbeFrequency, std::string); + itkGetMacro(Zoom, std::string); + itkSetMacro(Zoom, std::string); + itkGetMacro(IsVideoOnly, bool); + itkSetMacro(IsVideoOnly, bool); protected: USImageMetadata(); virtual ~USImageMetadata(); - USDevice::Pointer m_Device; - USProbe::Pointer m_Probe; + std::string m_DeviceManufacturer; + std::string m_DeviceModel; + std::string m_DeviceComment; + std::string m_ProbeName; + std::string m_ProbeFrequency; + std::string m_Zoom; + bool m_IsVideoOnly; }; } // namespace mitk #endif \ No newline at end of file