45 ClassImp(TEveElement::TEveListTreeInfo);
53 ClassImp(TEveElement);
55 const TGPicture* TEveElement::fgRnrIcons[4] = { 0 };
56 const TGPicture* TEveElement::fgListTreeIcons[9] = { 0 };
61 TEveElement::TEveElement() :
71 fDestroyOnZeroRefCnt (kTRUE),
74 fCanEditMainColor (kFALSE),
75 fCanEditMainTransparency(kFALSE),
76 fCanEditMainTrans (kFALSE),
77 fMainTransparency (0),
85 fHighlighted (kFALSE),
87 fImpliedHighlighted (0),
97 TEveElement::TEveElement(Color_t& main_color) :
104 fParentIgnoreCnt (0),
107 fDestroyOnZeroRefCnt (kTRUE),
109 fRnrChildren (kTRUE),
110 fCanEditMainColor (kFALSE),
111 fCanEditMainTransparency(kFALSE),
112 fCanEditMainTrans (kFALSE),
113 fMainTransparency (0),
114 fMainColorPtr (&main_color),
121 fHighlighted (kFALSE),
122 fImpliedSelected (0),
123 fImpliedHighlighted (0),
143 TEveElement::TEveElement(
const TEveElement& e) :
150 fParentIgnoreCnt (0),
153 fDestroyOnZeroRefCnt (e.fDestroyOnZeroRefCnt),
154 fRnrSelf (e.fRnrSelf),
155 fRnrChildren (e.fRnrChildren),
156 fCanEditMainColor (e.fCanEditMainColor),
157 fCanEditMainTransparency(e.fCanEditMainTransparency),
158 fCanEditMainTrans (e.fCanEditMainTrans),
159 fMainTransparency (e.fMainTransparency),
165 fPickable (e.fPickable),
167 fHighlighted (kFALSE),
168 fImpliedSelected (0),
169 fImpliedHighlighted (0),
170 fCSCBits (e.fCSCBits),
174 SetVizModel(e.fVizModel);
176 fMainColorPtr = (Color_t*)((
const char*)
this + ((
const char*) e.fMainColorPtr - (
const char*) &e));
178 fMainTrans =
new TEveTrans(*e.fMainTrans);
186 TEveElement::~TEveElement()
188 if (fDestructing != kAnnihilate)
190 fDestructing = kStandard;
191 RemoveElementsInternal();
193 for (List_i p=fParents.begin(); p!=fParents.end(); ++p)
195 (*p)->RemoveElementLocal(
this);
196 (*p)->fChildren.remove(
this);
197 --((*p)->fNumChildren);
203 for (sLTI_i i=fItems.begin(); i!=fItems.end(); ++i)
204 i->fTree->DeleteItem(i->fItem);
215 void TEveElement::PreDeleteElement()
217 gEve->PreDeleteElement(
this);
224 TEveElement* TEveElement::CloneElement()
const
226 return new TEveElement(*
this);
234 TEveElement* TEveElement::CloneElementRecurse(Int_t level)
const
236 TEveElement* el = CloneElement();
239 CloneChildrenRecurse(el, level);
249 void TEveElement::CloneChildrenRecurse(TEveElement* dest, Int_t level)
const
251 for (List_ci i=fChildren.begin(); i!=fChildren.end(); ++i)
253 dest->AddElement((*i)->CloneElementRecurse(level));
265 const char* TEveElement::GetElementName()
const
267 static const TEveException eh(
"TEveElement::GetElementName ");
269 TNamed* named =
dynamic_cast<TNamed*
>(GetObject(eh));
270 return named ? named->GetName() :
"<no-name>";
278 const char* TEveElement::GetElementTitle()
const
280 static const TEveException eh(
"TEveElement::GetElementTitle ");
282 TNamed* named =
dynamic_cast<TNamed*
>(GetObject(eh));
283 return named ? named->GetTitle() :
"<no-title>";
292 void TEveElement::SetElementName(
const char* name)
294 static const TEveException eh(
"TEveElement::SetElementName ");
296 TNamed* named =
dynamic_cast<TNamed*
>(GetObject(eh));
298 named->SetName(name);
309 void TEveElement::SetElementTitle(
const char* title)
311 static const TEveException eh(
"TEveElement::SetElementTitle ");
313 TNamed* named =
dynamic_cast<TNamed*
>(GetObject(eh));
315 named->SetTitle(title);
326 void TEveElement::SetElementNameTitle(
const char* name,
const char* title)
328 static const TEveException eh(
"TEveElement::SetElementNameTitle ");
330 TNamed* named =
dynamic_cast<TNamed*
>(GetObject(eh));
332 named->SetNameTitle(name, title);
342 void TEveElement::NameTitleChanged()
355 void TEveElement::SetVizModel(TEveElement* model)
359 fVizModel->RemoveElement(
this);
363 fVizModel->AddElement(
this);
374 Bool_t TEveElement::FindVizModel()
376 TEveElement* model = gEve->FindVizDBEntry(fVizTag);
397 Bool_t TEveElement::ApplyVizTag(
const TString& tag,
const TString& fallback_tag)
402 CopyVizParamsFromDB();
405 if ( ! fallback_tag.IsNull())
407 SetVizTag(fallback_tag);
410 CopyVizParamsFromDB();
414 Warning(
"TEveElement::ApplyVizTag",
"entry for tag '%s' not found in VizDB.", tag.Data());
427 void TEveElement::PropagateVizParamsToProjecteds()
429 TEveProjectable* pable =
dynamic_cast<TEveProjectable*
>(
this);
430 if (pable && pable->HasProjecteds())
432 pable->PropagateVizParams();
443 void TEveElement::PropagateVizParamsToElements(TEveElement* el)
448 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
450 (*i)->CopyVizParams(el);
462 void TEveElement::CopyVizParams(
const TEveElement* el)
464 fCanEditMainColor = el->fCanEditMainColor;
465 fCanEditMainTransparency = el->fCanEditMainTransparency;
466 fMainTransparency = el->fMainTransparency;
468 AddStamp(kCBColorSelection | kCBObjProps);
475 void TEveElement::CopyVizParamsFromDB()
479 CopyVizParams(fVizModel);
483 Warning(
"TEveElement::CopyVizParamsFromDB",
"VizModel has not been set.");
494 void TEveElement::SaveVizParams(std::ostream& out,
const TString& tag,
const TString& var)
496 static const TEveException eh(
"TEveElement::GetObject ");
499 TString cls(GetObject(eh)->ClassName());
503 TString intro =
" TAG='" + tag +
"', CLASS='" + cls +
"'";
504 out <<
" //" << intro <<
"\n";
505 out <<
" //" << TString(
'-', intro.Length()) <<
"\n";
506 out << t << cls <<
"* " << var <<
" = new " << cls <<
";\n";
508 WriteVizParams(out, var);
510 out << t <<
"gEve->InsertVizDBEntry(\"" << tag <<
"\", "<< var <<
");\n";
521 void TEveElement::WriteVizParams(std::ostream& out,
const TString& var)
523 TString t =
" " + var +
"->";
525 out << t <<
"SetElementName(\"" << GetElementName() <<
"\");\n";
526 out << t <<
"SetElementTitle(\"" << GetElementTitle() <<
"\");\n";
527 out << t <<
"SetEditMainColor(" << fCanEditMainColor <<
");\n";
528 out << t <<
"SetEditMainTransparency(" << fCanEditMainTransparency <<
");\n";
529 out << t <<
"SetMainTransparency(" << fMainTransparency <<
");\n";
535 void TEveElement::VizDB_Apply(
const char* tag)
537 if (ApplyVizTag(tag))
539 PropagateVizParamsToProjecteds();
548 void TEveElement::VizDB_Reapply()
552 CopyVizParamsFromDB();
553 PropagateVizParamsToProjecteds();
564 void TEveElement::VizDB_UpdateModel(Bool_t update)
568 fVizModel->CopyVizParams(
this);
571 fVizModel->PropagateVizParamsToElements(fVizModel);
577 Warning(
"VizDB_UpdateModel",
"VizModel has not been set.");
586 void TEveElement::VizDB_Insert(
const char* tag, Bool_t replace, Bool_t update)
588 static const TEveException eh(
"TEveElement::GetObject ");
590 TClass* cls = GetObject(eh)->IsA();
591 TEveElement* el =
reinterpret_cast<TEveElement*
>(cls->New());
593 Error(
"VizDB_Insert",
"Creation of replica failed.");
596 el->CopyVizParams(
this);
597 Bool_t succ = gEve->InsertVizDBEntry(tag, el, replace, update);
609 TEveElement* TEveElement::GetMaster()
611 TEveProjected* proj =
dynamic_cast<TEveProjected*
>(
this);
614 return dynamic_cast<TEveElement*
>(proj->GetProjectable())->GetMaster();
618 return fCompound->GetMaster();
620 if (TestCSCBits(kCSCBTakeAnyParentAsMaster))
622 for (List_i i = fParents.begin(); i != fParents.end(); ++i)
623 if (dynamic_cast<TEveCompound*>(*i))
624 return (*i)->GetMaster();
635 void TEveElement::AddParent(TEveElement* re)
637 fParents.push_back(re);
645 void TEveElement::RemoveParent(TEveElement* re)
647 static const TEveException eh(
"TEveElement::RemoveParent ");
650 CheckReferenceCount(eh);
659 void TEveElement::CheckReferenceCount(
const TEveException& eh)
661 if (fDestructing != kNone)
664 if (NumParents() <= fParentIgnoreCnt && fTopItemCnt <= 0 &&
665 fDestroyOnZeroRefCnt && fDenyDestroy <= 0)
667 if (gEve->GetUseOrphanage())
670 Info(eh,
"moving to orphanage '%s' on zero reference count.", GetElementName());
673 gEve->GetOrphanage()->AddElement(
this);
678 Info(eh,
"auto-destructing '%s' on zero reference count.", GetElementName());
692 void TEveElement::CollectSceneParents(List_t& scenes)
694 for (List_i p=fParents.begin(); p!=fParents.end(); ++p)
695 (*p)->CollectSceneParents(scenes);
705 void TEveElement::CollectSceneParentsFromChildren(List_t& scenes,
708 for (List_i p=fParents.begin(); p!=fParents.end(); ++p)
710 if (*p != parent) (*p)->CollectSceneParents(scenes);
713 for (List_i c=fChildren.begin(); c!=fChildren.end(); ++c)
715 (*c)->CollectSceneParentsFromChildren(scenes,
this);
729 void TEveElement::ExpandIntoListTree(TGListTree* ltree,
730 TGListTreeItem* parent)
732 if (parent->GetFirstChild() != 0)
734 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
735 (*i)->AddIntoListTree(ltree, parent);
742 void TEveElement::DestroyListSubTree(TGListTree* ltree,
743 TGListTreeItem* parent)
745 TGListTreeItem* i = parent->GetFirstChild();
748 TEveElement* re = (TEveElement*) i->GetUserData();
749 i = i->GetNextSibling();
750 re->RemoveFromListTree(ltree, parent);
759 TGListTreeItem* TEveElement::AddIntoListTree(TGListTree* ltree,
760 TGListTreeItem* parent_lti)
762 static const TEveException eh(
"TEveElement::AddIntoListTree ");
764 TGListTreeItem* item =
new TEveListTreeItem(
this);
765 ltree->AddItem(parent_lti, item);
766 fItems.insert(TEveListTreeInfo(ltree, item));
771 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
773 (*i)->AddIntoListTree(ltree, item);
776 ltree->ClearViewPort();
786 TGListTreeItem* TEveElement::AddIntoListTree(TGListTree* ltree,
789 TGListTreeItem* lti = 0;
791 lti = AddIntoListTree(ltree, (TGListTreeItem*) 0);
793 for (sLTI_ri i = parent->fItems.rbegin(); i != parent->fItems.rend(); ++i)
795 if (i->fTree == ltree)
796 lti = AddIntoListTree(ltree, i->fItem);
807 TGListTreeItem* TEveElement::AddIntoListTrees(TEveElement* parent)
809 TGListTreeItem* lti = 0;
810 for (sLTI_ri i = parent->fItems.rbegin(); i != parent->fItems.rend(); ++i)
812 lti = AddIntoListTree(i->fTree, i->fItem);
823 Bool_t TEveElement::RemoveFromListTree(TGListTree* ltree,
824 TGListTreeItem* parent_lti)
826 static const TEveException eh(
"TEveElement::RemoveFromListTree ");
828 sLTI_i i = FindItem(ltree, parent_lti);
829 if (i != fItems.end()) {
830 DestroyListSubTree(ltree, i->fItem);
831 ltree->DeleteItem(i->fItem);
832 ltree->ClearViewPort();
834 if (parent_lti == 0) {
836 CheckReferenceCount(eh);
848 Int_t TEveElement::RemoveFromListTrees(TEveElement* parent)
850 static const TEveException eh(
"TEveElement::RemoveFromListTrees ");
854 sLTI_i i = fItems.begin();
855 while (i != fItems.end())
858 TGListTreeItem *plti = j->fItem->GetParent();
859 if ((plti != 0 && (TEveElement*) plti->GetUserData() == parent) ||
860 (plti == 0 && parent == 0))
862 DestroyListSubTree(j->fTree, j->fItem);
863 j->fTree->DeleteItem(j->fItem);
864 j->fTree->ClearViewPort();
872 if (parent == 0 && count > 0)
873 CheckReferenceCount(eh);
883 TEveElement::sLTI_i TEveElement::FindItem(TGListTree* ltree)
885 for (sLTI_i i = fItems.begin(); i != fItems.end(); ++i)
886 if (i->fTree == ltree)
895 TEveElement::sLTI_i TEveElement::FindItem(TGListTree* ltree,
896 TGListTreeItem* parent_lti)
898 for (sLTI_i i = fItems.begin(); i != fItems.end(); ++i)
899 if (i->fTree == ltree && i->fItem->GetParent() == parent_lti)
909 TGListTreeItem* TEveElement::FindListTreeItem(TGListTree* ltree)
911 for (sLTI_i i = fItems.begin(); i != fItems.end(); ++i)
912 if (i->fTree == ltree)
921 TGListTreeItem* TEveElement::FindListTreeItem(TGListTree* ltree,
922 TGListTreeItem* parent_lti)
924 for (sLTI_i i = fItems.begin(); i != fItems.end(); ++i)
925 if (i->fTree == ltree && i->fItem->GetParent() == parent_lti)
937 TObject* TEveElement::GetObject(
const TEveException& eh)
const
939 const TObject* obj =
dynamic_cast<const TObject*
>(
this);
941 throw(eh +
"not a TObject.");
942 return const_cast<TObject*
>(obj);
949 void TEveElement::SpawnEditor()
951 gEve->EditElement(
this);
957 void TEveElement::ExportToCINT(
char* var_name)
959 const char* cname = IsA()->GetName();
960 gROOT->ProcessLine(TString::Format(
"%s* %s = (%s*)0x%lx;", cname, var_name, cname, (ULong_t)
this));
967 void TEveElement::DumpSourceObject()
const
969 static const TEveException eh(
"TEveElement::DumpSourceObject ");
971 TObject *so = GetSourceObject();
973 throw eh +
"source-object not set.";
982 void TEveElement::PrintSourceObject()
const
984 static const TEveException eh(
"TEveElement::PrintSourceObject ");
986 TObject *so = GetSourceObject();
988 throw eh +
"source-object not set.";
997 void TEveElement::ExportSourceObjectToCINT(
char* var_name)
const
999 static const TEveException eh(
"TEveElement::ExportSourceObjectToCINT ");
1001 TObject *so = GetSourceObject();
1003 throw eh +
"source-object not set.";
1005 const char* cname = so->IsA()->GetName();
1006 gROOT->ProcessLine(TString::Format(
"%s* %s = (%s*)0x%lx;", cname, var_name, cname, (ULong_t)so));
1012 void TEveElement::PadPaint(Option_t* option)
1014 static const TEveException eh(
"TEveElement::PadPaint ");
1017 if (GetRnrSelf() && (obj = GetRenderObject(eh)))
1021 if (GetRnrChildren()) {
1022 for (List_i i=BeginChildren(); i!=EndChildren(); ++i) {
1023 (*i)->PadPaint(option);
1034 void TEveElement::PaintStandard(TObject*
id)
1036 static const TEveException eh(
"TEveElement::PaintStandard ");
1038 TBuffer3D buff(TBuffer3DTypes::kGeneric);
1042 buff.fColor = GetMainColor();
1043 buff.fTransparency = GetMainTransparency();
1044 if (HasMainTrans()) RefMainTrans().SetBuffer3D(buff);
1046 buff.SetSectionsValid(TBuffer3D::kCore);
1048 Int_t reqSections = gPad->GetViewer3D()->AddObject(buff);
1049 if (reqSections != TBuffer3D::kNone)
1051 Warning(eh,
"IsA='%s'. Viewer3D requires more sections (%d). Only direct-rendering supported.",
1052 id->ClassName(), reqSections);
1061 Bool_t TEveElement::SetRnrSelf(Bool_t rnr)
1063 if (SingleRnrState())
1065 return SetRnrState(rnr);
1068 if (rnr != fRnrSelf)
1072 PropagateRnrStateToProjecteds();
1083 Bool_t TEveElement::SetRnrChildren(Bool_t rnr)
1085 if (SingleRnrState())
1087 return SetRnrState(rnr);
1090 if (rnr != fRnrChildren)
1094 PropagateRnrStateToProjecteds();
1104 Bool_t TEveElement::SetRnrSelfChildren(Bool_t rnr_self, Bool_t rnr_children)
1106 if (SingleRnrState())
1108 return SetRnrState(rnr_self);
1111 if (fRnrSelf != rnr_self || fRnrChildren != rnr_children)
1113 fRnrSelf = rnr_self;
1114 fRnrChildren = rnr_children;
1116 PropagateRnrStateToProjecteds();
1127 Bool_t TEveElement::SetRnrState(Bool_t rnr)
1129 if (fRnrSelf != rnr || fRnrChildren != rnr)
1131 fRnrSelf = fRnrChildren = rnr;
1133 PropagateRnrStateToProjecteds();
1143 void TEveElement::PropagateRnrStateToProjecteds()
1145 TEveProjectable *pable =
dynamic_cast<TEveProjectable*
>(
this);
1146 if (pable && pable->HasProjecteds())
1148 pable->PropagateRenderState(fRnrSelf, fRnrChildren);
1158 void TEveElement::SetMainColor(Color_t color)
1160 Color_t old_color = GetMainColor();
1164 *fMainColorPtr = color;
1165 StampColorSelection();
1168 PropagateMainColorToProjecteds(color, old_color);
1174 void TEveElement::SetMainColorPixel(Pixel_t pixel)
1176 SetMainColor(TColor::GetColor(pixel));
1182 void TEveElement::SetMainColorRGB(UChar_t r, UChar_t g, UChar_t b)
1184 SetMainColor(TColor::GetColor(r, g, b));
1190 void TEveElement::SetMainColorRGB(Float_t r, Float_t g, Float_t b)
1192 SetMainColor(TColor::GetColor(r, g, b));
1198 void TEveElement::PropagateMainColorToProjecteds(Color_t color, Color_t old_color)
1200 TEveProjectable* pable =
dynamic_cast<TEveProjectable*
>(
this);
1201 if (pable && pable->HasProjecteds())
1203 pable->PropagateMainColor(color, old_color);
1211 void TEveElement::SetMainTransparency(Char_t t)
1213 Char_t old_t = GetMainTransparency();
1215 if (t > 100) t = 100;
1216 fMainTransparency = t;
1217 StampColorSelection();
1219 PropagateMainTransparencyToProjecteds(t, old_t);
1226 void TEveElement::SetMainAlpha(Float_t alpha)
1228 if (alpha < 0) alpha = 0;
1229 if (alpha > 1) alpha = 1;
1230 SetMainTransparency((Char_t) (100.0f*(1.0f - alpha)));
1236 void TEveElement::PropagateMainTransparencyToProjecteds(Char_t t, Char_t old_t)
1238 TEveProjectable* pable =
dynamic_cast<TEveProjectable*
>(
this);
1239 if (pable && pable->HasProjecteds())
1241 pable->PropagateMainTransparency(t, old_t);
1249 TEveTrans* TEveElement::PtrMainTrans(Bool_t create)
1251 if (!fMainTrans && create)
1261 TEveTrans& TEveElement::RefMainTrans()
1274 void TEveElement::InitMainTrans(Bool_t can_edit)
1277 fMainTrans->UnitTrans();
1279 fMainTrans =
new TEveTrans;
1280 fCanEditMainTrans = can_edit;
1287 void TEveElement::DestroyMainTrans()
1291 fCanEditMainTrans = kFALSE;
1297 void TEveElement::SetTransMatrix(Double_t* carr)
1299 RefMainTrans().SetFrom(carr);
1305 void TEveElement::SetTransMatrix(
const TGeoMatrix& mat)
1307 RefMainTrans().SetFrom(mat);
1316 Bool_t TEveElement::AcceptElement(TEveElement* el)
1324 void TEveElement::AddElement(TEveElement* el)
1326 static const TEveException eh(
"TEveElement::AddElement ");
1328 if ( ! AcceptElement(el))
1329 throw(eh + Form(
"parent '%s' rejects '%s'.",
1330 GetElementName(), el->GetElementName()));
1332 el->AddParent(
this);
1333 fChildren.push_back(el); ++fNumChildren;
1334 el->AddIntoListTrees(
this);
1341 void TEveElement::RemoveElement(TEveElement* el)
1343 el->RemoveFromListTrees(
this);
1344 RemoveElementLocal(el);
1345 el->RemoveParent(
this);
1346 fChildren.remove(el); --fNumChildren;
1360 void TEveElement::RemoveElementLocal(TEveElement* )
1370 void TEveElement::RemoveElementsInternal()
1372 for (sLTI_i i=fItems.begin(); i!=fItems.end(); ++i)
1374 DestroyListSubTree(i->fTree, i->fItem);
1376 RemoveElementsLocal();
1377 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1379 (*i)->RemoveParent(
this);
1381 fChildren.clear(); fNumChildren = 0;
1389 void TEveElement::RemoveElements()
1393 RemoveElementsInternal();
1402 void TEveElement::RemoveElementsLocal()
1418 void TEveElement::ProjectChild(TEveElement* el, Bool_t same_depth)
1420 TEveProjectable* pable =
dynamic_cast<TEveProjectable*
>(
this);
1421 if (pable && HasChild(el))
1423 for (TEveProjectable::ProjList_i i = pable->BeginProjecteds(); i != pable->EndProjecteds(); ++i)
1425 TEveProjectionManager *pmgr = (*i)->GetManager();
1426 Float_t cd = pmgr->GetCurrentDepth();
1427 if (same_depth) pmgr->SetCurrentDepth((*i)->GetDepth());
1429 pmgr->SubImportElements(el, (*i)->GetProjectedAsElement());
1431 if (same_depth) pmgr->SetCurrentDepth(cd);
1448 void TEveElement::ProjectAllChildren(Bool_t same_depth)
1450 TEveProjectable* pable =
dynamic_cast<TEveProjectable*
>(
this);
1453 for (TEveProjectable::ProjList_i i = pable->BeginProjecteds(); i != pable->EndProjecteds(); ++i)
1455 TEveProjectionManager *pmgr = (*i)->GetManager();
1456 Float_t cd = pmgr->GetCurrentDepth();
1457 if (same_depth) pmgr->SetCurrentDepth((*i)->GetDepth());
1459 pmgr->SubImportChildren(
this, (*i)->GetProjectedAsElement());
1461 if (same_depth) pmgr->SetCurrentDepth(cd);
1469 Bool_t TEveElement::HasChild(TEveElement* el)
1471 return (std::find(fChildren.begin(), fChildren.end(), el) != fChildren.end());
1480 TEveElement* TEveElement::FindChild(
const TString& name,
const TClass* cls)
1482 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1484 if (name.CompareTo((*i)->GetElementName()) == 0)
1486 if (!cls || (cls && (*i)->IsA()->InheritsFrom(cls)))
1499 TEveElement* TEveElement::FindChild(TPRegexp& regexp,
const TClass* cls)
1501 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1503 if (regexp.MatchB((*i)->GetElementName()))
1505 if (!cls || (cls && (*i)->IsA()->InheritsFrom(cls)))
1518 Int_t TEveElement::FindChildren(List_t& matches,
1519 const TString& name,
const TClass* cls)
1522 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1524 if (name.CompareTo((*i)->GetElementName()) == 0)
1526 if (!cls || (cls && (*i)->IsA()->InheritsFrom(cls)))
1528 matches.push_back(*i);
1542 Int_t TEveElement::FindChildren(List_t& matches,
1543 TPRegexp& regexp,
const TClass* cls)
1546 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1548 if (regexp.MatchB((*i)->GetElementName()))
1550 if (!cls || (cls && (*i)->IsA()->InheritsFrom(cls)))
1552 matches.push_back(*i);
1563 TEveElement* TEveElement::FirstChild()
const
1565 return HasChildren() ? fChildren.front() : 0;
1571 TEveElement* TEveElement::LastChild ()
const
1573 return HasChildren() ? fChildren.back() : 0;
1580 void TEveElement::EnableListElements(Bool_t rnr_self, Bool_t rnr_children)
1582 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1584 (*i)->SetRnrSelf(rnr_self);
1585 (*i)->SetRnrChildren(rnr_children);
1588 ElementChanged(kTRUE, kTRUE);
1598 void TEveElement::DisableListElements(Bool_t rnr_self, Bool_t rnr_children)
1600 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1602 (*i)->SetRnrSelf(rnr_self);
1603 (*i)->SetRnrChildren(rnr_children);
1606 ElementChanged(kTRUE, kTRUE);
1612 void TEveElement::AnnihilateRecursively()
1614 static const TEveException eh(
"TEveElement::AnnihilateRecursively ");
1617 TEveProjectable* pable =
dynamic_cast<TEveProjectable*
>(
this);
1618 if (pable && pable->HasProjecteds())
1620 pable->ClearProjectedList();
1624 for (sLTI_i i=fItems.begin(); i!=fItems.end(); ++i)
1626 DestroyListSubTree(i->fTree, i->fItem);
1628 RemoveElementsLocal();
1629 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1631 (*i)->AnnihilateRecursively();
1637 fDestructing = kAnnihilate;
1649 void TEveElement::Annihilate()
1651 static const TEveException eh(
"TEveElement::Annihilate ");
1653 if (fParents.size() > 1)
1655 Warning(eh,
"More than one parent for '%s': %d. Refusing to delete.",
1656 GetElementName(), (Int_t) fParents.size());
1660 fDestructing = kAnnihilate;
1663 TEveProjectable* pable =
dynamic_cast<TEveProjectable*
>(
this);
1664 if (pable && pable->HasProjecteds())
1666 pable->AnnihilateProjecteds();
1670 while (!fParents.empty())
1672 fParents.front()->RemoveElement(
this);
1675 AnnihilateRecursively();
1683 void TEveElement::AnnihilateElements()
1685 while (!fChildren.empty())
1687 TEveElement* c = fChildren.front();
1700 void TEveElement::Destroy()
1702 static const TEveException eh(
"TEveElement::Destroy ");
1704 if (fDenyDestroy > 0)
1705 throw eh + TString::Format(
"element '%s' (%s*) 0x%lx is protected against destruction.",
1706 GetElementName(), IsA()->GetName(), (ULong_t)
this);
1716 void TEveElement::DestroyOrWarn()
1718 static const TEveException eh(
"TEveElement::DestroyOrWarn ");
1724 catch (TEveException& exc)
1726 Warning(eh,
"%s", exc.Data());
1733 void TEveElement::DestroyElements()
1735 static const TEveException eh(
"TEveElement::DestroyElements ");
1737 while (HasChildren())
1739 TEveElement* c = fChildren.front();
1740 if (c->fDenyDestroy <= 0)
1745 catch (
const TEveException &exc) {
1746 Warning(eh,
"element destruction failed: '%s'.", exc.Data());
1753 Info(eh,
"element '%s' is protected agains destruction, removing locally.", c->GetElementName());
1766 Bool_t TEveElement::GetDestroyOnZeroRefCnt()
const
1768 return fDestroyOnZeroRefCnt;
1776 void TEveElement::SetDestroyOnZeroRefCnt(Bool_t d)
1778 fDestroyOnZeroRefCnt = d;
1785 Int_t TEveElement::GetDenyDestroy()
const
1787 return fDenyDestroy;
1794 void TEveElement::IncDenyDestroy()
1803 void TEveElement::DecDenyDestroy()
1805 if (--fDenyDestroy <= 0)
1806 CheckReferenceCount(
"TEveElement::DecDenyDestroy ");
1816 Int_t TEveElement::GetParentIgnoreCnt()
const
1818 return fParentIgnoreCnt;
1824 void TEveElement::IncParentIgnoreCnt()
1832 void TEveElement::DecParentIgnoreCnt()
1834 if (--fParentIgnoreCnt <= 0)
1835 CheckReferenceCount(
"TEveElement::DecParentIgnoreCnt ");
1842 Bool_t TEveElement::HandleElementPaste(TEveElement* el)
1844 gEve->AddElement(el,
this);
1852 void TEveElement::ElementChanged(Bool_t update_scenes, Bool_t redraw)
1854 gEve->ElementChanged(
this, update_scenes, redraw);
1860 void TEveElement::SetPickableRecursively(Bool_t p)
1863 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1865 (*i)->SetPickableRecursively(p);
1874 TEveElement* TEveElement::ForwardSelection()
1884 TEveElement* TEveElement::ForwardEdit()
1892 void TEveElement::SelectElement(Bool_t state)
1894 if (fSelected != state) {
1896 if (!fSelected && fImpliedSelected == 0)
1898 fParentIgnoreCnt += (fSelected) ? 1 : -1;
1899 StampColorSelection();
1906 void TEveElement::IncImpliedSelected()
1908 if (fImpliedSelected++ == 0)
1909 StampColorSelection();
1915 void TEveElement::DecImpliedSelected()
1917 if (--fImpliedSelected == 0)
1921 StampColorSelection();
1930 void TEveElement::UnSelected()
1937 void TEveElement::HighlightElement(Bool_t state)
1939 if (fHighlighted != state) {
1940 fHighlighted = state;
1941 if (!fHighlighted && fImpliedHighlighted == 0)
1943 fParentIgnoreCnt += (fHighlighted) ? 1 : -1;
1944 StampColorSelection();
1951 void TEveElement::IncImpliedHighlighted()
1953 if (fImpliedHighlighted++ == 0)
1954 StampColorSelection();
1960 void TEveElement::DecImpliedHighlighted()
1962 if (--fImpliedHighlighted == 0)
1966 StampColorSelection();
1975 void TEveElement::UnHighlighted()
1989 void TEveElement::FillImpliedSelectedSet(Set_t& impSelSet)
1991 TEveProjectable* p =
dynamic_cast<TEveProjectable*
>(
this);
1994 p->AddProjectedsToSet(impSelSet);
2003 UChar_t TEveElement::GetSelectedLevel()
const
2005 if (fSelected)
return 1;
2006 if (fImpliedSelected > 0)
return 2;
2007 if (fHighlighted)
return 3;
2008 if (fImpliedHighlighted > 0)
return 4;
2020 void TEveElement::RecheckImpliedSelections()
2022 if (fSelected || fImpliedSelected)
2023 gEve->GetSelection()->RecheckImpliedSetForElement(
this);
2025 if (fHighlighted || fImpliedHighlighted)
2026 gEve->GetHighlight()->RecheckImpliedSetForElement(
this);
2035 void TEveElement::AddStamp(UChar_t bits)
2037 fChangeBits |= bits;
2038 if (fDestructing == kNone) gEve->ElementStamped(
this);
2044 const TGPicture* TEveElement::GetListTreeIcon(Bool_t open)
2047 return fgListTreeIcons[open ? 7 : 0];
2054 const TGPicture* TEveElement::GetListTreeCheckBoxIcon()
2057 if (fRnrSelf) idx = 2;
2058 if (fRnrChildren ) idx++;
2060 return fgRnrIcons[idx];
2067 const char* TEveElement::ToString(Bool_t b)
2069 return b ?
"kTRUE" :
"kFALSE";
2084 ClassImp(TEveElementList);
2089 TEveElementList::TEveElementList(
const char* n,
const char* t, Bool_t doColor, Bool_t doTransparency) :
2097 fCanEditMainColor = kTRUE;
2098 SetMainColorPtr(&fColor);
2102 fCanEditMainTransparency = kTRUE;
2109 TEveElementList::TEveElementList(
const TEveElementList& e) :
2114 fChildClass (e.fChildClass)
2122 TEveElementList* TEveElementList::CloneElement()
const
2124 return new TEveElementList(*
this);
2131 Bool_t TEveElementList::AcceptElement(TEveElement* el)
2133 if (fChildClass && ! el->IsA()->InheritsFrom(fChildClass))
2141 TClass* TEveElementList::ProjectedClass(
const TEveProjection*)
const
2143 return TEveElementListProjected::Class();
2152 ClassImp(TEveElementListProjected);
2157 TEveElementListProjected::TEveElementListProjected() :
2158 TEveElementList(
"TEveElementListProjected")
2166 void TEveElementListProjected::UpdateProjection()