Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp	(revision 2f7988dfca2f351ead05e5302eafd42b83b2f353)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp	(revision 65c3231ff9731698df9e1c840c3c6b5d4c56b2cf)
@@ -45,9 +45,7 @@
 
 #include <algorithm>
-#include <boost/assign.hpp>
 
 #include "Atom/atom.hpp"
 #include "Bond/bond.hpp"
-#include "Descriptors/AtomIdDescriptor.hpp"
 #include "Element/element.hpp"
 #include "Element/periodentafel.hpp"
@@ -56,56 +54,13 @@
 #include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp"
 #include "World.hpp"
-#include "WorldTime.hpp"
-
-#include "ObservedValue_wCallback.hpp"
-
-using namespace boost::assign;
-
-static const Observable::channels_t getAtomBondsChannels()
-{
-  Observable::channels_t channels;
-  channels += AtomObservable::BondsAdded, AtomObservable::BondsRemoved;
-  return channels;
-}
-
-static const Observable::channels_t getAllObservedChannels()
-{
-  Observable::channels_t channels;
-  channels +=
-      AtomObservable::IndexChanged,
-      AtomObservable::PositionChanged,
-      AtomObservable::ElementChanged,
-      AtomObservable::BondsAdded,
-      AtomObservable::BondsRemoved;
-  return channels;
-}
-
-// static entities
-const Observable::channels_t
-GLMoleculeObject_atom::AtomIndexChannels(1, AtomObservable::IndexChanged);
-const Observable::channels_t
-GLMoleculeObject_atom::AtomPositionChannels(1, AtomObservable::PositionChanged);
-const Observable::channels_t
-GLMoleculeObject_atom::AtomElementChannels(1, AtomObservable::ElementChanged);
-const Observable::channels_t
-GLMoleculeObject_atom::AtomBondsChannels(getAtomBondsChannels());
 
 GLMoleculeObject_atom::GLMoleculeObject_atom(
     QGLSceneNode *mesh[],
     QObject *parent,
-    const atomId_t _id,
-    QtObservedInstanceBoard * _board,
-    std::vector<boost::any> _ObservedValues) :
+    QtObservedAtom::ptr _ObservedAtom) :
   GLMoleculeObject(mesh, parent),
-  Observer(std::string("GLMoleculeObject_atom")+toString(_id)),
-  atomref(getAtom(_id)),
-  ObservedValues(_ObservedValues),
-  subjectKilledCount(0),
-  owner(NULL),
-  AllsignedOnChannels(getAllObservedChannels().size()),
-  signedOnChannels(0),
-  board(_board)
+  ObservedAtom(_ObservedAtom)
 {
-  init(_id);
+  init(ObservedAtom->getAtomIndex());
 }
 
@@ -118,15 +73,9 @@
   m_selected = const_cast<const World &>(World::getInstance()).isAtomSelected(_id);
 
-  // sign On
-  activateObserver();
-
-  // atomref is only used for caching the ref, it must be used elswhere
-  const_cast<atom *&>(atomref) = NULL;
-
   connect( this, SIGNAL(clicked()), this, SLOT(wasClicked()));
-  connect( this, SIGNAL(idChanged()), this, SLOT(resetIndex()), Qt::QueuedConnection);
-  connect( this, SIGNAL(elementChanged()), this, SLOT(resetElement()), Qt::QueuedConnection);
-  connect( this, SIGNAL(positionChanged()), this, SLOT(resetPosition()), Qt::QueuedConnection);
-  connect( this, SIGNAL(bondsChanged()), this, SLOT(resetPosition()), Qt::QueuedConnection);
+  connect( ObservedAtom.get(), SIGNAL(indexChanged()), this, SLOT(resetIndex()));
+  connect( ObservedAtom.get(), SIGNAL(elementChanged()), this, SLOT(resetElement()));
+  connect( ObservedAtom.get(), SIGNAL(positionChanged()), this, SLOT(resetPosition()));
+  connect( ObservedAtom.get(), SIGNAL(bondsChanged()), this, SLOT(resetPosition()));
 
   // use that ObservedValues::AtomBonds is always up-to-date
@@ -134,38 +83,10 @@
 }
 
