17 #ifndef mitkAnnotationPropertySerializer_h_included
18 #define mitkAnnotationPropertySerializer_h_included
27 class AnnotationPropertySerializer :
public BasePropertySerializer
30 mitkClassMacro(AnnotationPropertySerializer, BasePropertySerializer);
31 itkFactorylessNewMacro(Self) itkCloneMacro(Self)
33 virtual TiXmlElement *Serialize()
override
35 if (
const AnnotationProperty *prop = dynamic_cast<const AnnotationProperty *>(m_Property.GetPointer()))
37 auto element =
new TiXmlElement(
"annotation");
38 element->SetAttribute(
"label", prop->GetLabel());
39 Point3D point = prop->GetPosition();
40 element->SetAttribute(
"x", boost::lexical_cast<std::string>(point[0]));
41 element->SetAttribute(
"y", boost::lexical_cast<std::string>(point[1]));
42 element->SetAttribute(
"z", boost::lexical_cast<std::string>(point[2]));
53 const char *label(element->Attribute(
"label"));
54 std::string p_string[3];
55 if (element->QueryStringAttribute(
"x", &p_string[0]) != TIXML_SUCCESS)
57 if (element->QueryStringAttribute(
"y", &p_string[1]) != TIXML_SUCCESS)
59 if (element->QueryStringAttribute(
"z", &p_string[2]) != TIXML_SUCCESS)
64 StringsToNumbers<double>(3, p_string, p);
66 catch (boost::bad_lexical_cast &e)
68 MITK_ERROR <<
"Could not parse string as number: " << e.what();
76 AnnotationPropertySerializer() {}
77 virtual ~AnnotationPropertySerializer() {}
MITK_REGISTER_SERIALIZER(AnnotationPropertySerializer)
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< Self > Pointer
#define mitkClassMacro(className, SuperClassName)
Point< ScalarType, 3 > Point3D