Logo ROOT   6.16/01
Reference Guide
TGLRnrCtx.h
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Matevz Tadel, Feb 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TGLRnrCtx
13#define ROOT_TGLRnrCtx
14
15#include "Rtypes.h"
16#include "TGLStopwatch.h"
17
18#include <list>
19
20class TGLViewerBase;
21class TGLCamera;
22class TGLSceneBase;
23class TGLSceneInfo;
24
25class TGLColorSet;
26class TGLFont;
28
29class TGLClip;
30class TGLSelectBuffer;
31
32class TGLRect;
33
34class GLUquadric;
35
36/**************************************************************************/
37// TGLRnrCtx
38/**************************************************************************/
39
41{
42public:
43 enum EStyle
44 {
49 };
50 static const char* StyleName(Short_t style);
51
52 enum EPass
53 {
59 };
60
62 {
64 kLODPixel = 0, // Projected size pixel or less
65 kLODLow = 20,
66 kLODMed = 50,
67 kLODHigh = 100
68 };
69
71 {
78 };
79
81 {
84 kNever
85 };
86
87private:
88 TGLRnrCtx(const TGLRnrCtx&); // Not implemented
89 TGLRnrCtx& operator=(const TGLRnrCtx&); // Not implemented
90
91 typedef std::list<TGLColorSet*> lpTGLColorSet_t;
92
93protected:
97
100 Short_t fCombiLOD; // Combined viewer/scene lod.
101 Short_t fShapeLOD; // LOD calculated for current shape.
102 Float_t fShapePixSize; // Only relevant when not using display lists.
103
106
111
115
117
122
123 // Highlight / Selection stuff
124 Bool_t fHighlight; // True when in highlight.
125 Bool_t fHighlightOutline; // True when in highlight-outline.
126 Bool_t fSelection; // True when in selection.
127 Bool_t fSecSelection; // True when in secondary selection.
132
135
137
138 // GL state
139 Bool_t fDLCaptureOpen; //! DL-capture currently open
140 TGLContextIdentity *fGLCtxIdentity; //! Current GL context identity
141
142 GLUquadric *fQuadric;
143
144 // Picture grabbing
145 Bool_t fGrabImage; // Set to true to store the image.
146 Int_t fGrabBuffer; // Which buffer to grab after render.
147 UChar_t *fGrabbedImage; // Buffer where image was stored after rendering.
148
149public:
150 TGLRnrCtx(TGLViewerBase* viewer);
151 virtual ~TGLRnrCtx();
152
153 // Central objects
157 TGLCamera & RefCamera() { return *fCamera; }
162
163 const TGLCamera & RefCamera() const { return *fCamera; }
164 const TGLCamera * GetCamera() const { return fCamera; }
165
166 // void SetViewer (TGLViewerBase* v) { fViewer = v; }
169
170 // Draw LOD, style, clip, rnr-pass
171 Short_t ViewerLOD() const { return fViewerLOD; }
172 void SetViewerLOD(Short_t LOD) { fViewerLOD = LOD; }
173 Short_t SceneLOD() const { return fSceneLOD; }
174 void SetSceneLOD(Short_t LOD) { fSceneLOD = LOD; }
175 Short_t CombiLOD() const { return fCombiLOD; }
176 void SetCombiLOD(Short_t LOD) { fCombiLOD = LOD; }
177 Short_t ShapeLOD() const { return fShapeLOD; }
178 void SetShapeLOD(Short_t LOD) { fShapeLOD = LOD; }
181
182 Short_t ViewerStyle() const { return fViewerStyle; }
184 Short_t SceneStyle() const { return fSceneStyle; }
185 void SetSceneStyle(Short_t sty) { fSceneStyle = sty; }
186
195
196 TGLClip* ViewerClip() const { return fViewerClip; }
198 TGLClip* SceneClip() const { return fSceneClip; }
200 TGLClip* Clip() const { return fClip; }
201 void SetClip(TGLClip *p) { fClip = p; }
202 Bool_t HasClip() const { return fClip != 0; }
203
204 Short_t DrawPass() const { return fDrawPass; }
205 void SetDrawPass(Short_t dpass) { fDrawPass = dpass; }
206 Bool_t IsDrawPassFilled() const;
208
209 // Render time-out
212 void StartStopwatch();
213 void StopStopwatch();
216
217 // Highlight / Selection state during rendering
218 Bool_t Highlight() const { return fHighlight; }
219 void SetHighlight(Bool_t hil) { fHighlight = hil; }
222 Bool_t Selection() const { return fSelection; }
223 void SetSelection(Bool_t sel) { fSelection = sel; }
225 void SetSecSelection(Bool_t secSel) { fSecSelection = secSel; }
226 // Highlight / selection parameters
232 // Selection setup / end
233 void BeginSelection(Int_t x, Int_t y, Int_t r=3);
234 void EndSelection (Int_t glResult);
235
236 void PushColorSet();
238 void PopColorSet();
241
242 void ColorOrForeground(Color_t col);
243
246
249
251 void OpenDLCapture();
252 void CloseDLCapture();
253
256
257 void RegisterFont(Int_t size, Int_t file, Int_t mode, TGLFont& out);
258 void RegisterFont(Int_t size, const char* name, Int_t mode, TGLFont& out);
259 void RegisterFontNoScale(Int_t size, Int_t file, Int_t mode, TGLFont& out);
260 void RegisterFontNoScale(Int_t size, const char* name, Int_t mode, TGLFont& out);
261 void ReleaseFont(TGLFont& font);
262
263 GLUquadric* GetGluQuadric();
264
265 // Picture grabbing
266 void SetGrabImage(Bool_t gi) { fGrabImage = gi; }
267 Bool_t GetGrabImage() const { return fGrabImage; }
268
269 // Matrix manipulation helpers
271 void ProjectionMatrixPop();
272
273 ClassDef(TGLRnrCtx, 0); // Collection of objects and data passes along all rendering calls.
274};
275
276
277#endif
ROOT::R::TRInterface & r
Definition: Object.C:4
#define c(i)
Definition: RSha256.hxx:101
int Int_t
Definition: RtypesCore.h:41
unsigned char UChar_t
Definition: RtypesCore.h:34
unsigned int UInt_t
Definition: RtypesCore.h:42
bool Bool_t
Definition: RtypesCore.h:59
short Short_t
Definition: RtypesCore.h:35
double Double_t
Definition: RtypesCore.h:55
short Color_t
Definition: RtypesCore.h:79
float Float_t
Definition: RtypesCore.h:53
#define ClassDef(name, id)
Definition: Rtypes.h:324
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition: TGLCamera.h:44
Abstract clipping shape - derives from TGLPhysicalShape Adds clip mode (inside/outside) and pure virt...
Definition: TGLClip.h:32
Class encapsulating a set of colors used throughout standard rendering.
Definition: TGLUtil.h:835
Identifier of a shared GL-context.
Definition: TGLContext.h:81
A wrapper class for FTFont.
Viewport (pixel base) 2D rectangle class.
Definition: TGLUtil.h:423
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:41
Float_t fViewerOLLineW
Definition: TGLRnrCtx.h:109
void SetRenderScale(Float_t s)
Definition: TGLRnrCtx.h:245
void SetSceneInfo(TGLSceneInfo *si)
Definition: TGLRnrCtx.h:168
void SetSceneOLLineW(Float_t w)
Definition: TGLRnrCtx.h:194
void SetViewerLOD(Short_t LOD)
Definition: TGLRnrCtx.h:172
TGLColorSet * ChangeBaseColorSet(TGLColorSet *set)
Change the default/bottom color-set.
Definition: TGLRnrCtx.cxx:304
Bool_t fSecSelection
Definition: TGLRnrCtx.h:127
TGLViewerBase * fViewer
Definition: TGLRnrCtx.h:94
std::list< TGLColorSet * > lpTGLColorSet_t
Definition: TGLRnrCtx.h:91
void SetRenderTimeOut(Double_t tout)
Definition: TGLRnrCtx.h:211
Float_t ShapePixSize() const
Definition: TGLRnrCtx.h:179
void SetShapeLOD(Short_t LOD)
Definition: TGLRnrCtx.h:178
@ kLODHigh
Definition: TGLRnrCtx.h:67
@ kLODPixel
Definition: TGLRnrCtx.h:64
@ kLODUndef
Definition: TGLRnrCtx.h:63
void BeginSelection(Int_t x, Int_t y, Int_t r=3)
Setup context for running selection.
Definition: TGLRnrCtx.cxx:205
ESelectabilityOfTransparents
Definition: TGLRnrCtx.h:81
@ kIfClosest
Definition: TGLRnrCtx.h:83
@ kIfNoOpaques
Definition: TGLRnrCtx.h:82
Bool_t IsDLCaptureOpen() const
Definition: TGLRnrCtx.h:250
UChar_t * fGrabbedImage
Definition: TGLRnrCtx.h:147
TGLSceneInfo * fSceneInfo
Definition: TGLRnrCtx.h:96
TGLCamera * fCamera
Definition: TGLRnrCtx.h:95
TGLClip * fSceneClip
Definition: TGLRnrCtx.h:113
void PopColorSet()
Pops the top-most color-set.
Definition: TGLRnrCtx.cxx:287
Int_t fPickRadius
Definition: TGLRnrCtx.h:129
Short_t SelectTransparents() const
Definition: TGLRnrCtx.h:227
Float_t fSceneWFLineW
Definition: TGLRnrCtx.h:108
Float_t GetRenderScale() const
Definition: TGLRnrCtx.h:244
TGLRect * fPickRectangle
Definition: TGLRnrCtx.h:130
TGLClip * fClip
Definition: TGLRnrCtx.h:114
Bool_t fGrabImage
Definition: TGLRnrCtx.h:145
TGLRnrCtx & operator=(const TGLRnrCtx &)
Float_t fSceneOLLineW
Definition: TGLRnrCtx.h:110
Short_t SceneStyle() const
Definition: TGLRnrCtx.h:184
Int_t GetPickRadius()
Return pick radius. If selection is not active it returns 0.
Definition: TGLRnrCtx.cxx:257
TGLViewerBase * GetViewer()
Definition: TGLRnrCtx.h:154
Float_t ViewerWFLineW() const
Definition: TGLRnrCtx.h:187
Short_t fShapeLOD
Definition: TGLRnrCtx.h:101
void SetSecSelection(Bool_t secSel)
Definition: TGLRnrCtx.h:225
Float_t SceneOLLineW() const
Definition: TGLRnrCtx.h:193
UInt_t GetEventKeySym() const
Definition: TGLRnrCtx.h:247
void SetSceneClip(TGLClip *p)
Definition: TGLRnrCtx.h:199
TGLColorSet * GetBaseColorSet()
Returns the current base color-set.
Definition: TGLRnrCtx.cxx:314
GLUquadric * fQuadric
Current GL context identity.
Definition: TGLRnrCtx.h:142
TGLSelectBuffer * GetSelectBuffer() const
Definition: TGLRnrCtx.h:231
void ReleaseFont(TGLFont &font)
Release font in the GL rendering context.
Definition: TGLRnrCtx.cxx:359
void SetViewerOLLineW(Float_t w)
Definition: TGLRnrCtx.h:192
void SetViewerWFLineW(Float_t w)
Definition: TGLRnrCtx.h:188
void SetShapePixSize(Float_t ps)
Definition: TGLRnrCtx.h:180
void SetGLCtxIdentity(TGLContextIdentity *cid)
Definition: TGLRnrCtx.h:255
const TGLCamera * GetCamera() const
Definition: TGLRnrCtx.h:164
Double_t RenderTimeOut() const
Definition: TGLRnrCtx.h:210
void SetGrabImage(Bool_t gi)
Definition: TGLRnrCtx.h:266
TGLSceneBase * GetScene()
Return current scene (based on scene-info data).
Definition: TGLRnrCtx.cxx:135
void SetSceneLOD(Short_t LOD)
Definition: TGLRnrCtx.h:174
void PushColorSet()
Create copy of current color-set on the top of the stack.
Definition: TGLRnrCtx.cxx:270
TGLStopwatch fStopwatch
Definition: TGLRnrCtx.h:118
TGLRect * GetPickRectangle()
Return current pick rectangle.
Definition: TGLRnrCtx.cxx:249
Short_t ViewerStyle() const
Definition: TGLRnrCtx.h:182
Bool_t SecSelection() const
Definition: TGLRnrCtx.h:224
GLUquadric * GetGluQuadric()
Initialize fQuadric.
Definition: TGLRnrCtx.cxx:405
void SetHighlightOutline(Bool_t ho)
Definition: TGLRnrCtx.h:221
void RegisterFontNoScale(Int_t size, Int_t file, Int_t mode, TGLFont &out)
Get font in the GL rendering context.
Definition: TGLRnrCtx.cxx:367
EShapeSelectionLevel
Definition: TGLRnrCtx.h:71
@ kSSLImpliedHighlighted
Definition: TGLRnrCtx.h:76
@ kSSLSelected
Definition: TGLRnrCtx.h:73
@ kSSLNotSelected
Definition: TGLRnrCtx.h:72
@ kSSLImpliedSelected
Definition: TGLRnrCtx.h:74
@ kSSLHighlighted
Definition: TGLRnrCtx.h:75
Bool_t fHighlight
Definition: TGLRnrCtx.h:124
void CloseDLCapture()
End display list capture.
Definition: TGLRnrCtx.cxx:347
lpTGLColorSet_t * fColorSetStack
Definition: TGLRnrCtx.h:133
Short_t SceneLOD() const
Definition: TGLRnrCtx.h:173
Bool_t IsDrawPassFilled() const
Returns true if current render-pass uses filled polygon style.
Definition: TGLRnrCtx.cxx:153
Short_t fSceneLOD
Definition: TGLRnrCtx.h:99
Bool_t HasClip() const
Definition: TGLRnrCtx.h:202
void SetClip(TGLClip *p)
Definition: TGLRnrCtx.h:201
TGLSceneBase & RefScene()
Return current scene (based on scene-info data).
Definition: TGLRnrCtx.cxx:143
TGLColorSet & ColorSet()
Return reference to current color-set (top of the stack).
Definition: TGLRnrCtx.cxx:278
Bool_t HighlightOutline() const
Definition: TGLRnrCtx.h:220
TGLRnrCtx(const TGLRnrCtx &)
Bool_t IsStopwatchRunning() const
Definition: TGLRnrCtx.h:214
Bool_t fHighlightOutline
Definition: TGLRnrCtx.h:125
void SetSceneWFLineW(Float_t w)
Definition: TGLRnrCtx.h:190
TGLSceneInfo & RefSceneInfo()
Definition: TGLRnrCtx.h:159
TGLClip * ViewerClip() const
Definition: TGLRnrCtx.h:196
TGLCamera & RefCamera()
Definition: TGLRnrCtx.h:157
Bool_t fHasTimedOut
Definition: TGLRnrCtx.h:121
virtual ~TGLRnrCtx()
Destructor.
Definition: TGLRnrCtx.cxx:124
Bool_t GetGrabImage() const
Definition: TGLRnrCtx.h:267
void StartStopwatch()
Start the stopwatch.
Definition: TGLRnrCtx.cxx:166
Int_t fGrabBuffer
Definition: TGLRnrCtx.h:146
void RegisterFont(Int_t size, Int_t file, Int_t mode, TGLFont &out)
Get font in the GL rendering context.
Definition: TGLRnrCtx.cxx:384
void StopStopwatch()
Stop the stopwatch.
Definition: TGLRnrCtx.cxx:179
Float_t fViewerWFLineW
Definition: TGLRnrCtx.h:107
Double_t fRenderTimeOut
Definition: TGLRnrCtx.h:119
void EndSelection(Int_t glResult)
End selection.
Definition: TGLRnrCtx.cxx:219
Float_t fShapePixSize
Definition: TGLRnrCtx.h:102
Short_t ViewerLOD() const
Definition: TGLRnrCtx.h:171
void SetSceneStyle(Short_t sty)
Definition: TGLRnrCtx.h:185
Bool_t fSelection
Definition: TGLRnrCtx.h:126
void SetSelectTransparents(Short_t st)
Definition: TGLRnrCtx.h:228
Bool_t fDLCaptureOpen
Definition: TGLRnrCtx.h:139
UInt_t fEventKeySym
Definition: TGLRnrCtx.h:136
void SetViewerStyle(Short_t sty)
Definition: TGLRnrCtx.h:183
void ProjectionMatrixPushIdentity()
Definition: TGLRnrCtx.cxx:423
Float_t ViewerOLLineW() const
Definition: TGLRnrCtx.h:191
TGLViewerBase & RefViewer()
Definition: TGLRnrCtx.h:155
Short_t fSelectTransparents
Definition: TGLRnrCtx.h:128
void SetViewerClip(TGLClip *p)
Definition: TGLRnrCtx.h:197
Short_t fDrawPass
Definition: TGLRnrCtx.h:116
Bool_t IsDrawPassOutlineLine() const
Definition: TGLRnrCtx.h:207
Bool_t HasStopwatchTimedOut()
Check if the stopwatch went beyond the render time limit.
Definition: TGLRnrCtx.cxx:188
void ColorOrForeground(Color_t col)
Set col if it is different from background, otherwise use current foreground color.
Definition: TGLRnrCtx.cxx:323
void SetCamera(TGLCamera *c)
Definition: TGLRnrCtx.h:167
TGLClip * SceneClip() const
Definition: TGLRnrCtx.h:198
void SetDrawPass(Short_t dpass)
Definition: TGLRnrCtx.h:205
TGLClip * fViewerClip
Definition: TGLRnrCtx.h:112
void SetCombiLOD(Short_t LOD)
Definition: TGLRnrCtx.h:176
TGLSelectBuffer * fSelectBuffer
Definition: TGLRnrCtx.h:131
void ProjectionMatrixPop()
Definition: TGLRnrCtx.cxx:438
Bool_t Highlight() const
Definition: TGLRnrCtx.h:218
Float_t SceneWFLineW() const
Definition: TGLRnrCtx.h:189
TGLContextIdentity * fGLCtxIdentity
DL-capture currently open.
Definition: TGLRnrCtx.h:140
Short_t fCombiLOD
Definition: TGLRnrCtx.h:100
TGLCamera * GetCamera()
Definition: TGLRnrCtx.h:156
const TGLCamera & RefCamera() const
Definition: TGLRnrCtx.h:163
Short_t DrawPass() const
Definition: TGLRnrCtx.h:204
static const char * StyleName(Short_t style)
Return string describing the style.
Definition: TGLRnrCtx.cxx:453
void OpenDLCapture()
Start display-list capture.
Definition: TGLRnrCtx.cxx:338
Bool_t fIsRunning
Definition: TGLRnrCtx.h:120
TGLClip * Clip() const
Definition: TGLRnrCtx.h:200
void SetEventKeySym(UInt_t k)
Definition: TGLRnrCtx.h:248
TGLSceneInfo * GetSceneInfo()
Definition: TGLRnrCtx.h:158
Short_t fSceneStyle
Definition: TGLRnrCtx.h:105
@ kPassFill
Definition: TGLRnrCtx.h:55
@ kPassOutlineFill
Definition: TGLRnrCtx.h:56
@ kPassUndef
Definition: TGLRnrCtx.h:54
@ kPassWireFrame
Definition: TGLRnrCtx.h:58
@ kPassOutlineLine
Definition: TGLRnrCtx.h:57
Float_t fRenderScale
Definition: TGLRnrCtx.h:134
Bool_t Selection() const
Definition: TGLRnrCtx.h:222
Short_t fViewerStyle
Definition: TGLRnrCtx.h:104
Short_t fViewerLOD
Definition: TGLRnrCtx.h:98
void SetSelection(Bool_t sel)
Definition: TGLRnrCtx.h:223
Short_t ShapeLOD() const
Definition: TGLRnrCtx.h:177
@ kWireFrame
Definition: TGLRnrCtx.h:48
@ kOutline
Definition: TGLRnrCtx.h:47
@ kStyleUndef
Definition: TGLRnrCtx.h:45
void SetHighlight(Bool_t hil)
Definition: TGLRnrCtx.h:219
TGLContextIdentity * GetGLCtxIdentity() const
Definition: TGLRnrCtx.h:254
Short_t CombiLOD() const
Definition: TGLRnrCtx.h:175
Scene base-class – provides basic interface expected by the TGLViewer or its sub-classes:
Definition: TGLSceneBase.h:33
Base class for extended scene context.
Definition: TGLSceneInfo.h:27
Encapsulates OpenGL select buffer.
Stopwatch object for timing GL work.
Definition: TGLStopwatch.h:33
Base class for GL viewers.
Definition: TGLViewerBase.h:37
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
static constexpr double s
static constexpr double ps
Definition: file.py:1
TCanvas * style()
Definition: style.C:1