/* * GLMoleculeObject.hpp * * This is based on the Qt3D example "teaservice", specifically meshobject.h. * * Created on: Aug 17, 2011 * Author: heber */ #ifndef GLMOLECULEOBJECT_HPP_ #define GLMOLECULEOBJECT_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include class QGLView; class QGLSceneNode; class GLMoleculeScene; /** This class represents a single object within a molecule, e.g. atom or bond. * */ class GLMoleculeObject : public QObject { Q_OBJECT //!> Allow it to call cleanMaterialMap() friend class GLWorldScene; public: explicit GLMoleculeObject(QGLSceneNode *mesh, QObject *parent=0); explicit GLMoleculeObject(QGLAbstractScene *scene, QObject *parent=0); virtual ~GLMoleculeObject(); QVector3D position() const { return m_position; } void setPosition(const QVector3D& value) { m_position = value; } qreal scale() const { return m_scale; } void setScale(qreal value) { m_scale = value; } qreal scaleZ() const { return m_scaleZ; } void setScaleZ(qreal value) { m_scaleZ = value; } qreal rotationAngle() const { return m_rotationAngle; } void setRotationAngle(qreal value) { m_rotationAngle = value; } QVector3D rotationVector() const { return m_rotationVector; } void setRotationVector(const QVector3D& value) { m_rotationVector = value; } QGLMaterial *material() const { return m_material; } void setMaterial(QGLMaterial *value) { m_material = value; } QGLAbstractEffect *effect() const { return m_effect; } void setEffect(QGLAbstractEffect *value) { m_effect = value; } int objectId() const { return m_objectId; } void setObjectId(int id) { m_objectId = id; } bool selected() const { return m_selected; } void setSelected(bool value); void initStaticMaterials(); void initialize(QGLView *view, QGLPainter *painter); void draw(QGLPainter *painter); void drawSelectionBox(QGLPainter *painter); signals: void pressed(); void released(); void clicked(); void doubleClicked(); void hoverChanged(GLMoleculeObject *ob); void selectionChanged(); void changed(); protected: bool event(QEvent *e); static QGLMaterial* getMaterial(size_t); static void cleanMaterialMap(); typedef std::map< size_t, QGLMaterial *> ElementMaterialMap; static ElementMaterialMap ElementNoMaterialMap; private: QGLSceneNode *m_mesh; QGLAbstractScene *m_scene; QVector3D m_position; qreal m_scale; qreal m_scaleZ; qreal m_rotationAngle; QVector3D m_rotationVector; QGLMaterial *m_material; static QGLMaterial *m_hoverMaterial; static QGLMaterial *m_selectionMaterial; static QGLMaterial *m_selectionBoxMaterial; QGLAbstractEffect *m_effect; int m_objectId; bool m_hovering; bool m_selected; }; #endif /* GLMOLECULEOBJECT_HPP_ */