00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 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 mitkLevelWindowPropertySerializer_h_included 00019 #define mitkLevelWindowPropertySerializer_h_included 00020 00021 #include "mitkBasePropertySerializer.h" 00022 00023 #include "mitkLevelWindowProperty.h" 00024 00025 #include "SceneSerializationBaseExports.h" 00026 00027 namespace mitk 00028 { 00029 00030 class SceneSerializationBase_EXPORT LevelWindowPropertySerializer : public BasePropertySerializer 00031 { 00032 public: 00033 00034 mitkClassMacro( LevelWindowPropertySerializer, BasePropertySerializer ); 00035 itkNewMacro(Self); 00036 00037 virtual TiXmlElement* Serialize() 00038 { 00039 if (const LevelWindowProperty* prop = dynamic_cast<const LevelWindowProperty*>(m_Property.GetPointer())) 00040 { 00041 TiXmlElement* element = new TiXmlElement("LevelWindow"); 00042 00043 LevelWindow lw = prop->GetLevelWindow(); 00044 std::string boolString("false"); 00045 if (lw.IsFixed() == true) 00046 boolString = "true"; 00047 element->SetAttribute("fixed", boolString.c_str()); 00048 00049 TiXmlElement* child = new TiXmlElement("CurrentSettings"); 00050 element->LinkEndChild( child ); 00051 child->SetDoubleAttribute("level", lw.GetLevel()); 00052 child->SetDoubleAttribute("window", lw.GetWindow()); 00053 00054 child = new TiXmlElement("DefaultSettings"); 00055 element->LinkEndChild( child ); 00056 child->SetDoubleAttribute("level", lw.GetDefaultLevel()); 00057 child->SetDoubleAttribute("window", lw.GetDefaultWindow()); 00058 00059 child = new TiXmlElement("CurrentRange"); 00060 element->LinkEndChild( child ); 00061 child->SetDoubleAttribute("min", lw.GetRangeMin()); 00062 child->SetDoubleAttribute("max", lw.GetRangeMax()); 00063 00064 00065 return element; 00066 } 00067 else return NULL; 00068 } 00069 00070 protected: 00071 00072 LevelWindowPropertySerializer() {} 00073 virtual ~LevelWindowPropertySerializer() {} 00074 }; 00075 00076 } // namespace 00077 00078 // important to put this into the GLOBAL namespace (because it starts with 'namespace mitk') 00079 MITK_REGISTER_SERIALIZER(LevelWindowPropertySerializer); 00080 00081 #endif 00082