Logo ROOT   6.12/07
Reference Guide
TGLLogicalShape.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Richard Maunder 25/05/2005
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_TGLLogicalShape
13 #define ROOT_TGLLogicalShape
14 
15 #include "TGLBoundingBox.h"
16 
17 class TBuffer3D;
18 class TObject;
19 class TContextMenu;
20 
21 class TGLPhysicalShape;
22 class TGLRnrCtx;
23 class TGLSelectRecord;
24 class TGLViewer;
25 class TGLSceneBase;
26 class TGLScene;
27 
28 
30 {
31  friend class TGLScene;
32 
33 private:
34  TGLLogicalShape(const TGLLogicalShape&); // Not implemented.
35  TGLLogicalShape& operator=(const TGLLogicalShape&); // Not implemented.
36 
37 public:
38  enum ELODAxes { kLODAxesNone = 0, // LOD will be set to high or pixel.
39  kLODAxesX = 1 << 0,
40  kLODAxesY = 1 << 1,
41  kLODAxesZ = 1 << 2,
43  };
44 
45 protected:
46  mutable UInt_t fRef; //! physical instance ref counting
47  mutable TGLPhysicalShape *fFirstPhysical; //! first replica
48 
49  TObject *fExternalObj; //! Also plays the role of ID.
50  TGLBoundingBox fBoundingBox; //! Shape's bounding box.
51  mutable TGLScene *fScene; //! scene where object is stored (can be zero!)
52  mutable UInt_t fDLBase; //! display-list id base
53  mutable Int_t fDLSize; //! display-list size for different LODs
54  mutable UShort_t fDLValid; //! display-list validity bit-field
55  mutable Bool_t fDLCache; //! use display list caching
56  mutable Bool_t fRefStrong; //! Strong ref (delete on 0 ref); not in scene
57  mutable Bool_t fOwnExtObj; //! External object is a fake
58 
59  void PurgeDLRange(UInt_t base, Int_t size) const;
60 
62 
63  static Bool_t fgUseDLs; //! global flag for usage of display-lists
64  static Bool_t fgUseDLsForVertArrs; //! global flag for usage of display-lists in shapes that use vertex arrays
65 
66 public:
69  TGLLogicalShape(const TBuffer3D & buffer);
70  virtual ~TGLLogicalShape();
71 
72  // Physical shape reference-counting, replica management
73  UInt_t Ref() const { return fRef; }
74  void AddRef(TGLPhysicalShape* phys) const;
75  void SubRef(TGLPhysicalShape* phys) const;
76  void StrongRef(Bool_t strong) const { fRefStrong = strong; }
77  void DestroyPhysicals();
79 
81 
82  TObject* ID() const { return fExternalObj; }
83  TObject* GetExternal() const { return fExternalObj; }
84  TGLScene* GetScene() const { return fScene; }
85 
86  const TGLBoundingBox& BoundingBox() const { return fBoundingBox; }
87  virtual void UpdateBoundingBox() {}
89 
90  // Display List Caching
91  Bool_t SetDLCache(Bool_t cached);
92  virtual Bool_t ShouldDLCache(const TGLRnrCtx & rnrCtx) const;
93  virtual UInt_t DLOffset(Short_t /*lod*/) const { return 0; }
94  virtual void DLCacheClear();
95  virtual void DLCacheDrop();
96  virtual void DLCachePurge();
97 
98  virtual ELODAxes SupportedLODAxes() const { return kLODAxesNone; }
99  virtual Short_t QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const;
100  virtual void Draw(TGLRnrCtx& rnrCtx) const;
101  virtual void DirectDraw(TGLRnrCtx& rnrCtx) const = 0; // Actual draw method (non DL cached)
102 
103  virtual void DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* pshp, Int_t lvl=-1) const;
104 
105  virtual Bool_t IgnoreSizeForOfInterest() const;
106 
107  // Override in sub-classes that do direct object rendering (e.g. TGLObject).
108  virtual Bool_t KeepDuringSmartRefresh() const { return kFALSE; }
109  // Override in sub-classes that support secondary selection (e.g. TPointSet3DGL).
110  virtual Bool_t SupportsSecondarySelect() const { return kFALSE; }
111  virtual Bool_t AlwaysSecondarySelect() const { return kFALSE; }
112  virtual void ProcessSelection(TGLRnrCtx& rnrCtx, TGLSelectRecord& rec);
113 
114  void InvokeContextMenu(TContextMenu & menu, UInt_t x, UInt_t y) const;
115 
117  static void SetIgnoreSizeForCameraInterest(Bool_t isfci);
118 
119  static void SetEnvDefaults();
120 
121  ClassDef(TGLLogicalShape,0) // a logical (non-placed, local frame) drawable object
122 };
123 
124 
125 #endif // ROOT_TGLLogicalShape
virtual void DLCacheDrop()
Drop all entries for all LODs for this drawable from the display list cache, WITHOUT returning the re...
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
virtual void ProcessSelection(TGLRnrCtx &rnrCtx, TGLSelectRecord &rec)
Virtual method called-back after a secondary selection hit is recorded (see TGLViewer::HandleButton()...
virtual Short_t QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const
Logical shapes usually support only discreet LOD values, especially in view of display-list caching...
UInt_t fDLBase
scene where object is stored (can be zero!)
void UpdateBoundingBoxesOfPhysicals()
Update bounding-boxed of all dependent physicals.
unsigned short UShort_t
Definition: RtypesCore.h:36
Int_t fDLSize
display-list id base
UShort_t fDLValid
display-list size for different LODs
Scene base-class – provides basic interface expected by the TGLViewer or its sub-classes: ...
Definition: TGLSceneBase.h:32
static void SetEnvDefaults()
void DestroyPhysicals()
Destroy all physicals attached to this logical.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void AddRef(TGLPhysicalShape *phys) const
Add reference to given physical shape.
static Bool_t GetIgnoreSizeForCameraInterest()
Get state of static fgIgnoreSizeForCameraInterest flag.
virtual Bool_t SupportsSecondarySelect() const
Concrete physical shape - a GL drawable.
TGLScene * fScene
Shape&#39;s bounding box.
Double_t x[n]
Definition: legend1.C:17
void SubRef(TGLPhysicalShape *phys) const
Remove reference to given physical shape, potentially deleting this object when hitting zero ref-coun...
#define ClassDef(name, id)
Definition: Rtypes.h:320
static Bool_t fgUseDLs
virtual UInt_t DLOffset(Short_t) const
static void SetIgnoreSizeForCameraInterest(Bool_t isfci)
Set state of static fgIgnoreSizeForCameraInterest flag.
virtual ~TGLLogicalShape()
Destroy logical shape.
virtual void DLCachePurge()
Purge all entries for all LODs for this drawable from the display list cache, returning the reserved ...
TObject * fExternalObj
first replica
const TGLBoundingBox & BoundingBox() const
static Bool_t fgUseDLsForVertArrs
global flag for usage of display-lists
TObject * GetExternal() const
virtual void DrawHighlight(TGLRnrCtx &rnrCtx, const TGLPhysicalShape *pshp, Int_t lvl=-1) const
Draw the logical shape in highlight mode.
TGLPhysicalShape * fFirstPhysical
physical instance ref counting
Standard selection record including information about containing scene and details ob out selected ob...
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:40
UInt_t UnrefFirstPhysical()
Unreferenced first physical in the list, returning its id and making it fit for destruction somewhere...
unsigned int UInt_t
Definition: RtypesCore.h:42
const TGLPhysicalShape * GetFirstPhysical() const
short Short_t
Definition: RtypesCore.h:35
Generic 3D primitive description class.
Definition: TBuffer3D.h:17
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:53
Bool_t SetDLCache(Bool_t cached)
Modify capture of draws into display list cache kTRUE - capture, kFALSE direct draw.
TGLLogicalShape()
global flag for usage of display-lists in shapes that use vertex arrays
virtual Bool_t KeepDuringSmartRefresh() const
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const =0
Abstract logical shape - a GL &#39;drawable&#39; - base for all shapes - faceset sphere etc.
const Bool_t kFALSE
Definition: RtypesCore.h:88
Bool_t fOwnExtObj
Strong ref (delete on 0 ref); not in scene.
Bool_t fRefStrong
use display list caching
void StrongRef(Bool_t strong) const
virtual void UpdateBoundingBox()
Double_t y[n]
Definition: legend1.C:17
TGLLogicalShape & operator=(const TGLLogicalShape &)
UInt_t Ref() const
Mother of all ROOT objects.
Definition: TObject.h:37
Concrete class describing an orientated (free) or axis aligned box of 8 vertices. ...
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw the GL drawable, using draw flags.
void InvokeContextMenu(TContextMenu &menu, UInt_t x, UInt_t y) const
Invoke popup menu or our bound external TObject (if any), using passed &#39;menu&#39; object, at location &#39;x&#39; &#39;y&#39;.
virtual ELODAxes SupportedLODAxes() const
TGLScene provides management and rendering of ROOT&#39;s default 3D /object representation as logical and...
Definition: TGLScene.h:30
void PurgeDLRange(UInt_t base, Int_t size) const
External object is a fake.
TGLBoundingBox fBoundingBox
Also plays the role of ID.
virtual Bool_t IgnoreSizeForOfInterest() const
Return true if size of this shape should be ignored when determining if the object should be drawn...
Bool_t fDLCache
display-list validity bit-field
virtual Bool_t ShouldDLCache(const TGLRnrCtx &rnrCtx) const
Returns kTRUE if draws should be display list cached kFALSE otherwise.
TGLScene * GetScene() const
virtual Bool_t AlwaysSecondarySelect() const
TObject * ID() const
virtual void DLCacheClear()
Clear all entries for all LODs for this drawable from the display list cache but keeping the reserved...
static Bool_t fgIgnoreSizeForCameraInterest