gcp/bond.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * bond.h 
00006  *
00007  * Copyright (C) 2001-2008 Jean Bréfort <jean.brefort@normalesup.org>
00008  *
00009  * This program is free software; you can redistribute it and/or 
00010  * modify it under the terms of the GNU General Public License as 
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
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];//coordinates of the lines used to represent the bond in the canvas
00091         bool m_CoordsCalc; //true if m_coords have been calculated, false else
00092         std::map<Bond*, BondCrossing> m_Crossing;
00093         int m_level; // to know which bond should be considered front
00094 };
00095 
00096 }       //      namespace gcp
00097 
00098 #endif // GCHEMPAINT_BOND_H

Generated on Sun Jun 22 13:26:05 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6