gcp/document.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef GCHEMPAINT_DOCUMENT_H
00026 #define GCHEMPAINT_DOCUMENT_H
00027
00028 #include "operation.h"
00029 #include <gcu/document.h>
00030 #include <gcu/macros.h>
00031 #include <gcu/printable.h>
00032 #include <gcu/residue.h>
00033 #include <list>
00034 #include <map>
00035 #include <set>
00036 #include <string>
00037 #include <libxml/tree.h>
00038 #include <gtk/gtk.h>
00039
00041 namespace OpenBabel
00042 {
00043 class OBMol;
00044 }
00045
00046 namespace gcp {
00047
00052 extern gcu::SignalId OnChangedSignal;
00057 extern gcu::SignalId OnDeleteSignal;
00062 extern gcu::SignalId OnThemeChangedSignal;
00063
00064 class View;
00065 class Application;
00066 class Window;
00067 class Theme;
00068 class Residue;
00069 class Atom;
00070 class Bond;
00071 class Fragment;
00072 class Molecule;
00073
00077 class Document: public gcu::Document, public gcu::Printable
00078 {
00079
00080 public:
00089 Document (Application *App, bool StandAlone, Window *window = NULL);
00093 virtual ~Document ();
00094
00095
00096 public:
00100 void Clear ();
00104 GtkWidget* GetWidget ();
00108 View* GetView () {return m_pView;}
00114 bool ImportOB (OpenBabel::OBMol& Mol);
00118 void ExportOB () const;
00122 void Save () const;
00129 virtual bool Load (xmlNodePtr node);
00133 const gchar* GetTitle () const;
00139 void SetTitle (const gchar* title);
00145 void SetLabel (const gchar* label);
00149 const gchar* GetLabel () const;
00156 void SetFileName (std::string const &filename, const gchar *mime_type);
00160 const gchar* GetFileName () {return m_filename;}
00168 void DoPrint (GtkPrintOperation *print, GtkPrintContext *context, int page) const;
00174 void AddObject (Object* pObject);
00180 void AddAtom (Atom* pAtom);
00186 void AddFragment (Fragment* pFragment);
00193 void AddBond (Bond* pBond);
00199 void ParseXMLTree (xmlDocPtr xml);
00204 void LoadObjects (xmlNodePtr node);
00210 xmlDocPtr BuildXMLTree () const;
00214 void Update ();
00220 void Remove (Object* object);
00226 void Remove (const char* Id);
00230 void OnProperties ();
00234 void OnUndo ();
00238 void OnRedo ();
00242 const GDate* GetCreationDate () {return &CreationDate;}
00246 const GDate* GetRevisionDate () {return &RevisionDate;}
00250 const gchar* GetAuthor () {return m_author;}
00254 const gchar* GetMail () {return m_mail;}
00258 const gchar* GetComment () {return m_comment;}
00264 void SetAuthor (const gchar* author);
00270 void SetMail (const gchar* mail);
00276 void SetComment (const gchar* comment);
00282 void FinishOperation ();
00286 void AbortOperation ();
00290 void PopOperation ();
00297 void PushOperation (Operation* operation, bool undo = true);
00302 void SetActive ();
00308 Operation* GetNewOperation (OperationType type);
00312 Operation* GetCurrentOperation () {return m_pCurOp;}
00318 void AddData (xmlNodePtr node);
00322 bool CanUndo () {return m_UndoList.size() > 0;}
00328 void SetEditable (bool editable) {m_bWriteable = editable; m_bUndoRedo = true;}
00332 bool GetEditable () {return m_bWriteable;}
00336 gcp::Application* GetApplication () {return m_pApp;}
00346 void ExportImage (std::string const &filename, const char* type, int resolution = -1);
00352 void SetReadOnly (bool ro);
00356 bool GetReadOnly () {return m_bReadOnly;}
00363 virtual double GetYAlign ();
00367 Window *GetWindow () {return m_Window;}
00371 GtkWindow *GetGtkWindow ();
00378 void SetTheme (Theme *theme);
00387 bool OnSignal (gcu::SignalId Signal, gcu::Object *Child);
00393 void SetDirty (bool isDirty = true);
00398 void OnThemeNamesChanged ();
00404 double GetMedianBondLength ();
00414 bool SetProperty (unsigned property, char const *value);
00420 void SetLoading (bool loading) {m_bIsLoading = loading;}
00428 void SaveResidue (Residue const *r, xmlNodePtr node);
00438 gcu::Residue const *GetResidue (char const *symbol, bool *ambiguous = NULL);
00448 gcu::Residue *CreateResidue (char const *name, char const *symbol, gcu::Molecule *molecule);
00449
00450 private:
00451 void BuildBondList (std::list<Bond*>& BondList, gcu::Object const *obj) const;
00452 void BuildAtomTable (std::map<std::string, unsigned>& AtomTable, gcu::Object const *obj, unsigned& index) const;
00453 void RemoveAtom (Atom* pAtom);
00454 void RemoveBond (Bond* pBond);
00455 void RemoveFragment (Fragment* pFragment);
00456
00457
00458 private:
00459 View * m_pView;
00460 gchar* m_filename;
00461 gchar *m_title;
00462 gchar *m_label;
00463 gchar *m_comment, *m_author, *m_mail;
00464 bool m_bIsLoading, m_bUndoRedo, m_bReadOnly;
00465 std::string m_FileType;
00466 bool m_bWriteable;
00467 GDate CreationDate, RevisionDate;
00468 std::list<Operation*> m_UndoList, m_RedoList;
00469 Operation* m_pCurOp;
00470 Application* m_pApp;
00471 Window *m_Window;
00472 unsigned long m_OpID;
00473 unsigned m_LastStackSize;
00474 std::set<Residue const *> m_SavedResidues;
00475 std::map<std::string, gcu::SymbolResidue> m_Residues;
00476
00477
00478
00482 GCU_RO_PROP (Theme*, Theme)
00494 GCU_PROP (double, BondLength)
00509 GCU_PROP (double, BondAngle)
00521 GCU_PROP (double, ArrowLength)
00533 GCU_PROP (gchar*, TextFontFamily)
00545 GCU_PROP (PangoStyle, TextFontStyle)
00557 GCU_PROP (PangoWeight, TextFontWeight)
00569 GCU_PROP (PangoVariant, TextFontVariant)
00581 GCU_PROP (PangoStretch, TextFontStretch)
00593 GCU_PROP (gint, TextFontSize)
00597 GCU_RO_PROP (PangoAttrList*, PangoAttrList)
00609 GCU_PROP (bool, AllowClipboard)
00610 };
00611
00612 }
00613
00614 #endif // GCHEMPAINT_DOCUMENT_H