22 #include <itksys/SystemTools.hxx> 28 "MITK USDevice Writer (XML)"), m_Filename(
"")
50 MITK_WARN <<
"Cannot write to file - empty filename!";
57 m_Filename = filename;
62 TiXmlDocument document;
63 TiXmlDeclaration* xmlDeclaration =
new TiXmlDeclaration(
"1.0",
"",
"");
64 document.LinkEndChild(xmlDeclaration);
79 return document.SaveFile(m_Filename);
83 TiXmlDocument &document, TiXmlElement * ultrasoundDeviceTag,
98 std::string value = config.
server ?
"true" :
"false";
99 ultrasoundDeviceTag->SetAttribute(
ATTR_SERVER, value);
102 document.LinkEndChild(ultrasoundDeviceTag);
107 std::string value = config.
useGreyscale ?
"true" :
"false";
118 parentTag->LinkEndChild(generalSettingsTag);
123 if (config.
probes.size() != 0)
125 TiXmlElement *probesTag =
new TiXmlElement(
TAG_PROBES);
126 parentTag->LinkEndChild(probesTag);
128 for (
size_t index = 0; index < config.
probes.size(); ++index)
130 TiXmlElement *probeTag =
new TiXmlElement(
TAG_PROBE);
131 probesTag->LinkEndChild(probeTag);
133 mitk::USProbe::Pointer probe = config.
probes.at(index);
134 probeTag->SetAttribute(
ATTR_NAME, probe->GetName());
135 std::map<int, mitk::Vector3D> depthsAndSpacing = probe->GetDepthsAndSpacing();
136 if (depthsAndSpacing.size() != 0)
138 TiXmlElement *depthsTag =
new TiXmlElement(
TAG_DEPTHS);
139 probeTag->LinkEndChild(depthsTag);
140 for (std::map<int, mitk::Vector3D>::iterator it = depthsAndSpacing.begin(); it != depthsAndSpacing.end(); it++)
142 TiXmlElement *depthTag =
new TiXmlElement(
TAG_DEPTH);
143 depthTag->SetAttribute(
ATTR_DEPTH, it->first);
144 depthsTag->LinkEndChild(depthTag);
146 TiXmlElement *spacingTag =
new TiXmlElement(
TAG_SPACING);
147 spacingTag->SetDoubleAttribute(
ATTR_X, it->second[0], 6);
148 spacingTag->SetDoubleAttribute(
ATTR_Y, it->second[1], 6);
149 depthTag->LinkEndChild(spacingTag);
152 TiXmlElement *croppingTag =
new TiXmlElement(
TAG_CROPPING);
153 probeTag->LinkEndChild(croppingTag);
154 croppingTag->SetAttribute(
ATTR_TOP, probe->GetProbeCropping().top);
155 croppingTag->SetAttribute(
ATTR_BOTTOM, probe->GetProbeCropping().bottom);
156 croppingTag->SetAttribute(
ATTR_LEFT, probe->GetProbeCropping().left);
157 croppingTag->SetAttribute(
ATTR_RIGHT, probe->GetProbeCropping().right);
A device holds information about it's model, make and the connected probes. It is the common super cl...
void CreateXmlInformationOfUltrasoundDeviceTag(TiXmlDocument &document, TiXmlElement *ultrasoundDeviceTag, mitk::USDeviceReaderXML::USDeviceConfigData &config)
Creates the xml ULTRASOUNDDEVICE-Tag entry of the ultrasound video device configuration file...
static const char * TAG_CROPPING
static const char * TAG_DEPTH
void CreateXmlInformationOfGeneralSettingsTag(TiXmlElement *parentTag, TiXmlElement *generalSettingsTag, mitk::USDeviceReaderXML::USDeviceConfigData &config)
Creates the xml GENERALSETTINGS-Tag entry of the ultrasound video device configuration file...
static const char * ATTR_OPENCVPORT
static const char * ATTR_SERVER
static const char * TAG_PROBE
static const char * ATTR_RIGHT
DataCollection - Class to facilitate loading/accessing structured data.
static const char * ATTR_GREYSCALE
static const char * ATTR_RESOLUTIONWIDTH
std::string filepathVideoSource
std::vector< mitk::USProbe::Pointer > probes
void Write() override
Write the base data to the specified location or output stream.
static const char * ATTR_TOP
static const char * ATTR_DEPTH
static const char * ATTR_Y
bool useResolutionOverride
static const char * ATTR_LEFT
static const char * ATTR_COMMENT
static const char * ATTR_X
static const char * ATTR_TYPE
void SetFilename(std::string filename)
Sets the filename of the ultrasound device configuration file which should be created.
static const char * ATTR_IMAGESTREAMS
static const char * ATTR_PORT
mitk::USDeviceWriterXML * Clone() const override
static const char * ATTR_FILEVERS
bool WriteUltrasoundDeviceConfiguration(mitk::USDeviceReaderXML::USDeviceConfigData &config)
Writes the configuration settings of an ultrasound device to a xml-file.
static const char * ATTR_FILEPATH
us::ServiceRegistration< IFileWriter > RegisterService(us::ModuleContext *context=us::GetModuleContext())
static const char * ATTR_RESOLUTIONHEIGHT
static const char * ATTR_MODEL
~USDeviceWriterXML() override
static const char * ATTR_BOTTOM
static const char * TAG_ULTRASOUNDDEVICE
static const char * TAG_SPACING
static const char * ATTR_NAME
static const char * ATTR_HOST
Base class for writing mitk::BaseData objects to files or streams.
static const char * TAG_GENERALSETTINGS
static const char * ATTR_RESOLUTIONOVERRIDE
static const char * ATTR_MANUFACTURER
void CreateXmlInformationOfProbesTag(TiXmlElement *parentTag, mitk::USDeviceReaderXML::USDeviceConfigData &config)
Creates the xml PROBES-Tag entry of the ultrasound video device configuration file. All information of all configured probes is extracted and then stored in the xml file.
static const char * TAG_PROBES
static const char * TAG_DEPTHS
static const char * ATTR_SOURCEID