forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TGLRnrCtx.h
277 lines (223 loc) · 9.45 KB
/
TGLRnrCtx.h
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
// @(#)root/gl:$Id$
// Author: Matevz Tadel, Feb 2007
/*************************************************************************
* Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TGLRnrCtx
#define ROOT_TGLRnrCtx
#include "Rtypes.h"
#include "TGLStopwatch.h"
#include <list>
class TGLViewerBase;
class TGLCamera;
class TGLSceneBase;
class TGLSceneInfo;
class TGLColorSet;
class TGLFont;
class TGLContextIdentity;
class TGLClip;
class TGLSelectBuffer;
class TGLRect;
class GLUquadric;
/**************************************************************************/
// TGLRnrCtx
/**************************************************************************/
class TGLRnrCtx
{
public:
enum EStyle
{
kStyleUndef = -1,
kFill,
kOutline,
kWireFrame
};
static const char* StyleName(Short_t style);
enum EPass
{
kPassUndef = -1,
kPassFill,
kPassOutlineFill,
kPassOutlineLine,
kPassWireFrame
};
enum ELODPresets
{
kLODUndef = -1,
kLODPixel = 0, // Projected size pixel or less
kLODLow = 20,
kLODMed = 50,
kLODHigh = 100
};
enum EShapeSelectionLevel
{
kSSLNotSelected,
kSSLSelected,
kSSLImpliedSelected,
kSSLHighlighted,
kSSLImpliedHighlighted,
kSSLEnd
};
enum ESelectabilityOfTransparents
{
kIfNoOpaques = 0,
kIfClosest,
kNever
};
private:
TGLRnrCtx(const TGLRnrCtx&) = delete;
TGLRnrCtx& operator=(const TGLRnrCtx&) = delete;
typedef std::list<TGLColorSet*> lpTGLColorSet_t;
protected:
TGLViewerBase *fViewer;
TGLCamera *fCamera;
TGLSceneInfo *fSceneInfo;
Short_t fViewerLOD;
Short_t fSceneLOD;
Short_t fCombiLOD; // Combined viewer/scene lod.
Short_t fShapeLOD; // LOD calculated for current shape.
Float_t fShapePixSize; // Only relevant when not using display lists.
Short_t fViewerStyle;
Short_t fSceneStyle;
Float_t fViewerWFLineW;
Float_t fSceneWFLineW;
Float_t fViewerOLLineW;
Float_t fSceneOLLineW;
TGLClip *fViewerClip;
TGLClip *fSceneClip;
TGLClip *fClip;
Short_t fDrawPass;
TGLStopwatch fStopwatch;
Double_t fRenderTimeOut;
Bool_t fIsRunning;
Bool_t fHasTimedOut;
// Highlight / Selection stuff
Bool_t fHighlight; // True when in highlight.
Bool_t fHighlightOutline; // True when in highlight-outline.
Bool_t fSelection; // True when in selection.
Bool_t fSecSelection; // True when in secondary selection.
Short_t fSelectTransparents;
Int_t fPickRadius;
TGLRect *fPickRectangle;
TGLSelectBuffer*fSelectBuffer;
lpTGLColorSet_t*fColorSetStack;
Float_t fRenderScale;
UInt_t fEventKeySym;
// GL state
Bool_t fDLCaptureOpen; //! DL-capture currently open
TGLContextIdentity *fGLCtxIdentity; //! Current GL context identity
GLUquadric *fQuadric;
// Picture grabbing
Bool_t fGrabImage; // Set to true to store the image.
Int_t fGrabBuffer; // Which buffer to grab after render.
UChar_t *fGrabbedImage; // Buffer where image was stored after rendering.
public:
TGLRnrCtx(TGLViewerBase* viewer);
virtual ~TGLRnrCtx();
// Central objects
TGLViewerBase * GetViewer() { return fViewer; }
TGLViewerBase & RefViewer() { return *fViewer; }
TGLCamera * GetCamera() { return fCamera; }
TGLCamera & RefCamera() { return *fCamera; }
TGLSceneInfo * GetSceneInfo() { return fSceneInfo; }
TGLSceneInfo & RefSceneInfo() { return *fSceneInfo; }
TGLSceneBase * GetScene();
TGLSceneBase & RefScene();
const TGLCamera & RefCamera() const { return *fCamera; }
const TGLCamera * GetCamera() const { return fCamera; }
// void SetViewer (TGLViewerBase* v) { fViewer = v; }
void SetCamera (TGLCamera* c) { fCamera = c; }
void SetSceneInfo(TGLSceneInfo* si) { fSceneInfo = si; }
// Draw LOD, style, clip, rnr-pass
Short_t ViewerLOD() const { return fViewerLOD; }
void SetViewerLOD(Short_t LOD) { fViewerLOD = LOD; }
Short_t SceneLOD() const { return fSceneLOD; }
void SetSceneLOD(Short_t LOD) { fSceneLOD = LOD; }
Short_t CombiLOD() const { return fCombiLOD; }
void SetCombiLOD(Short_t LOD) { fCombiLOD = LOD; }
Short_t ShapeLOD() const { return fShapeLOD; }
void SetShapeLOD(Short_t LOD) { fShapeLOD = LOD; }
Float_t ShapePixSize() const { return fShapePixSize; }
void SetShapePixSize(Float_t ps) { fShapePixSize = ps; }
Short_t ViewerStyle() const { return fViewerStyle; }
void SetViewerStyle(Short_t sty) { fViewerStyle = sty; }
Short_t SceneStyle() const { return fSceneStyle; }
void SetSceneStyle(Short_t sty) { fSceneStyle = sty; }
Float_t ViewerWFLineW() const { return fViewerWFLineW; }
void SetViewerWFLineW(Float_t w) { fViewerWFLineW = w; }
Float_t SceneWFLineW() const { return fSceneWFLineW; }
void SetSceneWFLineW(Float_t w) { fSceneWFLineW = w; }
Float_t ViewerOLLineW() const { return fViewerOLLineW; }
void SetViewerOLLineW(Float_t w) { fViewerOLLineW = w; }
Float_t SceneOLLineW() const { return fSceneOLLineW; }
void SetSceneOLLineW(Float_t w) { fSceneOLLineW = w; }
TGLClip* ViewerClip() const { return fViewerClip; }
void SetViewerClip(TGLClip *p) { fViewerClip = p; }
TGLClip* SceneClip() const { return fSceneClip; }
void SetSceneClip(TGLClip *p) { fSceneClip = p; }
TGLClip* Clip() const { return fClip; }
void SetClip(TGLClip *p) { fClip = p; }
Bool_t HasClip() const { return fClip != nullptr; }
Short_t DrawPass() const { return fDrawPass; }
void SetDrawPass(Short_t dpass) { fDrawPass = dpass; }
Bool_t IsDrawPassFilled() const;
Bool_t IsDrawPassOutlineLine() const { return fDrawPass == kPassOutlineLine; }
// Render time-out
Double_t RenderTimeOut() const { return fRenderTimeOut; }
void SetRenderTimeOut(Double_t tout) { fRenderTimeOut = tout; }
void StartStopwatch();
void StopStopwatch();
Bool_t IsStopwatchRunning() const { return fIsRunning; }
Bool_t HasStopwatchTimedOut();
// Highlight / Selection state during rendering
Bool_t Highlight() const { return fHighlight; }
void SetHighlight(Bool_t hil) { fHighlight = hil; }
Bool_t HighlightOutline() const { return fHighlightOutline; }
void SetHighlightOutline(Bool_t ho) { fHighlightOutline = ho; }
Bool_t Selection() const { return fSelection; }
void SetSelection(Bool_t sel) { fSelection = sel; }
Bool_t SecSelection() const { return fSecSelection; }
void SetSecSelection(Bool_t secSel) { fSecSelection = secSel; }
// Highlight / selection parameters
Short_t SelectTransparents() const { return fSelectTransparents; }
void SetSelectTransparents(Short_t st) { fSelectTransparents = st; }
TGLRect * GetPickRectangle();
Int_t GetPickRadius();
TGLSelectBuffer * GetSelectBuffer() const { return fSelectBuffer; }
// Selection setup / end
void BeginSelection(Int_t x, Int_t y, Int_t r=3);
void EndSelection (Int_t glResult);
void PushColorSet();
TGLColorSet& ColorSet();
void PopColorSet();
TGLColorSet* ChangeBaseColorSet(TGLColorSet* set);
TGLColorSet* GetBaseColorSet();
void ColorOrForeground(Color_t col);
Float_t GetRenderScale() const { return fRenderScale; }
void SetRenderScale(Float_t s) { fRenderScale = s; }
UInt_t GetEventKeySym() const { return fEventKeySym; }
void SetEventKeySym(UInt_t k) { fEventKeySym = k; }
Bool_t IsDLCaptureOpen() const { return fDLCaptureOpen; }
void OpenDLCapture();
void CloseDLCapture();
TGLContextIdentity* GetGLCtxIdentity() const { return fGLCtxIdentity; }
void SetGLCtxIdentity(TGLContextIdentity* cid) { fGLCtxIdentity = cid; }
void RegisterFont(Int_t size, Int_t file, Int_t mode, TGLFont& out);
void RegisterFont(Int_t size, const char* name, Int_t mode, TGLFont& out);
void RegisterFontNoScale(Int_t size, Int_t file, Int_t mode, TGLFont& out);
void RegisterFontNoScale(Int_t size, const char* name, Int_t mode, TGLFont& out);
void ReleaseFont(TGLFont& font);
GLUquadric* GetGluQuadric();
// Picture grabbing
void SetGrabImage(Bool_t gi) { fGrabImage = gi; }
Bool_t GetGrabImage() const { return fGrabImage; }
// Matrix manipulation helpers
void ProjectionMatrixPushIdentity();
void ProjectionMatrixPop();
ClassDef(TGLRnrCtx, 0); // Collection of objects and data passes along all rendering calls.
};
#endif