crystaldoc.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * Gnome Chemisty Utils
00005  * crystaldoc.h 
00006  *
00007  * Copyright (C) 2002-2006 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 CRYSTAL_DOC_H
00026 #define CRYSTAL_DOC_H
00027 
00028 #include <libxml/tree.h>
00029 #include <glib.h>
00030 #include "chemistry.h"
00031 #include "crystalatom.h"
00032 #include "crystalbond.h"
00033 #include "crystalline.h"
00034 #include "crystalcleavage.h"
00035 #include "document.h"
00036 #include <gcu/gldocument.h>
00037 #ifdef HAVE_OPENBABEL_2_2
00038 #       include <openbabel/math/spacegroup.h>
00039 #       include <openbabel/mol.h>
00040 #endif
00041 
00042 namespace gcu
00043 {
00044 
00045 class CrystalView;
00046 class Matrix;
00047 
00067 enum gcLattices {cubic=0,
00068                                  body_centered_cubic,
00069                                  face_centered_cubic,
00070                                  hexagonal,
00071                                  tetragonal,
00072                                  body_centered_tetragonal,
00073                                  orthorhombic,
00074                                  base_centered_orthorhombic,
00075                                  body_centered_orthorhombic,
00076                                  face_centered_orthorhombic,
00077                                  rhombohedral,
00078                                  monoclinic,
00079                                  base_centered_monoclinic,
00080                                  triclinic
00081 };
00082 
00086 class CrystalDoc: public GLDocument
00087 {
00088 public:
00092         CrystalDoc (Application *App);
00096         virtual ~CrystalDoc ();
00097 
00108         void ParseXMLTree (xmlNode* xml);
00113         void Update ();
00117         CrystalView* GetView ();
00118 
00124         void Draw (Matrix &m);
00125 
00132         virtual CrystalView* CreateNewView ();
00139         virtual CrystalAtom* CreateNewAtom ();
00146         virtual CrystalLine* CreateNewLine ();
00152         virtual CrystalCleavage* CreateNewCleavage ();
00157         xmlDocPtr BuildXMLTree ();
00163         virtual const char* GetProgramId ();
00164 
00165 #ifdef HAVE_OPENBABEL_2_2
00166         bool ImportOB (OpenBabel::OBMol &mol);
00167 #endif
00168         
00169 protected:
00173         void Init ();
00177         void Reinit ();
00183         virtual bool LoadNewView (xmlNodePtr node);
00184 
00185 private:
00186         void Duplicate (CrystalAtom& Atom);
00187         void Duplicate (CrystalLine& Line);
00188 
00189 protected:
00193         gcLattices m_lattice;
00197         gdouble m_a;
00201         gdouble m_b;
00205         gdouble m_c;
00209         gdouble m_alpha;
00213         gdouble m_beta;
00217         gdouble m_gamma;
00221         gdouble m_xmin;
00225         gdouble m_ymin;
00229         gdouble m_zmin;
00233         gdouble m_xmax;
00237         gdouble m_ymax;
00241         gdouble m_zmax;
00245         gboolean m_bFixedSize;  //true if cleavages must not change positions in the view
00249         CrystalAtomList AtomDef;
00253         CrystalAtomList Atoms;
00257         CrystalLineList LineDef;
00261         CrystalLineList Lines;
00265         CrystalCleavageList Cleavages;
00269         std::list <CrystalView *> m_Views;
00270 
00271 #ifdef HAVE_OPENBABEL_2_2
00272 
00275         OpenBabel::SpaceGroup const *m_SpaceGroup;
00276 #endif
00277 };
00278 
00279 extern gchar const *LatticeName[];
00280 
00281 } //namespace gcu
00282 
00283 #endif //CRYSTAL_DOC_H

Generated on Tue Mar 18 16:06:03 2008 for The Gnome Chemistry Utils by  doxygen 1.5.5