| [907636] | 1 | /* | 
|---|
|  | 2 | * GLMoleculeObject.hpp | 
|---|
|  | 3 | * | 
|---|
|  | 4 | *  This is based on the Qt3D example "teaservice", specifically meshobject.h. | 
|---|
|  | 5 | * | 
|---|
|  | 6 | *  Created on: Aug 17, 2011 | 
|---|
|  | 7 | *      Author: heber | 
|---|
|  | 8 | */ | 
|---|
|  | 9 |  | 
|---|
|  | 10 | #ifndef GLMOLECULEOBJECT_HPP_ | 
|---|
|  | 11 | #define GLMOLECULEOBJECT_HPP_ | 
|---|
|  | 12 |  | 
|---|
|  | 13 | // include config.h | 
|---|
|  | 14 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 15 | #include <config.h> | 
|---|
|  | 16 | #endif | 
|---|
|  | 17 |  | 
|---|
|  | 18 |  | 
|---|
|  | 19 | #include <QtCore/qobject.h> | 
|---|
|  | 20 | #include <QtGui/qevent.h> | 
|---|
|  | 21 |  | 
|---|
|  | 22 | #include <qglpainter.h> | 
|---|
|  | 23 | #include <qglabstractscene.h> | 
|---|
|  | 24 |  | 
|---|
|  | 25 | class QGLView; | 
|---|
|  | 26 | class QGLSceneNode; | 
|---|
|  | 27 | class GLMoleculeScene; | 
|---|
|  | 28 |  | 
|---|
|  | 29 | /** This class represents a single object within a molecule, e.g. atom or bond. | 
|---|
|  | 30 | * | 
|---|
|  | 31 | */ | 
|---|
|  | 32 | class GLMoleculeObject : public QObject | 
|---|
|  | 33 | { | 
|---|
|  | 34 | Q_OBJECT | 
|---|
|  | 35 |  | 
|---|
|  | 36 | //!> Allow it to call cleanMaterialMap() | 
|---|
| [7188b1] | 37 | friend class GLWorldScene; | 
|---|
| [907636] | 38 | public: | 
|---|
|  | 39 | explicit GLMoleculeObject(QGLSceneNode *GLMoleculeObject, QObject *parent=0); | 
|---|
|  | 40 | explicit GLMoleculeObject(QGLAbstractScene *scene, QObject *parent=0); | 
|---|
|  | 41 | virtual ~GLMoleculeObject(); | 
|---|
|  | 42 |  | 
|---|
|  | 43 | QVector3D position() const { return m_position; } | 
|---|
|  | 44 | void setPosition(const QVector3D& value) { m_position = value; } | 
|---|
|  | 45 |  | 
|---|
|  | 46 | qreal scale() const { return m_scale; } | 
|---|
|  | 47 | void setScale(qreal value) { m_scale = value; } | 
|---|
|  | 48 |  | 
|---|
|  | 49 | qreal rotationAngle() const { return m_rotationAngle; } | 
|---|
|  | 50 | void setRotationAngle(qreal value) { m_rotationAngle = value; } | 
|---|
|  | 51 |  | 
|---|
|  | 52 | QVector3D rotationVector() const { return m_rotationVector; } | 
|---|
|  | 53 | void setRotationVector(const QVector3D& value) { m_rotationVector = value; } | 
|---|
|  | 54 |  | 
|---|
|  | 55 | QGLMaterial *material() const { return m_material; } | 
|---|
|  | 56 | void setMaterial(QGLMaterial *value) | 
|---|
|  | 57 | { m_material = value; m_hoverMaterial = value; } | 
|---|
|  | 58 |  | 
|---|
|  | 59 | QGLMaterial *hoverMaterial() const { return m_hoverMaterial; } | 
|---|
|  | 60 | void setHoverMaterial(QGLMaterial *value) { m_hoverMaterial = value; } | 
|---|
|  | 61 |  | 
|---|
|  | 62 | QGLAbstractEffect *effect() const { return m_effect; } | 
|---|
|  | 63 | void setEffect(QGLAbstractEffect *value) { m_effect = value; } | 
|---|
|  | 64 |  | 
|---|
|  | 65 | int objectId() const { return m_objectId; } | 
|---|
|  | 66 | void setObjectId(int id) { m_objectId = id; } | 
|---|
|  | 67 |  | 
|---|
|  | 68 | void initialize(QGLView *view, QGLPainter *painter); | 
|---|
|  | 69 | void draw(QGLPainter *painter); | 
|---|
|  | 70 |  | 
|---|
|  | 71 | signals: | 
|---|
|  | 72 | void pressed(); | 
|---|
|  | 73 | void released(); | 
|---|
|  | 74 | void clicked(); | 
|---|
|  | 75 | void doubleClicked(); | 
|---|
|  | 76 | void hoverChanged(); | 
|---|
|  | 77 |  | 
|---|
|  | 78 | protected: | 
|---|
|  | 79 | bool event(QEvent *e); | 
|---|
|  | 80 |  | 
|---|
|  | 81 | static QGLMaterial* getMaterial(size_t); | 
|---|
|  | 82 | static void cleanMaterialMap(); | 
|---|
|  | 83 |  | 
|---|
|  | 84 | typedef std::map< size_t, QGLMaterial *> ElementMaterialMap; | 
|---|
|  | 85 | static ElementMaterialMap ElementNoMaterialMap; | 
|---|
|  | 86 |  | 
|---|
|  | 87 | private: | 
|---|
|  | 88 |  | 
|---|
|  | 89 | QGLSceneNode *m_mesh; | 
|---|
|  | 90 | QGLSceneNode *m_GLMoleculeObject; | 
|---|
|  | 91 | QGLAbstractScene *m_scene; | 
|---|
|  | 92 | QVector3D m_position; | 
|---|
|  | 93 | qreal m_scale; | 
|---|
|  | 94 | qreal m_rotationAngle; | 
|---|
|  | 95 | QVector3D m_rotationVector; | 
|---|
|  | 96 | QGLMaterial *m_material; | 
|---|
|  | 97 | QGLMaterial *m_hoverMaterial; | 
|---|
|  | 98 | QGLAbstractEffect *m_effect; | 
|---|
|  | 99 | int m_objectId; | 
|---|
|  | 100 | bool m_hovering; | 
|---|
|  | 101 | }; | 
|---|
|  | 102 |  | 
|---|
|  | 103 |  | 
|---|
|  | 104 | #endif /* GLMOLECULEOBJECT_HPP_ */ | 
|---|