00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TEveElement
00013 #define ROOT_TEveElement
00014
00015 #include "TEveUtil.h"
00016 #include "TEveProjectionBases.h"
00017
00018 #include "TNamed.h"
00019 #include "TRef.h"
00020
00021 class TGListTree;
00022 class TGListTreeItem;
00023 class TGPicture;
00024
00025 class TEveCompound;
00026 class TEveTrans;
00027 class TGeoMatrix;
00028
00029
00030
00031
00032
00033 class TEveElement
00034 {
00035 friend class TEveManager;
00036
00037 TEveElement& operator=(const TEveElement&);
00038
00039 public:
00040 class TEveListTreeInfo
00041 {
00042 public:
00043 TGListTree* fTree;
00044 TGListTreeItem* fItem;
00045
00046 TEveListTreeInfo() : fTree(0), fItem(0) {}
00047 TEveListTreeInfo(TGListTree* lt, TGListTreeItem* lti) : fTree(lt), fItem(lti) {}
00048 TEveListTreeInfo(const TEveListTreeInfo& l) : fTree(l.fTree), fItem(l.fItem) {}
00049 virtual ~TEveListTreeInfo() {}
00050
00051 TEveListTreeInfo& operator=(const TEveListTreeInfo& l)
00052 { fTree = l.fTree; fItem = l.fItem; return *this; }
00053
00054 bool operator==(const TEveListTreeInfo& x) const
00055 { return fTree == x.fTree && fItem == x.fItem; }
00056 bool operator<(const TEveListTreeInfo& x) const
00057 { return fTree == x.fTree ? fItem < x.fItem : fTree < x.fTree; }
00058
00059 ClassDef(TEveListTreeInfo, 0);
00060 };
00061
00062 static const TGPicture* fgRnrIcons[4];
00063 static const TGPicture* fgListTreeIcons[9];
00064
00065 typedef std::set<TEveListTreeInfo> sLTI_t;
00066 typedef sLTI_t::iterator sLTI_i;
00067 typedef sLTI_t::reverse_iterator sLTI_ri;
00068
00069 typedef std::list<TEveElement*> List_t;
00070 typedef List_t::iterator List_i;
00071 typedef List_t::const_iterator List_ci;
00072
00073 typedef std::set<TEveElement*> Set_t;
00074 typedef Set_t::iterator Set_i;
00075 typedef Set_t::const_iterator Set_ci;
00076
00077 protected:
00078 List_t fParents;
00079 List_t fChildren;
00080 TEveCompound *fCompound;
00081 TEveElement *fVizModel;
00082 TString fVizTag;
00083
00084 Int_t fNumChildren;
00085 Int_t fParentIgnoreCnt;
00086 Int_t fTopItemCnt;
00087 Int_t fDenyDestroy;
00088 Bool_t fDestroyOnZeroRefCnt;
00089
00090 Bool_t fRnrSelf;
00091 Bool_t fRnrChildren;
00092 Bool_t fCanEditMainColor;
00093 Bool_t fCanEditMainTransparency;
00094 Bool_t fCanEditMainTrans;
00095
00096 Char_t fMainTransparency;
00097 Color_t *fMainColorPtr;
00098 TEveTrans *fMainTrans;
00099
00100 sLTI_t fItems;
00101
00102 TRef fSource;
00103 void *fUserData;
00104
00105 virtual void PreDeleteElement();
00106 virtual void RemoveElementsInternal();
00107 virtual void AnnihilateRecursively();
00108
00109 static const char* ToString(Bool_t b);
00110
00111 public:
00112 TEveElement();
00113 TEveElement(Color_t& main_color);
00114 TEveElement(const TEveElement& e);
00115 virtual ~TEveElement();
00116
00117 virtual TEveElement* CloneElement() const;
00118 virtual TEveElement* CloneElementRecurse(Int_t level=0) const;
00119 virtual void CloneChildrenRecurse(TEveElement* dest, Int_t level=0) const;
00120
00121 virtual const char* GetElementName() const;
00122 virtual const char* GetElementTitle() const;
00123 virtual TString GetHighlightTooltip() { return TString(GetElementTitle()); }
00124 virtual void SetElementName (const char* name);
00125 virtual void SetElementTitle(const char* title);
00126 virtual void SetElementNameTitle(const char* name, const char* title);
00127 virtual void NameTitleChanged();
00128
00129 const TString& GetVizTag() const { return fVizTag; }
00130 void SetVizTag(const TString& tag) { fVizTag = tag; }
00131
00132 TEveElement* GetVizModel() const { return fVizModel; }
00133 void SetVizModel(TEveElement* model);
00134 Bool_t FindVizModel();
00135
00136 Bool_t ApplyVizTag(const TString& tag, const TString& fallback_tag="");
00137
00138 virtual void PropagateVizParamsToProjecteds();
00139 virtual void PropagateVizParamsToElements(TEveElement* el=0);
00140 virtual void CopyVizParams(const TEveElement* el);
00141 virtual void CopyVizParamsFromDB();
00142 void SaveVizParams (ostream& out, const TString& tag, const TString& var);
00143 virtual void WriteVizParams(ostream& out, const TString& var);
00144
00145 TEveElement* GetMaster();
00146 TEveCompound* GetCompound() { return fCompound; }
00147 void SetCompound(TEveCompound* c) { fCompound = c; }
00148
00149 virtual void AddParent(TEveElement* re);
00150 virtual void RemoveParent(TEveElement* re);
00151 virtual void CheckReferenceCount(const TEveException& eh="TEveElement::CheckReferenceCount ");
00152 virtual void CollectSceneParents(List_t& scenes);
00153 virtual void CollectSceneParentsFromChildren(List_t& scenes,
00154 TEveElement* parent);
00155
00156 List_i BeginParents() { return fParents.begin(); }
00157 List_i EndParents() { return fParents.end(); }
00158 List_ci BeginParents() const { return fParents.begin(); }
00159 List_ci EndParents() const { return fParents.end(); }
00160 Int_t NumParents() const { return fParents.size(); }
00161 Bool_t HasParents() const { return !fParents.empty(); }
00162
00163 const List_t& RefChildren() const { return fChildren; }
00164 List_i BeginChildren() { return fChildren.begin(); }
00165 List_i EndChildren() { return fChildren.end(); }
00166 List_ci BeginChildren() const { return fChildren.begin(); }
00167 List_ci EndChildren() const { return fChildren.end(); }
00168 Int_t NumChildren() const { return fNumChildren; }
00169 Bool_t HasChildren() const { return fNumChildren != 0; }
00170
00171 Bool_t HasChild(TEveElement* el);
00172 TEveElement* FindChild(const TString& name, const TClass* cls=0);
00173 TEveElement* FindChild(TPRegexp& regexp, const TClass* cls=0);
00174 Int_t FindChildren(List_t& matches, const TString& name, const TClass* cls=0);
00175 Int_t FindChildren(List_t& matches, TPRegexp& regexp, const TClass* cls=0);
00176 TEveElement* FirstChild() const;
00177 TEveElement* LastChild () const;
00178
00179 void EnableListElements (Bool_t rnr_self=kTRUE, Bool_t rnr_children=kTRUE);
00180 void DisableListElements(Bool_t rnr_self=kFALSE, Bool_t rnr_children=kFALSE);
00181
00182 Bool_t GetDestroyOnZeroRefCnt() const;
00183 void SetDestroyOnZeroRefCnt(Bool_t d);
00184
00185 Int_t GetDenyDestroy() const;
00186 void IncDenyDestroy();
00187 void DecDenyDestroy();
00188
00189 Int_t GetParentIgnoreCnt() const;
00190 void IncParentIgnoreCnt();
00191 void DecParentIgnoreCnt();
00192
00193 virtual void PadPaint(Option_t* option);
00194 virtual void PaintStandard(TObject* id);
00195
00196 virtual TObject* GetObject (const TEveException& eh) const;
00197 virtual TObject* GetEditorObject(const TEveException& eh) const { return GetObject(eh); }
00198 virtual TObject* GetRenderObject(const TEveException& eh) const { return GetObject(eh); }
00199
00200
00201
00202 virtual void ExpandIntoListTree(TGListTree* ltree, TGListTreeItem* parent);
00203 virtual void DestroyListSubTree(TGListTree* ltree, TGListTreeItem* parent);
00204
00205 virtual TGListTreeItem* AddIntoListTree(TGListTree* ltree,
00206 TGListTreeItem* parent_lti);
00207 virtual TGListTreeItem* AddIntoListTree(TGListTree* ltree,
00208 TEveElement* parent);
00209 virtual TGListTreeItem* AddIntoListTrees(TEveElement* parent);
00210
00211 virtual Bool_t RemoveFromListTree(TGListTree* ltree,
00212 TGListTreeItem* parent_lti);
00213 virtual Int_t RemoveFromListTrees(TEveElement* parent);
00214
00215 virtual sLTI_i FindItem(TGListTree* ltree);
00216 virtual sLTI_i FindItem(TGListTree* ltree,
00217 TGListTreeItem* parent_lti);
00218 virtual TGListTreeItem* FindListTreeItem(TGListTree* ltree);
00219 virtual TGListTreeItem* FindListTreeItem(TGListTree* ltree,
00220 TGListTreeItem* parent_lti);
00221
00222 virtual Int_t GetNItems() const { return fItems.size(); }
00223
00224 void SpawnEditor();
00225 virtual void ExportToCINT(char* var_name);
00226
00227 void DumpSourceObject() const;
00228 void PrintSourceObject() const;
00229 void ExportSourceObjectToCINT(char* var_name) const;
00230
00231 virtual Bool_t AcceptElement(TEveElement* el);
00232
00233 virtual void AddElement(TEveElement* el);
00234 virtual void RemoveElement(TEveElement* el);
00235 virtual void RemoveElementLocal(TEveElement* el);
00236 virtual void RemoveElements();
00237 virtual void RemoveElementsLocal();
00238
00239 virtual void AnnihilateElements();
00240 virtual void Annihilate();
00241
00242 virtual void ProjectChild(TEveElement* el, Bool_t same_depth=kTRUE);
00243 virtual void ProjectAllChildren(Bool_t same_depth=kTRUE);
00244
00245 virtual void Destroy();
00246 virtual void DestroyOrWarn();
00247 virtual void DestroyElements();
00248
00249 virtual Bool_t HandleElementPaste(TEveElement* el);
00250 virtual void ElementChanged(Bool_t update_scenes=kTRUE, Bool_t redraw=kFALSE);
00251
00252 virtual Bool_t CanEditElement() const { return kTRUE; }
00253 virtual Bool_t SingleRnrState() const { return kFALSE; }
00254 virtual Bool_t GetRnrSelf() const { return fRnrSelf; }
00255 virtual Bool_t GetRnrChildren() const { return fRnrChildren; }
00256 virtual Bool_t GetRnrState() const { return fRnrSelf && fRnrChildren; }
00257 virtual Bool_t GetRnrAnything() const { return fRnrSelf || (fRnrChildren && HasChildren()); }
00258 virtual Bool_t SetRnrSelf(Bool_t rnr);
00259 virtual Bool_t SetRnrChildren(Bool_t rnr);
00260 virtual Bool_t SetRnrSelfChildren(Bool_t rnr_self, Bool_t rnr_children);
00261 virtual Bool_t SetRnrState(Bool_t rnr);
00262 virtual void PropagateRnrStateToProjecteds();
00263
00264 virtual Bool_t CanEditMainColor() const { return fCanEditMainColor; }
00265 void SetEditMainColor(Bool_t x) { fCanEditMainColor = x; }
00266 Color_t* GetMainColorPtr() const { return fMainColorPtr; }
00267 void SetMainColorPtr(Color_t* color) { fMainColorPtr = color; }
00268
00269 virtual Bool_t HasMainColor() const { return fMainColorPtr != 0; }
00270 virtual Color_t GetMainColor() const { return fMainColorPtr ? *fMainColorPtr : 0; }
00271 virtual void SetMainColor(Color_t color);
00272 void SetMainColorPixel(Pixel_t pixel);
00273 void SetMainColorRGB(UChar_t r, UChar_t g, UChar_t b);
00274 void SetMainColorRGB(Float_t r, Float_t g, Float_t b);
00275 virtual void PropagateMainColorToProjecteds(Color_t color, Color_t old_color);
00276
00277 virtual Bool_t CanEditMainTransparency() const { return fCanEditMainTransparency; }
00278 void SetEditMainTransparency(Bool_t x) { fCanEditMainTransparency = x; }
00279 virtual Char_t GetMainTransparency() const { return fMainTransparency; }
00280 virtual void SetMainTransparency(Char_t t);
00281 void SetMainAlpha(Float_t alpha);
00282 virtual void PropagateMainTransparencyToProjecteds(Char_t t, Char_t old_t);
00283
00284 virtual Bool_t CanEditMainTrans() const { return fCanEditMainTrans; }
00285 virtual Bool_t HasMainTrans() const { return fMainTrans != 0; }
00286 virtual TEveTrans* PtrMainTrans(Bool_t create=kTRUE);
00287 virtual TEveTrans& RefMainTrans();
00288 virtual void InitMainTrans(Bool_t can_edit=kTRUE);
00289 virtual void DestroyMainTrans();
00290
00291 virtual void SetTransMatrix(Double_t* carr);
00292 virtual void SetTransMatrix(const TGeoMatrix& mat);
00293
00294 TRef& GetSource() { return fSource; }
00295 TObject* GetSourceObject() const { return fSource.GetObject(); }
00296 void SetSourceObject(TObject* o) { fSource = o; }
00297
00298
00299
00300
00301
00302 void* GetUserData() const { return fUserData; }
00303 void SetUserData(void* ud) { fUserData = ud; }
00304
00305
00306
00307
00308
00309 protected:
00310 Bool_t fPickable;
00311 Bool_t fSelected;
00312 Bool_t fHighlighted;
00313 Short_t fImpliedSelected;
00314 Short_t fImpliedHighlighted;
00315
00316 enum ECompoundSelectionColorBits
00317 {
00318 kCSCBImplySelectAllChildren = BIT(0),
00319 kCSCBTakeAnyParentAsMaster = BIT(1),
00320 kCSCBApplyMainColorToAllChildren = BIT(2),
00321 kCSCBApplyMainColorToMatchingChildren = BIT(3),
00322 kCSCBApplyMainTransparencyToAllChildren = BIT(4),
00323 kCSCBApplyMainTransparencyToMatchingChildren = BIT(5)
00324 };
00325
00326 enum EDestruct
00327 {
00328 kNone,
00329 kStandard,
00330 kAnnihilate
00331 };
00332
00333 UChar_t fCSCBits;
00334
00335 public:
00336 typedef void (TEveElement::* Select_foo) (Bool_t);
00337 typedef void (TEveElement::* ImplySelect_foo) ();
00338
00339 Bool_t IsPickable() const { return fPickable; }
00340 void SetPickable(Bool_t p) { fPickable = p; }
00341
00342 virtual TEveElement* ForwardSelection();
00343 virtual TEveElement* ForwardEdit();
00344
00345 virtual void SelectElement(Bool_t state);
00346 virtual void IncImpliedSelected();
00347 virtual void DecImpliedSelected();
00348 virtual void UnSelected();
00349
00350 virtual void HighlightElement(Bool_t state);
00351 virtual void IncImpliedHighlighted();
00352 virtual void DecImpliedHighlighted();
00353 virtual void UnHighlighted();
00354
00355 virtual void FillImpliedSelectedSet(Set_t& impSelSet);
00356
00357 virtual UChar_t GetSelectedLevel() const;
00358
00359 void RecheckImpliedSelections();
00360
00361 void SetCSCBits(UChar_t f) { fCSCBits |= f; }
00362 void ResetCSCBits(UChar_t f) { fCSCBits &= ~f; }
00363 Bool_t TestCSCBits(UChar_t f) const { return (fCSCBits & f) != 0; }
00364
00365 void ResetAllCSCBits() { fCSCBits = 0; }
00366 void CSCImplySelectAllChildren() { fCSCBits |= kCSCBImplySelectAllChildren; }
00367 void CSCTakeAnyParentAsMaster() { fCSCBits |= kCSCBTakeAnyParentAsMaster; }
00368 void CSCApplyMainColorToAllChildren() { fCSCBits |= kCSCBApplyMainColorToAllChildren; }
00369 void CSCApplyMainColorToMatchingChildren() { fCSCBits |= kCSCBApplyMainColorToMatchingChildren; }
00370 void CSCApplyMainTransparencyToAllChildren() { fCSCBits |= kCSCBApplyMainTransparencyToAllChildren; }
00371 void CSCApplyMainTransparencyToMatchingChildren() { fCSCBits |= kCSCBApplyMainTransparencyToMatchingChildren; }
00372
00373
00374
00375
00376
00377 enum EChangeBits
00378 {
00379 kCBColorSelection = BIT(0),
00380 kCBTransBBox = BIT(1),
00381 kCBObjProps = BIT(2),
00382 kCBVisibility = BIT(3)
00383
00384
00385
00386
00387 };
00388
00389 protected:
00390 UChar_t fChangeBits;
00391 Char_t fDestructing;
00392
00393 public:
00394 void StampColorSelection() { AddStamp(kCBColorSelection); }
00395 void StampTransBBox() { AddStamp(kCBTransBBox); }
00396 void StampObjProps() { AddStamp(kCBObjProps); }
00397 void StampVisibility() { AddStamp(kCBVisibility); }
00398
00399
00400 virtual void AddStamp(UChar_t bits);
00401 virtual void ClearStamps() { fChangeBits = 0; }
00402
00403 UChar_t GetChangeBits() const { return fChangeBits; }
00404
00405
00406
00407
00408
00409 virtual const TGPicture* GetListTreeIcon(Bool_t open=kFALSE);
00410 virtual const TGPicture* GetListTreeCheckBoxIcon();
00411
00412
00413
00414 void VizDB_Apply(const char* tag);
00415 void VizDB_Reapply();
00416 void VizDB_UpdateModel(Bool_t update=kTRUE);
00417 void VizDB_Insert(const char* tag, Bool_t replace=kTRUE, Bool_t update=kTRUE);
00418
00419 ClassDef(TEveElement, 0);
00420 };
00421
00422
00423
00424
00425
00426
00427 class TEveElementObjectPtr : public TEveElement,
00428 public TObject
00429 {
00430 TEveElementObjectPtr& operator=(const TEveElementObjectPtr&);
00431
00432 protected:
00433 TObject* fObject;
00434 Bool_t fOwnObject;
00435
00436 public:
00437 TEveElementObjectPtr(TObject* obj, Bool_t own=kTRUE);
00438 TEveElementObjectPtr(TObject* obj, Color_t& mainColor, Bool_t own=kTRUE);
00439 TEveElementObjectPtr(const TEveElementObjectPtr& e);
00440 virtual ~TEveElementObjectPtr();
00441
00442 virtual TEveElementObjectPtr* CloneElement() const;
00443
00444 virtual TObject* GetObject(const TEveException& eh="TEveElementObjectPtr::GetObject ") const;
00445 virtual void ExportToCINT(char* var_name);
00446
00447 Bool_t GetOwnObject() const { return fOwnObject; }
00448 void SetOwnObject(Bool_t o) { fOwnObject = o; }
00449
00450 ClassDef(TEveElementObjectPtr, 0);
00451 };
00452
00453
00454
00455
00456
00457
00458 class TEveElementList : public TEveElement,
00459 public TNamed,
00460 public TEveProjectable
00461 {
00462 private:
00463 TEveElementList& operator=(const TEveElementList&);
00464
00465 protected:
00466 Color_t fColor;
00467 TClass *fChildClass;
00468
00469 public:
00470 TEveElementList(const char* n="TEveElementList", const char* t="",
00471 Bool_t doColor=kFALSE, Bool_t doTransparency=kFALSE);
00472 TEveElementList(const TEveElementList& e);
00473 virtual ~TEveElementList() {}
00474
00475 virtual TObject* GetObject(const TEveException& ="TEveElementList::GetObject ") const
00476 { const TObject* obj = this; return const_cast<TObject*>(obj); }
00477
00478 virtual TEveElementList* CloneElement() const;
00479
00480 virtual const char* GetElementName() const { return GetName(); }
00481 virtual const char* GetElementTitle() const { return GetTitle(); }
00482
00483 virtual void SetElementName (const char* name)
00484 { TNamed::SetName(name); NameTitleChanged(); }
00485
00486 virtual void SetElementTitle(const char* title)
00487 { TNamed::SetTitle(title); NameTitleChanged(); }
00488
00489 virtual void SetElementNameTitle(const char* name, const char* title)
00490 { TNamed::SetNameTitle(name, title); NameTitleChanged(); }
00491
00492 TClass* GetChildClass() const { return fChildClass; }
00493 void SetChildClass(TClass* c) { fChildClass = c; }
00494
00495 virtual Bool_t AcceptElement(TEveElement* el);
00496
00497 virtual TClass* ProjectedClass(const TEveProjection* p) const;
00498
00499 ClassDef(TEveElementList, 0);
00500 };
00501
00502
00503
00504
00505
00506
00507 class TEveElementListProjected : public TEveElementList,
00508 public TEveProjected
00509 {
00510 private:
00511 TEveElementListProjected(const TEveElementListProjected&);
00512 TEveElementListProjected& operator=(const TEveElementListProjected&);
00513
00514 public:
00515 TEveElementListProjected();
00516 virtual ~TEveElementListProjected() {}
00517
00518 virtual void UpdateProjection();
00519 virtual TEveElement* GetProjectedAsElement() { return this; }
00520
00521 ClassDef(TEveElementListProjected, 0);
00522 };
00523
00524 #endif