-void GLMoleculeObject_atom::activateObserver()
-{
-  if (atomref != NULL) {
-    Observable::channels_t channels = getAllObservedChannels();
-    owner = static_cast<const Observable *>(atomref);
-    for (Observable::channels_t::const_iterator iter = channels.begin();
-        iter != channels.end(); ++iter)
-      owner->signOn(this, *iter);
-  }
-}
-
-
-void GLMoleculeObject_atom::deactivateObserver()
-{
-  // sign Off
-  if (owner != NULL) {
-    Observable::channels_t channels = getAllObservedChannels();
-    for (Observable::channels_t::const_iterator iter = channels.begin();
-        iter != channels.end(); ++iter)
-      owner->signOff(this, *iter);
-    owner = NULL;
-    signedOnChannels = 0;
-  }
-}
-
 GLMoleculeObject_atom::~GLMoleculeObject_atom()
-{
-  deactivateObserver();
-  board->returnAtomObservedValues(getAtomIndex(), ObservedValues);
-}
+{}
 
 void GLMoleculeObject_atom::resetIndex()
 {
-  const atomId_t newId = getAtomIndex();
+  const atomId_t newId = ObservedAtom->getAtomIndex();
   const size_t oldId = objectId();
   ASSERT( newId != oldId,
@@ -173,11 +94,9 @@
   LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new index is "+toString(newId)+".");
   setObjectId(newId);
-
-  emit indexChanged(this, oldId, newId);
 }
 
 void GLMoleculeObject_atom::resetPosition()
 {
-  const Vector Position = getAtomPosition();
+  const Vector Position = ObservedAtom->getAtomPosition();
   LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new position is "+toString(Position)+".");
   setPosition(QVector3D(Position[0], Position[1], Position[2]));
@@ -188,5 +107,5 @@
   size_t elementno = 0;
   const element * const _type = World::getInstance().
-      getPeriode()->FindElement(getAtomElement());
+      getPeriode()->FindElement(ObservedAtom->getAtomElement());
   if (_type != NULL) {
     elementno = _type->getAtomicNumber();
@@ -214,24 +133,24 @@
 void GLMoleculeObject_atom::resetBonds()
 {
-  ListOfBonds_t ListOfBonds_new = getAtomBonds();
+  QtObservedAtom::ListOfBonds_t ListOfBonds_new = ObservedAtom->getAtomBonds();
   std::sort(ListOfBonds_new.begin(), ListOfBonds_new.end());
-  ListOfBonds_t BondsToAdd;
+  QtObservedAtom::ListOfBonds_t BondsToAdd;
   std::set_difference(
       ListOfBonds_new.begin(), ListOfBonds_new.end(),
       ListOfBonds.begin(), ListOfBonds.end(),
       std::back_inserter(BondsToAdd));
-  ListOfBonds_t BondsToRemove;
+  QtObservedAtom::ListOfBonds_t BondsToRemove;
   std::set_difference(
       ListOfBonds.begin(), ListOfBonds.end(),
       ListOfBonds_new.begin(), ListOfBonds_new.end(),
       std::back_inserter(BondsToRemove));
-  for (ListOfBonds_t::const_iterator iter = BondsToAdd.begin();
+  for (QtObservedAtom::ListOfBonds_t::const_iterator iter = BondsToAdd.begin();
       iter != BondsToAdd.end();
       ++iter) {
-    const GLMoleculeObject_bond::SideOfBond side = (iter->first == getAtomIndex()) ?
+    const GLMoleculeObject_bond::SideOfBond side = (iter->first == ObservedAtom->getAtomIndex()) ?
         GLMoleculeObject_bond::left : GLMoleculeObject_bond::right;
     emit BondsAdded(iter->first, iter->second, side);
   }
-  for (ListOfBonds_t::const_iterator iter = BondsToRemove.begin();
+  for (QtObservedAtom::ListOfBonds_t::const_iterator iter = BondsToRemove.begin();
       iter != BondsToRemove.end();
       ++iter) {
@@ -268,209 +187,6 @@
 void GLMoleculeObject_atom::wasClicked()
 {
-  LOG(4, "INFO: GLMoleculeObject_atom: atom " << getAtomIndex() << " has been clicked");
-  emit clicked(getAtomIndex());
+  LOG(4, "INFO: GLMoleculeObject_atom: atom "
+      << ObservedAtom->getAtomIndex() << " has been clicked");
+  emit clicked(ObservedAtom->getAtomIndex());
 }
-
-const atom * const GLMoleculeObject_atom::getAtomConst(const atomId_t _id)
-{
-  const atom * const _atom = const_cast<const World &>(World::getInstance()).
-      getAtom(AtomById(_id));
-  return _atom;
-}
-
-atom * const GLMoleculeObject_atom::getAtom(const atomId_t _id)
-{
-  atom * const _atom = World::getInstance().getAtom(AtomById(_id));
-  return _atom;
-}
-
-atomId_t GLMoleculeObject_atom::updateIndex()
-{
-  return const_cast<const World &>(World::getInstance()).lastChangedAtomId();
-}
-
-Vector GLMoleculeObject_atom::updatePosition(
-    const boost::function<const atomId_t ()> &_getAtomIndex)
-{
-  const atom * const _atom = getAtomConst(_getAtomIndex());
-  if (_atom != NULL) {
-    return _atom->getPosition();
-  } else {
-    return zeroVec;
-  }
-}
-
-atomicNumber_t GLMoleculeObject_atom::updateElement(
-    const boost::function<const atomId_t ()> &_getAtomIndex)
-{
-  const atom * const _atom = getAtomConst(_getAtomIndex());
-  if (_atom != NULL) {
-    return _atom->getElementNo();
-  } else {
-    return (atomicNumber_t)-1;
-  }
-}
-
-GLMoleculeObject_atom::ListOfBonds_t GLMoleculeObject_atom::updateBonds(
-    const boost::function<const atomId_t ()> &_getAtomIndex)
-{
-  ListOfBonds_t ListOfBonds;
-  const atom * const _atom = getAtomConst(_getAtomIndex());
-  if (_atom != NULL) {
-    // make sure bonds is up-to-date
-    const BondList ListBonds = _atom->getListOfBonds();
-    for (BondList::const_iterator iter = ListBonds.begin();
-        iter != ListBonds.end();
-        ++iter)
-      ListOfBonds.insert( ListOfBonds.end(), std::make_pair(
-          (*iter)->leftatom->getId(),
-          (*iter)->rightatom->getId()) );
-  } else {
-    ELOG(2, "Atom with id "+toString(_getAtomIndex())+" is already gone.");
-  }
-  return ListOfBonds;
-}
-
-void GLMoleculeObject_atom::update(Observable *publisher)
-{
-  ASSERT(0, "GLMoleculeObject_atom::update() - we are not signed on for global updates.");
-}
-
-void GLMoleculeObject_atom::subjectKilled(Observable *publisher)
-{
-  ++signedOnChannels;
-
-  if (signedOnChannels == AllsignedOnChannels) {
-    // remove owner: no more signOff needed
-    owner = NULL;
-
-    board->atomcountsubjectKilled(getAtomIndex());
-  }
-}
-
-void GLMoleculeObject_atom::recieveNotification(Observable *publisher, Notification_ptr notification)
-{
-  // ObservedValues have been updated before, hence convert updates to Qt's signals
-  atom * const _atom = dynamic_cast<atom *>(publisher);
-  if (_atom != NULL) {
-    switch (notification->getChannelNo()) {
-      case AtomObservable::IndexChanged:
-        emit idChanged();
-        break;
-      case AtomObservable::PositionChanged:
-        emit positionChanged();
-        break;
-      case AtomObservable::ElementChanged:
-        emit elementChanged();
-        break;
-      case AtomObservable::BondsAdded:
-      case AtomObservable::BondsRemoved:
-        emit bondsChanged();
-        break;
-      default:
-        ASSERT(0, "GLMoleculeObject_atom::recieveNotification() - we are not signed on to channel "
-            +toString(notification->getChannelNo())+" of the atom.");
-        break;
-    }
-  } else
-    ASSERT(0, "GLMoleculeObject_atom::recieveNotification() - received notification from unexpected source.");
-}
-
-void GLMoleculeObject_atom::initObservedValues(
-    std::vector<boost::any> &_ObservedValues,
-    const atomId_t _id,
-    const atom * const _atomref,
-    const boost::function<void(const atomId_t)> &_subjectKilled)
-{
-  /* This is an old note from when the code was still part of cstor's initializer body.
-   * TODO: Probably does not apply anymore but has not yet been tested.
-   *
-   * We must not use boost::cref(this) as "this" has not been properly constructed and seemingly
-   * boost::cref tries to do some magic to grasp the inheritance hierarchy which fails because
-   * the class has not been fully constructed yet. "This" itself seems to be working fine.
-   */
-
-  ASSERT( _ObservedValues.size() == MAX_ObservedTypes,
-      "GLMoleculeObject_atom::initObservedValues() - given ObservedValues has not correct size.");
-
-  // fill ObservedValues: index first
-  const boost::function<atomId_t ()> AtomIndexUpdater(
-      boost::bind(&GLMoleculeObject_atom::updateIndex));
-
-  ObservedValue_wCallback<atomId_t> * const IndexObservable =
-      new ObservedValue_wCallback<atomId_t>(
-          _atomref,
-          boost::bind(&GLMoleculeObject_atom::updateIndex),
-          "AtomIndex_"+toString(_id),
-          _id,
-          AtomIndexChannels,
-          _subjectKilled);
-  _ObservedValues[AtomIndex] = IndexObservable;
-
-  const boost::function<const atomId_t ()> AtomIndexGetter =
-      boost::bind(&ObservedValue_wCallback<atomId_t>::get,
-          IndexObservable);
-
-  // fill ObservedValues: then all the other that need index
-  const boost::function<Vector ()> AtomPositionUpdater(
-      boost::bind(&GLMoleculeObject_atom::updatePosition, AtomIndexGetter));
-  const boost::function<atomicNumber_t ()> AtomElementUpdater(
-      boost::bind(&GLMoleculeObject_atom::updateElement, AtomIndexGetter));
-  const boost::function<ListOfBonds_t ()> AtomBondsUpdater(
-      boost::bind(&GLMoleculeObject_atom::updateBonds, AtomIndexGetter));
-
-  _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector, atomId_t>(
-      _atomref,
-      AtomPositionUpdater,
-      "AtomPosition_"+toString(_id),
-      AtomPositionUpdater(),
-      AtomPositionChannels,
-      _subjectKilled,
-      AtomIndexGetter);
-  _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, atomId_t>(
-      _atomref,
-      AtomElementUpdater,
-      "AtomElement"+toString(_id),
-      AtomElementUpdater(),
-      AtomElementChannels,
-      _subjectKilled,
-      AtomIndexGetter);
-  _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, atomId_t>(
-      _atomref,
-      AtomBondsUpdater,
-      "AtomBonds_"+toString(_id),
-      AtomBondsUpdater(),
-      AtomBondsChannels,
-      _subjectKilled,
-      AtomIndexGetter);
-}
-
-void GLMoleculeObject_atom::destroyObservedValues(
-    std::vector<boost::any> &_ObservedValues)
-{
-  delete boost::any_cast<ObservedValue_wCallback<atomId_t> *>(_ObservedValues[AtomIndex]);
-  delete boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(_ObservedValues[AtomPosition]);
-  delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(_ObservedValues[AtomElement]);
-  delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(_ObservedValues[AtomBonds]);
-  _ObservedValues.clear();
-}
-
-atomId_t GLMoleculeObject_atom::getAtomIndex() const
-{
-  return boost::any_cast<ObservedValue_wCallback<atomId_t> *>(ObservedValues[AtomIndex])->get();
-}
-
-Vector GLMoleculeObject_atom::getAtomPosition() const
-{
-  return boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[AtomPosition])->get();
-}
-
-atomicNumber_t GLMoleculeObject_atom::getAtomElement() const
-{
-  return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[AtomElement])->get();
-}
-
-GLMoleculeObject_atom::ListOfBonds_t GLMoleculeObject_atom::getAtomBonds() const
-{
-  return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(ObservedValues[AtomBonds])->get();
-}
Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp	(revision 2f7988dfca2f351ead05e5302eafd42b83b2f353)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp	(revision 65c3231ff9731698df9e1c840c3c6b5d4c56b2cf)
@@ -20,10 +20,7 @@
 
 #include "CodePatterns/ObservedValue.hpp"
-#include "CodePatterns/Observer/Observer.hpp"
 
-#include "LinearAlgebra/Vector.hpp"
-
-#include "Bond/bond.hpp"
 #include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp"
+#include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp"
 #include "types.hpp"
 
@@ -31,5 +28,5 @@
 class QtObservedInstanceBoard;
 
-class GLMoleculeObject_atom : public GLMoleculeObject, Observer
+class GLMoleculeObject_atom : public GLMoleculeObject
 {
   Q_OBJECT
@@ -38,16 +35,9 @@
       QGLSceneNode *mesh[],
       QObject *parent,
-      const atomId_t id,
-      QtObservedInstanceBoard * _board,
-      std::vector<boost::any> _ObservedValues
+      QtObservedAtom::ptr _ObservedAtom
       );
   virtual ~GLMoleculeObject_atom();
 
   void draw(QGLPainter *painter, const QVector4D &cameraPlane);
-
-  // Observer functions
-  void update(Observable *publisher);
-  void subjectKilled(Observable *publisher);
-  void recieveNotification(Observable *publisher, Notification_ptr notification);
 
 public slots:
@@ -67,127 +57,13 @@
   void BondsRemoved(const atomId_t _left, const atomId_t _right);
   void indexChanged(GLMoleculeObject_atom *ob, const atomId_t oldId, const atomId_t newId);
-  void idChanged();
-  void positionChanged();
-  void elementChanged();
-  void bondsChanged();
 
 private:
-  //!> grant GLMoleculeObject_molecule acess to reset functions
-  friend class GLMoleculeObject_molecule;
-
-  //!> typedef for list of bonds, defined by pairs of atom ids
-  typedef std::vector< std::pair<atomId_t, atomId_t> > ListOfBonds_t;
-
-  static const atom * const getAtomConst(const atomId_t _id);
-  static atom * const getAtom(const atomId_t _id);
-
-  static atomId_t updateIndex();
-  static Vector updatePosition(
-      const boost::function<const atomId_t ()> &_getAtomIndex);
-  static atomicNumber_t updateElement(
-      const boost::function<const atomId_t ()> &_getAtomIndex);
-  static ListOfBonds_t updateBonds(
-      const boost::function<const atomId_t ()> &_getAtomIndex);
-
-  void activateObserver();
-  void deactivateObserver();
-
   void init(const atomId_t _id);
 
 private:
+  //!> current list of bonds to compare new onw against for changes
+  QtObservedAtom::ListOfBonds_t ListOfBonds;
 
-  //!> current list of bonds to compare new onw against for changes
-  ListOfBonds_t ListOfBonds;
-
-  //!> temporary variable used in cstor
-  atom * const atomref;
-
-private:
-  friend class QtObservedInstanceBoard;
-  /** Observed Values **/
-
-  //!> enumeration of observed values to match with entries in ObservedValues
-  enum ObservedTypes {
-    //!> contains the current atom index
-    AtomIndex,
-    //!> contains the current atom position
-    AtomPosition,
-    //!> contains the current atom element
-    AtomElement,
-    //!> contains the current set of bonds atoms fort the atom
-    AtomBonds,
-    //!> gives the size of the enumeration
-    MAX_ObservedTypes
-  };
-
-  //!> vector with all observed values
-  std::vector<boost::any> ObservedValues;
-
-  /** Initializes all \a ObservedValues entries.
-   *
-   * \param _ObservedValues vector of ObservedValue to be filled
-   * \param _id atom id
-   * \param _atomref reference to atom
-   * \param _subjectKilled ref to function to call on subjectKilled()
-   */
-  static void initObservedValues(
-      std::vector<boost::any> &_ObservedValues,
-      const atomId_t _id,
-      const atom * const _atomref,
-      const boost::function<void(const atomId_t)> &_subjectKilled);
-
-  /** Destroys all \a ObservedValues entries.
-   *
-   * \param _ObservedValues vector of ObservedValue to be destroyed
-   */
-  static void destroyObservedValues(
-      std::vector<boost::any> &_ObservedValues);
-
-  /** Getter to atom index contained in \a ObservedValues.
-   *
-   * \return atom's index
-   */
-  atomId_t getAtomIndex() const;
-
-  /** Getter to atom position contained in \a ObservedValues.
-   *
-   * \return atom's position
-   */
-  Vector getAtomPosition() const;
-
-  /** Getter to atom element contained in \a ObservedValues.
-   *
-   * \return atom's elemnt
-   */
-  atomicNumber_t getAtomElement() const;
-
-  /** Getter to atom bonds contained in \a ObservedValues.
-   *
-   * \return atom's bonds
-   */
-  ListOfBonds_t getAtomBonds() const;
-
-  //!> counts how many ObservedValues have already been subjectKilled()
-  mutable size_t subjectKilledCount;
-
-private:
-
-  //!> list of channels when index needs to update
-  static const Observable::channels_t AtomIndexChannels;
-  //!> list of channels when position needs to update
-  static const Observable::channels_t AtomPositionChannels;
-  //!> list of channels when element needs to update
-  static const Observable::channels_t AtomElementChannels;
-  //!> list of channels when bonds needs to update
-  static const Observable::channels_t AtomBondsChannels;
-
-  //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
-  const Observable *owner;
-
-  //!> we get multiple subjectKilled(), count and call callback() only on last
-  const unsigned int AllsignedOnChannels;
-  unsigned int signedOnChannels;
-
-  QtObservedInstanceBoard * board;
+  QtObservedAtom::ptr ObservedAtom;
 };
 
Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp	(revision 2f7988dfca2f351ead05e5302eafd42b83b2f353)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp	(revision 65c3231ff9731698df9e1c840c3c6b5d4c56b2cf)
@@ -573,7 +573,5 @@
           GLMoleculeObject::meshSphere,
           this,
-          _id,
-          board,
-          board->getAtomObservedValues(_id));
+          board->getObservedAtom(_id));
   ASSERT( atomObject != NULL,
       "GLMoleculeObject_molecule::atomInserted - could not create atom object for "+toString(_id));
