Loading...
Searching...
No Matches
RWMolecule Class Reference

The RWMolecule class is an editable molecule class that automatically populates an undo stack. More...

`#include <avogadro/qtgui/rwmolecule.h>`

Inheritance diagram for RWMolecule:

## Classes

class | UndoCommand

## Public Types

typedef RWAtom | AtomType
typedef PersistentAtom< RWMolecule > | PersistentAtomType
typedef RWBond | BondType
typedef PersistentBond< RWMolecule > | PersistentBondType

## Public Slots

void | emitChanged (unsigned int change)
| Force the molecule to emit the changed() signal.

## Signals

void | changed (unsigned int change)
| Indicates that the molecule has changed.

## Public Member Functions

| RWMolecule (Molecule &mol, QObject *parent=nullptr)
Molecule & | molecule ()
const Molecule & | molecule () const
AtomType | addAtom (unsigned char atomicNumber, bool usingPositions=true)
AtomType | addAtom (unsigned char atomicNumber, const Vector3 &position3d)
AtomType | atom (Index atomId) const
AtomType | atomByUniqueId (Index atomUId) const
Index | atomCount () const
Index | atomCount (unsigned char atomicNumber) const
void | clearAtoms ()
void | adjustHydrogens (Index atomId)
void | adjustHydrogens (const Core::Array< Index > &atomIds)
const Core::Array< unsigned char > & | atomicNumbers () const
unsigned char | atomicNumber (Index atomId) const
bool | setAtomicNumbers (const Core::Array< unsigned char > &nums)
bool | setAtomicNumber (Index atomId, unsigned char atomicNumber)
const Core::Array< Vector3 > & | atomPositions3d () const
Vector3 | atomPosition3d (Index atomId) const
bool | setAtomPositions3d (const Core::Array< Vector3 > &pos, const QString &undoText=tr("Change Atom Positions"))
bool | setAtomPosition3d (Index atomId, const Vector3 &pos, const QString &undoText=tr("Change Atom Position"))
std::string | atomLabel (Index atomId) const
bool | setAtomLabel (Index atomId, const std::string &label, const QString &undoText=tr("Change Atom Label"))
std::string | bondLabel (Index bondId) const
bool | setBondLabel (Index bondId, const std::string &label, const QString &undoText=tr("Change Bond Label"))
void | setAtomSelected (Index atomId, bool selected, const QString &undoText=tr("Change Selection"))
bool | atomSelected (Index atomId) const
bool | setAtomPosition2d (Index, const Vector2 &)
Vector2 | atomPosition2d (Index)
const Core::Array< Vector2 > & | atomPositions2d () const
Core::AtomHybridization | hybridization (Index atomId) const
bool | setHybridization (Index atomId, Core::AtomHybridization hyb)
signed char | formalCharge (Index atomId) const
bool | setFormalCharge (Index atomId, signed char charge)
unsigned short | isotope (Index atomId) const
bool | setIsotope (Index atomId, unsigned short isotope)
Vector3ub | color (Index atomId) const
bool | setColor (Index atomId, Vector3ub color)
bool | setResidueColor (Index residueId, Vector3ub color)
bool | setLayer (Index atomId, size_t layer)
size_t | layer (Index atomId) const
BondType | bond (Index bondId) const
BondType | bond (Index atom1, Index atom2) const
BondType | bond (const AtomType &atom1, const AtomType &atom2) const
BondType | bondByUniqueId (Index bondUid) const
Index | bondUniqueId (Index bondId) const
Index | bondUniqueId (const BondType &bond) const
Index | bondCount () const
void | clearBonds ()
Core::Array< BondType > | bonds (const AtomType &atom) const
Core::Array< BondType > | bonds (const Index &atomId) const
const Core::Array< unsigned char > & | bondOrders () const
unsigned char | bondOrder (Index bondId) const
bool | setBondOrders (const Core::Array< unsigned char > &orders)
bool | setBondOrder (Index bondId, unsigned char order)
const Core::Array< std::pair< Index, Index > > & | bondPairs () const
std::pair< Index, Index > | bondPair (Index bondId) const
bool | setBondPairs (const Core::Array< std::pair< Index, Index > > &pairs)
bool | setBondPair (Index bondId, const std::pair< Index, Index > &pair)
void | addUnitCell ()
void | removeUnitCell ()
void | addResidue (const Core::Residue &residue, Index offset=0)
void | modifyMolecule (const Molecule &newMolecule, Molecule::MoleculeChanges changes, const QString &undoText=QStringLiteral("Modify Molecule"))
void | appendMolecule (const Molecule &addMolecule, const QString &undoText=QStringLiteral("Append Molecule"))
void | editUnitCell (Matrix3 cellMatrix, Core::CrystalTools::Options opts)
void | wrapAtomsToCell ()
void | rotateCellToStandardOrientation ()
void | setCellVolume (double newVolume, Core::CrystalTools::Options options)
void | buildSupercell (unsigned int a, unsigned int b, unsigned int c)
void | niggliReduceCell ()
bool | reduceCellToPrimitive (double cartTol=1e-5, double copyTol=0.0)
bool | conventionalizeCell (double cartTol=1e-5, double copyTol=0.0)
bool | symmetrizeCell (double cartTol=1e-5, double copyTol=0.0)
bool | fillUnitCell (unsigned short hallNumber, double cartTol=1e-5, bool allCopies=false)
bool | fillTranslationalCopies (double cartTol=1e-5)
bool | reduceCellToAsymmetricUnit (unsigned short hallNumber, double cartTol=1e-5)
void | beginMergeMode (const QString &undoName=QStringLiteral("Draw"))
void | endMergeMode ()
void | setInteractive (bool b)
| Begin or end an interactive edit.
bool | isInteractive () const
const Core::Array< Vector3 > & | forceVectors () const
bool | setForceVector (Index atomId, const Vector3 &pos, const QString &undoText=QStringLiteral("Change Force Vectors"))
Index | atomUniqueId (Index atomId) const
Index | atomUniqueId (const AtomType &atom) const
bool | removeAtom (Index atomId)
bool | removeAtom (const AtomType &atom)
BondType | addBond (Index atom1, Index atom2, unsigned char order=1)
BondType | addBond (const AtomType &atom1, const AtomType &atom2, unsigned char order=1)
bool | removeBond (Index bondId)
bool | removeBond (const BondType &bond)
bool | removeBond (Index atom1, Index atom2)
bool | removeBond (const AtomType &atom1, const AtomType &atom2)
QUndoStack & | undoStack ()
const QUndoStack & | undoStack () const

