The Gnome Chemistry Utils  0.14.0
gcr/document.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemisty Utils
5  * gcr/document.h
6  *
7  * Copyright (C) 2002-2012 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCR_DOCUMENT_H
26 #define GCR_DOCUMENT_H
27 
28 #include <libxml/tree.h>
29 #include <glib.h>
30 #include "atom.h"
31 #include "bond.h"
32 #include "line.h"
33 #include "cleavage.h"
34 #include <gcu/chemistry.h>
35 #include <gcu/macros.h>
36 #include <gcu/gldocument.h>
37 
38 namespace gcu {
39 class Application;
40 class Matrix;
41 class SpaceGroup;
42 }
43 
45 namespace gcr {
46 
47 class View;
48 
68 enum Lattice {
69  cubic=0,
70  body_centered_cubic,
71  face_centered_cubic,
72  hexagonal,
73  tetragonal,
74  body_centered_tetragonal,
75  orthorhombic,
76  base_centered_orthorhombic,
77  body_centered_orthorhombic,
78  face_centered_orthorhombic,
79  rhombohedral,
80  monoclinic,
81  base_centered_monoclinic,
82  triclinic
83 };
84 
89 {
90 public:
98  virtual ~Document ();
99 
100  bool Load (const std::string &filename);
101 
112  void ParseXMLTree (xmlNode* xml);
117  void Update ();
118 
119  void UpdateAllViews ();
120 
124  View* GetView ();
125 
131  void Draw (gcu::Matrix const &m) const;
132 
139  virtual View* CreateNewView ();
146  virtual Atom* CreateNewAtom ();
153  virtual Line* CreateNewLine ();
159  virtual Cleavage* CreateNewCleavage ();
164  xmlDocPtr BuildXMLTree () const;
170  virtual const char* GetProgramId () const;
171 
179  bool SetProperty (unsigned property, char const *value);
180 
187  std::string GetProperty (unsigned property) const;
188 
193  bool Loaded () throw (gcu::LoaderError);
197  void AddChild (Object* object);
206  void Reinit ();
207 
211  AtomList* GetAtomList () {return &AtomDef;}
212 
217 
221  LineList* GetLineList () {return &LineDef;}
222 
234  void GetCell (Lattice *lattice, double *a, double *b, double *c, double *alpha, double *beta, double *gamma);
235 
247  void SetCell (Lattice lattice, double a, double b, double c, double alpha, double beta, double gamma);
248 
259  void GetSize (double* xmin, double* xmax, double* ymin, double* ymax, double* zmin, double* zmax);
260 
271  void SetSize (double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
272 
276  void CheckAtoms ();
277 
281  void CheckCleavages ();
282 
286  void CheckLines ();
287 
298  void Define (unsigned nPage = 0);
299 
305  void AddView(View* pView);
306 
313  bool RemoveView(View* pView);
314 
319  void RemoveAllViews ();
320 
324  View *GetActiveView () {return m_pActiveView;}
325 
329  std::list <gcr::View *> *GetViews () {return &m_Views;}
330 
334  void RenameViews ();
335 
342  bool VerifySaved();
343 
349  void SetWidget (GtkWidget* widget) {m_widget = widget;}
350 
354  const gchar* GetFileName () {return m_filename;}
355 
361  void SetActiveView (View *pView) {m_pActiveView = pView;}
362 
370  void SaveAsImage (const std::string &filename, char const *type, std::map<std::string, std::string>& options);
371 
377  void SetFileName (const std::string &filename);
378 
384  void SetTitle (char const *title);
385  void SetTitle (std::string& title);
386 
390  char const *GetTitle () {return m_Title.c_str ();}
391 
397  void SetAuthor (char const *author);
398 
404  void SetMail (char const *mail);
405 
412  void SetComment (char const *comment);
413 
419  void SetLabel (char const *label);
420 
424  GDate *GetCreationDate () {return &m_CreationDate;}
425 
429  GDate *GetRevisionDate () {return &m_RevisionDate;}
430 
434  char const *GetLabel () {return m_Label? m_Label: m_DefaultLabel.c_str ();}
435 
441  void OnExportVRML (const std::string &FileName) const;
442 
446  void Save () const;
447 
448 protected:
452  void Init ();
458  virtual bool LoadNewView (xmlNodePtr node);
459 
460 private:
461  void Duplicate (Atom& Atom);
462  void Duplicate (Line& Line);
463  void Error(int num) const;
464 
465 protected:
473  gdouble m_a;
477  gdouble m_b;
481  gdouble m_c;
485  gdouble m_alpha;
489  gdouble m_beta;
493  gdouble m_gamma;
497  gdouble m_xmin;
501  gdouble m_ymin;
505  gdouble m_zmin;
509  gdouble m_xmax;
513  gdouble m_ymax;
517  gdouble m_zmax;
541  std::list <View *> m_Views;
542 
547 
552 
553 private:
554  gchar *m_filename;
555  bool m_bClosing;
556  GtkWidget* m_widget;
557  View *m_pActiveView;
558  std::string m_DefaultLabel;
559  char *m_Label;
560 
564 GCU_RO_PROP (std::string, NameCommon)
568 GCU_RO_PROP (std::string, NameSystematic)
572 GCU_RO_PROP (std::string, NameMineral)
576 GCU_RO_PROP (std::string, NameStructure)
587 GCU_PROP (gcu::SpaceGroup const *, SpaceGroup)
600 GCU_PROP (bool, AutoSpaceGroup)
601 
614 GCU_PROP (bool, FixedSize);
615 
627 GCU_PROP (bool, ReadOnly)
628 
635 GCU_PROT_POINTER_PROP (char, Author)
636 
644 
651 GCU_PROT_POINTER_PROP (char, Comment)
652 };
653 
657 extern gchar const *LatticeName[];
658 
659 } // namespace gcr
660 
661 #endif // GCR_DOCUMENT_H