Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveDigitSet.h
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TEveDigitSet
13 #define ROOT_TEveDigitSet
14 
15 #include "TNamed.h"
16 #include "TQObject.h"
17 #include "TAtt3D.h"
18 #include "TAttBBox.h"
19 
20 #include "TEveUtil.h"
21 #include "TEveElement.h"
22 #include "TEveFrameBox.h"
23 #include "TEveRGBAPalette.h"
24 #include "TEveChunkManager.h"
26 
27 class TRefArray;
28 
29 class TEveDigitSet : public TEveElement,
30  public TNamed, public TQObject,
31  public TAtt3D,
32  public TAttBBox,
33  public TEveSecondarySelectable
34 {
35  friend class TEveDigitSetEditor;
36  friend class TEveDigitSetGL;
37 
38  TEveDigitSet(const TEveDigitSet&); // Not implemented
39  TEveDigitSet& operator=(const TEveDigitSet&); // Not implemented
40 
41 public:
42  enum ERenderMode_e { kRM_AsIs, kRM_Line, kRM_Fill };
43 
44  typedef void (*Callback_foo)(TEveDigitSet*, Int_t, TObject*);
45  typedef TString (*TooltipCB_foo)(TEveDigitSet*, Int_t);
46 
47  struct DigitBase_t
48  {
49  // Base-class for digit representation classes.
50 
51  Int_t fValue; // signal value of a digit (can be direct RGBA color)
52  void *fUserData; // user-data for given digit
53 
54  DigitBase_t(Int_t v=0) : fValue(v), fUserData(0) {}
55  };
56 
57 protected:
58  TRefArray *fDigitIds; // Array holding references to external objects.
59 
60  Int_t fDefaultValue; // Default signal value.
61  Bool_t fValueIsColor; // Interpret signal value as RGBA color.
62  Bool_t fSingleColor; // Use the same color for all digits.
63  Bool_t fAntiFlick; // Make extra render pass to avoid flickering when quads are too small.
64  Bool_t fOwnIds; // Flag specifying if id-objects are owned by the TEveDigitSet.
65  TEveChunkManager fPlex; // Container of digit data.
66  DigitBase_t* fLastDigit; //! The last / current digit added to collection.
67  Int_t fLastIdx; //! The last / current idx added to collection.
68 
69  Color_t fColor; // Color used for frame (or all digis with single-color).
70  TEveFrameBox* fFrame; // Pointer to frame structure.
71  TEveRGBAPalette* fPalette; // Pointer to signal-color palette.
72  ERenderMode_e fRenderMode; // Render mode: as-is / line / filled.
73  Bool_t fSelectViaFrame; // Allow selection via frame.
74  Bool_t fHighlightFrame; // Highlight frame when object is selected.
75  Bool_t fDisableLighting;// Disable lighting for rendering.
76  Bool_t fHistoButtons; // Show histogram buttons in object editor.
77 
78  Bool_t fEmitSignals; // Emit signals on secondary-select.
79  Callback_foo fCallbackFoo; //! Additional function to call on secondary-select.
80  TooltipCB_foo fTooltipCBFoo; //! Function providing highlight tooltips when always-sec-select is active.
81 
82  DigitBase_t* NewDigit();
83  void ReleaseIds();
84 
85 public:
86  TEveDigitSet(const char* n="TEveDigitSet", const char* t="");
87  virtual ~TEveDigitSet();
88 
89  virtual TObject* GetObject(const TEveException&) const
90  { const TObject* obj = this; return const_cast<TObject*>(obj); }
91 
92  void UseSingleColor();
93 
94  Bool_t GetAntiFlick() const { return fAntiFlick; }
95  void SetAntiFlick(Bool_t f) { fAntiFlick = f; }
96 
97  virtual void SetMainColor(Color_t color);
98 
99  virtual void UnSelected();
100  virtual void UnHighlighted();
101 
102  virtual TString GetHighlightTooltip();
103 
104  // Implemented in sub-classes:
105  // virtual void Reset(EQuadType_e quadType, Bool_t valIsCol, Int_t chunkSize);
106 
107  void RefitPlex();
108  void ScanMinMaxValues(Int_t& min, Int_t& max);
109 
110  // --------------------------------
111 
112  void SetCurrentDigit(Int_t idx);
113 
114  void DigitValue(Int_t value);
115  void DigitColor(Color_t ci);
116  void DigitColor(Color_t ci, Char_t transparency);
117  void DigitColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255);
118  void DigitColor(UChar_t* rgba);
119 
120  Bool_t GetOwnIds() const { return fOwnIds; }
121  void SetOwnIds(Bool_t o) { fOwnIds = o; }
122 
123  void DigitId(TObject* id);
124  void DigitUserData(void* ud);
125 
126  void DigitId(Int_t n, TObject* id);
127  void DigitUserData(Int_t n, void* ud);
128 
129  DigitBase_t* GetDigit(Int_t n) const { return (DigitBase_t*) fPlex.Atom(n); }
130  TObject* GetId(Int_t n) const;
131  void* GetUserData(Int_t n) const;
132  using TEveElement::GetUserData;
133 
134  // --------------------------------
135 
136  // Implemented in subclasses:
137  // virtual void ComputeBBox();
138 
139  virtual void Paint(Option_t* option="");
140 
141  virtual void DigitSelected(Int_t idx);
142  virtual void SecSelected(TEveDigitSet* qs, Int_t idx); // *SIGNAL*
143 
144  // --------------------------------
145 
146  TEveChunkManager* GetPlex() { return &fPlex; }
147 
148  TEveFrameBox* GetFrame() const { return fFrame; }
149  void SetFrame(TEveFrameBox* b);
150 
151  Bool_t GetSelectViaFrame() const { return fSelectViaFrame; }
152  void SetSelectViaFrame(Bool_t sf) { fSelectViaFrame = sf; }
153 
154  Bool_t GetHighlightFrame() const { return fHighlightFrame; }
155  void SetHighlightFrame(Bool_t hf) { fHighlightFrame = hf; }
156 
157  Bool_t GetValueIsColor() const { return fValueIsColor; }
158 
159  TEveRGBAPalette* GetPalette() const { return fPalette; }
160  void SetPalette(TEveRGBAPalette* p);
161  TEveRGBAPalette* AssertPalette();
162 
163  ERenderMode_e GetRenderMode() const { return fRenderMode; }
164  void SetRenderMode(ERenderMode_e rm) { fRenderMode = rm; }
165 
166  Bool_t GetDisableLighting() const { return fDisableLighting; }
167  void SetDisableLighting(Bool_t l) { fDisableLighting = l; }
168 
169  Bool_t GetHistoButtons() const { return fHistoButtons; }
170  void SetHistoButtons(Bool_t f) { fHistoButtons = f; }
171 
172  Bool_t GetEmitSignals() const { return fEmitSignals; }
173  void SetEmitSignals(Bool_t f) { fEmitSignals = f; }
174 
175  Callback_foo GetCallbackFoo() const { return fCallbackFoo; }
176  void SetCallbackFoo(Callback_foo f) { fCallbackFoo = f; }
177 
178  TooltipCB_foo GetTooltipCBFoo() const { return fTooltipCBFoo; }
179  void SetTooltipCBFoo(TooltipCB_foo f) { fTooltipCBFoo = f; }
180 
181  ClassDef(TEveDigitSet, 0); // Base-class for storage of digit collections; provides transformation matrix (TEveTrans), signal to color mapping (TEveRGBAPalette) and visual grouping (TEveFrameBox).
182 };
183 
184 #endif