Logo ROOT   6.08/07
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 
20 class TGLViewerBase;
21 class TGLCamera;
22 class TGLSceneBase;
23 class TGLSceneInfo;
24 
25 class TGLColorSet;
26 class TGLFont;
27 class TGLContextIdentity;
28 
29 class TGLClip;
30 class TGLSelectBuffer;
31 
32 class TGLRect;
33 
34 class GLUquadric;
35 
36 /**************************************************************************/
37 // TGLRnrCtx
38 /**************************************************************************/
39 
40 class TGLRnrCtx
41 {
42 public:
43  enum EStyle
44  {
49  };
50  static const char* StyleName(Short_t style);
51 
52  enum EPass
53  {
54  kPassUndef = -1,
59  };
60 
62  {
63  kLODUndef = -1,
64  kLODPixel = 0, // Projected size pixel or less
65  kLODLow = 20,
66  kLODMed = 50,
67  kLODHigh = 100
68  };
69 
71  {
78  };
79 
81  {
85  };
86 
87 private:
88  TGLRnrCtx(const TGLRnrCtx&); // Not implemented
89  TGLRnrCtx& operator=(const TGLRnrCtx&); // Not implemented
90 
91  typedef std::list<TGLColorSet*> lpTGLColorSet_t;
92 
93 protected:
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 
133  lpTGLColorSet_t*fColorSetStack;
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 
149 public:
150  TGLRnrCtx(TGLViewerBase* viewer);
151  virtual ~TGLRnrCtx();
152 
153  // Central objects
155  TGLViewerBase & RefViewer() { return *fViewer; }
156  TGLCamera * GetCamera() { return fCamera; }
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; }
167  void SetCamera (TGLCamera* c) { fCamera = c; }
168  void SetSceneInfo(TGLSceneInfo* si) { fSceneInfo = si; }
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; }
179  Float_t ShapePixSize() const { return fShapePixSize; }
180  void SetShapePixSize(Float_t ps) { fShapePixSize = ps; }
181 
182  Short_t ViewerStyle() const { return fViewerStyle; }
183  void SetViewerStyle(Short_t sty) { fViewerStyle = sty; }
184  Short_t SceneStyle() const { return fSceneStyle; }
185  void SetSceneStyle(Short_t sty) { fSceneStyle = sty; }
186 
188  void SetViewerWFLineW(Float_t w) { fViewerWFLineW = w; }
189  Float_t SceneWFLineW() const { return fSceneWFLineW; }
190  void SetSceneWFLineW(Float_t w) { fSceneWFLineW = w; }
192  void SetViewerOLLineW(Float_t w) { fViewerOLLineW = w; }
193  Float_t SceneOLLineW() const { return fSceneOLLineW; }
194  void SetSceneOLLineW(Float_t w) { fSceneOLLineW = w; }
195 
196  TGLClip* ViewerClip() const { return fViewerClip; }
197  void SetViewerClip(TGLClip *p) { fViewerClip = p; }
198  TGLClip* SceneClip() const { return fSceneClip; }
199  void SetSceneClip(TGLClip *p) { fSceneClip = p; }
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;
207  Bool_t IsDrawPassOutlineLine() const { return fDrawPass == kPassOutlineLine; }
208 
209  // Render time-out
211  void SetRenderTimeOut(Double_t tout) { fRenderTimeOut = tout; }
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; }
221  void SetHighlightOutline(Bool_t ho) { fHighlightOutline = ho; }
222  Bool_t Selection() const { return fSelection; }
223  void SetSelection(Bool_t sel) { fSelection = sel; }
224  Bool_t SecSelection() const { return fSecSelection; }
225  void SetSecSelection(Bool_t secSel) { fSecSelection = secSel; }
226  // Highlight / selection parameters
228  void SetSelectTransparents(Short_t st) { fSelectTransparents = st; }
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 
244  Float_t GetRenderScale() const { return fRenderScale; }
245  void SetRenderScale(Float_t s) { fRenderScale = s; }
246 
247  UInt_t GetEventKeySym() const { return fEventKeySym; }
248  void SetEventKeySym(UInt_t k) { fEventKeySym = k; }
249 
251  void OpenDLCapture();
252  void CloseDLCapture();
253 
255  void SetGLCtxIdentity(TGLContextIdentity* cid) { fGLCtxIdentity = cid; }
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
Bool_t Highlight() const
Definition: TGLRnrCtx.h:218
TGLSelectBuffer * fSelectBuffer
Definition: TGLRnrCtx.h:131
TGLRnrCtx(const TGLRnrCtx &)
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
void SetSecSelection(Bool_t secSel)
Definition: TGLRnrCtx.h:225
Class encapsulating a set of colors used throughout standard rendering.
Definition: TGLUtil.h:838
Bool_t SecSelection() const
Definition: TGLRnrCtx.h:224
EShapeSelectionLevel
Definition: TGLRnrCtx.h:70
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition: TGLCamera.h:43
TGLClip * fSceneClip
Definition: TGLRnrCtx.h:113
Int_t GetPickRadius()
Return pick radius. If selection is not active it returns 0.
Definition: TGLRnrCtx.cxx:257
void ProjectionMatrixPushIdentity()
Definition: TGLRnrCtx.cxx:423
float Float_t
Definition: RtypesCore.h:53
Short_t fShapeLOD
Definition: TGLRnrCtx.h:101
return c
Bool_t HasClip() const
Definition: TGLRnrCtx.h:202
Bool_t Selection() const
Definition: TGLRnrCtx.h:222
void SetSelection(Bool_t sel)
Definition: TGLRnrCtx.h:223
Identifier of a shared GL-context.
Definition: TGLContext.h:85
TGLCamera & RefCamera()
Definition: TGLRnrCtx.h:157
Stopwatch object for timing GL work.
Definition: TGLStopwatch.h:34
Float_t ViewerOLLineW() const
Definition: TGLRnrCtx.h:191
Scene base-class – provides basic interface expected by the TGLViewer or its sub-classes: ...
Definition: TGLSceneBase.h:32
void SetGrabImage(Bool_t gi)
Definition: TGLRnrCtx.h:266
GLUquadric * GetGluQuadric()
Initialize fQuadric.
Definition: TGLRnrCtx.cxx:405
Abstract clipping shape - derives from TGLPhysicalShape Adds clip mode (inside/outside) and pure virt...
Definition: TGLClip.h:31
void SetSceneClip(TGLClip *p)
Definition: TGLRnrCtx.h:199
TGLSceneInfo * GetSceneInfo()
Definition: TGLRnrCtx.h:158
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t fHighlight
Definition: TGLRnrCtx.h:124
void RegisterFontNoScale(Int_t size, Int_t file, Int_t mode, TGLFont &out)
Get font in the GL rendering context.
Definition: TGLRnrCtx.cxx:367
Short_t fCombiLOD
Definition: TGLRnrCtx.h:100
Float_t GetRenderScale() const
Definition: TGLRnrCtx.h:244
void SetViewerLOD(Short_t LOD)
Definition: TGLRnrCtx.h:172
Bool_t fHighlightOutline
Definition: TGLRnrCtx.h:125
TGLRnrCtx & operator=(const TGLRnrCtx &)
Bool_t fIsRunning
Definition: TGLRnrCtx.h:120
Float_t ViewerWFLineW() const
Definition: TGLRnrCtx.h:187
Bool_t IsDrawPassOutlineLine() const
Definition: TGLRnrCtx.h:207
void StartStopwatch()
Start the stopwatch.
Definition: TGLRnrCtx.cxx:166
TGLClip * ViewerClip() const
Definition: TGLRnrCtx.h:196
TGLRect * GetPickRectangle()
Return current pick rectangle.
Definition: TGLRnrCtx.cxx:249
TGLClip * SceneClip() const
Definition: TGLRnrCtx.h:198
void SetShapeLOD(Short_t LOD)
Definition: TGLRnrCtx.h:178
Short_t DrawPass() const
Definition: TGLRnrCtx.h:204
TGLContextIdentity * GetGLCtxIdentity() const
Definition: TGLRnrCtx.h:254
Base class for GL viewers.
Definition: TGLViewerBase.h:36
GLUquadric * fQuadric
Current GL context identity.
Definition: TGLRnrCtx.h:142
TGLStopwatch fStopwatch
Definition: TGLRnrCtx.h:118
Encapsulates OpenGL select buffer.
void SetViewerOLLineW(Float_t w)
Definition: TGLRnrCtx.h:192
Bool_t IsDrawPassFilled() const
Returns true if current render-pass uses filled polygon style.
Definition: TGLRnrCtx.cxx:153
void SetSceneLOD(Short_t LOD)
Definition: TGLRnrCtx.h:174
Double_t x[n]
Definition: legend1.C:17
void PushColorSet()
Create copy of current color-set on the top of the stack.
Definition: TGLRnrCtx.cxx:270
#define ClassDef(name, id)
Definition: Rtypes.h:254
void ColorOrForeground(Color_t col)
Set col if it is different from background, otherwise use current foreground color.
Definition: TGLRnrCtx.cxx:323
void SetViewerStyle(Short_t sty)
Definition: TGLRnrCtx.h:183
TGLClip * fViewerClip
Definition: TGLRnrCtx.h:112
Bool_t IsDLCaptureOpen() const
Definition: TGLRnrCtx.h:250
Short_t SceneLOD() const
Definition: TGLRnrCtx.h:173
Bool_t GetGrabImage() const
Definition: TGLRnrCtx.h:267
Bool_t fDLCaptureOpen
Definition: TGLRnrCtx.h:139
void StopStopwatch()
Stop the stopwatch.
Definition: TGLRnrCtx.cxx:179
TGLCamera * GetCamera()
Definition: TGLRnrCtx.h:156
Short_t SelectTransparents() const
Definition: TGLRnrCtx.h:227
ESelectabilityOfTransparents
Definition: TGLRnrCtx.h:80
void SetSceneInfo(TGLSceneInfo *si)
Definition: TGLRnrCtx.h:168
Double_t fRenderTimeOut
Definition: TGLRnrCtx.h:119
Viewport (pixel base) 2D rectangle class.
Definition: TGLUtil.h:426
static const char * StyleName(Short_t style)
Return string describing the style.
Definition: TGLRnrCtx.cxx:453
Short_t fViewerStyle
Definition: TGLRnrCtx.h:104
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 ProjectionMatrixPop()
Definition: TGLRnrCtx.cxx:438
TGLSceneInfo & RefSceneInfo()
Definition: TGLRnrCtx.h:159
short Color_t
Definition: RtypesCore.h:79
Short_t ShapeLOD() const
Definition: TGLRnrCtx.h:177
Short_t CombiLOD() const
Definition: TGLRnrCtx.h:175
void SetEventKeySym(UInt_t k)
Definition: TGLRnrCtx.h:248
Float_t fRenderScale
Definition: TGLRnrCtx.h:134
UChar_t * fGrabbedImage
Definition: TGLRnrCtx.h:147
void SetSceneStyle(Short_t sty)
Definition: TGLRnrCtx.h:185
Short_t fViewerLOD
Definition: TGLRnrCtx.h:98
void CloseDLCapture()
End display list capture.
Definition: TGLRnrCtx.cxx:347
void SetSceneWFLineW(Float_t w)
Definition: TGLRnrCtx.h:190
TGLContextIdentity * fGLCtxIdentity
DL-capture currently open.
Definition: TGLRnrCtx.h:140
void SetShapePixSize(Float_t ps)
Definition: TGLRnrCtx.h:180
virtual ~TGLRnrCtx()
Destructor.
Definition: TGLRnrCtx.cxx:124
TRandom2 r(17)
Short_t SceneStyle() const
Definition: TGLRnrCtx.h:184
void SetCamera(TGLCamera *c)
Definition: TGLRnrCtx.h:167
Bool_t fHasTimedOut
Definition: TGLRnrCtx.h:121
void SetHighlight(Bool_t hil)
Definition: TGLRnrCtx.h:219
void SetHighlightOutline(Bool_t ho)
Definition: TGLRnrCtx.h:221
Bool_t HighlightOutline() const
Definition: TGLRnrCtx.h:220
TGLSceneBase & RefScene()
Return current scene (based on scene-info data).
Definition: TGLRnrCtx.cxx:143
void SetCombiLOD(Short_t LOD)
Definition: TGLRnrCtx.h:176
void SetSceneOLLineW(Float_t w)
Definition: TGLRnrCtx.h:194
TGLCamera * fCamera
Definition: TGLRnrCtx.h:95
Short_t fSceneLOD
Definition: TGLRnrCtx.h:99
Int_t fGrabBuffer
Definition: TGLRnrCtx.h:146
unsigned int UInt_t
Definition: RtypesCore.h:42
Float_t fSceneOLLineW
Definition: TGLRnrCtx.h:110
short Short_t
Definition: RtypesCore.h:35
const TGLCamera & RefCamera() const
Definition: TGLRnrCtx.h:163
TGLClip * fClip
Definition: TGLRnrCtx.h:114
Short_t fSelectTransparents
Definition: TGLRnrCtx.h:128
Float_t fShapePixSize
Definition: TGLRnrCtx.h:102
TGLViewerBase & RefViewer()
Definition: TGLRnrCtx.h:155
std::list< TGLColorSet * > lpTGLColorSet_t
Definition: TGLRnrCtx.h:91
Float_t ShapePixSize() const
Definition: TGLRnrCtx.h:179
TGLColorSet * ChangeBaseColorSet(TGLColorSet *set)
Change the default/bottom color-set.
Definition: TGLRnrCtx.cxx:304
Bool_t IsStopwatchRunning() const
Definition: TGLRnrCtx.h:214
UInt_t fEventKeySym
Definition: TGLRnrCtx.h:136
void OpenDLCapture()
Start display-list capture.
Definition: TGLRnrCtx.cxx:338
void EndSelection(Int_t glResult)
End selection.
Definition: TGLRnrCtx.cxx:219
lpTGLColorSet_t * fColorSetStack
Definition: TGLRnrCtx.h:133
double Double_t
Definition: RtypesCore.h:55
Bool_t fSecSelection
Definition: TGLRnrCtx.h:127
Float_t SceneOLLineW() const
Definition: TGLRnrCtx.h:193
void BeginSelection(Int_t x, Int_t y, Int_t r=3)
Setup context for running selection.
Definition: TGLRnrCtx.cxx:205
Float_t fSceneWFLineW
Definition: TGLRnrCtx.h:108
void ReleaseFont(TGLFont &font)
Release font in the GL rendering context.
Definition: TGLRnrCtx.cxx:359
TCanvas * style()
Definition: style.C:1
Double_t y[n]
Definition: legend1.C:17
TGLRect * fPickRectangle
Definition: TGLRnrCtx.h:130
Bool_t fSelection
Definition: TGLRnrCtx.h:126
TGLSceneBase * GetScene()
Return current scene (based on scene-info data).
Definition: TGLRnrCtx.cxx:135
void SetDrawPass(Short_t dpass)
Definition: TGLRnrCtx.h:205
void SetClip(TGLClip *p)
Definition: TGLRnrCtx.h:201
Int_t fPickRadius
Definition: TGLRnrCtx.h:129
Float_t fViewerWFLineW
Definition: TGLRnrCtx.h:107
TGLClip * Clip() const
Definition: TGLRnrCtx.h:200
Definition: file.py:1
void PopColorSet()
Pops the top-most color-set.
Definition: TGLRnrCtx.cxx:287
Bool_t HasStopwatchTimedOut()
Check if the stopwatch went beyond the render time limit.
Definition: TGLRnrCtx.cxx:188
Short_t fSceneStyle
Definition: TGLRnrCtx.h:105
Base class for extended scene context.
Definition: TGLSceneInfo.h:26
TGLColorSet * GetBaseColorSet()
Returns the current base color-set.
Definition: TGLRnrCtx.cxx:314
void SetRenderTimeOut(Double_t tout)
Definition: TGLRnrCtx.h:211
Short_t ViewerStyle() const
Definition: TGLRnrCtx.h:182
TGLViewerBase * GetViewer()
Definition: TGLRnrCtx.h:154
unsigned char UChar_t
Definition: RtypesCore.h:34
A wrapper class for FTFont.
Double_t RenderTimeOut() const
Definition: TGLRnrCtx.h:210
TGLViewerBase * fViewer
Definition: TGLRnrCtx.h:94
void SetViewerWFLineW(Float_t w)
Definition: TGLRnrCtx.h:188
Float_t fViewerOLLineW
Definition: TGLRnrCtx.h:109
TGLColorSet & ColorSet()
Return reference to current color-set (top of the stack).
Definition: TGLRnrCtx.cxx:278
TGLSelectBuffer * GetSelectBuffer() const
Definition: TGLRnrCtx.h:231
TGLSceneInfo * fSceneInfo
Definition: TGLRnrCtx.h:96
void SetSelectTransparents(Short_t st)
Definition: TGLRnrCtx.h:228
Short_t ViewerLOD() const
Definition: TGLRnrCtx.h:171
void SetViewerClip(TGLClip *p)
Definition: TGLRnrCtx.h:197
char name[80]
Definition: TGX11.cxx:109
Float_t SceneWFLineW() const
Definition: TGLRnrCtx.h:189
const TGLCamera * GetCamera() const
Definition: TGLRnrCtx.h:164
UInt_t GetEventKeySym() const
Definition: TGLRnrCtx.h:247
Short_t fDrawPass
Definition: TGLRnrCtx.h:116
Bool_t fGrabImage
Definition: TGLRnrCtx.h:145
void SetGLCtxIdentity(TGLContextIdentity *cid)
Definition: TGLRnrCtx.h:255
void SetRenderScale(Float_t s)
Definition: TGLRnrCtx.h:245