5 #include "ReveManager.h"
10 #include <TBuffer3DTypes.h>
11 #include <TVirtualPad.h>
12 #include <TVirtualViewer3D.h>
16 //______________________________________________________________________
22 DigitSet::DigitSet(const Text_t* n, const Text_t* t) :
26 fDefaultValue (kMinInt),
27 fValueIsColor (kFALSE),
34 fRenderMode (RM_Fill),
35 fDisableLigting (kTRUE),
36 fEmitSignals (kFALSE),
37 fHistoButtons (kTRUE),
51 /**************************************************************************/
53 DigitSet::DigitBase* DigitSet::NewDigit()
55 fLastDigit = new (fPlex.NewAtom()) DigitBase(fDefaultValue);
59 void DigitSet::ReleaseIds()
61 VoidCPlex::iterator qi(fPlex);
63 DigitBase& q = * (DigitBase*) qi();
64 if (q.fId.GetObject()) {
65 delete q.fId.GetObject();
71 /**************************************************************************/
72 /**************************************************************************/
74 void DigitSet::SetMainColor(Color_t color)
76 // Override from RenderElement, forward to Frame.
79 fFrame->SetFrameColor(color);
80 fFrame->UpdateBackPtrItems();
85 /**************************************************************************/
86 /**************************************************************************/
88 void DigitSet::RefitPlex()
90 // Instruct underlying memory allocator to regroup itself into a
91 // contiguous memory chunk.
96 /**************************************************************************/
98 void DigitSet::ScanMinMaxValues(Int_t& min, Int_t& max)
100 if (fValueIsColor || fPlex.Size() == 0) return;
103 for (Int_t c=0; c<fPlex.VecSize(); ++c)
105 Char_t* a = fPlex.Chunk(c);
106 Int_t n = fPlex.NAtoms(c);
109 Int_t v = ((DigitBase*)a)->fValue;
110 if (v < min) min = v;
111 if (v > max) max = v;
119 /**************************************************************************/
122 void DigitSet::DigitValue(Int_t value)
124 fLastDigit->fValue = value;
127 void DigitSet::DigitColor(Color_t ci)
129 ColorFromIdx(ci, (UChar_t*) & fLastDigit->fValue, kTRUE);
132 void DigitSet::DigitColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a)
134 UChar_t* x = (UChar_t*) & fLastDigit->fValue;
135 x[0] = r; x[1] = g; x[2] = b; x[3] = a;
138 void DigitSet::DigitColor(UChar_t* rgba)
140 UChar_t* x = (UChar_t*) & fLastDigit->fValue;
141 x[0] = rgba[0]; x[1] = rgba[1]; x[2] = rgba[2]; x[3] = rgba[3];
144 /**************************************************************************/
146 void DigitSet::DigitId(TObject* id)
148 fLastDigit->fId = id;
151 /**************************************************************************/
152 /**************************************************************************/
154 void DigitSet::Paint(Option_t* /*option*/)
156 static const Exc_t eH("DigitSet::Paint ");
158 TBuffer3D buff(TBuffer3DTypes::kGeneric);
162 buff.fColor = fFrame ? fFrame->GetFrameColor() : 1;
163 buff.fTransparency = 0;
164 fHMTrans.SetBuffer3D(buff);
165 buff.SetSectionsValid(TBuffer3D::kCore);
167 Int_t reqSections = gPad->GetViewer3D()->AddObject(buff);
168 if (reqSections != TBuffer3D::kNone)
169 Error(eH, "only direct GL rendering supported.");
172 void DigitSet::DigitSelected(Int_t idx)
175 CtrlClicked(this, idx);
177 DigitBase* qb = GetDigit(idx);
178 TObject* obj = qb->fId.GetObject();
179 printf("DigitSet::DigitSelected idx=%d, value=%d, obj=0x%lx\n",
180 idx, qb->fValue, (ULong_t)obj);
186 void DigitSet::CtrlClicked(DigitSet* qs, Int_t idx)
189 args[0] = (Long_t) qs;
190 args[1] = (Long_t) idx;
192 Emit("CtrlClicked(Reve::DigitSet*, Int_t)", args);
195 /**************************************************************************/
196 // Getters / Setters for Frame, RGBAPalette, ZTrans
197 /**************************************************************************/
199 void DigitSet::SetFrame(FrameBox* b)
201 if (fFrame == b) return;
202 if (fFrame) fFrame->DecRefCount(this);
205 fFrame->IncRefCount(this);
206 SetMainColorPtr(fFrame->PtrFrameColor());
212 void DigitSet::SetPalette(RGBAPalette* p)
214 if (fPalette == p) return;
215 if (fPalette) fPalette->DecRefCount();
217 if (fPalette) fPalette->IncRefCount();
220 RGBAPalette* DigitSet::AssertPalette()
223 fPalette = new RGBAPalette;
224 if (!fValueIsColor) {
226 ScanMinMaxValues(min, max);
227 fPalette->SetLimits(min, max);
228 fPalette->SetMinMax(min, max);