[c67518] | 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 |
|
---|
[6c16a0] | 18 | #include <Qt3D/qgeometrydata.h>
|
---|
| 19 |
|
---|
| 20 | #include "CodePatterns/Cacheable.hpp"
|
---|
[c67518] | 21 | #include "CodePatterns/Observer/Observer.hpp"
|
---|
[6c16a0] | 22 | #include "CodePatterns/ObservedValue.hpp"
|
---|
[c67518] | 23 |
|
---|
| 24 | #include "GLMoleculeObject_bond.hpp"
|
---|
| 25 |
|
---|
| 26 | class atom;
|
---|
| 27 | class bond;
|
---|
[8c001a] | 28 | class GLMoleculeObject_atom;
|
---|
| 29 | class GLWorldScene;
|
---|
[c67518] | 30 | class molecule;
|
---|
| 31 |
|
---|
| 32 | class GLMoleculeObject_molecule : public GLMoleculeObject, public Observer
|
---|
| 33 | {
|
---|
| 34 | Q_OBJECT
|
---|
| 35 | public:
|
---|
[704d59] | 36 | GLMoleculeObject_molecule(QObject *parent, const moleculeId_t molid);
|
---|
| 37 | GLMoleculeObject_molecule(QGLSceneNode *mesh[], QObject *parent, const moleculeId_t molid);
|
---|
[c67518] | 38 | virtual ~GLMoleculeObject_molecule();
|
---|
| 39 |
|
---|
| 40 | // Observer functions
|
---|
| 41 | void update(Observable *publisher);
|
---|
| 42 | void subjectKilled(Observable *publisher);
|
---|
| 43 | void recieveNotification(Observable *publisher, Notification_ptr notification);
|
---|
| 44 |
|
---|
[8c001a] | 45 | void initialize(QGLView *view, QGLPainter *painter);
|
---|
| 46 | void draw(QGLPainter *painter, const QVector4D &cameraPlane);
|
---|
| 47 |
|
---|
| 48 | typedef std::pair< atomId_t, atomId_t> BondIds;
|
---|
| 49 | friend std::ostream &operator<<(std::ostream &ost, const BondIds &t);
|
---|
| 50 |
|
---|
| 51 | static BondIds getBondIds(
|
---|
| 52 | const bond::ptr _bond,
|
---|
| 53 | const enum GLMoleculeObject_bond::SideOfBond side);
|
---|
| 54 |
|
---|
| 55 | signals:
|
---|
| 56 | void changed();
|
---|
| 57 | void changeOccured();
|
---|
[704d59] | 58 | void hoverChanged(const atomId_t);
|
---|
| 59 | void hoverChanged(const moleculeId_t, int);
|
---|
[6c16a0] | 60 | void indexChanged(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t);
|
---|
[8c001a] | 61 | void atomClicked(atomId_t no);
|
---|
[9a7ef9] | 62 | void moleculeClicked(moleculeId_t no);
|
---|
[6c16a0] | 63 | void TesselationHullChanged();
|
---|
| 64 | void BoundingBoxChanged();
|
---|
| 65 | void IsSelectedChanged();
|
---|
| 66 | void AtomInserted(const atomId_t _id);
|
---|
| 67 | void AtomRemoved(const atomId_t _id);
|
---|
| 68 | void IdChanged();
|
---|
[8c001a] | 69 |
|
---|
| 70 | private slots:
|
---|
| 71 | //!> grant GLWorldScene access to private slots
|
---|
| 72 | friend class GLWorldScene;
|
---|
| 73 |
|
---|
[9a7ef9] | 74 | void wasClicked();
|
---|
[2f76d2] | 75 | void atomInserted(const atomId_t _id);
|
---|
| 76 | void atomRemoved(const atomId_t _id);
|
---|
[6c16a0] | 77 | void bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond side);
|
---|
[8c001a] | 78 | void bondRemoved(const atomId_t leftnr, const atomId_t rightnr);
|
---|
| 79 | void hoverChangedSignalled(GLMoleculeObject *ob);
|
---|
[6c16a0] | 80 | void changeAtomId(GLMoleculeObject_atom *, const atomId_t, const atomId_t);
|
---|
[8c001a] | 81 |
|
---|
[34e7fdb] | 82 | void setVisible(bool value);
|
---|
| 83 |
|
---|
[73b13c] | 84 | void activateObserver();
|
---|
[6c16a0] | 85 | void deactivateObserver();
|
---|
| 86 |
|
---|
| 87 | void resetTesselationHull();
|
---|
| 88 | void resetIsSelected();
|
---|
| 89 | void resetBoundingBox();
|
---|
| 90 | void resetAtoms();
|
---|
| 91 | void resetIndex();
|
---|
| 92 |
|
---|
| 93 | private:
|
---|
| 94 | static const molecule * const getMolecule(const moleculeId_t _id);
|
---|
[73b13c] | 95 |
|
---|
[c67518] | 96 | private:
|
---|
[8c001a] | 97 | void addAtomBonds(
|
---|
| 98 | const bond::ptr &_bond,
|
---|
| 99 | const GLMoleculeObject_bond::SideOfBond _side
|
---|
| 100 | );
|
---|
| 101 | void addAtomBonds(const atom *_atom);
|
---|
| 102 |
|
---|
[6c16a0] | 103 | //!> typedef for the internal set of atoms
|
---|
| 104 | typedef std::set<atomId_t> atoms_t;
|
---|
| 105 |
|
---|
| 106 | /** Structure for the required information on the bounding box.
|
---|
| 107 | *
|
---|
| 108 | */
|
---|
| 109 | struct BoundingBoxInfo {
|
---|
| 110 | //!> position of center
|
---|
| 111 | Vector position;
|
---|
| 112 | //!> radius of sphere
|
---|
| 113 | double radius;
|
---|
| 114 | };
|
---|
| 115 |
|
---|
| 116 | /** Structure for the required information on the tesselation hull.
|
---|
| 117 | *
|
---|
| 118 | */
|
---|
| 119 | struct TesselationHullInfo {
|
---|
| 120 | };
|
---|
| 121 |
|
---|
| 122 | QGeometryData updateTesselationHull() const;
|
---|
| 123 | bool updateIsSelected() const;
|
---|
| 124 | BoundingBoxInfo updateBoundingBox() const;
|
---|
| 125 | atoms_t updateAtoms();
|
---|
| 126 | moleculeId_t updateIndex() const;
|
---|
| 127 |
|
---|
| 128 | //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
|
---|
| 129 | const Observable * owner;
|
---|
| 130 |
|
---|
| 131 | //!> internal variable for caching molecule ref in cstor
|
---|
| 132 | const molecule * const molref;
|
---|
| 133 |
|
---|
| 134 | //!> list of channels when contained atoms needs to update
|
---|
| 135 | static const Observable::channels_t AtomsChannels;
|
---|
| 136 | //!> list of channels when tesselation hull needs to update
|
---|
| 137 | static const Observable::channels_t HullChannels;
|
---|
| 138 | //!> list of channels when selection status needs to update
|
---|
| 139 | static const Observable::channels_t SelectionStatusChannels;
|
---|
| 140 | //!> list of channels when bounding box needs to update
|
---|
| 141 | static const Observable::channels_t BoundingBoxChannels;
|
---|
| 142 | //!> list of channels when the index needs to update
|
---|
| 143 | static const Observable::channels_t IndexChannels;
|
---|
| 144 |
|
---|
| 145 | boost::function<moleculeId_t ()> MolIndexUpdater;
|
---|
| 146 | boost::function<QGeometryData ()> TesselationHullUpdater;
|
---|
| 147 | boost::function<bool ()> IsSelectedUpdater;
|
---|
| 148 | boost::function<BoundingBoxInfo ()> BoundingBoxUpdater;
|
---|
| 149 | boost::function<atoms_t ()> PresentAtomsUpdater;
|
---|
| 150 |
|
---|
| 151 | //!> contains the current molecule index
|
---|
| 152 | ObservedValue<moleculeId_t> MolIndex;
|
---|
| 153 | //!> contains current version of the tesselation hull on request
|
---|
| 154 | Cacheable<QGeometryData> TesselationHull;
|
---|
| 155 | //!> contains newest version of the selection status
|
---|
| 156 | ObservedValue<bool> isSelected;
|
---|
| 157 | //!> contains newest version of the bounding box on request
|
---|
| 158 | ObservedValue<BoundingBoxInfo> BoundingBox;
|
---|
| 159 | //!> contains the current live set of atoms for the molecule
|
---|
| 160 | ObservedValue<atoms_t> PresentAtoms;
|
---|
| 161 |
|
---|
| 162 | //!> contains the set of atoms displayed
|
---|
| 163 | atoms_t DisplayedAtoms;
|
---|
[7b5984] | 164 |
|
---|
[8c001a] | 165 | typedef std::map< atomId_t, GLMoleculeObject_atom* > AtomNodeMap;
|
---|
| 166 | typedef std::map< BondIds , GLMoleculeObject_bond* > BondNodeMap;
|
---|
| 167 | AtomNodeMap AtomsinSceneMap;
|
---|
| 168 | BondNodeMap BondsinSceneMap;
|
---|
| 169 |
|
---|
[704d59] | 170 | atomId_t hoverAtomId;
|
---|
[c67518] | 171 | };
|
---|
| 172 |
|
---|
[8c001a] | 173 | std::ostream &operator<<(std::ostream &ost, const GLMoleculeObject_molecule::BondIds &t);
|
---|
[c67518] | 174 |
|
---|
| 175 |
|
---|
| 176 | #endif /* GLMOLECULEOBJECT_MOLECULE_HPP_ */
|
---|