1 | /*
|
---|
2 | * GLMoleculeObject_molecule.hpp
|
---|
3 | *
|
---|
4 | * Created on: Mar 30, 2012
|
---|
5 | * Author: ankele
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef GLMOLECULEOBJECT_MOLECULE_HPP_
|
---|
9 | #define GLMOLECULEOBJECT_MOLECULE_HPP_
|
---|
10 |
|
---|
11 | // include config.h
|
---|
12 | #ifdef HAVE_CONFIG_H
|
---|
13 | #include <config.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | #include "GLMoleculeObject.hpp"
|
---|
17 |
|
---|
18 | #include <Qt3D/qgeometrydata.h>
|
---|
19 |
|
---|
20 | #include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp"
|
---|
21 |
|
---|
22 | #include <map>
|
---|
23 |
|
---|
24 | #include <boost/function.hpp>
|
---|
25 |
|
---|
26 | #include "CodePatterns/Cacheable.hpp"
|
---|
27 | #include "CodePatterns/Observer/Observable.hpp"
|
---|
28 |
|
---|
29 | #include "GLMoleculeObject_bond.hpp"
|
---|
30 |
|
---|
31 | #include "types.hpp"
|
---|
32 |
|
---|
33 | class atom;
|
---|
34 | class bond;
|
---|
35 | class molecule;
|
---|
36 | class GLMoleculeObject_atom;
|
---|
37 | class GLWorldScene;
|
---|
38 | class QtObservedInstanceBoard;
|
---|
39 |
|
---|
40 | class GLMoleculeObject_molecule : public GLMoleculeObject
|
---|
41 | {
|
---|
42 | Q_OBJECT
|
---|
43 | public:
|
---|
44 | GLMoleculeObject_molecule(
|
---|
45 | QObject *parent,
|
---|
46 | QtObservedInstanceBoard &_board,
|
---|
47 | QtObservedMolecule::ptr &_ObservedMolecule);
|
---|
48 | GLMoleculeObject_molecule(
|
---|
49 | QGLSceneNode *mesh[],
|
---|
50 | QObject *parent,
|
---|
51 | QtObservedInstanceBoard &_board,
|
---|
52 | QtObservedMolecule::ptr &_ObservedMolecule);
|
---|
53 | virtual ~GLMoleculeObject_molecule();
|
---|
54 |
|
---|
55 | void initialize(QGLView *view, QGLPainter *painter);
|
---|
56 | void draw(QGLPainter *painter, const QVector4D &cameraPlane);
|
---|
57 |
|
---|
58 | typedef std::pair< atomId_t, atomId_t> BondIds;
|
---|
59 | friend std::ostream &operator<<(std::ostream &ost, const BondIds &t);
|
---|
60 |
|
---|
61 | static BondIds getBondIds(
|
---|
62 | const bond::ptr _bond,
|
---|
63 | const enum GLMoleculeObject_bond::SideOfBond side);
|
---|
64 |
|
---|
65 | signals:
|
---|
66 | void changed();
|
---|
67 | void changeOccured();
|
---|
68 | void hoverChanged(const atomId_t);
|
---|
69 | void hoverChanged(const moleculeId_t, int);
|
---|
70 | void indexChanged(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t);
|
---|
71 | void atomClicked(atomId_t no);
|
---|
72 | void moleculeClicked(moleculeId_t no);
|
---|
73 | void IsSelectedChanged();
|
---|
74 |
|
---|
75 | private slots:
|
---|
76 | //!> grant GLWorldScene access to private slots
|
---|
77 | friend class GLWorldScene;
|
---|
78 |
|
---|
79 | void wasClicked();
|
---|
80 | void atomInserted(QtObservedAtom::ptr _atom);
|
---|
81 | void atomRemoved(const atomId_t _id);
|
---|
82 | void bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond side);
|
---|
83 | void bondRemoved(const atomId_t leftnr, const atomId_t rightnr);
|
---|
84 | void hoverChangedSignalled(GLMoleculeObject *ob);
|
---|
85 | void changeAtomId(GLMoleculeObject_atom *, const atomId_t, const atomId_t);
|
---|
86 |
|
---|
87 | void setVisible(bool value);
|
---|
88 |
|
---|
89 | void resetTesselationHull();
|
---|
90 | void resetBoundingBox();
|
---|
91 | void resetIndex(const moleculeId_t, const moleculeId_t);
|
---|
92 | void resetSelected();
|
---|
93 |
|
---|
94 | private:
|
---|
95 | void addAtomBonds(
|
---|
96 | const bond::ptr &_bond,
|
---|
97 | const GLMoleculeObject_bond::SideOfBond _side
|
---|
98 | );
|
---|
99 |
|
---|
100 | void init(const moleculeId_t _molid);
|
---|
101 |
|
---|
102 | //!> typedef for the internal set of atoms
|
---|
103 | typedef std::set<atomId_t> atoms_t;
|
---|
104 |
|
---|
105 | /** Getter to contained atoms contained in \a ObservedValues.
|
---|
106 | *
|
---|
107 | * \return molecule's contained atoms
|
---|
108 | */
|
---|
109 | atoms_t getPresentAtoms() const;
|
---|
110 |
|
---|
111 | private:
|
---|
112 |
|
---|
113 | //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
|
---|
114 | const Observable * owner;
|
---|
115 |
|
---|
116 | QGeometryData updateTesselationHull() const;
|
---|
117 |
|
---|
118 | //!> list of channels when tesselation hull needs to update
|
---|
119 | static const Observable::channels_t HullChannels;
|
---|
120 |
|
---|
121 | //!> internal variable for caching molecule ref in cstor
|
---|
122 | const molecule * const molref;
|
---|
123 |
|
---|
124 | //!> contains current version of the tesselation hull on request
|
---|
125 | QGeometryData TesselationHull;
|
---|
126 |
|
---|
127 | //!> contains the set of atoms displayed
|
---|
128 | atoms_t DisplayedAtoms;
|
---|
129 |
|
---|
130 | typedef std::map< atomId_t, GLMoleculeObject_atom* > AtomNodeMap;
|
---|
131 | typedef std::map< BondIds , GLMoleculeObject_bond* > BondNodeMap;
|
---|
132 | AtomNodeMap AtomsinSceneMap;
|
---|
133 | BondNodeMap BondsinSceneMap;
|
---|
134 |
|
---|
135 | atomId_t hoverAtomId;
|
---|
136 |
|
---|
137 | QtObservedInstanceBoard &board;
|
---|
138 |
|
---|
139 | QtObservedMolecule::ptr ObservedMolecule;
|
---|
140 | };
|
---|
141 |
|
---|
142 | std::ostream &operator<<(std::ostream &ost, const GLMoleculeObject_molecule::BondIds &t);
|
---|
143 |
|
---|
144 |
|
---|
145 | #endif /* GLMOLECULEOBJECT_MOLECULE_HPP_ */
|
---|