3 #ifndef REVE_RenderElement_H
4 #define REVE_RenderElement_H
20 /******************************************************************************/
22 /******************************************************************************/
26 friend class ReveManager;
28 RenderElement(const RenderElement&); // Not implemented
29 RenderElement& operator=(const RenderElement&); // Not implemented
36 TGListTreeItem* fItem;
38 ListTreeInfo() : fTree(0), fItem(0) {}
39 ListTreeInfo(TGListTree* lt, TGListTreeItem* lti) : fTree(lt), fItem(lti) {}
40 ListTreeInfo(const ListTreeInfo& l) : fTree(l.fTree), fItem(l.fItem) {}
41 virtual ~ListTreeInfo() {}
43 ListTreeInfo& operator=(const ListTreeInfo& l)
44 { fTree = l.fTree; fItem = l.fItem; return *this; }
46 bool operator==(const ListTreeInfo& x) const
47 { return fTree == x.fTree && fItem == x.fItem; }
48 bool operator<(const ListTreeInfo& x) const
49 { return fTree == x.fTree ? fItem < x.fItem : fTree < x.fTree; }
51 ClassDef(ListTreeInfo, 0); // Structure agregating data for a render element image in a list tree.
54 static const TGPicture* fgRnrIcons[4];
55 static const TGPicture* fgListTreeIcons[8];
57 typedef std::set<ListTreeInfo> sLTI_t;
58 typedef sLTI_t::iterator sLTI_i;
59 typedef sLTI_t::reverse_iterator sLTI_ri;
61 typedef std::list<RenderElement*> List_t;
62 typedef std::list<RenderElement*>::iterator List_i;
67 Bool_t fRnrSelf; // Render this element.
68 Bool_t fRnrChildren; // Render children of this element.
69 Color_t* fMainColorPtr; // Pointer to main-color variable.
71 sLTI_t fItems; // Set of list-tree-items.
72 List_t fParents; // List of parents.
74 Bool_t fDestroyOnZeroRefCnt; // Auto-destruct when ref-count reaches zero.
75 Int_t fDenyDestroy; // Deny-destroy count.
77 List_t fChildren; // List of children.
81 RenderElement(Color_t& main_color);
82 virtual ~RenderElement();
84 virtual void SetRnrElNameTitle(const Text_t* name, const Text_t* title);
85 virtual const Text_t* GetRnrElName() const;
86 virtual const Text_t* GetRnrElTitle() const;
88 virtual void AddParent(RenderElement* re);
89 virtual void RemoveParent(RenderElement* re);
90 virtual void CheckReferenceCount(const Reve::Exc_t& eh="RenderElement::CheckReferenceCount ");
91 virtual void CollectSceneParents(List_t& scenes);
92 virtual void CollectSceneParentsFromChildren(List_t& scenes, RenderElement* parent);
94 List_i BeginParents() { return fParents.begin(); }
95 List_i EndParents() { return fParents.end(); }
96 Int_t GetNParents() const { return fParents.size(); }
98 List_i BeginChildren() { return fChildren.begin(); }
99 List_i EndChildren() { return fChildren.end(); }
100 Int_t GetNChildren() const { return fChildren.size(); }
102 void EnableListElements (Bool_t rnr_self=kTRUE, Bool_t rnr_children=kTRUE); // *MENU*
103 void DisableListElements(Bool_t rnr_self=kFALSE, Bool_t rnr_children=kFALSE); // *MENU*
105 Bool_t GetDestroyOnZeroRefCnt() const { return fDestroyOnZeroRefCnt; }
106 void SetDestroyOnZeroRefCnt(Bool_t d) { fDestroyOnZeroRefCnt = d; }
108 Int_t GetDenyDestroy() const { return fDenyDestroy; }
109 void IncDenyDestroy() { ++fDenyDestroy; }
110 void DecDenyDestroy() { if (--fDenyDestroy <= 0) CheckReferenceCount("RenderElement::DecDenyDestroy "); }
112 virtual void PadPaint(Option_t* option);
114 virtual TObject* GetObject(Reve::Exc_t eh="RenderElement::GetObject ") const;
115 virtual TObject* GetEditorObject() const { return GetObject(); }
117 TRef& GetSource() { return fSource; }
118 TObject* GetSourceObject() const { return fSource.GetObject(); }
119 void SetSourceObject(TObject* o) { fSource.SetObject(o); }
121 void DumpSourceObject(); // *MENU*
122 void InspectSourceObject(); // *MENU*
125 // --------------------------------
127 virtual Int_t ExpandIntoListTree(TGListTree* ltree, TGListTreeItem* parent);
128 virtual Int_t DestroyListSubTree(TGListTree* ltree, TGListTreeItem* parent);
130 virtual TGListTreeItem* AddIntoListTree(TGListTree* ltree,
131 TGListTreeItem* parent_lti);
132 virtual TGListTreeItem* AddIntoListTree(TGListTree* ltree,
133 RenderElement* parent);
134 virtual TGListTreeItem* AddIntoListTrees(RenderElement* parent);
136 virtual Bool_t RemoveFromListTree(TGListTree* ltree,
137 TGListTreeItem* parent_lti);
138 virtual Int_t RemoveFromListTrees(RenderElement* parent);
140 virtual sLTI_i FindItem(TGListTree* ltree);
141 virtual sLTI_i FindItem(TGListTree* ltree,
142 TGListTreeItem* parent_lti);
143 virtual TGListTreeItem* FindListTreeItem(TGListTree* ltree);
144 virtual TGListTreeItem* FindListTreeItem(TGListTree* ltree,
145 TGListTreeItem* parent_lti);
147 virtual Int_t GetNItems() const { return fItems.size(); }
148 virtual void UpdateItems();
150 void SpawnEditor(); // *MENU*
151 virtual void ExportToCINT(Text_t* var_name); // *MENU*
153 virtual Bool_t AcceptRenderElement(RenderElement* /*el*/) { return kTRUE; }
155 virtual TGListTreeItem* AddElement(RenderElement* el);
156 virtual void RemoveElement(RenderElement* el);
157 virtual void RemoveElementLocal(RenderElement* el);
158 virtual void RemoveElements();
159 virtual void RemoveElementsLocal();
161 virtual void Destroy(); // *MENU*
162 virtual void DestroyElements(); // *MENU*
164 virtual Bool_t HandleElementPaste(RenderElement* el);
165 virtual void ElementChanged(Bool_t update_scenes=kTRUE, Bool_t redraw=kFALSE);
167 virtual Bool_t CanEditRnrElement() { return kTRUE; }
168 virtual Bool_t GetRnrSelf() const { return fRnrSelf; }
169 virtual Bool_t GetRnrChildren() const { return fRnrChildren; }
170 virtual void SetRnrSelf(Bool_t rnr);
171 virtual void SetRnrChildren(Bool_t rnr);
172 virtual void SetRnrState(Bool_t rnr);
174 virtual Bool_t CanEditMainColor() { return kFALSE; }
175 Color_t* GetMainColorPtr() { return fMainColorPtr; }
176 void SetMainColorPtr(Color_t* color) { fMainColorPtr = color; }
178 virtual Color_t GetMainColor() const { return fMainColorPtr ? *fMainColorPtr : 0; }
179 virtual void SetMainColor(Color_t color);
180 void SetMainColor(Pixel_t pixel);
182 virtual Bool_t CanEditMainTransparency() { return kFALSE; }
183 virtual UChar_t GetMainTransparency() const { return 0; }
184 virtual void SetMainTransparency(UChar_t) {}
186 virtual Bool_t CanEditMainHMTrans() { return kFALSE; }
187 virtual ZTrans* PtrMainHMTrans() { return 0; }
189 static const TGPicture* GetCheckBoxPicture(Bool_t rnrElement, Bool_t rnrDaughter);
190 virtual const TGPicture* GetListTreeIcon() { return fgListTreeIcons[0]; }
192 ClassDef(RenderElement, 1); // Base class for visualization elements.
193 }; // endclass RenderElement
196 /******************************************************************************/
197 // RenderElementObjPtr
198 /******************************************************************************/
200 class RenderElementObjPtr : public RenderElement,
203 RenderElementObjPtr(const RenderElementObjPtr&); // Not implemented
204 RenderElementObjPtr& operator=(const RenderElementObjPtr&); // Not implemented
207 TObject* fObject; // External object holding the visual data.
208 Bool_t fOwnObject; // Is object owned / should be deleted on destruction.
211 RenderElementObjPtr(TObject* obj, Bool_t own=kTRUE);
212 RenderElementObjPtr(TObject* obj, Color_t& mainColor, Bool_t own=kTRUE);
213 virtual ~RenderElementObjPtr();
215 virtual TObject* GetObject(Exc_t eh="RenderElementObjPtr::GetObject ") const;
216 virtual void ExportToCINT(Text_t* var_name);
218 Bool_t GetOwnObject() const { return fOwnObject; }
219 void SetOwnObject(Bool_t o) { fOwnObject = o; }
221 ClassDef(RenderElementObjPtr, 1); // Render element with external TObject as visualization data holder.
222 }; // endclass RenderElementObjPtr
225 /******************************************************************************/
227 /******************************************************************************/
229 class RenderElementList : public RenderElement,
233 Color_t fColor; // Color of the object.
234 Bool_t fDoColor; // Should serve fColor as the main color of the object.
235 TClass *fChildClass; // Class of acceptable children, others are rejected.
238 RenderElementList(const Text_t* n="RenderElementList", const Text_t* t="",
239 Bool_t doColor=kFALSE);
240 virtual ~RenderElementList() {}
242 virtual Bool_t CanEditMainColor() { return fDoColor; }
244 TClass* GetChildClass() const { return fChildClass; }
245 void SetChildClass(TClass* c) { fChildClass = c; }
247 virtual Bool_t AcceptRenderElement(RenderElement* el);
249 ClassDef(RenderElementList, 1); // List of render elements.