The Gnome Chemistry Utils 0.13.3
gcr/document.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * Gnome Chemisty Utils
00005  * gcr/document.h 
00006  *
00007  * Copyright (C) 2002-2010 Jean Bréfort <jean.brefort@normalesup.org>
00008  *
00009  * This program is free software; you can redistribute it and/or 
00010  * modify it under the terms of the GNU General Public License as 
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
00023  */
00024 
00025 #ifndef GCR_DOCUMENT_H
00026 #define GCR_DOCUMENT_H
00027 
00028 #include <libxml/tree.h>
00029 #include <glib.h>
00030 #include "atom.h"
00031 #include "bond.h"
00032 #include "line.h"
00033 #include "cleavage.h"
00034 #include <gcu/chemistry.h>
00035 #include <gcu/macros.h>
00036 #include <gcu/gldocument.h>
00037 
00038 namespace gcu {
00039 class Application;
00040 class Matrix;
00041 class SpaceGroup;
00042 }
00043 
00045 namespace gcr {
00046 
00047 class View;
00048 
00068 enum Lattice {
00069         cubic=0,
00070         body_centered_cubic,
00071         face_centered_cubic,
00072         hexagonal,
00073         tetragonal,
00074         body_centered_tetragonal,
00075         orthorhombic,
00076         base_centered_orthorhombic,
00077         body_centered_orthorhombic,
00078         face_centered_orthorhombic,
00079         rhombohedral,
00080         monoclinic,
00081         base_centered_monoclinic,
00082         triclinic
00083 };
00084 
00088 class Document: public gcu::GLDocument
00089 {
00090 public:
00094         Document (gcu::Application *App);
00098         virtual ~Document ();
00099 
00110         void ParseXMLTree (xmlNode* xml);
00115         void Update ();
00119         View* GetView ();
00120 
00126         void Draw (gcu::Matrix const &m) const;
00127 
00134         virtual View* CreateNewView ();
00141         virtual Atom* CreateNewAtom ();
00148         virtual Line* CreateNewLine ();
00154         virtual Cleavage* CreateNewCleavage ();
00159         xmlDocPtr BuildXMLTree () const;
00165         virtual const char* GetProgramId () const;
00166 
00174         bool SetProperty (unsigned property, char const *value);
00175 
00182         std::string GetProperty (unsigned property) const;
00183 
00188         bool Loaded () throw (gcu::LoaderError);
00192         void AddChild (Object* object);
00197         gcu::SpaceGroup const *FindSpaceGroup ();
00201         void Reinit ();
00202         AtomList* GetAtomList () {return &AtomDef;}
00203         CleavageList *GetCleavageList () {return &Cleavages;}
00204         LineList* GetLineList () {return &LineDef;}
00205         void GetCell (Lattice *lattice, double *a, double *b, double *c, double *alpha, double *beta, double *gamma);
00206         void SetCell (Lattice lattice, double a, double b, double c, double alpha, double beta, double gamma);
00207         void GetSize (double* xmin, double* xmax, double* ymin, double* ymax, double* zmin, double* zmax);
00208         void SetSize (double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
00209 
00210 protected:
00214         void Init ();
00220         virtual bool LoadNewView (xmlNodePtr node);
00221 
00222 private:
00223         void Duplicate (Atom& Atom);
00224         void Duplicate (Line& Line);
00225 
00226 protected:
00230         Lattice m_lattice;
00234         gdouble m_a;
00238         gdouble m_b;
00242         gdouble m_c;
00246         gdouble m_alpha;
00250         gdouble m_beta;
00254         gdouble m_gamma;
00258         gdouble m_xmin;
00262         gdouble m_ymin;
00266         gdouble m_zmin;
00270         gdouble m_xmax;
00274         gdouble m_ymax;
00278         gdouble m_zmax;
00282         AtomList AtomDef;
00286         AtomList Atoms;
00290         LineList LineDef;
00294         LineList Lines;
00298         CleavageList Cleavages;
00302         std::list <View *> m_Views;
00303         
00307 GCU_RO_PROP (std::string, NameCommon)
00311 GCU_RO_PROP (std::string, NameSystematic)
00315 GCU_RO_PROP (std::string, NameMineral)
00319 GCU_RO_PROP (std::string, NameStructure)
00330 GCU_PROP (gcu::SpaceGroup const *, SpaceGroup)
00343 GCU_PROP (bool, AutoSpaceGroup)
00344 
00348 GCU_PROP (bool, FixedSize);
00349 };
00350 
00354 extern gchar const *LatticeName[];
00355 
00356 } // namespace gcr
00357 
00358 #endif // GCR_DOCUMENT_H