#include "TEveScene.h"
#include "TEveViewer.h"
#include "TEveManager.h"
#include "TEveTrans.h"
#include "TList.h"
#include "TGLScenePad.h"
#include "TGLLogicalShape.h"
#include "TGLPhysicalShape.h"
ClassImp(TEveScene);
TEveScene::TEveScene(const Text_t* n, const Text_t* t) :
   TEveElementList(n, t),
   fPad    (0),
   fGLScene(0),
   fChanged      (kFALSE),
   fSmartRefresh (kTRUE)
{
   
   fPad = new TEvePad;
   fPad->GetListOfPrimitives()->Add(this);
   fGLScene = new TGLScenePad(fPad);
   fGLScene->SetName(n);
   fGLScene->SetAutoDestruct(kFALSE);
   fGLScene->SetSmartRefresh(kTRUE);
}
TEveScene::~TEveScene()
{
   
   gEve->GetViewers()->SceneDestructing(this);
}
void TEveScene::CollectSceneParents(List_t& scenes)
{
   
   
   scenes.push_back(this);
}
void TEveScene::Repaint(Bool_t dropLogicals)
{
   
   if (dropLogicals) fGLScene->SetSmartRefresh(kFALSE);
   fGLScene->PadPaint(fPad);
   if (dropLogicals) fGLScene->SetSmartRefresh(kTRUE);
   fChanged = kFALSE;
   
   
   
   
   
   
   TGLScene::LogicalShapeMap_t& logs = fGLScene->RefLogicalShapes();
   TEveElement* elm;
   for (TGLScene::LogicalShapeMapIt_t li = logs.begin(); li != logs.end(); ++li)
   {
      elm = dynamic_cast<TEveElement*>(li->first);
      if (elm && li->second->Ref() == 1)
      {
         TGLPhysicalShape* pshp = const_cast<TGLPhysicalShape*>(li->second->GetFirstPhysical());
         pshp->Select(elm->GetSelectedLevel());
      }
   }
}
void TEveScene::SetName(const Text_t* n)
{
   
   TEveElementList::SetName(n);
   fGLScene->SetName(n);
}
void TEveScene::Paint(Option_t* option)
{
   
   if (fRnrChildren)
   {
      for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
         (*i)->PadPaint(option);
   }
}
void TEveScene::DestroyElementRenderers(TEveElement* element)
{
   
   
   fGLScene->BeginUpdate();
   Bool_t changed = fGLScene->DestroyLogical(element->GetRenderObject(), kFALSE);
   fGLScene->EndUpdate(changed, changed);
}
void TEveScene::DestroyElementRenderers(TObject* rnrObj)
{
   
   
   fGLScene->BeginUpdate();
   Bool_t changed = fGLScene->DestroyLogical(rnrObj, kFALSE);
   fGLScene->EndUpdate(changed, changed);
}
const TGPicture* TEveScene::GetListTreeIcon(Bool_t)
{
   
   return TEveElement::fgListTreeIcons[2];
}
ClassImp(TEveSceneList);
TEveSceneList::TEveSceneList(const Text_t* n, const Text_t* t) :
   TEveElementList(n, t)
{
   
   SetChildClass(TEveScene::Class());
}
void TEveSceneList::RepaintChangedScenes(Bool_t dropLogicals)
{
   
   for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
   {
      TEveScene* s = (TEveScene*) *i;
      if (s->IsChanged())
      {
         s->Repaint(dropLogicals);
      }
   }
}
void TEveSceneList::RepaintAllScenes(Bool_t dropLogicals)
{
   
   for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
   {
      ((TEveScene*) *i)->Repaint(dropLogicals);
   }
}
void TEveSceneList::DestroyElementRenderers(TEveElement* element)
{
   
   
   TObject* obj = element->GetRenderObject();
   for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
   {
      ((TEveScene*)*i)->DestroyElementRenderers(obj);
   }
}
void TEveSceneList::ProcessSceneChanges(Bool_t dropLogicals, Set_t& stampSet)
{
   
   
   
   
   
   
   
   for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
   {
      TEveScene* s = (TEveScene*) *i;
      if (s->IsChanged())
      {
         s->Repaint(dropLogicals);
      }
      else
      {
         Bool_t updateViewers = kFALSE;
         Bool_t incTimeStamp  = kFALSE;
         s->GetGLScene()->BeginUpdate();
         
         TGLScene::LogicalShapeMap_t& logs = s->GetGLScene()->RefLogicalShapes();
         TGLScene::LogicalShapeMapIt_t li = logs.begin();
         Set_i ei = stampSet.begin();
         TObject* eobj = 0;
         while (li != logs.end() && ei != stampSet.end())
         {
            if (!eobj) eobj = (*ei)->GetRenderObject();
            if (li->first == eobj)
            {
               if (li->second->Ref() != 1)
                  Warning("TEveSceneList::ProcessSceneChanges",
                          "Expect one physical, cnt=%u.", li->second->Ref());
               TGLLogicalShape  *lshp = li->second;
               TGLPhysicalShape *pshp = const_cast<TGLPhysicalShape*>(lshp->GetFirstPhysical());
               TEveElement      *el   = *ei;
               UChar_t           bits = el->GetChangeBits();
               if (bits & kCBColorSelection)
               {
                  pshp->Select(el->GetSelectedLevel());
                  pshp->SetDiffuseColor(el->GetMainColor(),
                                        el->GetMainTransparency());
               }
               if (bits & kCBTransBBox)
               {
                  if (el->HasMainTrans())
                     pshp->SetTransform(el->PtrMainTrans()->Array());
                  lshp->UpdateBoundingBox();
                  incTimeStamp = kTRUE;
               }
               if (bits & kCBObjProps)
               {
                  lshp->DLCacheClear();
               }
               ++li; ++ei; eobj = 0;
               updateViewers = kTRUE;
            }
            else if (li->first < eobj)
            {
               ++li;
            }
            else
            {
               ++ei; eobj = 0;
            }
         }
         s->GetGLScene()->EndUpdate(updateViewers, incTimeStamp, updateViewers);
      }
   }
}
Last change: Tue May 13 17:09:45 2008
Last generated: 2008-05-13 17:09
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.