## Protected Member Functions

Index | findAtomUniqueId (Index atomId) const
Index | findBondUniqueId (Index bondId) const

## Protected Attributes

Molecule & | m_molecule
| m_molecule still stored all data, this class acts upon it and builds an undo/redo stack that can be used to offer undo and redo.
bool | m_interactive
QUndoStack | m_undoStack

## Detailed Description

This class implements the molecule API and composes a QUndoStack (undoStack()). New undo commands are automatically generated and push each time a non-const method is called.

An interactive mode is supported that causes "noisy" commands, such as atom position changes, to be merged into a single command, saving memory keeping the stack usable during interactive editing of the molecule. Use setInteractive(bool) to toggle interactive mode.

Similarly, multiple sequences of commands can be compressed into a single named action using the QUndoStack's macro capability. Call undoStack().beginMacro(tr("User Description Of Change")) to begin a macro, and undoStack().endMacro() when finished.

## Member Typedef Documentation

## AtomType

typedef RWAtom AtomType

Typedef for Atom class.

## PersistentAtomType

typedef PersistentAtom<RWMolecule> PersistentAtomType

Typedef for PersistentAtom class.

## BondType

typedef RWBond BondType

Typedef for Bond class.

## PersistentBondType

typedef PersistentBond<RWMolecule> PersistentBondType

