Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp

    rce4126 rf115cc  
    5656  GLMoleculeObject(mesh, parent),
    5757  Observer(std::string("GLMoleculeObject_atom")+toString(_id)),
    58   atomicid(_id)
     58  atomicid(_id),
     59  uptodatePosition(false),
     60  uptodateElement(false)
    5961{
    6062  // sign on as observer (obtain non-const instance before)
     
    108110    ELOG(2, "Atom with id "+toString(atomicid)+" is already gone.");
    109111  }
     112  uptodatePosition = true;
    110113}
    111114
     
    141144  }
    142145  setScale( radius / 4. );
     146
     147  uptodateElement = true;
    143148}
    144149
     
    165170  // selected?
    166171  setSelected(World::getInstance().isAtomSelected(atomicid));
     172}
     173
     174void GLMoleculeObject_atom::draw(QGLPainter *painter, const QVector4D &cameraPlane)
     175{
     176  // hook to update prior to painting
     177  if (!uptodatePosition)
     178    resetPosition();
     179  if (!uptodateElement)
     180    resetElement();
     181
     182  // call old hook to do the actual paining
     183  GLMoleculeObject::draw(painter, cameraPlane);
    167184}
    168185
     
    185202    switch (notification->getChannelNo()) {
    186203      case AtomObservable::ElementChanged:
    187         resetElement();
    188         emit changed();
     204        uptodateElement = false;
    189205        break;
    190206      case AtomObservable::IndexChanged:
     
    192208        break;
    193209      case AtomObservable::PositionChanged:
    194         resetPosition();
    195         emit changed();
     210        uptodatePosition = false;
    196211        break;
    197212      case AtomObservable::BondsAdded:
     
    199214        const atom *_atom = World::getInstance().getAtom(AtomById(atomicid));
    200215        if (_atom != NULL) {
     216          // make sure position is up-to-date
     217          if (!uptodatePosition)
     218            resetPosition();
    201219          ASSERT(!_atom->getListOfBonds().empty(),
    202220              "GLMoleculeObject_atom::recieveNotification() - received BondsAdded but ListOfBonds is empty.");
Note: See TracChangeset for help on using the changeset viewer.