#include "TEveProjectionManager.h"
#include "TEveManager.h"
#include "TEveProjectionBases.h"
#include "TEveCompound.h"
#include "TAttBBox.h"
#include "TBuffer3D.h"
#include "TBuffer3DTypes.h"
#include "TVirtualPad.h"
#include "TVirtualViewer3D.h"
#include "TClass.h"
#include <list>
ClassImp(TEveProjectionManager);
TEveProjectionManager::TEveProjectionManager():
TEveElementList("TEveProjectionManager",""),
TAttBBox(),
fProjection (0),
fCurrentDepth(0),
fImportEmpty (kFALSE)
{
for (Int_t i = 0; i < TEveProjection::kPT_End; ++i)
fProjections[i] = 0;
SetProjection(TEveProjection::kPT_RPhi);
}
TEveProjectionManager::~TEveProjectionManager()
{
for (Int_t i = 0; i < TEveProjection::kPT_End; ++i)
{
delete fProjections[i];
}
while ( ! fDependentEls.empty())
{
fDependentEls.front()->Destroy();
}
}
void TEveProjectionManager::AddDependent(TEveElement* el)
{
fDependentEls.push_back(el);
}
void TEveProjectionManager::RemoveDependent(TEveElement* el)
{
fDependentEls.remove(el);
}
void TEveProjectionManager::UpdateName()
{
SetName(Form ("%s (%3.1f)", fProjection->GetName(), fProjection->GetDistortion()*1000));
}
void TEveProjectionManager::SetProjection(TEveProjection::EPType_e type)
{
static const TEveException eH("TEveProjectionManager::SetProjection ");
if (fProjections[type] == 0)
{
switch (type)
{
case TEveProjection::kPT_RPhi:
{
fProjections[type] = new TEveRPhiProjection();
break;
}
case TEveProjection::kPT_RhoZ:
{
fProjections[type] = new TEveRhoZProjection();
break;
}
default:
throw(eH + "projection type not valid.");
break;
}
}
fProjection = fProjections[type];
fProjection->SetCenter(fCenter);
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* el)
{
if (fImportEmpty)
return kTRUE;
if (el->IsA()->InheritsFrom(TEveProjectable::Class()))
return kTRUE;
for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i)
if (ShouldImport(*i))
return kTRUE;
return kFALSE;
}
void TEveProjectionManager::UpdateDependentElsAndScenes(TEveElement* root)
{
for (List_i i=fDependentEls.begin(); i!=fDependentEls.end(); ++i)
{
TAttBBox* bbox = dynamic_cast<TAttBBox*>(*i);
if (bbox)
bbox->ComputeBBox();
}
List_t scenes;
root->CollectSceneParentsFromChildren(scenes, 0);
gEve->ScenesChanged(scenes);
}
TEveElement* TEveProjectionManager::ImportElementsRecurse(TEveElement* el,
TEveElement* parent)
{
static const TEveException eh("TEveProjectionManager::ImportElementsRecurse ");
TEveElement *new_el = 0;
if (ShouldImport(el))
{
TEveProjected *new_pr = 0;
TEveProjectable *pble = dynamic_cast<TEveProjectable*>(el);
if (pble)
{
new_el = (TEveElement*) pble->ProjectedClass()->New();
new_pr = dynamic_cast<TEveProjected*>(new_el);
new_pr->SetProjection(this, pble);
new_pr->SetDepth(fCurrentDepth);
}
else
{
new_el = new TEveElementList;
}
new_el->SetElementName (Form("%s [P]", el->GetElementName()));
new_el->SetElementTitle(Form("Projected replica.\n%s", el->GetElementTitle()));
new_el->SetRnrSelf (el->GetRnrSelf());
new_el->SetRnrChildren (el->GetRnrChildren());
new_el->SetPickable (el->IsPickable());
parent->AddElement(new_el);
TEveCompound *cmpnd = dynamic_cast<TEveCompound*>(el);
TEveCompound *cmpnd_pr = dynamic_cast<TEveCompound*>(new_el);
for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i)
{
TEveElement* child_pr = ImportElementsRecurse(*i, new_el);
if (cmpnd && (*i)->GetCompound() == cmpnd)
child_pr->SetCompound(cmpnd_pr);
}
}
return new_el;
}
TEveElement* TEveProjectionManager::ImportElements(TEveElement* el,
TEveElement* ext_list)
{
TEveElement* new_el = ImportElementsRecurse(el, this);
if (new_el)
{
AssertBBox();
ProjectChildrenRecurse(new_el);
AssertBBoxExtents(0.1);
UpdateDependentElsAndScenes(new_el);
if (ext_list)
ext_list->AddElement(new_el);
}
return new_el;
}
void TEveProjectionManager::ProjectChildrenRecurse(TEveElement* el)
{
TEveProjected* pted = dynamic_cast<TEveProjected*>(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]);
}
el->ElementChanged(kFALSE);
}
for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i)
ProjectChildrenRecurse(*i);
}
void TEveProjectionManager::ProjectChildren()
{
BBoxInit();
ProjectChildrenRecurse(this);
AssertBBoxExtents(0.1);
UpdateDependentElsAndScenes(this);
}
void TEveProjectionManager::ComputeBBox()
{
static const TEveException eH("TEveProjectionManager::ComputeBBox ");
if (HasChildren() == kFALSE) {
BBoxZero();
return;
}
BBoxInit();
}
TEveProjectionManager.cxx:1 TEveProjectionManager.cxx:2 TEveProjectionManager.cxx:3 TEveProjectionManager.cxx:4 TEveProjectionManager.cxx:5 TEveProjectionManager.cxx:6 TEveProjectionManager.cxx:7 TEveProjectionManager.cxx:8 TEveProjectionManager.cxx:9 TEveProjectionManager.cxx:10 TEveProjectionManager.cxx:11 TEveProjectionManager.cxx:12 TEveProjectionManager.cxx:13 TEveProjectionManager.cxx:14 TEveProjectionManager.cxx:15 TEveProjectionManager.cxx:16 TEveProjectionManager.cxx:17 TEveProjectionManager.cxx:18 TEveProjectionManager.cxx:19 TEveProjectionManager.cxx:20 TEveProjectionManager.cxx:21 TEveProjectionManager.cxx:22 TEveProjectionManager.cxx:23 TEveProjectionManager.cxx:24 TEveProjectionManager.cxx:25 TEveProjectionManager.cxx:26 TEveProjectionManager.cxx:27 TEveProjectionManager.cxx:28 TEveProjectionManager.cxx:29 TEveProjectionManager.cxx:30 TEveProjectionManager.cxx:31 TEveProjectionManager.cxx:32 TEveProjectionManager.cxx:33 TEveProjectionManager.cxx:34 TEveProjectionManager.cxx:35 TEveProjectionManager.cxx:36 TEveProjectionManager.cxx:37 TEveProjectionManager.cxx:38 TEveProjectionManager.cxx:39 TEveProjectionManager.cxx:40 TEveProjectionManager.cxx:41 TEveProjectionManager.cxx:42 TEveProjectionManager.cxx:43 TEveProjectionManager.cxx:44 TEveProjectionManager.cxx:45 TEveProjectionManager.cxx:46 TEveProjectionManager.cxx:47 TEveProjectionManager.cxx:48 TEveProjectionManager.cxx:49 TEveProjectionManager.cxx:50 TEveProjectionManager.cxx:51 TEveProjectionManager.cxx:52 TEveProjectionManager.cxx:53 TEveProjectionManager.cxx:54 TEveProjectionManager.cxx:55 TEveProjectionManager.cxx:56 TEveProjectionManager.cxx:57 TEveProjectionManager.cxx:58 TEveProjectionManager.cxx:59 TEveProjectionManager.cxx:60 TEveProjectionManager.cxx:61 TEveProjectionManager.cxx:62 TEveProjectionManager.cxx:63 TEveProjectionManager.cxx:64 TEveProjectionManager.cxx:65 TEveProjectionManager.cxx:66 TEveProjectionManager.cxx:67 TEveProjectionManager.cxx:68 TEveProjectionManager.cxx:69 TEveProjectionManager.cxx:70 TEveProjectionManager.cxx:71 TEveProjectionManager.cxx:72 TEveProjectionManager.cxx:73 TEveProjectionManager.cxx:74 TEveProjectionManager.cxx:75 TEveProjectionManager.cxx:76 TEveProjectionManager.cxx:77 TEveProjectionManager.cxx:78 TEveProjectionManager.cxx:79 TEveProjectionManager.cxx:80 TEveProjectionManager.cxx:81 TEveProjectionManager.cxx:82 TEveProjectionManager.cxx:83 TEveProjectionManager.cxx:84 TEveProjectionManager.cxx:85 TEveProjectionManager.cxx:86 TEveProjectionManager.cxx:87 TEveProjectionManager.cxx:88 TEveProjectionManager.cxx:89 TEveProjectionManager.cxx:90 TEveProjectionManager.cxx:91 TEveProjectionManager.cxx:92 TEveProjectionManager.cxx:93 TEveProjectionManager.cxx:94 TEveProjectionManager.cxx:95 TEveProjectionManager.cxx:96 TEveProjectionManager.cxx:97 TEveProjectionManager.cxx:98 TEveProjectionManager.cxx:99 TEveProjectionManager.cxx:100 TEveProjectionManager.cxx:101 TEveProjectionManager.cxx:102 TEveProjectionManager.cxx:103 TEveProjectionManager.cxx:104 TEveProjectionManager.cxx:105 TEveProjectionManager.cxx:106 TEveProjectionManager.cxx:107 TEveProjectionManager.cxx:108 TEveProjectionManager.cxx:109 TEveProjectionManager.cxx:110 TEveProjectionManager.cxx:111 TEveProjectionManager.cxx:112 TEveProjectionManager.cxx:113 TEveProjectionManager.cxx:114 TEveProjectionManager.cxx:115 TEveProjectionManager.cxx:116 TEveProjectionManager.cxx:117 TEveProjectionManager.cxx:118 TEveProjectionManager.cxx:119 TEveProjectionManager.cxx:120 TEveProjectionManager.cxx:121 TEveProjectionManager.cxx:122 TEveProjectionManager.cxx:123 TEveProjectionManager.cxx:124 TEveProjectionManager.cxx:125 TEveProjectionManager.cxx:126 TEveProjectionManager.cxx:127 TEveProjectionManager.cxx:128 TEveProjectionManager.cxx:129 TEveProjectionManager.cxx:130 TEveProjectionManager.cxx:131 TEveProjectionManager.cxx:132 TEveProjectionManager.cxx:133 TEveProjectionManager.cxx:134 TEveProjectionManager.cxx:135 TEveProjectionManager.cxx:136 TEveProjectionManager.cxx:137 TEveProjectionManager.cxx:138 TEveProjectionManager.cxx:139 TEveProjectionManager.cxx:140 TEveProjectionManager.cxx:141 TEveProjectionManager.cxx:142 TEveProjectionManager.cxx:143 TEveProjectionManager.cxx:144 TEveProjectionManager.cxx:145 TEveProjectionManager.cxx:146 TEveProjectionManager.cxx:147 TEveProjectionManager.cxx:148 TEveProjectionManager.cxx:149 TEveProjectionManager.cxx:150 TEveProjectionManager.cxx:151 TEveProjectionManager.cxx:152 TEveProjectionManager.cxx:153 TEveProjectionManager.cxx:154 TEveProjectionManager.cxx:155 TEveProjectionManager.cxx:156 TEveProjectionManager.cxx:157 TEveProjectionManager.cxx:158 TEveProjectionManager.cxx:159 TEveProjectionManager.cxx:160 TEveProjectionManager.cxx:161 TEveProjectionManager.cxx:162 TEveProjectionManager.cxx:163 TEveProjectionManager.cxx:164 TEveProjectionManager.cxx:165 TEveProjectionManager.cxx:166 TEveProjectionManager.cxx:167 TEveProjectionManager.cxx:168 TEveProjectionManager.cxx:169 TEveProjectionManager.cxx:170 TEveProjectionManager.cxx:171 TEveProjectionManager.cxx:172 TEveProjectionManager.cxx:173 TEveProjectionManager.cxx:174 TEveProjectionManager.cxx:175 TEveProjectionManager.cxx:176 TEveProjectionManager.cxx:177 TEveProjectionManager.cxx:178 TEveProjectionManager.cxx:179 TEveProjectionManager.cxx:180 TEveProjectionManager.cxx:181 TEveProjectionManager.cxx:182 TEveProjectionManager.cxx:183 TEveProjectionManager.cxx:184 TEveProjectionManager.cxx:185 TEveProjectionManager.cxx:186 TEveProjectionManager.cxx:187 TEveProjectionManager.cxx:188 TEveProjectionManager.cxx:189 TEveProjectionManager.cxx:190 TEveProjectionManager.cxx:191 TEveProjectionManager.cxx:192 TEveProjectionManager.cxx:193 TEveProjectionManager.cxx:194 TEveProjectionManager.cxx:195 TEveProjectionManager.cxx:196 TEveProjectionManager.cxx:197 TEveProjectionManager.cxx:198 TEveProjectionManager.cxx:199 TEveProjectionManager.cxx:200 TEveProjectionManager.cxx:201 TEveProjectionManager.cxx:202 TEveProjectionManager.cxx:203 TEveProjectionManager.cxx:204 TEveProjectionManager.cxx:205 TEveProjectionManager.cxx:206 TEveProjectionManager.cxx:207 TEveProjectionManager.cxx:208 TEveProjectionManager.cxx:209 TEveProjectionManager.cxx:210 TEveProjectionManager.cxx:211 TEveProjectionManager.cxx:212 TEveProjectionManager.cxx:213 TEveProjectionManager.cxx:214 TEveProjectionManager.cxx:215 TEveProjectionManager.cxx:216 TEveProjectionManager.cxx:217 TEveProjectionManager.cxx:218 TEveProjectionManager.cxx:219 TEveProjectionManager.cxx:220 TEveProjectionManager.cxx:221 TEveProjectionManager.cxx:222 TEveProjectionManager.cxx:223 TEveProjectionManager.cxx:224 TEveProjectionManager.cxx:225 TEveProjectionManager.cxx:226 TEveProjectionManager.cxx:227 TEveProjectionManager.cxx:228 TEveProjectionManager.cxx:229 TEveProjectionManager.cxx:230 TEveProjectionManager.cxx:231 TEveProjectionManager.cxx:232 TEveProjectionManager.cxx:233 TEveProjectionManager.cxx:234 TEveProjectionManager.cxx:235 TEveProjectionManager.cxx:236 TEveProjectionManager.cxx:237 TEveProjectionManager.cxx:238 TEveProjectionManager.cxx:239 TEveProjectionManager.cxx:240 TEveProjectionManager.cxx:241 TEveProjectionManager.cxx:242 TEveProjectionManager.cxx:243 TEveProjectionManager.cxx:244 TEveProjectionManager.cxx:245 TEveProjectionManager.cxx:246 TEveProjectionManager.cxx:247 TEveProjectionManager.cxx:248 TEveProjectionManager.cxx:249 TEveProjectionManager.cxx:250 TEveProjectionManager.cxx:251 TEveProjectionManager.cxx:252 TEveProjectionManager.cxx:253 TEveProjectionManager.cxx:254 TEveProjectionManager.cxx:255 TEveProjectionManager.cxx:256 TEveProjectionManager.cxx:257 TEveProjectionManager.cxx:258 TEveProjectionManager.cxx:259 TEveProjectionManager.cxx:260 TEveProjectionManager.cxx:261 TEveProjectionManager.cxx:262 TEveProjectionManager.cxx:263 TEveProjectionManager.cxx:264 TEveProjectionManager.cxx:265 TEveProjectionManager.cxx:266 TEveProjectionManager.cxx:267 TEveProjectionManager.cxx:268 TEveProjectionManager.cxx:269 TEveProjectionManager.cxx:270 TEveProjectionManager.cxx:271 TEveProjectionManager.cxx:272 TEveProjectionManager.cxx:273 TEveProjectionManager.cxx:274 TEveProjectionManager.cxx:275 TEveProjectionManager.cxx:276 TEveProjectionManager.cxx:277 TEveProjectionManager.cxx:278 TEveProjectionManager.cxx:279 TEveProjectionManager.cxx:280 TEveProjectionManager.cxx:281 TEveProjectionManager.cxx:282 TEveProjectionManager.cxx:283 TEveProjectionManager.cxx:284 TEveProjectionManager.cxx:285 TEveProjectionManager.cxx:286 TEveProjectionManager.cxx:287 TEveProjectionManager.cxx:288 TEveProjectionManager.cxx:289 TEveProjectionManager.cxx:290 TEveProjectionManager.cxx:291 TEveProjectionManager.cxx:292 TEveProjectionManager.cxx:293 TEveProjectionManager.cxx:294 TEveProjectionManager.cxx:295 TEveProjectionManager.cxx:296 TEveProjectionManager.cxx:297 TEveProjectionManager.cxx:298 TEveProjectionManager.cxx:299 TEveProjectionManager.cxx:300 TEveProjectionManager.cxx:301 TEveProjectionManager.cxx:302 TEveProjectionManager.cxx:303 TEveProjectionManager.cxx:304 TEveProjectionManager.cxx:305 TEveProjectionManager.cxx:306 TEveProjectionManager.cxx:307 TEveProjectionManager.cxx:308 TEveProjectionManager.cxx:309 TEveProjectionManager.cxx:310 TEveProjectionManager.cxx:311 TEveProjectionManager.cxx:312 TEveProjectionManager.cxx:313 TEveProjectionManager.cxx:314 TEveProjectionManager.cxx:315 TEveProjectionManager.cxx:316 TEveProjectionManager.cxx:317 TEveProjectionManager.cxx:318 TEveProjectionManager.cxx:319 TEveProjectionManager.cxx:320 TEveProjectionManager.cxx:321