Typedef for PersistentBond class.

## Constructor & Destructor Documentation

## RWMolecule()

RWMolecule | ( | Molecule & | mol,
|  | QObject * | parent = nullptr )

explicit

Construct a molecule with the atoms/bonds of mol.

## Member Function Documentation

## addAtom() [1/2]

AtomType addAtom | ( | unsigned char | atomicNumber,
|  | bool | usingPositions = true )

Add a new atom to the molecule.

Parameters

  atomicNumber | The atomic number of the new atom.
  usingPositions | Whether or not to use positions for this atom. Default is true. Set to false if the atom will not be using coordinates.

Returns
  The new Atom object.

## addAtom() [2/2]

AtomType addAtom | ( | unsigned char | atomicNumber,
|  | const Vector3 & | position3d )

Add a new atom to the molecule and set its position.

Parameters

  atomicNumber | The atomic number of the new atom.
  position3d | The position of the atom.

Returns
  The new Atom object.

## atom()

RWMolecule::AtomType atom | ( | Index | atomId | ) | const

Obtain an atom object.

Parameters

  atomId | The index of the atom to return.

Returns
  The requested atom object. Will be invalid if atomId >= atomCount().

## atomByUniqueId()

RWMolecule::AtomType atomByUniqueId | ( | Index | atomUId | ) | const

Obtain an atom object from it's unique id.

Parameters

  atomUId | The unique of the requested atom.

Returns
  The requested atom object. Will be invalid if atomUId is not in use.

## atomUniqueId() [1/2]

Index atomUniqueId | ( | Index | atomId | ) | const

Returns
  The unique id of the atom.

## atomUniqueId() [2/2]

Index atomUniqueId | ( | const AtomType & | atom | ) | const

Returns
  The unique id of the atom.

## atomCount() [1/2]

Index atomCount | ( |  | ) | const

Returns
  The number of atoms in the molecule.

## atomCount() [2/2]

Index atomCount | ( | unsigned char | atomicNumber | ) | const

Returns
  The number of atoms in the molecule with the atomic number atomicNumber.

## removeAtom() [1/2]

bool removeAtom | ( | Index | atomId | ) |

Delete the specified atom from this molecule.

Returns
  True on success, false otherwise.

Note
  This also removes all bonds connected to the atom.

## removeAtom() [2/2]

bool removeAtom | ( | const AtomType & | atom | ) |

Delete the specified atom from this molecule.

Returns
  True on success, false otherwise.

Note
  This also removes all bonds connected to the atom.

## clearAtoms()

void clearAtoms | ( |  | ) |

Delete all atoms from this molecule.

Note
  This also removes all bonds.

## adjustHydrogens() [1/2]

void adjustHydrogens | ( | Index | atomId | ) |

Adjust hydrogens for an atom.

Parameters

  atomId | The index of the atom.

Note
  Checks to make sure the atom is valid before adjusting the hydrogens.

## adjustHydrogens() [2/2]

void adjustHydrogens | ( | const Core::Array< Index > & | atomIds | ) |

Adjust hydrogens for multiple atoms.

Parameters

  atomIds | The indices for the atoms.

Note
  Checks to make sure the atoms are valid before adjusting the hydrogens.

## atomicNumbers()

const Core::Array< unsigned char > & atomicNumbers | ( |  | ) | const

Returns
  An array containing atomic numbers for all atoms in the molecule, indexed by atom index.

## atomicNumber()

unsigned char atomicNumber | ( | Index | atomId | ) | const

Get the atomic number for the requested atom.

Parameters

  atomId | The index of the atom.

Returns
  The atomic number of the atom indexed at atomId, or Avogadro::InvalidElement if atomId is invalid.

## setAtomicNumbers()

