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