Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

QGLViewerXML.h

Go to the documentation of this file.
00001 /*
00002  * QGLViewerXML.h
00003  * $Id: QGLViewerXML.h,v 1.6 2001/09/28 11:06:08 mjanich Exp $
00004  *
00005  * Copyright (C) 1999, 2000, 2001 Michael Meissner, Alexander Buck
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 
00023 //  Description : Class QGLViewerXML
00024 //  Purpose     : Provides  funcionality
00025 
00026 
00027 #ifndef __QGLVIEWERXML_H
00028 #define __QGLVIEWERXML_H
00029 
00030 
00031 // System
00033 #include <math.h>
00034 #include <iostream.h>
00035 
00036 // Own
00038 #include "CP2D.h"
00039 #include "CV2D.h"
00040 #include "CBoundingBox3D.h"
00041 #include "CCamera.h"
00042 #include "CList.h"
00043 #include "CCameraKeyPathPoint.h"
00044 #include "CCameraKeyPathAttributes.h"
00045 
00046 // Qt
00048 #include <qdom.h>
00049 
00050 
00051 // forward declarations
00053 
00054 
00055 
00061 namespace QGLViewerXML {
00062 
00066    QDomElement addNode(QDomElement& parent,
00067                        const QString& member = QString::null);
00068 
00071    QDomElement queryNode(const QDomElement& parent,
00072                          const QString& member);
00073 
00076   bool readXML(const QDomElement&, CP2D&);
00077 
00080   bool writeXML(QDomElement, const CP2D&);
00081 
00084   bool readXML(const QDomElement&, CP3D&);
00085 
00088   bool writeXML(QDomElement, const CP3D&);
00089 
00092   bool readXML(const QDomElement&, CP4D&);
00093 
00096   bool writeXML(QDomElement, const CP4D&);
00097 
00098 
00101   bool readXML(const QDomElement&, CV2D&);
00102 
00105   bool writeXML(QDomElement, const CV2D&);
00106 
00109   bool readXML(const QDomElement&, CV3D&);
00110 
00113   bool writeXML(QDomElement, const CV3D&);
00114 
00117   bool readXML(const QDomElement&, CV4D&);
00118 
00121   bool writeXML(QDomElement, const CV4D&);
00122 
00123 
00126   bool readXML(const QDomElement&, CQuat&);
00127 
00130   bool writeXML(QDomElement, const CQuat&);
00131 
00132 
00135   bool readXML(const QDomElement&, CBoundingBox3D&);
00136 
00139   bool writeXML(QDomElement, const CBoundingBox3D&);
00140 
00141 
00144   bool readXML(const QDomElement&, CMat4D&);
00145 
00148   bool writeXML(QDomElement, const CMat4D&);
00149 
00150 
00153   bool readXML(const QDomElement&, CCamera&);
00154 
00157   bool writeXML(QDomElement, const CCamera&);
00158 
00160   bool readXML(const QDomElement&, CCameraKeyPathPoint&);
00161     
00165   bool writeXML(QDomElement, const CCameraKeyPathPoint&,bool fParams=true);
00166     
00171   bool readXML(const QDomElement&, CCameraKeyPathAttributes&);
00172     
00176   bool writeXML(QDomElement, const CCameraKeyPathAttributes&);
00177 
00181   template <class T>
00182     bool readXML(const QDomElement& domElem, CList<T>& list, QString tagName="CList") {
00183     if (domElem.nodeName().compare(tagName) != 0)
00184       return false;
00185 
00186     int l=0;
00187     QDomNode node = domElem.firstChild();
00188     while (!node.isNull()) {
00189       if (node.isElement()) {
00190         QDomElement elem = node.toElement();
00191         T cam;
00192 
00193         if (QGLViewerXML::readXML(elem, cam)) {
00194           list.insertAsLast(new T(cam));
00195           l++;
00196         }
00197       }
00198       node = node.nextSibling();
00199     }
00200 
00201     return l>0;
00202   };
00203 
00204 
00205 
00209   template <class T>
00210     bool writeXML(QDomElement domElem, const CList<T>& list, QString tagName="CList") {
00211     domElem.setTagName(tagName);
00212     CListContainer<T> *pContainer;
00213     pContainer = list.getFirst();
00214     while (pContainer) {
00215       if (!writeXML(addNode(domElem), *(pContainer->getObject())))
00216         return false;
00217       pContainer = pContainer->getNext();
00218     }
00219     return true;
00220   };
00221 
00222 }
00223 
00224 
00225 #endif

Generated at Thu Oct 4 17:17:26 2001 for QGLViewer by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001