64 ClassImp(TGLLogicalShape);
66 Bool_t TGLLogicalShape::fgIgnoreSizeForCameraInterest = kFALSE;
68 Bool_t TGLLogicalShape::fgUseDLs = kTRUE;
69 Bool_t TGLLogicalShape::fgUseDLsForVertArrs = kTRUE;
74 TGLLogicalShape::TGLLogicalShape() :
91 TGLLogicalShape::TGLLogicalShape(TObject* obj) :
108 TGLLogicalShape::TGLLogicalShape(
const TBuffer3D & buffer) :
111 fExternalObj (buffer.fID),
121 if (buffer.SectionsValid(TBuffer3D::kBoundingBox)) {
122 fBoundingBox.Set(buffer.fBBVertex);
123 }
else if (buffer.SectionsValid(TBuffer3D::kRaw)) {
125 fBoundingBox.SetAligned(buffer.NbPnts(), buffer.fPnts);
130 if (fExternalObj == 0)
132 fExternalObj =
new TNamed(
"Generic object",
"Internal object created for bookkeeping.");
140 TGLLogicalShape::~TGLLogicalShape()
145 Warning(
"TGLLogicalShape::~TGLLogicalShape",
"some physicals still lurking around.");
163 void TGLLogicalShape::AddRef(TGLPhysicalShape* phys)
const
165 phys->fNextPhysical = fFirstPhysical;
166 fFirstPhysical = phys;
175 void TGLLogicalShape::SubRef(TGLPhysicalShape* phys)
const
179 Bool_t found = kFALSE;
180 if (fFirstPhysical == phys) {
181 fFirstPhysical = phys->fNextPhysical;
184 TGLPhysicalShape *shp1 = fFirstPhysical, *shp2;
185 while ((shp2 = shp1->fNextPhysical) != 0) {
187 shp1->fNextPhysical = shp2->fNextPhysical;
194 if (found == kFALSE) {
195 Error(
"TGLLogicalShape::SubRef",
"Attempt to un-ref an unregistered physical.");
199 if (--fRef == 0 && fRefStrong)
206 void TGLLogicalShape::DestroyPhysicals()
208 TGLPhysicalShape *curr = fFirstPhysical, *next;
211 next = curr->fNextPhysical;
212 curr->fLogicalShape = 0;
226 UInt_t TGLLogicalShape::UnrefFirstPhysical()
228 if (fFirstPhysical == 0)
return 0;
230 TGLPhysicalShape *phys = fFirstPhysical;
231 UInt_t phid = phys->ID();
232 fFirstPhysical = phys->fNextPhysical;
233 phys->fLogicalShape = 0;
246 void TGLLogicalShape::UpdateBoundingBoxesOfPhysicals()
248 TGLPhysicalShape* pshp = fFirstPhysical;
251 pshp->UpdateBoundingBox();
252 pshp = pshp->fNextPhysical;
265 Bool_t TGLLogicalShape::SetDLCache(Bool_t cache)
267 if (cache == fDLCache)
289 Bool_t TGLLogicalShape::ShouldDLCache(
const TGLRnrCtx& rnrCtx)
const
291 if (!fDLCache || !fScene ||
292 (rnrCtx.SecSelection() && SupportsSecondarySelect()))
303 void TGLLogicalShape::DLCacheClear()
315 void TGLLogicalShape::DLCacheDrop()
329 void TGLLogicalShape::DLCachePurge()
333 PurgeDLRange(fDLBase, fDLSize);
343 void TGLLogicalShape::PurgeDLRange(UInt_t base, Int_t size)
const
347 fScene->GetGLCtxIdentity()->RegisterDLNameRangeToWipe(base, size);
351 Warning(
"TGLLogicalShape::PurgeDLRange",
"Scene unknown, attempting direct deletion.");
352 glDeleteLists(base, size);
362 Short_t TGLLogicalShape::QuantizeShapeLOD(Short_t shapeLOD,
374 void TGLLogicalShape::Draw(TGLRnrCtx& rnrCtx)
const
378 Info(
"TGLLogicalShape::Draw",
"this %ld (class %s) LOD %d", (Long_t)
this, IsA()->GetName(), rnrCtx.ShapeLOD());
389 if (!fgUseDLs || !ShouldDLCache(rnrCtx) || rnrCtx.IsDLCaptureOpen())
397 fDLBase = glGenLists(fDLSize);
400 Warning(
"TGLLogicalShape::Draw",
"display-list registration failed.");
406 Short_t lod = rnrCtx.ShapeLOD();
407 UInt_t off = DLOffset(lod);
408 if ((1<<off) & fDLValid)
410 glCallList(fDLBase + off);
414 rnrCtx.OpenDLCapture();
415 glNewList(fDLBase + off, GL_COMPILE_AND_EXECUTE);
418 rnrCtx.CloseDLCapture();
419 fDLValid |= (1<<off);
428 void TGLLogicalShape::DrawHighlight(TGLRnrCtx& rnrCtx,
const TGLPhysicalShape* pshp, Int_t lvl)
const
430 if (lvl < 0) lvl = pshp->GetSelected();
432 glColor4ubv(rnrCtx.ColorSet().Selection(lvl).CArr());
433 TGLUtil::LockColor();
435 TGLUtil::UnlockColor();
445 void TGLLogicalShape::ProcessSelection(TGLRnrCtx& , TGLSelectRecord& rec)
447 printf(
"TGLLogicalShape::ProcessSelection %d names on the stack (z1=%g, z2=%g).\n",
448 rec.GetN(), rec.GetMinZ(), rec.GetMaxZ());
450 for (Int_t j=0; j<rec.GetN(); ++j) printf (
"%u ", rec.GetItem(j));
458 void TGLLogicalShape::InvokeContextMenu(TContextMenu& menu, UInt_t x, UInt_t y)
const
461 menu.Popup(x, y, fExternalObj);
472 Bool_t TGLLogicalShape::IgnoreSizeForOfInterest()
const
474 return fgIgnoreSizeForCameraInterest;
481 Bool_t TGLLogicalShape::GetIgnoreSizeForCameraInterest()
483 return fgIgnoreSizeForCameraInterest;
489 void TGLLogicalShape::SetIgnoreSizeForCameraInterest(Bool_t isfci)
491 fgIgnoreSizeForCameraInterest = isfci;
497 void TGLLogicalShape::SetEnvDefaults()
499 fgUseDLs = gEnv->GetValue(
"OpenGL.UseDisplayLists", 1);
500 fgUseDLsForVertArrs = gEnv->GetValue(
"OpenGL.UseDisplayListsForVertexArrays", 1);
502 if (!fgUseDLs || !fgUseDLsForVertArrs)
504 printf(
"TGLLogicalShape::SetEnvDefaults() fgUseDLs=%d, fgUseDLsForVertArrs=%d\n",
505 fgUseDLs, fgUseDLsForVertArrs);