00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "TGLObject.h"
00014 #include "TGLRnrCtx.h"
00015 #include "TObject.h"
00016 #include "TClass.h"
00017 #include "TBaseClass.h"
00018 #include "TList.h"
00019 #include "TString.h"
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 ClassImp(TGLObject);
00037
00038 TMap TGLObject::fgGLClassMap;
00039
00040
00041 Bool_t TGLObject::ShouldDLCache(const TGLRnrCtx& rnrCtx) const
00042 {
00043
00044
00045
00046 if (!fDLCache ||
00047 !fScene ||
00048 (rnrCtx.SecSelection() && SupportsSecondarySelect()) ||
00049 (fMultiColor && (rnrCtx.HighlightOutline() || rnrCtx.IsDrawPassOutlineLine())) ||
00050 (AlwaysSecondarySelect() && rnrCtx.Highlight()))
00051 {
00052 return kFALSE;
00053 }
00054
00055 return kTRUE;
00056 }
00057
00058
00059 void TGLObject::UpdateBoundingBox()
00060 {
00061
00062
00063
00064
00065 SetBBox();
00066 UpdateBoundingBoxesOfPhysicals();
00067 }
00068
00069
00070 Bool_t TGLObject::SetModelCheckClass(TObject* obj, TClass* cls)
00071 {
00072
00073
00074
00075
00076 if(obj->InheritsFrom(cls) == kFALSE) {
00077 Warning("TGLObject::SetModelCheckClass", "object of wrong class passed.");
00078 return kFALSE;
00079 }
00080 fExternalObj = obj;
00081
00082 return kTRUE;
00083 }
00084
00085
00086 void TGLObject::SetAxisAlignedBBox(Float_t xmin, Float_t xmax,
00087 Float_t ymin, Float_t ymax,
00088 Float_t zmin, Float_t zmax)
00089 {
00090
00091
00092
00093 fBoundingBox.SetAligned(TGLVertex3(xmin, ymin, zmin),
00094 TGLVertex3(xmax, ymax, zmax));
00095 }
00096
00097
00098 void TGLObject::SetAxisAlignedBBox(const Float_t* p)
00099 {
00100
00101
00102
00103 SetAxisAlignedBBox(p[0], p[1], p[2], p[3], p[4], p[5]);
00104 }
00105
00106
00107
00108 TClass* TGLObject::SearchGLRenderer(TClass* cls)
00109 {
00110
00111
00112
00113 TString rnr( cls->GetName() );
00114 rnr += "GL";
00115 TClass* c = TClass::GetClass(rnr);
00116 if (c != 0)
00117 return c;
00118
00119 TList* bases = cls->GetListOfBases();
00120 if (bases == 0 || bases->IsEmpty())
00121 return 0;
00122
00123 TIter next_base(bases);
00124 TBaseClass* bc;
00125 while ((bc = (TBaseClass*) next_base()) != 0) {
00126 cls = bc->GetClassPointer();
00127 if ((c = SearchGLRenderer(cls)) != 0) {
00128 return c;
00129 }
00130 }
00131 return 0;
00132 }
00133
00134
00135 TClass* TGLObject::GetGLRenderer(TClass* isa)
00136 {
00137
00138
00139
00140 TPair* p = (TPair*) fgGLClassMap.FindObject(isa);
00141 TClass* cls;
00142 if (p != 0) {
00143 cls = (TClass*) p->Value();
00144 } else {
00145 cls = SearchGLRenderer(isa);
00146 fgGLClassMap.Add(isa, cls);
00147 }
00148 return cls;
00149 }