bool setAtomicNumbers | ( | const Core::Array< unsigned char > & | nums | ) |

Replace the current array of atomic numbers.

Parameters

  nums | The new atomic number array. Must be of length atomCount().

Returns
  True on success, false otherwise.

## setAtomicNumber()

bool setAtomicNumber | ( | Index | atomId,
|  | unsigned char | atomicNumber )

Set the atomic number of a single atom.

Parameters

  atomId | The index of the atom to modify.
  atomicNumber | The new atomic number.

Returns
  True on success, false otherwise.

## atomPositions3d()

const Core::Array< Vector3 > & atomPositions3d | ( |  | ) | const

Returns
  An array containing 3D coordinates for all atoms in the molecule, indexed by atom index.

Note
  May be empty if position information has not been set for any atoms.

## atomPosition3d()

Vector3 atomPosition3d | ( | Index | atomId | ) | const

Get the 3D position of a single atom.

Parameters

  atomId | The index of the atom.

Returns
  The position of the atom, or Vector3::Zero() if no position information has been set.

## setAtomPositions3d()

bool setAtomPositions3d | ( | const Core::Array< Vector3 > & | pos,
|  | const QString & | undoText = tr("Change Atom Positions") )

Replace the current array of 3D atomic coordinates.

Parameters

  pos | The new coordinate array. Must be of length atomCount().
  undoText | The undo text to be displayed for undo commands.

Returns
  True on success, false otherwise.

## setAtomPosition3d()

bool setAtomPosition3d | ( | Index | atomId,
|  | const Vector3 & | pos,
|  | const QString & | undoText = tr("Change Atom Position") )

Set the 3D position of a single atom.

Parameters

  atomId | The index of the atom to modify.
  pos | The new position of the atom.
  undoText | The undo text to be displayed for undo commands.

Returns
  True on success, false otherwise.

## atomLabel()

std::string atomLabel | ( | Index | atomId | ) | const

Get the label on an atom.

Parameters

  atomId | The index of the atom.

Returns
  The label of the atom indexed at atomId, or an empty string if atomId is invalid or has no label.

## setAtomLabel()

bool setAtomLabel | ( | Index | atomId,
|  | const std::string & | label,
|  | const QString & | undoText = tr("Change Atom Label") )

Set the label of a single atom.

Parameters

  atomId | The index of the atom to modify.
  label | The new label.
  undoText | The undo text to be displayed for undo commands.

Returns
  True on success, false otherwise.

## bondLabel()

std::string bondLabel | ( | Index | bondId | ) | const

Get the label on a bond

Parameters

  bondId | The index of the bond.

Returns
  The label of the bond indexed at bondId, or an empty string if bondId is invalid or has no label.

## setBondLabel()

bool setBondLabel | ( | Index | bondId,
|  | const std::string & | label,
|  | const QString & | undoText = tr("Change Bond Label") )

Set the label of a single bond.

Parameters

  bondId | The index of the bond to modify.
  label | The new label.
  undoText | The undo text to be displayed for undo commands.

Returns
  True on success, false otherwise.

## setAtomSelected()

void setAtomSelected | ( | Index | atomId,
|  | bool | selected,
|  | const QString & | undoText = tr("Change Selection") )

Set whether the specified atom is selected or not.

## atomSelected()

bool atomSelected | ( | Index | atomId | ) | const

Query whether the supplied atom index has been selected.

## hybridization()

Core::AtomHybridization hybridization | ( | Index | atomId | ) | const

Get the hybridization for the requested atom.

Parameters

  atomId | The index of the atom.

Returns
  The hybridization of the atom indexed at atomId, or 0 if atomId is invalid.

## setHybridization()

bool setHybridization | ( | Index | atomId,
|  | Core::AtomHybridization | hyb )

Set the hybridization of a single atom.

Parameters

  atomId | The index of the atom to modify.
  hyb | The new hybridization.

Returns
  True on success, false otherwise.

