Avogadro
1.1.0
|
00001 /********************************************************************** 00002 Atom - Atom class derived from the base Primitive class 00003 00004 Copyright (C) 2007 Donald Ephraim Curtis 00005 Copyright (c) 2008-2009 Geoff Hutchison 00006 Copyright (c) 2008-2009 Marcus D. Hanwell 00007 Copyright (c) 2010 Konstantin Tokarev 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 ATOM_H 00029 #define ATOM_H 00030 00031 #include <avogadro/primitive.h> 00032 #include <QtCore/QList> 00033 00034 namespace OpenBabel { 00035 class OBAtom; 00036 } 00037 00038 namespace Avogadro { 00039 00040 class Molecule; 00050 class Bond; 00051 class Residue; 00052 class AtomPrivate; 00053 class A_EXPORT Atom : public Primitive 00054 { 00055 Q_OBJECT 00056 00057 public: 00063 Atom(QObject *parent=0); 00064 00068 ~Atom(); 00069 00079 void setPos(const Eigen::Vector3d &vec); 00080 00085 void setPos(const Eigen::Vector3d *vec) { setPos(*vec); } 00086 00091 void setAtomicNumber(int num); 00092 00098 void setPartialCharge(double charge) const; 00099 00103 void setFormalCharge(int charge); 00104 00108 void setGroupIndex(unsigned int index); 00109 00113 void setForceVector(const Eigen::Vector3d &force); 00114 00118 void setCustomLabel(const QString &label); 00119 00123 void setCustomColorName(const QString &name); 00124 00128 void setCustomRadius(const double radius); 00137 Molecule * molecule() const { return m_molecule; } 00138 00142 const Eigen::Vector3d * pos() const; 00143 00148 int atomicNumber() const { return m_atomicNumber; } 00149 00153 QList<unsigned long> bonds() const { return m_bonds; } 00154 00158 QList<unsigned long> neighbors() const; 00159 00165 Bond * bond(const Atom *other) const; 00166 00170 double valence() const { return static_cast<double>(m_bonds.size()); } 00171 00175 unsigned int groupIndex() const; 00176 00180 bool isHydrogen() const { return m_atomicNumber == 1; } 00181 00185 double partialCharge() const; 00186 00190 int formalCharge() const; 00191 00192 QString customLabel() const; 00193 00194 QString customColorName() const; 00195 00196 double customRadius() const; 00197 00201 const Eigen::Vector3d forceVector() const; 00202 00206 unsigned long residueId() const; 00207 00211 Residue * residue() const; 00223 OpenBabel::OBAtom OBAtom(); 00224 //const OpenBabel::OBAtom OBAtom() const; 00225 00229 bool setOBAtom(OpenBabel::OBAtom *obatom); 00236 Atom& operator=(const Atom& other); 00239 friend class Molecule; 00240 friend class Bond; 00241 friend class Residue; 00242 00243 protected: 00247 void addBond(unsigned long bond); 00248 00252 void addBond(Bond* bond); 00253 00257 void removeBond(Bond* bond); 00258 00262 void removeBond(unsigned long bond); 00263 00267 void setResidue(unsigned long id); 00268 00272 void setResidue(const Residue *residue); 00273 00274 AtomPrivate * const d_ptr; 00275 Molecule *m_molecule; 00276 int m_atomicNumber; 00277 QList<unsigned long> m_bonds; 00278 00279 Q_DECLARE_PRIVATE(Atom) 00280 }; 00281 00282 } // End namespace Avoagdro 00283 00284 #endif