gcp/bond.h
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() const {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) const;
00067 virtual bool LoadNode (xmlNodePtr);
00068 virtual void Update (GtkWidget* w) const;
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) const;
00077 virtual double GetYAlign ();
00078 bool IsCrossing (Bond *pBond);
00079 bool BuildContextualMenu (GtkUIManager *UIManager, Object *object, double x, double y);
00080 void MoveToBack ();
00081 void BringToFront ();
00082 bool SetProperty (unsigned property, char const *value);
00083
00084 private:
00085 GnomeCanvasPathDef* BuildPathDef (WidgetData* pData);
00086 GnomeCanvasPathDef* BuildCrossingPathDef (WidgetData* pData);
00087
00088 protected:
00089 BondType m_type;
00090 double m_coords[16];
00091 bool m_CoordsCalc;
00092 std::map<Bond*, BondCrossing> m_Crossing;
00093 int m_level;
00094 };
00095
00096 }
00097
00098 #endif // GCHEMPAINT_BOND_H