Avogadro::QtGui::Molecule#
-
class Molecule : public QObject, public Molecule#
A QObject derived molecule object with signals/slots.
Unnamed Group
-
Index atomUniqueId(const AtomType &atom) const#
Get the unique ID of the atom, this will uniquely reference the atom as long as it exists.
- Parameters:
atom – The atom to obtain the unique ID of.
- Returns:
The unique identifier for the atom, MaxIndex if the atom is invalid or does not belong to this molecule.
-
Index atomUniqueId(Index atom) const#
Get the unique ID of the atom, this will uniquely reference the atom as long as it exists.
- Parameters:
atom – The atom to obtain the unique ID of.
- Returns:
The unique identifier for the atom, MaxIndex if the atom is invalid or does not belong to this molecule.
Unnamed Group
-
virtual bool removeBond(const AtomType &atom1, const AtomType &atom2) override#
Remove the specified bond.
- Parameters:
atom1 – One atom in the bond.
atom2 – The other atom in the bond.
- Returns:
True on success, false if the bond was not found. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
virtual bool removeBond(Index atom1, Index atom2) override#
Remove the specified bond.
- Parameters:
atom1 – One atom in the bond.
atom2 – The other atom in the bond.
- Returns:
True on success, false if the bond was not found. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Unnamed Group
-
Index bondUniqueId(const BondType &bond) const#
Get the unique ID of the bond, this will uniquely reference the bond as long as it exists.
- Parameters:
bond – The bond to obtain the unique ID of.
- Returns:
The unique identifier for the bond, MaxIndex if the bond is invalid or does not belong to this molecule.
-
Index bondUniqueId(Index bond) const#
Get the unique ID of the bond, this will uniquely reference the bond as long as it exists.
- Parameters:
bond – The bond to obtain the unique ID of.
- Returns:
The unique identifier for the bond, MaxIndex if the bond is invalid or does not belong to this molecule.
Public Types
-
enum MoleculeChange#
Enumeration of change types that can be given.
Values:
-
enumerator NoChange#
Useful for initializing MoleculeChange variables.
-
enumerator Atoms#
Object types that can be changed.
-
enumerator Bonds#
-
enumerator UnitCell#
-
enumerator Selection#
-
enumerator Layers#
-
enumerator Properties#
-
enumerator Added#
Operations that can affect the above types.
-
enumerator Removed#
-
enumerator Modified#
-
enumerator NoChange#
-
typedef PersistentAtom<Molecule> PersistentAtomType#
Typedef for PersistentAtom class.
-
typedef PersistentBond<Molecule> PersistentBondType#
Typedef for PersistentBond class.
Public Functions
-
Molecule(QObject *parent_ = nullptr)#
-
virtual ~Molecule() override#
Destroys the molecule object.
-
Molecule &operator=(const Core::Molecule &other)#
Assignment operator to copy data from base instance
-
virtual AtomType addAtom(unsigned char atomicNumber) override#
Add an atom with
atomicNumber
to the molecule.- Returns:
The atom created.
-
virtual AtomType addAtom(unsigned char atomicNumber, Index uniqueId)#
Add an atom with
atomicNumber
anduniqueId
to the molecule.- Returns:
The atom created. This can be invalid if the unique ID was already in use.
-
virtual bool removeAtom(Index index) override#
Remove the specified atom from the molecule.
- Parameters:
index – The index of the atom to be removed.
- Returns:
True on success, false if the atom was not found.
-
virtual bool removeAtom(const AtomType &atom) override#
Remove the specified atom from the molecule.
- Parameters:
atom – The atom to be removed.
- Returns:
True on success, false if the atom was not found. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
AtomType atomByUniqueId(Index uniqueId)#
Get the atom referenced by the
uniqueId
, the isValid method should be queried to ensure the id still referenced a valid atom.- Parameters:
uniqueId – The unique identifier for the atom.
- Returns:
An Atom object, check it is valid before using it.
-
virtual BondType addBond(const AtomType &a, const AtomType &b, unsigned char bondOrder = 1) override#
Add a bond between the specified atoms.
- Parameters:
a – The first atom in the bond.
b – The second atom in the bond.
bondOrder – The order of the bond.
- Returns:
The bond created.
-
virtual BondType addBond(Index atomId1, Index atomId2, unsigned char bondOrder = 1) override#
Add a bond between the specified atoms.
- Parameters:
atomId1 – The index of the first atom in the bond.
atomId2 – The index of the second atom in the bond.
bondOrder – The order of the bond.
- Returns:
The bond created.
-
void addBonds(const Core::Array<std::pair<Index, Index>> &bonds, const Core::Array<unsigned char> &orders)#
-
virtual BondType addBond(const AtomType &a, const AtomType &b, unsigned char bondOrder, Index uniqueId)#
Add a bond between the specified atoms.
- Parameters:
a – The first atom in the bond.
b – The second atom in the bond.
bondOrder – The order of the bond.
uniqueId – The unique ID to use for the bond.
- Returns:
The bond created. This can be invalid if the unique ID was already in use.
-
virtual BondType addBond(Index atomId1, Index atomId2, unsigned char bondOrder, Index uniqueId)#
Add a bond between the specified atoms.
- Parameters:
a – The index of the first atom in the bond.
b – The index of the second atom in the bond.
bondOrder – The order of the bond.
uniqueId – The unique ID to use for the bond.
- Returns:
The bond created. This can be invalid if the unique ID was already in use.
-
virtual bool removeBond(Index index) override#
Remove the specified bond.
- Parameters:
index – The index of the bond to be removed.
- Returns:
True on success, false if the bond was not found.
-
virtual bool removeBond(const BondType &bond) override#
Remove the specified bond.
- Parameters:
bond – The bond to be removed.
- Returns:
True on success, false if the bond was not found. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
BondType bondByUniqueId(Index uniqueId)#
Get the bond referenced by the
uniqueId
, the isValid method should be queried to ensure the id still referenced a valid bond.- Parameters:
uniqueId – The unique identifier for the bond.
- Returns:
A Bond object, check it is valid before using it.
-
Index findAtomUniqueId(Index index) const#
-
Index findBondUniqueId(Index index) const#
-
RWMolecule *undoMolecule()#
-
void swapBond(Index a, Index b)#
-
void swapAtom(Index a, Index b)#
Public Slots
Signals
-
void changed(unsigned int change)#
Indicates that the molecule has changed.
The
change
variable indicates what has changed, i.e. if change & Atoms == true then atoms were changed in some way, and if change & Removed == true then one or more atoms were removed.- Parameters:
change – Use the MoleculeChange enum to check what has changed.
-
Index atomUniqueId(const AtomType &atom) const#