blob: 51b326053606948a4927e466ec4d94e9a4d87e79 (
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
91
92
93
94
95
96
|
// Copyright 2008 Nanorex, Inc. See LICENSE file for details.
#ifndef NX_BALLANDSTICKOPENGLRENDERER_H
#define NX_BALLANDSTICKOPENGLRENDERER_H
#include <map>
#include <cassert>
extern "C" {
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
}
#include "../NXOpenGLRendererPlugin.h"
/* CLASS: NXBallAndStickOpenGLRenderer */
/**
* Renders atoms and bonds using balls and sticks
*/
class NXBallAndStickOpenGLRenderer : public NXOpenGLRendererPlugin {
Q_OBJECT;
Q_INTERFACES(NXOpenGLRendererPlugin);
public:
NXBallAndStickOpenGLRenderer(Nanorex::NXRenderingEngine *parent = NULL);
virtual ~NXBallAndStickOpenGLRenderer();
Nanorex::NXCommandResult const *const initialize(void);
Nanorex::NXCommandResult const *const cleanup(void);
Nanorex::NXRendererPlugin* newInstance(Nanorex::NXRenderingEngine *) const;
/// Call plugin to render the atom display list and return the scenegraph node. Returns NULL upon failure.
/// Must set commandResult to indicate success or failure
NXSGOpenGLNode* renderAtom(Nanorex::NXAtomData const&);
/// Call plugin to render the atom display list and return the scenegraph node. Returns NULL upon failure.
/// Must set commandResult to indicate success or failure
NXSGOpenGLNode* renderBond(Nanorex::NXBondData const&);
#if 0
/// @fixme r1.0.0 hacks
// -- begin hacks --
NXSGOpenGLNode* renderDnaSegment(/*TODO*/);
NXSGOpenGLNode* renderDnaStrand(/*TODO*/);
// -- end hacks --
#endif
private:
static double const BOND_WIDTH;
static int const MAX_BONDS = 6;
// The 'guard' scenegraph objects ensure that each scenegraph element has
// a ref-count of at least one if all scenegraphs using these nodes are
// constructed properly. This is to ensure that these nodes are available
// even after a previously constructed scenegraph is deleted. Without these
// guards, these nodes would be deleted by the last parent node when their
// reference count becomes zero.
// sphere nodes, for atoms
NXSGOpenGLRenderable *canonicalSphereNode;
Nanorex::NXSGNode canonicalSphereNodeGuard;
// cylinder nodes, for bonds
NXSGOpenGLRenderable *canonicalCylinderNode;
Nanorex::NXSGNode canonicalCylinderNodeGuard;
// bonds
NXSGOpenGLNode *canonicalBondNode[MAX_BONDS];
Nanorex::NXSGNode canonicalBondNodeGuard[MAX_BONDS];
std::map<int,double> atomicRadiusMap;
// initialization helpers
void initializeAtomicRadiusMap(void);
bool initializeCanonicalGeometryNodes(void);
bool initializeCanonicalSphereNode(void);
void drawOpenGLCanonicalSphere(void);
bool initializeCanonicalCylinderNode(void);
void drawOpenGLCanonicalCylinder(void);
bool initializeCanonicalBondNodes(void);
bool initializeCanonicalSingleBondNode(void);
bool initializeCanonicalDoubleBondNode(void);
bool initializeCanonicalTripleBondNode(void);
bool initializeCanonicalAromaticBondNode(void);
bool initializeCanonicalCarbomericBondNode(void);
bool initializeCanonicalGraphiticBondNode(void);
friend class NXBallAndStickOpenGLRendererTest;
};
#endif // NX_BALLANDSTICKOPENGLRENDERER_H
|