diff --git a/Modules/US/USModel/mitkUSDeviceReaderWriterConstants.cpp b/Modules/US/USModel/mitkUSDeviceReaderWriterConstants.cpp new file mode 100644 index 0000000000..7eee5038e0 --- /dev/null +++ b/Modules/US/USModel/mitkUSDeviceReaderWriterConstants.cpp @@ -0,0 +1,50 @@ +/*============================================================================ + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center (DKFZ) +All rights reserved. + +Use of this source code is governed by a 3-clause BSD license that can be +found in the LICENSE file. + +============================================================================*/ + +#include "mitkUSDeviceReaderWriterConstants.h" + +namespace mitk +{ + const char* USDeviceReaderWriterConstants::TAG_ULTRASOUNDDEVICE = "ULTRASOUNDDEVICE"; + const char* USDeviceReaderWriterConstants::TAG_GENERALSETTINGS = "GENERALSETTINGS"; + const char* USDeviceReaderWriterConstants::TAG_PROBES = "PROBES"; + const char* USDeviceReaderWriterConstants::TAG_PROBE = "PROBE"; + const char* USDeviceReaderWriterConstants::TAG_DEPTHS = "DEPTHS"; + const char* USDeviceReaderWriterConstants::TAG_DEPTH = "DEPTH"; + const char* USDeviceReaderWriterConstants::TAG_SPACING = "SPACING"; + const char* USDeviceReaderWriterConstants::TAG_CROPPING = "CROPPING"; + + const char* USDeviceReaderWriterConstants::ATTR_FILEVERS = "filevers"; + const char* USDeviceReaderWriterConstants::ATTR_TYPE = "type"; + const char* USDeviceReaderWriterConstants::ATTR_HOST = "host"; + const char* USDeviceReaderWriterConstants::ATTR_PORT = "port"; + const char* USDeviceReaderWriterConstants::ATTR_SERVER = "server"; + const char* USDeviceReaderWriterConstants::ATTR_NAME = "name"; + const char* USDeviceReaderWriterConstants::ATTR_MANUFACTURER = "manufacturer"; + const char* USDeviceReaderWriterConstants::ATTR_MODEL = "model"; + const char* USDeviceReaderWriterConstants::ATTR_COMMENT = "comment"; + const char* USDeviceReaderWriterConstants::ATTR_IMAGESTREAMS = "imagestreams"; + const char* USDeviceReaderWriterConstants::ATTR_GREYSCALE = "greyscale"; + const char* USDeviceReaderWriterConstants::ATTR_RESOLUTIONOVERRIDE = "resolutionOverride"; + const char* USDeviceReaderWriterConstants::ATTR_RESOLUTIONWIDTH = "resolutionWidth"; + const char* USDeviceReaderWriterConstants::ATTR_RESOLUTIONHEIGHT = "resolutionHeight"; + const char* USDeviceReaderWriterConstants::ATTR_SOURCEID = "sourceID"; + const char* USDeviceReaderWriterConstants::ATTR_FILEPATH = "filepath"; + const char* USDeviceReaderWriterConstants::ATTR_OPENCVPORT = "opencvPort"; + const char* USDeviceReaderWriterConstants::ATTR_DEPTH = "depth"; + const char* USDeviceReaderWriterConstants::ATTR_X = "x"; + const char* USDeviceReaderWriterConstants::ATTR_Y = "y"; + const char* USDeviceReaderWriterConstants::ATTR_TOP = "top"; + const char* USDeviceReaderWriterConstants::ATTR_BOTTOM = "bottom"; + const char* USDeviceReaderWriterConstants::ATTR_LEFT = "left"; + const char* USDeviceReaderWriterConstants::ATTR_RIGHT = "right"; +} diff --git a/Modules/US/USModel/mitkUSDeviceReaderWriterConstants.h b/Modules/US/USModel/mitkUSDeviceReaderWriterConstants.h index 3c01c2dd6d..7307f04628 100644 --- a/Modules/US/USModel/mitkUSDeviceReaderWriterConstants.h +++ b/Modules/US/USModel/mitkUSDeviceReaderWriterConstants.h @@ -1,52 +1,57 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef mitkUSDeviceReaderWriterConstants_H_HEADER_INCLUDED_ #define mitkUSDeviceReaderWriterConstants_H_HEADER_INCLUDED_ -const static char* TAG_ULTRASOUNDDEVICE = "ULTRASOUNDDEVICE"; -const static char* TAG_GENERALSETTINGS = "GENERALSETTINGS"; -const static char* TAG_PROBES = "PROBES"; -const static char* TAG_PROBE = "PROBE"; -const static char* TAG_DEPTHS = "DEPTHS"; -const static char* TAG_DEPTH = "DEPTH"; -const static char* TAG_SPACING = "SPACING"; -const static char* TAG_CROPPING = "CROPPING"; - -const static char* ATTR_FILEVERS = "filevers"; -const static char* ATTR_TYPE = "type"; -const static char* ATTR_HOST = "host"; -const static char* ATTR_PORT = "port"; -const static char* ATTR_SERVER = "server"; -const static char* ATTR_NAME = "name"; -const static char* ATTR_MANUFACTURER = "manufacturer"; -const static char* ATTR_MODEL = "model"; -const static char* ATTR_COMMENT = "comment"; -const static char* ATTR_IMAGESTREAMS = "imagestreams"; -const static char* ATTR_GREYSCALE = "greyscale"; -const static char* ATTR_RESOLUTIONOVERRIDE = "resolutionOverride"; -const static char* ATTR_RESOLUTIONWIDTH = "resolutionWidth"; -const static char* ATTR_RESOLUTIONHEIGHT = "resolutionHeight"; -const static char* ATTR_SOURCEID = "sourceID"; -const static char* ATTR_FILEPATH = "filepath"; -const static char* ATTR_OPENCVPORT = "opencvPort"; -const static char* ATTR_DEPTH = "depth"; -const static char* ATTR_X = "x"; -const static char* ATTR_Y = "y"; -const static char* ATTR_TOP = "top"; -const static char* ATTR_BOTTOM = "bottom"; -const static char* ATTR_LEFT = "left"; -const static char* ATTR_RIGHT = "right"; - +namespace mitk +{ + struct USDeviceReaderWriterConstants + { + static const char* TAG_ULTRASOUNDDEVICE; + static const char* TAG_GENERALSETTINGS; + static const char* TAG_PROBES; + static const char* TAG_PROBE; + static const char* TAG_DEPTHS; + static const char* TAG_DEPTH; + static const char* TAG_SPACING; + static const char* TAG_CROPPING; + + static const char* ATTR_FILEVERS; + static const char* ATTR_TYPE; + static const char* ATTR_HOST; + static const char* ATTR_PORT; + static const char* ATTR_SERVER; + static const char* ATTR_NAME; + static const char* ATTR_MANUFACTURER; + static const char* ATTR_MODEL; + static const char* ATTR_COMMENT; + static const char* ATTR_IMAGESTREAMS; + static const char* ATTR_GREYSCALE; + static const char* ATTR_RESOLUTIONOVERRIDE; + static const char* ATTR_RESOLUTIONWIDTH; + static const char* ATTR_RESOLUTIONHEIGHT; + static const char* ATTR_SOURCEID; + static const char* ATTR_FILEPATH; + static const char* ATTR_OPENCVPORT; + static const char* ATTR_DEPTH; + static const char* ATTR_X; + static const char* ATTR_Y; + static const char* ATTR_TOP; + static const char* ATTR_BOTTOM; + static const char* ATTR_LEFT; + static const char* ATTR_RIGHT; + }; +} #endif // mitkUSDeviceReaderWriterConstants_H_HEADER_INCLUDED_ diff --git a/Modules/US/USModel/mitkUSDeviceReaderXML.cpp b/Modules/US/USModel/mitkUSDeviceReaderXML.cpp index a880fb1c4b..9c6b2ade02 100644 --- a/Modules/US/USModel/mitkUSDeviceReaderXML.cpp +++ b/Modules/US/USModel/mitkUSDeviceReaderXML.cpp @@ -1,217 +1,217 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ // MITK #include "mitkUSDeviceReaderWriterConstants.h" #include "mitkUSDeviceReaderXML.h" #include #include #include // Third Party #include #include #include namespace { std::string ReadStringAttribute(const tinyxml2::XMLElement* elem, const char* name) { const char* attrib = elem->Attribute(name); return attrib != nullptr ? attrib : ""; } } mitk::USDeviceReaderXML::USDeviceReaderXML() : AbstractFileReader( mitk::IGTMimeTypes::USDEVICEINFORMATIONXML_MIMETYPE(), "MITK USDevice Reader (XML)"), m_Filename("") { RegisterService(); } mitk::USDeviceReaderXML::~USDeviceReaderXML() { } mitk::USDeviceReaderXML::USDeviceConfigData &mitk::USDeviceReaderXML::GetUSDeviceConfigData() { return m_DeviceConfig; } mitk::USDeviceReaderXML::USDeviceReaderXML(const mitk::USDeviceReaderXML& other) : AbstractFileReader(other) { } mitk::USDeviceReaderXML* mitk::USDeviceReaderXML::Clone() const { return new USDeviceReaderXML(*this); } std::vector> mitk::USDeviceReaderXML::DoRead() { MITK_WARN << "This method is not implemented. \ Please use the method ReadUltrasoundDeviceConfiguration() instead."; std::vector result; return result; } bool mitk::USDeviceReaderXML::ReadUltrasoundDeviceConfiguration() { MITK_INFO << "Try to start reading xml device configuration..."; if (m_Filename == "") { MITK_WARN << "Cannot read file - empty filename!"; return false; } tinyxml2::XMLDocument document; if (tinyxml2::XML_SUCCESS != document.LoadFile(m_Filename.c_str())) { MITK_ERROR << "Error when opening and reading file :" << m_Filename; return false; } tinyxml2::XMLHandle documentHandle(&document); - auto* ultrasoundDeviceTag = documentHandle.FirstChildElement(TAG_ULTRASOUNDDEVICE).ToElement(); + auto* ultrasoundDeviceTag = documentHandle.FirstChildElement(USDeviceReaderWriterConstants::TAG_ULTRASOUNDDEVICE).ToElement(); if (ultrasoundDeviceTag == nullptr) { MITK_ERROR << "Error parsing the file :" << m_Filename << std::endl << "Wrong xml format structure."; return false; } //Extract attribute information of the ULTRASOUNDDEVICE-Tag: this->ExtractAttributeInformationOfUltrasoundDeviceTag(ultrasoundDeviceTag); - auto* generalSettingsTag = documentHandle.FirstChildElement(TAG_ULTRASOUNDDEVICE).FirstChildElement(TAG_GENERALSETTINGS).ToElement(); + auto* generalSettingsTag = documentHandle.FirstChildElement(USDeviceReaderWriterConstants::TAG_ULTRASOUNDDEVICE).FirstChildElement(USDeviceReaderWriterConstants::TAG_GENERALSETTINGS).ToElement(); if (generalSettingsTag == nullptr) { MITK_ERROR << "Error parsing the GENERALSETTINGS-Tag in the file :" << m_Filename; return false; } //Extract attribute information of the GENERALSETTINGS-Tag: this->ExtractAttributeInformationOfGeneralSettingsTag(generalSettingsTag); - auto* probesTag = documentHandle.FirstChildElement(TAG_ULTRASOUNDDEVICE).FirstChildElement(TAG_PROBES).ToElement(); + auto* probesTag = documentHandle.FirstChildElement(USDeviceReaderWriterConstants::TAG_ULTRASOUNDDEVICE).FirstChildElement(USDeviceReaderWriterConstants::TAG_PROBES).ToElement(); if (probesTag == nullptr) { MITK_ERROR << "Error: PROBES-Tag was not found in the file :" << m_Filename << "Therefore, creating default probe."; //Create default ultrasound probe: mitk::USProbe::Pointer ultrasoundProbeDefault = mitk::USProbe::New(); ultrasoundProbeDefault->SetName("default"); ultrasoundProbeDefault->SetDepth(0); m_DeviceConfig.probes.push_back(ultrasoundProbeDefault); return true; } //Extract all saved and configured probes of the USDevice: - for (auto* probeTag = probesTag->FirstChildElement(TAG_PROBE); + for (auto* probeTag = probesTag->FirstChildElement(USDeviceReaderWriterConstants::TAG_PROBE); probeTag != nullptr; probeTag = probeTag->NextSiblingElement()) { this->ExtractProbe(probeTag); } return true; } void mitk::USDeviceReaderXML::SetFilename(std::string filename) { m_Filename = filename; } void mitk::USDeviceReaderXML::ExtractAttributeInformationOfUltrasoundDeviceTag(const tinyxml2::XMLElement *ultrasoundTag) { - ultrasoundTag->QueryDoubleAttribute(ATTR_FILEVERS, &m_DeviceConfig.fileversion); - ultrasoundTag->QueryIntAttribute(ATTR_IMAGESTREAMS, &m_DeviceConfig.numberOfImageStreams); - ultrasoundTag->QueryIntAttribute(ATTR_PORT, &m_DeviceConfig.port); - ultrasoundTag->QueryBoolAttribute(ATTR_SERVER, &m_DeviceConfig.server); - - m_DeviceConfig.deviceType = ReadStringAttribute(ultrasoundTag, ATTR_TYPE); - m_DeviceConfig.deviceName = ReadStringAttribute(ultrasoundTag, ATTR_TYPE); - m_DeviceConfig.manufacturer = ReadStringAttribute(ultrasoundTag, ATTR_TYPE); - m_DeviceConfig.model = ReadStringAttribute(ultrasoundTag, ATTR_TYPE); - m_DeviceConfig.comment = ReadStringAttribute(ultrasoundTag, ATTR_TYPE); - m_DeviceConfig.host = ReadStringAttribute(ultrasoundTag, ATTR_HOST); + ultrasoundTag->QueryDoubleAttribute(USDeviceReaderWriterConstants::ATTR_FILEVERS, &m_DeviceConfig.fileversion); + ultrasoundTag->QueryIntAttribute(USDeviceReaderWriterConstants::ATTR_IMAGESTREAMS, &m_DeviceConfig.numberOfImageStreams); + ultrasoundTag->QueryIntAttribute(USDeviceReaderWriterConstants::ATTR_PORT, &m_DeviceConfig.port); + ultrasoundTag->QueryBoolAttribute(USDeviceReaderWriterConstants::ATTR_SERVER, &m_DeviceConfig.server); + + m_DeviceConfig.deviceType = ReadStringAttribute(ultrasoundTag, USDeviceReaderWriterConstants::ATTR_TYPE); + m_DeviceConfig.deviceName = ReadStringAttribute(ultrasoundTag, USDeviceReaderWriterConstants::ATTR_TYPE); + m_DeviceConfig.manufacturer = ReadStringAttribute(ultrasoundTag, USDeviceReaderWriterConstants::ATTR_TYPE); + m_DeviceConfig.model = ReadStringAttribute(ultrasoundTag, USDeviceReaderWriterConstants::ATTR_TYPE); + m_DeviceConfig.comment = ReadStringAttribute(ultrasoundTag, USDeviceReaderWriterConstants::ATTR_TYPE); + m_DeviceConfig.host = ReadStringAttribute(ultrasoundTag, USDeviceReaderWriterConstants::ATTR_HOST); } void mitk::USDeviceReaderXML::ExtractAttributeInformationOfGeneralSettingsTag(const tinyxml2::XMLElement *generalSettingsTag) { - generalSettingsTag->QueryBoolAttribute(ATTR_GREYSCALE, &m_DeviceConfig.useGreyscale); - generalSettingsTag->QueryBoolAttribute(ATTR_RESOLUTIONOVERRIDE, &m_DeviceConfig.useResolutionOverride); - generalSettingsTag->QueryIntAttribute(ATTR_RESOLUTIONHEIGHT, &m_DeviceConfig.resolutionHeight); - generalSettingsTag->QueryIntAttribute(ATTR_RESOLUTIONWIDTH, &m_DeviceConfig.resolutionWidth); - generalSettingsTag->QueryIntAttribute(ATTR_SOURCEID, &m_DeviceConfig.sourceID); - generalSettingsTag->QueryIntAttribute(ATTR_OPENCVPORT, &m_DeviceConfig.opencvPort); - - m_DeviceConfig.filepathVideoSource = ReadStringAttribute(generalSettingsTag, ATTR_FILEPATH); + generalSettingsTag->QueryBoolAttribute(USDeviceReaderWriterConstants::ATTR_GREYSCALE, &m_DeviceConfig.useGreyscale); + generalSettingsTag->QueryBoolAttribute(USDeviceReaderWriterConstants::ATTR_RESOLUTIONOVERRIDE, &m_DeviceConfig.useResolutionOverride); + generalSettingsTag->QueryIntAttribute(USDeviceReaderWriterConstants::ATTR_RESOLUTIONHEIGHT, &m_DeviceConfig.resolutionHeight); + generalSettingsTag->QueryIntAttribute(USDeviceReaderWriterConstants::ATTR_RESOLUTIONWIDTH, &m_DeviceConfig.resolutionWidth); + generalSettingsTag->QueryIntAttribute(USDeviceReaderWriterConstants::ATTR_SOURCEID, &m_DeviceConfig.sourceID); + generalSettingsTag->QueryIntAttribute(USDeviceReaderWriterConstants::ATTR_OPENCVPORT, &m_DeviceConfig.opencvPort); + + m_DeviceConfig.filepathVideoSource = ReadStringAttribute(generalSettingsTag, USDeviceReaderWriterConstants::ATTR_FILEPATH); } void mitk::USDeviceReaderXML::ExtractProbe(const tinyxml2::XMLElement *probeTag) { mitk::USProbe::Pointer ultrasoundProbe = mitk::USProbe::New(); - auto probeName = ReadStringAttribute(probeTag, ATTR_NAME); + auto probeName = ReadStringAttribute(probeTag, USDeviceReaderWriterConstants::ATTR_NAME); ultrasoundProbe->SetName(probeName); - auto* depthsTag = probeTag->FirstChildElement(TAG_DEPTHS); + auto* depthsTag = probeTag->FirstChildElement(USDeviceReaderWriterConstants::TAG_DEPTHS); if (depthsTag != nullptr) { - for (auto* depthTag = depthsTag->FirstChildElement(TAG_DEPTH); + for (auto* depthTag = depthsTag->FirstChildElement(USDeviceReaderWriterConstants::TAG_DEPTH); depthTag != nullptr; depthTag = depthTag->NextSiblingElement()) { int depth = 0; mitk::Vector3D spacing; spacing[0] = 1; spacing[1] = 1; spacing[2] = 1; - depthTag->QueryIntAttribute(ATTR_DEPTH, &depth); + depthTag->QueryIntAttribute(USDeviceReaderWriterConstants::ATTR_DEPTH, &depth); - auto* spacingTag = depthTag->FirstChildElement(TAG_SPACING); + auto* spacingTag = depthTag->FirstChildElement(USDeviceReaderWriterConstants::TAG_SPACING); if (spacingTag != nullptr) { - spacingTag->QueryDoubleAttribute(ATTR_X, &spacing[0]); - spacingTag->QueryDoubleAttribute(ATTR_Y, &spacing[1]); + spacingTag->QueryDoubleAttribute(USDeviceReaderWriterConstants::ATTR_X, &spacing[0]); + spacingTag->QueryDoubleAttribute(USDeviceReaderWriterConstants::ATTR_Y, &spacing[1]); } ultrasoundProbe->SetDepthAndSpacing(depth, spacing); } } else { MITK_ERROR << "Error: DEPTHS-Tag was not found in the file :" << m_Filename << "Therefore, creating default depth [0] and spacing [1,1,1] for the probe."; ultrasoundProbe->SetDepth(0); } unsigned int croppingTop = 0; unsigned int croppingBottom = 0; unsigned int croppingLeft = 0; unsigned int croppingRight = 0; - auto* croppingTag = probeTag->FirstChildElement(TAG_CROPPING); + auto* croppingTag = probeTag->FirstChildElement(USDeviceReaderWriterConstants::TAG_CROPPING); if (croppingTag != nullptr) { - croppingTag->QueryUnsignedAttribute(ATTR_TOP, &croppingTop); - croppingTag->QueryUnsignedAttribute(ATTR_BOTTOM, &croppingBottom); - croppingTag->QueryUnsignedAttribute(ATTR_LEFT, &croppingLeft); - croppingTag->QueryUnsignedAttribute(ATTR_RIGHT, &croppingRight); + croppingTag->QueryUnsignedAttribute(USDeviceReaderWriterConstants::ATTR_TOP, &croppingTop); + croppingTag->QueryUnsignedAttribute(USDeviceReaderWriterConstants::ATTR_BOTTOM, &croppingBottom); + croppingTag->QueryUnsignedAttribute(USDeviceReaderWriterConstants::ATTR_LEFT, &croppingLeft); + croppingTag->QueryUnsignedAttribute(USDeviceReaderWriterConstants::ATTR_RIGHT, &croppingRight); } ultrasoundProbe->SetProbeCropping(croppingTop, croppingBottom, croppingLeft, croppingRight); m_DeviceConfig.probes.push_back(ultrasoundProbe); } diff --git a/Modules/US/USModel/mitkUSDeviceWriterXML.cpp b/Modules/US/USModel/mitkUSDeviceWriterXML.cpp index b1186fa24a..81a0ac8280 100644 --- a/Modules/US/USModel/mitkUSDeviceWriterXML.cpp +++ b/Modules/US/USModel/mitkUSDeviceWriterXML.cpp @@ -1,160 +1,160 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ // MITK #include "mitkUSDeviceReaderWriterConstants.h" #include "mitkUSDeviceWriterXML.h" #include #include #include // Third Party #include #include #include #include mitk::USDeviceWriterXML::USDeviceWriterXML() : AbstractFileWriter(USDevice::GetStaticNameOfClass(), mitk::IGTMimeTypes::USDEVICEINFORMATIONXML_MIMETYPE(), "MITK USDevice Writer (XML)"), m_Filename("") { RegisterService(); } mitk::USDeviceWriterXML::USDeviceWriterXML(const mitk::USDeviceWriterXML& other) : AbstractFileWriter(other) { } mitk::USDeviceWriterXML::~USDeviceWriterXML() { } mitk::USDeviceWriterXML* mitk::USDeviceWriterXML::Clone() const { return new USDeviceWriterXML(*this); } void mitk::USDeviceWriterXML::Write() { if (m_Filename == "") { MITK_WARN << "Cannot write to file - empty filename!"; return; } } void mitk::USDeviceWriterXML::SetFilename(std::string filename) { m_Filename = filename; } bool mitk::USDeviceWriterXML::WriteUltrasoundDeviceConfiguration(mitk::USDeviceReaderXML::USDeviceConfigData & config) { tinyxml2::XMLDocument document; document.InsertEndChild(document.NewDeclaration()); //Create the xml information of the ULTRASOUNDDEVICE-Tag: - auto *ultrasoundDeviceTag = document.NewElement(TAG_ULTRASOUNDDEVICE); + auto *ultrasoundDeviceTag = document.NewElement(USDeviceReaderWriterConstants::TAG_ULTRASOUNDDEVICE); this->CreateXmlInformationOfUltrasoundDeviceTag(document, ultrasoundDeviceTag, config); //Create the xml information of the GENERALSETTINGS-Tag: - auto *generalSettingsTag = document.NewElement(TAG_GENERALSETTINGS); + auto *generalSettingsTag = document.NewElement(USDeviceReaderWriterConstants::TAG_GENERALSETTINGS); this->CreateXmlInformationOfGeneralSettingsTag(ultrasoundDeviceTag, generalSettingsTag, config); //Create the xml information of the PROBES-Tag: this->CreateXmlInformationOfProbesTag(ultrasoundDeviceTag, config); return document.SaveFile(m_Filename.c_str()) == tinyxml2::XML_SUCCESS; } void mitk::USDeviceWriterXML::CreateXmlInformationOfUltrasoundDeviceTag( tinyxml2::XMLDocument &document, tinyxml2::XMLElement* ultrasoundDeviceTag, mitk::USDeviceReaderXML::USDeviceConfigData &config) { - ultrasoundDeviceTag->SetAttribute(ATTR_FILEVERS, config.fileversion); - ultrasoundDeviceTag->SetAttribute(ATTR_TYPE, config.deviceType.c_str()); - ultrasoundDeviceTag->SetAttribute(ATTR_NAME, config.deviceName.c_str()); - ultrasoundDeviceTag->SetAttribute(ATTR_MANUFACTURER, config.manufacturer.c_str()); - ultrasoundDeviceTag->SetAttribute(ATTR_MODEL, config.model.c_str()); - ultrasoundDeviceTag->SetAttribute(ATTR_COMMENT, config.comment.c_str()); - ultrasoundDeviceTag->SetAttribute(ATTR_IMAGESTREAMS, config.numberOfImageStreams); + ultrasoundDeviceTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_FILEVERS, config.fileversion); + ultrasoundDeviceTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_TYPE, config.deviceType.c_str()); + ultrasoundDeviceTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_NAME, config.deviceName.c_str()); + ultrasoundDeviceTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_MANUFACTURER, config.manufacturer.c_str()); + ultrasoundDeviceTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_MODEL, config.model.c_str()); + ultrasoundDeviceTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_COMMENT, config.comment.c_str()); + ultrasoundDeviceTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_IMAGESTREAMS, config.numberOfImageStreams); if (config.deviceType.compare("oigtl") == 0) { - ultrasoundDeviceTag->SetAttribute(ATTR_HOST, config.host.c_str()); - ultrasoundDeviceTag->SetAttribute(ATTR_PORT, config.port); + ultrasoundDeviceTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_HOST, config.host.c_str()); + ultrasoundDeviceTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_PORT, config.port); std::string value = config.server ? "true" : "false"; - ultrasoundDeviceTag->SetAttribute(ATTR_SERVER, value.c_str()); + ultrasoundDeviceTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_SERVER, value.c_str()); } document.InsertEndChild(ultrasoundDeviceTag); } void mitk::USDeviceWriterXML::CreateXmlInformationOfGeneralSettingsTag(tinyxml2::XMLElement *parentTag, tinyxml2::XMLElement *generalSettingsTag, mitk::USDeviceReaderXML::USDeviceConfigData & config) { std::string value = config.useGreyscale ? "true" : "false"; - generalSettingsTag->SetAttribute(ATTR_GREYSCALE, value.c_str()); + generalSettingsTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_GREYSCALE, value.c_str()); value = config.useResolutionOverride ? "true" : "false"; - generalSettingsTag->SetAttribute(ATTR_RESOLUTIONOVERRIDE, value.c_str()); - generalSettingsTag->SetAttribute(ATTR_RESOLUTIONWIDTH, config.resolutionWidth); - generalSettingsTag->SetAttribute(ATTR_RESOLUTIONHEIGHT, config.resolutionHeight); + generalSettingsTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_RESOLUTIONOVERRIDE, value.c_str()); + generalSettingsTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_RESOLUTIONWIDTH, config.resolutionWidth); + generalSettingsTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_RESOLUTIONHEIGHT, config.resolutionHeight); - generalSettingsTag->SetAttribute(ATTR_SOURCEID, config.sourceID); - generalSettingsTag->SetAttribute(ATTR_FILEPATH, config.filepathVideoSource.c_str()); - generalSettingsTag->SetAttribute(ATTR_OPENCVPORT, config.opencvPort); + generalSettingsTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_SOURCEID, config.sourceID); + generalSettingsTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_FILEPATH, config.filepathVideoSource.c_str()); + generalSettingsTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_OPENCVPORT, config.opencvPort); parentTag->InsertEndChild(generalSettingsTag); } void mitk::USDeviceWriterXML::CreateXmlInformationOfProbesTag(tinyxml2::XMLElement *parentTag, mitk::USDeviceReaderXML::USDeviceConfigData & config) { if (config.probes.size() != 0) { auto* doc = parentTag->GetDocument(); - auto *probesTag = doc->NewElement(TAG_PROBES); + auto *probesTag = doc->NewElement(USDeviceReaderWriterConstants::TAG_PROBES); parentTag->InsertEndChild(probesTag); for (size_t index = 0; index < config.probes.size(); ++index) { - auto *probeTag = doc->NewElement(TAG_PROBE); + auto *probeTag = doc->NewElement(USDeviceReaderWriterConstants::TAG_PROBE); probesTag->InsertEndChild(probeTag); mitk::USProbe::Pointer probe = config.probes.at(index); - probeTag->SetAttribute(ATTR_NAME, probe->GetName().c_str()); + probeTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_NAME, probe->GetName().c_str()); std::map depthsAndSpacing = probe->GetDepthsAndSpacing(); if (depthsAndSpacing.size() != 0) { - auto *depthsTag = doc->NewElement(TAG_DEPTHS); + auto *depthsTag = doc->NewElement(USDeviceReaderWriterConstants::TAG_DEPTHS); probeTag->InsertEndChild(depthsTag); for (std::map::iterator it = depthsAndSpacing.begin(); it != depthsAndSpacing.end(); it++) { - auto *depthTag = doc->NewElement(TAG_DEPTH); - depthTag->SetAttribute(ATTR_DEPTH, it->first); + auto *depthTag = doc->NewElement(USDeviceReaderWriterConstants::TAG_DEPTH); + depthTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_DEPTH, it->first); depthsTag->InsertEndChild(depthTag); - auto *spacingTag = doc->NewElement(TAG_SPACING); - spacingTag->SetAttribute(ATTR_X, it->second[0]); - spacingTag->SetAttribute(ATTR_Y, it->second[1]); + auto *spacingTag = doc->NewElement(USDeviceReaderWriterConstants::TAG_SPACING); + spacingTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_X, it->second[0]); + spacingTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_Y, it->second[1]); depthTag->InsertEndChild(spacingTag); } - auto *croppingTag = doc->NewElement(TAG_CROPPING); + auto *croppingTag = doc->NewElement(USDeviceReaderWriterConstants::TAG_CROPPING); probeTag->InsertEndChild(croppingTag); - croppingTag->SetAttribute(ATTR_TOP, probe->GetProbeCropping().top); - croppingTag->SetAttribute(ATTR_BOTTOM, probe->GetProbeCropping().bottom); - croppingTag->SetAttribute(ATTR_LEFT, probe->GetProbeCropping().left); - croppingTag->SetAttribute(ATTR_RIGHT, probe->GetProbeCropping().right); + croppingTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_TOP, probe->GetProbeCropping().top); + croppingTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_BOTTOM, probe->GetProbeCropping().bottom); + croppingTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_LEFT, probe->GetProbeCropping().left); + croppingTag->SetAttribute(USDeviceReaderWriterConstants::ATTR_RIGHT, probe->GetProbeCropping().right); } } } } diff --git a/Modules/US/files.cmake b/Modules/US/files.cmake index 42c099ed21..2f67fd9490 100644 --- a/Modules/US/files.cmake +++ b/Modules/US/files.cmake @@ -1,36 +1,37 @@ SET(CPP_FILES ## Module Activator mitkUSActivator.cpp ## Model Classes USModel/mitkUSImage.cpp USModel/mitkUSImageMetadata.cpp USModel/mitkUSDevice.cpp USModel/mitkUSIGTLDevice.cpp USModel/mitkUSVideoDevice.cpp USModel/mitkUSVideoDeviceCustomControls.cpp USModel/mitkUSProbe.cpp USModel/mitkUSDevicePersistence.cpp +USModel/mitkUSDeviceReaderWriterConstants.cpp USModel/mitkUSDeviceReaderXML.cpp USModel/mitkUSDeviceWriterXML.cpp ## Filters and Sources USFilters/mitkUSImageLoggingFilter.cpp USFilters/mitkUSImageSource.cpp USFilters/mitkUSImageVideoSource.cpp USFilters/mitkIGTLMessageToUSImageFilter.cpp ## Control Interfaces USControlInterfaces/mitkUSAbstractControlInterface.cpp USControlInterfaces/mitkUSControlInterfaceBMode.cpp USControlInterfaces/mitkUSControlInterfaceProbes.cpp USControlInterfaces/mitkUSControlInterfaceDoppler.cpp USControlInterfaces/mitkUSDiPhASDeviceCustomControls.cpp ) set(RESOURCE_FILES Interactions/USPointMarkInteractions.xml Interactions/USZoneInteractions.xml Interactions/USZoneInteractionsHold.xml )