Logo ROOT   6.14/05
Reference Guide
TGLViewerBase.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_TGLViewerBase
13 #define ROOT_TGLViewerBase
14 
15 #include <TObject.h>
16 
17 #include "TGLLockable.h"
18 #include <TGLBoundingBox.h>
19 #include "TGLOverlay.h"
20 
21 #include <list>
22 #include <vector>
23 
24 class TGLSceneBase;
25 class TGLSceneInfo;
26 class TGLCamera;
27 class TGLClip;
28 class TGLRnrCtx;
29 class TGLLogicalShape;
30 class TGLSelectRecord;
31 class TGLOvlSelectRecord;
32 class TGLOverlayElement;
33 
34 // Avoid TObject inheritance due to clash with TVirtualViewer3D.
35 
36 class TGLViewerBase : public TGLLockable // : public TObject
37 {
38 private:
39  TGLViewerBase(const TGLViewerBase&); // Not implemented
40  TGLViewerBase& operator=(const TGLViewerBase&); // Not implemented
41 
42 protected:
43  typedef std::list<TGLSceneInfo*> SceneInfoList_t;
44  typedef SceneInfoList_t::iterator SceneInfoList_i;
45 
46  typedef std::vector<TGLSceneInfo*> SceneInfoVec_t;
47  typedef SceneInfoVec_t::iterator SceneInfoVec_i;
48 
49  typedef std::vector<TGLOverlayElement*> OverlayElmVec_t;
50  typedef OverlayElmVec_t::iterator OverlayElmVec_i;
51 
52  SceneInfoList_i FindScene(TGLSceneBase* scene);
53 
55 
56  void SubRenderScenes(SubRender_foo render_foo);
57 
58  virtual void SetupClipObject();
59 
60  // Members
61 
63 
64  TGLCamera *fCamera; // Camera for rendering.
65  TGLClip *fClip; // Viewer clipping-plane.
66  Short_t fLOD; // Viewer-lod for rendering.
67  Short_t fStyle; // Viewer-style for rendering.
68  Float_t fWFLineW; // Optional override of scene wire-frame line-width
69  Float_t fOLLineW; // Optional override of scene outline line-width
70 
71  Bool_t fResetSceneInfosOnRender; // Request rebuild of view-specific scene data.
72  Bool_t fChanged; // Change requiring redraw is pending.
73 
74  SceneInfoList_t fScenes; // Registered scenes.
75  SceneInfoVec_t fVisScenes; // Visible scenes.
76 
77  TGLBoundingBox fOverallBoundingBox; // Axis-aligned union of scene bboxes.
78 
79  OverlayElmVec_t fOverlay;
80 
81  // ================================================================
82 
83 public:
84 
85  TGLViewerBase();
86  virtual ~TGLViewerBase();
87 
88  virtual const char* LockIdStr() const;
89 
91  void RemoveScene(TGLSceneBase* scene);
92  void RemoveAllScenes();
93  void SceneDestructing(TGLSceneBase* scene);
94 
96 
98 
99  virtual void AddOverlayElement(TGLOverlayElement* el);
100  virtual void RemoveOverlayElement(TGLOverlayElement* el);
101  virtual void DeleteOverlayAnnotations();
103 
104  TGLClip* Clip() const { return fClip; }
105  void SetClip(TGLClip *p) { fClip = p; }
106 
107  Short_t LOD() const { return fLOD; }
108  void SetLOD(Short_t lod) { fLOD = lod; }
109 
110  Short_t Style() const { return fStyle; }
111  void SetStyle(Short_t st) { fStyle = st; }
112 
113  Float_t WFLineW() const { return fWFLineW; }
114  void SetWFLineW(Float_t w) { fWFLineW = w; }
115  Float_t OLLineW() const { return fOLLineW; }
116  void SetOLLineW(Float_t w) { fOLLineW = w; }
117 
118  // ================================================================
119 
120  virtual void ResetSceneInfos();
121  virtual void Changed() { fChanged = kTRUE; }
122  virtual Bool_t IsChanged() const { return fChanged; }
123 
124  virtual void MergeSceneBBoxes(TGLBoundingBox& bbox);
125 
127 
128  // ================================================================
129 
130  // Low-level methods
131  virtual void PreRender();
132  virtual void Render();
133  virtual void RenderNonSelected();
134  virtual void RenderSelected();
135  virtual void RenderSelectedForHighlight();
136  virtual void RenderOpaque(Bool_t rnr_non_selected=kTRUE, Bool_t rnr_selected=kTRUE);
137  virtual void RenderTransparent(Bool_t rnr_non_selected=kTRUE, Bool_t rnr_selected=kTRUE);
138  virtual void RenderOverlay(Int_t state, Bool_t selection);
139  virtual void PostRender();
140 
141  virtual void PreRenderOverlaySelection();
142  virtual void PostRenderOverlaySelection();
143 
144  // High-level methods
145  // virtual void Draw();
146  // virtual void Select();
147  // virtual void SelectOverlay();
148 
149  // Demangle select buffer
151  // Slightly higher-level search in select-buffer
154 
155  // Demangle overlay select buffer
157 
158  TGLRnrCtx* GetRnrCtx() const { return fRnrCtx; }
159  TGLRnrCtx& RnrCtx() const { return *fRnrCtx; }
160 
161  ClassDef(TGLViewerBase, 0); // GL Viewer base-class.
162 };
163 
164 
165 #endif
void SceneDestructing(TGLSceneBase *scene)
Remove scene, its scene-info is deleted.
std::vector< TGLOverlayElement * > OverlayElmVec_t
Definition: TGLViewerBase.h:49
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
virtual void SetupClipObject()
Setup clip-object. Protected virtual method.
SceneInfoVec_t fVisScenes
Definition: TGLViewerBase.h:75
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition: TGLCamera.h:43
void(TGLSceneBase::* SubRender_foo)(TGLRnrCtx &)
Definition: TGLViewerBase.h:54
float Float_t
Definition: RtypesCore.h:53
std::list< TGLSceneInfo * > SceneInfoList_t
Definition: TGLViewerBase.h:43
OverlayElmVec_t::iterator OverlayElmVec_i
Definition: TGLViewerBase.h:50
virtual void Render()
Render all scenes.
Scene base-class – provides basic interface expected by the TGLViewer or its sub-classes: ...
Definition: TGLSceneBase.h:32
Bool_t FindClosestRecord(TGLSelectRecord &rec, Int_t &recIdx)
Find next select record that can be resolved, starting from position &#39;recIdx&#39;.
virtual void RemoveOverlayElement(TGLOverlayElement *el)
Remove overlay element.
TGLViewerBase & operator=(const TGLViewerBase &)
Abstract clipping shape - derives from TGLPhysicalShape Adds clip mode (inside/outside) and pure virt...
Definition: TGLClip.h:31
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual ~TGLViewerBase()
Destructor.
Short_t Style() const
void SetOLLineW(Float_t w)
virtual void RenderSelected()
Render selected objects from all scenes.
Float_t WFLineW() const
An overlay element.
Definition: TGLOverlay.h:22
Base class for GL viewers.
Definition: TGLViewerBase.h:36
Bool_t FindClosestOpaqueRecord(TGLSelectRecord &rec, Int_t &recIdx)
Find next select record that can be resolved and whose result is not transparent, starting from posit...
Short_t LOD() const
virtual void PostRenderOverlaySelection()
Perform cleanup after overlay selection.
#define ClassDef(name, id)
Definition: Rtypes.h:320
TGLRnrCtx * fRnrCtx
Definition: TGLViewerBase.h:62
virtual void ResetSceneInfos()
Force rebuild of view-dependent scene-info structures.
virtual void RenderSelectedForHighlight()
Render selected objects from all scenes for highlight.
TGLRnrCtx & RnrCtx() const
Float_t OLLineW() const
TGLLogicalShape * FindLogicalInScenes(TObject *id)
Find logical-shape representing object id in the list of scenes.
TGLRnrCtx * GetRnrCtx() const
TGLBoundingBox fOverallBoundingBox
Definition: TGLViewerBase.h:77
ROOT::R::TRInterface & r
Definition: Object.C:4
TGLCamera * fCamera
Definition: TGLViewerBase.h:64
virtual void PreRender()
Initialize render-context, setup camera, GL, render-area.
virtual void Changed()
Standard selection record including information about containing scene and details ob out selected ob...
void SetClip(TGLClip *p)
void SubRenderScenes(SubRender_foo render_foo)
Call sub-rendering function render_foo on all currently visible scenes.
short Short_t
Definition: RtypesCore.h:35
virtual void RenderTransparent(Bool_t rnr_non_selected=kTRUE, Bool_t rnr_selected=kTRUE)
Render transparent objects from all scenes.
virtual void PostRender()
Function called after rendering is finished.
Short_t fStyle
Definition: TGLViewerBase.h:67
virtual void RenderOpaque(Bool_t rnr_non_selected=kTRUE, Bool_t rnr_selected=kTRUE)
Render opaque objects from all scenes.
virtual void DeleteOverlayElements(TGLOverlayElement::ERole r)
Delete overlay elements.
Bool_t fResetSceneInfosOnRender
Definition: TGLViewerBase.h:71
Abstract logical shape - a GL &#39;drawable&#39; - base for all shapes - faceset sphere etc.
SceneInfoVec_t::iterator SceneInfoVec_i
Definition: TGLViewerBase.h:47
virtual void PreRenderOverlaySelection()
Perform minimal initialization for overlay selection.
virtual void RenderOverlay(Int_t state, Bool_t selection)
Render overlay objects.
virtual void AddOverlayElement(TGLOverlayElement *el)
Add overlay element.
void SetLOD(Short_t lod)
std::vector< TGLSceneInfo * > SceneInfoVec_t
Definition: TGLViewerBase.h:46
TGLClip * fClip
Definition: TGLViewerBase.h:65
virtual const char * LockIdStr() const
Name to print in locking output.
TGLSceneInfo * AddScene(TGLSceneBase *scene)
Add new scene, appropriate scene-info is created.
virtual void RenderNonSelected()
Render non-selected objects from all scenes.
TGLClip * Clip() const
Float_t fOLLineW
Definition: TGLViewerBase.h:69
const TGLBoundingBox & RefOverallBoundingBox() const
Bool_t FindClosestOverlayRecord(TGLOvlSelectRecord &rec, Int_t &recIdx)
Find next overlay-select record that can be resolved, starting from position &#39;recIdx&#39;.
virtual void MergeSceneBBoxes(TGLBoundingBox &bbox)
Merge bounding-boxes of all active registered scenes.
SceneInfoList_i FindScene(TGLSceneBase *scene)
Find scene-info corresponding to scene.
void RemoveAllScenes()
Remove all scenes from the viewer, their scene-infos are deleted.
Mother of all ROOT objects.
Definition: TObject.h:37
Concrete class describing an orientated (free) or axis aligned box of 8 vertices. ...
typedef void((*Func_t)())
SceneInfoList_t fScenes
Definition: TGLViewerBase.h:74
virtual void DeleteOverlayAnnotations()
Delete overlay elements that are annotations.
void RemoveScene(TGLSceneBase *scene)
Remove scene from the viewer, its scene-info is deleted.
Base class for extended scene context.
Definition: TGLSceneInfo.h:26
Float_t fWFLineW
Definition: TGLViewerBase.h:68
SceneInfoList_t::iterator SceneInfoList_i
Definition: TGLViewerBase.h:44
Selection record for overlay objects.
Simple locking interface used by viewer and scene.
Definition: TGLLockable.h:17
Bool_t ResolveSelectRecord(TGLSelectRecord &rec, Int_t recIdx)
Process selection record on buffer-position &#39;recIdx&#39; and fill the data into &#39;rec&#39;.
void SetWFLineW(Float_t w)
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual Bool_t IsChanged() const
void SetStyle(Short_t st)
TGLSceneInfo * GetSceneInfo(TGLSceneBase *scene)
Find scene-info corresponding to scene.
OverlayElmVec_t fOverlay
Definition: TGLViewerBase.h:79