Logo ROOT  
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
TGLLogicalShape::UpdateBoundingBox
virtual void UpdateBoundingBox()
Definition: TGLLogicalShape.h:87
TGLLogicalShape::Ref
UInt_t Ref() const
Definition: TGLLogicalShape.h:73
TGLSceneBase
Scene base-class – provides basic interface expected by the TGLViewer or its sub-classes:
Definition: TGLSceneBase.h:33
TGLLogicalShape::fRef
UInt_t fRef
Definition: TGLLogicalShape.h:46
TGLLogicalShape::kLODAxesAll
@ kLODAxesAll
Definition: TGLLogicalShape.h:42
TGLLogicalShape::SupportedLODAxes
virtual ELODAxes SupportedLODAxes() const
Definition: TGLLogicalShape.h:98
UShort_t
unsigned short UShort_t
Definition: RtypesCore.h:40
TGLLogicalShape::kLODAxesZ
@ kLODAxesZ
Definition: TGLLogicalShape.h:41
TGLLogicalShape::KeepDuringSmartRefresh
virtual Bool_t KeepDuringSmartRefresh() const
Definition: TGLLogicalShape.h:108
TGLLogicalShape::~TGLLogicalShape
virtual ~TGLLogicalShape()
Destroy logical shape.
Definition: TGLLogicalShape.cxx:140
TGLLogicalShape::fOwnExtObj
Bool_t fOwnExtObj
Strong ref (delete on 0 ref); not in scene.
Definition: TGLLogicalShape.h:57
TGLLogicalShape::IgnoreSizeForOfInterest
virtual Bool_t IgnoreSizeForOfInterest() const
Return true if size of this shape should be ignored when determining if the object should be drawn.
Definition: TGLLogicalShape.cxx:472
TGLLogicalShape::fExternalObj
TObject * fExternalObj
first replica
Definition: TGLLogicalShape.h:49
TGLLogicalShape::UpdateBoundingBoxesOfPhysicals
void UpdateBoundingBoxesOfPhysicals()
Update bounding-boxed of all dependent physicals.
Definition: TGLLogicalShape.cxx:246
TGLLogicalShape::DrawHighlight
virtual void DrawHighlight(TGLRnrCtx &rnrCtx, const TGLPhysicalShape *pshp, Int_t lvl=-1) const
Draw the logical shape in highlight mode.
Definition: TGLLogicalShape.cxx:428
TGLLogicalShape::fFirstPhysical
TGLPhysicalShape * fFirstPhysical
physical instance ref counting
Definition: TGLLogicalShape.h:47
TGLLogicalShape::fScene
TGLScene * fScene
Shape's bounding box.
Definition: TGLLogicalShape.h:51
TGLLogicalShape::ID
TObject * ID() const
Definition: TGLLogicalShape.h:82
TGLLogicalShape::GetExternal
TObject * GetExternal() const
Definition: TGLLogicalShape.h:83
x
Double_t x[n]
Definition: legend1.C:17
TGLLogicalShape::DLCacheClear
virtual void DLCacheClear()
Clear all entries for all LODs for this drawable from the display list cache but keeping the reserved...
Definition: TGLLogicalShape.cxx:303
TGLLogicalShape::kLODAxesX
@ kLODAxesX
Definition: TGLLogicalShape.h:39
TGLLogicalShape::UnrefFirstPhysical
UInt_t UnrefFirstPhysical()
Unreferenced first physical in the list, returning its id and making it fit for destruction somewhere...
Definition: TGLLogicalShape.cxx:226
TGLBoundingBox.h
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGLBoundingBox
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
Definition: TGLBoundingBox.h:33
TGLLogicalShape::TGLLogicalShape
TGLLogicalShape(const TGLLogicalShape &)
TGLLogicalShape::SupportsSecondarySelect
virtual Bool_t SupportsSecondarySelect() const
Definition: TGLLogicalShape.h:110
bool
TGLScene
TGLScene provides management and rendering of ROOT's default 3D /object representation as logical and...
Definition: TGLScene.h:29
TGLLogicalShape::PurgeDLRange
void PurgeDLRange(UInt_t base, Int_t size) const
External object is a fake.
Definition: TGLLogicalShape.cxx:343
TGLLogicalShape::SubRef
void SubRef(TGLPhysicalShape *phys) const
Remove reference to given physical shape, potentially deleting this object when hitting zero ref-coun...
Definition: TGLLogicalShape.cxx:175
TContextMenu
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:44
TGLLogicalShape::fgUseDLsForVertArrs
static Bool_t fgUseDLsForVertArrs
global flag for usage of display-lists
Definition: TGLLogicalShape.h:64
TBuffer3D
Generic 3D primitive description class.
Definition: TBuffer3D.h:18
TGLViewer
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:55
TGLLogicalShape::kLODAxesY
@ kLODAxesY
Definition: TGLLogicalShape.h:40
TGLLogicalShape::Draw
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw the GL drawable, using draw flags.
Definition: TGLLogicalShape.cxx:374
TGLLogicalShape::SetEnvDefaults
static void SetEnvDefaults()
Definition: TGLLogicalShape.cxx:497
size
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
TGLLogicalShape::DestroyPhysicals
void DestroyPhysicals()
Destroy all physicals attached to this logical.
Definition: TGLLogicalShape.cxx:206
TGLSelectRecord
Standard selection record including information about containing scene and details ob out selected ob...
Definition: TGLSelectRecord.h:75
TGLLogicalShape::AddRef
void AddRef(TGLPhysicalShape *phys) const
Add reference to given physical shape.
Definition: TGLLogicalShape.cxx:163
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TGLLogicalShape::ProcessSelection
virtual void ProcessSelection(TGLRnrCtx &rnrCtx, TGLSelectRecord &rec)
Virtual method called-back after a secondary selection hit is recorded (see TGLViewer::HandleButton()...
Definition: TGLLogicalShape.cxx:445
TGLLogicalShape::QuantizeShapeLOD
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.
Definition: TGLLogicalShape.cxx:362
TGLLogicalShape::fBoundingBox
TGLBoundingBox fBoundingBox
Also plays the role of ID.
Definition: TGLLogicalShape.h:50
TGLLogicalShape::ShouldDLCache
virtual Bool_t ShouldDLCache(const TGLRnrCtx &rnrCtx) const
Returns kTRUE if draws should be display list cached kFALSE otherwise.
Definition: TGLLogicalShape.cxx:289
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TGLLogicalShape::fDLBase
UInt_t fDLBase
scene where object is stored (can be zero!)
Definition: TGLLogicalShape.h:52
y
Double_t y[n]
Definition: legend1.C:17
TGLLogicalShape::fgUseDLs
static Bool_t fgUseDLs
Definition: TGLLogicalShape.h:63
Short_t
short Short_t
Definition: RtypesCore.h:39
TGLLogicalShape::fDLCache
Bool_t fDLCache
display-list validity bit-field
Definition: TGLLogicalShape.h:55
TGLLogicalShape::DLOffset
virtual UInt_t DLOffset(Short_t) const
Definition: TGLLogicalShape.h:93
TGLLogicalShape::fRefStrong
Bool_t fRefStrong
use display list caching
Definition: TGLLogicalShape.h:56
TGLLogicalShape::fDLSize
Int_t fDLSize
display-list id base
Definition: TGLLogicalShape.h:53
TGLLogicalShape::StrongRef
void StrongRef(Bool_t strong) const
Definition: TGLLogicalShape.h:76
unsigned int
TGLLogicalShape::GetFirstPhysical
const TGLPhysicalShape * GetFirstPhysical() const
Definition: TGLLogicalShape.h:80
TGLLogicalShape::SetDLCache
Bool_t SetDLCache(Bool_t cached)
Modify capture of draws into display list cache kTRUE - capture, kFALSE direct draw.
Definition: TGLLogicalShape.cxx:265
TGLLogicalShape::TGLLogicalShape
TGLLogicalShape()
global flag for usage of display-lists in shapes that use vertex arrays
Definition: TGLLogicalShape.cxx:74
TGLLogicalShape::fgIgnoreSizeForCameraInterest
static Bool_t fgIgnoreSizeForCameraInterest
Definition: TGLLogicalShape.h:61
TGLLogicalShape::InvokeContextMenu
void InvokeContextMenu(TContextMenu &menu, UInt_t x, UInt_t y) const
Invoke popup menu or our bound external TObject (if any), using passed 'menu' object,...
Definition: TGLLogicalShape.cxx:458
TGLLogicalShape::GetIgnoreSizeForCameraInterest
static Bool_t GetIgnoreSizeForCameraInterest()
Get state of static fgIgnoreSizeForCameraInterest flag.
Definition: TGLLogicalShape.cxx:481
TGLLogicalShape::BoundingBox
const TGLBoundingBox & BoundingBox() const
Definition: TGLLogicalShape.h:86
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGLLogicalShape
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
Definition: TGLLogicalShape.h:30
TGLPhysicalShape
Concrete physical shape - a GL drawable.
Definition: TGLPhysicalShape.h:32
TGLLogicalShape::operator=
TGLLogicalShape & operator=(const TGLLogicalShape &)
TGLLogicalShape::fDLValid
UShort_t fDLValid
display-list size for different LODs
Definition: TGLLogicalShape.h:54
TGLLogicalShape::ELODAxes
ELODAxes
Definition: TGLLogicalShape.h:38
TGLLogicalShape::SetIgnoreSizeForCameraInterest
static void SetIgnoreSizeForCameraInterest(Bool_t isfci)
Set state of static fgIgnoreSizeForCameraInterest flag.
Definition: TGLLogicalShape.cxx:489
TGLLogicalShape::DirectDraw
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const =0
TGLLogicalShape::DLCacheDrop
virtual void DLCacheDrop()
Drop all entries for all LODs for this drawable from the display list cache, WITHOUT returning the re...
Definition: TGLLogicalShape.cxx:315
TGLLogicalShape::kLODAxesNone
@ kLODAxesNone
Definition: TGLLogicalShape.h:38
TGLLogicalShape::DLCachePurge
virtual void DLCachePurge()
Purge all entries for all LODs for this drawable from the display list cache, returning the reserved ...
Definition: TGLLogicalShape.cxx:329
TGLRnrCtx
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:41
int
TGLLogicalShape::GetScene
TGLScene * GetScene() const
Definition: TGLLogicalShape.h:84
TGLLogicalShape::AlwaysSecondarySelect
virtual Bool_t AlwaysSecondarySelect() const
Definition: TGLLogicalShape.h:111