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 WidgetData;
00050
00051 class Bond: public gcu::Bond
00052 {
00053 public:
00054 Bond ();
00055 Bond (Atom* first, Atom* last, unsigned char order);
00056 virtual ~Bond ();
00057
00058 virtual Object* GetAtomAt (double x, double y, double z = 0.);
00059 BondType GetType() {return m_type;}
00060 void SetType (BondType type);
00061 double GetAngle2D (Atom* pAtom);
00062 void AddCycle (gcu::Cycle* pCycle);
00063 void RemoveCycle (gcu::Cycle* pCycle);
00064 void RemoveAllCycles ();
00065 bool GetLine2DCoords (unsigned Num, double* x1, double* y1, double* x2, double* y2);
00066 virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr);
00067 virtual bool LoadNode (xmlNodePtr);
00068 virtual void Update (GtkWidget* w);
00069 virtual void Move (double x, double y, double z = 0);
00070 virtual void Transform2D (gcu::Matrix2D& m, double x, double y);
00071 double GetDist (double x, double y);
00072 void SetDirty ();
00073 void Revert ();
00074 void IncOrder (int n = 1);
00075 virtual void SetSelected (GtkWidget* w, int state);
00076 void Add (GtkWidget* w);
00077 bool ReplaceAtom (Atom* oldAtom, Atom* newAtom);
00078 virtual double GetYAlign ();
00079 bool IsCrossing (Bond *pBond);
00080 bool BuildContextualMenu (GtkUIManager *UIManager, Object *object, double x, double y);
00081 void MoveToBack ();
00082 void BringToFront ();
00083 bool SetProperty (unsigned property, char const *value);
00084
00085 private:
00086 GnomeCanvasPathDef* BuildPathDef (WidgetData* pData);
00087 GnomeCanvasPathDef* BuildCrossingPathDef (WidgetData* pData);
00088
00089 protected:
00090 BondType m_type;
00091 double m_coords[16];
00092 bool m_CoordsCalc;
00093 std::map<Bond*, BondCrossing> m_Crossing;
00094 int m_level;
00095 };
00096
00097 }
00098
00099 #endif // GCHEMPAINT_BOND_H