Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGLObject.cxx
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Matevz Tadel 7/4/2006
3
4/*************************************************************************
5 * Copyright (C) 1995-2006, 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
13#include "TGLObject.h"
14#include "TGLRnrCtx.h"
15#include "TObject.h"
16#include "TClass.h"
17#include "TBaseClass.h"
18#include "TList.h"
19#include "TString.h"
20
21/** \class TGLObject
22\ingroup opengl
23Base-class for direct OpenGL renderers.
24This allows classes to circumvent passing of TBuffer3D and
25use user-provided OpenGL code.
26By convention, if you want class TFoo : public TObject to have direct rendering
27you should also provide TFooGL : public TGLObject and implement
28abstract functions SetModel() and SetBBox().
29TAttBBox can be used to facilitate calculation of bounding-boxes.
30See TPointSet3D and TPointSet3DGL.
31*/
32
33
35
36////////////////////////////////////////////////////////////////////////////////
37/// Decide if display-list should be used for this pass rendering,
38/// as determined by rnrCtx.
39
41{
42 if (!fDLCache ||
43 !fScene ||
44 (rnrCtx.SecSelection() && SupportsSecondarySelect()) ||
45 (fMultiColor && (rnrCtx.Highlight() || rnrCtx.IsDrawPassOutlineLine())) ||
46 (AlwaysSecondarySelect() && rnrCtx.Highlight()))
47 {
48 return kFALSE;
49 }
50
51 return kTRUE;
52}
53
54////////////////////////////////////////////////////////////////////////////////
55/// Update bounding box from external source.
56/// We call abstract SetBBox() and propagate the change to all
57/// attached physicals.
58
64
65////////////////////////////////////////////////////////////////////////////////
66/// Checks if obj is of proper class and sets the model.
67/// Protected helper for subclasses.
68/// Most sub-classes use exception-throwing SetModelDynCast() instead.
69
71{
72 if(obj->InheritsFrom(cls) == kFALSE) {
73 Warning("TGLObject::SetModelCheckClass", "object of wrong class passed.");
74 return kFALSE;
75 }
76 fExternalObj = obj;
77
78 return kTRUE;
79}
80
81////////////////////////////////////////////////////////////////////////////////
82/// Set axis-aligned bounding-box.
83/// Protected helper for subclasses.
84
92
93////////////////////////////////////////////////////////////////////////////////
94/// Set axis-aligned bounding-box.
95/// Protected helper for subclasses.
96
98{
99 SetAxisAlignedBBox(p[0], p[1], p[2], p[3], p[4], p[5]);
100}
101
102
103////////////////////////////////////////////////////////////////////////////////
104/// Recursively search cls and its base classes for a GL-renderer
105/// class.
106
108{
109 TString rnr( cls->GetName() );
110 rnr += "GL";
112 if (c != nullptr)
113 return c;
114
115 TList* bases = cls->GetListOfBases();
116 if (bases == nullptr || bases->IsEmpty())
117 return nullptr;
118
120 TBaseClass* bc;
121 while ((bc = (TBaseClass*) next_base()) != nullptr) {
122 cls = bc->GetClassPointer();
123 if ((c = SearchGLRenderer(cls)) != nullptr) {
124 return c;
125 }
126 }
127 return nullptr;
128}
129
130////////////////////////////////////////////////////////////////////////////////
131/// Return direct-rendering GL class for class isa.
132/// Zero is a valid response.
133
135{
136 TPair* p = (TPair*) fgGLClassMap.FindObject(isa);
137 TClass* cls;
138 if (p != nullptr) {
139 cls = (TClass*) p->Value();
140 } else {
142 fgGLClassMap.Add(isa, cls);
143 }
144 return cls;
145}
#define c(i)
Definition RSha256.hxx:101
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
winID h TVirtualViewer3D TVirtualGLPainter p
float xmin
float ymin
float xmax
float ymax
Each class (see TClass) has a linked list of its base class(es).
Definition TBaseClass.h:33
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2973
void SetAligned(const TGLVertex3 &lowVertex, const TGLVertex3 &highVertex)
Set ALIGNED box from two low/high vertices.
virtual Bool_t SupportsSecondarySelect() const
TGLBoundingBox fBoundingBox
Also plays the role of ID.
TObject * fExternalObj
first replica
void UpdateBoundingBoxesOfPhysicals()
Update bounding-boxed of all dependent physicals.
TGLScene * fScene
Shape's bounding box.
Bool_t fDLCache
display-list validity bit-field
virtual Bool_t AlwaysSecondarySelect() const
Bool_t fMultiColor
Definition TGLObject.h:28
static TClass * SearchGLRenderer(TClass *cls)
Recursively search cls and its base classes for a GL-renderer class.
void UpdateBoundingBox() override
Update bounding box from external source.
Definition TGLObject.cxx:59
void SetAxisAlignedBBox(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax)
Set axis-aligned bounding-box.
Definition TGLObject.cxx:85
Bool_t ShouldDLCache(const TGLRnrCtx &rnrCtx) const override
Decide if display-list should be used for this pass rendering, as determined by rnrCtx.
Definition TGLObject.cxx:40
static TMap fgGLClassMap
Definition TGLObject.h:24
virtual void SetBBox()=0
Bool_t SetModelCheckClass(TObject *obj, TClass *cls)
Checks if obj is of proper class and sets the model.
Definition TGLObject.cxx:70
static TClass * GetGLRenderer(TClass *isa)
Return direct-rendering GL class for class isa.
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
3 component (x/y/z) vertex class.
Definition TGLUtil.h:84
A doubly linked list.
Definition TList.h:38
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition TMap.h:40
Mother of all ROOT objects.
Definition TObject.h:41
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
Class used by TMap to store (key,value) pairs.
Definition TMap.h:102
Basic string class.
Definition TString.h:138