Avogadro  1.1.0
Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes
Avogadro::Molecule Class Reference

The molecule contains all of the molecular primitives. More...

#include <avogadro/molecule.h>

Inheritance diagram for Avogadro::Molecule:
Inheritance graph
[legend]

List of all members.

Public Slots

void updateMolecule ()

Signals

void moleculeChanged ()
void primitiveAdded (Primitive *primitive)
void primitiveUpdated (Primitive *primitive)
void primitiveRemoved (Primitive *primitive)
void atomAdded (Atom *atom)
void atomUpdated (Atom *atom)
void atomRemoved (Atom *atom)
void bondAdded (Bond *bond)
void bondUpdated (Bond *bond)
void bondRemoved (Bond *bond)

Public Member Functions

 Molecule (QObject *parent=0)
 Molecule (const Molecule &other)
virtual ~Molecule ()
void update ()
void addHydrogens (Atom *atom=0, const QList< unsigned long > &atomIds=QList< unsigned long >(), const QList< unsigned long > &bondIds=QList< unsigned long >())
void removeHydrogens (Atom *atom=0)
void setDipoleMoment (const Eigen::Vector3d &moment)
Eigen::Vector3d dipoleMoment (bool *estimate=0) const
void calculatePartialCharges () const
void calculateAromaticity () const
void calculateGroupIndices () const
Bondbond (unsigned long id1, unsigned long id2)
Bondbond (const Atom *, const Atom *)
unsigned long conformerSize ()
bool addConformer (const std::vector< Eigen::Vector3d > &conformer, unsigned int index)
std::vector< Eigen::Vector3d > * addConformer (unsigned int index)
std::vector< Eigen::Vector3d > * conformer (unsigned int index)
const std::vector< std::vector
< Eigen::Vector3d > * > & 
conformers () const
bool setConformer (unsigned int index)
bool setAllConformers (const std::vector< std::vector< Eigen::Vector3d > * > conformers, bool deleteExisting=true)
void clearConformers ()
unsigned int numConformers () const
unsigned int currentConformer () const
const std::vector< double > & energies () const
double energy (int index=-1) const
void setEnergy (double energy)
void setEnergy (int index, double energy)
void setEnergies (const std::vector< double > &energies)
void clear ()
QReadWriteLocklock () const
Molecule parameters

These methods set and get Molecule parameters.

void setFileName (const QString &name)
QString fileName () const
Atom properties

These functions are used to change and retrieve the properties of the Atom objects in the Molecule.

AtomaddAtom ()
AtomaddAtom (unsigned long id)
AtomaddAtom (int atomicNum, const Eigen::Vector3d &pos)
AtomaddAtom (const Atom &other)
void removeAtom (Atom *atom)
void removeAtom (unsigned long id)
Atomatom (int index) const
AtomatomById (unsigned long id) const
QList< Atom * > atoms () const
void setAtomPos (unsigned long id, const Eigen::Vector3d &vec)
void setAtomPos (unsigned long id, const Eigen::Vector3d *vec)
const Eigen::Vector3d * atomPos (unsigned long id) const
unsigned int numAtoms () const
Bond properties

These functions are used to change and retrieve the properties of the Bond objects in the Molecule.

BondaddBond ()
BondaddBond (unsigned long id)
BondaddBond (unsigned long beginAtomId, unsigned long endAtomId, short order=1)
BondaddBond (Atom *beginAtom, Atom *endAtom, short order=1)
void removeBond (Bond *bond)
void removeBond (unsigned long id)
Bondbond (int index) const
BondbondById (unsigned long id) const
QList< Bond * > bonds () const
unsigned int numBonds () const
Residue properties

These functions are used to change and retrieve the properties of the Residue objects in the Molecule.

ResidueaddResidue ()
ResidueaddResidue (unsigned long id)
void removeResidue (Residue *residue)
void removeResidue (unsigned long id)
Residueresidue (int index)
const Residueresidue (int index) const
ResidueresidueById (unsigned long id) const
QList< Residue * > residues () const
unsigned int numResidues () const
Ring properties

These functions are used to change and retrieve the properties of the Ring objects in the Molecule.

Note:
These should probably be generalized to Fragments, but then a convenience function to return a list of just rings would be needed.
FragmentaddRing ()
FragmentaddRing (unsigned long id)
void removeRing (Fragment *ring)
void removeRing (unsigned long id)
QList< Fragment * > rings ()
unsigned int numRings () const
Cube properties

These functions are used to change and retrieve the properties of the Cube objects in the Molecule.

CubeaddCube ()
CubeaddCube (unsigned long id)
void removeCube (Cube *cube)
void removeCube (unsigned long id)
Cubecube (int index) const
CubecubeById (unsigned long id) const
QList< Cube * > cubes () const
unsigned int numCubes () const
Mesh properties

These functions are used to change and retrieve the properties of the Mesh objects in the Molecule.

