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_BOND_H
00026 #define GCHEMPAINT_BOND_H
00027
00028 #include <gcu/bond.h>
00029 #include <list>
00030 #include <libgnomecanvas/gnome-canvas-path-def.h>
00031
00032 using namespace gcu;
00033
00034 namespace gcp {
00035
00036 typedef enum
00037 {
00038 NormalBondType,
00039 UpBondType,
00040 DownBondType,
00041 ForeBondType,
00042 UndeterminedBondType
00043 } BondType;
00044
00045 typedef struct {
00046 double a;
00047 bool is_before;
00048 } BondCrossing;
00049
00050 class Atom;
00051 class Cycle;
00052 class WidgetData;
00053
00054 class Bond: public gcu::Bond
00055 {
00056 public:
00057 Bond ();
00058 Bond (Atom* first, Atom* last, unsigned char order);
00059 virtual ~Bond ();
00060
00061 virtual Object* GetAtomAt (double x, double y, double z = 0.);
00062 BondType GetType() {return m_type;}
00063 void SetType (BondType type);
00064 double GetAngle2D (Atom* pAtom);
00065 double GetAngle2DRad (Atom* pAtom);
00066 void AddCycle (Cycle* pCycle);
00067 void RemoveCycle (Cycle* pCycle);
00068 void RemoveAllCycles ();
00069 unsigned IsCyclic () {return m_Cycles.size ();}
00070 Cycle* GetFirstCycle (std::list<Cycle*>::iterator& i, Cycle * pCycle);
00071 Cycle* GetNextCycle (std::list<Cycle*>::iterator& i, Cycle * pCycle);
00072 bool IsInCycle (Cycle* pCycle);
00073 bool GetLine2DCoords (unsigned Num, double* x1, double* y1, double* x2, double* y2);
00074 virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr);
00075 virtual bool LoadNode (xmlNodePtr);
00076 virtual void Update (GtkWidget* w);
00077 virtual void Move (double x, double y, double z = 0);
00078 virtual void Transform2D (Matrix2D& m, double x, double y);
00079 double GetDist (double x, double y);
00080 void SetDirty ();
00081 void Revert ();
00082 double Get2DLength ();
00083 void IncOrder (int n = 1);
00084 virtual void SetSelected (GtkWidget* w, int state);
00085 void Add (GtkWidget* w);
00086 bool ReplaceAtom (Atom* oldAtom, Atom* newAtom);
00087 virtual double GetYAlign ();
00088 bool IsCrossing (Bond *pBond);
00089 bool BuildContextualMenu (GtkUIManager *UIManager, Object *object, double x, double y);
00090 void MoveToBack ();
00091 void BringToFront ();
00092
00093 private:
00094 GnomeCanvasPathDef* BuildPathDef (WidgetData* pData);
00095 GnomeCanvasPathDef* BuildCrossingPathDef (WidgetData* pData);
00096
00097 protected:
00098 BondType m_type;
00099 double m_coords[16];
00100 bool m_CoordsCalc;
00101 list<Cycle*> m_Cycles;
00102 map<Bond*, BondCrossing> m_Crossing;
00103 int m_level;
00104 };
00105
00106 }
00107
00108 #endif // GCHEMPAINT_BOND_H