Exemplo n.º 1
0
void MoleculeWatcher::atomChanged(const Atom *atom, Molecule::ChangeType changeType)
{
    switch(changeType){
        case Molecule::AtomAdded:
            Q_EMIT atomAdded(atom);
            break;
        case Molecule::AtomRemoved:
            Q_EMIT atomRemoved(atom);
            break;
        case Molecule::AtomAtomicNumberChanged:
            Q_EMIT atomAtomicNumberChanged(atom);
            break;
        case Molecule::AtomPositionChanged:
            Q_EMIT atomPositionChanged(atom);
            break;
        default:
            break;
    }
}
Exemplo n.º 2
0
  void Molecule::removeAtom(Atom *atom)
  {
    if(atom) {
      // When deleting an atom this also implicitly deletes any bonds to the atom
      foreach (unsigned long bond, atom->bonds()) {
        removeBond(bond);
      }

      m_atoms[atom->id()] = 0;
      // 1 based arrays stored/shown to user
      int index = atom->index();
      m_atomList.removeAt(index);
      for (int i = index; i < m_atomList.size(); ++i)
        m_atomList[i]->setIndex(i);
      atom->deleteLater();

      disconnect(atom, SIGNAL(updated()), this, SLOT(updateAtom()));
      emit atomRemoved(atom);
    }
  }