Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGLObject.h
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 #ifndef ROOT_TGLObject
13 #define ROOT_TGLObject
14 
15 #include "TGLLogicalShape.h"
16 #include "TMap.h"
17 #include <stdexcept>
18 
19 class TClass;
20 
21 class TGLObject : public TGLLogicalShape
22 {
23 private:
24  static TMap fgGLClassMap;
25  static TClass* SearchGLRenderer(TClass* cls);
26 
27 protected:
28  mutable Bool_t fMultiColor; // Are multiple colors used for object rendering.
29 
30  Bool_t SetModelCheckClass(TObject* obj, TClass* cls);
31 
32  void SetAxisAlignedBBox(Float_t xmin, Float_t xmax,
33  Float_t ymin, Float_t ymax,
34  Float_t zmin, Float_t zmax);
35  void SetAxisAlignedBBox(const Float_t* p);
36 
37  template <class TT> TT* SetModelDynCast(TObject* obj)
38  {
39  TT *ret = dynamic_cast<TT*>(obj);
40  if (!ret) throw std::runtime_error("Object of wrong type passed.");
41  fExternalObj = obj;
42  return ret;
43  }
44 
45  template <class TT> TT* DynCast(TObject* obj)
46  {
47  TT *ret = dynamic_cast<TT*>(obj);
48  if (!ret) throw std::runtime_error("Object of wrong type passed.");
49  return ret;
50  }
51 
52 public:
53  TGLObject() : TGLLogicalShape(0), fMultiColor(kFALSE) {}
54  virtual ~TGLObject() {}
55 
56  virtual Bool_t ShouldDLCache(const TGLRnrCtx& rnrCtx) const;
57 
58  // Kept from TGLLogicalShape
59  // virtual ELODAxes SupportedLODAxes() const { return kLODAxesNone; }
60 
61  // Changed from TGLLogicalShape
62  virtual Bool_t KeepDuringSmartRefresh() const { return kTRUE; }
63  virtual void UpdateBoundingBox();
64 
65  // TGLObject virtuals
66  virtual Bool_t SetModel(TObject* obj, const Option_t* opt=0) = 0;
67  virtual void SetBBox() = 0;
68  // Abstract method from TGLLogicalShape:
69  // virtual void DirectDraw(TGLRnrCtx & rnrCtx) const = 0;
70 
71  // Interface to class .vs. classGL map.
72  static TClass* GetGLRenderer(TClass* isa);
73 
74  ClassDef(TGLObject, 0); // Base-class for direct OpenGL renderers
75 };
76 
77 #endif