#include "TEveProjectionManager.h"
#include "TEveManager.h"
#include "TEveProjectionBases.h"
#include "TBuffer3D.h"
#include "TBuffer3DTypes.h"
#include "TVirtualPad.h"
#include "TVirtualViewer3D.h"
#include "TClass.h"
#include <list>
ClassImp(TEveProjectionManager)
TEveProjectionManager::TEveProjectionManager():
TEveElementList("TEveProjectionManager",""),
fProjection (0),
fDrawCenter(kFALSE),
fDrawOrigin(kFALSE),
fSplitInfoMode(0),
fSplitInfoLevel(1),
fAxisColor(0),
fCurrentDepth(0)
{
fProjection = new TEveCircularFishEyeProjection(fCenter);
UpdateName();
}
TEveProjectionManager::~TEveProjectionManager()
{
if(fProjection) delete fProjection;
}
void TEveProjectionManager::UpdateName()
{
SetName(Form ("%s (%3.1f)", fProjection->GetName(), fProjection->GetDistortion()*1000));
UpdateItems();
}
void TEveProjectionManager::SetProjection(TEveProjection::EPType_e type, Float_t distort)
{
static const TEveException eH("TEveProjectionManager::SetProjection ");
delete fProjection;
fProjection = 0;
switch (type)
{
case TEveProjection::kPT_CFishEye:
{
fProjection = new TEveCircularFishEyeProjection(fCenter);
break;
}
case TEveProjection::kPT_RhoZ:
{
fProjection = new TEveRhoZProjection(fCenter);
break;
}
default:
throw(eH + "projection type not valid.");
break;
}
fProjection->SetDistortion(distort);
UpdateName();
}
void TEveProjectionManager::SetCenter(Float_t x, Float_t y, Float_t z)
{
fCenter.Set(x, y, z);
fProjection->SetCenter(fCenter);
ProjectChildren();
}
Bool_t TEveProjectionManager::HandleElementPaste(TEveElement* el)
{
List_t::size_type n_children = fChildren.size();
ImportElements(el);
return n_children != fChildren.size();
}
Bool_t TEveProjectionManager::ShouldImport(TEveElement* rnr_el)
{
if (rnr_el->IsA()->InheritsFrom(TEveProjectable::Class()))
return kTRUE;
for (List_i i=rnr_el->BeginChildren(); i!=rnr_el->EndChildren(); ++i)
if (ShouldImport(*i))
return kTRUE;
return kFALSE;
}
void TEveProjectionManager::ImportElementsRecurse(TEveElement* rnr_el, TEveElement* parent)
{
static const TEveException eh("TEveProjectionManager::ImportElementsRecurse ");
if (ShouldImport(rnr_el))
{
TEveElement *new_re = 0;
TEveProjected *new_pr = 0;
TEveProjectable *pble = dynamic_cast<TEveProjectable*>(rnr_el);
if (pble)
{
new_re = (TEveElement*) pble->ProjectedClass()->New();
new_pr = dynamic_cast<TEveProjected*>(new_re);
new_pr->SetProjection(this, pble);
new_pr->SetDepth(fCurrentDepth);
}
else
{
new_re = new TEveElementList;
}
TObject *tobj = rnr_el->GetObject(eh);
new_re->SetRnrElNameTitle(Form("NLT %s", tobj->GetName()),
tobj->GetTitle());
new_re->SetRnrSelf (rnr_el->GetRnrSelf());
new_re->SetRnrChildren(rnr_el->GetRnrChildren());
gEve->AddElement(new_re, parent);
for (List_i i=rnr_el->BeginChildren(); i!=rnr_el->EndChildren(); ++i)
ImportElementsRecurse(*i, new_re);
}
}
void TEveProjectionManager::ImportElements(TEveElement* rnr_el)
{
ImportElementsRecurse(rnr_el, this);
ProjectChildren();
}
void TEveProjectionManager::ProjectChildrenRecurse(TEveElement* rnr_el)
{
TEveProjected* pted = dynamic_cast<TEveProjected*>(rnr_el);
if (pted)
{
pted->UpdateProjection();
TAttBBox* bb = dynamic_cast<TAttBBox*>(pted);
if(bb)
{
Float_t* b = bb->AssertBBox();
BBoxCheckPoint(b[0], b[2], b[4]);
BBoxCheckPoint(b[1], b[3], b[5]);
}
rnr_el->ElementChanged(kFALSE);
}
for (List_i i=rnr_el->BeginChildren(); i!=rnr_el->EndChildren(); ++i)
ProjectChildrenRecurse(*i);
}
void TEveProjectionManager::ProjectChildren()
{
BBoxZero();
ProjectChildrenRecurse(this);
AssertBBoxExtents(0.1);
{
using namespace TMath;
fBBox[0] = 10.0f * Floor(fBBox[0]/10.0f);
fBBox[1] = 10.0f * Ceil (fBBox[1]/10.0f);
fBBox[2] = 10.0f * Floor(fBBox[2]/10.0f);
fBBox[3] = 10.0f * Ceil (fBBox[3]/10.0f);
}
List_t scenes;
CollectSceneParentsFromChildren(scenes, 0);
gEve->ScenesChanged(scenes);
}
void TEveProjectionManager::Paint(Option_t* )
{
static const TEveException eH("TEveProjectionManager::Paint ");
TBuffer3D buff(TBuffer3DTypes::kGeneric);
buff.fID = this;
buff.fColor = fAxisColor;
buff.fTransparency = 0;
buff.SetSectionsValid(TBuffer3D::kCore);
Int_t reqSections = gPad->GetViewer3D()->AddObject(buff);
if (reqSections != TBuffer3D::kNone)
Error(eH, "only direct GL rendering supported.");
}
void TEveProjectionManager::ComputeBBox()
{
static const TEveException eH("TEveProjectionManager::ComputeBBox ");
if(GetNChildren() == 0) {
BBoxZero();
return;
}
BBoxInit();
}
Last update: Thu Jan 17 08:49:05 2008
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.