]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Reve/DigitSetEditor.cxx
Dummy methods DefineParticle required by the interface added.
[u/mrichter/AliRoot.git] / EVE / Reve / DigitSetEditor.cxx
CommitLineData
32e219c2 1// $Header$
2
3#include "DigitSetEditor.h"
4#include <Reve/DigitSet.h>
5
6#include <Reve/RGValuators.h>
7#include <Reve/ZTransEditor.h>
8#include <Reve/RGBAPaletteEditor.h>
9#include <Reve/RGEditor.h>
10
11#include <TVirtualPad.h>
12#include <TColor.h>
13#include <TH1F.h>
14#include <TStyle.h>
15
16#include <TGLabel.h>
17#include <TG3DLine.h>
18#include <TGButton.h>
19#include <TGNumberEntry.h>
20#include <TGColorSelect.h>
21#include <TGDoubleSlider.h>
22
23using namespace Reve;
24
cec82a67 25//______________________________________________________________________________
32e219c2 26// DigitSetEditor
27//
cec82a67 28// GUI editor for class DigitSet.
29//
32e219c2 30
31ClassImp(DigitSetEditor)
32
cec82a67 33//______________________________________________________________________________
32e219c2 34DigitSetEditor::DigitSetEditor(const TGWindow *p, Int_t width, Int_t height,
35 UInt_t options, Pixel_t back) :
36 TGedFrame(p, width, height, options | kVerticalFrame, back),
37 fM(0),
38 fHMTrans (0),
39 fPalette (0),
40
41 fHistoButtFrame(0),
42 fInfoFrame(0)
43{
cec82a67 44 // Constructor.
45
32e219c2 46 MakeTitle("Transformation matrix");
47
48 fHMTrans = new ZTransSubEditor(this);
49 fHMTrans->Connect("UseTrans()", "Reve::DigitSetEditor", this, "Update()");
50 fHMTrans->Connect("TransChanged()", "Reve::DigitSetEditor", this, "Update()");
51 AddFrame(fHMTrans, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 0, 0));
52
53
54 MakeTitle("Palette controls");
55
56 fPalette = new RGBAPaletteSubEditor(this);
57 fPalette->Connect("Changed", "Reve::DigitSetEditor", this, "Update()");
58 AddFrame(fPalette, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 0, 0));
59
60 CreateInfoTab();
61}
62
cec82a67 63//______________________________________________________________________________
32e219c2 64DigitSetEditor::~DigitSetEditor()
cec82a67 65{
66 // Destructor. Noop.
67}
32e219c2 68
69/*************************************************************************/
cec82a67 70
71//______________________________________________________________________________
32e219c2 72void DigitSetEditor::CreateInfoTab()
73{
cec82a67 74 // Create information tab.
32e219c2 75
76 fInfoFrame = CreateEditorTabSubFrame("Info");
77
78 TGCompositeFrame *title1 = new TGCompositeFrame(fInfoFrame, 180, 10,
79 kHorizontalFrame |
80 kLHintsExpandX |
81 kFixedWidth |
82 kOwnBackground);
83
84 title1->AddFrame(new TGLabel(title1, "DigitSet Info"),
85 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
86 title1->AddFrame(new TGHorizontal3DLine(title1),
87 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
88 fInfoFrame->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
89
90
91 fHistoButtFrame = new TGHorizontalFrame(fInfoFrame);
92 TGTextButton* b = 0;
93 b = new TGTextButton(fHistoButtFrame, "Histo");
94 b->SetToolTipText("Show histogram over full range.");
95 fHistoButtFrame->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
96 b->Connect("Clicked()", "Reve::DigitSetEditor", this, "DoHisto()");
97
98 b = new TGTextButton(fHistoButtFrame, "Range Histo");
99 b->SetToolTipText("Show histogram over selected range.");
100 fHistoButtFrame->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
101 b->Connect("Clicked()", "Reve::DigitSetEditor", this, "DoRangeHisto()");
102 fInfoFrame->AddFrame(fHistoButtFrame, new TGLayoutHints(kLHintsExpandX, 2, 0, 0, 0));
103}
104
105/**************************************************************************/
106
cec82a67 107//______________________________________________________________________________
32e219c2 108void DigitSetEditor::SetModel(TObject* obj)
109{
cec82a67 110 // Set model object.
111
32e219c2 112 fM = dynamic_cast<DigitSet*>(obj);
113
114 fHMTrans->SetDataFromTrans(&fM->fHMTrans);
115
116 if (fM->fValueIsColor || fM->fPalette == 0) {
117 fPalette->UnmapWindow();
118 } else {
119 fPalette->SetModel(fM->fPalette);
120 fPalette->MapWindow();
121 }
122
32e219c2 123 if (fM->fHistoButtons)
124 fHistoButtFrame->MapWindow();
125 else
126 fHistoButtFrame->UnmapWindow();
127}
128
129/**************************************************************************/
130
cec82a67 131//______________________________________________________________________________
32e219c2 132void DigitSetEditor::DoHisto()
133{
cec82a67 134 // Show histogram slot.
135
32e219c2 136 Int_t min, max;
137 if (fM->fPalette) {
138 min = fM->fPalette->GetLowLimit();
139 max = fM->fPalette->GetHighLimit();
140 } else {
141 fM->ScanMinMaxValues(min, max);
142 }
143 PlotHisto(min, max);
144}
145
cec82a67 146//______________________________________________________________________________
32e219c2 147void DigitSetEditor::DoRangeHisto()
148{
cec82a67 149 // Show ranged histogram slot.
150
32e219c2 151 Int_t min, max;
152 if (fM->fPalette) {
153 min = fM->fPalette->GetMinVal();
154 max = fM->fPalette->GetMaxVal();
155 } else {
156 fM->ScanMinMaxValues(min, max);
157 }
158 PlotHisto(min, max);
159}
160
cec82a67 161//______________________________________________________________________________
32e219c2 162void DigitSetEditor::PlotHisto(Int_t min, Int_t max)
163{
cec82a67 164 // Plots a histogram from digit vales with given range.
165
32e219c2 166 Int_t nbins = max-min+1;
167 while (nbins > 200)
168 nbins /= 2;
169
170 TH1F* h = new TH1F(fM->GetName(), fM->GetTitle(), nbins, min-0.5, max+0.5);
171 h->SetDirectory(0);
172 h->SetBit(kCanDelete);
173 VoidCPlex::iterator qi(fM->fPlex);
174 while (qi.next())
175 h->Fill(((DigitSet::DigitBase*)qi())->fValue);
176
177 gStyle->SetOptStat(1111111);
178 h->Draw();
179 gPad->Modified();
180 gPad->Update();
181}