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
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;
00372 map <string, string> m_TranslationTable;
00373 GtkMenu* m_Menu;
00374 };
00375
00376 }
00377
#endif //GCU_OBJECT_H