00001 // @(#)root/eve:$Id: TEveCompound.cxx 33864 2010-06-14 09:47:19Z matevz $ 00002 // Author: Matevz Tadel 2007 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 #include "TEveCompound.h" 00013 00014 //============================================================================== 00015 //============================================================================== 00016 // TEveCompound 00017 //============================================================================== 00018 00019 //______________________________________________________________________________ 00020 // 00021 // Description of TEveCompound 00022 // 00023 00024 ClassImp(TEveCompound); 00025 00026 //______________________________________________________________________________ 00027 TEveCompound::TEveCompound(const char* n, const char* t, Bool_t doColor, Bool_t doTransparency) : 00028 TEveElementList (n, t, doColor, doTransparency), 00029 fCompoundOpen (0) 00030 { 00031 // Constructor. 00032 } 00033 00034 //______________________________________________________________________________ 00035 void TEveCompound::SetMainColor(Color_t color) 00036 { 00037 // SetMainColor for the compound. 00038 // The color is also propagated to children with compound set to this 00039 // whose current color is the same as the old color. 00040 // 00041 // The following CompoundSelectionColorBits have further influence: 00042 // kCSCBApplyMainColorToAllChildren - apply color to all children; 00043 // kCSCBApplyMainColorToMatchingChildren - apply color to children who have 00044 // matching old color. 00045 00046 Color_t old_color = GetMainColor(); 00047 00048 TEveElement::SetMainColor(color); 00049 00050 Bool_t color_all = TestCSCBits(kCSCBApplyMainColorToAllChildren); 00051 Bool_t color_matching = TestCSCBits(kCSCBApplyMainColorToMatchingChildren); 00052 00053 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) 00054 { 00055 if (color_all || (color_matching && (*i)->GetMainColor() == old_color) || 00056 ((*i)->GetCompound() == this && (*i)->GetMainColor() == old_color)) 00057 { 00058 (*i)->SetMainColor(color); 00059 } 00060 } 00061 } 00062 00063 //______________________________________________________________________________ 00064 void TEveCompound::SetMainTransparency(Char_t t) 00065 { 00066 // SetMainTransparency for the compound. 00067 // The transparenct is also propagated to children with compound set to this 00068 // whose current transparency is the same as the old transparency. 00069 // 00070 // The following CompoundSelectionColorBits have further influence: 00071 // kCSCBApplyMainTransparencyToAllChildren - apply transparency to all children; 00072 // kCSCBApplyMainTransparencyToMatchingChildren - apply transparency to children who have 00073 // matching transparency. 00074 00075 Char_t old_t = GetMainTransparency(); 00076 00077 TEveElement::SetMainTransparency(t); 00078 00079 Bool_t chg_all = TestCSCBits(kCSCBApplyMainTransparencyToAllChildren); 00080 Bool_t chg_matching = TestCSCBits(kCSCBApplyMainTransparencyToMatchingChildren); 00081 00082 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) 00083 { 00084 if (chg_all || (chg_matching && (*i)->GetMainTransparency() == old_t) || 00085 ((*i)->GetCompound() == this && (*i)->GetMainTransparency() == old_t)) 00086 { 00087 (*i)->SetMainTransparency(t); 00088 } 00089 } 00090 } 00091 00092 //****************************************************************************** 00093 00094 //______________________________________________________________________________ 00095 void TEveCompound::AddElement(TEveElement* el) 00096 { 00097 // Call base-class implementation. 00098 // If compund is open and compound of the new element is not set, 00099 // the el's compound is set to this. 00100 // You might also want to call RecheckImpliedSelections(). 00101 00102 TEveElementList::AddElement(el); 00103 if (IsCompoundOpen() && el->GetCompound() == 0) 00104 el->SetCompound(this); 00105 } 00106 00107 //______________________________________________________________________________ 00108 void TEveCompound::RemoveElementLocal(TEveElement* el) 00109 { 00110 // Decompoundofy el, call base-class version. 00111 00112 if (el->GetCompound() == this) 00113 el->SetCompound(0); 00114 00115 TEveElementList::RemoveElementLocal(el); 00116 } 00117 00118 //______________________________________________________________________________ 00119 void TEveCompound::RemoveElementsLocal() 00120 { 00121 // Decompoundofy children, call base-class version. 00122 00123 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) 00124 { 00125 if ((*i)->GetCompound() == this) 00126 (*i)->SetCompound(0); 00127 } 00128 00129 TEveElementList::RemoveElementsLocal(); 00130 } 00131 00132 //****************************************************************************** 00133 00134 //______________________________________________________________________________ 00135 void TEveCompound::FillImpliedSelectedSet(Set_t& impSelSet) 00136 { 00137 // Recurse on all children that are in this compund and 00138 // call the base-class version. 00139 // If SelectionColorBit kSCBImplySelectAllChildren is set, then all 00140 // children are added to the set. 00141 // 00142 // Note that projected replicas of the compound will be added to 00143 // the set in base-class function that handles projectables. 00144 00145 Bool_t select_all = TestCSCBits(kCSCBImplySelectAllChildren); 00146 00147 for (List_i i = fChildren.begin(); i != fChildren.end(); ++i) 00148 { 00149 if (select_all || (*i)->GetCompound() == this) 00150 { 00151 if (impSelSet.insert(*i).second) 00152 (*i)->FillImpliedSelectedSet(impSelSet); 00153 } 00154 } 00155 00156 TEveElementList::FillImpliedSelectedSet(impSelSet); 00157 } 00158 00159 //****************************************************************************** 00160 00161 //______________________________________________________________________________ 00162 TClass* TEveCompound::ProjectedClass(const TEveProjection*) const 00163 { 00164 // Virtual from TEveProjectable, returns TEveCompoundProjected class. 00165 00166 return TEveCompoundProjected::Class(); 00167 } 00168 00169 00170 //============================================================================== 00171 //============================================================================== 00172 // TEveCompoundProjected 00173 //============================================================================== 00174 00175 //______________________________________________________________________________ 00176 // 00177 // Description of TEveCompoundProjected 00178 // 00179 00180 ClassImp(TEveCompoundProjected); 00181 00182 //______________________________________________________________________________ 00183 TEveCompoundProjected::TEveCompoundProjected() : 00184 TEveCompound (), 00185 TEveProjected () 00186 { 00187 // Constructor. 00188 } 00189 00190 //______________________________________________________________________________ 00191 void TEveCompoundProjected::SetMainColor(Color_t color) 00192 { 00193 // Revert back to the behaviour of TEveElement as color 00194 // is propagated: 00195 // a) from projectable -> projected 00196 // b) from compound -> compound elements 00197 // and we do not need to do this twice for projected-compound-elements. 00198 00199 TEveElement::SetMainColor(color); 00200 }