## formalCharge()

signed char formalCharge | ( | Index | atomId | ) | const

Get the formal charge for the requested atom.

Parameters

  atomId | The index of the atom.

Returns
  The formal charge of the atom indexed at atomId, or 0 if atomId is invalid.

## setFormalCharge()

bool setFormalCharge | ( | Index | atomId,
|  | signed char | charge )

Set the formal charge of a single atom.

Parameters

  atomId | The index of the atom to modify.
  charge | The new formal charge.

Returns
  True on success, false otherwise.

## isotope()

unsigned short isotope | ( | Index | atomId | ) | const

Get the isotope for the requested atom.

Parameters

  atomId | The index of the atom.

Returns
  The isotope of the atom indexed at atomId, or 0 if atomId is invalid. (default is 0 for most common isotope)

## setIsotope()

bool setIsotope | ( | Index | atomId,
|  | unsigned short | isotope )

Set the isotope of a single atom.

Parameters

  atomId | The index of the atom to modify.
  isotope | The new isotope

Returns
  True on success, false otherwise.

## color()

Vector3ub color | ( | Index | atomId | ) | const

Get the color for the requested atom.

Parameters

  atomId | The index of the atom.

Returns
  The color of the atom indexed at atomId, or (0, 0, 0) if atomId is invalid. If no color is set for the given atomId, the default color for the atomic number of the atomId is returned.

## setColor()

bool setColor | ( | Index | atomId,
|  | Vector3ub | color )

Set the color of a single atom.

Parameters

  atomId | The index of the atom to modify.
  color | The new color.

Returns
  True on success, false otherwise.

## setResidueColor()

bool setResidueColor | ( | Index | residueId,
|  | Vector3ub | color )

Set the color of a single residue.

Parameters

  residueId | The index of the residue to modify.
  color | The new color.

Returns
  True on success, false otherwise.

## addBond() [1/2]

BondType addBond | ( | Index | atom1,
|  | Index | atom2,
|  | unsigned char | order = 1 )

Create a new bond in the molecule.

Parameters

  atom1 | The first atom in the bond.
  atom2 | The second order in the bond.
  order | The bond order.

Returns
  The new bond object. Will be invalid if atom1 or atom2 does not exist.

## addBond() [2/2]

RWMolecule::BondType addBond | ( | const AtomType & | atom1,
|  | const AtomType & | atom2,
|  | unsigned char | order = 1 )

Create a new bond in the molecule.

Parameters

  atom1 | The first atom in the bond.
  atom2 | The second order in the bond.
  order | The bond order.

Returns
  The new bond object. Will be invalid if atom1 or atom2 does not exist.

## bond() [1/3]

RWMolecule::BondType bond | ( | Index | bondId | ) | const

Get a bond object.

Parameters

  bondId | The index of the requested bond.

Returns
  The requested bond object. Will be invalid if bondId >= bondCount().

## bond() [2/3]

BondType bond | ( | Index | atom1,
|  | Index | atom2 ) const

Get a bond object.

Parameters

  atom1 | The index of one atom in the bond.
  atom2 | The index of the other atom in bond.

Returns
  The requested bond object. Will be invalid if atom1 or atom2 do not exist.

## bond() [3/3]

RWMolecule::BondType bond | ( | const AtomType & | atom1,
|  | const AtomType & | atom2 ) const

Get a bond object.

Parameters

  atom1 | One atom in the bond.
  atom2 | The other atom in bond.

Returns
  The requested bond object. Will be invalid if atom1 or atom2 are invalid.

## bondByUniqueId()

RWMolecule::BondType bondByUniqueId | ( | Index | bondUid | ) | const

Get a bond object from its unique id.

Parameters

  bondUid | The unique id of the bond.

Returns
  The requested bond object. Will be invalid if bondUid is not in use.

## bondUniqueId() [1/2]

Index bondUniqueId | ( | Index | bondId | ) | const

