13 #ifndef mitkAnnotationPropertySerializer_h_included 14 #define mitkAnnotationPropertySerializer_h_included 23 class AnnotationPropertySerializer :
public BasePropertySerializer
26 mitkClassMacro(AnnotationPropertySerializer, BasePropertySerializer);
27 itkFactorylessNewMacro(Self) itkCloneMacro(Self)
29 TiXmlElement *Serialize()
override 31 if (
const AnnotationProperty *prop = dynamic_cast<const AnnotationProperty *>(m_Property.GetPointer()))
33 auto element =
new TiXmlElement(
"annotation");
34 element->SetAttribute(
"label", prop->GetLabel());
35 Point3D point = prop->GetPosition();
36 element->SetAttribute(
"x", boost::lexical_cast<std::string>(point[0]));
37 element->SetAttribute(
"y", boost::lexical_cast<std::string>(point[1]));
38 element->SetAttribute(
"z", boost::lexical_cast<std::string>(point[2]));
49 const char *label(element->Attribute(
"label"));
50 std::string p_string[3];
51 if (element->QueryStringAttribute(
"x", &p_string[0]) != TIXML_SUCCESS)
53 if (element->QueryStringAttribute(
"y", &p_string[1]) != TIXML_SUCCESS)
55 if (element->QueryStringAttribute(
"z", &p_string[2]) != TIXML_SUCCESS)
60 StringsToNumbers<double>(3, p_string, p);
62 catch (boost::bad_lexical_cast &e)
64 MITK_ERROR <<
"Could not parse string as number: " << e.what();
72 AnnotationPropertySerializer() {}
73 ~AnnotationPropertySerializer()
override {}
MITK_REGISTER_SERIALIZER(AnnotationPropertySerializer)
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< Self > Pointer
#define mitkClassMacro(className, SuperClassName)
Point< ScalarType, 3 > Point3D