MeshaddMesh ()
MeshaddMesh (unsigned long id)
void removeMesh (Mesh *mesh)
void removeMesh (unsigned long id)
Meshmesh (int index) const
MeshmeshById (unsigned long id) const
QList< Mesh * > meshes () const
unsigned int numMeshes () const
ZMatrix properties

These functions are used to change and retrieve the properties of the ZMatrix objects in the Molecule.

ZMatrixaddZMatrix ()
void removeZMatrix (ZMatrix *zmatrix)
ZMatrixzMatrix (int index) const
QList< ZMatrix * > zMatrices () const
unsigned int numZMatrices () const
OpenBabel translation functions

These functions are used to exchange information with OpenBabel.

OpenBabel::OBMol OBMol () const
bool setOBMol (OpenBabel::OBMol *obmol)
OpenBabel::OBUnitCellOBUnitCell () const
bool setOBUnitCell (OpenBabel::OBUnitCell *obunitcell)
Molecule geometry information and manipulation

These functions can be used to retrieve several aspects of Molecule geometry and to manipulate some aspects.

const Eigen::Vector3d center () const
const Eigen::Vector3d normalVector () const
double radius () const
const AtomfarthestAtom () const
void translate (const Eigen::Vector3d &)
Operators

Overloaded operators.

Moleculeoperator= (const Molecule &other)
Moleculeoperator+= (const Molecule &other)
Misc.

Functions that don't neatly fit into the above categories.

PrimitiveList copyAtomsAndBonds (const QList< Atom * > &atoms, const QList< Bond * > &bonds)
PrimitiveList copyAtomsAndBonds (const PrimitiveList &atomsAndBonds)

Protected Member Functions

void computeGeomInfo () const

Protected Attributes

MoleculePrivate *const d_ptr
QString m_fileName
std::vector< Eigen::Vector3d > * m_atomPos
std::vector< std::vector
< Eigen::Vector3d > * > 
m_atomConformers
unsigned int m_currentConformer
bool m_estimatedDipoleMoment
Eigen::Vector3d * m_dipoleMoment
bool m_invalidPartialCharges
bool m_invalidAromaticity
std::vector< Atom * > m_atoms
std::vector< Bond * > m_bonds
QList< Atom * > m_atomList
QList< Bond * > m_bondList
QReadWriteLockm_lock

Detailed Description

The molecule contains all of the molecular primitives.

Author:
Marcus D. Hanwell

The Molecule class contains the core data of the molecule. It is the central model, holding all information displayed by our various views and manipulated by tools and extensions. It typically contains Atom and Bond objects, but may also contain Cube, Mesh, Fragment, Residue and other objects.


Constructor & Destructor Documentation

Constructor.

Parameters:
parentThe object parent.

References QObject::connect(), QDir::homePath(), QObject::tr(), and Avogadro::Primitive::updated().

Copy constructor.

Parameters:
otherMolecule to make a copy of.

References QObject::connect(), and Avogadro::Primitive::updated().

Destructor.

References QObject::blockSignals(), clear(), and QObject::disconnect().


Member Function Documentation

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Create a new Atom object and return a pointer to it.

Note:
Do not delete the object, use removeAtom(Atom*).

Referenced by addAtom(), addHydrogens(), Avogadro::ZMatrix::addRow(), copyAtomsAndBonds(), operator+=(), and setOBMol().

Atom * Avogadro::Molecule::addAtom ( unsigned long  id)

Create a new Atom object with the specified id and return a pointer to it. Used when you need to recreate an Atom with the same unique id.

Note:
Do not delete the object, use removeAtom(unsigned long id).

References atom(), atomAdded(), QObject::connect(), Avogadro::Primitive::id(), m_atomConformers, QList::push_back(), Avogadro::Primitive::setId(), Avogadro::Primitive::setIndex(), QList::size(), and Avogadro::Primitive::updated().

