Logo ROOT   6.10/09
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 public:
66  TGLLogicalShape(const TBuffer3D & buffer);
67  virtual ~TGLLogicalShape();
68 
69  // Physical shape reference-counting, replica management
70  UInt_t Ref() const { return fRef; }
71  void AddRef(TGLPhysicalShape* phys) const;
72  void SubRef(TGLPhysicalShape* phys) const;
73  void StrongRef(Bool_t strong) const { fRefStrong = strong; }
74  void DestroyPhysicals();
76 
78 
79  TObject* ID() const { return fExternalObj; }
80  TObject* GetExternal() const { return fExternalObj; }
81  TGLScene* GetScene() const { return fScene; }
82 
83  const TGLBoundingBox& BoundingBox() const { return fBoundingBox; }
84  virtual void UpdateBoundingBox() {}
86 
87  // Display List Caching
88  Bool_t SetDLCache(Bool_t cached);
89  virtual Bool_t ShouldDLCache(const TGLRnrCtx & rnrCtx) const;
90  virtual UInt_t DLOffset(Short_t /*lod*/) const { return 0; }
91  virtual void DLCacheClear();
92  virtual void DLCacheDrop();
93  virtual void DLCachePurge();
94 
95  virtual ELODAxes SupportedLODAxes() const { return kLODAxesNone; }
96  virtual Short_t QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const;
97  virtual void Draw(TGLRnrCtx& rnrCtx) const;
98  virtual void DirectDraw(TGLRnrCtx& rnrCtx) const = 0; // Actual draw method (non DL cached)
99 
100  virtual void DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* pshp, Int_t lvl=-1) const;
101 
102  virtual Bool_t IgnoreSizeForOfInterest() const;
103 
104  // Override in sub-classes that do direct object rendering (e.g. TGLObject).
105  virtual Bool_t KeepDuringSmartRefresh() const { return kFALSE; }
106  // Override in sub-classes that support secondary selection (e.g. TPointSet3DGL).
107  virtual Bool_t SupportsSecondarySelect() const { return kFALSE; }
108  virtual Bool_t AlwaysSecondarySelect() const { return kFALSE; }
109  virtual void ProcessSelection(TGLRnrCtx& rnrCtx, TGLSelectRecord& rec);
110 
111  void InvokeContextMenu(TContextMenu & menu, UInt_t x, UInt_t y) const;
112 
114  static void SetIgnoreSizeForCameraInterest(Bool_t isfci);
115 
116  ClassDef(TGLLogicalShape,0) // a logical (non-placed, local frame) drawable object
117 };
118 
119 
120 #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.
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:297
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: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()
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.
const Bool_t kFALSE
Definition: RtypesCore.h:92
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