cm_project.h

00001 /* -- 2007-05-07 -- 
00002  *  ardev - an augmented reality library for robot developers
00003  *  Copyright 2005-2007 - Toby Collett (ardev _at_ plan9.net.nz)
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Lesser General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2.1 of the License, or (at your option) any later version.
00009  *
00010  *  This library is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00013  *  Lesser General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU Lesser General Public
00016  *  License along with this library; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
00018  *
00019  */
00020  
00021 #ifndef ARIDE_PROJECT_H
00022 #define ARIDE_PROJECT_H
00023 
00024 #define CONFIG_FILE_VERSION "0.3"
00025 
00026 #include <ardev/ardev.h>
00027 
00028 #include <QDomNode>
00029 #include <QDomElement>
00030 #include <QDomDocument>
00031 
00032 #include <stdlib.h>
00033 #include <list>
00034 #include <vector>
00035 #include <deque>
00036 using namespace std;
00037 
00038 class QWidget;
00039 class ObjectHandler;
00040 class EnvironmentObjectHandler;
00041 
00042 typedef enum ArideSection {ARIDE_UNKNOWN,ARIDE_CAMERA,ARIDE_CAPTURE,ARIDE_OUTPUT,ARIDE_SECONDARYOUTPUT,ARIDE_PREPROCESS,ARIDE_POSITION,ARIDE_RENDER,ARIDE_MISC,ARIDE_RENDERPAIR,ARIDE_ENVIRONMENTS,ARIDE_END} ArideSection;
00043 const char * GetArideSectionTypeName(ArideSection Section);
00044 
00045 class aride_object
00046 {
00047         public:
00048                 aride_object(const QDomElement & _Element, ObjectHandler * Handler=NULL);
00049                 virtual ~aride_object();
00050         
00051                 QString GUID;
00052                 QString Parent;
00053                 ArideSection Section;   // ie camera, capture etc
00054                 QString Type;           // ie CameraPlayer
00055         
00056                 QDomElement Element;
00057         
00058                 static int GetSection(const QString & TagName);
00059                 
00060                 void ChangeType(const QString & NewType);
00061                 
00062                 QString GetName() const;
00063                 void SetName(const QString & Name);
00064                 
00065                 ObjectHandler * Handler;
00066 };
00067 
00068 
00069 class aride_environment : public aride_object
00070 {
00071         public:
00072                 aride_environment(const QDomElement & _Element);
00073                 virtual ~aride_environment();
00074         
00075                 EnvironmentObjectHandler * EnvHandler;
00076                 
00077                 QString Out;
00078                 QString Cam;
00079                 QString Cap;
00080                 list<QString> PreProcessObjects;
00081                 list<QString> SecondaryObjects;
00082                 list<QString> MiscObjects;
00083 
00084                 void Start();
00085                 void Pause();
00086                 void Stop();
00087                 bool Paused;
00088         
00089 };
00090 
00091 
00092 class aride_displaylist_node
00093 {
00094         public:
00095                 aride_displaylist_node(const QDomElement & _Element, aride_displaylist_node * _Parent, aride_object * _Object);
00096                 ~aride_displaylist_node();
00097                 
00098                 aride_displaylist_node * Parent;
00099                 
00100                 QDomElement Element;
00101                 aride_object * object;
00102                 QString GUID;
00103                 QString Name;
00104                 
00105                 QString GetName() {return Name;};
00106                 void SetName(const QString & _Name) {Name = _Name;};
00107 };
00108 
00109 
00110 class aride_project
00111 {
00112         public:
00113                 aride_project();
00114                 ~aride_project();
00115 
00116                 int LoadFromFile(const char * Filename);
00117                 int SaveToFile(const char * Filename=NULL);
00118                 int New();
00119                 int Close();
00120                 
00121                 bool isOpen();
00122         
00123                 aride_object * CreateObjectNode(ArideSection Section, const QString & Type, aride_object * parent=NULL);
00124                 int CreateEnvironmentNode();
00125                 aride_displaylist_node * CreateDisplayList(QDomNode &n);
00126                 aride_displaylist_node * CreateDisplayList();
00127                 aride_displaylist_node * CreateDisplayListNode(aride_displaylist_node * parent, QDomNode &n);
00128                 aride_displaylist_node * CreateDisplayListNode(const ArideSection Section, const QString & Type,const QString & Parent);
00129                 void RemoveDisplayListNode(QString Name);
00130                 void RemoveDisplayListNode(aride_displaylist_node * node);
00131                 int RemoveObject(aride_object * obj);
00132                 int RemoveEnvironment(aride_environment * env);
00133 
00134                 RenderPair * CreateRenderPair(aride_displaylist_node * node);
00135 
00136                 void Run();
00137                 void Pause();
00138                 void Stop(); 
00139 
00140                 QString GetGUIDByName(const QString & GUID);
00141                 aride_object * GetObjectByGUID(const QString & GUID);
00142                 aride_environment * GetEnvByGUID(const QString & GUID);
00143                 aride_displaylist_node * GetDisplayNodeByGUID(const QString & GUID);
00144                 aride_object * GetFirstChild(const aride_object * obj);
00145         
00146                 void RemoveObjects();
00147                 ARObject * InitialiseObject(ARObject *);
00148                 bool CheckName(const QString & Name); 
00149                 QString MakeUniqueName(const QString & Type); 
00150 
00151                 bool CheckGUID(const QString & GUID); 
00152                 QString MakeUniqueGUID(); 
00153 
00154                 void RefreshObjects();
00155         
00156                 list<aride_object *> Objects;
00157                 list<aride_environment *> Environments;
00158                 list<aride_displaylist_node *> DisplayNodes;
00159                 list<RenderPair *> RenderPairs;
00160         protected:
00161                 deque<ARObject *> ActiveObjects;
00162 
00163                 QDomDocument doc;
00164                 char * StoredFilename;
00165                 bool Changed;
00166                 bool Open;
00167 };
00168 
00169 extern aride_project * CurrentProject;
00170 
00171 #endif

SourceForge.net Logo Generated on Sat May 12 15:25:43 2007 for ardev by doxygen 1.5.1