Atom * Avogadro::Molecule::addAtom ( int  atomicNum,
const Eigen::Vector3d &  pos 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Create a new Atom object of the specified element at the given position, and return a pointer to it.

Parameters:
atomicNumAtomic number
posCartesian position
Note:
Do not delete the object, use removeAtom(unsigned long id).

References addAtom(), and Avogadro::Atom::m_atomicNumber.

Atom * Avogadro::Molecule::addAtom ( const Atom other)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Create a new Atom object and copy the Atom object other's data into it. A pointer to the new atom in this is returned.

Parameters:
otherThe atom to copy into the new atom
Note:
Do not delete the new object, use removeAtom(unsigned long id).

References addAtom().

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Create a new Bond object and return a pointer to it.

Note:
Do not delete the object, use removeBond(Bond*).

Referenced by addBond(), addHydrogens(), Avogadro::ZMatrix::addRow(), copyAtomsAndBonds(), operator+=(), Avogadro::Animation::setFrame(), and setOBMol().

Bond * Avogadro::Molecule::addBond ( unsigned long  id)

Create a new Bond object with the specified id and return a pointer to it. Used when you need to recreate a Bond with the same unique id.

Note:
Do not delete the object, use removeBond(unsigned long id).

References bond(), bondAdded(), QObject::connect(), Avogadro::Primitive::id(), QList::push_back(), Avogadro::Primitive::setId(), Avogadro::Primitive::setIndex(), QList::size(), and Avogadro::Primitive::updated().

Bond * Avogadro::Molecule::addBond ( unsigned long  beginAtomId,
unsigned long  endAtomId,
short  order = 1 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Create a new bond between two atoms of the specified order. A pointer to the new Bond is returned.

Parameters:
beginAtomIdID of the beginning atom of the bond
endAtomIdID of the ending atom of the bond
orderBond order of the new bond (default 1)
Note:
Do not delete the object, use removeBond(Bond*).

References addBond(), and Avogadro::Bond::setAtoms().

Bond * Avogadro::Molecule::addBond ( Atom beginAtom,
Atom endAtom,
short  order = 1 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Create a new bond between two atoms of the specified order. A pointer to the new Bond is returned.

Parameters:
beginAtomPointer to the beginning atom of the bond
endAtomPointer to the ending atom of the bond
orderBond order of the new bond (default 1)
Note:
Do not delete the object, use removeBond(Bond*).
Both beginAtom and endAtom must be owned by this Molecule.

References addBond(), and Avogadro::Bond::setAtoms().

bool Avogadro::Molecule::addConformer ( const std::vector< Eigen::Vector3d > &  conformer,
unsigned int  index 
)

Add a new conformer to the Molecule. If the index is an already existing conformer, this conformer will be overwritten. If there is a gap between the currently last index and the new index, new conformers will be created to make sure all indexes have a valid conformer. For example, if there is only one conformer and this method is called with index 9, a total of nine conformers are added (0 existed, 1-9 are created).

Note:
Conformer atom positions are indexed by their unique id (Atom::id()). Use conformerSize() to check the current size needed to accommodate all atoms.
Parameters:
conformerA vector of Vector3d with all atom positions.
indexThe index of the conformer to add.

References conformer(), Avogadro::Primitive::index(), and m_atomConformers.

Referenced by setOBMol().

vector< Vector3d > * Avogadro::Molecule::addConformer ( unsigned int  index)

Add a new conformer and return a pointer to it. If the index is an already existing conformer, no new conformer will be created and a pointer to the already existing conformer is returned. If there is a gap between the currently last index and the new index, new conformers will be created to make sure all indexes have a valid conformer. For example, if there is only one conformer and this method is called with index 9, a total of nine conformers are added (0 existed, 1-9 are created) and a pointer to the last one is returned.

Note:
Conformer atom positions are indexed by their unique id (Atom::id()). Use conformerSize() to check the current size needed to accommodate all atoms.
Parameters:
indexThe index of the new conformer.
Returns:
Pointer to the conformer added.

References Avogadro::Primitive::index(), and m_atomConformers.

Create a new Cube object and return a pointer to it.

Note:
Do not delete the object, use removeCube(unsigned long id).

Referenced by setOBMol().

Cube * Avogadro::Molecule::addCube ( unsigned long  id)

Create a new Cube object with the specified id and return a pointer to it. Used when you need to recreate a Cube with the same unique id.

Note:
Do not delete the object, use removeCube(unsigned long id).

References QObject::connect(), cube(), Avogadro::Primitive::id(), primitiveAdded(), Avogadro::Primitive::setId(), Avogadro::Primitive::setIndex(), and Avogadro::Primitive::updated().

void Avogadro::Molecule::addHydrogens ( Atom atom = 0,
const QList< unsigned long > &  atomIds = QList<unsigned long>(),
const QList< unsigned long > &  bondIds = QList<unsigned long>() 
)

Create a new Mesh object and return a pointer to it.

Note:
Do not delete the object, use removeMesh(unsigned long id).
Mesh * Avogadro::Molecule::addMesh ( unsigned long  id)

Create a new Mesh object with the specified id and return a pointer to it. Used when you need to recreate a Mesh with the same unique id.

Note:
Do not delete the object, use removeMesh(unsigned long id).

References QObject::connect(), Avogadro::Primitive::id(), mesh(), primitiveAdded(), Avogadro::Primitive::setId(), Avogadro::Primitive::setIndex(), and Avogadro::Primitive::updated().

Create a new Residue object and return a pointer to it.

Note:
Do not delete the object, use removeResidue(Residue *residue).

Referenced by operator+=(), operator=(), and setOBMol().

Residue * Avogadro::Molecule::addResidue ( unsigned long  id)

Create a new Residue object with the specified id and return a pointer to it. Used when you need to recreate a Residue with the same unique id.

Note:
Do not delete the object, use removeResidue(unsigned long id).

References QObject::connect(), Avogadro::Primitive::id(), primitiveAdded(), residue(), Avogadro::Primitive::setId(), Avogadro::Primitive::setIndex(), and Avogadro::Primitive::updated().

Create a new ring object and return a pointer to it.

Note:
Do not delete the object, use removeRing(Fragment *ring).

Referenced by rings().

Fragment * Avogadro::Molecule::addRing ( unsigned long  id)

Create a new Ring object with the specified id and return a pointer to it. Used when you need to recreate a Ring with the same unique id.

Note:
Do not delete the object, use removeRing(unsigned long id).

References QObject::connect(), Avogadro::Primitive::id(), Avogadro::Primitive::setId(), Avogadro::Primitive::setIndex(), and Avogadro::Primitive::updated().

Create a new ZMatrix object and return a pointer to it.

Note:
Do not delete the object, use removeZMatrix(unsigned long id).
Atom * Avogadro::Molecule::atom ( int  index) const [inline]
void Avogadro::Molecule::atomAdded ( Atom atom) [signal]

Emitted when an Atom is added.

Parameters:
Atompointer to the Atom that was added.

Referenced by addAtom().

Atom * Avogadro::Molecule::atomById ( unsigned long  id) const [inline]
const Eigen::Vector3d * Avogadro::Molecule::atomPos ( unsigned long  id) const [inline]

Get the position vector of the supplied Atom.

Parameters:
idUnique id of the Atom.
Returns:
Position vector of the Atom.

Referenced by Avogadro::Bond::beginPos(), Avogadro::Bond::endPos(), Avogadro::Bond::midPos(), Avogadro::Atom::OBAtom(), and Avogadro::Atom::pos().

void Avogadro::Molecule::atomRemoved ( Atom atom) [signal]

Emitted when an Atom is removed.

Parameters:
Atompointer to the Atom that was removed.

Referenced by removeAtom().

void Avogadro::Molecule::atomUpdated ( Atom atom) [signal]

Emitted when an Atom is updated.

Parameters:
Atompointer to the Atom that was updated.

Referenced by translate().

Bond * Avogadro::Molecule::bond ( int  index) const [inline]
Bond * Avogadro::Molecule::bond ( unsigned long  id1,
unsigned long  id2 
)
Returns:
The bond between the two supplied atom ids if one exists, otherwise 0 is returned.

References atomById(), bond(), bondById(), Avogadro::Atom::bonds(), bonds(), and Avogadro::Bond::otherAtom().

Bond * Avogadro::Molecule::bond ( const Atom a1,
const Atom a2 
)
Returns:
The bond between the two supplied atom pointers if one exists, otherwise 0 is returned.

References bond(), and Avogadro::Primitive::id().

void Avogadro::Molecule::bondAdded ( Bond bond) [signal]

Emitted when a Bond is added.

Parameters:
Bondpointer to the bond that was added.

Referenced by addBond().

Bond * Avogadro::Molecule::bondById ( unsigned long  id) const [inline]
Returns:
The Bond at the supplied unique id.

Referenced by bond(), Avogadro::Atom::formalCharge(), and Avogadro::Atom::neighbors().

void Avogadro::Molecule::bondRemoved ( Bond bond) [signal]

Emitted when a Bond is removed.

Parameters:
Bondpointer to the Bond that was removed.

Referenced by removeBond().

void Avogadro::Molecule::bondUpdated ( Bond bond) [signal]

Emitted when a Bond is updated.

Parameters:
Bondpointer to the bond that was updated.

Calculate the indices of atoms in groups of atoms of the same element.

References QVector::at(), atom(), numAtoms(), QVector::push_back(), QVector::resize(), Avogadro::Atom::setGroupIndex(), and QVector::size().

Referenced by Avogadro::Atom::groupIndex().

const Eigen::Vector3d Avogadro::Molecule::center ( ) const
Returns:
The position of the center of the Molecule.

References computeGeomInfo().

Remove all elements of the molecule.

References atom(), bond(), QList::clear(), clearConformers(), cube(), QObject::deleteLater(), mesh(), primitiveRemoved(), and residue().

Referenced by operator=(), setOBMol(), and ~Molecule().

Clear all conformers from the molecule, leaving just conformer zero. This conformer will also be set as current conformer.

References m_atomConformers.

Referenced by clear(), and setAllConformers().

void Avogadro::Molecule::computeGeomInfo ( ) const [protected]

Compute all the geometry information for the Molecule. This allows several relatively expensive calculations to be cached by the Molecule instead of being recalculated every time the Molecule is drawn.

FIXME This leads to the dipole moment always getting invalidated as the geometry information must be computed on load

References atom(), Avogadro::Primitive::id(), numAtoms(), and Avogadro::Atom::pos().

Referenced by center(), farthestAtom(), normalVector(), radius(), and setOBMol().

vector< Vector3d > * Avogadro::Molecule::conformer ( unsigned int  index)
Note:
Conformer atom positions are indexed by their unique id (Atom::id()). Use conformerSize() to check the current size needed to accommodate all atoms.
Parameters:
indexThe index of the conformer to retrieve.
Returns:
Pointer to an existing conformer, or NULL if the index doesn't exist.

References m_atomConformers.

Referenced by addConformer(), Avogadro::Animation::setFrames(), Avogadro::Animation::setMolecule(), and setOBMol().

const std::vector< std::vector< Eigen::Vector3d > * > & Avogadro::Molecule::conformers ( ) const

Get const reference to all conformers.

Note:
Conformer atom positions are indexed by their unique id (Atom::id()). Use conformerSize() to check the current size needed to accommodate all atoms.

References m_atomConformers.

Referenced by setAllConformers(), and Avogadro::MoleculeFile::writeConformers().

unsigned long Avogadro::Molecule::conformerSize ( ) [inline]

Get the current conformer size to accommodate all atoms. Since atom positions are indexed by their uniaue id, this is not the same as the number of atoms

     Molecule *molecule;
     ...
     // create a correctly sized conformer and initialize its elements
     std::vector<Eigen::Vector3d> newConformer(molecule->conformerSize(), Eigen::Vector3d::Zero())
     // change the atom posistions in the conformer
     foreach (Atom *atom, molecule->atoms()) {
       newConformer[atom->id()] = ...;
     }
     // add the conformer to the end of the current list (i.e. index = numConformers())
     molecule->addConformer(newConformer, molecule->numConformers())
PrimitiveList Avogadro::Molecule::copyAtomsAndBonds ( const QList< Atom * > &  atoms,
const QList< Bond * > &  bonds 
)

Copy the atoms and bonds in the argument lists into new atoms and bonds in this.

Parameters:
atomsAtoms to copy into this.
bondsBonds to copy into this.
Returns:
A PrimitiveList containing new atoms and bonds.
Note:
All atoms and bonds must belong to the same molecule.
All bonds in must be between atoms in .

References addAtom(), addBond(), Avogadro::PrimitiveList::append(), QList::constBegin(), QList::constEnd(), QList::first(), Avogadro::Primitive::id(), QVector::insert(), QList::isEmpty(), QVector::push_back(), QVector::reserve(), and QList::size().

Referenced by copyAtomsAndBonds().

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Copy the atoms and bonds in the argument lists into new atoms and bonds in this.

Parameters:
atomsAndBondsAtoms and bonds to copy into this.
Returns:
A PrimitiveList containing the new atoms and bonds.
Note:
All atoms and bonds must belong to the same molecule.
All bonds in the list must be between atoms in the list.
The QList overload of this function is faster.

References QList::append(), atoms(), Avogadro::Primitive::AtomType, bonds(), Avogadro::Primitive::BondType, QList::constBegin(), QList::constEnd(), copyAtomsAndBonds(), QList::reserve(), QList::size(), and Avogadro::PrimitiveList::subList().

Cube * Avogadro::Molecule::cube ( int  index) const
Returns:
The Cube at the supplied index.

Referenced by addCube(), clear(), OBMol(), and setOBMol().

Cube * Avogadro::Molecule::cubeById ( unsigned long  id) const
Returns:
The Cube at the supplied unique id.

References cubes(), and QList::size().

Returns:
QList of all cubes in the molecule.

Referenced by cubeById(), and removeCube().

unsigned int Avogadro::Molecule::currentConformer ( ) const
Returns:
The current conformer index.
Eigen::Vector3d Avogadro::Molecule::dipoleMoment ( bool *  estimate = 0) const

Calculate the dipole moment vector for this molecule. If not known, Avogadro will estimate it based on partial charges.

Parameters:
Aboolean to indicate if the dipole is estimated or not
Returns:
The dipole moment of the Molecule.

References atom(), atoms(), OpenBabel::OBForceField::FindForceField(), OpenBabel::OBForceField::GetPartialCharges(), OpenBabel::OBPairData::GetValue(), OBMol(), Avogadro::Atom::partialCharge(), Avogadro::Atom::pos(), and OpenBabel::OBForceField::Setup().

const std::vector< double > & Avogadro::Molecule::energies ( ) const
Returns:
The energies for all conformers (in kJ/mol).

References numConformers().

Referenced by setEnergies(), setEnergy(), and setOBMol().

double Avogadro::Molecule::energy ( int  index = -1) const

Get the energy of the supplied conformer (in kJ/mol), defaults to returning the energy of the current conformer.

Parameters:
indexThe conformer, defaults to the current conformer.
Returns:
The energy of the Molecule (or current conformer).

References Avogadro::Primitive::index().

Referenced by OBMol(), and setEnergy().

Returns:
The Atom furthest away from the center of the Molecule.

References computeGeomInfo().

Returns:
The full path filename of the molecule.

Provides locking, should be used before reading/writing to the Molecule.

Referenced by Avogadro::Animation::setFrame(), Avogadro::Animation::start(), and Avogadro::Animation::stop().

Mesh * Avogadro::Molecule::mesh ( int  index) const
Returns:
The Mesh at the supplied index.

Referenced by addMesh(), and clear().

Mesh * Avogadro::Molecule::meshById ( unsigned long  id) const
Returns:
The Mesh at the supplied unique id.

References meshes(), and QList::size().

Returns:
QList of all Mesh objects in the Molecule.

Referenced by meshById(), and removeMesh().

Emitted when the Molecule changes in a big way, e.g. thousands of atoms added/removed. Typically functions should respond by building up their interpretation of the Molecule from the beginning.

Referenced by updateMolecule().

const Eigen::Vector3d Avogadro::Molecule::normalVector ( ) const
Returns:
The normal vector of the Molecule.

References computeGeomInfo().

unsigned int Avogadro::Molecule::numAtoms ( ) const
Returns:
The total number of Atom objects in the molecule.

References QList::size().

Referenced by addHydrogens(), calculateGroupIndices(), calculatePartialCharges(), computeGeomInfo(), and setOBMol().

unsigned int Avogadro::Molecule::numBonds ( ) const
Returns:
The total number of Bond objects in the Mmolecule.

References QList::size().

Referenced by calculateAromaticity().

unsigned int Avogadro::Molecule::numConformers ( ) const
unsigned int Avogadro::Molecule::numCubes ( ) const
Returns:
The total number of Cube objects in the Molecule.
unsigned int Avogadro::Molecule::numMeshes ( ) const
Returns:
The total number of meshes in the molecule.
unsigned int Avogadro::Molecule::numResidues ( ) const
Returns:
The total number of Residue objects in the Molecule.
unsigned int Avogadro::Molecule::numRings ( ) const
Returns:
The total number of rings in the molecule.
unsigned int Avogadro::Molecule::numZMatrices ( ) const
Returns:
The total number of ZMatrix objects in the molecule.

Get access to an OpenBabel::OBMol, this is a copy of the internal data structure in OpenBabel form, you must call setOBMol in order to save any changes you make to this object.

References OpenBabel::OBResidue::AddAtom(), OpenBabel::OBMol::AddBond(), OpenBabel::OBGridData::ANGSTROM, atom(), atomById(), Avogadro::Atom::atomicNumber(), Avogadro::Residue::atomId(), Avogadro::Fragment::atoms(), Avogadro::Bond::beginAtomId(), OpenBabel::OBMol::BeginModify(), bond(), Avogadro::Residue::chainID(), cube(), Avogadro::Bond::customLabel(), QByteArray::data(), Avogadro::Cube::dimensions(), QObject::dynamicPropertyNames(), Avogadro::Bond::endAtomId(), OpenBabel::OBMol::EndModify(), energy(), OpenBabel::etab, OpenBabel::fileformatInput, OpenBabel::OBMol::GetAtom(), OpenBabel::OBMol::GetBond(), OpenBabel::OBAtom::GetIdx(), Avogadro::Primitive::index(), QString::isEmpty(), KCAL_TO_KJ, Avogadro::Cube::min(), Avogadro::Fragment::name(), OpenBabel::OBMol::NewAtom(), OpenBabel::OBMol::NewResidue(), Avogadro::Residue::number(), OpenBabel::OBMol::NumBonds(), Avogadro::Atom::OBAtom(), OBUnitCell(), Avogadro::Bond::order(), QObject::property(), residue(), OpenBabel::OBResidue::SetAtomID(), OpenBabel::OBGridData::SetAttribute(), OpenBabel::OBPairData::SetAttribute(), OpenBabel::OBResidue::SetChain(), OpenBabel::OBMol::SetData(), SetData, OpenBabel::OBMol::SetEnergy(), OpenBabel::OBResidue::SetHetAtom(), OpenBabel::OBGridData::SetLimits(), OpenBabel::OBResidue::SetName(), OpenBabel::OBResidue::SetNum(), OpenBabel::OBGridData::SetNumberOfPoints(), OpenBabel::OBGridData::SetOrigin(), OpenBabel::OBMol::SetPartialChargesPerceived(), OpenBabel::OBResidue::SetSerialNum(), OpenBabel::OBGridData::SetUnit(), OpenBabel::OBPairData::SetValue(), OpenBabel::OBGridData::SetValues(), Avogadro::Cube::spacing(), QString::toLatin1(), QString::toStdString(), and QString::toUpper().

Referenced by addHydrogens(), calculateAromaticity(), calculatePartialCharges(), dipoleMoment(), Avogadro::MoleculeFile::replaceMolecule(), rings(), Avogadro::MoleculeFile::writeConformers(), and Avogadro::MoleculeFile::writeMolecule().

Get access to the OpenBabel unit cell, if any

Returns:
the OBUnitCell or NULL if none exists

Referenced by OBMol(), operator=(), and setOBMol().

Molecule & Avogadro::Molecule::operator+= ( const Molecule other)
Molecule & Avogadro::Molecule::operator= ( const Molecule other)
void Avogadro::Molecule::primitiveAdded ( Primitive primitive) [signal]

Emitted when a child primitive is added.

Parameters:
primitivepointer to the primitive that was added

Referenced by addCube(), addMesh(), addResidue(), operator+=(), and operator=().

void Avogadro::Molecule::primitiveRemoved ( Primitive primitive) [signal]

Emitted when a child primitive is removed.

Parameters:
primitivepointer to the primitive that was removed.

Referenced by clear(), removeCube(), removeMesh(), and removeResidue().

void Avogadro::Molecule::primitiveUpdated ( Primitive primitive) [signal]

Emitted when a child primitive is updated.

Parameters:
primitivepointer to the primitive that was updated
double Avogadro::Molecule::radius ( ) const
Returns:
The radius of the Molecule.

References computeGeomInfo().

void Avogadro::Molecule::removeAtom ( unsigned long  id)

Delete the Atom with the unique id specified.

References atomById(), and removeAtom().

Remove the supplied Bond.

References Avogadro::Primitive::id(), and QObject::parent().

Referenced by removeAtom(), and Avogadro::Animation::setFrame().

void Avogadro::Molecule::removeBond ( unsigned long  id)
void Avogadro::Molecule::removeCube ( unsigned long  id)

Remove the Cube with the unique id specified.

References cubes(), removeCube(), and QList::size().

Remove all hydrogens from the molecule.

Parameters:
atomIf supplied only remove hydrogens connected to the specified atom.

References atomById(), Avogadro::Primitive::id(), Avogadro::Atom::isHydrogen(), Avogadro::Atom::neighbors(), and removeAtom().

void Avogadro::Molecule::removeMesh ( unsigned long  id)

Remove the Mesh with the unique id specified.

References meshes(), removeMesh(), and QList::size().

void Avogadro::Molecule::removeResidue ( unsigned long  id)

Remove the residue with the unique id specified.

References removeResidue(), residues(), and QList::size().

void Avogadro::Molecule::removeRing ( unsigned long  id)

Remove the ring with the unique id specified.

References removeRing(), rings(), and QList::size().

Remove the supplied ZMatrix.

Returns:
The residue at the supplied index.
Note:
Replaces GetResidue.

Referenced by addResidue(), clear(), OBMol(), operator+=(), operator=(), and setOBMol().

Residue * Avogadro::Molecule::residueById ( unsigned long  id) const
Returns:
The residue at the supplied unique id.

References residues(), and QList::size().

Referenced by Avogadro::Atom::residue().

Returns:
QList of all Residue objects in the Molecule.

Referenced by operator+=(), operator=(), removeResidue(), residueById(), and setOBMol().

bool Avogadro::Molecule::setAllConformers ( const std::vector< std::vector< Eigen::Vector3d > * >  conformers,
bool  deleteExisting = true 
)

Replace all conformers in the Molecule. This will first clear all conformers. If the number of specified conformers is 0, this method behaves like clearConformers(). In any case, the current conformer is set to the first one (index 0).

Note:
Conformer atom positions are indexed by their unique id (Atom::id()). Use conformerSize() to check the current size needed to accommodate all atoms.
Parameters:
conformerA vector of conformers (vector of Vector3d)
deleteExistingWhether to free the memory from the existing conformers
Returns:
True if successful (i.e. all conformers have the correct size: conformerSize()).

References clearConformers(), conformers(), and m_atomConformers.

Referenced by Avogadro::Animation::start(), and Avogadro::Animation::stop().

void Avogadro::Molecule::setAtomPos ( unsigned long  id,
const Eigen::Vector3d &  vec 
)

Set the Atom position.

Parameters:
idUnique id of the Atom to set the position for.
vecPosition vector to set the Atom to.

References Avogadro::Primitive::id().

Referenced by setAtomPos(), Avogadro::Atom::setOBAtom(), and Avogadro::Atom::setPos().

void Avogadro::Molecule::setAtomPos ( unsigned long  id,
const Eigen::Vector3d *  vec 
)

Set the Atom position.

Parameters:
idUnique id of the Atom to set the position for.
vecPosition vector to set the Atom to.

References setAtomPos().

bool Avogadro::Molecule::setConformer ( unsigned int  index)

Change the conformer to the one at the specified index. Conformers are indexed from 0 to numConformers() - 1. When the index is invalid (i.e. >= numConformers()), this method returns false.

Returns:
True if the conformer index is valid.

References Avogadro::Primitive::index(), and m_atomConformers.

Referenced by Avogadro::Animation::setFrame(), and setOBMol().

void Avogadro::Molecule::setDipoleMoment ( const Eigen::Vector3d &  moment)

Set the dipole moment of the Molecule.

Parameters:
momentThe dipole moment of the Molecule.
void Avogadro::Molecule::setEnergies ( const std::vector< double > &  energies)

Set the energies for all conformers (in kJ/mol).

Parameters:
energiesThe vector of all energy values

References energies().

Referenced by setOBMol().

void Avogadro::Molecule::setEnergy ( double  energy)

Set the energy for the current conformer (in kJ/mol).

Parameters:
energyThe value for this conformer

References energies(), and numConformers().

Referenced by setOBMol().

void Avogadro::Molecule::setEnergy ( int  index,
double  energy 
)

Set the energy for the specified conformer (in kJ/mol).

Parameters:
indexthe index of the confomer
energyThe energy for this conformer

References energy(), Avogadro::Primitive::index(), and numConformers().

void Avogadro::Molecule::setFileName ( const QString name)

Set the filename of the molecule.

References QObject::name().

Referenced by Avogadro::MoleculeFile::readMolecule().

Copy as much data as possible from the supplied OpenBabel::OBMol to the Avogadro Molecule object.

Copy these residues!

References Avogadro::Residue::addAtom(), addAtom(), Avogadro::Fragment::addBond(), addBond(), addConformer(), addCube(), addResidue(), QList::append(), atom(), atoms(), OpenBabel::OBMol::BeginAtom(), OpenBabel::OBMol::BeginBond(), OpenBabel::OBMol::BeginResidue(), QObject::blockSignals(), bond(), clear(), computeGeomInfo(), conformer(), OpenBabel::OBGenericDataType::ConformerData, QHash::contains(), cube(), OpenBabel::OBGenericDataType::DOSData, OpenBabel::OBGenericDataType::ElectronicData, OpenBabel::OBGenericDataType::ElectronicTransitionData, energies(), OpenBabel::OBMol::GetAllData(), OpenBabel::OBOrbitalData::GetAlphaOrbitals(), OpenBabel::OBPairData::GetAttribute(), OpenBabel::OBOrbitalData::GetBetaOrbitals(), OpenBabel::OBMol::GetCoordinates(), OpenBabel::OBVectorData::GetData(), OpenBabel::OBMol::GetData(), OpenBabel::OBConformerData::GetEnergies(), OpenBabel::OBMol::GetEnergy(), OpenBabel::OBConformerData::GetForces(), OpenBabel::OBAtom::GetIdx(), OpenBabel::OBBond::GetIdx(), OpenBabel::OBGridData::GetMaxVector(), OpenBabel::OBGridData::GetNumberOfPoints(), OpenBabel::OBGridData::GetOriginVector(), OpenBabel::OBGridData::GetValues(), OpenBabel::OBGenericDataType::GridData, OpenBabel::OBMol::HasData(), Avogadro::Primitive::id(), Avogadro::Primitive::index(), OpenBabel::OBOrbitalData::IsOpenShell(), KCAL_TO_KJ, QObject::name(), OpenBabel::OBMol::NextAtom(), OpenBabel::OBMol::NextBond(), OpenBabel::OBMol::NextResidue(), numAtoms(), OpenBabel::OBMol::NumConformers(), OBUnitCell(), OpenBabel::OBGenericDataType::PairData, QObject::property(), residue(), residues(), Avogadro::Residue::setAtomId(), Avogadro::Bond::setAtoms(), Avogadro::Residue::setChainID(), Avogadro::Residue::setChainNumber(), OpenBabel::OBMol::SetConformer(), setConformer(), Avogadro::Bond::setCustomLabel(), Avogadro::Cube::setData(), setEnergies(), setEnergy(), Avogadro::Atom::setForceVector(), Avogadro::Cube::setLimits(), Avogadro::Fragment::setName(), Avogadro::Residue::setNumber(), Avogadro::Atom::setOBAtom(), QObject::setProperty(), OpenBabel::OBGenericDataType::UnitCell, update(), QHash::value(), OpenBabel::OBGenericDataType::VibrationData, OpenBabel::vector3::x(), OpenBabel::vector3::y(), and OpenBabel::vector3::z().

Referenced by Avogadro::MoleculeFile::molecule(), and Avogadro::MoleculeFile::readMolecule().

Copy as much data as possible from the supplied OpenBabel::OBUnitCell to this Avogadro Molecule object.

Returns:
True if successful

References OpenBabel::OBGenericDataType::UnitCell.

void Avogadro::Molecule::translate ( const Eigen::Vector3d &  offset)

Translate the Molecule using the supplied vector.

References atom(), atomUpdated(), and Avogadro::Primitive::id().

Call to trigger an update signal, causing the molecule to be redrawn.

Reimplemented from Avogadro::Primitive.

References Avogadro::Primitive::updated().

Referenced by Avogadro::Animation::setFrame(), and setOBMol().

Signal that the molecule has been changed in some large way, emits the moleculeChanged and updated signals. This indicates that anything listening to this signal should tear town its cache/model and rebuild it.

References moleculeChanged(), and Avogadro::Primitive::updated().

Returns:
QList of all ZMatrix objects in the Molecule.
ZMatrix * Avogadro::Molecule::zMatrix ( int  index) const
Returns:
The ZMatrix at the supplied index.

Member Data Documentation

std::vector< std::vector<Eigen::Vector3d>* > Avogadro::Molecule::m_atomConformers [protected]

Vector containing pointers to various conformers.

Referenced by addAtom(), addConformer(), clearConformers(), conformer(), conformers(), numConformers(), operator=(), setAllConformers(), and setConformer().


The documentation for this class was generated from the following files: