00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef __QGLVIEWERXML_H
00035 #define __QGLVIEWERXML_H
00036
00037
00038
00040 #include <math.h>
00041 #ifdef _MSC_VER
00042 #if _MSC_VER >= 1300
00043 #include <iostream>
00044 #endif
00045 #else
00046 #include <iostream.h>
00047 #endif
00048
00049
00050
00052 #include "CP2D.h"
00053 #include "CV2D.h"
00054 #include "CBoundingBox3D.h"
00055 #include "CCamera.h"
00056 #include "CList.h"
00057 #include "CCameraKeyPathPoint.h"
00058 #include "CCameraKeyPathAttributes.h"
00059
00060
00062 #include <qdom.h>
00063
00064
00065
00067
00068
00069
00075 namespace QGLViewerXML {
00076
00080 QDomElement addNode(QDomElement& parent,
00081 const QString& member = QString::null);
00082
00085 QDomElement queryNode(const QDomElement& parent,
00086 const QString& member);
00087
00090 bool readXML(const QDomElement&, CP2D&);
00091
00094 bool writeXML(QDomElement, const CP2D&);
00095
00098 bool readXML(const QDomElement&, CP3D&);
00099
00102 bool writeXML(QDomElement, const CP3D&);
00103
00106 bool readXML(const QDomElement&, CP4D&);
00107
00110 bool writeXML(QDomElement, const CP4D&);
00111
00112
00115 bool readXML(const QDomElement&, CV2D&);
00116
00119 bool writeXML(QDomElement, const CV2D&);
00120
00123 bool readXML(const QDomElement&, CV3D&);
00124
00127 bool writeXML(QDomElement, const CV3D&);
00128
00131 bool readXML(const QDomElement&, CV4D&);
00132
00135 bool writeXML(QDomElement, const CV4D&);
00136
00137
00140 bool readXML(const QDomElement&, CQuat&);
00141
00144 bool writeXML(QDomElement, const CQuat&);
00145
00146
00149 bool readXML(const QDomElement&, CBoundingBox3D&);
00150
00153 bool writeXML(QDomElement, const CBoundingBox3D&);
00154
00155
00158 bool readXML(const QDomElement&, CMat4D&);
00159
00162 bool writeXML(QDomElement, const CMat4D&);
00163
00164
00167 bool readXML(const QDomElement&, CCamera&);
00168
00171 bool writeXML(QDomElement, const CCamera&);
00172
00174 bool readXML(const QDomElement&, CCameraKeyPathPoint&);
00175
00179 bool writeXML(QDomElement, const CCameraKeyPathPoint&,bool fParams=true);
00180
00185 bool readXML(const QDomElement&, CCameraKeyPathAttributes&);
00186
00190 bool writeXML(QDomElement, const CCameraKeyPathAttributes&);
00191
00195 template <class T>
00196 bool readXML(const QDomElement& domElem, CList<T>& list, QString tagName="CList") {
00197 if (domElem.nodeName().compare(tagName) != 0)
00198 return false;
00199
00200 int l=0;
00201 QDomNode node = domElem.firstChild();
00202 while (!node.isNull()) {
00203 if (node.isElement()) {
00204 QDomElement elem = node.toElement();
00205 T cam;
00206
00207 if (QGLViewerXML::readXML(elem, cam)) {
00208 list.insertAsLast(new T(cam));
00209 l++;
00210 }
00211 }
00212 node = node.nextSibling();
00213 }
00214
00215 return l>0;
00216 };
00217
00218
00219
00223 template <class T>
00224 bool writeXML(QDomElement domElem, const CList<T>& list, QString tagName="CList") {
00225 domElem.setTagName(tagName);
00226 CListContainer<T> *pContainer;
00227 pContainer = list.getFirst();
00228 while (pContainer) {
00229 if (!writeXML(addNode(domElem), *(pContainer->getObject())))
00230 return false;
00231 pContainer = pContainer->getNext();
00232 }
00233 return true;
00234 };
00235
00236 }
00237
00238
00239 #endif