00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TEveElement.h"
00013 #include "TEveCompound.h"
00014 #include "TEveTrans.h"
00015 #include "TEveManager.h"
00016 #include "TEveSelection.h"
00017 #include "TEveProjectionBases.h"
00018 #include "TEveProjectionManager.h"
00019
00020 #include "TBuffer3D.h"
00021 #include "TBuffer3DTypes.h"
00022 #include "TVirtualPad.h"
00023 #include "TVirtualViewer3D.h"
00024
00025 #include "TGeoMatrix.h"
00026
00027 #include "TClass.h"
00028 #include "TPRegexp.h"
00029 #include "TROOT.h"
00030 #include "TColor.h"
00031 #include "TEveBrowser.h"
00032 #include "TGListTree.h"
00033 #include "TGPicture.h"
00034
00035 #include <algorithm>
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 ClassImp(TEveElement::TEveListTreeInfo);
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 ClassImp(TEveElement);
00063
00064
00065 const TGPicture* TEveElement::fgRnrIcons[4] = { 0 };
00066 const TGPicture* TEveElement::fgListTreeIcons[9] = { 0 };
00067
00068
00069 TEveElement::TEveElement() :
00070 fParents (),
00071 fChildren (),
00072 fCompound (0),
00073 fVizModel (0),
00074 fVizTag (),
00075 fNumChildren (0),
00076 fParentIgnoreCnt (0),
00077 fTopItemCnt (0),
00078 fDenyDestroy (0),
00079 fDestroyOnZeroRefCnt (kTRUE),
00080 fRnrSelf (kTRUE),
00081 fRnrChildren (kTRUE),
00082 fCanEditMainColor (kFALSE),
00083 fCanEditMainTransparency(kFALSE),
00084 fCanEditMainTrans (kFALSE),
00085 fMainTransparency (0),
00086 fMainColorPtr (0),
00087 fMainTrans (0),
00088 fItems (),
00089 fSource (),
00090 fUserData (0),
00091 fPickable (kFALSE),
00092 fSelected (kFALSE),
00093 fHighlighted (kFALSE),
00094 fImpliedSelected (0),
00095 fImpliedHighlighted (0),
00096 fCSCBits (0),
00097 fChangeBits (0),
00098 fDestructing (kNone)
00099 {
00100
00101 }
00102
00103
00104 TEveElement::TEveElement(Color_t& main_color) :
00105 fParents (),
00106 fChildren (),
00107 fCompound (0),
00108 fVizModel (0),
00109 fVizTag (),
00110 fNumChildren (0),
00111 fParentIgnoreCnt (0),
00112 fTopItemCnt (0),
00113 fDenyDestroy (0),
00114 fDestroyOnZeroRefCnt (kTRUE),
00115 fRnrSelf (kTRUE),
00116 fRnrChildren (kTRUE),
00117 fCanEditMainColor (kFALSE),
00118 fCanEditMainTransparency(kFALSE),
00119 fCanEditMainTrans (kFALSE),
00120 fMainTransparency (0),
00121 fMainColorPtr (&main_color),
00122 fMainTrans (0),
00123 fItems (),
00124 fSource (),
00125 fUserData (0),
00126 fPickable (kFALSE),
00127 fSelected (kFALSE),
00128 fHighlighted (kFALSE),
00129 fImpliedSelected (0),
00130 fImpliedHighlighted (0),
00131 fCSCBits (0),
00132 fChangeBits (0),
00133 fDestructing (kNone)
00134 {
00135
00136 }
00137
00138
00139 TEveElement::TEveElement(const TEveElement& e) :
00140 fParents (),
00141 fChildren (),
00142 fCompound (0),
00143 fVizModel (0),
00144 fVizTag (e.fVizTag),
00145 fNumChildren (0),
00146 fParentIgnoreCnt (0),
00147 fTopItemCnt (0),
00148 fDenyDestroy (0),
00149 fDestroyOnZeroRefCnt (e.fDestroyOnZeroRefCnt),
00150 fRnrSelf (e.fRnrSelf),
00151 fRnrChildren (e.fRnrChildren),
00152 fCanEditMainColor (e.fCanEditMainColor),
00153 fCanEditMainTransparency(e.fCanEditMainTransparency),
00154 fCanEditMainTrans (e.fCanEditMainTrans),
00155 fMainTransparency (e.fMainTransparency),
00156 fMainColorPtr (0),
00157 fMainTrans (0),
00158 fItems (),
00159 fSource (e.fSource),
00160 fUserData (0),
00161 fPickable (e.fPickable),
00162 fSelected (kFALSE),
00163 fHighlighted (kFALSE),
00164 fImpliedSelected (0),
00165 fImpliedHighlighted (0),
00166 fCSCBits (e.fCSCBits),
00167 fChangeBits (0),
00168 fDestructing (kNone)
00169 {
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 SetVizModel(e.fVizModel);
00182 if (e.fMainColorPtr)
00183 fMainColorPtr = (Color_t*)((const char*) this + ((const char*) e.fMainColorPtr - (const char*) &e));
00184 if (e.fMainTrans)
00185 fMainTrans = new TEveTrans(*e.fMainTrans);
00186 }
00187
00188
00189 TEveElement::~TEveElement()
00190 {
00191
00192
00193 if (fDestructing != kAnnihilate)
00194 {
00195 fDestructing = kStandard;
00196 RemoveElementsInternal();
00197
00198 for (List_i p=fParents.begin(); p!=fParents.end(); ++p)
00199 {
00200 (*p)->RemoveElementLocal(this);
00201 (*p)->fChildren.remove(this);
00202 --((*p)->fNumChildren);
00203 }
00204 }
00205
00206 fParents.clear();
00207
00208 for (sLTI_i i=fItems.begin(); i!=fItems.end(); ++i)
00209 i->fTree->DeleteItem(i->fItem);
00210
00211 delete fMainTrans;
00212 }
00213
00214
00215 void TEveElement::PreDeleteElement()
00216 {
00217
00218
00219
00220
00221
00222 gEve->PreDeleteElement(this);
00223 }
00224
00225
00226 TEveElement* TEveElement::CloneElement() const
00227 {
00228
00229
00230
00231 return new TEveElement(*this);
00232 }
00233
00234
00235 TEveElement* TEveElement::CloneElementRecurse(Int_t level) const
00236 {
00237
00238
00239
00240
00241 TEveElement* el = CloneElement();
00242 if (level--)
00243 {
00244 CloneChildrenRecurse(el, level);
00245 }
00246 return el;
00247 }
00248
00249
00250 void TEveElement::CloneChildrenRecurse(TEveElement* dest, Int_t level) const
00251 {
00252
00253
00254
00255
00256 for (List_ci i=fChildren.begin(); i!=fChildren.end(); ++i)
00257 {
00258 dest->AddElement((*i)->CloneElementRecurse(level));
00259 }
00260 }
00261
00262
00263
00264
00265
00266 const char* TEveElement::GetElementName() const
00267 {
00268
00269
00270
00271
00272 static const TEveException eh("TEveElement::GetElementName ");
00273
00274 TNamed* named = dynamic_cast<TNamed*>(GetObject(eh));
00275 return named ? named->GetName() : "<no-name>";
00276 }
00277
00278
00279 const char* TEveElement::GetElementTitle() const
00280 {
00281
00282
00283
00284
00285 static const TEveException eh("TEveElement::GetElementTitle ");
00286
00287 TNamed* named = dynamic_cast<TNamed*>(GetObject(eh));
00288 return named ? named->GetTitle() : "<no-title>";
00289 }
00290
00291
00292 void TEveElement::SetElementName(const char* name)
00293 {
00294
00295
00296
00297
00298
00299 static const TEveException eh("TEveElement::SetElementName ");
00300
00301 TNamed* named = dynamic_cast<TNamed*>(GetObject(eh));
00302 if (named) {
00303 named->SetName(name);
00304 NameTitleChanged();
00305 }
00306 }
00307
00308
00309 void TEveElement::SetElementTitle(const char* title)
00310 {
00311
00312
00313
00314
00315
00316 static const TEveException eh("TEveElement::SetElementTitle ");
00317
00318 TNamed* named = dynamic_cast<TNamed*>(GetObject(eh));
00319 if (named) {
00320 named->SetTitle(title);
00321 NameTitleChanged();
00322 }
00323 }
00324
00325
00326 void TEveElement::SetElementNameTitle(const char* name, const char* title)
00327 {
00328
00329
00330
00331
00332
00333 static const TEveException eh("TEveElement::SetElementNameTitle ");
00334
00335 TNamed* named = dynamic_cast<TNamed*>(GetObject(eh));
00336 if (named) {
00337 named->SetNameTitle(name, title);
00338 NameTitleChanged();
00339 }
00340 }
00341
00342
00343 void TEveElement::NameTitleChanged()
00344 {
00345
00346
00347
00348
00349
00350 }
00351
00352
00353
00354
00355 void TEveElement::SetVizModel(TEveElement* model)
00356 {
00357
00358
00359
00360
00361
00362 if (fVizModel) {
00363 --fParentIgnoreCnt;
00364 fVizModel->RemoveElement(this);
00365 }
00366 fVizModel = model;
00367 if (fVizModel) {
00368 fVizModel->AddElement(this);
00369 ++fParentIgnoreCnt;
00370 }
00371 }
00372
00373
00374 Bool_t TEveElement::FindVizModel()
00375 {
00376
00377
00378
00379
00380
00381 TEveElement* model = gEve->FindVizDBEntry(fVizTag);
00382 if (model)
00383 {
00384 SetVizModel(model);
00385 return kTRUE;
00386 }
00387 else
00388 {
00389 return kFALSE;
00390 }
00391 }
00392
00393
00394 Bool_t TEveElement::ApplyVizTag(const TString& tag, const TString& fallback_tag)
00395 {
00396
00397
00398
00399
00400
00401
00402
00403
00404 SetVizTag(tag);
00405 if (FindVizModel())
00406 {
00407 CopyVizParamsFromDB();
00408 return kTRUE;
00409 }
00410 if ( ! fallback_tag.IsNull())
00411 {
00412 SetVizTag(fallback_tag);
00413 if (FindVizModel())
00414 {
00415 CopyVizParamsFromDB();
00416 return kTRUE;
00417 }
00418 }
00419 Warning("TEveElement::ApplyVizTag", "entry for tag '%s' not found in VizDB.", tag.Data());
00420 return kFALSE;
00421 }
00422
00423
00424 void TEveElement::PropagateVizParamsToProjecteds()
00425 {
00426
00427
00428
00429
00430
00431
00432
00433
00434 TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
00435 if (pable && pable->HasProjecteds())
00436 {
00437 pable->PropagateVizParams();
00438 }
00439 }
00440
00441
00442 void TEveElement::PropagateVizParamsToElements(TEveElement* el)
00443 {
00444
00445
00446
00447
00448
00449
00450 if (el == 0)
00451 el = this;
00452
00453 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
00454 {
00455 (*i)->CopyVizParams(el);
00456 }
00457 }
00458
00459
00460 void TEveElement::CopyVizParams(const TEveElement* el)
00461 {
00462
00463
00464
00465
00466
00467
00468
00469 fCanEditMainColor = el->fCanEditMainColor;
00470 fCanEditMainTransparency = el->fCanEditMainTransparency;
00471 fMainTransparency = el->fMainTransparency;
00472
00473 AddStamp(kCBColorSelection | kCBObjProps);
00474 }
00475
00476
00477 void TEveElement::CopyVizParamsFromDB()
00478 {
00479
00480
00481
00482 if (fVizModel)
00483 {
00484 CopyVizParams(fVizModel);
00485 }
00486 else
00487 {
00488 Warning("TEveElement::CopyVizParamsFromDB", "VizModel has not been set.");
00489 }
00490 }
00491
00492
00493 void TEveElement::SaveVizParams(ostream& out, const TString& tag, const TString& var)
00494 {
00495
00496
00497
00498
00499
00500
00501 static const TEveException eh("TEveElement::GetObject ");
00502
00503 TString t = " ";
00504 TString cls(GetObject(eh)->ClassName());
00505
00506 out << "\n";
00507
00508 TString intro = " TAG='" + tag + "', CLASS='" + cls + "'";
00509 out << " //" << intro << "\n";
00510 out << " //" << TString('-', intro.Length()) << "\n";
00511 out << t << cls << "* " << var <<" = new " << cls << ";\n";
00512
00513 WriteVizParams(out, var);
00514
00515 out << t << "gEve->InsertVizDBEntry(\"" << tag << "\", "<< var <<");\n";
00516 }
00517
00518
00519 void TEveElement::WriteVizParams(ostream& out, const TString& var)
00520 {
00521
00522
00523
00524
00525
00526
00527
00528 TString t = " " + var + "->";
00529
00530 out << t << "SetElementName(\"" << GetElementName() << "\");\n";
00531 out << t << "SetElementTitle(\"" << GetElementTitle() << "\");\n";
00532 out << t << "SetEditMainColor(" << fCanEditMainColor << ");\n";
00533 out << t << "SetEditMainTransparency(" << fCanEditMainTransparency << ");\n";
00534 out << t << "SetMainTransparency(" << fMainTransparency << ");\n";
00535 }
00536
00537
00538 void TEveElement::VizDB_Apply(const char* tag)
00539 {
00540
00541
00542 if (ApplyVizTag(tag))
00543 {
00544 PropagateVizParamsToProjecteds();
00545 gEve->Redraw3D();
00546 }
00547 }
00548
00549
00550 void TEveElement::VizDB_Reapply()
00551 {
00552
00553
00554
00555 if (fVizModel)
00556 {
00557 CopyVizParamsFromDB();
00558 PropagateVizParamsToProjecteds();
00559 gEve->Redraw3D();
00560 }
00561 }
00562
00563
00564 void TEveElement::VizDB_UpdateModel(Bool_t update)
00565 {
00566
00567
00568
00569
00570
00571 if (fVizModel)
00572 {
00573 fVizModel->CopyVizParams(this);
00574 if (update)
00575 {
00576 fVizModel->PropagateVizParamsToElements(fVizModel);
00577 gEve->Redraw3D();
00578 }
00579 }
00580 else
00581 {
00582 Warning("VizDB_UpdateModel", "VizModel has not been set.");
00583 }
00584 }
00585
00586
00587 void TEveElement::VizDB_Insert(const char* tag, Bool_t replace, Bool_t update)
00588 {
00589
00590
00591
00592
00593 static const TEveException eh("TEveElement::GetObject ");
00594
00595 TClass* cls = GetObject(eh)->IsA();
00596 TEveElement* el = reinterpret_cast<TEveElement*>(cls->New());
00597 if (el == 0) {
00598 Error("VizDB_Insert", "Creation of replica failed.");
00599 return;
00600 }
00601 el->CopyVizParams(this);
00602 Bool_t succ = gEve->InsertVizDBEntry(tag, el, replace, update);
00603 if (succ && update)
00604 gEve->Redraw3D();
00605 }
00606
00607
00608
00609
00610 TEveElement* TEveElement::GetMaster()
00611 {
00612
00613
00614
00615
00616
00617
00618 TEveProjected* proj = dynamic_cast<TEveProjected*>(this);
00619 if (proj)
00620 {
00621 return dynamic_cast<TEveElement*>(proj->GetProjectable())->GetMaster();
00622 }
00623 if (fCompound)
00624 {
00625 return fCompound->GetMaster();
00626 }
00627 if (TestCSCBits(kCSCBTakeAnyParentAsMaster))
00628 {
00629 for (List_i i = fParents.begin(); i != fParents.end(); ++i)
00630 if (dynamic_cast<TEveCompound*>(*i))
00631 return (*i)->GetMaster();
00632 }
00633 return this;
00634 }
00635
00636
00637
00638
00639 void TEveElement::AddParent(TEveElement* re)
00640 {
00641
00642
00643
00644
00645 fParents.push_back(re);
00646 }
00647
00648
00649 void TEveElement::RemoveParent(TEveElement* re)
00650 {
00651
00652
00653
00654
00655 static const TEveException eh("TEveElement::RemoveParent ");
00656
00657 fParents.remove(re);
00658 CheckReferenceCount(eh);
00659 }
00660
00661
00662
00663
00664 void TEveElement::CheckReferenceCount(const TEveException& eh)
00665 {
00666
00667
00668
00669 if (fDestructing != kNone)
00670 return;
00671
00672 if (NumParents() <= fParentIgnoreCnt && fTopItemCnt <= 0 &&
00673 fDestroyOnZeroRefCnt && fDenyDestroy <= 0)
00674 {
00675 if (gEve->GetUseOrphanage())
00676 {
00677 if (gDebug > 0)
00678 Info(eh, "moving to orphanage '%s' on zero reference count.", GetElementName());
00679
00680 PreDeleteElement();
00681 gEve->GetOrphanage()->AddElement(this);
00682 }
00683 else
00684 {
00685 if (gDebug > 0)
00686 Info(eh, "auto-destructing '%s' on zero reference count.", GetElementName());
00687
00688 PreDeleteElement();
00689 delete this;
00690 }
00691 }
00692 }
00693
00694
00695 void TEveElement::CollectSceneParents(List_t& scenes)
00696 {
00697
00698
00699
00700
00701
00702 for (List_i p=fParents.begin(); p!=fParents.end(); ++p)
00703 (*p)->CollectSceneParents(scenes);
00704 }
00705
00706
00707 void TEveElement::CollectSceneParentsFromChildren(List_t& scenes,
00708 TEveElement* parent)
00709 {
00710
00711
00712
00713
00714
00715
00716 for (List_i p=fParents.begin(); p!=fParents.end(); ++p)
00717 {
00718 if (*p != parent) (*p)->CollectSceneParents(scenes);
00719 }
00720
00721 for (List_i c=fChildren.begin(); c!=fChildren.end(); ++c)
00722 {
00723 (*c)->CollectSceneParentsFromChildren(scenes, this);
00724 }
00725 }
00726
00727
00728
00729
00730
00731
00732 void TEveElement::ExpandIntoListTree(TGListTree* ltree,
00733 TGListTreeItem* parent)
00734 {
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744 if (parent->GetFirstChild() != 0)
00745 return;
00746 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
00747 (*i)->AddIntoListTree(ltree, parent);
00748 }
00749 }
00750
00751
00752 void TEveElement::DestroyListSubTree(TGListTree* ltree,
00753 TGListTreeItem* parent)
00754 {
00755
00756
00757 TGListTreeItem* i = parent->GetFirstChild();
00758 while (i != 0)
00759 {
00760 TEveElement* re = (TEveElement*) i->GetUserData();
00761 i = i->GetNextSibling();
00762 re->RemoveFromListTree(ltree, parent);
00763 }
00764 }
00765
00766
00767 TGListTreeItem* TEveElement::AddIntoListTree(TGListTree* ltree,
00768 TGListTreeItem* parent_lti)
00769 {
00770
00771
00772
00773
00774 static const TEveException eh("TEveElement::AddIntoListTree ");
00775
00776 TGListTreeItem* item = new TEveListTreeItem(this);
00777 ltree->AddItem(parent_lti, item);
00778 fItems.insert(TEveListTreeInfo(ltree, item));
00779
00780 if (parent_lti == 0)
00781 ++fTopItemCnt;
00782
00783 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
00784 {
00785 (*i)->AddIntoListTree(ltree, item);
00786 }
00787
00788 ltree->ClearViewPort();
00789
00790 return item;
00791 }
00792
00793
00794 TGListTreeItem* TEveElement::AddIntoListTree(TGListTree* ltree,
00795 TEveElement* parent)
00796 {
00797
00798
00799
00800
00801 TGListTreeItem* lti = 0;
00802 if (parent == 0) {
00803 lti = AddIntoListTree(ltree, (TGListTreeItem*) 0);
00804 } else {
00805 for (sLTI_ri i = parent->fItems.rbegin(); i != parent->fItems.rend(); ++i)
00806 {
00807 if (i->fTree == ltree)
00808 lti = AddIntoListTree(ltree, i->fItem);
00809 }
00810 }
00811 return lti;
00812 }
00813
00814
00815 TGListTreeItem* TEveElement::AddIntoListTrees(TEveElement* parent)
00816 {
00817
00818
00819
00820
00821 TGListTreeItem* lti = 0;
00822 for (sLTI_ri i = parent->fItems.rbegin(); i != parent->fItems.rend(); ++i)
00823 {
00824 lti = AddIntoListTree(i->fTree, i->fItem);
00825 }
00826 return lti;
00827 }
00828
00829
00830 Bool_t TEveElement::RemoveFromListTree(TGListTree* ltree,
00831 TGListTreeItem* parent_lti)
00832 {
00833
00834
00835
00836
00837
00838 static const TEveException eh("TEveElement::RemoveFromListTree ");
00839
00840 sLTI_i i = FindItem(ltree, parent_lti);
00841 if (i != fItems.end()) {
00842 DestroyListSubTree(ltree, i->fItem);
00843 ltree->DeleteItem(i->fItem);
00844 ltree->ClearViewPort();
00845 fItems.erase(i);
00846 if (parent_lti == 0) {
00847 --fTopItemCnt;
00848 CheckReferenceCount(eh);
00849 }
00850 return kTRUE;
00851 } else {
00852 return kFALSE;
00853 }
00854 }
00855
00856
00857 Int_t TEveElement::RemoveFromListTrees(TEveElement* parent)
00858 {
00859
00860
00861
00862 static const TEveException eh("TEveElement::RemoveFromListTrees ");
00863
00864 Int_t count = 0;
00865
00866 sLTI_i i = fItems.begin();
00867 while (i != fItems.end())
00868 {
00869 sLTI_i j = i++;
00870 TGListTreeItem *plti = j->fItem->GetParent();
00871 if ((plti != 0 && (TEveElement*) plti->GetUserData() == parent) ||
00872 (plti == 0 && parent == 0))
00873 {
00874 DestroyListSubTree(j->fTree, j->fItem);
00875 j->fTree->DeleteItem(j->fItem);
00876 j->fTree->ClearViewPort();
00877 fItems.erase(j);
00878 if (parent == 0)
00879 --fTopItemCnt;
00880 ++count;
00881 }
00882 }
00883
00884 if (parent == 0 && count > 0)
00885 CheckReferenceCount(eh);
00886
00887 return count;
00888 }
00889
00890
00891 TEveElement::sLTI_i TEveElement::FindItem(TGListTree* ltree)
00892 {
00893
00894
00895
00896
00897 for (sLTI_i i = fItems.begin(); i != fItems.end(); ++i)
00898 if (i->fTree == ltree)
00899 return i;
00900 return fItems.end();
00901 }
00902
00903
00904 TEveElement::sLTI_i TEveElement::FindItem(TGListTree* ltree,
00905 TGListTreeItem* parent_lti)
00906 {
00907
00908
00909
00910 for (sLTI_i i = fItems.begin(); i != fItems.end(); ++i)
00911 if (i->fTree == ltree && i->fItem->GetParent() == parent_lti)
00912 return i;
00913 return fItems.end();
00914 }
00915
00916
00917 TGListTreeItem* TEveElement::FindListTreeItem(TGListTree* ltree)
00918 {
00919
00920
00921
00922
00923 for (sLTI_i i = fItems.begin(); i != fItems.end(); ++i)
00924 if (i->fTree == ltree)
00925 return i->fItem;
00926 return 0;
00927 }
00928
00929
00930 TGListTreeItem* TEveElement::FindListTreeItem(TGListTree* ltree,
00931 TGListTreeItem* parent_lti)
00932 {
00933
00934
00935
00936 for (sLTI_i i = fItems.begin(); i != fItems.end(); ++i)
00937 if (i->fTree == ltree && i->fItem->GetParent() == parent_lti)
00938 return i->fItem;
00939 return 0;
00940 }
00941
00942
00943
00944
00945 TObject* TEveElement::GetObject(const TEveException& eh) const
00946 {
00947
00948
00949
00950
00951
00952
00953 const TObject* obj = dynamic_cast<const TObject*>(this);
00954 if (obj == 0)
00955 throw(eh + "not a TObject.");
00956 return const_cast<TObject*>(obj);
00957 }
00958
00959
00960 void TEveElement::SpawnEditor()
00961 {
00962
00963
00964
00965 gEve->EditElement(this);
00966 }
00967
00968
00969 void TEveElement::ExportToCINT(char* var_name)
00970 {
00971
00972
00973 const char* cname = IsA()->GetName();
00974 gROOT->ProcessLine(TString::Format("%s* %s = (%s*)0x%lx;", cname, var_name, cname, (ULong_t)this));
00975 }
00976
00977
00978
00979
00980 void TEveElement::DumpSourceObject() const
00981 {
00982
00983
00984
00985 static const TEveException eh("TEveElement::DumpSourceObject ");
00986
00987 TObject *so = GetSourceObject();
00988 if (!so)
00989 throw eh + "source-object not set.";
00990
00991 so->Dump();
00992 }
00993
00994
00995 void TEveElement::PrintSourceObject() const
00996 {
00997
00998
00999
01000 static const TEveException eh("TEveElement::PrintSourceObject ");
01001
01002 TObject *so = GetSourceObject();
01003 if (!so)
01004 throw eh + "source-object not set.";
01005
01006 so->Print();
01007 }
01008
01009
01010 void TEveElement::ExportSourceObjectToCINT(char* var_name) const
01011 {
01012
01013
01014
01015 static const TEveException eh("TEveElement::ExportSourceObjectToCINT ");
01016
01017 TObject *so = GetSourceObject();
01018 if (!so)
01019 throw eh + "source-object not set.";
01020
01021 const char* cname = so->IsA()->GetName();
01022 gROOT->ProcessLine(TString::Format("%s* %s = (%s*)0x%lx;", cname, var_name, cname, (ULong_t)so));
01023 }
01024
01025
01026
01027
01028 void TEveElement::PadPaint(Option_t* option)
01029 {
01030
01031
01032 static const TEveException eh("TEveElement::PadPaint ");
01033
01034 TObject* obj = 0;
01035 if (GetRnrSelf() && (obj = GetRenderObject(eh)))
01036 obj->Paint(option);
01037
01038
01039 if (GetRnrChildren()) {
01040 for (List_i i=BeginChildren(); i!=EndChildren(); ++i) {
01041 (*i)->PadPaint(option);
01042 }
01043 }
01044 }
01045
01046
01047 void TEveElement::PaintStandard(TObject* id)
01048 {
01049
01050
01051
01052
01053
01054 static const TEveException eh("TEveElement::PaintStandard ");
01055
01056 TBuffer3D buff(TBuffer3DTypes::kGeneric);
01057
01058
01059 buff.fID = id;
01060 buff.fColor = GetMainColor();
01061 buff.fTransparency = GetMainTransparency();
01062 if (HasMainTrans()) RefMainTrans().SetBuffer3D(buff);
01063
01064 buff.SetSectionsValid(TBuffer3D::kCore);
01065
01066 Int_t reqSections = gPad->GetViewer3D()->AddObject(buff);
01067 if (reqSections != TBuffer3D::kNone)
01068 {
01069 Warning(eh, "IsA='%s'. Viewer3D requires more sections (%d). Only direct-rendering supported.",
01070 id->ClassName(), reqSections);
01071 }
01072 }
01073
01074
01075
01076
01077 Bool_t TEveElement::SetRnrSelf(Bool_t rnr)
01078 {
01079
01080
01081
01082
01083 if (SingleRnrState())
01084 {
01085 return SetRnrState(rnr);
01086 }
01087
01088 if (rnr != fRnrSelf)
01089 {
01090 fRnrSelf = rnr;
01091 StampVisibility();
01092 PropagateRnrStateToProjecteds();
01093 return kTRUE;
01094 }
01095 return kFALSE;
01096 }
01097
01098
01099 Bool_t TEveElement::SetRnrChildren(Bool_t rnr)
01100 {
01101
01102
01103
01104
01105 if (SingleRnrState())
01106 {
01107 return SetRnrState(rnr);
01108 }
01109
01110 if (rnr != fRnrChildren)
01111 {
01112 fRnrChildren = rnr;
01113 StampVisibility();
01114 PropagateRnrStateToProjecteds();
01115 return kTRUE;
01116 }
01117 return kFALSE;
01118 }
01119
01120
01121 Bool_t TEveElement::SetRnrSelfChildren(Bool_t rnr_self, Bool_t rnr_children)
01122 {
01123
01124
01125
01126 if (SingleRnrState())
01127 {
01128 return SetRnrState(rnr_self);
01129 }
01130
01131 if (fRnrSelf != rnr_self || fRnrChildren != rnr_children)
01132 {
01133 fRnrSelf = rnr_self;
01134 fRnrChildren = rnr_children;
01135 StampVisibility();
01136 PropagateRnrStateToProjecteds();
01137 return kTRUE;
01138 }
01139 return kFALSE;
01140 }
01141
01142
01143 Bool_t TEveElement::SetRnrState(Bool_t rnr)
01144 {
01145
01146
01147
01148
01149 if (fRnrSelf != rnr || fRnrChildren != rnr)
01150 {
01151 fRnrSelf = fRnrChildren = rnr;
01152 StampVisibility();
01153 PropagateRnrStateToProjecteds();
01154 return kTRUE;
01155 }
01156 return kFALSE;
01157 }
01158
01159
01160 void TEveElement::PropagateRnrStateToProjecteds()
01161 {
01162
01163
01164
01165 TEveProjectable *pable = dynamic_cast<TEveProjectable*>(this);
01166 if (pable && pable->HasProjecteds())
01167 {
01168 pable->PropagateRenderState(fRnrSelf, fRnrChildren);
01169 }
01170 }
01171
01172
01173
01174
01175 void TEveElement::SetMainColor(Color_t color)
01176 {
01177
01178
01179
01180
01181
01182 Color_t old_color = GetMainColor();
01183
01184 if (fMainColorPtr)
01185 {
01186 *fMainColorPtr = color;
01187 StampColorSelection();
01188 }
01189
01190 PropagateMainColorToProjecteds(color, old_color);
01191 }
01192
01193
01194 void TEveElement::SetMainColorPixel(Pixel_t pixel)
01195 {
01196
01197
01198 SetMainColor(TColor::GetColor(pixel));
01199 }
01200
01201
01202 void TEveElement::SetMainColorRGB(UChar_t r, UChar_t g, UChar_t b)
01203 {
01204
01205
01206 SetMainColor(TColor::GetColor(r, g, b));
01207 }
01208
01209
01210 void TEveElement::SetMainColorRGB(Float_t r, Float_t g, Float_t b)
01211 {
01212
01213
01214 SetMainColor(TColor::GetColor(r, g, b));
01215 }
01216
01217
01218 void TEveElement::PropagateMainColorToProjecteds(Color_t color, Color_t old_color)
01219 {
01220
01221
01222 TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
01223 if (pable && pable->HasProjecteds())
01224 {
01225 pable->PropagateMainColor(color, old_color);
01226 }
01227 }
01228
01229
01230 void TEveElement::SetMainTransparency(Char_t t)
01231 {
01232
01233
01234
01235 Char_t old_t = GetMainTransparency();
01236
01237 if (t > 100) t = 100;
01238 fMainTransparency = t;
01239 StampColorSelection();
01240
01241 PropagateMainTransparencyToProjecteds(t, old_t);
01242 }
01243
01244
01245 void TEveElement::SetMainAlpha(Float_t alpha)
01246 {
01247
01248
01249
01250 if (alpha < 0) alpha = 0;
01251 if (alpha > 1) alpha = 1;
01252 SetMainTransparency((Char_t) (100.0f*(1.0f - alpha)));
01253 }
01254
01255
01256 void TEveElement::PropagateMainTransparencyToProjecteds(Char_t t, Char_t old_t)
01257 {
01258
01259
01260 TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
01261 if (pable && pable->HasProjecteds())
01262 {
01263 pable->PropagateMainTransparency(t, old_t);
01264 }
01265 }
01266
01267
01268
01269
01270
01271 TEveTrans* TEveElement::PtrMainTrans(Bool_t create)
01272 {
01273
01274
01275
01276 if (!fMainTrans && create)
01277 InitMainTrans();
01278
01279 return fMainTrans;
01280 }
01281
01282
01283 TEveTrans& TEveElement::RefMainTrans()
01284 {
01285
01286
01287
01288 if (!fMainTrans)
01289 InitMainTrans();
01290
01291 return *fMainTrans;
01292 }
01293
01294
01295 void TEveElement::InitMainTrans(Bool_t can_edit)
01296 {
01297
01298
01299
01300
01301 if (fMainTrans)
01302 fMainTrans->UnitTrans();
01303 else
01304 fMainTrans = new TEveTrans;
01305 fCanEditMainTrans = can_edit;
01306 }
01307
01308
01309 void TEveElement::DestroyMainTrans()
01310 {
01311
01312
01313
01314 delete fMainTrans;
01315 fMainTrans = 0;
01316 fCanEditMainTrans = kFALSE;
01317 }
01318
01319
01320 void TEveElement::SetTransMatrix(Double_t* carr)
01321 {
01322
01323
01324 RefMainTrans().SetFrom(carr);
01325 }
01326
01327
01328 void TEveElement::SetTransMatrix(const TGeoMatrix& mat)
01329 {
01330
01331
01332 RefMainTrans().SetFrom(mat);
01333 }
01334
01335
01336
01337
01338
01339 Bool_t TEveElement::AcceptElement(TEveElement* el)
01340 {
01341
01342
01343
01344
01345
01346 return el != this;
01347 }
01348
01349
01350 void TEveElement::AddElement(TEveElement* el)
01351 {
01352
01353
01354 static const TEveException eh("TEveElement::AddElement ");
01355
01356 if ( ! AcceptElement(el))
01357 throw(eh + Form("parent '%s' rejects '%s'.",
01358 GetElementName(), el->GetElementName()));
01359
01360 el->AddParent(this);
01361 fChildren.push_back(el); ++fNumChildren;
01362 el->AddIntoListTrees(this);
01363 ElementChanged();
01364 }
01365
01366
01367 void TEveElement::RemoveElement(TEveElement* el)
01368 {
01369
01370
01371 el->RemoveFromListTrees(this);
01372 RemoveElementLocal(el);
01373 el->RemoveParent(this);
01374 fChildren.remove(el); --fNumChildren;
01375 ElementChanged();
01376 }
01377
01378
01379 void TEveElement::RemoveElementLocal(TEveElement* )
01380 {
01381
01382
01383
01384
01385
01386
01387
01388
01389 }
01390
01391
01392 void TEveElement::RemoveElementsInternal()
01393 {
01394
01395
01396
01397
01398
01399 for (sLTI_i i=fItems.begin(); i!=fItems.end(); ++i)
01400 {
01401 DestroyListSubTree(i->fTree, i->fItem);
01402 }
01403 RemoveElementsLocal();
01404 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
01405 {
01406 (*i)->RemoveParent(this);
01407 }
01408 fChildren.clear(); fNumChildren = 0;
01409 }
01410
01411
01412 void TEveElement::RemoveElements()
01413 {
01414
01415
01416
01417
01418 if (HasChildren())
01419 {
01420 RemoveElementsInternal();
01421 ElementChanged();
01422 }
01423 }
01424
01425
01426 void TEveElement::RemoveElementsLocal()
01427 {
01428
01429
01430 }
01431
01432
01433
01434
01435 void TEveElement::ProjectChild(TEveElement* el, Bool_t same_depth)
01436 {
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448 TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
01449 if (pable && HasChild(el))
01450 {
01451 for (TEveProjectable::ProjList_i i = pable->BeginProjecteds(); i != pable->EndProjecteds(); ++i)
01452 {
01453 TEveProjectionManager *pmgr = (*i)->GetManager();
01454 Float_t cd = pmgr->GetCurrentDepth();
01455 if (same_depth) pmgr->SetCurrentDepth((*i)->GetDepth());
01456
01457 pmgr->SubImportElements(el, (*i)->GetProjectedAsElement());
01458
01459 if (same_depth) pmgr->SetCurrentDepth(cd);
01460 }
01461 }
01462 }
01463
01464
01465 void TEveElement::ProjectAllChildren(Bool_t same_depth)
01466 {
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478 TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
01479 if (pable)
01480 {
01481 for (TEveProjectable::ProjList_i i = pable->BeginProjecteds(); i != pable->EndProjecteds(); ++i)
01482 {
01483 TEveProjectionManager *pmgr = (*i)->GetManager();
01484 Float_t cd = pmgr->GetCurrentDepth();
01485 if (same_depth) pmgr->SetCurrentDepth((*i)->GetDepth());
01486
01487 pmgr->SubImportChildren(this, (*i)->GetProjectedAsElement());
01488
01489 if (same_depth) pmgr->SetCurrentDepth(cd);
01490 }
01491 }
01492 }
01493
01494
01495
01496
01497 Bool_t TEveElement::HasChild(TEveElement* el)
01498 {
01499
01500
01501 return (std::find(fChildren.begin(), fChildren.end(), el) != fChildren.end());
01502 }
01503
01504
01505 TEveElement* TEveElement::FindChild(const TString& name, const TClass* cls)
01506 {
01507
01508
01509
01510
01511
01512 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
01513 {
01514 if (name.CompareTo((*i)->GetElementName()) == 0)
01515 {
01516 if (!cls || (cls && (*i)->IsA()->InheritsFrom(cls)))
01517 return *i;
01518 }
01519 }
01520 return 0;
01521 }
01522
01523
01524 TEveElement* TEveElement::FindChild(TPRegexp& regexp, const TClass* cls)
01525 {
01526
01527
01528
01529
01530
01531 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
01532 {
01533 if (regexp.MatchB((*i)->GetElementName()))
01534 {
01535 if (!cls || (cls && (*i)->IsA()->InheritsFrom(cls)))
01536 return *i;
01537 }
01538 }
01539 return 0;
01540 }
01541
01542
01543 Int_t TEveElement::FindChildren(List_t& matches,
01544 const TString& name, const TClass* cls)
01545 {
01546
01547
01548
01549
01550
01551 Int_t count = 0;
01552 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
01553 {
01554 if (name.CompareTo((*i)->GetElementName()) == 0)
01555 {
01556 if (!cls || (cls && (*i)->IsA()->InheritsFrom(cls)))
01557 {
01558 matches.push_back(*i);
01559 ++count;
01560 }
01561 }
01562 }
01563 return count;
01564 }
01565
01566
01567 Int_t TEveElement::FindChildren(List_t& matches,
01568 TPRegexp& regexp, const TClass* cls)
01569 {
01570
01571
01572
01573
01574
01575 Int_t count = 0;
01576 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
01577 {
01578 if (regexp.MatchB((*i)->GetElementName()))
01579 {
01580 if (!cls || (cls && (*i)->IsA()->InheritsFrom(cls)))
01581 {
01582 matches.push_back(*i);
01583 ++count;
01584 }
01585 }
01586 }
01587 return count;
01588 }
01589
01590
01591 TEveElement* TEveElement::FirstChild() const
01592 {
01593
01594
01595 return HasChildren() ? fChildren.front() : 0;
01596 }
01597
01598
01599 TEveElement* TEveElement::LastChild () const
01600 {
01601
01602
01603 return HasChildren() ? fChildren.back() : 0;
01604 }
01605
01606
01607
01608
01609
01610 void TEveElement::EnableListElements(Bool_t rnr_self, Bool_t rnr_children)
01611 {
01612
01613
01614
01615 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
01616 {
01617 (*i)->SetRnrSelf(rnr_self);
01618 (*i)->SetRnrChildren(rnr_children);
01619 }
01620
01621 ElementChanged(kTRUE, kTRUE);
01622 }
01623
01624
01625 void TEveElement::DisableListElements(Bool_t rnr_self, Bool_t rnr_children)
01626 {
01627
01628
01629
01630
01631
01632
01633 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
01634 {
01635 (*i)->SetRnrSelf(rnr_self);
01636 (*i)->SetRnrChildren(rnr_children);
01637 }
01638
01639 ElementChanged(kTRUE, kTRUE);
01640 }
01641
01642
01643
01644
01645 void TEveElement::AnnihilateRecursively()
01646 {
01647
01648
01649 static const TEveException eh("TEveElement::AnnihilateRecursively ");
01650
01651
01652 TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
01653 if (pable && pable->HasProjecteds())
01654 {
01655 pable->ClearProjectedList();
01656 }
01657
01658
01659 for (sLTI_i i=fItems.begin(); i!=fItems.end(); ++i)
01660 {
01661 DestroyListSubTree(i->fTree, i->fItem);
01662 }
01663 RemoveElementsLocal();
01664 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
01665 {
01666 (*i)->AnnihilateRecursively();
01667 }
01668
01669 fChildren.clear();
01670 fNumChildren = 0;
01671
01672 fDestructing = kAnnihilate;
01673 PreDeleteElement();
01674
01675 delete this;
01676 }
01677
01678
01679 void TEveElement::Annihilate()
01680 {
01681
01682
01683
01684
01685
01686 static const TEveException eh("TEveElement::Annihilate ");
01687
01688 if (fParents.size() > 1)
01689 {
01690 Warning(eh, "More than one parent for '%s': %d. Refusing to delete.",
01691 GetElementName(), (Int_t) fParents.size());
01692 return;
01693 }
01694
01695 fDestructing = kAnnihilate;
01696
01697
01698 TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
01699 if (pable && pable->HasProjecteds())
01700 {
01701 pable->AnnihilateProjecteds();
01702 }
01703
01704
01705 while (!fParents.empty())
01706 {
01707 fParents.front()->RemoveElement(this);
01708 }
01709
01710 AnnihilateRecursively();
01711
01712 gEve->Redraw3D();
01713 }
01714
01715
01716 void TEveElement::AnnihilateElements()
01717 {
01718
01719
01720 while (!fChildren.empty())
01721 {
01722 TEveElement* c = fChildren.front();
01723 c->Annihilate();
01724 }
01725
01726 fNumChildren = 0;
01727 }
01728
01729
01730 void TEveElement::Destroy()
01731 {
01732
01733
01734 static const TEveException eh("TEveElement::Destroy ");
01735
01736 if (fDenyDestroy > 0)
01737 throw eh + TString::Format("element '%s' (%s*) 0x%lx is protected against destruction.",
01738 GetElementName(), IsA()->GetName(), (ULong_t)this);
01739
01740 PreDeleteElement();
01741 delete this;
01742 gEve->Redraw3D();
01743 }
01744
01745
01746 void TEveElement::DestroyOrWarn()
01747 {
01748
01749
01750 static const TEveException eh("TEveElement::DestroyOrWarn ");
01751
01752 try
01753 {
01754 Destroy();
01755 }
01756 catch (TEveException& exc)
01757 {
01758 Warning(eh, "%s", exc.Data());
01759 }
01760 }
01761
01762
01763 void TEveElement::DestroyElements()
01764 {
01765
01766
01767 static const TEveException eh("TEveElement::DestroyElements ");
01768
01769 while (HasChildren())
01770 {
01771 TEveElement* c = fChildren.front();
01772 if (c->fDenyDestroy <= 0)
01773 {
01774 try {
01775 c->Destroy();
01776 }
01777 catch (TEveException exc) {
01778 Warning(eh, "element destruction failed: '%s'.", exc.Data());
01779 RemoveElement(c);
01780 }
01781 }
01782 else
01783 {
01784 if (gDebug > 0)
01785 Info(eh, "element '%s' is protected agains destruction, removing locally.", c->GetElementName());
01786 RemoveElement(c);
01787 }
01788 }
01789
01790 gEve->Redraw3D();
01791 }
01792
01793
01794 Bool_t TEveElement::GetDestroyOnZeroRefCnt() const
01795 {
01796
01797
01798
01799
01800 return fDestroyOnZeroRefCnt;
01801 }
01802
01803
01804 void TEveElement::SetDestroyOnZeroRefCnt(Bool_t d)
01805 {
01806
01807
01808
01809
01810 fDestroyOnZeroRefCnt = d;
01811 }
01812
01813
01814 Int_t TEveElement::GetDenyDestroy() const
01815 {
01816
01817
01818
01819 return fDenyDestroy;
01820 }
01821
01822
01823 void TEveElement::IncDenyDestroy()
01824 {
01825
01826
01827
01828 ++fDenyDestroy;
01829 }
01830
01831
01832 void TEveElement::DecDenyDestroy()
01833 {
01834
01835
01836
01837 if (--fDenyDestroy <= 0)
01838 CheckReferenceCount("TEveElement::DecDenyDestroy ");
01839 }
01840
01841
01842 Int_t TEveElement::GetParentIgnoreCnt() const
01843 {
01844
01845
01846
01847
01848
01849
01850 return fParentIgnoreCnt;
01851 }
01852
01853
01854 void TEveElement::IncParentIgnoreCnt()
01855 {
01856
01857
01858 ++fParentIgnoreCnt;
01859 }
01860
01861
01862 void TEveElement::DecParentIgnoreCnt()
01863 {
01864
01865
01866 if (--fParentIgnoreCnt <= 0)
01867 CheckReferenceCount("TEveElement::DecParentIgnoreCnt ");
01868 }
01869
01870
01871
01872
01873
01874 Bool_t TEveElement::HandleElementPaste(TEveElement* el)
01875 {
01876
01877
01878
01879 gEve->AddElement(el, this);
01880 return kTRUE;
01881 }
01882
01883
01884 void TEveElement::ElementChanged(Bool_t update_scenes, Bool_t redraw)
01885 {
01886
01887
01888
01889 gEve->ElementChanged(this, update_scenes, redraw);
01890 }
01891
01892
01893
01894
01895
01896
01897 TEveElement* TEveElement::ForwardSelection()
01898 {
01899
01900
01901
01902
01903 return 0;
01904 }
01905
01906
01907 TEveElement* TEveElement::ForwardEdit()
01908 {
01909
01910
01911
01912
01913 return 0;
01914 }
01915
01916
01917 void TEveElement::SelectElement(Bool_t state)
01918 {
01919
01920
01921 if (fSelected != state) {
01922 fSelected = state;
01923 if (!fSelected && fImpliedSelected == 0)
01924 UnSelected();
01925 fParentIgnoreCnt += (fSelected) ? 1 : -1;
01926 StampColorSelection();
01927 }
01928 }
01929
01930
01931 void TEveElement::IncImpliedSelected()
01932 {
01933
01934
01935 if (fImpliedSelected++ == 0)
01936 StampColorSelection();
01937 }
01938
01939
01940 void TEveElement::DecImpliedSelected()
01941 {
01942
01943
01944 if (--fImpliedSelected == 0)
01945 {
01946 if (!fSelected)
01947 UnSelected();
01948 StampColorSelection();
01949 }
01950 }
01951
01952
01953 void TEveElement::UnSelected()
01954 {
01955
01956
01957
01958 }
01959
01960
01961 void TEveElement::HighlightElement(Bool_t state)
01962 {
01963
01964
01965 if (fHighlighted != state) {
01966 fHighlighted = state;
01967 if (!fHighlighted && fImpliedHighlighted == 0)
01968 UnHighlighted();
01969 fParentIgnoreCnt += (fHighlighted) ? 1 : -1;
01970 StampColorSelection();
01971 }
01972 }
01973
01974
01975 void TEveElement::IncImpliedHighlighted()
01976 {
01977
01978
01979 if (fImpliedHighlighted++ == 0)
01980 StampColorSelection();
01981 }
01982
01983
01984 void TEveElement::DecImpliedHighlighted()
01985 {
01986
01987
01988 if (--fImpliedHighlighted == 0)
01989 {
01990 if (!fHighlighted)
01991 UnHighlighted();
01992 StampColorSelection();
01993 }
01994 }
01995
01996
01997 void TEveElement::UnHighlighted()
01998 {
01999
02000
02001
02002 }
02003
02004
02005 void TEveElement::FillImpliedSelectedSet(Set_t& impSelSet)
02006 {
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016 TEveProjectable* p = dynamic_cast<TEveProjectable*>(this);
02017 if (p)
02018 {
02019 p->AddProjectedsToSet(impSelSet);
02020 }
02021 }
02022
02023
02024 UChar_t TEveElement::GetSelectedLevel() const
02025 {
02026
02027
02028
02029
02030 if (fSelected) return 1;
02031 if (fImpliedSelected > 0) return 2;
02032 if (fHighlighted) return 3;
02033 if (fImpliedHighlighted > 0) return 4;
02034 return 0;
02035 }
02036
02037
02038 void TEveElement::RecheckImpliedSelections()
02039 {
02040
02041
02042
02043
02044
02045
02046
02047 if (fSelected || fImpliedSelected)
02048 gEve->GetSelection()->RecheckImpliedSetForElement(this);
02049
02050 if (fHighlighted || fImpliedHighlighted)
02051 gEve->GetHighlight()->RecheckImpliedSetForElement(this);
02052 }
02053
02054
02055
02056
02057
02058
02059
02060 void TEveElement::AddStamp(UChar_t bits)
02061 {
02062
02063
02064
02065
02066
02067 fChangeBits |= bits;
02068 if (fDestructing == kNone) gEve->ElementStamped(this);
02069 }
02070
02071
02072
02073
02074
02075
02076 const TGPicture* TEveElement::GetListTreeIcon(Bool_t open)
02077 {
02078
02079
02080
02081 return fgListTreeIcons[open ? 7 : 0];
02082 }
02083
02084
02085 const TGPicture* TEveElement::GetListTreeCheckBoxIcon()
02086 {
02087
02088
02089
02090 Int_t idx = 0;
02091 if (fRnrSelf) idx = 2;
02092 if (fRnrChildren ) idx++;
02093
02094 return fgRnrIcons[idx];
02095 }
02096
02097
02098 const char* TEveElement::ToString(Bool_t b)
02099 {
02100
02101
02102
02103 return b ? "kTRUE" : "kFALSE";
02104 }
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116 ClassImp(TEveElementObjectPtr);
02117
02118
02119 TEveElementObjectPtr::TEveElementObjectPtr(TObject* obj, Bool_t own) :
02120 TEveElement (),
02121 TObject (),
02122 fObject (obj),
02123 fOwnObject (own)
02124 {
02125
02126 }
02127
02128
02129 TEveElementObjectPtr::TEveElementObjectPtr(TObject* obj, Color_t& mainColor, Bool_t own) :
02130 TEveElement (mainColor),
02131 TObject (),
02132 fObject (obj),
02133 fOwnObject (own)
02134 {
02135
02136 }
02137
02138
02139 TEveElementObjectPtr::TEveElementObjectPtr(const TEveElementObjectPtr& e) :
02140 TEveElement (e),
02141 TObject (e),
02142 fObject (0),
02143 fOwnObject (e.fOwnObject)
02144 {
02145
02146
02147
02148
02149
02150 if (fOwnObject && e.fObject)
02151 {
02152 fObject = e.fObject->Clone();
02153 SetMainColorPtr((Color_t*)((const char*) fObject + ((const char*) e.GetMainColorPtr() - (const char*) e.fObject)));
02154 }
02155 else
02156 {
02157 SetMainColorPtr(e.GetMainColorPtr());
02158 }
02159 }
02160
02161
02162 TEveElementObjectPtr* TEveElementObjectPtr::CloneElement() const
02163 {
02164
02165
02166
02167 return new TEveElementObjectPtr(*this);
02168 }
02169
02170
02171 TObject* TEveElementObjectPtr::GetObject(const TEveException& eh) const
02172 {
02173
02174
02175
02176 if (fObject == 0)
02177 throw eh + "fObject not set.";
02178 return fObject;
02179 }
02180
02181
02182 void TEveElementObjectPtr::ExportToCINT(char* var_name)
02183 {
02184
02185
02186
02187 static const TEveException eh("TEveElementObjectPtr::ExportToCINT ");
02188
02189 TObject* obj = GetObject(eh);
02190 const char* cname = obj->IsA()->GetName();
02191 gROOT->ProcessLine(Form("%s* %s = (%s*)0x%lx;", cname, var_name, cname, (ULong_t)obj));
02192 }
02193
02194
02195 TEveElementObjectPtr::~TEveElementObjectPtr()
02196 {
02197
02198
02199 if (fOwnObject)
02200 delete fObject;
02201 }
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220 ClassImp(TEveElementList);
02221
02222
02223 TEveElementList::TEveElementList(const char* n, const char* t, Bool_t doColor, Bool_t doTransparency) :
02224 TEveElement(),
02225 TNamed(n, t),
02226 TEveProjectable(),
02227 fColor(0),
02228 fChildClass(0)
02229 {
02230
02231
02232 if (doColor) {
02233 fCanEditMainColor = kTRUE;
02234 SetMainColorPtr(&fColor);
02235 }
02236 if (doTransparency)
02237 {
02238 fCanEditMainTransparency = kTRUE;
02239 }
02240 }
02241
02242
02243 TEveElementList::TEveElementList(const TEveElementList& e) :
02244 TEveElement (e),
02245 TNamed (e),
02246 TEveProjectable(),
02247 fColor (e.fColor),
02248 fChildClass (e.fChildClass)
02249 {
02250
02251 }
02252
02253
02254 TEveElementList* TEveElementList::CloneElement() const
02255 {
02256
02257
02258
02259 return new TEveElementList(*this);
02260 }
02261
02262
02263 Bool_t TEveElementList::AcceptElement(TEveElement* el)
02264 {
02265
02266
02267
02268 if (fChildClass && ! el->IsA()->InheritsFrom(fChildClass))
02269 return kFALSE;
02270 return kTRUE;
02271 }
02272
02273
02274 TClass* TEveElementList::ProjectedClass(const TEveProjection*) const
02275 {
02276
02277
02278 return TEveElementListProjected::Class();
02279 }
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292 ClassImp(TEveElementListProjected);
02293
02294
02295 TEveElementListProjected::TEveElementListProjected() :
02296 TEveElementList("TEveElementListProjected")
02297 {
02298
02299 }
02300
02301
02302 void TEveElementListProjected::UpdateProjection()
02303 {
02304
02305
02306 }