]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/RenderElement.h
Add some class docs.
[u/mrichter/AliRoot.git] / EVE / Reve / RenderElement.h
1 // $Header$
2
3 #ifndef REVE_RenderElement_H
4 #define REVE_RenderElement_H
5
6 #include <Reve/Reve.h>
7
8 #include <TNamed.h>
9 #include <TRef.h>
10
11 class TGListTree;
12 class TGListTreeItem;
13 class TGPicture;
14
15 namespace Reve {
16
17 class ZTrans;
18
19
20 /******************************************************************************/
21 // RenderElement
22 /******************************************************************************/
23
24 class RenderElement
25 {
26   friend class ReveManager;
27
28   RenderElement(const RenderElement&);            // Not implemented
29   RenderElement& operator=(const RenderElement&); // Not implemented
30
31 public:
32   class ListTreeInfo
33   {
34   public:
35     TGListTree*     fTree;
36     TGListTreeItem* fItem;
37
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() {}
42
43     ListTreeInfo& operator=(const ListTreeInfo& l)
44     { fTree = l.fTree; fItem = l.fItem; return *this; }
45
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; }
50
51     ClassDef(ListTreeInfo, 0); // Structure agregating data for a render element image in a list tree.
52   };
53
54   static const TGPicture*                      fgRnrIcons[4];
55   static const TGPicture*                      fgListTreeIcons[8];
56
57   typedef std::set<ListTreeInfo>               sLTI_t;
58   typedef sLTI_t::iterator                     sLTI_i;
59   typedef sLTI_t::reverse_iterator             sLTI_ri;
60
61   typedef std::list<RenderElement*>            List_t;
62   typedef std::list<RenderElement*>::iterator  List_i;
63
64 protected:
65   // TRef     fSource;
66
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.
70
71   sLTI_t fItems;                  // Set of list-tree-items.
72   List_t fParents;                // List of parents.
73
74   Bool_t fDestroyOnZeroRefCnt;    // Auto-destruct when ref-count reaches zero.
75   Int_t  fDenyDestroy;            // Deny-destroy count.
76
77   List_t fChildren;               // List of children.
78
79 public:
80   RenderElement();
81   RenderElement(Color_t& main_color);
82   virtual ~RenderElement();
83
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;
87
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);
93
94   List_i BeginParents() { return fParents.begin(); }
95   List_i EndParents()   { return fParents.end();   }
96   Int_t  GetNParents() const { return fParents.size(); }
97
98   List_i BeginChildren() { return fChildren.begin(); }
99   List_i EndChildren()   { return fChildren.end();   }
100   Int_t  GetNChildren() const { return fChildren.size(); }
101
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*
104
105   Bool_t GetDestroyOnZeroRefCnt() const   { return fDestroyOnZeroRefCnt; }
106   void   SetDestroyOnZeroRefCnt(Bool_t d) { fDestroyOnZeroRefCnt = d; }
107
108   Int_t  GetDenyDestroy() const { return fDenyDestroy; }
109   void   IncDenyDestroy()       { ++fDenyDestroy; }
110   void   DecDenyDestroy()       { if (--fDenyDestroy <= 0) CheckReferenceCount("RenderElement::DecDenyDestroy "); }
111
112   virtual void PadPaint(Option_t* option);
113
114   virtual TObject* GetObject(Reve::Exc_t eh="RenderElement::GetObject ") const;
115   virtual TObject* GetEditorObject() const { return GetObject(); }
116   /*
117     TRef&    GetSource() { return fSource; }
118     TObject* GetSourceObject() const { return fSource.GetObject(); }
119     void SetSourceObject(TObject* o) { fSource.SetObject(o); }
120
121     void DumpSourceObject();    // *MENU*
122     void InspectSourceObject(); // *MENU*
123   */
124
125   // --------------------------------
126
127   virtual Int_t ExpandIntoListTree(TGListTree* ltree, TGListTreeItem* parent);
128   virtual Int_t DestroyListSubTree(TGListTree* ltree, TGListTreeItem* parent);
129
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);
135
136   virtual Bool_t          RemoveFromListTree(TGListTree* ltree,
137                                              TGListTreeItem* parent_lti);
138   virtual Int_t           RemoveFromListTrees(RenderElement* parent);
139
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);
146
147   virtual Int_t GetNItems() const { return fItems.size(); }
148   virtual void  UpdateItems();
149
150   void SpawnEditor();                          // *MENU*
151   virtual void ExportToCINT(Text_t* var_name); // *MENU*
152
153   virtual Bool_t AcceptRenderElement(RenderElement* /*el*/) { return kTRUE; }
154
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();
160
161   virtual void Destroy();                      // *MENU*
162   virtual void DestroyElements();              // *MENU*
163
164   virtual Bool_t HandleElementPaste(RenderElement* el);
165   virtual void   ElementChanged(Bool_t update_scenes=kTRUE, Bool_t redraw=kFALSE);
166
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);
173
174   virtual Bool_t CanEditMainColor()        { return kFALSE; }
175   Color_t* GetMainColorPtr()               { return fMainColorPtr; }
176   void     SetMainColorPtr(Color_t* color) { fMainColorPtr = color; }
177
178   virtual Color_t GetMainColor() const { return fMainColorPtr ? *fMainColorPtr : 0; }
179   virtual void    SetMainColor(Color_t color);
180   void    SetMainColor(Pixel_t pixel);
181
182   virtual Bool_t  CanEditMainTransparency()    { return kFALSE; }
183   virtual UChar_t GetMainTransparency() const  { return 0; }
184   virtual void    SetMainTransparency(UChar_t) {}
185
186   virtual Bool_t  CanEditMainHMTrans() { return kFALSE; }
187   virtual ZTrans* PtrMainHMTrans()     { return 0; }
188
189   static  const TGPicture* GetCheckBoxPicture(Bool_t rnrElement, Bool_t rnrDaughter);
190   virtual const TGPicture* GetListTreeIcon() { return fgListTreeIcons[0]; }
191
192   ClassDef(RenderElement, 1); // Base class for visualization elements.
193 }; // endclass RenderElement
194
195
196 /******************************************************************************/
197 // RenderElementObjPtr
198 /******************************************************************************/
199
200 class RenderElementObjPtr : public RenderElement,
201                             public TObject
202 {
203   RenderElementObjPtr(const RenderElementObjPtr&);            // Not implemented
204   RenderElementObjPtr& operator=(const RenderElementObjPtr&); // Not implemented
205
206 protected:
207   TObject* fObject;     // External object holding the visual data.
208   Bool_t   fOwnObject;  // Is object owned / should be deleted on destruction.
209
210 public:
211   RenderElementObjPtr(TObject* obj, Bool_t own=kTRUE);
212   RenderElementObjPtr(TObject* obj, Color_t& mainColor, Bool_t own=kTRUE);
213   virtual ~RenderElementObjPtr();
214
215   virtual TObject* GetObject(Exc_t eh="RenderElementObjPtr::GetObject ") const;
216   virtual void     ExportToCINT(Text_t* var_name);
217
218   Bool_t GetOwnObject() const   { return fOwnObject; }
219   void   SetOwnObject(Bool_t o) { fOwnObject = o; }
220
221   ClassDef(RenderElementObjPtr, 1); // Render element with external TObject as visualization data holder.
222 }; // endclass RenderElementObjPtr
223
224
225 /******************************************************************************/
226 // RenderElementList
227 /******************************************************************************/
228
229 class RenderElementList : public RenderElement,
230                           public TNamed
231 {
232 protected:
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.
236
237 public:
238   RenderElementList(const Text_t* n="RenderElementList", const Text_t* t="",
239                     Bool_t doColor=kFALSE);
240   virtual ~RenderElementList() {}
241
242   virtual Bool_t CanEditMainColor()  { return fDoColor; }
243
244   TClass* GetChildClass() const { return fChildClass; }
245   void SetChildClass(TClass* c) { fChildClass = c; }
246
247   virtual Bool_t AcceptRenderElement(RenderElement* el);
248
249   ClassDef(RenderElementList, 1); // List of render elements.
250 };
251
252 }
253
254 #endif