The Gnome Chemistry Utils  0.13.7
gcp/bond.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /*
00004  * GChemPaint library
00005  * bond.h
00006  *
00007  * Copyright (C) 2001-2012 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 3 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 
00030 #include <gccv/item-client.h>
00031 #include <gcu/bond.h>
00032 #include <list>
00033 
00034 namespace gcu {
00035 class UIManager;
00036 }
00037 
00038 namespace gcp {
00039 
00049 typedef enum
00050 {
00051         NormalBondType,
00052         UpBondType,
00053         DownBondType,
00054         ForeBondType,
00055         UndeterminedBondType,
00056         NewmanBondType
00057 } BondType;
00058 
00063 typedef struct {
00067         double a;
00071         bool is_before;
00072 } BondCrossing;
00073 
00074 class Atom;
00075 class WidgetData;
00076 
00081 class Bond: public gcu::Bond, public gccv::ItemClient
00082 {
00083 public:
00087         Bond ();
00095         Bond (Atom* first, Atom* last, unsigned char order);
00099         virtual ~Bond ();
00100 
00109         Object* GetAtomAt (double x, double y, double z = 0.);
00113         BondType GetType() const {return m_type;}
00119         void SetType (BondType type);
00126         double GetAngle2D (Atom* pAtom);
00132         void AddCycle (gcu::Cycle* pCycle);
00138         void RemoveCycle (gcu::Cycle* pCycle);
00142         void RemoveAllCycles ();
00154         bool GetLine2DCoords (unsigned Num, double* x1, double* y1, double* x2, double* y2);
00162         virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
00168         bool LoadNode (xmlNodePtr node);
00177         void Move (double x, double y, double z = 0);
00187         void Transform2D (gcu::Matrix2D& m, double x, double y);
00197         double GetDist (double x, double y);
00202         void SetDirty ();
00206         void Revert ();
00213         void IncOrder (int n = 1);
00217         void AddItem ();
00221         void UpdateItem ();
00229         void SetSelected (int state);
00234         double GetYAlign ();
00242         bool IsCrossing (Bond *pBond);
00251         bool BuildContextualMenu (gcu::UIManager *UIManager, Object *object, double x, double y);
00255         void MoveToBack ();
00259         void BringToFront ();
00266         std::string GetProperty (unsigned property) const;
00275         bool SetProperty (unsigned property, char const *value);
00276 
00285         void AdjustPosition (double &x, double &y);
00286 
00290         void OnLoaded ();
00291 
00292 private:
00293 //      GnomeCanvasPathDef* BuildPathDef (WidgetData* pData);
00294 //      GnomeCanvasPathDef* BuildCrossingPathDef (WidgetData* pData);
00295         BondType m_type;
00296         double m_coords[16];//coordinates of the lines used to represent the bond in the canvas
00297         bool m_CoordsCalc; //true if m_coords have been calculated, false else
00298         std::map<Bond*, BondCrossing> m_Crossing;
00299         int m_level; // to know which bond should be considered front
00300 };
00301 
00302 }       //      namespace gcp
00303 
00304 #endif // GCHEMPAINT_BOND_H