[907636] | 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 |
|
---|
[2ad1ec] | 20 | #include <iosfwd>
|
---|
| 21 |
|
---|
[73b13c] | 22 | #include <boost/thread/recursive_mutex.hpp>
|
---|
| 23 |
|
---|
[88c8ec] | 24 | #include "Bond/bond.hpp"
|
---|
[2ad1ec] | 25 | #include "GLMoleculeObject_bond.hpp"
|
---|
[c67518] | 26 | #include "GLMoleculeObject_molecule.hpp"
|
---|
[3e93332] | 27 | #include "types.hpp"
|
---|
[2ad1ec] | 28 |
|
---|
[1b07b1] | 29 | #include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp"
|
---|
| 30 | #include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp"
|
---|
| 31 |
|
---|
[f75491] | 32 | class Shape;
|
---|
[7188b1] | 33 |
|
---|
[907636] | 34 | class QGLPainter;
|
---|
| 35 | class QGLSceneNode;
|
---|
| 36 | class QGLView;
|
---|
| 37 |
|
---|
| 38 | class GLMoleculeObject;
|
---|
| 39 | class GLMoleculeObject_atom;
|
---|
[c67518] | 40 | class GLMoleculeObject_molecule;
|
---|
[284551] | 41 | class GLMoleculeObject_shape;
|
---|
[907636] | 42 |
|
---|
[2f7988] | 43 | class QtObservedInstanceBoard;
|
---|
[15c8a9] | 44 |
|
---|
[907636] | 45 | /** This class contains a list of all molecules in the world.
|
---|
| 46 | *
|
---|
| 47 | */
|
---|
| 48 | class GLWorldScene : public QObject
|
---|
| 49 | {
|
---|
| 50 | Q_OBJECT
|
---|
| 51 | public:
|
---|
[15c8a9] | 52 | GLWorldScene(
|
---|
[2f7988] | 53 | QtObservedInstanceBoard * _board,
|
---|
[15c8a9] | 54 | QObject *parent=0);
|
---|
[907636] | 55 | virtual ~GLWorldScene();
|
---|
| 56 |
|
---|
| 57 | //#if !defined(QT_OPENGL_ES_1)
|
---|
| 58 | // PerPixelEffect *lighting;
|
---|
| 59 | //#endif
|
---|
| 60 |
|
---|
| 61 | void changeMaterials(bool perPixel);
|
---|
| 62 | QGLSceneNode* getAtom(size_t);
|
---|
[c67518] | 63 | QGLSceneNode* getMolecule(size_t);
|
---|
[907636] | 64 | QGLSceneNode* getBond(size_t, size_t);
|
---|
| 65 |
|
---|
| 66 | void initialize(QGLView *view, QGLPainter *painter) const;
|
---|
[72a4c1] | 67 | void draw(QGLPainter *painter, const QVector4D &cameraPlane) const;
|
---|
[907636] | 68 |
|
---|
[6966b7] | 69 | enum SelectionModeType{
|
---|
| 70 | SelectAtom,
|
---|
| 71 | SelectMolecule
|
---|
| 72 | };
|
---|
| 73 | void setSelectionMode(SelectionModeType mode);
|
---|
| 74 |
|
---|
[907636] | 75 | signals:
|
---|
| 76 | void changed();
|
---|
[f714763] | 77 | // void updated();
|
---|
[65487f] | 78 | void changeOccured();
|
---|
[7188b1] | 79 | void pressed();
|
---|
| 80 | void released();
|
---|
| 81 | void clicked();
|
---|
| 82 | void clicked(atomId_t);
|
---|
| 83 | void doubleClicked();
|
---|
[704d59] | 84 | void hoverChanged(const atomId_t);
|
---|
| 85 | void hoverChanged(const moleculeId_t, int);
|
---|
[8281cc] | 86 | void insertMolecule(QtObservedMolecule::ptr);
|
---|
[e29427] | 87 | void removeMolecule(QtObservedMolecule*);
|
---|
[907636] | 88 |
|
---|
| 89 | private slots:
|
---|
[7188b1] | 90 | void atomClicked(atomId_t no);
|
---|
[9a7ef9] | 91 | void moleculeClicked(moleculeId_t no);
|
---|
[e29427] | 92 | void moleculeRemoved(QtObservedMolecule* _mol);
|
---|
[8281cc] | 93 | void moleculeSignOff(const moleculeId_t _id);
|
---|
[e29427] | 94 | void moleculeEmpty(QtObservedMolecule::ptr _mol);
|
---|
[1b07b1] | 95 | void moleculeInserted(QtObservedMolecule::ptr);
|
---|
[8281cc] | 96 | void moleculeSignOn(QtObservedMolecule::ptr);
|
---|
[15c8a9] | 97 | void moleculeIndexChanged(const moleculeId_t _oldid, const moleculeId_t _newid);
|
---|
[96e145] | 98 | void moleculesAtomRemoved(const atomId_t _atomid, QtObservedMolecule * _mol);
|
---|
| 99 | void moleculesAtomInserted(QtObservedAtom::ptr, QtObservedMolecule *_mol);
|
---|
[8281cc] | 100 | void atomRemoved(const atomId_t _atomid);
|
---|
[1b07b1] | 101 | void atomInserted(QtObservedAtom::ptr);
|
---|
[8281cc] | 102 | void atomIndexChanged(const atomId_t _oldid, const atomId_t _newid);
|
---|
[6966b7] | 103 | void setSelectionModeAtom();
|
---|
| 104 | void setSelectionModeMolecule();
|
---|
[07136a] | 105 | void addShape(const std::string &_name);
|
---|
| 106 | void removeShape(const std::string &_name);
|
---|
[f714763] | 107 | // void update();
|
---|
[739ee9] | 108 | void moleculesVisibilityChanged(const moleculeId_t _id, bool _visible);
|
---|
[284551] | 109 |
|
---|
| 110 | public:
|
---|
[85c36d] | 111 | void updateSelectedShapes();
|
---|
[907636] | 112 |
|
---|
[2ad1ec] | 113 | private:
|
---|
| 114 |
|
---|
[c67518] | 115 | typedef std::map< moleculeId_t , GLMoleculeObject_molecule* > MoleculeNodeMap;
|
---|
[284551] | 116 | typedef std::map< std::string , GLMoleculeObject_shape* > ShapeNodeMap;
|
---|
[c67518] | 117 | MoleculeNodeMap MoleculesinSceneMap;
|
---|
[284551] | 118 | ShapeNodeMap ShapesinSceneMap;
|
---|
[7cf0eb] | 119 | //!> flag to indicate whether state map is currently worked on
|
---|
| 120 | boost::recursive_mutex MoleculeinSceneMap_mutex;
|
---|
[bca99d] | 121 |
|
---|
[9c259e] | 122 | //!> enumeration of all possible changes molecule might have missed before instantiation
|
---|
| 123 | enum StateChangeType {
|
---|
| 124 | atomInsertedState,
|
---|
| 125 | atomRemovedState,
|
---|
| 126 | MAX_StateChangeType
|
---|
| 127 | };
|
---|
[1b07b1] | 128 | typedef std::map< atomId_t, QtObservedAtom::ptr> QtObservedAtomMap_t;
|
---|
[8281cc] | 129 | typedef std::map< moleculeId_t, QtObservedMolecule::ptr> QtObservedMoleculeMap_t;
|
---|
[9c259e] | 130 | typedef std::multimap< atomId_t, StateChangeType> StateChangeMap_t;
|
---|
| 131 | typedef std::map< moleculeId_t, StateChangeMap_t> MoleculeMissedStateMap_t;
|
---|
| 132 | //!> map of all missed state changes
|
---|
| 133 | MoleculeMissedStateMap_t MoleculeMissedStateMap;
|
---|
[1b07b1] | 134 | //!> map to contain all QtObservedAtom that have not been instantiated so far
|
---|
| 135 | QtObservedAtomMap_t QtObservedAtomMap;
|
---|
[8281cc] | 136 | //!> map to contain all QtObservedMolecule that have not been instantiated so far
|
---|
| 137 | QtObservedMoleculeMap_t QtObservedMoleculeMap;
|
---|
[59f1bc] | 138 |
|
---|
[e29427] | 139 | //!> map to get from QtObservedMolecule to the visual representant
|
---|
| 140 | typedef std::map< QtObservedMolecule* , GLMoleculeObject_molecule* > RemovedMoleculesMap_t;
|
---|
[bcf9cd] | 141 | //!> set of all currently removed molecules
|
---|
[e29427] | 142 | RemovedMoleculesMap_t RemovedMolecules;
|
---|
[bcf9cd] | 143 |
|
---|
[73b13c] | 144 | //!> flag to indicate whether state map is currently worked on
|
---|
| 145 | boost::recursive_mutex MoleculeMissedStateMap_mutex;
|
---|
[9c259e] | 146 |
|
---|
[6966b7] | 147 | SelectionModeType selectionMode;
|
---|
[15c8a9] | 148 |
|
---|
[2f7988] | 149 | QtObservedInstanceBoard * board;
|
---|
[907636] | 150 | };
|
---|
| 151 |
|
---|
| 152 | #endif /* GLWORLDSCENE_HPP_ */
|
---|