| [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 |
|
|---|
| [bd6768] | 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"
|
|---|
| [96f14a] | 30 | #include "UIElements/Qt4/InstanceBoard/QtObservedBond.hpp"
|
|---|
| [1b07b1] | 31 | #include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp"
|
|---|
| 32 |
|
|---|
| [f75491] | 33 | class Shape;
|
|---|
| [7188b1] | 34 |
|
|---|
| [907636] | 35 | class QGLPainter;
|
|---|
| 36 | class QGLSceneNode;
|
|---|
| 37 | class QGLView;
|
|---|
| 38 |
|
|---|
| 39 | class GLMoleculeObject;
|
|---|
| 40 | class GLMoleculeObject_atom;
|
|---|
| [c67518] | 41 | class GLMoleculeObject_molecule;
|
|---|
| [284551] | 42 | class GLMoleculeObject_shape;
|
|---|
| [907636] | 43 |
|
|---|
| [2f7988] | 44 | class QtObservedInstanceBoard;
|
|---|
| [15c8a9] | 45 |
|
|---|
| [907636] | 46 | /** This class contains a list of all molecules in the world.
|
|---|
| 47 | *
|
|---|
| 48 | */
|
|---|
| 49 | class GLWorldScene : public QObject
|
|---|
| 50 | {
|
|---|
| 51 | Q_OBJECT
|
|---|
| 52 | public:
|
|---|
| [15c8a9] | 53 | GLWorldScene(
|
|---|
| [2f7988] | 54 | QtObservedInstanceBoard * _board,
|
|---|
| [15c8a9] | 55 | QObject *parent=0);
|
|---|
| [907636] | 56 | virtual ~GLWorldScene();
|
|---|
| 57 |
|
|---|
| 58 | //#if !defined(QT_OPENGL_ES_1)
|
|---|
| 59 | // PerPixelEffect *lighting;
|
|---|
| 60 | //#endif
|
|---|
| 61 |
|
|---|
| 62 | void changeMaterials(bool perPixel);
|
|---|
| 63 | QGLSceneNode* getAtom(size_t);
|
|---|
| [c67518] | 64 | QGLSceneNode* getMolecule(size_t);
|
|---|
| [907636] | 65 | QGLSceneNode* getBond(size_t, size_t);
|
|---|
| 66 |
|
|---|
| 67 | void initialize(QGLView *view, QGLPainter *painter) const;
|
|---|
| [72a4c1] | 68 | void draw(QGLPainter *painter, const QVector4D &cameraPlane) const;
|
|---|
| [907636] | 69 |
|
|---|
| [6966b7] | 70 | enum SelectionModeType{
|
|---|
| 71 | SelectAtom,
|
|---|
| 72 | SelectMolecule
|
|---|
| 73 | };
|
|---|
| 74 | void setSelectionMode(SelectionModeType mode);
|
|---|
| 75 |
|
|---|
| [907636] | 76 | signals:
|
|---|
| 77 | void changed();
|
|---|
| [f714763] | 78 | // void updated();
|
|---|
| [65487f] | 79 | void changeOccured();
|
|---|
| [7188b1] | 80 | void pressed();
|
|---|
| 81 | void released();
|
|---|
| 82 | void clicked();
|
|---|
| 83 | void clicked(atomId_t);
|
|---|
| 84 | void doubleClicked();
|
|---|
| [704d59] | 85 | void hoverChanged(const atomId_t);
|
|---|
| 86 | void hoverChanged(const moleculeId_t, int);
|
|---|
| [bd6768] | 87 | void atomConnected(QtObservedAtom::ptr);
|
|---|
| 88 | void bondConnected(QtObservedBond::ptr);
|
|---|
| [907636] | 89 |
|
|---|
| 90 | private slots:
|
|---|
| [bd6768] | 91 |
|
|---|
| 92 | void clickAtom(atomId_t no);
|
|---|
| 93 | void connectAtom(QtObservedAtom::ptr);
|
|---|
| 94 | void insertAtom(QtObservedAtom::ptr);
|
|---|
| 95 | void removeAtom(ObservedValue_Index_t _atomid);
|
|---|
| 96 |
|
|---|
| 97 | void connectBond(QtObservedBond::ptr);
|
|---|
| 98 | void insertBond(QtObservedBond::ptr);
|
|---|
| 99 | void removeBond(ObservedValue_Index_t _bondid);
|
|---|
| 100 |
|
|---|
| 101 | void clickMolecule(moleculeId_t no);
|
|---|
| 102 | void insertMolecule(QtObservedMolecule::ptr);
|
|---|
| 103 | void removeMolecule(ObservedValue_Index_t _molid);
|
|---|
| 104 |
|
|---|
| [6966b7] | 105 | void setSelectionModeAtom();
|
|---|
| 106 | void setSelectionModeMolecule();
|
|---|
| [bd6768] | 107 |
|
|---|
| [07136a] | 108 | void addShape(const std::string &_name);
|
|---|
| 109 | void removeShape(const std::string &_name);
|
|---|
| [f714763] | 110 | // void update();
|
|---|
| [f91ef6] | 111 | void moleculesVisibilityChanged(ObservedValue_Index_t _id, bool _visible);
|
|---|
| [f1b5ca] | 112 | void hoverChangedSignalled(GLMoleculeObject *ob);
|
|---|
| [284551] | 113 |
|
|---|
| [bd6768] | 114 | void reparentAtom();
|
|---|
| 115 | void reparentBondLeft();
|
|---|
| 116 | void reparentBondRight();
|
|---|
| 117 |
|
|---|
| [284551] | 118 | public:
|
|---|
| [85c36d] | 119 | void updateSelectedShapes();
|
|---|
| [907636] | 120 |
|
|---|
| [2ad1ec] | 121 | private:
|
|---|
| 122 |
|
|---|
| [f1b5ca] | 123 | //!> id of atom hovered over
|
|---|
| 124 | atomId_t hoverAtomId;
|
|---|
| 125 |
|
|---|
| [f91ef6] | 126 | typedef std::map< ObservedValue_Index_t , GLMoleculeObject_molecule* > MoleculeNodeMap;
|
|---|
| [f1b5ca] | 127 | typedef std::map< ObservedValue_Index_t, GLMoleculeObject_atom* > AtomNodeMap;
|
|---|
| [bd6768] | 128 | typedef std::multimap< ObservedValue_Index_t, GLMoleculeObject_bond* > BondNodeMap;
|
|---|
| [284551] | 129 | typedef std::map< std::string , GLMoleculeObject_shape* > ShapeNodeMap;
|
|---|
| [f1b5ca] | 130 |
|
|---|
| [bd6768] | 131 | //!> typedef for storing the current parent to each node in scene
|
|---|
| 132 | typedef std::map<ObservedValue_Index_t, QObject *> AtomNodeParentMap_t;
|
|---|
| 133 | typedef std::map<ObservedValue_Index_t, std::vector<QObject *> > BondNodeParentMap_t;
|
|---|
| 134 |
|
|---|
| 135 | //!> mutex to ascertain atomic access to NodeParentMaps
|
|---|
| 136 | boost::recursive_mutex AtomNodeParentMap_mutex;
|
|---|
| 137 | boost::recursive_mutex BondNodeParentMap_mutex;
|
|---|
| 138 |
|
|---|
| [f1b5ca] | 139 | AtomNodeMap AtomsinSceneMap;
|
|---|
| 140 | BondNodeMap BondsinSceneMap;
|
|---|
| [c67518] | 141 | MoleculeNodeMap MoleculesinSceneMap;
|
|---|
| [284551] | 142 | ShapeNodeMap ShapesinSceneMap;
|
|---|
| [bd6768] | 143 | AtomNodeParentMap_t AtomNodeParentMap;
|
|---|
| 144 | BondNodeParentMap_t BondNodeParentMap;
|
|---|
| [9c259e] | 145 |
|
|---|
| [6966b7] | 146 | SelectionModeType selectionMode;
|
|---|
| [15c8a9] | 147 |
|
|---|
| [2f7988] | 148 | QtObservedInstanceBoard * board;
|
|---|
| [907636] | 149 | };
|
|---|
| 150 |
|
|---|
| 151 | #endif /* GLWORLDSCENE_HPP_ */
|
|---|