Logo ROOT   6.08/07
Reference Guide
TEveElement.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TEveElement.h"
13 #include "TEveCompound.h"
14 #include "TEveTrans.h"
15 #include "TEveManager.h"
16 #include "TEveSelection.h"
17 #include "TEveProjectionBases.h"
18 #include "TEveProjectionManager.h"
19 
20 #include "TBuffer3D.h"
21 #include "TBuffer3DTypes.h"
22 #include "TVirtualPad.h"
23 #include "TVirtualViewer3D.h"
24 
25 #include "TGeoMatrix.h"
26 
27 #include "TClass.h"
28 #include "TPRegexp.h"
29 #include "TROOT.h"
30 #include "TColor.h"
31 #include "TEveBrowser.h"
32 #include "TGListTree.h"
33 #include "TGPicture.h"
34 
35 #include <algorithm>
36 
37 /** \class TEveElement::TEveListTreeInfo
38 \ingroup TEve
39 Structure holding information about TGListTree and TGListTreeItem
40 that represents given TEveElement. This needed because each element
41 can appear in several list-trees as well as several times in the
42 same list-tree.
43 */
44 
46 
47 /** \class TEveElement
48 \ingroup TEve
49 Base class for TEveUtil visualization elements, providing hierarchy
50 management, rendering control and list-tree item management.
51 */
52 
54 
55 const TGPicture* TEveElement::fgRnrIcons[4] = { 0 };
56 const TGPicture* TEveElement::fgListTreeIcons[9] = { 0 };
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 /// Default constructor.
60 
62  fParents (),
63  fChildren (),
64  fCompound (0),
65  fVizModel (0),
66  fVizTag (),
67  fNumChildren (0),
68  fParentIgnoreCnt (0),
69  fTopItemCnt (0),
70  fDenyDestroy (0),
71  fDestroyOnZeroRefCnt (kTRUE),
72  fRnrSelf (kTRUE),
73  fRnrChildren (kTRUE),
74  fCanEditMainColor (kFALSE),
75  fCanEditMainTransparency(kFALSE),
76  fCanEditMainTrans (kFALSE),
77  fMainTransparency (0),
78  fMainColorPtr (0),
79  fMainTrans (0),
80  fItems (),
81  fSource (),
82  fUserData (0),
83  fPickable (kFALSE),
84  fSelected (kFALSE),
85  fHighlighted (kFALSE),
86  fImpliedSelected (0),
87  fImpliedHighlighted (0),
88  fCSCBits (0),
89  fChangeBits (0),
90  fDestructing (kNone)
91 {
92 }
93 
94 ////////////////////////////////////////////////////////////////////////////////
95 /// Constructor.
96 
98  fParents (),
99  fChildren (),
100  fCompound (0),
101  fVizModel (0),
102  fVizTag (),
103  fNumChildren (0),
104  fParentIgnoreCnt (0),
105  fTopItemCnt (0),
106  fDenyDestroy (0),
108  fRnrSelf (kTRUE),
113  fMainTransparency (0),
114  fMainColorPtr (&main_color),
115  fMainTrans (0),
116  fItems (),
117  fSource (),
118  fUserData (0),
119  fPickable (kFALSE),
120  fSelected (kFALSE),
122  fImpliedSelected (0),
124  fCSCBits (0),
125  fChangeBits (0),
127 {
128 }
129 
130 ////////////////////////////////////////////////////////////////////////////////
131 /// Copy constructor. Does shallow copy.
132 /// For deep-cloning and children-cloning, see:
133 /// ~~~ {.cpp}
134 /// TEveElement* CloneElementRecurse(Int_t level)
135 /// void CloneChildrenRecurse(TEveElement* dest, Int_t level)
136 /// ~~~
137 /// 'TRef fSource' is copied but 'void* UserData' is NOT.
138 /// If the element is projectable, its projections are NOT copied.
139 ///
140 /// Not implemented for most sub-classes, let us know.
141 /// Note that sub-classes of TEveProjected are NOT and will NOT be copyable.
142 
144  fParents (),
145  fChildren (),
146  fCompound (0),
147  fVizModel (0),
148  fVizTag (e.fVizTag),
149  fNumChildren (0),
150  fParentIgnoreCnt (0),
151  fTopItemCnt (0),
152  fDenyDestroy (0),
154  fRnrSelf (e.fRnrSelf),
160  fMainColorPtr (0),
161  fMainTrans (0),
162  fItems (),
163  fSource (e.fSource),
164  fUserData (0),
165  fPickable (e.fPickable),
166  fSelected (kFALSE),
168  fImpliedSelected (0),
170  fCSCBits (e.fCSCBits),
171  fChangeBits (0),
173 {
175  if (e.fMainColorPtr)
176  fMainColorPtr = (Color_t*)((const char*) this + ((const char*) e.fMainColorPtr - (const char*) &e));
177  if (e.fMainTrans)
178  fMainTrans = new TEveTrans(*e.fMainTrans);
179 }
180 
181 ////////////////////////////////////////////////////////////////////////////////
182 /// Destructor. Do not call this method directly, either call Destroy() or
183 /// Annihilate(). See also DestroyElements() and AnnihilateElements() if you
184 /// need to delete all children of an element.
185 
187 {
188  if (fDestructing != kAnnihilate)
189  {
192 
193  for (List_i p=fParents.begin(); p!=fParents.end(); ++p)
194  {
195  (*p)->RemoveElementLocal(this);
196  (*p)->fChildren.remove(this);
197  --((*p)->fNumChildren);
198  }
199  }
200 
201  fParents.clear();
202 
203  for (sLTI_i i=fItems.begin(); i!=fItems.end(); ++i)
204  i->fTree->DeleteItem(i->fItem);
205 
206  delete fMainTrans;
207 }
208 
209 ////////////////////////////////////////////////////////////////////////////////
210 /// Called before the element is deleted, thus offering the last chance
211 /// to detach from acquired resources and from the framework itself.
212 /// Here the request is just passed to TEveManager.
213 /// If you override it, make sure to call base-class version.
214 
216 {
217  gEve->PreDeleteElement(this);
218 }
219 
220 ////////////////////////////////////////////////////////////////////////////////
221 /// Clone the element via copy constructor.
222 /// Should be implemented for all classes that require cloning support.
223 
225 {
226  return new TEveElement(*this);
227 }
228 
229 ////////////////////////////////////////////////////////////////////////////////
230 /// Clone elements and recurse 'level' deep over children.
231 /// - If level == 0, only the element itself is cloned (default).
232 /// - If level == -1, all the hierarchy is cloned.
233 
235 {
236  TEveElement* el = CloneElement();
237  if (level--)
238  {
239  CloneChildrenRecurse(el, level);
240  }
241  return el;
242 }
243 
244 ////////////////////////////////////////////////////////////////////////////////
245 /// Clone children and attach them to the dest element.
246 /// If level == 0, only the direct descendants are cloned (default).
247 /// If level == -1, all the hierarchy is cloned.
248 
250 {
251  for (List_ci i=fChildren.begin(); i!=fChildren.end(); ++i)
252  {
253  dest->AddElement((*i)->CloneElementRecurse(level));
254  }
255 }
256 
257 
258 //==============================================================================
259 
260 ////////////////////////////////////////////////////////////////////////////////
261 /// Virtual function for retrieving name of the element.
262 /// Here we attempt to cast the assigned object into TNamed and call
263 /// GetName() there.
264 
265 const char* TEveElement::GetElementName() const
266 {
267  static const TEveException eh("TEveElement::GetElementName ");
268 
269  TNamed* named = dynamic_cast<TNamed*>(GetObject(eh));
270  return named ? named->GetName() : "<no-name>";
271 }
272 
273 ////////////////////////////////////////////////////////////////////////////////
274 /// Virtual function for retrieving title of the render-element.
275 /// Here we attempt to cast the assigned object into TNamed and call
276 /// GetTitle() there.
277 
278 const char* TEveElement::GetElementTitle() const
279 {
280  static const TEveException eh("TEveElement::GetElementTitle ");
281 
282  TNamed* named = dynamic_cast<TNamed*>(GetObject(eh));
283  return named ? named->GetTitle() : "<no-title>";
284 }
285 
286 ////////////////////////////////////////////////////////////////////////////////
287 /// Virtual function for setting of name of an element.
288 /// Here we attempt to cast the assigned object into TNamed and call
289 /// SetName() there.
290 /// If you override this call NameTitleChanged() from there.
291 
293 {
294  static const TEveException eh("TEveElement::SetElementName ");
295 
296  TNamed* named = dynamic_cast<TNamed*>(GetObject(eh));
297  if (named) {
298  named->SetName(name);
300  }
301 }
302 
303 ////////////////////////////////////////////////////////////////////////////////
304 /// Virtual function for setting of title of an element.
305 /// Here we attempt to cast the assigned object into TNamed and call
306 /// SetTitle() there.
307 /// If you override this call NameTitleChanged() from there.
308 
309 void TEveElement::SetElementTitle(const char* title)
310 {
311  static const TEveException eh("TEveElement::SetElementTitle ");
312 
313  TNamed* named = dynamic_cast<TNamed*>(GetObject(eh));
314  if (named) {
315  named->SetTitle(title);
317  }
318 }
319 
320 ////////////////////////////////////////////////////////////////////////////////
321 /// Virtual function for setting of name and title of render element.
322 /// Here we attempt to cast the assigned object into TNamed and call
323 /// SetNameTitle() there.
324 /// If you override this call NameTitleChanged() from there.
325 
326 void TEveElement::SetElementNameTitle(const char* name, const char* title)
327 {
328  static const TEveException eh("TEveElement::SetElementNameTitle ");
329 
330  TNamed* named = dynamic_cast<TNamed*>(GetObject(eh));
331  if (named) {
332  named->SetNameTitle(name, title);
334  }
335 }
336 
337 ////////////////////////////////////////////////////////////////////////////////
338 /// Virtual function called when a name or title of the element has
339 /// been changed.
340 /// If you override this, call also the version of your direct base-class.
341 
343 {
344  // Nothing to do - list-tree-items take this info directly.
345 }
346 
347 //******************************************************************************
348 
349 ////////////////////////////////////////////////////////////////////////////////
350 /// Set visualization-parameter model element.
351 /// Calling of this function from outside of EVE should in principle
352 /// be avoided as it can lead to dis-synchronization of viz-tag and
353 /// viz-model.
354 
356 {
357  if (fVizModel) {
359  fVizModel->RemoveElement(this);
360  }
361  fVizModel = model;
362  if (fVizModel) {
363  fVizModel->AddElement(this);
365  }
366 }
367 
368 ////////////////////////////////////////////////////////////////////////////////
369 /// Find model element in VizDB that corresponds to previously
370 /// assigned fVizTag and set fVizModel accordingly.
371 /// If the tag is not found in VizDB, the old model-element is kept
372 /// and false is returned.
373 
375 {
377  if (model)
378  {
379  SetVizModel(model);
380  return kTRUE;
381  }
382  else
383  {
384  return kFALSE;
385  }
386 }
387 
388 ////////////////////////////////////////////////////////////////////////////////
389 /// Set the VizTag, find model-element from the VizDB and copy
390 /// visualization-parameters from it. If the model is not found and
391 /// fallback_tag is non-null, its search is attempted as well.
392 /// For example: ApplyVizTag("TPC Clusters", "Clusters");
393 ///
394 /// If the model-element can not be found a warning is printed and
395 /// false is returned.
396 
397 Bool_t TEveElement::ApplyVizTag(const TString& tag, const TString& fallback_tag)
398 {
399  SetVizTag(tag);
400  if (FindVizModel())
401  {
403  return kTRUE;
404  }
405  if ( ! fallback_tag.IsNull())
406  {
407  SetVizTag(fallback_tag);
408  if (FindVizModel())
409  {
411  return kTRUE;
412  }
413  }
414  Warning("TEveElement::ApplyVizTag", "entry for tag '%s' not found in VizDB.", tag.Data());
415  return kFALSE;
416 }
417 
418 ////////////////////////////////////////////////////////////////////////////////
419 /// Propagate visualization parameters to dependent elements.
420 ///
421 /// MainColor is propagated independently in SetMainColor().
422 /// In this case, as fMainColor is a pointer to Color_t, it should
423 /// be set in TProperClass::CopyVizParams().
424 ///
425 /// Render state is not propagated. Maybe it should be, at least optionally.
426 
428 {
429  TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
430  if (pable && pable->HasProjecteds())
431  {
432  pable->PropagateVizParams();
433  }
434 }
435 
436 ////////////////////////////////////////////////////////////////////////////////
437 /// Propagate visualization parameters from element el (defaulting
438 /// to this) to all elements (children).
439 ///
440 /// The primary use of this is for model-elements from
441 /// visualization-parameter database.
442 
444 {
445  if (el == 0)
446  el = this;
447 
448  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
449  {
450  (*i)->CopyVizParams(el);
451  }
452 }
453 
454 ////////////////////////////////////////////////////////////////////////////////
455 /// Copy visualization parameters from element el.
456 /// This method needs to be overriden by any class that introduces
457 /// new parameters.
458 /// Color is copied in sub-classes which define it.
459 /// See, for example, TEvePointSet::CopyVizParams(),
460 /// TEveLine::CopyVizParams() and TEveTrack::CopyVizParams().
461 
463 {
467 
469 }
470 
471 ////////////////////////////////////////////////////////////////////////////////
472 /// Copy visualization parameters from the model-element fVizModel.
473 /// A warning is printed if the model-element fVizModel is not set.
474 
476 {
477  if (fVizModel)
478  {
480  }
481  else
482  {
483  Warning("TEveElement::CopyVizParamsFromDB", "VizModel has not been set.");
484  }
485 }
486 
487 ////////////////////////////////////////////////////////////////////////////////
488 /// Save visualization parameters for this element with given tag.
489 ///
490 /// This function creates the instantiation code, calls virtual
491 /// WriteVizParams() and, at the end, writes out the code for
492 /// registration of the model into the VizDB.
493 
494 void TEveElement::SaveVizParams(std::ostream& out, const TString& tag, const TString& var)
495 {
496  static const TEveException eh("TEveElement::GetObject ");
497 
498  TString t = " ";
499  TString cls(GetObject(eh)->ClassName());
500 
501  out << "\n";
502 
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";
507 
508  WriteVizParams(out, var);
509 
510  out << t << "gEve->InsertVizDBEntry(\"" << tag << "\", "<< var <<");\n";
511 }
512 
513 ////////////////////////////////////////////////////////////////////////////////
514 /// Write-out visual parameters for this object.
515 /// This is a virtual function and all sub-classes are required to
516 /// first call the base-element version.
517 /// The name of the element pointer is 'x%03d', due to cint limitations.
518 /// Three spaces should be used for indentation, same as in
519 /// SavePrimitive() methods.
520 
521 void TEveElement::WriteVizParams(std::ostream& out, const TString& var)
522 {
523  TString t = " " + var + "->";
524 
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";
530 }
531 
532 ////////////////////////////////////////////////////////////////////////////////
533 /// Set visual parameters for this object for given tag.
534 
535 void TEveElement::VizDB_Apply(const char* tag)
536 {
537  if (ApplyVizTag(tag))
538  {
540  gEve->Redraw3D();
541  }
542 }
543 
544 ////////////////////////////////////////////////////////////////////////////////
545 /// Reset visual parameters for this object from VizDB.
546 /// The model object must be already set.
547 
549 {
550  if (fVizModel)
551  {
554  gEve->Redraw3D();
555  }
556 }
557 
558 ////////////////////////////////////////////////////////////////////////////////
559 /// Copy visual parameters from this element to viz-db model.
560 /// If update is set, all clients of the model will be updated to
561 /// the new value.
562 /// A warning is printed if the model-element fVizModel is not set.
563 
565 {
566  if (fVizModel)
567  {
568  fVizModel->CopyVizParams(this);
569  if (update)
570  {
572  gEve->Redraw3D();
573  }
574  }
575  else
576  {
577  Warning("VizDB_UpdateModel", "VizModel has not been set.");
578  }
579 }
580 
581 ////////////////////////////////////////////////////////////////////////////////
582 /// Create a replica of element and insert it into VizDB with given tag.
583 /// If replace is true an existing element with the same tag will be replaced.
584 /// If update is true, existing client of tag will be updated.
585 
586 void TEveElement::VizDB_Insert(const char* tag, Bool_t replace, Bool_t update)
587 {
588  static const TEveException eh("TEveElement::GetObject ");
589 
590  TClass* cls = GetObject(eh)->IsA();
591  TEveElement* el = reinterpret_cast<TEveElement*>(cls->New());
592  if (el == 0) {
593  Error("VizDB_Insert", "Creation of replica failed.");
594  return;
595  }
596  el->CopyVizParams(this);
597  Bool_t succ = gEve->InsertVizDBEntry(tag, el, replace, update);
598  if (succ && update)
599  gEve->Redraw3D();
600 }
601 
602 ////////////////////////////////////////////////////////////////////////////////
603 /// Returns the master element - that is:
604 /// - master of projectable, if this is a projected;
605 /// - master of compound, if fCompound is set;
606 /// - master of first compound parent, if kSCBTakeAnyParentAsMaster bit is set;
607 /// If non of the above is true, *this* is returned.
608 
610 {
611  TEveProjected* proj = dynamic_cast<TEveProjected*>(this);
612  if (proj)
613  {
614  return dynamic_cast<TEveElement*>(proj->GetProjectable())->GetMaster();
615  }
616  if (fCompound)
617  {
618  return fCompound->GetMaster();
619  }
621  {
622  for (List_i i = fParents.begin(); i != fParents.end(); ++i)
623  if (dynamic_cast<TEveCompound*>(*i))
624  return (*i)->GetMaster();
625  }
626  return this;
627 }
628 
629 ////////////////////////////////////////////////////////////////////////////////
630 /// Add re into the list parents.
631 ///
632 /// Adding parent is subordinate to adding an element.
633 /// This is an internal function.
634 
636 {
637  fParents.push_back(re);
638 }
639 
640 ////////////////////////////////////////////////////////////////////////////////
641 /// Remove re from the list of parents.
642 /// Removing parent is subordinate to removing an element.
643 /// This is an internal function.
644 
646 {
647  static const TEveException eh("TEveElement::RemoveParent ");
648 
649  fParents.remove(re);
651 }
652 
653 /******************************************************************************/
654 
655 ////////////////////////////////////////////////////////////////////////////////
656 /// Check external references to this and eventually auto-destruct
657 /// the render-element.
658 
660 {
661  if (fDestructing != kNone)
662  return;
663 
664  if (NumParents() <= fParentIgnoreCnt && fTopItemCnt <= 0 &&
666  {
667  if (gEve->GetUseOrphanage())
668  {
669  if (gDebug > 0)
670  Info(eh, "moving to orphanage '%s' on zero reference count.", GetElementName());
671 
673  gEve->GetOrphanage()->AddElement(this);
674  }
675  else
676  {
677  if (gDebug > 0)
678  Info(eh, "auto-destructing '%s' on zero reference count.", GetElementName());
679 
681  delete this;
682  }
683  }
684 }
685 
686 ////////////////////////////////////////////////////////////////////////////////
687 /// Collect all parents of class TEveScene. This is needed to
688 /// automatically detect which scenes need to be updated.
689 ///
690 /// Overriden in TEveScene to include itself and return.
691 
693 {
694  for (List_i p=fParents.begin(); p!=fParents.end(); ++p)
695  (*p)->CollectSceneParents(scenes);
696 }
697 
698 ////////////////////////////////////////////////////////////////////////////////
699 /// Collect scene-parents from all children. This is needed to
700 /// automatically detect which scenes need to be updated during/after
701 /// a full sub-tree update.
702 /// Argument parent specifies parent in traversed hierarchy for which we can
703 /// skip the upwards search.
704 
706  TEveElement* parent)
707 {
708  for (List_i p=fParents.begin(); p!=fParents.end(); ++p)
709  {
710  if (*p != parent) (*p)->CollectSceneParents(scenes);
711  }
712 
713  for (List_i c=fChildren.begin(); c!=fChildren.end(); ++c)
714  {
715  (*c)->CollectSceneParentsFromChildren(scenes, this);
716  }
717 }
718 
719 ////////////////////////////////////////////////////////////////////////////////
720 /// Populates parent with elements.
721 /// parent must be an already existing representation of *this*.
722 /// Returns number of inserted elements.
723 /// If parent already has children, it does nothing.
724 ///
725 /// Element can be inserted in a list-tree several times, thus we can not
726 /// search through fItems to get parent here.
727 /// Anyhow, it is probably known as it must have been selected by the user.
728 
730  TGListTreeItem* parent)
731 {
732  if (parent->GetFirstChild() != 0)
733  return;
734  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
735  (*i)->AddIntoListTree(ltree, parent);
736  }
737 }
738 
739 ////////////////////////////////////////////////////////////////////////////////
740 /// Destroy sub-tree under item 'parent' in list-tree 'ltree'.
741 
743  TGListTreeItem* parent)
744 {
745  TGListTreeItem* i = parent->GetFirstChild();
746  while (i != 0)
747  {
748  TEveElement* re = (TEveElement*) i->GetUserData();
749  i = i->GetNextSibling();
750  re->RemoveFromListTree(ltree, parent);
751  }
752 }
753 
754 ////////////////////////////////////////////////////////////////////////////////
755 /// Add this element into ltree to an already existing item
756 /// parent_lti. Children, if any, are added as below the newly created item.
757 /// Returns the newly created list-tree-item.
758 
760  TGListTreeItem* parent_lti)
761 {
762  static const TEveException eh("TEveElement::AddIntoListTree ");
763 
764  TGListTreeItem* item = new TEveListTreeItem(this);
765  ltree->AddItem(parent_lti, item);
766  fItems.insert(TEveListTreeInfo(ltree, item));
767 
768  if (parent_lti == 0)
769  ++fTopItemCnt;
770 
771  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
772  {
773  (*i)->AddIntoListTree(ltree, item);
774  }
775 
776  ltree->ClearViewPort();
777 
778  return item;
779 }
780 
781 ////////////////////////////////////////////////////////////////////////////////
782 /// Add this render element into ltree to all items belonging to
783 /// parent. Returns list-tree-item from the first register entry (but
784 /// we use a set for that so it can be anything).
785 
787  TEveElement* parent)
788 {
789  TGListTreeItem* lti = 0;
790  if (parent == 0) {
791  lti = AddIntoListTree(ltree, (TGListTreeItem*) 0);
792  } else {
793  for (sLTI_ri i = parent->fItems.rbegin(); i != parent->fItems.rend(); ++i)
794  {
795  if (i->fTree == ltree)
796  lti = AddIntoListTree(ltree, i->fItem);
797  }
798  }
799  return lti;
800 }
801 
802 ////////////////////////////////////////////////////////////////////////////////
803 /// Add this render element into all list-trees and all items
804 /// belonging to parent. Returns list-tree-item from the first
805 /// register entry (but we use a set for that so it can be anything).
806 
808 {
809  TGListTreeItem* lti = 0;
810  for (sLTI_ri i = parent->fItems.rbegin(); i != parent->fItems.rend(); ++i)
811  {
812  lti = AddIntoListTree(i->fTree, i->fItem);
813  }
814  return lti;
815 }
816 
817 ////////////////////////////////////////////////////////////////////////////////
818 /// Remove element from list-tree 'ltree' where its parent item is
819 /// 'parent_lti'.
820 /// Returns kTRUE if the item was found and removed, kFALSE
821 /// otherwise.
822 
824  TGListTreeItem* parent_lti)
825 {
826  static const TEveException eh("TEveElement::RemoveFromListTree ");
827 
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();
833  fItems.erase(i);
834  if (parent_lti == 0) {
835  --fTopItemCnt;
837  }
838  return kTRUE;
839  } else {
840  return kFALSE;
841  }
842 }
843 
844 ////////////////////////////////////////////////////////////////////////////////
845 /// Remove element from all list-trees where 'parent' is the
846 /// user-data of the parent list-tree-item.
847 
849 {
850  static const TEveException eh("TEveElement::RemoveFromListTrees ");
851 
852  Int_t count = 0;
853 
854  sLTI_i i = fItems.begin();
855  while (i != fItems.end())
856  {
857  sLTI_i j = i++;
858  TGListTreeItem *plti = j->fItem->GetParent();
859  if ((plti != 0 && (TEveElement*) plti->GetUserData() == parent) ||
860  (plti == 0 && parent == 0))
861  {
862  DestroyListSubTree(j->fTree, j->fItem);
863  j->fTree->DeleteItem(j->fItem);
864  j->fTree->ClearViewPort();
865  fItems.erase(j);
866  if (parent == 0)
867  --fTopItemCnt;
868  ++count;
869  }
870  }
871 
872  if (parent == 0 && count > 0)
874 
875  return count;
876 }
877 
878 ////////////////////////////////////////////////////////////////////////////////
879 /// Find any list-tree-item of this element in list-tree 'ltree'.
880 /// Note that each element can be placed into the same list-tree on
881 /// several postions.
882 
884 {
885  for (sLTI_i i = fItems.begin(); i != fItems.end(); ++i)
886  if (i->fTree == ltree)
887  return i;
888  return fItems.end();
889 }
890 
891 ////////////////////////////////////////////////////////////////////////////////
892 /// Find list-tree-item of this element with given parent
893 /// list-tree-item.
894 
896  TGListTreeItem* parent_lti)
897 {
898  for (sLTI_i i = fItems.begin(); i != fItems.end(); ++i)
899  if (i->fTree == ltree && i->fItem->GetParent() == parent_lti)
900  return i;
901  return fItems.end();
902 }
903 
904 ////////////////////////////////////////////////////////////////////////////////
905 /// Find any list-tree-item of this element in list-tree 'ltree'.
906 /// Note that each element can be placed into the same list-tree on
907 /// several postions.
908 
910 {
911  for (sLTI_i i = fItems.begin(); i != fItems.end(); ++i)
912  if (i->fTree == ltree)
913  return i->fItem;
914  return 0;
915 }
916 
917 ////////////////////////////////////////////////////////////////////////////////
918 /// Find list-tree-item of this element with given parent
919 /// list-tree-item.
920 
922  TGListTreeItem* parent_lti)
923 {
924  for (sLTI_i i = fItems.begin(); i != fItems.end(); ++i)
925  if (i->fTree == ltree && i->fItem->GetParent() == parent_lti)
926  return i->fItem;
927  return 0;
928 }
929 
930 ////////////////////////////////////////////////////////////////////////////////
931 /// Get a TObject associated with this render-element.
932 /// Most cases uses double-inheritance from TEveElement and TObject
933 /// so we just do a dynamic cast here.
934 /// If some TEveElement descendant implements a different scheme,
935 /// this virtual method should be overriden accordingly.
936 
938 {
939  const TObject* obj = dynamic_cast<const TObject*>(this);
940  if (obj == 0)
941  throw(eh + "not a TObject.");
942  return const_cast<TObject*>(obj);
943 }
944 
945 ////////////////////////////////////////////////////////////////////////////////
946 /// Show GUI editor for this object.
947 /// This is forwarded to TEveManager::EditElement().
948 
950 {
951  gEve->EditElement(this);
952 }
953 
954 ////////////////////////////////////////////////////////////////////////////////
955 /// Export render-element to CINT with variable name var_name.
956 
957 void TEveElement::ExportToCINT(char* var_name)
958 {
959  const char* cname = IsA()->GetName();
960  gROOT->ProcessLine(TString::Format("%s* %s = (%s*)0x%lx;", cname, var_name, cname, (ULong_t)this));
961 }
962 
963 ////////////////////////////////////////////////////////////////////////////////
964 /// Call Dump() on source object.
965 /// Throws an exception if it is not set.
966 
968 {
969  static const TEveException eh("TEveElement::DumpSourceObject ");
970 
971  TObject *so = GetSourceObject();
972  if (!so)
973  throw eh + "source-object not set.";
974 
975  so->Dump();
976 }
977 
978 ////////////////////////////////////////////////////////////////////////////////
979 /// Call Print() on source object.
980 /// Throws an exception if it is not set.
981 
983 {
984  static const TEveException eh("TEveElement::PrintSourceObject ");
985 
986  TObject *so = GetSourceObject();
987  if (!so)
988  throw eh + "source-object not set.";
989 
990  so->Print();
991 }
992 
993 ////////////////////////////////////////////////////////////////////////////////
994 /// Export source object to CINT with given name for the variable.
995 /// Throws an exception if it is not set.
996 
997 void TEveElement::ExportSourceObjectToCINT(char* var_name) const
998 {
999  static const TEveException eh("TEveElement::ExportSourceObjectToCINT ");
1000 
1001  TObject *so = GetSourceObject();
1002  if (!so)
1003  throw eh + "source-object not set.";
1004 
1005  const char* cname = so->IsA()->GetName();
1006  gROOT->ProcessLine(TString::Format("%s* %s = (%s*)0x%lx;", cname, var_name, cname, (ULong_t)so));
1007 }
1008 
1009 ////////////////////////////////////////////////////////////////////////////////
1010 /// Paint self and/or children into currently active pad.
1011 
1013 {
1014  static const TEveException eh("TEveElement::PadPaint ");
1015 
1016  TObject* obj = 0;
1017  if (GetRnrSelf() && (obj = GetRenderObject(eh)))
1018  obj->Paint(option);
1019 
1020 
1021  if (GetRnrChildren()) {
1022  for (List_i i=BeginChildren(); i!=EndChildren(); ++i) {
1023  (*i)->PadPaint(option);
1024  }
1025  }
1026 }
1027 
1028 ////////////////////////////////////////////////////////////////////////////////
1029 /// Paint object -- a generic implementation for EVE elements.
1030 /// This supports direct rendering using a dedicated GL class.
1031 /// Override TObject::Paint() in sub-classes if different behaviour
1032 /// is required.
1033 
1035 {
1036  static const TEveException eh("TEveElement::PaintStandard ");
1037 
1039 
1040  // Section kCore
1041  buff.fID = id;
1042  buff.fColor = GetMainColor();
1044  if (HasMainTrans()) RefMainTrans().SetBuffer3D(buff);
1045 
1047 
1048  Int_t reqSections = gPad->GetViewer3D()->AddObject(buff);
1049  if (reqSections != TBuffer3D::kNone)
1050  {
1051  Warning(eh, "IsA='%s'. Viewer3D requires more sections (%d). Only direct-rendering supported.",
1052  id->ClassName(), reqSections);
1053  }
1054 }
1055 
1056 ////////////////////////////////////////////////////////////////////////////////
1057 /// Set render state of this element, i.e. if it will be published
1058 /// on next scene update pass.
1059 /// Returns true if the state has changed.
1060 
1062 {
1063  if (SingleRnrState())
1064  {
1065  return SetRnrState(rnr);
1066  }
1067 
1068  if (rnr != fRnrSelf)
1069  {
1070  fRnrSelf = rnr;
1071  StampVisibility();
1073  return kTRUE;
1074  }
1075  return kFALSE;
1076 }
1077 
1078 ////////////////////////////////////////////////////////////////////////////////
1079 /// Set render state of this element's children, i.e. if they will
1080 /// be published on next scene update pass.
1081 /// Returns true if the state has changed.
1082 
1084 {
1085  if (SingleRnrState())
1086  {
1087  return SetRnrState(rnr);
1088  }
1089 
1090  if (rnr != fRnrChildren)
1091  {
1092  fRnrChildren = rnr;
1093  StampVisibility();
1095  return kTRUE;
1096  }
1097  return kFALSE;
1098 }
1099 
1100 ////////////////////////////////////////////////////////////////////////////////
1101 /// Set state for rendering of this element and its children.
1102 /// Returns true if the state has changed.
1103 
1105 {
1106  if (SingleRnrState())
1107  {
1108  return SetRnrState(rnr_self);
1109  }
1110 
1111  if (fRnrSelf != rnr_self || fRnrChildren != rnr_children)
1112  {
1113  fRnrSelf = rnr_self;
1114  fRnrChildren = rnr_children;
1115  StampVisibility();
1117  return kTRUE;
1118  }
1119  return kFALSE;
1120 }
1121 
1122 ////////////////////////////////////////////////////////////////////////////////
1123 /// Set render state of this element and of its children to the same
1124 /// value.
1125 /// Returns true if the state has changed.
1126 
1128 {
1129  if (fRnrSelf != rnr || fRnrChildren != rnr)
1130  {
1131  fRnrSelf = fRnrChildren = rnr;
1132  StampVisibility();
1134  return kTRUE;
1135  }
1136  return kFALSE;
1137 }
1138 
1139 ////////////////////////////////////////////////////////////////////////////////
1140 /// Propagate render state to the projected replicas of this element.
1141 /// Maybe this should be optional on gEve/element level.
1142 
1144 {
1145  TEveProjectable *pable = dynamic_cast<TEveProjectable*>(this);
1146  if (pable && pable->HasProjecteds())
1147  {
1149  }
1150 }
1151 
1152 ////////////////////////////////////////////////////////////////////////////////
1153 /// Set main color of the element.
1154 ///
1155 ///
1156 /// List-tree-items are updated.
1157 
1159 {
1160  Color_t old_color = GetMainColor();
1161 
1162  if (fMainColorPtr)
1163  {
1164  *fMainColorPtr = color;
1166  }
1167 
1168  PropagateMainColorToProjecteds(color, old_color);
1169 }
1170 
1171 ////////////////////////////////////////////////////////////////////////////////
1172 /// Convert pixel to Color_t and call SetMainColor().
1173 
1175 {
1177 }
1178 
1179 ////////////////////////////////////////////////////////////////////////////////
1180 /// Convert RGB values to Color_t and call SetMainColor.
1181 
1183 {
1184  SetMainColor(TColor::GetColor(r, g, b));
1185 }
1186 
1187 ////////////////////////////////////////////////////////////////////////////////
1188 /// Convert RGB values to Color_t and call SetMainColor.
1189 
1191 {
1192  SetMainColor(TColor::GetColor(r, g, b));
1193 }
1194 
1195 ////////////////////////////////////////////////////////////////////////////////
1196 /// Propagate color to projected elements.
1197 
1199 {
1200  TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
1201  if (pable && pable->HasProjecteds())
1202  {
1203  pable->PropagateMainColor(color, old_color);
1204  }
1205 }
1206 
1207 ////////////////////////////////////////////////////////////////////////////////
1208 /// Set main-transparency.
1209 /// Transparency is clamped to [0, 100].
1210 
1212 {
1213  Char_t old_t = GetMainTransparency();
1214 
1215  if (t > 100) t = 100;
1216  fMainTransparency = t;
1218 
1220 }
1221 
1222 ////////////////////////////////////////////////////////////////////////////////
1223 /// Set main-transparency via float alpha variable.
1224 /// Value of alpha is clamped t0 [0, 1].
1225 
1227 {
1228  if (alpha < 0) alpha = 0;
1229  if (alpha > 1) alpha = 1;
1230  SetMainTransparency((Char_t) (100.0f*(1.0f - alpha)));
1231 }
1232 
1233 ////////////////////////////////////////////////////////////////////////////////
1234 /// Propagate transparency to projected elements.
1235 
1237 {
1238  TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
1239  if (pable && pable->HasProjecteds())
1240  {
1241  pable->PropagateMainTransparency(t, old_t);
1242  }
1243 }
1244 
1245 ////////////////////////////////////////////////////////////////////////////////
1246 /// Return pointer to main transformation. If 'create' flag is set (default)
1247 /// it is created if not yet existing.
1248 
1250 {
1251  if (!fMainTrans && create)
1252  InitMainTrans();
1253 
1254  return fMainTrans;
1255 }
1256 
1257 ////////////////////////////////////////////////////////////////////////////////
1258 /// Return reference to main transformation. It is created if not yet
1259 /// existing.
1260 
1262 {
1263  if (!fMainTrans)
1264  InitMainTrans();
1265 
1266  return *fMainTrans;
1267 }
1268 
1269 ////////////////////////////////////////////////////////////////////////////////
1270 /// Initialize the main transformation to identity matrix.
1271 /// If can_edit is true (default), the user will be able to edit the
1272 /// transformation parameters via TEveElementEditor.
1273 
1275 {
1276  if (fMainTrans)
1277  fMainTrans->UnitTrans();
1278  else
1279  fMainTrans = new TEveTrans;
1280  fCanEditMainTrans = can_edit;
1281 }
1282 
1283 ////////////////////////////////////////////////////////////////////////////////
1284 /// Destroy the main transformation matrix, it will always be taken
1285 /// as identity. Editing of transformation parameters is disabled.
1286 
1288 {
1289  delete fMainTrans;
1290  fMainTrans = 0;
1292 }
1293 
1294 ////////////////////////////////////////////////////////////////////////////////
1295 /// Set transformation matrix from column-major array.
1296 
1298 {
1299  RefMainTrans().SetFrom(carr);
1300 }
1301 
1302 ////////////////////////////////////////////////////////////////////////////////
1303 /// Set transformation matrix from TGeo's matrix.
1304 
1306 {
1307  RefMainTrans().SetFrom(mat);
1308 }
1309 
1310 ////////////////////////////////////////////////////////////////////////////////
1311 /// Check if el can be added to this element.
1312 ///
1313 /// In the base-class version we only make sure the new child is not
1314 /// equal to this.
1315 
1317 {
1318  return el != this;
1319 }
1320 
1321 ////////////////////////////////////////////////////////////////////////////////
1322 /// Add el to the list of children.
1323 
1325 {
1326  static const TEveException eh("TEveElement::AddElement ");
1327 
1328  if ( ! AcceptElement(el))
1329  throw(eh + Form("parent '%s' rejects '%s'.",
1330  GetElementName(), el->GetElementName()));
1331 
1332  el->AddParent(this);
1333  fChildren.push_back(el); ++fNumChildren;
1334  el->AddIntoListTrees(this);
1335  ElementChanged();
1336 }
1337 
1338 ////////////////////////////////////////////////////////////////////////////////
1339 /// Remove el from the list of children.
1340 
1342 {
1343  el->RemoveFromListTrees(this);
1344  RemoveElementLocal(el);
1345  el->RemoveParent(this);
1346  fChildren.remove(el); --fNumChildren;
1347  ElementChanged();
1348 }
1349 
1350 ////////////////////////////////////////////////////////////////////////////////
1351 /// Perform additional local removal of el.
1352 /// Called from RemoveElement() which does whole untangling.
1353 /// Put into special function as framework-related handling of
1354 /// element removal should really be common to all classes and
1355 /// clearing of local structures happens in between removal
1356 /// of list-tree-items and final removal.
1357 /// If you override this, you should also override
1358 /// RemoveElementsLocal().
1359 
1361 {
1362 }
1363 
1364 ////////////////////////////////////////////////////////////////////////////////
1365 /// Remove all elements. This assumes removing of all elements can
1366 /// be done more efficiently then looping over them and removing one
1367 /// by one. This protected function performs the removal on the
1368 /// level of TEveElement.
1369 
1371 {
1372  for (sLTI_i i=fItems.begin(); i!=fItems.end(); ++i)
1373  {
1374  DestroyListSubTree(i->fTree, i->fItem);
1375  }
1377  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1378  {
1379  (*i)->RemoveParent(this);
1380  }
1381  fChildren.clear(); fNumChildren = 0;
1382 }
1383 
1384 ////////////////////////////////////////////////////////////////////////////////
1385 /// Remove all elements. This assumes removing of all elements can
1386 /// be done more efficiently then looping over them and removing
1387 /// them one by one.
1388 
1390 {
1391  if (HasChildren())
1392  {
1394  ElementChanged();
1395  }
1396 }
1397 
1398 ////////////////////////////////////////////////////////////////////////////////
1399 /// Perform additional local removal of all elements.
1400 /// See comment to RemoveElementlocal(TEveElement*).
1401 
1403 {
1404 }
1405 
1406 ////////////////////////////////////////////////////////////////////////////////
1407 /// If this is a projectable, loop over all projected replicas and
1408 /// add the projected image of child 'el' there. This is supposed to
1409 /// be called after you add a child to a projectable after it has
1410 /// already been projected.
1411 /// You might also want to call RecheckImpliedSelections() on this
1412 /// element or 'el'.
1413 ///
1414 /// If 'same_depth' flag is true, the same depth as for parent object
1415 /// is used in every projection. Otherwise current depth of each
1416 /// relevant projection-manager is used.
1417 
1419 {
1420  TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
1421  if (pable && HasChild(el))
1422  {
1423  for (TEveProjectable::ProjList_i i = pable->BeginProjecteds(); i != pable->EndProjecteds(); ++i)
1424  {
1425  TEveProjectionManager *pmgr = (*i)->GetManager();
1426  Float_t cd = pmgr->GetCurrentDepth();
1427  if (same_depth) pmgr->SetCurrentDepth((*i)->GetDepth());
1428 
1429  pmgr->SubImportElements(el, (*i)->GetProjectedAsElement());
1430 
1431  if (same_depth) pmgr->SetCurrentDepth(cd);
1432  }
1433  }
1434 }
1435 
1436 ////////////////////////////////////////////////////////////////////////////////
1437 /// If this is a projectable, loop over all projected replicas and
1438 /// add the projected image of all children there. This is supposed
1439 /// to be called after you destroy all children and then add new
1440 /// ones after this element has already been projected.
1441 /// You might also want to call RecheckImpliedSelections() on this
1442 /// element.
1443 ///
1444 /// If 'same_depth' flag is true, the same depth as for the
1445 /// projected element is used in every projection. Otherwise current
1446 /// depth of each relevant projection-manager is used.
1447 
1449 {
1450  TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
1451  if (pable)
1452  {
1453  for (TEveProjectable::ProjList_i i = pable->BeginProjecteds(); i != pable->EndProjecteds(); ++i)
1454  {
1455  TEveProjectionManager *pmgr = (*i)->GetManager();
1456  Float_t cd = pmgr->GetCurrentDepth();
1457  if (same_depth) pmgr->SetCurrentDepth((*i)->GetDepth());
1458 
1459  pmgr->SubImportChildren(this, (*i)->GetProjectedAsElement());
1460 
1461  if (same_depth) pmgr->SetCurrentDepth(cd);
1462  }
1463  }
1464 }
1465 
1466 ////////////////////////////////////////////////////////////////////////////////
1467 /// Check if element el is a child of this element.
1468 
1470 {
1471  return (std::find(fChildren.begin(), fChildren.end(), el) != fChildren.end());
1472 }
1473 
1474 ////////////////////////////////////////////////////////////////////////////////
1475 /// Find the first child with given name. If cls is specified (non
1476 /// 0), it is also checked.
1477 ///
1478 /// Returns 0 if not found.
1479 
1481 {
1482  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1483  {
1484  if (name.CompareTo((*i)->GetElementName()) == 0)
1485  {
1486  if (!cls || (cls && (*i)->IsA()->InheritsFrom(cls)))
1487  return *i;
1488  }
1489  }
1490  return 0;
1491 }
1492 
1493 ////////////////////////////////////////////////////////////////////////////////
1494 /// Find the first child whose name matches regexp. If cls is
1495 /// specified (non 0), it is also checked.
1496 ///
1497 /// Returns 0 if not found.
1498 
1500 {
1501  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1502  {
1503  if (regexp.MatchB((*i)->GetElementName()))
1504  {
1505  if (!cls || (cls && (*i)->IsA()->InheritsFrom(cls)))
1506  return *i;
1507  }
1508  }
1509  return 0;
1510 }
1511 
1512 ////////////////////////////////////////////////////////////////////////////////
1513 /// Find all children with given name and append them to matches
1514 /// list. If class is specified (non 0), it is also checked.
1515 ///
1516 /// Returns number of elements added to the list.
1517 
1519  const TString& name, const TClass* cls)
1520 {
1521  Int_t count = 0;
1522  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1523  {
1524  if (name.CompareTo((*i)->GetElementName()) == 0)
1525  {
1526  if (!cls || (cls && (*i)->IsA()->InheritsFrom(cls)))
1527  {
1528  matches.push_back(*i);
1529  ++count;
1530  }
1531  }
1532  }
1533  return count;
1534 }
1535 
1536 ////////////////////////////////////////////////////////////////////////////////
1537 /// Find all children whose name matches regexp and append them to
1538 /// matches list.
1539 ///
1540 /// Returns number of elements added to the list.
1541 
1543  TPRegexp& regexp, const TClass* cls)
1544 {
1545  Int_t count = 0;
1546  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1547  {
1548  if (regexp.MatchB((*i)->GetElementName()))
1549  {
1550  if (!cls || (cls && (*i)->IsA()->InheritsFrom(cls)))
1551  {
1552  matches.push_back(*i);
1553  ++count;
1554  }
1555  }
1556  }
1557  return count;
1558 }
1559 
1560 ////////////////////////////////////////////////////////////////////////////////
1561 /// Returns the first child element or 0 if the list is empty.
1562 
1564 {
1565  return HasChildren() ? fChildren.front() : 0;
1566 }
1567 
1568 ////////////////////////////////////////////////////////////////////////////////
1569 /// Returns the last child element or 0 if the list is empty.
1570 
1572 {
1573  return HasChildren() ? fChildren.back() : 0;
1574 }
1575 
1576 ////////////////////////////////////////////////////////////////////////////////
1577 /// Enable rendering of children and their list contents.
1578 /// Arguments control how to set self/child rendering.
1579 
1580 void TEveElement::EnableListElements(Bool_t rnr_self, Bool_t rnr_children)
1581 {
1582  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1583  {
1584  (*i)->SetRnrSelf(rnr_self);
1585  (*i)->SetRnrChildren(rnr_children);
1586  }
1587 
1589 }
1590 
1591 ////////////////////////////////////////////////////////////////////////////////
1592 /// Disable rendering of children and their list contents.
1593 /// Arguments control how to set self/child rendering.
1594 ///
1595 /// Same as above function, but default arguments are different. This
1596 /// is convenient for calls via context menu.
1597 
1598 void TEveElement::DisableListElements(Bool_t rnr_self, Bool_t rnr_children)
1599 {
1600  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1601  {
1602  (*i)->SetRnrSelf(rnr_self);
1603  (*i)->SetRnrChildren(rnr_children);
1604  }
1605 
1607 }
1608 
1609 ////////////////////////////////////////////////////////////////////////////////
1610 /// Protected member function called from TEveElement::Annihilate().
1611 
1613 {
1614  static const TEveException eh("TEveElement::AnnihilateRecursively ");
1615 
1616  // projected were already destroyed in TEveElement::Anihilate(), now only clear its list
1617  TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
1618  if (pable && pable->HasProjecteds())
1619  {
1620  pable->ClearProjectedList();
1621  }
1622 
1623  // same as TEveElements::RemoveElementsInternal(), except parents are ignored
1624  for (sLTI_i i=fItems.begin(); i!=fItems.end(); ++i)
1625  {
1626  DestroyListSubTree(i->fTree, i->fItem);
1627  }
1629  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1630  {
1631  (*i)->AnnihilateRecursively();
1632  }
1633 
1634  fChildren.clear();
1635  fNumChildren = 0;
1636 
1638  PreDeleteElement();
1639 
1640  delete this;
1641 }
1642 
1643 ////////////////////////////////////////////////////////////////////////////////
1644 /// Optimized destruction without check of reference-count.
1645 /// Parents are not notified about child destruction.
1646 /// The method should only be used when an element does not have
1647 /// more than one parent -- otherwise an exception is thrown.
1648 
1650 {
1651  static const TEveException eh("TEveElement::Annihilate ");
1652 
1653  if (fParents.size() > 1)
1654  {
1655  Warning(eh, "More than one parent for '%s': %d. Refusing to delete.",
1656  GetElementName(), (Int_t) fParents.size());
1657  return;
1658  }
1659 
1661 
1662  // recursive annihilation of projecteds
1663  TEveProjectable* pable = dynamic_cast<TEveProjectable*>(this);
1664  if (pable && pable->HasProjecteds())
1665  {
1666  pable->AnnihilateProjecteds();
1667  }
1668 
1669  // detach from the parent
1670  while (!fParents.empty())
1671  {
1672  fParents.front()->RemoveElement(this);
1673  }
1674 
1676 
1677  gEve->Redraw3D();
1678 }
1679 
1680 ////////////////////////////////////////////////////////////////////////////////
1681 /// Annihilate elements.
1682 
1684 {
1685  while (!fChildren.empty())
1686  {
1687  TEveElement* c = fChildren.front();
1688  c->Annihilate();
1689  }
1690 
1691  fNumChildren = 0;
1692 }
1693 
1694 ////////////////////////////////////////////////////////////////////////////////
1695 /// Destroy this element. Throws an exception if deny-destroy is in force.
1696 /// This method should be called instead of a destructor.
1697 /// Note that an exception will be thrown if the element has been
1698 /// protected against destruction with IncDenyDestroy().
1699 
1701 {
1702  static const TEveException eh("TEveElement::Destroy ");
1703 
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);
1707 
1708  PreDeleteElement();
1709  delete this;
1710  gEve->Redraw3D();
1711 }
1712 
1713 ////////////////////////////////////////////////////////////////////////////////
1714 /// Destroy this element. Prints a warning if deny-destroy is in force.
1715 
1717 {
1718  static const TEveException eh("TEveElement::DestroyOrWarn ");
1719 
1720  try
1721  {
1722  Destroy();
1723  }
1724  catch (TEveException& exc)
1725  {
1726  Warning(eh, "%s", exc.Data());
1727  }
1728 }
1729 
1730 ////////////////////////////////////////////////////////////////////////////////
1731 /// Destroy all children of this element.
1732 
1734 {
1735  static const TEveException eh("TEveElement::DestroyElements ");
1736 
1737  while (HasChildren())
1738  {
1739  TEveElement* c = fChildren.front();
1740  if (c->fDenyDestroy <= 0)
1741  {
1742  try {
1743  c->Destroy();
1744  }
1745  catch (TEveException exc) {
1746  Warning(eh, "element destruction failed: '%s'.", exc.Data());
1747  RemoveElement(c);
1748  }
1749  }
1750  else
1751  {
1752  if (gDebug > 0)
1753  Info(eh, "element '%s' is protected agains destruction, removing locally.", c->GetElementName());
1754  RemoveElement(c);
1755  }
1756  }
1757 
1758  gEve->Redraw3D();
1759 }
1760 
1761 ////////////////////////////////////////////////////////////////////////////////
1762 /// Returns state of flag determining if the element will be
1763 /// destroyed when reference count reaches zero.
1764 /// This is true by default.
1765 
1767 {
1768  return fDestroyOnZeroRefCnt;
1769 }
1770 
1771 ////////////////////////////////////////////////////////////////////////////////
1772 /// Sets the state of flag determining if the element will be
1773 /// destroyed when reference count reaches zero.
1774 /// This is true by default.
1775 
1777 {
1779 }
1780 
1781 ////////////////////////////////////////////////////////////////////////////////
1782 /// Returns the number of times deny-destroy has been requested on
1783 /// the element.
1784 
1786 {
1787  return fDenyDestroy;
1788 }
1789 
1790 ////////////////////////////////////////////////////////////////////////////////
1791 /// Increases the deny-destroy count of the element.
1792 /// Call this if you store an external pointer to the element.
1793 
1795 {
1796  ++fDenyDestroy;
1797 }
1798 
1799 ////////////////////////////////////////////////////////////////////////////////
1800 /// Decreases the deny-destroy count of the element.
1801 /// Call this after releasing an external pointer to the element.
1802 
1804 {
1805  if (--fDenyDestroy <= 0)
1806  CheckReferenceCount("TEveElement::DecDenyDestroy ");
1807 }
1808 
1809 ////////////////////////////////////////////////////////////////////////////////
1810 /// Get number of parents that should be ignored in doing
1811 /// reference-counting.
1812 ///
1813 /// For example, this is used when subscribing an element to a
1814 /// visualization-database model object.
1815 
1817 {
1818  return fParentIgnoreCnt;
1819 }
1820 
1821 ////////////////////////////////////////////////////////////////////////////////
1822 /// Increase number of parents ignored in reference-counting.
1823 
1825 {
1826  ++fParentIgnoreCnt;
1827 }
1828 
1829 ////////////////////////////////////////////////////////////////////////////////
1830 /// Decrease number of parents ignored in reference-counting.
1831 
1833 {
1834  if (--fParentIgnoreCnt <= 0)
1835  CheckReferenceCount("TEveElement::DecParentIgnoreCnt ");
1836 }
1837 
1838 ////////////////////////////////////////////////////////////////////////////////
1839 /// React to element being pasted or dnd-ed.
1840 /// Return true if redraw is needed.
1841 
1843 {
1844  gEve->AddElement(el, this);
1845  return kTRUE;
1846 }
1847 
1848 ////////////////////////////////////////////////////////////////////////////////
1849 /// Call this after an element has been changed so that the state
1850 /// can be propagated around the framework.
1851 
1852 void TEveElement::ElementChanged(Bool_t update_scenes, Bool_t redraw)
1853 {
1854  gEve->ElementChanged(this, update_scenes, redraw);
1855 }
1856 
1857 ////////////////////////////////////////////////////////////////////////////////
1858 /// Set pickable state on the element and all its children.
1859 
1861 {
1862  fPickable = p;
1863  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
1864  {
1865  (*i)->SetPickableRecursively(p);
1866  }
1867 }
1868 
1869 ////////////////////////////////////////////////////////////////////////////////
1870 /// Returns element to be selected on click.
1871 /// If value is zero the selected object will follow rules in
1872 /// TEveSelection.
1873 
1875 {
1876  return 0;
1877 }
1878 
1879 ////////////////////////////////////////////////////////////////////////////////
1880 /// Returns element to be displayed in GUI editor on click.
1881 /// If value is zero the displayed object will follow rules in
1882 /// TEveSelection.
1883 
1885 {
1886  return 0;
1887 }
1888 
1889 ////////////////////////////////////////////////////////////////////////////////
1890 /// Set element's selection state. Stamp appropriately.
1891 
1893 {
1894  if (fSelected != state) {
1895  fSelected = state;
1896  if (!fSelected && fImpliedSelected == 0)
1897  UnSelected();
1898  fParentIgnoreCnt += (fSelected) ? 1 : -1;
1900  }
1901 }
1902 
1903 ////////////////////////////////////////////////////////////////////////////////
1904 /// Increase element's implied-selection count. Stamp appropriately.
1905 
1907 {
1908  if (fImpliedSelected++ == 0)
1910 }
1911 
1912 ////////////////////////////////////////////////////////////////////////////////
1913 /// Decrease element's implied-selection count. Stamp appropriately.
1914 
1916 {
1917  if (--fImpliedSelected == 0)
1918  {
1919  if (!fSelected)
1920  UnSelected();
1922  }
1923 }
1924 
1925 ////////////////////////////////////////////////////////////////////////////////
1926 /// Virtual function called when both fSelected is false and
1927 /// fImpliedSelected is 0.
1928 /// Nothing is done in this base-class version
1929 
1931 {
1932 }
1933 
1934 ////////////////////////////////////////////////////////////////////////////////
1935 /// Set element's highlight state. Stamp appropriately.
1936 
1938 {
1939  if (fHighlighted != state) {
1940  fHighlighted = state;
1941  if (!fHighlighted && fImpliedHighlighted == 0)
1942  UnHighlighted();
1943  fParentIgnoreCnt += (fHighlighted) ? 1 : -1;
1945  }
1946 }
1947 
1948 ////////////////////////////////////////////////////////////////////////////////
1949 /// Increase element's implied-highlight count. Stamp appropriately.
1950 
1952 {
1953  if (fImpliedHighlighted++ == 0)
1955 }
1956 
1957 ////////////////////////////////////////////////////////////////////////////////
1958 /// Decrease element's implied-highlight count. Stamp appropriately.
1959 
1961 {
1962  if (--fImpliedHighlighted == 0)
1963  {
1964  if (!fHighlighted)
1965  UnHighlighted();
1967  }
1968 }
1969 
1970 ////////////////////////////////////////////////////////////////////////////////
1971 /// Virtual function called when both fHighlighted is false and
1972 /// fImpliedHighlighted is 0.
1973 /// Nothing is done in this base-class version
1974 
1976 {
1977 }
1978 
1979 ////////////////////////////////////////////////////////////////////////////////
1980 /// Populate set impSelSet with derived / dependant elements.
1981 ///
1982 /// If this is a TEveProjectable, the projected replicas are added
1983 /// to the set. Thus it does not have to be reimplemented for each
1984 /// sub-class of TEveProjected.
1985 ///
1986 /// Note that this also takes care of projections of TEveCompound
1987 /// class, which is also a projectable.
1988 
1990 {
1991  TEveProjectable* p = dynamic_cast<TEveProjectable*>(this);
1992  if (p)
1993  {
1994  p->AddProjectedsToSet(impSelSet);
1995  }
1996 }
1997 
1998 ////////////////////////////////////////////////////////////////////////////////
1999 /// Get selection level, needed for rendering selection and
2000 /// highlight feedback.
2001 /// This should go to TAtt3D.
2002 
2004 {
2005  if (fSelected) return 1;
2006  if (fImpliedSelected > 0) return 2;
2007  if (fHighlighted) return 3;
2008  if (fImpliedHighlighted > 0) return 4;
2009  return 0;
2010 }
2011 
2012 ////////////////////////////////////////////////////////////////////////////////
2013 /// Call this if it is possible that implied-selection or highlight
2014 /// has changed for this element or for implied-selection this
2015 /// element is member of and you want to maintain consistent
2016 /// selection state.
2017 /// This can happen if you add elements into compounds in response
2018 /// to user-interaction.
2019 
2021 {
2022  if (fSelected || fImpliedSelected)
2024 
2027 }
2028 
2029 ////////////////////////////////////////////////////////////////////////////////
2030 /// Add (bitwise or) given stamps to fChangeBits.
2031 /// Register this element to gEve as stamped.
2032 /// This method is virtual so that sub-classes can add additional
2033 /// actions. The base-class method should still be called (or replicated).
2034 
2036 {
2037  fChangeBits |= bits;
2038  if (fDestructing == kNone) gEve->ElementStamped(this);
2039 }
2040 
2041 ////////////////////////////////////////////////////////////////////////////////
2042 /// Returns pointer to first listtreeicon
2043 
2045 {
2046  // Need better solution for icon-loading/ids !!!!
2047  return fgListTreeIcons[open ? 7 : 0];
2048 }
2049 
2050 ////////////////////////////////////////////////////////////////////////////////
2051 /// Returns list-tree-item check-box picture appropriate for given
2052 /// rendering state.
2053 
2055 {
2056  Int_t idx = 0;
2057  if (fRnrSelf) idx = 2;
2058  if (fRnrChildren ) idx++;
2059 
2060  return fgRnrIcons[idx];
2061 }
2062 
2063 ////////////////////////////////////////////////////////////////////////////////
2064 /// Convert Bool_t to string - kTRUE or kFALSE.
2065 /// Needed in WriteVizParams().
2066 
2068 {
2069  return b ? "kTRUE" : "kFALSE";
2070 }
2071 
2072 /** \class TEveElementObjectPtr
2073 \ingroup TEve
2074 TEveElement with external TObject as a holder of visualization data.
2075 */
2076 
2078 
2079 ////////////////////////////////////////////////////////////////////////////////
2080 /// Constructor.
2081 
2083  TEveElement (),
2084  TObject (),
2085  fObject (obj),
2086  fOwnObject (own)
2087 {
2088 }
2089 
2090 ////////////////////////////////////////////////////////////////////////////////
2091 /// Constructor.
2092 
2094  TEveElement (mainColor),
2095  TObject (),
2096  fObject (obj),
2097  fOwnObject (own)
2098 {
2099 }
2100 
2101 ////////////////////////////////////////////////////////////////////////////////
2102 /// Copy constructor.
2103 /// If object pointed to is owned it is cloned.
2104 /// It is assumed that the main-color has its origin in the TObject pointed to so
2105 /// it is fixed here accordingly.
2106 
2108  TEveElement (e),
2109  TObject (e),
2110  fObject (0),
2112 {
2113  if (fOwnObject && e.fObject)
2114  {
2115  fObject = e.fObject->Clone();
2116  SetMainColorPtr((Color_t*)((const char*) fObject + ((const char*) e.GetMainColorPtr() - (const char*) e.fObject)));
2117  }
2118  else
2119  {
2121  }
2122 }
2123 
2124 ////////////////////////////////////////////////////////////////////////////////
2125 /// Clone the element via copy constructor.
2126 /// Virtual from TEveElement.
2127 
2129 {
2130  return new TEveElementObjectPtr(*this);
2131 }
2132 
2133 ////////////////////////////////////////////////////////////////////////////////
2134 /// Return external object.
2135 /// Virtual from TEveElement.
2136 
2138 {
2139  if (fObject == 0)
2140  throw eh + "fObject not set.";
2141  return fObject;
2142 }
2143 
2144 ////////////////////////////////////////////////////////////////////////////////
2145 /// Export external object to CINT with variable name var_name.
2146 /// Virtual from TEveElement.
2147 
2149 {
2150  static const TEveException eh("TEveElementObjectPtr::ExportToCINT ");
2151 
2152  TObject* obj = GetObject(eh);
2153  const char* cname = obj->IsA()->GetName();
2154  gROOT->ProcessLine(Form("%s* %s = (%s*)0x%lx;", cname, var_name, cname, (ULong_t)obj));
2155 }
2156 
2157 ////////////////////////////////////////////////////////////////////////////////
2158 /// Destructor.
2159 
2161 {
2162  if (fOwnObject)
2163  delete fObject;
2164 }
2165 
2166 /** \class TEveElementList
2167 \ingroup TEve
2168 A list of TEveElements.
2169 
2170 Class of acceptable children can be limited by setting the
2171 fChildClass member.
2172 
2173 !!! should have two ctors (like in TEveElement), one with Color_t&
2174 and set fDoColor automatically, based on which ctor is called.
2175 */
2176 
2178 
2179 ////////////////////////////////////////////////////////////////////////////////
2180 /// Constructor.
2181 
2182 TEveElementList::TEveElementList(const char* n, const char* t, Bool_t doColor, Bool_t doTransparency) :
2183  TEveElement(),
2184  TNamed(n, t),
2185  TEveProjectable(),
2186  fColor(0),
2187  fChildClass(0)
2188 {
2189  if (doColor) {
2192  }
2193  if (doTransparency)
2194  {
2196  }
2197 }
2198 
2199 ////////////////////////////////////////////////////////////////////////////////
2200 /// Copy constructor.
2201 
2203  TEveElement (e),
2204  TNamed (e),
2205  TEveProjectable(),
2206  fColor (e.fColor),
2208 {
2209 }
2210 
2211 ////////////////////////////////////////////////////////////////////////////////
2212 /// Clone the element via copy constructor.
2213 /// Virtual from TEveElement.
2214 
2216 {
2217  return new TEveElementList(*this);
2218 }
2219 
2220 ////////////////////////////////////////////////////////////////////////////////
2221 /// Check if TEveElement el is inherited from fChildClass.
2222 /// Virtual from TEveElement.
2223 
2225 {
2226  if (fChildClass && ! el->IsA()->InheritsFrom(fChildClass))
2227  return kFALSE;
2228  return kTRUE;
2229 }
2230 
2231 ////////////////////////////////////////////////////////////////////////////////
2232 /// Virtual from TEveProjectable, returns TEveCompoundProjected class.
2233 
2235 {
2237 }
2238 
2239 /** \class TEveElementListProjected
2240 \ingroup TEve
2241 A projected element list -- required for proper propagation
2242 of render state to projected views.
2243 */
2244 
2246 
2247 ////////////////////////////////////////////////////////////////////////////////
2248 /// Constructor.
2249 
2251  TEveElementList("TEveElementListProjected")
2252 {
2253 }
2254 
2255 ////////////////////////////////////////////////////////////////////////////////
2256 /// This is abstract method from base-class TEveProjected.
2257 /// No implementation.
2258 
2260 {
2261 }
void ElementStamped(TEveElement *element)
Mark element as changed – it will be processed on next redraw.
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition: TEveTrans.h:26
virtual void AnnihilateProjecteds()
Optimized destroy of projected elements with condition there is only one parent for projected element...
Abstract base class for classes that hold results of a non-linear projection transformation.
virtual void SetElementName(const char *name)
Virtual function for setting of name of an element.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
std::string GetName(const std::string &scope_name)
Definition: Cppyy.cxx:140
void DecDenyDestroy()
Decreases the deny-destroy count of the element.
virtual void PadPaint(Option_t *option)
Paint self and/or children into currently active pad.
sLTI_t::iterator sLTI_i
Definition: TEveElement.h:66
List_i EndChildren()
Definition: TEveElement.h:165
TEveProjectable * GetProjectable() const
void SetVizModel(TEveElement *model)
Set visualization-parameter model element.
virtual Bool_t SingleRnrState() const
Definition: TEveElement.h:253
TRef fSource
Set of list-tree-items.
Definition: TEveElement.h:102
void DisableListElements(Bool_t rnr_self=kFALSE, Bool_t rnr_children=kFALSE)
Disable rendering of children and their list contents.
virtual void SelectElement(Bool_t state)
Set element&#39;s selection state. Stamp appropriately.
Int_t fDenyDestroy
Counter for top-level list-tree items that prevent automatic destruction.
Definition: TEveElement.h:87
TEveElement * fVizModel
Definition: TEveElement.h:81
virtual void * GetUserData() const =0
virtual void AddParent(TEveElement *re)
Add re into the list parents.
void * fUserData
Definition: TEveElement.h:103
Bool_t fCanEditMainTrans
Definition: TEveElement.h:94
virtual sLTI_i FindItem(TGListTree *ltree)
Find any list-tree-item of this element in list-tree &#39;ltree&#39;.
virtual TEveElementObjectPtr * CloneElement() const
Clone the element via copy constructor.
Int_t DeleteItem(TGListTreeItem *item)
Delete item from list tree.
TEveElement * FirstChild() const
Returns the first child element or 0 if the list is empty.
static const TGPicture * fgRnrIcons[4]
Definition: TEveElement.h:62
Bool_t MatchB(const TString &s, const TString &mods="", Int_t start=0, Int_t nMaxMatch=10)
Definition: TPRegexp.h:84
virtual Char_t GetMainTransparency() const
Definition: TEveElement.h:279
virtual void CollectSceneParentsFromChildren(List_t &scenes, TEveElement *parent)
Collect scene-parents from all children.
Char_t fMainTransparency
Definition: TEveElement.h:96
void EditElement(TEveElement *element)
Show element in default editor.
float Float_t
Definition: RtypesCore.h:53
virtual Bool_t HasMainTrans() const
Definition: TEveElement.h:285
TClass * fChildClass
Definition: TEveElement.h:468
Int_t GetParentIgnoreCnt() const
Get number of parents that should be ignored in doing reference-counting.
virtual void AddStamp(UChar_t bits)
Add (bitwise or) given stamps to fChangeBits.
return c
std::set< TEveElement * > Set_t
Definition: TEveElement.h:73
const char Option_t
Definition: RtypesCore.h:62
Geometrical transformation package.
Definition: TGeoMatrix.h:40
virtual void DestroyMainTrans()
Destroy the main transformation matrix, it will always be taken as identity.
Int_t fParentIgnoreCnt
Definition: TEveElement.h:85
virtual Bool_t AcceptElement(TEveElement *el)
Check if TEveElement el is inherited from fChildClass.
void VizDB_Apply(const char *tag)
Set visual parameters for this object for given tag.
List_t fChildren
Definition: TEveElement.h:79
Bool_t fPickable
Definition: TEveElement.h:310
virtual void RemoveParent(TEveElement *re)
Remove re from the list of parents.
virtual void NameTitleChanged()
Virtual function called when a name or title of the element has been changed.
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:131
virtual Int_t SubImportChildren(TEveElement *el, TEveElement *proj_parent)
Recursively import children elements of el and apply projection to the newly imported objects...
Bool_t HasChildren() const
Definition: TEveElement.h:169
void ExportSourceObjectToCINT(char *var_name) const
Export source object to CINT with given name for the variable.
Bool_t fCanEditMainColor
Definition: TEveElement.h:92
Bool_t fRnrChildren
Definition: TEveElement.h:91
virtual void RemoveElementLocal(TEveElement *el)
Perform additional local removal of el.
static const TGPicture * fgListTreeIcons[9]
Definition: TEveElement.h:63
Int_t fTopItemCnt
Counter for parents that are ignored in ref-counting.
Definition: TEveElement.h:86
List_t::iterator List_i
Definition: TEveElement.h:70
Bool_t fRnrSelf
Definition: TEveElement.h:90
void IncDenyDestroy()
Increases the deny-destroy count of the element.
virtual void PropagateMainColorToProjecteds(Color_t color, Color_t old_color)
Propagate color to projected elements.
#define gROOT
Definition: TROOT.h:364
virtual Bool_t SetRnrState(Bool_t rnr)
Set render state of this element and of its children to the same value.
virtual void ProjectAllChildren(Bool_t same_depth=kTRUE)
If this is a projectable, loop over all projected replicas and add the projected image of all childre...
virtual void PropagateMainTransparency(Char_t t, Char_t old_t)
Set main transparency of projecteds if their transparency is the same as the old one.
virtual TEveElementList * CloneElement() const
Clone the element via copy constructor.
virtual void PaintStandard(TObject *id)
Paint object – a generic implementation for EVE elements.
virtual void CopyVizParams(const TEveElement *el)
Copy visualization parameters from element el.
Basic string class.
Definition: TString.h:137
Int_t NumParents() const
Definition: TEveElement.h:160
virtual void CollectSceneParents(List_t &scenes)
Collect all parents of class TEveScene.
virtual void Destroy()
Destroy this element.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TEveElement * FindVizDBEntry(const TString &tag)
Find a visualization-parameter database entry corresponding to tag.
const Bool_t kFALSE
Definition: Rtypes.h:92
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
Definition: TObject.cxx:595
const char * Class
Definition: TXMLSetup.cxx:64
Bool_t GetDestroyOnZeroRefCnt() const
Returns state of flag determining if the element will be destroyed when reference count reaches zero...
virtual TEveElement * CloneElementRecurse(Int_t level=0) const
Clone elements and recurse &#39;level&#39; deep over children.
virtual Bool_t GetRnrSelf() const
Definition: TEveElement.h:254
sLTI_t fItems
Definition: TEveElement.h:100
void DecParentIgnoreCnt()
Decrease number of parents ignored in reference-counting.
Bool_t FindVizModel()
Find model element in VizDB that corresponds to previously assigned fVizTag and set fVizModel accordi...
virtual Bool_t HasProjecteds() const
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition: TNamed.cxx:145
static const char * ToString(Bool_t b)
Convert Bool_t to string - kTRUE or kFALSE.
TEveElementList(const char *n="TEveElementList", const char *t="", Bool_t doColor=kFALSE, Bool_t doTransparency=kFALSE)
Constructor.
virtual void PropagateVizParamsToProjecteds()
Propagate visualization parameters to dependent elements.
virtual void RemoveElementsLocal()
Perform additional local removal of all elements.
TEveElement()
Default constructor.
Definition: TEveElement.cxx:61
void SetMainColorPtr(Color_t *color)
Definition: TEveElement.h:267
A list of TEveElements.
Definition: TEveElement.h:459
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
Bool_t TestCSCBits(UChar_t f) const
Definition: TEveElement.h:364
List_t fParents
Definition: TEveElement.h:78
void RecheckImpliedSelections()
Call this if it is possible that implied-selection or highlight has changed for this element or for i...
virtual void RemoveElement(TEveElement *el)
Remove el from the list of children.
virtual TObject * GetRenderObject(const TEveException &eh) const
Definition: TEveElement.h:198
void IncParentIgnoreCnt()
Increase number of parents ignored in reference-counting.
Color_t * fMainColorPtr
Definition: TEveElement.h:97
TEveElement * LastChild() const
Returns the last child element or 0 if the list is empty.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:188
Bool_t fDestroyOnZeroRefCnt
Deny-destroy count.
Definition: TEveElement.h:88
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2335
virtual void ElementChanged(Bool_t update_scenes=kTRUE, Bool_t redraw=kFALSE)
Call this after an element has been changed so that the state can be propagated around the framework...
ULong_t Pixel_t
Definition: GuiTypes.h:41
Bool_t fCanEditMainTransparency
Definition: TEveElement.h:93
sLTI_t::reverse_iterator sLTI_ri
Definition: TEveElement.h:67
virtual void Annihilate()
Optimized destruction without check of reference-count.
void StampVisibility()
Definition: TEveElement.h:398
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
void VizDB_Reapply()
Reset visual parameters for this object from VizDB.
TEveCompound * fCompound
Definition: TEveElement.h:80
void SetVizTag(const TString &tag)
Definition: TEveElement.h:130
virtual void DestroyListSubTree(TGListTree *ltree, TGListTreeItem *parent)
Destroy sub-tree under item &#39;parent&#39; in list-tree &#39;ltree&#39;.
TEveElementListProjected()
Constructor.
Int_t FindChildren(List_t &matches, const TString &name, const TClass *cls=0)
Find all children with given name and append them to matches list.
void Info(const char *location, const char *msgfmt,...)
const std::string ClassName(PyObject *pyobj)
Retrieve the class name from the given python object (which may be just an instance of the class)...
Definition: Utility.cxx:702
void VizDB_Insert(const char *tag, Bool_t replace=kTRUE, Bool_t update=kTRUE)
Create a replica of element and insert it into VizDB with given tag.
virtual void SetElementTitle(const char *title)
Virtual function for setting of title of an element.
Base-class for non-linear projections.
XFontStruct * id
Definition: TGX11.cxx:108
Short_t fImpliedSelected
Definition: TEveElement.h:313
virtual void PropagateRenderState(Bool_t rnr_self, Bool_t rnr_children)
Set render state of projecteds.
virtual void ExpandIntoListTree(TGListTree *ltree, TGListTreeItem *parent)
Populates parent with elements.
void SaveVizParams(std::ostream &out, const TString &tag, const TString &var)
Save visualization parameters for this element with given tag.
Bool_t HasChild(TEveElement *el)
Check if element el is a child of this element.
virtual void DestroyElements()
Destroy all children of this element.
void Error(const char *location, const char *msgfmt,...)
Manager class for steering of projections and managing projected objects.
void SetSectionsValid(UInt_t mask)
Definition: TBuffer3D.h:67
short Color_t
Definition: RtypesCore.h:79
void SetFrom(Double_t *carr)
Definition: TEveTrans.cxx:981
void DumpSourceObject() const
Call Dump() on source object.
UChar_t fChangeBits
Definition: TEveElement.h:391
virtual ~TEveElement()
Destructor.
Abstract base-class for non-linear projectable objects.
void ElementChanged(TEveElement *element, Bool_t update_scenes=kTRUE, Bool_t redraw=kFALSE)
Element was changed, perform framework side action.
TEveElementList * GetOrphanage() const
Definition: TEveManager.h:132
virtual void InitMainTrans(Bool_t can_edit=kTRUE)
Initialize the main transformation to identity matrix.
virtual Color_t GetMainColor() const
Definition: TEveElement.h:270
void SetPickableRecursively(Bool_t p)
Set pickable state on the element and all its children.
virtual TGListTreeItem * AddIntoListTrees(TEveElement *parent)
Add this render element into all list-trees and all items belonging to parent.
virtual void PreDeleteElement()
Externally assigned and controlled user data.
List_t::const_iterator List_ci
Definition: TEveElement.h:71
virtual void CheckReferenceCount(const TEveException &eh="TEveElement::CheckReferenceCount ")
Check external references to this and eventually auto-destruct the render-element.
TEveElement * GetMaster()
Returns the master element - that is:
TRandom2 r(17)
virtual TGListTreeItem * AddIntoListTree(TGListTree *ltree, TGListTreeItem *parent_lti)
Add this element into ltree to an already existing item parent_lti.
virtual TObject * GetObject(const TEveException &eh="TEveElementObjectPtr::GetObject ") const
Return external object.
TGListTreeItem * GetNextSibling() const
Definition: TGListTree.h:83
TEveTrans * fMainTrans
Definition: TEveElement.h:98
virtual ~TEveElementObjectPtr()
Destructor.
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
virtual void SetElementNameTitle(const char *name, const char *title)
Virtual function for setting of name and title of render element.
virtual void DecImpliedHighlighted()
Decrease element&#39;s implied-highlight count. Stamp appropriately.
Char_t fDestructing
Definition: TEveElement.h:392
virtual void PropagateMainTransparencyToProjecteds(Char_t t, Char_t old_t)
Propagate transparency to projected elements.
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
virtual void DecImpliedSelected()
Decrease element&#39;s implied-selection count. Stamp appropriately.
virtual const TGPicture * GetListTreeCheckBoxIcon()
Returns list-tree-item check-box picture appropriate for given rendering state.
void SetMainColorRGB(UChar_t r, UChar_t g, UChar_t b)
Convert RGB values to Color_t and call SetMainColor.
std::list< TEveProjected * >::iterator ProjList_i
virtual void CloneChildrenRecurse(TEveElement *dest, Int_t level=0) const
Clone children and attach them to the dest element.
void SetMainAlpha(Float_t alpha)
Set main-transparency via float alpha variable.
virtual Bool_t GetRnrChildren() const
Definition: TEveElement.h:255
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
virtual void AnnihilateRecursively()
Protected member function called from TEveElement::Annihilate().
virtual void IncImpliedSelected()
Increase element&#39;s implied-selection count. Stamp appropriately.
virtual void ClearProjectedList()
Bool_t fHighlighted
Definition: TEveElement.h:312
void SetBuffer3D(TBuffer3D &buff)
Fill transformation part TBuffer3D core section.
Definition: TEveTrans.cxx:1049
virtual void FillImpliedSelectedSet(Set_t &impSelSet)
Populate set impSelSet with derived / dependant elements.
virtual void IncImpliedHighlighted()
Increase element&#39;s implied-highlight count. Stamp appropriately.
virtual void ExportToCINT(char *var_name)
Export render-element to CINT with variable name var_name.
char * Form(const char *fmt,...)
const Handle_t kNone
Definition: GuiTypes.h:89
TEveElement with external TObject as a holder of visualization data.
Definition: TEveElement.h:428
virtual Bool_t SetRnrSelf(Bool_t rnr)
Set render state of this element, i.e.
void PrintSourceObject() const
Call Print() on source object.
Generic 3D primitive description class.
Definition: TBuffer3D.h:19
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb"...
Definition: TColor.cxx:1706
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
Definition: TClass.cxx:4610
virtual void AddElement(TEveElement *el)
Add el to the list of children.
TObject * fID
Definition: TBuffer3D.h:89
void Warning(const char *location, const char *msgfmt,...)
virtual void SetMainColor(Color_t color)
Set main color of the element.
void StampColorSelection()
Definition: TEveElement.h:395
virtual const char * GetElementName() const
Virtual function for retrieving name of the element.
TEveSelection * GetHighlight() const
Definition: TEveManager.h:130
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition: TGCanvas.cxx:888
virtual Int_t RemoveFromListTrees(TEveElement *parent)
Remove element from all list-trees where &#39;parent&#39; is the user-data of the parent list-tree-item.
virtual void SetMainTransparency(Char_t t)
Set main-transparency.
virtual Bool_t RemoveFromListTree(TGListTree *ltree, TGListTreeItem *parent_lti)
Remove element from list-tree &#39;ltree&#39; where its parent item is &#39;parent_lti&#39;.
virtual TEveElement * ForwardEdit()
Returns element to be displayed in GUI editor on click.
Int_t fNumChildren
Definition: TEveElement.h:84
Bool_t fSelected
Definition: TEveElement.h:311
TGListTreeItem * GetParent() const
Definition: TGListTree.h:79
void SetCurrentDepth(Float_t d)
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
Definition: TObject.cxx:564
std::list< TEveElement * > List_t
Definition: TEveElement.h:69
virtual void DestroyOrWarn()
Destroy this element. Prints a warning if deny-destroy is in force.
#define ClassImp(name)
Definition: Rtypes.h:279
double f(double x)
void EnableListElements(Bool_t rnr_self=kTRUE, Bool_t rnr_children=kTRUE)
Enable rendering of children and their list contents.
virtual void RemoveElementsInternal()
Remove all elements.
virtual const char * GetElementTitle() const
Virtual function for retrieving title of the render-element.
double Double_t
Definition: RtypesCore.h:55
Color_t * GetMainColorPtr() const
Definition: TEveElement.h:266
virtual void ExportToCINT(char *var_name)
Export external object to CINT with variable name var_name.
A projected element list – required for proper propagation of render state to projected views...
Definition: TEveElement.h:508
TGListTreeItem * GetFirstChild() const
Definition: TGListTree.h:80
virtual TEveElement * CloneElement() const
Clone the element via copy constructor.
virtual void Dump() const
Dump contents of object on stdout.
Definition: TObject.cxx:325
unsigned long ULong_t
Definition: RtypesCore.h:51
Int_t fColor
Definition: TBuffer3D.h:90
virtual Bool_t SetRnrChildren(Bool_t rnr)
Set render state of this element&#39;s children, i.e.
TEveSelection * GetSelection() const
Definition: TEveManager.h:129
virtual void HighlightElement(Bool_t state)
Set element&#39;s highlight state. Stamp appropriately.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition: TString.cxx:386
virtual void UnHighlighted()
Virtual function called when both fHighlighted is false and fImpliedHighlighted is 0...
virtual TObject * GetObject(const TEveException &eh) const
Get a TObject associated with this render-element.
const TGWindow * GetParent() const
Definition: TGWindow.h:87
virtual const TGPicture * GetListTreeIcon(Bool_t open=kFALSE)
Returns pointer to first listtreeicon.
Short_t fImpliedHighlighted
Definition: TEveElement.h:314
void SpawnEditor()
Show GUI editor for this object.
Bool_t IsNull() const
Definition: TString.h:387
virtual void CopyVizParamsFromDB()
Copy visualization parameters from the model-element fVizModel.
Mother of all ROOT objects.
Definition: TObject.h:37
Structure holding information about TGListTree and TGListTreeItem that represents given TEveElement...
Definition: TEveElement.h:40
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TObject.cxx:204
virtual void PropagateVizParams(TEveElement *el=0)
Set visualization parameters of projecteds.
char Char_t
Definition: RtypesCore.h:29
virtual void AddProjectedsToSet(std::set< TEveElement *> &set)
Add the projected elements to the set, dyn-casting them to TEveElement.
ProjList_i BeginProjecteds()
TEveElementObjectPtr(TObject *obj, Bool_t own=kTRUE)
Constructor.
virtual void RemoveElements()
Remove all elements.
Special list-tree-item for Eve.
Definition: TEveBrowser.h:28
virtual Bool_t AcceptElement(TEveElement *el)
Check if el can be added to this element.
TObject * GetSourceObject() const
Definition: TEveElement.h:295
#define dest(otri, vertexptr)
Definition: triangle.c:1040
Bool_t ApplyVizTag(const TString &tag, const TString &fallback_tag="")
Set the VizTag, find model-element from the VizDB and copy visualization-parameters from it...
virtual void PropagateVizParamsToElements(TEveElement *el=0)
Propagate visualization parameters from element el (defaulting to this) to all elements (children)...
virtual void WriteVizParams(std::ostream &out, const TString &var)
Write-out visual parameters for this object.
void SetMainColorPixel(Pixel_t pixel)
Convert pixel to Color_t and call SetMainColor().
List_i BeginChildren()
Definition: TEveElement.h:164
virtual TEveTrans & RefMainTrans()
Return reference to main transformation.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
Bool_t GetUseOrphanage() const
Definition: TEveManager.h:133
virtual Bool_t SetRnrSelfChildren(Bool_t rnr_self, Bool_t rnr_children)
Set state for rendering of this element and its children.
virtual TClass * ProjectedClass(const TEveProjection *p) const
Virtual from TEveProjectable, returns TEveCompoundProjected class.
#define gPad
Definition: TVirtualPad.h:289
Exception class thrown by TEve classes and macros.
Definition: TEveUtil.h:102
R__EXTERN Int_t gDebug
Definition: Rtypes.h:128
virtual TGListTreeItem * FindListTreeItem(TGListTree *ltree)
Find any list-tree-item of this element in list-tree &#39;ltree&#39;.
Short_t fTransparency
Definition: TBuffer3D.h:91
void VizDB_UpdateModel(Bool_t update=kTRUE)
Copy visual parameters from this element to viz-db model.
void SetDestroyOnZeroRefCnt(Bool_t d)
Sets the state of flag determining if the element will be destroyed when reference count reaches zero...
Bool_t InsertVizDBEntry(const TString &tag, TEveElement *model, Bool_t replace, Bool_t update)
Insert a new visualization-parameter database entry.
virtual void PropagateMainColor(Color_t color, Color_t old_color)
Set main color of projecteds if their color is the same as old_color.
virtual void PropagateRnrStateToProjecteds()
Propagate render state to the projected replicas of this element.
unsigned char UChar_t
Definition: RtypesCore.h:34
virtual void AnnihilateElements()
Annihilate elements.
void RecheckImpliedSetForElement(TEveElement *el)
If given element is selected or implied-selected with this selection and recheck implied-set for give...
virtual TEveTrans * PtrMainTrans(Bool_t create=kTRUE)
Return pointer to main transformation.
TEveElement * FindChild(const TString &name, const TClass *cls=0)
Find the first child with given name.
Int_t GetDenyDestroy() const
Returns the number of times deny-destroy has been requested on the element.
virtual TEveElement * SubImportElements(TEveElement *el, TEveElement *proj_parent)
Recursively import elements and apply projection to the newly imported objects.
virtual void UnSelected()
Virtual function called when both fSelected is false and fImpliedSelected is 0.
void PreDeleteElement(TEveElement *element)
Called from TEveElement prior to its destruction so the framework components (like object editor) can...
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:416
virtual TEveElement * ForwardSelection()
Returns element to be selected on click.
virtual UChar_t GetSelectedLevel() const
Get selection level, needed for rendering selection and highlight feedback.
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
Float_t GetCurrentDepth() const
virtual void ProjectChild(TEveElement *el, Bool_t same_depth=kTRUE)
If this is a projectable, loop over all projected replicas and add the projected image of child &#39;el&#39; ...
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:33
const Int_t n
Definition: legend1.C:16
TString fVizTag
Element used as model from VizDB.
Definition: TEveElement.h:82
char name[80]
Definition: TGX11.cxx:109
virtual void SetTransMatrix(Double_t *carr)
Set transformation matrix from column-major array.
void UnitTrans()
Reset matrix to unity.
Definition: TEveTrans.cxx:130
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
virtual void UpdateProjection()
This is abstract method from base-class TEveProjected.
UChar_t fCSCBits
Definition: TEveElement.h:333
virtual Bool_t HandleElementPaste(TEveElement *el)
React to element being pasted or dnd-ed.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition: TClass.cxx:4714
const char * Data() const
Definition: TString.h:349
ProjList_i EndProjecteds()