00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date: 2009-07-07 15:56:37 +0200 (Di, 07. Jul 2009) $ 00006 Version: $Revision: 1.12 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #ifndef mitkClippingPropertySerializer_h_included 00019 #define mitkClippingPropertySerializer_h_included 00020 00021 #include "mitkBasePropertySerializer.h" 00022 00023 #include "mitkClippingProperty.h" 00024 #include "mitkVector.h" 00025 00026 #include "SceneSerializationBaseExports.h" 00027 00028 namespace mitk 00029 { 00030 class SceneSerializationBase_EXPORT ClippingPropertySerializer : public BasePropertySerializer 00031 { 00032 public: 00033 mitkClassMacro( ClippingPropertySerializer, BasePropertySerializer ); 00034 itkNewMacro(Self); 00035 00036 virtual TiXmlElement* Serialize() 00037 { 00038 if (const ClippingProperty* prop = dynamic_cast<const ClippingProperty*>(m_Property.GetPointer())) 00039 { 00040 TiXmlElement* element = new TiXmlElement("clipping"); 00041 if (prop->GetClippingEnabled()) 00042 element->SetAttribute("enabled", "true"); 00043 else 00044 element->SetAttribute("enabled", "false"); 00045 TiXmlElement* originElement = new TiXmlElement("origin"); 00046 const Point3D origin = prop->GetOrigin(); 00047 originElement->SetDoubleAttribute("x", origin[0]); 00048 originElement->SetDoubleAttribute("y", origin[1]); 00049 originElement->SetDoubleAttribute("z", origin[2]); 00050 element->LinkEndChild(originElement); 00051 TiXmlElement* normalElement = new TiXmlElement("normal"); 00052 const Vector3D normal = prop->GetNormal(); 00053 normalElement->SetDoubleAttribute("x", normal[0]); 00054 normalElement->SetDoubleAttribute("y", normal[1]); 00055 normalElement->SetDoubleAttribute("z", normal[2]); 00056 element->LinkEndChild(normalElement); 00057 return element; 00058 } 00059 else 00060 return NULL; 00061 } 00062 protected: 00063 ClippingPropertySerializer() {} 00064 virtual ~ClippingPropertySerializer() {} 00065 }; 00066 } // namespace 00067 // important to put this into the GLOBAL namespace (because it starts with 'namespace mitk') 00068 MITK_REGISTER_SERIALIZER(ClippingPropertySerializer); 00069 #endif