41 TEveScene::TEveScene(
const char* n,
const char* t) :
42 TEveElementList(n, t),
46 fSmartRefresh (kTRUE),
47 fHierarchical (kFALSE)
50 fPad->GetListOfPrimitives()->Add(
this);
51 fGLScene =
new TGLScenePad(fPad);
53 fGLScene->SetAutoDestruct(kFALSE);
54 fGLScene->SetSmartRefresh(kTRUE);
60 TEveScene::TEveScene(TGLScenePad* gl_scene,
const char* n,
const char* t) :
61 TEveElementList(n, t),
65 fSmartRefresh (kTRUE),
66 fHierarchical (kFALSE)
69 fPad->GetListOfPrimitives()->Add(
this);
70 fGLScene->SetPad(fPad);
72 fGLScene->SetAutoDestruct(kFALSE);
73 fGLScene->SetSmartRefresh(kTRUE);
79 TEveScene::~TEveScene()
81 fDestructing = kStandard;
83 gEve->GetViewers()->SceneDestructing(
this);
84 gEve->GetScenes()->RemoveElement(
this);
93 void TEveScene::CollectSceneParents(List_t& scenes)
95 scenes.push_back(
this);
101 void TEveScene::Repaint(Bool_t dropLogicals)
103 if (dropLogicals) fGLScene->SetSmartRefresh(kFALSE);
104 fGLScene->PadPaint(fPad);
105 if (dropLogicals) fGLScene->SetSmartRefresh(kTRUE);
115 TGLScene::LogicalShapeMap_t& logs = fGLScene->RefLogicalShapes();
117 for (TGLScene::LogicalShapeMapIt_t li = logs.begin(); li != logs.end(); ++li)
119 elm =
dynamic_cast<TEveElement*
>(li->first);
120 if (elm && li->second->Ref() == 1)
122 TGLPhysicalShape* pshp =
const_cast<TGLPhysicalShape*
>(li->second->GetFirstPhysical());
123 pshp->Select(elm->GetSelectedLevel());
130 RetransHierarchically();
138 void TEveScene::RetransHierarchically()
140 fGLScene->BeginUpdate();
142 RetransHierarchicallyRecurse(
this, RefMainTrans());
144 fGLScene->EndUpdate();
151 void TEveScene::RetransHierarchicallyRecurse(TEveElement* el,
const TEveTrans& tp)
153 static const TEveException eh(
"TEveScene::RetransHierarchicallyRecurse ");
156 if (el->HasMainTrans())
157 t *= el->RefMainTrans();
159 if (el->GetRnrSelf() && el !=
this)
161 fGLScene->UpdatePhysioLogical(el->GetRenderObject(eh), t.Array(), 0);
164 if (el->GetRnrChildren())
166 for (List_i i = el->BeginChildren(); i != el->EndChildren(); ++i)
168 if ((*i)->GetRnrAnything())
169 RetransHierarchicallyRecurse(*i, t);
177 void TEveScene::SetName(
const char* n)
179 TEveElementList::SetName(n);
180 fGLScene->SetName(n);
186 void TEveScene::Paint(Option_t* option)
190 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
191 (*i)->PadPaint(option);
199 void TEveScene::DestroyElementRenderers(TEveElement* element)
201 static const TEveException eh(
"TEveScene::DestroyElementRenderers ");
203 fGLScene->BeginUpdate();
204 Bool_t changed = fGLScene->DestroyLogical(element->GetRenderObject(eh), kFALSE);
205 fGLScene->EndUpdate(changed, changed);
212 void TEveScene::DestroyElementRenderers(TObject* rnrObj)
214 fGLScene->BeginUpdate();
215 Bool_t changed = fGLScene->DestroyLogical(rnrObj, kFALSE);
216 fGLScene->EndUpdate(changed, changed);
222 const TGPicture* TEveScene::GetListTreeIcon(Bool_t)
224 return TEveElement::fgListTreeIcons[2];
232 ClassImp(TEveSceneList);
237 TEveSceneList::TEveSceneList(
const char* n,
const char* t) :
238 TEveElementList(n, t)
240 SetChildClass(TEveScene::Class());
247 void TEveSceneList::DestroyScenes()
249 List_i i = fChildren.begin();
250 while (i != fChildren.end())
252 TEveScene* s = (TEveScene*) *(i++);
253 s->DestroyElements();
261 void TEveSceneList::RepaintChangedScenes(Bool_t dropLogicals)
263 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
265 TEveScene* s = (TEveScene*) *i;
268 s->Repaint(dropLogicals);
276 void TEveSceneList::RepaintAllScenes(Bool_t dropLogicals)
278 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
280 ((TEveScene*) *i)->Repaint(dropLogicals);
287 void TEveSceneList::DestroyElementRenderers(TEveElement* element)
289 static const TEveException eh(
"TEveSceneList::DestroyElementRenderers ");
291 TObject* obj = element->GetRenderObject(eh);
292 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
294 ((TEveScene*)*i)->DestroyElementRenderers(obj);
307 void TEveSceneList::ProcessSceneChanges(Bool_t dropLogicals, TExMap* stampMap)
313 static const TEveException eh(
"TEveSceneList::ProcessSceneChanges ");
315 typedef std::map<TObject*, TEveElement*> mObjectElement_t;
316 typedef mObjectElement_t::iterator mObjectElement_i;
318 mObjectElement_t changed_objects;
321 TExMapIter stamped_elements(stampMap);
322 while (stamped_elements.Next(key, value))
324 TEveElement *el =
reinterpret_cast<TEveElement*
>(key);
325 changed_objects.insert(std::make_pair(el->GetRenderObject(eh), el));
329 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
331 TEveScene* s = (TEveScene*) *i;
335 s->Repaint(dropLogicals);
339 Bool_t updateViewers = kFALSE;
340 Bool_t incTimeStamp = kFALSE;
341 Bool_t transbboxChg = kFALSE;
343 s->GetGLScene()->BeginUpdate();
346 TGLScene::LogicalShapeMap_t &logs = s->GetGLScene()->RefLogicalShapes();
347 TGLScene::LogicalShapeMapIt_t li = logs.begin();
349 mObjectElement_i ei = changed_objects.begin();
351 while (li != logs.end() && ei != changed_objects.end())
353 if (li->first == ei->first)
355 if (li->second->Ref() != 1)
356 Warning(
"TEveSceneList::ProcessSceneChanges",
357 "Expect one physical, cnt=%u.", li->second->Ref());
359 TGLLogicalShape *lshp = li->second;
360 TGLPhysicalShape *pshp =
const_cast<TGLPhysicalShape*
>(lshp->GetFirstPhysical());
361 TEveElement *el = ei->second;
362 UChar_t bits = el->GetChangeBits();
364 if (bits & kCBColorSelection)
366 pshp->Select(el->GetSelectedLevel());
367 pshp->SetDiffuseColor(el->GetMainColor(),
368 el->GetMainTransparency());
371 if (bits & kCBTransBBox)
373 if (el->HasMainTrans())
374 pshp->SetTransform(el->PtrMainTrans()->Array());
375 lshp->UpdateBoundingBox();
376 incTimeStamp = kTRUE;
377 transbboxChg = kTRUE;
380 if (bits & kCBObjProps)
382 lshp->DLCacheClear();
386 updateViewers = kTRUE;
388 else if (li->first < ei->first)
398 s->GetGLScene()->EndUpdate(updateViewers, incTimeStamp, updateViewers);
401 if (s->GetHierarchical() && transbboxChg)
403 s->RetransHierarchically();