The Gnome Chemistry Utils  0.14.0
gcp/molecule.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * GChemPaint library
5  * molecule.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_MOLECULE_H
26 #define GCHEMPAINT_MOLECULE_H
27 
28 #include "fragment.h"
29 #include <list>
30 #include <gcugtk/molecule.h>
31 
34 namespace gcu {
35 class UIManager;
36 }
37 
38 namespace gcp {
39 
40 class Bond;
41 
46 {
47 friend class MoleculePrivate;
48 public:
52  Molecule (gcu::TypeId Type = gcu::MoleculeType);
59  Molecule (Atom* pAtom);
63  virtual ~Molecule ();
69  void AddChild (gcu::Object* object);
75  void AddAtom (gcu::Atom* pAtom);
81  void AddFragment (Fragment* pFragment);
87  void AddBond (gcu::Bond* pBond);
93  void Remove (gcu::Object* pObject);
104  bool Merge (Molecule* pMolecule, bool RemoveDuplicates = false);
111  bool Load (xmlNodePtr node);
118  xmlNodePtr Save (xmlDocPtr xml) const;
122  void Clear ();
131  void Transform2D (gcu::Matrix2D& m, double x, double y);
140  Object* GetAtomAt (double x, double y, double z = 0.);
145  double GetYAlign ();
155  bool BuildContextualMenu (gcu::UIManager *UIManager, gcu::Object *object, double x, double y);
164  bool OnSignal (gcu::SignalId Signal, gcu::Object *Child);
172  void SelectAlignmentItem (gcu::Object *child);
176  std::string GetAlignmentId () {return (m_Alignment)? m_Alignment->GetId (): "";}
181  void OpenCalc ();
188  void CheckCrossings (Bond *pBond);
193  std::string GetRawFormula () const;
197  void OnLoaded ();
202  unsigned GetAtomsNumber () const;
203 
207  double GetMeanBondLength () const;
208 
214  void AddChiralAtom (Atom *atom) {m_ChiralAtoms.insert (atom);}
215 
220  bool AtomIsChiral (Atom *atom) const;
221 
222 private:
223  std::list< Fragment * > m_Fragments;
224  std::set < Atom * > m_ChiralAtoms;
225  gcu::Object *m_Alignment;
226  bool m_IsResidue;
227 };
228 
229 } // namespace gcp
230 
231 #endif // GCHEMPAINT_MOLECULE_H