Avogadro  1.1.0
/home/kitware/dashboards/avogadro/libavogadro/src/bond.h
00001 /**********************************************************************
00002   Bond - Bond class derived from the base Primitive class
00003 
00004   Copyright (C) 2007 Donald Ephraim Curtis
00005   Copyright (c) 2008-2009 Marcus D. Hanwell
00006   Copyright (c) 2009 Tim Vandermeersch
00007   Copyright (c) 2009 Geoff Hutchison
00008 
00009   This file is part of the Avogadro molecular editor project.
00010   For more information, see <http://avogadro.openmolecules.net/>
00011 
00012   Avogadro is free software; you can redistribute it and/or modify
00013   it under the terms of the GNU General Public License as published by
00014   the Free Software Foundation; either version 2 of the License, or
00015   (at your option) any later version.
00016 
00017   Avogadro is distributed in the hope that it will be useful,
00018   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020   GNU General Public License for more details.
00021 
00022   You should have received a copy of the GNU General Public License
00023   along with this program; if not, write to the Free Software
00024   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00025   02110-1301, USA.
00026  **********************************************************************/
00027 
00028 #ifndef BOND_H
00029 #define BOND_H
00030 
00031 #include <avogadro/primitive.h>
00032 
00033 namespace OpenBabel {
00034   class OBBond;
00035 }
00036 
00037 namespace Avogadro {
00038 
00046   class Atom;
00047   class Molecule;
00048   class BondPrivate;
00049   class A_EXPORT Bond : public Primitive
00050   {
00051   Q_OBJECT
00052 
00053   public:
00059     Bond(QObject *parent=0);
00060 
00061     ~Bond();
00062 
00071     void setBegin(Atom* atom);
00072 
00076     void setEnd(Atom* atom);
00077 
00084     void setAtoms(unsigned long atom1, unsigned long atom2,
00085                   short order = 1);
00086 
00090     void setOrder(short order) { m_order = order; }
00091 
00095     void setAromaticity(bool isAromatic) const;
00096 
00100     void setCustomLabel(const QString &label) {  m_customLabel = label; }
00111     unsigned long beginAtomId() const { return m_beginAtomId; }
00112 
00116     Atom * beginAtom() const;
00117 
00121     unsigned long endAtomId() const { return m_endAtomId; }
00122 
00126     Atom * endAtom() const;
00127 
00131     const Eigen::Vector3d * beginPos() const;
00132 
00136     const Eigen::Vector3d * midPos() const;
00137 
00141     const Eigen::Vector3d * endPos() const;
00142 
00150     unsigned long otherAtom(unsigned long atomId) const;
00151 
00155     short order() const { return m_order; }
00156 
00160     bool isAromatic() const;
00161 
00165     double length() const;
00166 
00170     QString customLabel() const { return m_customLabel; }
00181     bool setOBBond(OpenBabel::OBBond *obbond);
00188     Bond& operator=(const Bond& other);
00191     friend class Molecule;
00192 
00193   private:
00194     unsigned long m_beginAtomId, m_endAtomId;
00195     short m_order;
00196     mutable bool m_isAromatic;
00197     mutable Eigen::Vector3d m_midPos;
00198     Molecule *m_molecule;
00199     QString m_customLabel;
00200     /* shared d_ptr with Primitive */
00201     Q_DECLARE_PRIVATE(Bond)
00202   };
00203 
00204 } // End namespace Avogadro
00205 
00206 #endif