Logo ROOT   6.08/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 #ifndef ROOT_TGLBoundingBox
16 #include "TGLBoundingBox.h"
17 #endif
18 
19 class TBuffer3D;
20 class TObject;
21 class TContextMenu;
22 
23 class TGLPhysicalShape;
24 class TGLRnrCtx;
25 class TGLSelectRecord;
26 class TGLViewer;
27 class TGLSceneBase;
28 class TGLScene;
29 
30 
32 {
33  friend class TGLScene;
34 
35 private:
36  TGLLogicalShape(const TGLLogicalShape&); // Not implemented.
37  TGLLogicalShape& operator=(const TGLLogicalShape&); // Not implemented.
38 
39 public:
40  enum ELODAxes { kLODAxesNone = 0, // LOD will be set to high or pixel.
41  kLODAxesX = 1 << 0,
42  kLODAxesY = 1 << 1,
43  kLODAxesZ = 1 << 2,
45  };
46 
47 protected:
48  mutable UInt_t fRef; //! physical instance ref counting
49  mutable TGLPhysicalShape *fFirstPhysical; //! first replica
50 
51  TObject *fExternalObj; //! Also plays the role of ID.
52  TGLBoundingBox fBoundingBox; //! Shape's bounding box.
53  mutable TGLScene *fScene; //! scene where object is stored (can be zero!)
54  mutable UInt_t fDLBase; //! display-list id base
55  mutable Int_t fDLSize; //! display-list size for different LODs
56  mutable UShort_t fDLValid; //! display-list validity bit-field
57  mutable Bool_t fDLCache; //! use display list caching
58  mutable Bool_t fRefStrong; //! Strong ref (delete on 0 ref); not in scene
59  mutable Bool_t fOwnExtObj; //! External object is a fake
60 
61  void PurgeDLRange(UInt_t base, Int_t size) const;
62 
64 
65 public:
68  TGLLogicalShape(const TBuffer3D & buffer);
69  virtual ~TGLLogicalShape();
70 
71  // Physical shape reference-counting, replica management
72  UInt_t Ref() const { return fRef; }
73  void AddRef(TGLPhysicalShape* phys) const;
74  void SubRef(TGLPhysicalShape* phys) const;
75  void StrongRef(Bool_t strong) const { fRefStrong = strong; }
76  void DestroyPhysicals();
78 
80 
81  TObject* ID() const { return fExternalObj; }
82  TObject* GetExternal() const { return fExternalObj; }
83  TGLScene* GetScene() const { return fScene; }
84 
85  const TGLBoundingBox& BoundingBox() const { return fBoundingBox; }
86  virtual void UpdateBoundingBox() {}
88 
89  // Display List Caching
90  Bool_t SetDLCache(Bool_t cached);
91  virtual Bool_t ShouldDLCache(const TGLRnrCtx & rnrCtx) const;
92  virtual UInt_t DLOffset(Short_t /*lod*/) const { return 0; }
93  virtual void DLCacheClear();
94  virtual void DLCacheDrop();
95  virtual void DLCachePurge();
96 
97  virtual ELODAxes SupportedLODAxes() const { return kLODAxesNone; }
98  virtual Short_t QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const;
99  virtual void Draw(TGLRnrCtx& rnrCtx) const;
100  virtual void DirectDraw(TGLRnrCtx& rnrCtx) const = 0; // Actual draw method (non DL cached)
101 
102  virtual void DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* pshp, Int_t lvl=-1) const;
103 
104  virtual Bool_t IgnoreSizeForOfInterest() const;
105 
106  // Override in sub-classes that do direct object rendering (e.g. TGLObject).
107  virtual Bool_t KeepDuringSmartRefresh() const { return kFALSE; }
108  // Override in sub-classes that support secondary selection (e.g. TPointSet3DGL).
109  virtual Bool_t SupportsSecondarySelect() const { return kFALSE; }
110  virtual Bool_t AlwaysSecondarySelect() const { return kFALSE; }
111  virtual void ProcessSelection(TGLRnrCtx& rnrCtx, TGLSelectRecord& rec);
112 
113  void InvokeContextMenu(TContextMenu & menu, UInt_t x, UInt_t y) const;
114 
116  static void SetIgnoreSizeForCameraInterest(Bool_t isfci);
117 
118  ClassDef(TGLLogicalShape,0) // a logical (non-placed, local frame) drawable object
119 };
120 
121 
122 #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
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.
const Bool_t kFALSE
Definition: Rtypes.h:92
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:254
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
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:44
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:19
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()
Constructor.
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.
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