The Gnome Chemistry Utils  0.14.16
gcp/bond.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * GChemPaint library
5  * bond.h
6  *
7  * Copyright (C) 2001-2012 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCHEMPAINT_BOND_H
26 #define GCHEMPAINT_BOND_H
27 
30 #include <gccv/item-client.h>
31 #include <gcu/bond.h>
32 #include <list>
33 
34 namespace gcu {
35 class UIManager;
36 }
37 
38 namespace gcp {
39 
49 typedef enum
50 {
51  NormalBondType,
52  UpBondType,
53  DownBondType,
54  ForeBondType,
55  UndeterminedBondType,
56  NewmanBondType
57 } BondType;
58 
67 typedef enum
68 {
69  DoubleBondAuto,
70  DoubleBondCenter,
71  DoubleBondLeft,
72  DoubleBondRight
74 
79 typedef struct {
83  double a;
87  bool is_before;
88 } BondCrossing;
89 
90 class Atom;
91 class WidgetData;
92 
97 class Bond: public gcu::Bond, public gccv::ItemClient
98 {
99 public:
103  Bond ();
111  Bond (Atom* first, Atom* last, unsigned char order);
115  virtual ~Bond ();
116 
125  Object* GetAtomAt (double x, double y, double z = 0.);
129  BondType GetType() const {return m_type;}
135  void SetType (BondType type);
142  double GetAngle2D (Atom* pAtom);
148  void AddCycle (gcu::Cycle* pCycle);
154  void RemoveCycle (gcu::Cycle* pCycle);
158  void RemoveAllCycles ();
170  bool GetLine2DCoords (unsigned Num, double* x1, double* y1, double* x2, double* y2);
178  virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
184  bool LoadNode (xmlNodePtr node);
193  void Move (double x, double y, double z = 0);
203  void Transform2D (gcu::Matrix2D& m, double x, double y);
213  double GetDist (double x, double y);
218  void SetDirty ();
222  void Revert ();
229  void IncOrder (int n = 1);
233  void AddItem ();
237  void UpdateItem ();
245  void SetSelected (int state);
250  double GetYAlign ();
258  bool IsCrossing (Bond *pBond);
267  bool BuildContextualMenu (gcu::UIManager *UIManager, Object *object, double x, double y);
271  void MoveToBack ();
275  void BringToFront ();
282  std::string GetProperty (unsigned property) const;
291  bool SetProperty (unsigned property, char const *value);
292 
301  void AdjustPosition (double &x, double &y);
302 
306  void OnLoaded ();
307 
308 private:
309 // GnomeCanvasPathDef* BuildPathDef (WidgetData* pData);
310 // GnomeCanvasPathDef* BuildCrossingPathDef (WidgetData* pData);
311  BondType m_type;
312  double m_coords[16];//coordinates of the lines used to represent the bond in the canvas
313  bool m_CoordsCalc; //true if m_coords have been calculated, false else
314  std::map<Bond*, BondCrossing> m_Crossing;
315  int m_level; // to know which bond should be considered front
316 
317 GCU_PROP (DoubleBondPosition, DoublePosition)
318 };
319 
320 } // namespace gcp
321 
322 #endif // GCHEMPAINT_BOND_H
the base class for objects associated with a canvas item.
Definition: item-client.h:44
GChemPaint specific C++ classes.
BondType
Definition: gcp/bond.h:49
DoubleBondPosition
Definition: gcp/bond.h:67
base class for a user interface manager
Definition: ui-manager.h:33
The Gnome Chemistry Utils C++ classes.
BondType GetType() const
Definition: gcp/bond.h:129
#define GCU_PROP(type, member)
Definition: macros.h:50