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