TEveElement.cxx

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

Generated on Tue Jul 5 14:16:11 2011 for ROOT_528-00b_version by  doxygen 1.5.1