// @(#)root/gl:$Id$
// Author: Matevz Tadel  7/4/2006

/*************************************************************************
 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGLObject
#define ROOT_TGLObject

#include "TGLLogicalShape.h"
#include "TMap.h"
#include <stdexcept>

class TClass;

class TGLObject : public TGLLogicalShape
{
private:
   static TMap    fgGLClassMap;
   static TClass* SearchGLRenderer(TClass* cls);

protected:
   mutable Bool_t fMultiColor; // Are multiple colors used for object rendering.

   Bool_t SetModelCheckClass(TObject* obj, TClass* cls);

   void   SetAxisAlignedBBox(Float_t xmin, Float_t xmax,
                             Float_t ymin, Float_t ymax,
                             Float_t zmin, Float_t zmax);
   void   SetAxisAlignedBBox(const Float_t* p);

   template <class TT> TT* SetModelDynCast(TObject* obj)
   {
      TT *ret = dynamic_cast<TT*>(obj);
      if (!ret) throw std::runtime_error("Object of wrong type passed.");
      fExternalObj = obj;
      return ret;
   }

   template <class TT> TT* DynCast(TObject* obj)
   {
      TT *ret = dynamic_cast<TT*>(obj);
      if (!ret) throw std::runtime_error("Object of wrong type passed.");
      return ret;
   }

public:
   TGLObject() : TGLLogicalShape(0), fMultiColor(kFALSE) {}
   virtual ~TGLObject() {}

   virtual Bool_t ShouldDLCache(const TGLRnrCtx& rnrCtx) const;

   // Kept from TGLLogicalShape
   // virtual ELODAxes SupportedLODAxes() const { return kLODAxesNone; }

   // Changed from TGLLogicalShape
   virtual Bool_t KeepDuringSmartRefresh() const { return kTRUE; }
   virtual void   UpdateBoundingBox();

   // TGLObject virtuals
   virtual Bool_t SetModel(TObject* obj, const Option_t* opt=0) = 0;
   virtual void   SetBBox() = 0;
   // Abstract method from TGLLogicalShape:
   // virtual void DirectDraw(TGLRnrCtx & rnrCtx) const = 0;

   // Interface to class .vs. classGL map.
   static TClass* GetGLRenderer(TClass* isa);

   ClassDef(TGLObject, 0); // Base-class for direct OpenGL renderers
};

#endif
 TGLObject.h:1
 TGLObject.h:2
 TGLObject.h:3
 TGLObject.h:4
 TGLObject.h:5
 TGLObject.h:6
 TGLObject.h:7
 TGLObject.h:8
 TGLObject.h:9
 TGLObject.h:10
 TGLObject.h:11
 TGLObject.h:12
 TGLObject.h:13
 TGLObject.h:14
 TGLObject.h:15
 TGLObject.h:16
 TGLObject.h:17
 TGLObject.h:18
 TGLObject.h:19
 TGLObject.h:20
 TGLObject.h:21
 TGLObject.h:22
 TGLObject.h:23
 TGLObject.h:24
 TGLObject.h:25
 TGLObject.h:26
 TGLObject.h:27
 TGLObject.h:28
 TGLObject.h:29
 TGLObject.h:30
 TGLObject.h:31
 TGLObject.h:32
 TGLObject.h:33
 TGLObject.h:34
 TGLObject.h:35
 TGLObject.h:36
 TGLObject.h:37
 TGLObject.h:38
 TGLObject.h:39
 TGLObject.h:40
 TGLObject.h:41
 TGLObject.h:42
 TGLObject.h:43
 TGLObject.h:44
 TGLObject.h:45
 TGLObject.h:46
 TGLObject.h:47
 TGLObject.h:48
 TGLObject.h:49
 TGLObject.h:50
 TGLObject.h:51
 TGLObject.h:52
 TGLObject.h:53
 TGLObject.h:54
 TGLObject.h:55
 TGLObject.h:56
 TGLObject.h:57
 TGLObject.h:58
 TGLObject.h:59
 TGLObject.h:60
 TGLObject.h:61
 TGLObject.h:62
 TGLObject.h:63
 TGLObject.h:64
 TGLObject.h:65
 TGLObject.h:66
 TGLObject.h:67
 TGLObject.h:68
 TGLObject.h:69
 TGLObject.h:70
 TGLObject.h:71
 TGLObject.h:72
 TGLObject.h:73
 TGLObject.h:74
 TGLObject.h:75
 TGLObject.h:76
 TGLObject.h:77