00001 #if !defined(_GLACIERLINEHISTORY_H_) 00002 #define _GLACIERLINEHISTORY_H_ 00003 00004 #include <stack> 00005 #include "glimslinedata.h" 00006 #include "TraceLog.h" 00007 00020 enum HistoryAction { 00021 noAction, 00022 deletedNode, deletedLine, 00023 addedNode, addedLine, 00024 insertedNode, 00025 movedNode, 00026 joinedLines, 00027 brokeLine, 00028 selection 00029 } ; 00030 00042 class GlacierLineHistoryElement { 00043 00044 private: 00045 Shape * mGlacierLineComponent ; 00046 00047 int mLineIndex ; 00048 int mNodeIndex ; 00049 00050 HistoryAction mAction ; 00051 00052 public: 00057 GlacierLineHistoryElement() { 00058 mGlacierLineComponent = NULL ; 00059 mLineIndex = -1 ; 00060 mNodeIndex = -1 ; 00061 mAction = noAction ; 00062 } 00063 00074 GlacierLineHistoryElement(GlacierLine & shp, int iline, int inode, HistoryAction action) { 00075 00076 GlacierLine * newLine = new GlacierLine ; 00077 (*newLine) = shp ; 00078 mGlacierLineComponent = newLine ; 00079 00080 mLineIndex = iline ; 00081 mNodeIndex = inode ; 00082 mAction = action ; 00083 00084 } 00085 00096 GlacierLineHistoryElement(Node & shp, int iline, int inode, HistoryAction action) { 00097 Node * newNode = new Node ; 00098 (*newNode) = shp ; 00099 mGlacierLineComponent = newNode ; 00100 mLineIndex = iline ; 00101 mNodeIndex = inode ; 00102 mAction = action ; 00103 } 00104 00105 virtual ~GlacierLineHistoryElement() {} 00106 00110 HistoryAction getAction () { return mAction ; } 00111 void setAction (HistoryAction newAction) { mAction = newAction ; } 00112 00116 Shape * getShape () { return mGlacierLineComponent ; } 00117 00118 void setShape (GlacierLine * newShape) { 00119 GlacierLine * newLine = new GlacierLine ; 00120 (*newLine) = (*newShape) ; 00121 mGlacierLineComponent = newLine ; 00122 } 00123 00124 void setShape (Node * newShape) { 00125 Node * newNode = new Node ; 00126 (*newNode) = (*newShape) ; 00127 mGlacierLineComponent = newNode ; 00128 } 00129 00133 int getLineIndex () { return mLineIndex ; } 00134 void setLineIndex (int li) { mLineIndex = li; } 00135 00140 int getNodeIndex () { return mNodeIndex ; } 00141 void setNodeIndex (int ni) { mNodeIndex = ni ; } 00142 00143 } ; 00144 00162 class GlacierLineHistory { 00163 private: 00165 stack <GlacierLineHistoryElement*> mHistory ; 00166 00167 public: 00168 GlacierLineHistory() {;} 00169 virtual ~GlacierLineHistory() {;} 00170 00181 void push (GlacierLine & shp, int iline, int inode, HistoryAction action) { 00182 GlacierLineHistoryElement * newElem = new GlacierLineHistoryElement (shp, iline, inode, action) ; 00183 mHistory.push (newElem) ; 00184 } 00185 00196 void push (Node & shp, int iline, int inode, HistoryAction action) { 00197 GlacierLineHistoryElement * newElem = new GlacierLineHistoryElement (shp, iline, inode, action) ; 00198 mHistory.push (newElem) ; 00199 } 00200 00208 void push (GlacierLineHistoryElement * historyElement) { 00209 mHistory.push (historyElement) ; 00210 } 00211 00219 GlacierLineHistoryElement * pop () { 00220 if (mHistory.size()) { 00221 GlacierLineHistoryElement * element = mHistory.top () ; 00222 mHistory.pop () ; 00223 return element ; 00224 } 00225 else return NULL ; 00226 } 00227 00235 GlacierLineHistoryElement * peek () { 00236 if (mHistory.size()) { 00237 GlacierLineHistoryElement * element = mHistory.top () ; 00238 return element ; 00239 } 00240 else return NULL ; 00241 } 00242 00250 void clear () { 00251 for (unsigned int i = 0 ; i < mHistory.size() ; i++) { 00252 mHistory.pop() ; 00253 } 00254 } 00255 00261 int size() { 00262 return mHistory.size() ; 00263 } 00264 00265 }; 00266 00267 #endif // !defined(_GLACIERLINEHISTORY_H_) 00268 00269 00270
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |