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 <iosfwd>
|
---|
21 |
|
---|
22 | #include <boost/thread/recursive_mutex.hpp>
|
---|
23 |
|
---|
24 | #include "Bond/bond.hpp"
|
---|
25 | #include "GLMoleculeObject_bond.hpp"
|
---|
26 | #include "GLMoleculeObject_molecule.hpp"
|
---|
27 | #include "types.hpp"
|
---|
28 |
|
---|
29 | class atom;
|
---|
30 | class molecule;
|
---|
31 | class Shape;
|
---|
32 |
|
---|
33 | class QGLPainter;
|
---|
34 | class QGLSceneNode;
|
---|
35 | class QGLView;
|
---|
36 |
|
---|
37 | class GLMoleculeObject;
|
---|
38 | class GLMoleculeObject_atom;
|
---|
39 | class GLMoleculeObject_molecule;
|
---|
40 | class GLMoleculeObject_shape;
|
---|
41 | class QtSelectionChangedAgent;
|
---|
42 |
|
---|
43 | /** This class contains a list of all molecules in the world.
|
---|
44 | *
|
---|
45 | */
|
---|
46 | class GLWorldScene : public QObject
|
---|
47 | {
|
---|
48 | Q_OBJECT
|
---|
49 | public:
|
---|
50 | GLWorldScene(QObject *parent=0);
|
---|
51 | virtual ~GLWorldScene();
|
---|
52 |
|
---|
53 | //#if !defined(QT_OPENGL_ES_1)
|
---|
54 | // PerPixelEffect *lighting;
|
---|
55 | //#endif
|
---|
56 |
|
---|
57 | void changeMaterials(bool perPixel);
|
---|
58 | QGLSceneNode* getAtom(size_t);
|
---|
59 | QGLSceneNode* getMolecule(size_t);
|
---|
60 | QGLSceneNode* getBond(size_t, size_t);
|
---|
61 |
|
---|
62 | void initialize(QGLView *view, QGLPainter *painter) const;
|
---|
63 | void draw(QGLPainter *painter, const QVector4D &cameraPlane) const;
|
---|
64 |
|
---|
65 | enum SelectionModeType{
|
---|
66 | SelectAtom,
|
---|
67 | SelectMolecule
|
---|
68 | };
|
---|
69 | void setSelectionMode(SelectionModeType mode);
|
---|
70 |
|
---|
71 | void setSelectionChangedAgent(QtSelectionChangedAgent *agent);
|
---|
72 |
|
---|
73 | signals:
|
---|
74 | void changed();
|
---|
75 | // void updated();
|
---|
76 | void changeOccured();
|
---|
77 | void pressed();
|
---|
78 | void released();
|
---|
79 | void clicked();
|
---|
80 | void clicked(atomId_t);
|
---|
81 | void doubleClicked();
|
---|
82 | void hoverChanged(const atomId_t);
|
---|
83 | void hoverChanged(const moleculeId_t, int);
|
---|
84 | void moleculePreparedInserted(const moleculeId_t _id);
|
---|
85 |
|
---|
86 | private slots:
|
---|
87 | void atomClicked(atomId_t no);
|
---|
88 | void moleculeClicked(moleculeId_t no);
|
---|
89 | void moleculePrepareInserted(const moleculeId_t _id);
|
---|
90 | void moleculeRemoved(const moleculeId_t _id);
|
---|
91 | void moleculeInserted(const moleculeId_t _id);
|
---|
92 | void atomRemoved(const moleculeId_t _molid, const atomId_t _atomid);
|
---|
93 | void atomInserted(const moleculeId_t _molid, const atomId_t _atomid);
|
---|
94 | void setSelectionModeAtom();
|
---|
95 | void setSelectionModeMolecule();
|
---|
96 | void addShape(const std::string &_name);
|
---|
97 | void removeShape(const std::string &_name);
|
---|
98 | // void update();
|
---|
99 | void moleculesVisibilityChanged(const moleculeId_t _id, bool _visible);
|
---|
100 | void changeMoleculeId(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t);
|
---|
101 |
|
---|
102 | void AtomSelected(const moleculeId_t _molid, const atomId_t);
|
---|
103 | void AtomUnselected(const moleculeId_t _molid, const atomId_t);
|
---|
104 | void MoleculeSelected(const moleculeId_t);
|
---|
105 | void MoleculeUnselected(const moleculeId_t);
|
---|
106 |
|
---|
107 | public:
|
---|
108 | void updateSelectedShapes();
|
---|
109 |
|
---|
110 | private:
|
---|
111 |
|
---|
112 | typedef std::set<moleculeId_t> RemovalMolecule_t;
|
---|
113 | //!> list of molecule ids whose moleculeRemoved we have received but who have not been inserted yet
|
---|
114 | RemovalMolecule_t RemovalMolecules;
|
---|
115 |
|
---|
116 | typedef std::map< moleculeId_t , GLMoleculeObject_molecule* > MoleculeNodeMap;
|
---|
117 | typedef std::map< std::string , GLMoleculeObject_shape* > ShapeNodeMap;
|
---|
118 | MoleculeNodeMap MoleculesinSceneMap;
|
---|
119 | ShapeNodeMap ShapesinSceneMap;
|
---|
120 | //!> flag to indicate whether state map is currently worked on
|
---|
121 | boost::recursive_mutex MoleculeinSceneMap_mutex;
|
---|
122 |
|
---|
123 | //!> enumeration of all possible changes molecule might have missed before instantiation
|
---|
124 | enum StateChangeType {
|
---|
125 | atomInsertedState,
|
---|
126 | atomRemovedState,
|
---|
127 | MAX_StateChangeType
|
---|
128 | };
|
---|
129 | typedef std::multimap< atomId_t, StateChangeType> StateChangeMap_t;
|
---|
130 | typedef std::map< moleculeId_t, StateChangeMap_t> MoleculeMissedStateMap_t;
|
---|
131 | //!> map of all missed state changes
|
---|
132 | MoleculeMissedStateMap_t MoleculeMissedStateMap;
|
---|
133 | //!> flag to indicate whether state map is currently worked on
|
---|
134 | boost::recursive_mutex MoleculeMissedStateMap_mutex;
|
---|
135 |
|
---|
136 | SelectionModeType selectionMode;
|
---|
137 | };
|
---|
138 |
|
---|
139 | #endif /* GLWORLDSCENE_HPP_ */
|
---|