[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 |
|
---|
[4269ca] | 22 | #include <Qt3D/qglpainter.h>
|
---|
| 23 | #include <Qt3D/qglabstractscene.h>
|
---|
[907636] | 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 |
|
---|
[8a77ac] | 62 | QGLMaterial *selectionMaterial() const { return m_selectionMaterial; }
|
---|
| 63 | void setSelectionMaterial(QGLMaterial *value) { m_selectionMaterial = value; }
|
---|
| 64 |
|
---|
[907636] | 65 | QGLAbstractEffect *effect() const { return m_effect; }
|
---|
| 66 | void setEffect(QGLAbstractEffect *value) { m_effect = value; }
|
---|
| 67 |
|
---|
| 68 | int objectId() const { return m_objectId; }
|
---|
| 69 | void setObjectId(int id) { m_objectId = id; }
|
---|
| 70 |
|
---|
| 71 | void initialize(QGLView *view, QGLPainter *painter);
|
---|
| 72 | void draw(QGLPainter *painter);
|
---|
| 73 |
|
---|
| 74 | signals:
|
---|
| 75 | void pressed();
|
---|
| 76 | void released();
|
---|
| 77 | void clicked();
|
---|
| 78 | void doubleClicked();
|
---|
| 79 | void hoverChanged();
|
---|
| 80 |
|
---|
| 81 | protected:
|
---|
| 82 | bool event(QEvent *e);
|
---|
| 83 |
|
---|
| 84 | static QGLMaterial* getMaterial(size_t);
|
---|
| 85 | static void cleanMaterialMap();
|
---|
| 86 |
|
---|
| 87 | typedef std::map< size_t, QGLMaterial *> ElementMaterialMap;
|
---|
| 88 | static ElementMaterialMap ElementNoMaterialMap;
|
---|
| 89 |
|
---|
| 90 | private:
|
---|
| 91 |
|
---|
| 92 | QGLSceneNode *m_mesh;
|
---|
| 93 | QGLSceneNode *m_GLMoleculeObject;
|
---|
| 94 | QGLAbstractScene *m_scene;
|
---|
| 95 | QVector3D m_position;
|
---|
| 96 | qreal m_scale;
|
---|
| 97 | qreal m_rotationAngle;
|
---|
| 98 | QVector3D m_rotationVector;
|
---|
| 99 | QGLMaterial *m_material;
|
---|
| 100 | QGLMaterial *m_hoverMaterial;
|
---|
[613f8c] | 101 | QGLMaterial *m_selectionMaterial;
|
---|
[907636] | 102 | QGLAbstractEffect *m_effect;
|
---|
| 103 | int m_objectId;
|
---|
| 104 | bool m_hovering;
|
---|
[8a77ac] | 105 | bool m_selected;
|
---|
[907636] | 106 | };
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 | #endif /* GLMOLECULEOBJECT_HPP_ */
|
---|