[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 |
|
---|
[494478] | 20 | #include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp"
|
---|
| 21 |
|
---|
| 22 | #include <map>
|
---|
| 23 |
|
---|
[8688ef] | 24 | #include <boost/function.hpp>
|
---|
[7c7c4a] | 25 |
|
---|
[6c16a0] | 26 | #include "CodePatterns/Cacheable.hpp"
|
---|
[494478] | 27 | #include "CodePatterns/Observer/Observable.hpp"
|
---|
[c67518] | 28 |
|
---|
| 29 | #include "GLMoleculeObject_bond.hpp"
|
---|
| 30 |
|
---|
[494478] | 31 | #include "types.hpp"
|
---|
[e39e7a] | 32 |
|
---|
[c67518] | 33 | class atom;
|
---|
| 34 | class bond;
|
---|
[494478] | 35 | class molecule;
|
---|
[8c001a] | 36 | class GLMoleculeObject_atom;
|
---|
| 37 | class GLWorldScene;
|
---|
[2f7988] | 38 | class QtObservedInstanceBoard;
|
---|
[c67518] | 39 |
|
---|
[494478] | 40 | class GLMoleculeObject_molecule : public GLMoleculeObject
|
---|
[c67518] | 41 | {
|
---|
| 42 | Q_OBJECT
|
---|
| 43 | public:
|
---|
[026bef] | 44 | GLMoleculeObject_molecule(
|
---|
| 45 | QObject *parent,
|
---|
[494478] | 46 | QtObservedInstanceBoard &_board,
|
---|
[1b07b1] | 47 | QtObservedMolecule::ptr &_ObservedMolecule);
|
---|
[026bef] | 48 | GLMoleculeObject_molecule(
|
---|
| 49 | QGLSceneNode *mesh[],
|
---|
| 50 | QObject *parent,
|
---|
[494478] | 51 | QtObservedInstanceBoard &_board,
|
---|
[1b07b1] | 52 | QtObservedMolecule::ptr &_ObservedMolecule);
|
---|
[c67518] | 53 | virtual ~GLMoleculeObject_molecule();
|
---|
| 54 |
|
---|
[8c001a] | 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();
|
---|
[704d59] | 68 | void hoverChanged(const atomId_t);
|
---|
| 69 | void hoverChanged(const moleculeId_t, int);
|
---|
[6c16a0] | 70 | void indexChanged(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t);
|
---|
[e29427] | 71 | void atomClicked(atomId_t);
|
---|
| 72 | void moleculeClicked(moleculeId_t);
|
---|
| 73 | void moleculeEmptied(QtObservedMolecule::ptr);
|
---|
[6c16a0] | 74 | void IsSelectedChanged();
|
---|
[8c001a] | 75 |
|
---|
| 76 | private slots:
|
---|
| 77 | //!> grant GLWorldScene access to private slots
|
---|
| 78 | friend class GLWorldScene;
|
---|
| 79 |
|
---|
[9a7ef9] | 80 | void wasClicked();
|
---|
[1b07b1] | 81 | void atomInserted(QtObservedAtom::ptr _atom);
|
---|
[2f76d2] | 82 | void atomRemoved(const atomId_t _id);
|
---|
[6c16a0] | 83 | void bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond side);
|
---|
[8c001a] | 84 | void bondRemoved(const atomId_t leftnr, const atomId_t rightnr);
|
---|
| 85 | void hoverChangedSignalled(GLMoleculeObject *ob);
|
---|
[6c16a0] | 86 | void changeAtomId(GLMoleculeObject_atom *, const atomId_t, const atomId_t);
|
---|
[8c001a] | 87 |
|
---|
[34e7fdb] | 88 | void setVisible(bool value);
|
---|
| 89 |
|
---|
[6c16a0] | 90 | void resetTesselationHull();
|
---|
| 91 | void resetBoundingBox();
|
---|
[1c0961] | 92 | void resetIndex(const moleculeId_t, const moleculeId_t);
|
---|
[5cd3a33] | 93 | void resetSelected();
|
---|
[015f8c] | 94 |
|
---|
[c67518] | 95 | private:
|
---|
[8c001a] | 96 | void addAtomBonds(
|
---|
| 97 | const bond::ptr &_bond,
|
---|
| 98 | const GLMoleculeObject_bond::SideOfBond _side
|
---|
| 99 | );
|
---|
| 100 |
|
---|
[494478] | 101 | void init(const moleculeId_t _molid);
|
---|
| 102 |
|
---|
[6c16a0] | 103 | //!> typedef for the internal set of atoms
|
---|
| 104 | typedef std::set<atomId_t> atoms_t;
|
---|
| 105 |
|
---|
[8d5fbf1] | 106 | /** Getter to contained atoms contained in \a ObservedValues.
|
---|
| 107 | *
|
---|
| 108 | * \return molecule's contained atoms
|
---|
| 109 | */
|
---|
| 110 | atoms_t getPresentAtoms() const;
|
---|
| 111 |
|
---|
[494478] | 112 | private:
|
---|
| 113 |
|
---|
[6c16a0] | 114 | //!> the Observable we are signed on, also indicates whether we are sign on (not NULL)
|
---|
| 115 | const Observable * owner;
|
---|
| 116 |
|
---|
[494478] | 117 | QGeometryData updateTesselationHull() const;
|
---|
[6c16a0] | 118 |
|
---|
| 119 | //!> list of channels when tesselation hull needs to update
|
---|
| 120 | static const Observable::channels_t HullChannels;
|
---|
[7c7c4a] | 121 |
|
---|
[494478] | 122 | //!> internal variable for caching molecule ref in cstor
|
---|
| 123 | const molecule * const molref;
|
---|
[8688ef] | 124 |
|
---|
[6c16a0] | 125 | //!> contains current version of the tesselation hull on request
|
---|
[3fe318] | 126 | QGeometryData TesselationHull;
|
---|
[6c16a0] | 127 |
|
---|
| 128 | //!> contains the set of atoms displayed
|
---|
| 129 | atoms_t DisplayedAtoms;
|
---|
[7b5984] | 130 |
|
---|
[8c001a] | 131 | typedef std::map< atomId_t, GLMoleculeObject_atom* > AtomNodeMap;
|
---|
| 132 | typedef std::map< BondIds , GLMoleculeObject_bond* > BondNodeMap;
|
---|
| 133 | AtomNodeMap AtomsinSceneMap;
|
---|
| 134 | BondNodeMap BondsinSceneMap;
|
---|
| 135 |
|
---|
[704d59] | 136 | atomId_t hoverAtomId;
|
---|
[8d5fbf1] | 137 |
|
---|
[494478] | 138 | QtObservedInstanceBoard &board;
|
---|
[8d5fbf1] | 139 |
|
---|
[494478] | 140 | QtObservedMolecule::ptr ObservedMolecule;
|
---|
[c67518] | 141 | };
|
---|
| 142 |
|
---|
[8c001a] | 143 | std::ostream &operator<<(std::ostream &ost, const GLMoleculeObject_molecule::BondIds &t);
|
---|
[c67518] | 144 |
|
---|
| 145 |
|
---|
| 146 | #endif /* GLMOLECULEOBJECT_MOLECULE_HPP_ */
|
---|