Get the unique id of a bond.

Parameters

  bondId | The index of the requested bond.

Returns
  The unique id currently assigned to the bond at index bondId

## bondUniqueId() [2/2]

Index bondUniqueId | ( | const BondType & | bond | ) | const

Get the unique id of a bond.

Parameters

  bond | The requested bond object.

Returns
  The unique id currently assigned to bond.

## bondCount()

Index bondCount | ( |  | ) | const

Returns
  The number of bonds in the molecule.

## removeBond() [1/4]

bool removeBond | ( | Index | bondId | ) |

Remove the requested bond.

Returns
  True on success, false otherwise.

## removeBond() [2/4]

bool removeBond | ( | const BondType & | bond | ) |

Remove the requested bond.

Returns
  True on success, false otherwise.

## removeBond() [3/4]

bool removeBond | ( | Index | atom1,
|  | Index | atom2 )

Remove the requested bond.

Returns
  True on success, false otherwise.

## removeBond() [4/4]

bool removeBond | ( | const AtomType & | atom1,
|  | const AtomType & | atom2 )

Remove the requested bond.

Returns
  True on success, false otherwise.

## clearBonds()

void clearBonds | ( |  | ) |

Remove all bonds from the molecule.

## bonds() [1/2]

Core::Array< RWMolecule::BondType > bonds | ( | const AtomType & | atom | ) | const

Find bonds connected to an atom.

Parameters

  atom | The atom of interest.

Returns
  An array of bond objects that are attached to the specified atom.

## bonds() [2/2]

Core::Array< RWMolecule::BondType > bonds | ( | const Index & | atomId | ) | const

Find bonds connected to an atom.

Parameters

  atomId | The index for the atom of interest.

Returns
  An array of bond objects that are attached to the specified atom.

## bondOrders()

const Core::Array< unsigned char > & bondOrders | ( |  | ) | const

Returns
  An array of bond orders for all bonds in the molecule, indexed by bond index.

## bondOrder()

unsigned char bondOrder | ( | Index | bondId | ) | const

Get the order of a bond.

Parameters

  bondId | The id of the bond.

Returns
  The bond order.

## setBondOrders()

bool setBondOrders | ( | const Core::Array< unsigned char > & | orders | ) |

Replace the current array of bond orders.

Parameters

  orders | The new array.

Returns
  True on success, false on failure.

## setBondOrder()

bool setBondOrder | ( | Index | bondId,
|  | unsigned char | order )

Set the order of a bond in the molecule.

Parameters

  bondId | The bond's index.
  order | The new order of the bond.

Returns
  True on success, false on failure.

## bondPairs()

const Core::Array< std::pair< Index, Index > > & bondPairs | ( |  | ) | const

Returns
  An array of all bonded atoms in the molecule, indexed by bond index. Each bond pair is represented by a pair of atom indices.

## bondPair()

std::pair< Index, Index > bondPair | ( | Index | bondId | ) | const

Get the set of bonded atoms corresponding to bondId.

Parameters

  bondId | The index of the requested bond.

Returns
  The bonded atom pair, represented as a pair of atom indices.

## setBondPairs()

bool setBondPairs | ( | const Core::Array< std::pair< Index, Index > > & | pairs | ) |

Replace the current array of bonded atoms.

Parameters

  pairs | The array.

Returns
  True on success, false on failure.

Note
  The bonded atoms are represented as a pair of bond indices.
  If needed, the elements in pairs will be modified to ensure that the first atom index is less than the second.

## setBondPair()

bool setBondPair | ( | Index | bondId,
|  | const std::pair< Index, Index > & | pair )

Set the bonded atoms for a bond.

Parameters

  bondId | The bond to modify.
  pair | The new bond pair.

Returns
  True on success, false otherwise.

Note
  If needed, pair will be modified to ensure that the first atom index is less than the second.

## addUnitCell()

