Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.cpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.cpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
@@ -0,0 +1,206 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * GLMoleculeObject.cpp
+ *
+ *  This is based on the Qt3D example "teaservice", specifically meshobject.cpp.
+ *
+ *  Created on: Aug 17, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "GLMoleculeObject.hpp"
+
+#include <Qt3D/qglview.h>
+#include <Qt3D/qglscenenode.h>
+#include <Qt3D/qglpainter.h>
+#include <Qt3D/qglmaterial.h>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "CodePatterns/Assert.hpp"
+#include "CodePatterns/Log.hpp"
+
+#include "Helpers/defs.hpp"
+#include "element.hpp"
+#include "periodentafel.hpp"
+#include "World.hpp"
+
+GLMoleculeObject::ElementMaterialMap GLMoleculeObject::ElementNoMaterialMap;
+
+
+#include "CodePatterns/MemDebug.hpp"
+
+
+GLMoleculeObject::GLMoleculeObject(QGLSceneNode *GLMoleculeObject, QObject *parent)
+   : QObject(parent)
+{
+   m_mesh = 0;
+   m_GLMoleculeObject = GLMoleculeObject;
+   m_scale = 1.0f;
+   m_rotationAngle = 0.0f;
+   m_effect = 0;
+   m_objectId = -1;
+   m_hovering = false;
+   m_material = 0;
+   m_hoverMaterial = 0;
+}
+
+GLMoleculeObject::GLMoleculeObject(QGLAbstractScene *scene, QObject *parent)
+   : QObject(parent)
+{
+   scene->setParent(this);
+   m_mesh = 0;
+   m_GLMoleculeObject = scene->mainNode();
+   m_scale = 1.0f;
+   m_rotationAngle = 0.0f;
+   m_effect = 0;
+   m_objectId = -1;
+   m_hovering = false;
+   m_material = 0;
+   m_hoverMaterial = 0;
+}
+
+GLMoleculeObject::~GLMoleculeObject()
+{
+   delete m_mesh;
+}
+
+void GLMoleculeObject::initialize(QGLView *view, QGLPainter *painter)
+{
+   Q_UNUSED(painter);
+   if (m_objectId != -1)
+       view->registerObject(m_objectId, this);
+}
+
+void GLMoleculeObject::draw(QGLPainter *painter)
+{
+   // Position the model at its designated position, scale, and orientation.
+   painter->modelViewMatrix().push();
+   painter->modelViewMatrix().translate(m_position);
+   if (m_scale != 1.0f)
+       painter->modelViewMatrix().scale(m_scale);
+   if (m_rotationAngle != 0.0f)
+       painter->modelViewMatrix().rotate(m_rotationAngle, m_rotationVector);
+
+   // Apply the material and effect to the painter.
+   QGLMaterial *material;
+   if (m_hovering)
+       material = m_hoverMaterial;
+   else
+       material = m_material;
+   painter->setColor(material->diffuseColor());
+   painter->setFaceMaterial(QGL::AllFaces, material);
+   if (m_effect)
+       painter->setUserEffect(m_effect);
+   else
+       painter->setStandardEffect(QGL::LitMaterial);
+
+   // Mark the object for object picking purposes.
+   int prevObjectId = painter->objectPickId();
+   if (m_objectId != -1)
+       painter->setObjectPickId(m_objectId);
+
+   // Draw the geometry mesh.
+   if (m_GLMoleculeObject)
+       m_GLMoleculeObject->draw(painter);
+   else
+       m_mesh->draw(painter);
+
+   // Turn off the user effect, if present.
+   if (m_effect)
+       painter->setStandardEffect(QGL::LitMaterial);
+
+   // Revert to the previous object identifier.
+   painter->setObjectPickId(prevObjectId);
+
+   // Restore the modelview matrix.
+   painter->modelViewMatrix().pop();
+}
+
+bool GLMoleculeObject::event(QEvent *e)
+{
+   // Convert the raw event into a signal representing the user's action.
+   if (e->type() == QEvent::MouseButtonPress) {
+       QMouseEvent *me = (QMouseEvent *)e;
+       if (me->button() == Qt::LeftButton)
+           emit pressed();
+   } else if (e->type() == QEvent::MouseButtonRelease) {
+       QMouseEvent *me = (QMouseEvent *)e;
+       if (me->button() == Qt::LeftButton) {
+           emit released();
+           if (me->x() >= 0)   // Positive: inside object, Negative: outside.
+               emit clicked();
+       }
+   } else if (e->type() == QEvent::MouseButtonDblClick) {
+       emit doubleClicked();
+   } else if (e->type() == QEvent::Enter) {
+       m_hovering = true;
+       emit hoverChanged();
+   } else if (e->type() == QEvent::Leave) {
+       m_hovering = false;
+       emit hoverChanged();
+   }
+   return QObject::event(e);
+}
+
+/** Returns the ref to the Material for element No \a from the map.
+ *
+ * \note We create a new one if the element is missing.
+ *
+ * @param no element no
+ * @return ref to QGLMaterial
+ */
+QGLMaterial* GLMoleculeObject::getMaterial(size_t no)
+{
+  ASSERT( (no >= 0) && (no < MAX_ELEMENTS),
+      "GLMoleculeView::getMaterial() - Element no "+toString(no)+" is invalid.");
+  if (ElementNoMaterialMap.find(no) != ElementNoMaterialMap.end()){
+    // get present one
+    return ElementNoMaterialMap[no];
+  } else {
+    // create new one
+    LOG(1, "Creating new material for element "+toString(no)+".");
+    QGLMaterial *newmaterial = new QGLMaterial(NULL);
+
+    if (no == 0) { // create hover material
+      newmaterial->setAmbientColor( QColor(0, 128, 128) );
+    } else { // create material for element
+      periodentafel *periode = World::getInstance().getPeriode();
+      const element *desiredelement = periode->FindElement(no);
+      ASSERT(desiredelement != NULL,
+          "GLMoleculeView::getMaterial() - desired element "+toString(no)+" not present in periodentafel.");
+      const unsigned char* color = desiredelement->getColor();
+      LOG(1, "Creating new material with color " << (int)color[0] << "," << (int)color[1] << "," << (int)color[2] << ".");
+      newmaterial->setAmbientColor( QColor((int)color[0], (int)color[1], (int)color[2]) );
+    }
+    newmaterial->setSpecularColor( QColor(60, 60, 60) );
+    newmaterial->setShininess( 128 );
+    ElementNoMaterialMap.insert( make_pair(no, newmaterial) );
+
+    return newmaterial;
+  }
+}
+
+/** Static function to be called when Materials have to be removed.
+ *
+ */
+void GLMoleculeObject::cleanMaterialMap()
+{
+  for (ElementMaterialMap::iterator iter = ElementNoMaterialMap.begin();
+      !ElementNoMaterialMap.empty();
+      iter = ElementNoMaterialMap.begin()) {
+    delete iter->second;
+    ElementNoMaterialMap.erase(iter);
+  }
+}
Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.hpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.hpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.hpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
@@ -0,0 +1,104 @@
+/*
+ * GLMoleculeObject.hpp
+ *
+ *  This is based on the Qt3D example "teaservice", specifically meshobject.h.
+ *
+ *  Created on: Aug 17, 2011
+ *      Author: heber
+ */
+
+#ifndef GLMOLECULEOBJECT_HPP_
+#define GLMOLECULEOBJECT_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <QtCore/qobject.h>
+#include <QtGui/qevent.h>
+
+#include <qglpainter.h>
+#include <qglabstractscene.h>
+
+class QGLView;
+class QGLSceneNode;
+class GLMoleculeScene;
+
+/** This class represents a single object within a molecule, e.g. atom or bond.
+ *
+ */
+class GLMoleculeObject : public QObject
+{
+   Q_OBJECT
+
+   //!> Allow it to call cleanMaterialMap()
+   friend class GLMoleculeScene;
+public:
+   explicit GLMoleculeObject(QGLSceneNode *GLMoleculeObject, QObject *parent=0);
+   explicit GLMoleculeObject(QGLAbstractScene *scene, QObject *parent=0);
+   virtual ~GLMoleculeObject();
+
+   QVector3D position() const { return m_position; }
+   void setPosition(const QVector3D& value) { m_position = value; }
+
+   qreal scale() const { return m_scale; }
+   void setScale(qreal value) { m_scale = value; }
+
+   qreal rotationAngle() const { return m_rotationAngle; }
+   void setRotationAngle(qreal value) { m_rotationAngle = value; }
+
+   QVector3D rotationVector() const { return m_rotationVector; }
+   void setRotationVector(const QVector3D& value) { m_rotationVector = value; }
+
+   QGLMaterial *material() const { return m_material; }
+   void setMaterial(QGLMaterial *value)
+       { m_material = value; m_hoverMaterial = value; }
+
+   QGLMaterial *hoverMaterial() const { return m_hoverMaterial; }
+   void setHoverMaterial(QGLMaterial *value) { m_hoverMaterial = value; }
+
+   QGLAbstractEffect *effect() const { return m_effect; }
+   void setEffect(QGLAbstractEffect *value) { m_effect = value; }
+
+   int objectId() const { return m_objectId; }
+   void setObjectId(int id) { m_objectId = id; }
+
+   void initialize(QGLView *view, QGLPainter *painter);
+   void draw(QGLPainter *painter);
+
+signals:
+   void pressed();
+   void released();
+   void clicked();
+   void doubleClicked();
+   void hoverChanged();
+
+protected:
+   bool event(QEvent *e);
+
+   static QGLMaterial* getMaterial(size_t);
+   static void cleanMaterialMap();
+
+   typedef std::map< size_t, QGLMaterial *> ElementMaterialMap;
+   static ElementMaterialMap ElementNoMaterialMap;
+
+private:
+
+   QGLSceneNode *m_mesh;
+   QGLSceneNode *m_GLMoleculeObject;
+   QGLAbstractScene *m_scene;
+   QVector3D m_position;
+   qreal m_scale;
+   qreal m_rotationAngle;
+   QVector3D m_rotationVector;
+   QGLMaterial *m_material;
+   QGLMaterial *m_hoverMaterial;
+   QGLAbstractEffect *m_effect;
+   int m_objectId;
+   bool m_hovering;
+};
+
+
+#endif /* GLMOLECULEOBJECT_HPP_ */
Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
@@ -0,0 +1,70 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * GLMoleculeObject_atom.cpp
+ *
+ *  Created on: Aug 17, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "GLMoleculeObject_atom.hpp"
+
+#include <Qt3D/qglbuilder.h>
+#include <Qt3D/qglscenenode.h>
+#include <Qt3D/qglsphere.h>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "CodePatterns/Assert.hpp"
+
+#include "atom.hpp"
+#include "element.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+
+static QGLSceneNode * createAtom(QObject *parent)
+{
+  QGLBuilder builder;
+  builder << QGLSphere(0.5);
+  QGLSceneNode *n = builder.finalizedSceneNode();
+  n->setParent(parent);
+  return n;
+}
+
+GLMoleculeObject_atom::GLMoleculeObject_atom(QObject *parent, const atom *_atom) :
+  GLMoleculeObject(createAtom(parent), parent)
+{
+  const Vector Position = _atom->getPosition();
+  const size_t elementno = _atom->getType()->getNumber();
+
+  // set materials
+  QGLMaterial *elementmaterial = getMaterial(elementno);
+  ASSERT(elementmaterial != NULL,
+      "GLMoleculeObject_atom::GLMoleculeObject_atom() - QGLMaterial ref from getter function is NULL.");
+  setMaterial(elementmaterial);
+  QGLMaterial *hovermaterial = getMaterial(0); // 0 is the hover material
+  ASSERT(hovermaterial != NULL,
+      "GLMoleculeObject_atom::GLMoleculeObject_atom() - QGLMaterial ref from getter function for hover is NULL.");
+  setHoverMaterial(hovermaterial);
+
+  // set position
+  setPosition(QVector3D(Position[0], Position[1], Position[2]));
+
+  // set scale
+  setScale( _atom->getType()->getVanDerWaalsRadius());
+
+  // set the object's id
+  setObjectId(_atom->getId());
+
+  std::cout << "Created sphere at " << Position << " with elementno " << elementno << "." << endl;
+}
Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
@@ -0,0 +1,33 @@
+/*
+ * GLMoleculeObject_atom.hpp
+ *
+ *  Created on: Aug 17, 2011
+ *      Author: heber
+ */
+
+#ifndef GLMOLECULEOBJECT_ATOM_HPP_
+#define GLMOLECULEOBJECT_ATOM_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "GLMoleculeObject.hpp"
+
+class atom;
+
+class GLMoleculeObject_atom : public GLMoleculeObject
+{
+   Q_OBJECT
+public:
+   GLMoleculeObject_atom(QObject *parent, const atom *atomref);
+   ~GLMoleculeObject_atom() {}
+
+private:
+   atom *_atom;
+};
+
+
+
+#endif /* GLMOLECULEOBJECT_ATOM_HPP_ */
Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
@@ -0,0 +1,104 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * GLMoleculeObject_bond.cpp
+ *
+ *  Created on: Aug 17, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "GLMoleculeObject_bond.hpp"
+
+#include <Qt3D/qglbuilder.h>
+#include <Qt3D/qglcylinder.h>
+#include <Qt3D/qglmaterial.h>
+#include <Qt3D/qglscenenode.h>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include <cmath>
+
+#include "CodePatterns/Assert.hpp"
+#include "atom.hpp"
+#include "Bond/bond.hpp"
+#include "element.hpp"
+#include "Helpers/defs.hpp"
+#include "LinearAlgebra/Line.hpp"
+#include "LinearAlgebra/Vector.hpp"
+
+static QGLSceneNode *createBond(QObject *parent, double distance)
+{
+   QGLBuilder builder;
+   QGLCylinder cylinder(.25,.25,.25);
+   cylinder.setHeight(distance);
+   builder << cylinder;
+   QGLSceneNode *n = builder.finalizedSceneNode();
+   n->setParent(parent);
+   return n;
+}
+
+GLMoleculeObject_bond::GLMoleculeObject_bond(QObject *parent, bond *_bond, double distance, enum SideOfBond side) :
+  GLMoleculeObject(createBond(parent, distance), parent)
+{
+  Vector Position;
+  Vector OtherPosition;
+  size_t elementno = 0;
+  switch (side) {
+    case left:
+      Position = _bond->leftatom->getPosition();
+      OtherPosition = _bond->rightatom->getPosition();
+      elementno = _bond->leftatom->getType()->getNumber();
+      break;
+    case right:
+      Position = _bond->rightatom->getPosition();
+      OtherPosition = _bond->leftatom->getPosition();
+      elementno = _bond->rightatom->getType()->getNumber();
+      break;
+    default:
+      ASSERT(0,
+          "GLMoleculeObject_bond::GLMoleculeObject_bond() - side is not a valid argument: "+toString(side)+".");
+      break;
+  }
+
+  QGLMaterial *elementmaterial = getMaterial(elementno);
+  setMaterial(elementmaterial);
+
+  // calculate position
+  Vector Z(0.,0.,1.);
+  Vector zeroVec(0.,0.,0.);
+  Vector a,b;
+  Vector OtherAxis;
+  double alpha;
+  a = Position - OtherPosition;
+  // construct rotation axis
+  b = a;
+  b.VectorProduct(Z);
+  Line axis(zeroVec, b);
+  // calculate rotation angle
+  alpha = a.Angle(Z);
+  // construct other axis to check right-hand rule
+  OtherAxis = b;
+  OtherAxis.VectorProduct(Z);
+  // assure right-hand rule for the rotation
+  if (a.ScalarProduct(OtherAxis) < MYEPSILON)
+    alpha = M_PI-alpha;
+  // check
+  Vector a_rotated = axis.rotateVector(a, alpha);
+  std::cout << "Created cylinder from "// << Position << " to " << OtherPosition
+      << a << " to " << a_rotated << " around " << b << " by " << alpha/M_PI*180. << ", respectively." << endl;
+
+  // set position
+  setPosition(QVector3D(Position[0], Position[1], Position[2]));
+  setRotationVector(QVector3D(b[0], b[1], b[2]));
+  setRotationAngle(alpha/M_PI*180.);
+}
Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
@@ -0,0 +1,36 @@
+/*
+ * GLMoleculeObject_bond.hpp
+ *
+ *  Created on: Aug 17, 2011
+ *      Author: heber
+ */
+
+#ifndef GLMOLECULEOBJECT_BOND_HPP_
+#define GLMOLECULEOBJECT_BOND_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "GLMoleculeObject.hpp"
+
+class bond;
+
+class GLMoleculeObject_bond : public GLMoleculeObject
+{
+   Q_OBJECT
+public:
+   enum SideOfBond { left, right };
+
+   GLMoleculeObject_bond(QObject *parent, bond *bondref, double distance, enum SideOfBond side);
+   ~GLMoleculeObject_bond() {}
+
+
+private:
+   bond *_bond;
+};
+
+
+
+#endif /* GLMOLECULEOBJECT_BOND_HPP_ */
Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeScene.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeScene.cpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeScene.cpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
@@ -0,0 +1,98 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * GLMoleculeScene.cpp
+ *
+ *  This is based on the Qt3D example "teaservice", specifically sceneobject.cpp.
+ *
+ *  Created on: Aug 17, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "GLMoleculeScene.hpp"
+
+#include "GLMoleculeObject.hpp"
+#include "GLMoleculeObject_atom.hpp"
+#include "GLMoleculeObject_bond.hpp"
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "atom.hpp"
+#include "Bond/bond.hpp"
+#include "molecule.hpp"
+
+
+GLMoleculeScene::GLMoleculeScene(QObject *parent, molecule *_mol) :
+   QObject(parent), mol(_mol)
+{
+  for (molecule::const_iterator atomiter = mol->begin();
+      atomiter != mol->end();
+      ++atomiter) {
+    // create atom objects in scene
+    GLMoleculeObject_atom *atomObject= new GLMoleculeObject_atom(this, *atomiter);
+    AtomsinMoleculeMap.insert( make_pair((*atomiter)->getId(), atomObject) );
+
+    // create its bonds
+    const BondList &bonds = (*atomiter)->getListOfBonds();
+    for (BondList::const_iterator bonditer = bonds.begin();
+        bonditer != bonds.end();
+        ++bonditer) {
+      if ((*bonditer)->leftatom->getId() == (*atomiter)->getId()) {
+        // create bond objects in scene
+        const double distance =
+            (*bonditer)->leftatom->getPosition().distance((*bonditer)->rightatom->getPosition())/2.;
+        GLMoleculeObject_bond *bondObject= new GLMoleculeObject_bond(this, *bonditer, distance, GLMoleculeObject_bond::left);
+        BondsinMoleculeMap.insert( make_pair(
+            make_pair(
+                (*bonditer)->leftatom->getId(),
+                (*bonditer)->rightatom->getId()
+                ),
+            bondObject) );
+        bondObject= new GLMoleculeObject_bond(this, *bonditer, distance, GLMoleculeObject_bond::right);
+        BondsinMoleculeMap.insert( make_pair(
+            make_pair(
+                (*bonditer)->rightatom->getId(),
+                (*bonditer)->leftatom->getId()
+                ),
+            bondObject) );
+      }
+    }
+  }
+}
+
+GLMoleculeScene::~GLMoleculeScene()
+{
+  // remove all elements
+  GLMoleculeObject::cleanMaterialMap();
+}
+
+void GLMoleculeScene::initialize(QGLView *view, QGLPainter *painter)
+{
+  // Initialize all of the mesh objects that we have as children.
+   foreach (QObject *obj, children()) {
+     GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
+       if (meshobj)
+           meshobj->initialize(view, painter);
+   }
+}
+
+void GLMoleculeScene::draw(QGLPainter *painter)
+{
+   // Draw all of the mesh objects that we have as children.
+   foreach (QObject *obj, children()) {
+     GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
+       if (meshobj)
+           meshobj->draw(painter);
+   }
+}
+
Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeScene.hpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeScene.hpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeScene.hpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
@@ -0,0 +1,51 @@
+/*
+ * GLMoleculeScene.hpp
+ *
+ *  This is based on the Qt3D example "teaservice", specifically sceneobject.h.
+ *
+ *  Created on: Aug 17, 2011
+ *      Author: heber
+ */
+
+#ifndef GLMOLECULESCENE_HPP_
+#define GLMOLECULESCENE_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <QtCore/qobject.h>
+#include <Qt3D/qglpainter.h>
+
+class molecule;
+class QGLView;
+class GLMoleculeObject_atom;
+class GLMoleculeObject_bond;
+
+/** This class represent a single molecule within the scene with all its atoms
+ *  and bonds.
+ *
+ */
+class GLMoleculeScene : public QObject
+{
+   Q_OBJECT
+public:
+   explicit GLMoleculeScene(QObject *parent, molecule *_mol);
+   virtual ~GLMoleculeScene();
+
+   virtual void initialize(QGLView *view, QGLPainter *painter);
+   virtual void draw(QGLPainter *painter);
+
+private:
+   typedef std::map< size_t, GLMoleculeObject_atom* > AtomNodeMap;
+   typedef std::map< std::pair< size_t, size_t> , GLMoleculeObject_bond* > BondNodeMap;
+   AtomNodeMap AtomsinMoleculeMap;
+   BondNodeMap BondsinMoleculeMap;
+
+   molecule *mol;
+};
+
+
+
+#endif /* GLMOLECULESCENE_HPP_ */
Index: src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
+++ src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
@@ -0,0 +1,164 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * GLWorldScene.cpp
+ *
+ *  This is based on the Qt3D example "teaservice", specifically parts of teaservice.cpp.
+ *
+ *  Created on: Aug 17, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "GLWorldScene.hpp"
+
+#include "GLMoleculeScene.hpp"
+#include "GLMoleculeObject.hpp"
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "atom.hpp"
+#include "molecule.hpp"
+#include "World.hpp"
+
+
+GLWorldScene::GLWorldScene(QObject *parent)
+   : QObject(parent)
+{
+  init();
+
+  //changeMaterials(false);
+}
+
+GLWorldScene::~GLWorldScene()
+{}
+
+/** Initialise the WorldScene with molecules and atoms from World.
+ *
+ */
+void GLWorldScene::init()
+{
+  const std::vector<molecule*> &molecules = World::getInstance().getAllMolecules();
+
+  if (molecules.size() > 0) {
+    for (std::vector<molecule*>::const_iterator Runner = molecules.begin();
+        Runner != molecules.end();
+        Runner++) {
+      // create molecule
+      GLMoleculeScene * const molObject = new GLMoleculeScene(this, *Runner);
+      MoleculeSceneList.push_back(molObject);
+    }
+  }
+}
+
+void GLWorldScene::initialize(QGLView *view, QGLPainter *painter) const
+{
+  for (List_MoleculeScene::const_iterator iter = MoleculeSceneList.begin();
+      iter != MoleculeSceneList.end();
+      ++iter) {
+    (*iter)->initialize(view, painter);
+  }
+}
+
+
+void GLWorldScene::draw(QGLPainter *painter) const
+{
+  for (List_MoleculeScene::const_iterator iter = MoleculeSceneList.begin();
+      iter != MoleculeSceneList.end();
+      ++iter) {
+    (*iter)->draw(painter);
+  }
+}
+//
+///** create an atom object in the scene.
+// * \param molObject Object of the molecule in the scene to set as parent
+// * \param _atom ref to the atom to create
+// */
+//void GLWorldScene::makeAtom(GLMoleculeObject *&molObject, const atom *&_atom)
+//{
+//  // create object (hand over getMaterial as callback function)
+//  GLMoleculeObject_atom *newatom = new GLMoleculeObject_atom(molObject, _atom, &getMaterial);
+//
+//  // connect signal
+//  connect(newatom, SIGNAL(hoverChanged()), this, SIGNAL(changed()));
+//
+//  // add to nodes map
+//  AtomsinSceneMap.insert( make_pair(_atom->getId(), newatom) );
+//}
+//
+///** Create a bond object in the scene.
+// * \param molObject Object of the molecule in the scene to set as parent
+// * \param _bond ref to the bond to create
+// */
+//void GLWorldScene::makeCylinder(GLMoleculeObject *&molObject, const bond *_bond)
+//    //const Vector &x, const Vector &y, double radius, double height, const size_t elementno)
+//{
+//  // create object
+//  QGLMoleculeObject_bond *newbond = new QGLMoleculeObject_bond(molObject, _bond, &getMaterial)
+//
+//  // nothing to connect here
+//
+//  // add to nodes map
+//  BondsinSceneMap.insert(
+//      make_pair(
+//          make_pair(
+//              _bond->leftatom->getId(),
+//              _bond->rightatom->getId()
+//              ),
+//      newatom) );
+//}
+//
+//
+//
+//QGLSceneNode* GLMoleculeView::getAtom(size_t no)
+//{
+//  // first some sensibility checks
+//  ASSERT(World::getInstance().getAtom(AtomById(no)) != NULL,
+//      "GLMoleculeView::getAtom() - desired atom "
+//      +toString(no)+" not present in the World.");
+//  ASSERT(AtomsinSceneMap.find(no) != AtomsinSceneMap.end(),
+//      "GLMoleculeView::getAtom() - desired atom "
+//      +toString(no)+" not present in the AtomsinSceneMap.");
+//
+//  return AtomsinSceneMap[no];
+//}
+//
+//QGLSceneNode* GLMoleculeView::getBond(size_t leftno, size_t rightno)
+//{
+//  // first some sensibility checks
+//  ASSERT(World::getInstance().getAtom(AtomById(leftno)) != NULL,
+//      "GLMoleculeView::getAtom() - desired atom "
+//      +toString(leftno)+" of bond not present in the World.");
+//  ASSERT(World::getInstance().getAtom(AtomById(rightno)) != NULL,
+//      "GLMoleculeView::getAtom() - desired atom "
+//      +toString(rightno)+" of bond not present in the World.");
+//  ASSERT(AtomsinSceneMap.find(leftno) != AtomsinSceneMap.end(),
+//      "GLMoleculeView::getAtom() - desired atom "
+//      +toString(leftno)+" of bond not present in the AtomsinSceneMap.");
+//  ASSERT(AtomsinSceneMap.find(rightno) != AtomsinSceneMap.end(),
+//      "GLMoleculeView::getAtom() - desired atom "
+//      +toString(rightno)+" of bond not present in the AtomsinSceneMap.");
+//  ASSERT(leftno == rightno,
+//      "GLMoleculeView::getAtom() - bond must not be between the same atom: "
+//      +toString(leftno)+" == "+toString(rightno)+".");
+//
+//  // then return with smaller index first
+//  if (leftno > rightno)
+//    return AtomsinSceneMap[ make_pair(rightno, leftno) ];
+//  else
+//    return AtomsinSceneMap[ make_pair(leftno, rightno) ];
+//}
+
+void GLWorldScene::atomClicked()
+{
+   qDebug("atom clicked");
+}
Index: src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
+++ src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
@@ -0,0 +1,66 @@
+/*
+ * GLWorldScene.hpp
+ *
+ *  This is based on the Qt3D example "teaservice", specifically parts of teaservice.cpp.
+ *
+ *  Created on: Aug 17, 2011
+ *      Author: heber
+ */
+
+#ifndef GLWORLDSCENE_HPP_
+#define GLWORLDSCENE_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Qt/qobject.h>
+
+class QGLPainter;
+class QGLSceneNode;
+class QGLView;
+
+class GLMoleculeObject;
+class GLMoleculeObject_atom;
+class GLMoleculeObject_bond;
+class GLMoleculeScene;
+
+/** This class contains a list of all molecules in the world.
+ *
+ */
+class GLWorldScene : public QObject
+{
+  Q_OBJECT
+public:
+  GLWorldScene(QObject *parent=0);
+  virtual ~GLWorldScene();
+
+//#if !defined(QT_OPENGL_ES_1)
+//  PerPixelEffect *lighting;
+//#endif
+
+  void changeMaterials(bool perPixel);
+  QGLSceneNode* getAtom(size_t);
+  QGLSceneNode* getBond(size_t, size_t);
+
+  void initialize(QGLView *view, QGLPainter *painter) const;
+  void draw(QGLPainter *painter) const;
+
+signals:
+  void changed();
+
+private slots:
+  void atomClicked();
+
+private:
+  void init();
+
+  typedef std::list< GLMoleculeScene * > List_MoleculeScene;
+
+  List_MoleculeScene MoleculeSceneList;
+};
+
+
+
+#endif /* GLWORLDSCENE_HPP_ */
Index: src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp	(revision 04f01714d458f4a933c136873fbcc398845e35c2)
+++ src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
@@ -21,8 +21,6 @@
 
 #include <Qt/qevent.h>
