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 void BuildBondList (std::list<Bond*>& BondList, gcu::Object const *obj) const;
00115 bool ImportOB (OpenBabel::OBMol& Mol);
00119 void ExportOB () const;
00124 void BuildAtomTable (std::map<std::string, unsigned>& AtomTable, gcu::Object const *obj, unsigned& index) const;
00125 void Save () const;
00126 virtual bool Load (xmlNodePtr);
00127 const gchar* GetTitle () const;
00128 void SetTitle (const gchar* title);
00129 void SetLabel (const gchar* label);
00130 const gchar* GetLabel () const;
00131 void SetFileName (std::string const &, const gchar *mime_type);
00132 const gchar* GetFileName () {return m_filename;}
00133 void DoPrint (GtkPrintOperation *print, GtkPrintContext *context) const;
00134 void AddObject (Object* pObject);
00135 void AddAtom (Atom* pAtom);
00136 void AddFragment (Fragment* pFragment);
00137 void AddBond (Bond* pBond);
00138 void ParseXMLTree (xmlDocPtr xml);
00139 void LoadObjects (xmlNodePtr node);
00140 xmlDocPtr BuildXMLTree () const;
00141 void Update ();
00142 void Remove (Object*);
00143 void Remove (const char* Id);
00144 void OnProperties ();
00145 void OnUndo ();
00146 void OnRedo ();
00147 const GDate* GetCreationDate () {return &CreationDate;}
00148 const GDate* GetRevisionDate () {return &RevisionDate;}
00149 const gchar* GetAuthor () {return m_author;}
00150 const gchar* GetMail () {return m_mail;}
00151 const gchar* GetComment () {return m_comment;}
00152 void SetAuthor (const gchar* author);
00153 void SetMail (const gchar* mail);
00154 void SetComment (const gchar* comment);
00155 void FinishOperation ();
00156 void AbortOperation ();
00157 void PopOperation ();
00158 void PushOperation (Operation* operation, bool undo = true);
00159 void SetActive ();
00160 Operation* GetNewOperation (OperationType type);
00161 Operation* GetCurrentOperation () {return m_pCurOp;}
00162 void AddData (xmlNodePtr node);
00163 bool CanUndo () {return m_UndoList.size() > 0;}
00164 void SetEditable (bool editable) {m_bWriteable = editable; m_bUndoRedo = true;}
00165 bool GetEditable () {return m_bWriteable;}
00166 gcp::Application* GetApplication () {return m_pApp;}
00167 void ExportImage (std::string const &filename, const char* type, int resolution = -1);
00168 void SetReadOnly (bool ro);
00169 bool GetReadOnly () {return m_bReadOnly;}
00170 virtual double GetYAlign ();
00171 Window *GetWindow () {return m_Window;}
00172 GtkWindow *GetGtkWindow ();
00173 void SetTheme (Theme *theme);
00174 bool OnSignal (gcu::SignalId Signal, gcu::Object *Child);
00175 void SetDirty (bool isDirty = true);
00176 void OnThemeNamesChanged ();
00177 double GetMedianBondLength ();
00178 bool SetProperty (unsigned property, char const *value);
00179 void SetLoading (bool loading) {m_bIsLoading = loading;}
00180 void SaveResidue (Residue const *r, xmlNodePtr node);
00190 gcu::Residue const *GetResidue (char const *symbol, bool *ambiguous = NULL);
00200 gcu::Residue *CreateResidue (char const *name, char const *symbol, gcu::Molecule *molecule);
00201
00202 private:
00203 void RemoveAtom (Atom* pAtom);
00204 void RemoveBond (Bond* pBond);
00205 void RemoveFragment (Fragment* pFragment);
00206
00207
00208 private:
00209 View * m_pView;
00210 gchar* m_filename;
00211 gchar *m_title;
00212 gchar *m_label;
00213 gchar *m_comment, *m_author, *m_mail;
00214 bool m_bIsLoading, m_bUndoRedo, m_bReadOnly;
00215 std::string m_FileType;
00216 bool m_bWriteable;
00217 GDate CreationDate, RevisionDate;
00218 std::list<Operation*> m_UndoList, m_RedoList;
00219 Operation* m_pCurOp;
00220 Application* m_pApp;
00221 Window *m_Window;
00222 unsigned long m_OpID;
00223 unsigned m_LastStackSize;
00224 std::set<Residue const *> m_SavedResidues;
00225 std::map<std::string, gcu::SymbolResidue> m_Residues;
00226
00227
00228
00232 GCU_RO_PROP (Theme*, Theme)
00244 GCU_PROP (double, BondLength)
00259 GCU_PROP (double, BondAngle)
00271 GCU_PROP (double, ArrowLength)
00283 GCU_PROP (gchar*, TextFontFamily)
00295 GCU_PROP (PangoStyle, TextFontStyle)
00307 GCU_PROP (PangoWeight, TextFontWeight)
00319 GCU_PROP (PangoVariant, TextFontVariant)
00331 GCU_PROP (PangoStretch, TextFontStretch)
00343 GCU_PROP (gint, TextFontSize)
00347 GCU_RO_PROP (PangoAttrList*, PangoAttrList)
00359 GCU_PROP (bool, AllowClipboard)
00360 };
00361
00362 extern std::list<Document*> Docs;
00363 extern bool bCloseAll;
00364
00365 }
00366
00367 #endif // GCHEMPAINT_DOCUMENT_H