void addUnitCell | ( |  | ) |

Add a default unit cell to the molecule. Does nothing if there already is a unit cell. Changes are emitted.

## removeUnitCell()

void removeUnitCell | ( |  | ) |

Remove the unit cell from the molecule. Does nothing if there is no unit cell. Changes are emitted.

## addResidue()

void addResidue | ( | const Core::Residue & | residue,
|  | Index | offset = 0 )

Add a residue to the molecule.

Parameters

  residue | The residue to be added.
  offset | The atomic index offset for the new residue.

## modifyMolecule()

void modifyMolecule | ( | const Molecule & | newMolecule,
|  | Molecule::MoleculeChanges | changes,
|  | const QString & | undoText = QStringLiteral("Modify Molecule") )

Generic edit that changes the current molecule to be newMolecule. Also sets the text for the undo command to be undoText. Changes are emitted.

Parameters

  newMolecule | The new molecule to be set.
  changes | The changes to be emitted.
  undoText | The text description for the undo command.

## appendMolecule()

void appendMolecule | ( | const Molecule & | addMolecule,
|  | const QString & | undoText = QStringLiteral("Append Molecule") )

Generic edit that adds newMolecule to the current molecule. Also sets the text for the undo command to be undoText. Changes are emitted.

Parameters

  addMolecule | The new molecule to be set.
  undoText | The text description for the undo command.

## editUnitCell()

void editUnitCell | ( | Matrix3 | cellMatrix,
|  | Core::CrystalTools::Options | opts )

Edit the unit cell by replacing the current cell matrix with a new cell matrix. Changes are emitted.

Parameters

  cellMatrix | The new cell matrix to be set.
  opts | If TransformAtoms is specified, the atoms in molecule are adjusted so that their fractional (lattice) coordinates are preserved. This option is ignored if the input molecule has no unit cell.

## wrapAtomsToCell()

void wrapAtomsToCell | ( |  | ) |

Wrap atoms to the unit cell. Changes are emitted.

## rotateCellToStandardOrientation()

void rotateCellToStandardOrientation | ( |  | ) |

Rotate cell to standard orientation. Changes are emitted.

## setCellVolume()

void setCellVolume | ( | double | newVolume,
|  | Core::CrystalTools::Options | options )

Scale a cell's volume. Changes are emitted.

Parameters

  newVolume | The new volume to be set.
  options | If CrystalTools::TransformAtoms is set, then the atoms will be transformed during the scaling.

## buildSupercell()

void buildSupercell | ( | unsigned int | a,
|  | unsigned int | b,
|  | unsigned int | c )

Build a supercell. Changes are emitted.

Parameters

  a | The final number of units along the A vector (at least 1).
  b | The final number of units along the B vector (at least 1).
  c | The final number of units along the C vector (at least 1).

## niggliReduceCell()

void niggliReduceCell | ( |  | ) |

Perform a Niggli reduction on the cell. Changes are emitted.

## reduceCellToPrimitive()

bool reduceCellToPrimitive | ( | double | cartTol = 1e-5,
|  | double | copyTol = 0.0 )

Use spglib to reduce the cell to its primitive form. Changes are emitted.

Parameters

  cartTol | Cartesian tolerance for primitive reduction.
  copyTol | If > 0, add translational boundary copies with this tolerance in the same undo step.

Returns
  True if the algorithm succeeded, and false if it failed.

## conventionalizeCell()

bool conventionalizeCell | ( | double | cartTol = 1e-5,
|  | double | copyTol = 0.0 )

Use spglib to convert the cell to its conventional form. Changes are emitted.

Parameters

  cartTol | Cartesian tolerance for conventionalization.
  copyTol | If > 0, add translational boundary copies with this tolerance in the same undo step.

Returns
  True if the algorithm succeeded, and false if it failed.

## symmetrizeCell()

bool symmetrizeCell | ( | double | cartTol = 1e-5,
|  | double | copyTol = 0.0 )

