Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
24class TGLSceneBase;
25class TGLSceneInfo;
26class TGLCamera;
27class TGLClip;
28class TGLRnrCtx;
29class TGLLogicalShape;
30class TGLSelectRecord;
33
34// Avoid TObject inheritance due to clash with TVirtualViewer3D.
35
36class TGLViewerBase : public TGLLockable // : public TObject
37{
38private:
39 TGLViewerBase(const TGLViewerBase&); // Not implemented
40 TGLViewerBase& operator=(const TGLViewerBase&); // Not implemented
41
42protected:
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
53
54 typedef void (TGLSceneBase::* SubRender_foo) (TGLRnrCtx &);
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
80
81 // ================================================================
82
83public:
84
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; }
115 Float_t OLLineW() const { return fOLLineW; }
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
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
short Short_t
Definition RtypesCore.h:39
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassDef(name, id)
Definition Rtypes.h:337
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
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
Simple locking interface used by viewer and scene.
Definition TGLLockable.h:18
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
An overlay element.
Definition TGLOverlay.h:23
Selection record for overlay objects.
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
Scene base-class – provides basic interface expected by the TGLViewer or its sub-classes:
Base class for extended scene context.
Standard selection record including information about containing scene and details ob out selected ob...
Base class for GL viewers.
void SetLOD(Short_t lod)
void SceneDestructing(TGLSceneBase *scene)
Remove scene, its scene-info is deleted.
OverlayElmVec_t fOverlay
virtual void RenderTransparent(Bool_t rnr_non_selected=kTRUE, Bool_t rnr_selected=kTRUE)
Render transparent objects from all scenes.
Short_t Style() const
virtual void DeleteOverlayElements(TGLOverlayElement::ERole r)
Delete overlay elements.
virtual void Changed()
virtual void PreRenderOverlaySelection()
Perform minimal initialization for overlay selection.
SceneInfoList_t fScenes
TGLRnrCtx * fRnrCtx
SceneInfoVec_t fVisScenes
TGLViewerBase & operator=(const TGLViewerBase &)
TGLCamera * fCamera
virtual ~TGLViewerBase()
Destructor.
virtual void RenderSelected()
Render selected objects from all scenes.
void SubRenderScenes(SubRender_foo render_foo)
Call sub-rendering function render_foo on all currently visible scenes.
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...
virtual void ResetSceneInfos()
Force rebuild of view-dependent scene-info structures.
TGLViewerBase(const TGLViewerBase &)
TGLSceneInfo * AddScene(TGLSceneBase *scene)
Add new scene, appropriate scene-info is created.
TGLLogicalShape * FindLogicalInScenes(TObject *id)
Find logical-shape representing object id in the list of scenes.
std::vector< TGLOverlayElement * > OverlayElmVec_t
virtual void RemoveOverlayElement(TGLOverlayElement *el)
Remove overlay element.
TGLClip * fClip
virtual void RenderOverlay(Int_t state, Bool_t selection)
Render overlay objects.
SceneInfoVec_t::iterator SceneInfoVec_i
TGLSceneInfo * GetSceneInfo(TGLSceneBase *scene)
Find scene-info corresponding to scene.
TGLClip * Clip() const
virtual void Render()
Render all scenes.
virtual void PostRenderOverlaySelection()
Perform cleanup after overlay selection.
virtual void PreRender()
Initialize render-context, setup camera, GL, render-area.
virtual void PostRender()
Function called after rendering is finished.
std::vector< TGLSceneInfo * > SceneInfoVec_t
void SetClip(TGLClip *p)
void(TGLSceneBase::* SubRender_foo)(TGLRnrCtx &)
virtual void SetupClipObject()
Setup clip-object. Protected virtual method.
void SetOLLineW(Float_t w)
TGLRnrCtx * GetRnrCtx() const
SceneInfoList_i FindScene(TGLSceneBase *scene)
Find scene-info corresponding to scene.
Bool_t FindClosestOverlayRecord(TGLOvlSelectRecord &rec, Int_t &recIdx)
Find next overlay-select record that can be resolved, starting from position 'recIdx'.
virtual void MergeSceneBBoxes(TGLBoundingBox &bbox)
Merge bounding-boxes of all active registered scenes.
OverlayElmVec_t::iterator OverlayElmVec_i
Float_t OLLineW() const
void RemoveAllScenes()
Remove all scenes from the viewer, their scene-infos are deleted.
Float_t WFLineW() const
Bool_t fResetSceneInfosOnRender
Short_t LOD() const
TGLBoundingBox fOverallBoundingBox
void RemoveScene(TGLSceneBase *scene)
Remove scene from the viewer, its scene-info is deleted.
std::list< TGLSceneInfo * > SceneInfoList_t
virtual Bool_t IsChanged() const
virtual void DeleteOverlayAnnotations()
Delete overlay elements that are annotations.
virtual void RenderNonSelected()
Render non-selected objects from all scenes.
Bool_t ResolveSelectRecord(TGLSelectRecord &rec, Int_t recIdx)
Process selection record on buffer-position 'recIdx' and fill the data into 'rec'.
void SetStyle(Short_t st)
TGLRnrCtx & RnrCtx() const
virtual void RenderSelectedForHighlight()
Render selected objects from all scenes for highlight.
virtual void RenderOpaque(Bool_t rnr_non_selected=kTRUE, Bool_t rnr_selected=kTRUE)
Render opaque objects from all scenes.
void SetWFLineW(Float_t w)
virtual const char * LockIdStr() const
Name to print in locking output.
SceneInfoList_t::iterator SceneInfoList_i
virtual void AddOverlayElement(TGLOverlayElement *el)
Add overlay element.
const TGLBoundingBox & RefOverallBoundingBox() const
Bool_t FindClosestRecord(TGLSelectRecord &rec, Int_t &recIdx)
Find next select record that can be resolved, starting from position 'recIdx'.
Mother of all ROOT objects.
Definition TObject.h:41