| 1 | /* | 
|---|
| 2 | * GLWorldScene.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  This is based on the Qt3D example "teaservice", specifically parts of teaservice.cpp. | 
|---|
| 5 | * | 
|---|
| 6 | *  Created on: Aug 17, 2011 | 
|---|
| 7 | *      Author: heber | 
|---|
| 8 | */ | 
|---|
| 9 |  | 
|---|
| 10 | #ifndef GLWORLDSCENE_HPP_ | 
|---|
| 11 | #define GLWORLDSCENE_HPP_ | 
|---|
| 12 |  | 
|---|
| 13 | // include config.h | 
|---|
| 14 | #ifdef HAVE_CONFIG_H | 
|---|
| 15 | #include <config.h> | 
|---|
| 16 | #endif | 
|---|
| 17 |  | 
|---|
| 18 | #include <Qt/qobject.h> | 
|---|
| 19 |  | 
|---|
| 20 | #include "molecule.hpp" | 
|---|
| 21 |  | 
|---|
| 22 | class atom; | 
|---|
| 23 |  | 
|---|
| 24 | class QGLPainter; | 
|---|
| 25 | class QGLSceneNode; | 
|---|
| 26 | class QGLView; | 
|---|
| 27 |  | 
|---|
| 28 | class GLMoleculeObject; | 
|---|
| 29 | class GLMoleculeObject_atom; | 
|---|
| 30 | class GLMoleculeObject_bond; | 
|---|
| 31 |  | 
|---|
| 32 | /** This class contains a list of all molecules in the world. | 
|---|
| 33 | * | 
|---|
| 34 | */ | 
|---|
| 35 | class GLWorldScene : public QObject | 
|---|
| 36 | { | 
|---|
| 37 | Q_OBJECT | 
|---|
| 38 | public: | 
|---|
| 39 | GLWorldScene(QObject *parent=0); | 
|---|
| 40 | virtual ~GLWorldScene(); | 
|---|
| 41 |  | 
|---|
| 42 | //#if !defined(QT_OPENGL_ES_1) | 
|---|
| 43 | //  PerPixelEffect *lighting; | 
|---|
| 44 | //#endif | 
|---|
| 45 |  | 
|---|
| 46 | void changeMaterials(bool perPixel); | 
|---|
| 47 | QGLSceneNode* getAtom(size_t); | 
|---|
| 48 | QGLSceneNode* getBond(size_t, size_t); | 
|---|
| 49 |  | 
|---|
| 50 | void initialize(QGLView *view, QGLPainter *painter) const; | 
|---|
| 51 | void draw(QGLPainter *painter) const; | 
|---|
| 52 |  | 
|---|
| 53 | signals: | 
|---|
| 54 | void changed(); | 
|---|
| 55 | void changeOccured(); | 
|---|
| 56 | void pressed(); | 
|---|
| 57 | void released(); | 
|---|
| 58 | void clicked(); | 
|---|
| 59 | void clicked(atomId_t); | 
|---|
| 60 | void doubleClicked(); | 
|---|
| 61 | void hoverChanged(); | 
|---|
| 62 |  | 
|---|
| 63 | private slots: | 
|---|
| 64 | void atomClicked(atomId_t no); | 
|---|
| 65 | void atomInserted(const atom *_atom); | 
|---|
| 66 | void atomRemoved(const atom *_atom); | 
|---|
| 67 | void bondsChanged(const atom *_atom); | 
|---|
| 68 |  | 
|---|
| 69 | private: | 
|---|
| 70 | void init(); | 
|---|
| 71 | void bondInserted(const bond *_bond); | 
|---|
| 72 | void bondRemoved(const atomId_t leftnr, const atomId_t rightnr); | 
|---|
| 73 |  | 
|---|
| 74 | typedef std::pair< atomId_t, atomId_t> BondIds; | 
|---|
| 75 | typedef std::map< atomId_t, GLMoleculeObject_atom* > AtomNodeMap; | 
|---|
| 76 | typedef std::map< BondIds , GLMoleculeObject_bond* > BondNodeMap; | 
|---|
| 77 | typedef std::multimap< atomId_t, atomId_t > BondIdsMap; | 
|---|
| 78 | AtomNodeMap AtomsinSceneMap; | 
|---|
| 79 | BondIdsMap BondIdsinSceneMap; | 
|---|
| 80 | BondNodeMap BondsinSceneMap; | 
|---|
| 81 | }; | 
|---|
| 82 |  | 
|---|
| 83 |  | 
|---|
| 84 |  | 
|---|
| 85 | #endif /* GLWORLDSCENE_HPP_ */ | 
|---|