Use spglib to symmetrize the cell. Changes are emitted.

Parameters

  cartTol | Cartesian tolerance for symmetrization.
  copyTol | If > 0, add translational boundary copies with this tolerance in the same undo step.

Returns
  True if the algorithm succeeded, and false if it failed.

## fillUnitCell()

bool fillUnitCell | ( | unsigned short | hallNumber,
|  | double | cartTol = 1e-5,
|  | bool | allCopies = false )

Fill unit cell using transforms for the space group. Changes are emitted.

Parameters

  hallNumber | The hall number to be used for transforming the cell.
  cartTol | Cartesian tolerance for comparing atom positions.
  allCopies | If true, all copies will be filled (i.e. edges and corners)

Returns
  True if the algorithm succeeded, and false if it failed.

## fillTranslationalCopies()

bool fillTranslationalCopies | ( | double | cartTol = 1e-5 | ) |

Add translational copies of atoms on the unit cell boundary without applying symmetry operations. Changes are emitted.

Parameters

  cartTol | Cartesian tolerance for comparing atom positions.

Returns
  True if the algorithm succeeded, and false if it failed.

## reduceCellToAsymmetricUnit()

bool reduceCellToAsymmetricUnit | ( | unsigned short | hallNumber,
|  | double | cartTol = 1e-5 )

Use transforms to reduce a cell to its asymmetric unit. Changes are emitted.

Parameters

  hallNumber | The hall number to be used for obtaining the transforms.
  cartTol | Cartesian tolerance for comparing atom positions.

Returns
  True if the algorithm succeeded, and false if it failed.

## beginMergeMode()

void beginMergeMode | ( | const QString & | undoName = QStringLiteral("Draw") | ) |

Call this function when you wish to merge all undo commands. It turns on interactive mode to merge similar undo commands in a series (in order to save space), and it uses QUndoStack's beginMacro() to merge dissimilar undo commands together. You must call endMergeMode() to end the merging section (undo and redo are unavailable while merge mode is on).

Parameters

  undoName | The name of the undo command

## endMergeMode()

void endMergeMode | ( |  | ) |

Call this function when you wish merge mode to end. This will turn off interactive mode, and it will call QUndoStack's endMacro(). All of the undo commands pushed between beginMergeMode() and endMergeMode() will be merged into one undo command. beginMergeMode() should have been called before this is called.

## setInteractive()

void setInteractive | ( | bool | b | ) |

If enabled, certain undo operations will be merged together. For instance, an editor dragging an atom through space in response to mouse movement will only generate a single undo command containing the initial and final positions and discard the intermediate states. If disabled, each intermediate action will appear in the undo log.

## isInteractive()

bool isInteractive | ( |  | ) | const

Returns
  True if interactive mode is enabled, false otherwise.

See also
  setInteractive

## undoStack() [1/2]

QUndoStack & undoStack | ( |  | ) |

Returns
  The QUndoStack for this molecule.

## undoStack() [2/2]

const QUndoStack & undoStack | ( |  | ) | const

Returns
  The QUndoStack for this molecule.

## forceVectors()

const Core::Array< Vector3 > & forceVectors | ( |  | ) | const

Returns a vector of forces for the atoms in the molecule.

## setForceVector()

bool setForceVector | ( | Index | atomId,
|  | const Vector3 & | pos,
|  | const QString & | undoText = QStringLiteral("Change Force Vectors") )

Replace the current array of force vectors.

Parameters

  pos | The new force vector array. Must be of length atomCount().
  undoText | The undo text to be displayed for undo commands.

Returns
  True on success, false otherwise.

## emitChanged

void emitChanged | ( | unsigned int | change | ) |

slot

Parameters

  change | See changed().

## changed

void changed | ( | unsigned int | change | ) |

signal

Parameters

  change | Use the MoleculeChange enum to check what 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.

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

- rwmolecule.h