-#include <Qt3D/qglbuilder.h>
-#include <Qt3D/qglcube.h>
-
-//#include "GLWorldScene.hpp"
+
+#include "GLWorldScene.hpp"
 
 #include "CodePatterns/MemDebug.hpp"
@@ -31,9 +29,9 @@
    : QGLView(parent), worldscene(NULL)
 {
-//   worldscene = new GLWorldScene(this);
+   worldscene = new GLWorldScene(this);
 
    setOption(QGLView::ObjectPicking, true);
 
-//   connect(worldscene, SIGNAL(changed()), this, SLOT(updateGL()));
+   connect(worldscene, SIGNAL(changed()), this, SLOT(updateGL()));
 }
 
@@ -46,32 +44,23 @@
 void GLWorldView::initializeGL(QGLPainter *painter)
 {
-  QGLBuilder builder;
-  builder << QGL::Faceted;
-  builder << QGLCube();
-  worldscene = builder.finalizedSceneNode();
-//   worldscene->initialize(this, painter);
+   worldscene->initialize(this, painter);
 }
 
 void GLWorldView::paintGL(QGLPainter *painter)
 {
-  painter->setStandardEffect(QGL::LitMaterial);
-  painter->setFaceColor(QGL::AllFaces, QColor(170, 202, 0));
-
-  painter->modelViewMatrix().rotate(45.0f, 1.0f, 1.0f, 1.0f);
-  worldscene->draw(painter);
-//   worldscene->draw(painter);
+   worldscene->draw(painter);
 }
 
-//void GLWorldView::keyPressEvent(QKeyEvent *e)
-//{
-//   if (e->key() == Qt::Key_Tab) {
-//       // The Tab key turns the ShowPicking option on and off,
-//       // which helps show what the pick buffer looks like.
-//       setOption(QGLView::ShowPicking, ((options() & QGLView::ShowPicking) == 0));
-//       updateGL();
-//   }
-//   QGLView::keyPressEvent(e);
-//}
-//
+void GLWorldView::keyPressEvent(QKeyEvent *e)
+{
+   if (e->key() == Qt::Key_Tab) {
+       // The Tab key turns the ShowPicking option on and off,
+       // which helps show what the pick buffer looks like.
+       setOption(QGLView::ShowPicking, ((options() & QGLView::ShowPicking) == 0));
+       updateGL();
+   }
+   QGLView::keyPressEvent(e);
+}
+
 
 //#include <GL/glu.h>
Index: src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp	(revision 04f01714d458f4a933c136873fbcc398845e35c2)
+++ src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp	(revision 907636a5dab60af4f441f0c8888aadfce03987fc)
@@ -15,9 +15,7 @@
 
 #include "qglview.h"
-#include "qglteapot.h"
 
-//class QKeyEvent;
-//class GLWorldScene;
-class QGLSceneNode;
+class QKeyEvent;
+class GLWorldScene;
 class QGLPainter;
 
@@ -38,9 +36,8 @@
    void initializeGL(QGLPainter *painter);
    void paintGL(QGLPainter *painter);
-   //void keyPressEvent(QKeyEvent *e);
+   void keyPressEvent(QKeyEvent *e);
 
 private:
-   //GLWorldScene *worldscene;
-   QGLSceneNode *worldscene;
+   GLWorldScene *worldscene;
 };
 
