00001 #ifndef __VIEWSTATE_H 00002 #define __VIEWSTATE_H 00003 00004 #include "zoomattr.h" 00005 #include "shape.h" 00006 #include "xmlserializeable.h" 00007 00014 class ViewState : public XMLSerializeable { 00015 public: 00016 bool mEditable; 00017 ZoomAttr mZoom; 00018 std::string mName; 00019 std::string mChildName; 00020 std::string mParentName; 00021 Rect mGeom; 00022 00023 public: 00024 ViewState( ) { 00025 mZoom.factor = 1.0; 00026 mZoom.type = ZoomAttr::WHOLE; 00027 mZoom.min = -99999999; 00028 mZoom.max = 99999999; 00029 mEditable = true; 00030 } 00031 00032 00033 virtual bool toXML(QDomDocument &doc, 00034 QDomElement &elem, 00035 std::string id = "" ) { 00036 QDomElement base = 00037 createBaseTag( doc, elem, id, "ViewState" ); 00038 00039 writeIntTag( doc, base, "Editable", mEditable ); 00040 writeTextTag( doc, base, "Name", mName ); 00041 writeTextTag( doc, base, "ChildName", mChildName ); 00042 writeTextTag( doc, base, "ParentName", mParentName ); 00043 mZoom.toXML( doc, base ); 00044 mGeom.toXML( doc, base ); 00045 return true; 00046 } 00047 00048 virtual bool fromXML( QDomElement &elem ) { 00049 QDomNodeList nodelist; 00050 QDomElement e; 00051 if ( std::string( "ViewState" ).compare( (const char*)elem.tagName() ) ) 00052 return false; 00053 00054 mEditable = readIntTag( elem, "Editable" ); 00055 mName = readTextTag( elem, "Name" ); 00056 mChildName = readTextTag( elem, "ChildName" ); 00057 mParentName = readTextTag( elem, "ParentName" ); 00058 00059 nodelist = elem.elementsByTagName( "ZoomAttr" ); 00060 if ( nodelist.count() >= 1 ) { 00061 e = nodelist.item(0).toElement(); 00062 mZoom.fromXML( e ); 00063 } 00064 00065 nodelist = elem.elementsByTagName( "Rect" ); 00066 if ( nodelist.count() >= 1 ) { 00067 e = nodelist.item(0).toElement(); 00068 mGeom.fromXML( e ); 00069 } 00070 00071 return true; 00072 } 00073 00074 }; 00075 00076 #endif 00077 00078 00079 00080 00081
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |