Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

object.h

00001 // -*- C++ -*- 00002 00003 /* 00004 * Gnome Chemistry Utils 00005 * chemistry/object.h 00006 * 00007 * Copyright (C) 2002-2003 00008 * 00009 * Developed by Jean Bréfort <jean.brefort@ac-dijon.fr> 00010 * 00011 * This library is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU Lesser General Public 00013 * License as published by the Free Software Foundation; either 00014 * version 2.1 of the License, or (at your option) any later version. 00015 * 00016 * This library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this library; if not, write to the 00023 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00024 * Boston, MA 02111-1307, USA. 00025 */ 00026 00027 #ifndef GCU_OBJECT_H 00028 #define GCU_OBJECT_H 00029 00030 #include <glib.h> 00031 #include <libxml/parser.h> 00032 #include <map> 00033 #include <string> 00034 #include <gtk/gtk.h> 00035 #include <libgnomeprint/gnome-print.h> 00036 00037 #define square(x) ((x)*(x)) 00038 00039 using namespace std; 00040 00041 namespace gcu 00042 { 00043 00067 enum TypeId 00068 { 00069 AtomType, 00070 FragmentType, 00071 BondType, 00072 MoleculeType, 00073 ChainType, 00074 CycleType, 00075 ReactantType, 00076 ReactionArrowType, 00077 ReactionOperatorType, 00078 ReactionType, 00079 MesomeryType, 00080 MesomeryArrowType, 00081 DocumentType, 00082 TextType, 00083 OtherType 00084 }; 00085 00089 class Object 00090 { 00091 public: 00095 Object(TypeId Id = OtherType); 00099 virtual ~Object(); 00100 00105 TypeId GetType() {return m_Type;} 00111 void SetId(gchar* Id); 00115 const gchar* GetId() {return m_Id;} 00122 void AddChild(Object* object); 00129 Object* GetMolecule(); 00136 Object* GetReaction(); 00143 Object* GetDocument(); 00153 Object* GetParentOfType(TypeId Id); 00160 Object* GetChild(const gchar* Id); 00167 Object* GetFirstChild(map<string, Object*>::iterator& i); 00174 Object* GetNextChild(map<string, Object*>::iterator& i); 00181 Object* GetDescendant(const gchar* Id); 00185 Object* GetParent() {return m_Parent;} 00192 void SetParent(Object* Parent); 00200 virtual xmlNodePtr Save(xmlDocPtr xml); 00217 virtual bool Load(xmlNodePtr node); 00226 virtual void Move(double x, double y, double z = 0.); 00235 bool SaveChildren(xmlDocPtr xml, xmlNodePtr node); 00241 void SaveId(xmlNodePtr node); 00252 xmlNodePtr GetNodeByProp(xmlNodePtr node, char* Property, char* Id); 00262 xmlNodePtr GetNextNodeByProp(xmlNodePtr node, char* Property, char* Id); 00272 xmlNodePtr GetNodeByName(xmlNodePtr node, char* Name); 00281 xmlNodePtr GetNextNodeByName(xmlNodePtr node, char* Name); 00289 void ShowContextualMenu(unsigned button, unsigned time); 00296 virtual void Add(GtkWidget* w); 00302 virtual void Print(GnomePrintContext *pc); 00309 virtual void Update(GtkWidget* w); 00317 virtual void SetSelected(GtkWidget* w, int state); 00321 bool HasChildren() {return m_Children.size() != 0;} 00331 static unsigned AddType(string TypeName, Object*(*CreateFunc)(), TypeId id = OtherType); 00342 static Object* CreateObject(string& TypeName, Object* parent = NULL); 00348 void EmptyTranslationTable(); 00357 virtual Object* GetAtomAt(double x, double y, double z = 0.); 00358 00359 protected: 00365 virtual void BuildContextualMenu(); 00366 00367 private: 00368 gchar* m_Id; 00369 TypeId m_Type; 00370 Object *m_Parent; 00371 map<string, Object*> m_Children; //string is Id of object, so each object must have an Id 00372 map <string, string> m_TranslationTable;//used when Ids translations are necessary (on pasting...) 00373 GtkMenu* m_Menu; 00374 }; 00375 00376 } 00377 #endif //GCU_OBJECT_H

Generated on Thu Oct 21 20:22:10 2004 for The Gnome Chemistry Utils by doxygen 1.3.8