summaryrefslogtreecommitdiff
path: root/cad/plugins/NanoVision-1/src/Plugins/RenderingEngines/OpenGL/Renderers/NXBallAndStickOpenGLRendererTest.h
blob: d07c2861ff7a9bdb502900069315282957f6935b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright 2008 Nanorex, Inc.  See LICENSE file for details.

#ifndef NX_BALLANDSTICKOPENGLRENDERERTEST_H
#define NX_BALLANDSTICKOPENGLRENDERERTEST_H

#include <QtGui>
#include <QtOpenGL>

#include "glt_color.h"
#include "glt_vector4.h"

#include "Nanorex/Interface/NXAtomRenderData.h"
#include "Nanorex/Interface/NXTrackball.h"
#include "NXBallAndStickOpenGLRenderer.h"

using namespace Nanorex;

class TestMainWindow : public QGLWidget {
public:
    TestMainWindow(QWidget *parent=0);
    ~TestMainWindow(void);
    
    void setAtomRenderData(NXAtomRenderData const& theAtomRenderData);
    void setBondRenderData(NXBondRenderData const& theBondRenderData);
    
    void setupScene(void);
    
    // void setBondRenderData(NXBondRenderData const& theBondRenderData)
    // { bondRenderData = theBondRenderData; }
    
    // override QGLWidget:: virtual methods
    void initializeGL(void);
    void paintGL(void);
    void resizeGL(int w, int h);
    
    // trap keyboard events
    void keyPressEvent(QKeyEvent *keyEvent);
    // mouse events
    void mousePressEvent(QMouseEvent *mouseEvent);
    void mouseMoveEvent(QMouseEvent *mouseEvent);
    // void mouseReleaseEvent(QMouseEvent *mouseEvent);
    
    NXOpenGLMaterial const& getDefaultAtomMaterial(void) const
    { return defaultAtomMaterial; }
    
    NXOpenGLMaterial const& getDefaultBondMaterial(void) const
    { return defaultBondMaterial; }
    
private:
    NXAtomRenderData atomRenderData;
    NXBondRenderData bondRenderData;
    
    NXBallAndStickOpenGLRenderer *renderer;
    NXSGOpenGLNode *scene;
    
#ifndef NO_GLT // using GLT
    Vector4 position;
    Vector dir;
    GltColor diffuse;
    GltColor specular;
    GltColor mat_specular;
    real mat_shininess;
#else
    GLfloat position[4];
    GLfloat dir[3];
    GLfloat diffuse[4];
    GLfloat specular[4];
    GLfloat mat_specular[4];
    GLfloat mat_shininess;
#endif
    
    NXOpenGLMaterial defaultAtomMaterial;
    NXOpenGLMaterial defaultBondMaterial;
    
    NXTrackball trackball;
    
    // mouse manipulation
    QPoint lastMouseClick;
    Qt::MouseButton lastMouseButton;
    GLdouble modelview_matrix[16];
    GLdouble projection_matrix[16];
    GLint viewport[4];
    GLdouble angleDegrees;
    Vector axis;
    
    void setupDefaultMaterials(void);
};


#endif // NX_BALLANDSTICKOPENGLRENDERERTEST_H