forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveDigitSetEditor.cxx
164 lines (133 loc) · 5.07 KB
/
TEveDigitSetEditor.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// @(#)root/eve:$Id$
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "TEveDigitSetEditor.h"
#include "TEveDigitSet.h"
#include "TEveGValuators.h"
//#include "TEveTransEditor.h"
#include "TEveRGBAPaletteEditor.h"
#include "TEveGedEditor.h"
#include "TVirtualPad.h"
#include "TColor.h"
#include "TH1F.h"
#include "TStyle.h"
#include "TGLabel.h"
#include "TG3DLine.h"
#include "TGButton.h"
#include "TGNumberEntry.h"
#include "TGColorSelect.h"
#include "TGDoubleSlider.h"
/** \class TEveDigitSetEditor
\ingroup TEve
Editor for TEveDigitSet class.
*/
ClassImp(TEveDigitSetEditor);
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TEveDigitSetEditor::TEveDigitSetEditor(const TGWindow *p, Int_t width, Int_t height,
UInt_t options, Pixel_t back) :
TGedFrame(p, width, height, options | kVerticalFrame, back),
fM (0),
fPalette (0),
fHistoButtFrame(0),
fInfoFrame(0)
{
MakeTitle("Palette controls");
fPalette = new TEveRGBAPaletteSubEditor(this);
AddFrame(fPalette, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 0, 0));
fPalette->Connect("Changed()", "TEveDigitSetEditor", this, "Update()");
CreateInfoTab();
}
////////////////////////////////////////////////////////////////////////////////
/// Create information tab.
void TEveDigitSetEditor::CreateInfoTab()
{
fInfoFrame = CreateEditorTabSubFrame("Info");
TGCompositeFrame *title1 = new TGCompositeFrame(fInfoFrame, 180, 10,
kHorizontalFrame |
kLHintsExpandX |
kFixedWidth |
kOwnBackground);
title1->AddFrame(new TGLabel(title1, "TEveDigitSet Info"),
new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
title1->AddFrame(new TGHorizontal3DLine(title1),
new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
fInfoFrame->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
fHistoButtFrame = new TGHorizontalFrame(fInfoFrame);
TGTextButton* b = 0;
b = new TGTextButton(fHistoButtFrame, "Histo");
b->SetToolTipText("Show histogram over full range.");
fHistoButtFrame->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
b->Connect("Clicked()", "TEveDigitSetEditor", this, "DoHisto()");
b = new TGTextButton(fHistoButtFrame, "Range Histo");
b->SetToolTipText("Show histogram over selected range.");
fHistoButtFrame->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
b->Connect("Clicked()", "TEveDigitSetEditor", this, "DoRangeHisto()");
fInfoFrame->AddFrame(fHistoButtFrame, new TGLayoutHints(kLHintsExpandX, 2, 0, 0, 0));
}
////////////////////////////////////////////////////////////////////////////////
/// Set model object.
void TEveDigitSetEditor::SetModel(TObject* obj)
{
fM = dynamic_cast<TEveDigitSet*>(obj);
if (fM->fValueIsColor || fM->fPalette == 0) {
fPalette->UnmapWindow();
} else {
fPalette->SetModel(fM->fPalette);
fPalette->MapWindow();
}
if (fM->fHistoButtons)
fHistoButtFrame->MapWindow();
else
fHistoButtFrame->UnmapWindow();
}
////////////////////////////////////////////////////////////////////////////////
/// Show histogram slot.
void TEveDigitSetEditor::DoHisto()
{
Int_t min, max;
if (fM->fPalette) {
min = fM->fPalette->GetLowLimit();
max = fM->fPalette->GetHighLimit();
} else {
fM->ScanMinMaxValues(min, max);
}
PlotHisto(min, max);
}
////////////////////////////////////////////////////////////////////////////////
/// Show ranged histogram slot.
void TEveDigitSetEditor::DoRangeHisto()
{
Int_t min, max;
if (fM->fPalette) {
min = fM->fPalette->GetMinVal();
max = fM->fPalette->GetMaxVal();
} else {
fM->ScanMinMaxValues(min, max);
}
PlotHisto(min, max);
}
////////////////////////////////////////////////////////////////////////////////
/// Plots a histogram from digit vales with given range.
void TEveDigitSetEditor::PlotHisto(Int_t min, Int_t max)
{
Int_t nbins = max-min+1;
while (nbins > 200)
nbins /= 2;
TH1F* h = new TH1F(fM->GetName(), fM->GetTitle(), nbins, min-0.5, max+0.5);
h->SetDirectory(0);
h->SetBit(kCanDelete);
TEveChunkManager::iterator qi(fM->fPlex);
while (qi.next())
h->Fill(((TEveDigitSet::DigitBase_t*)qi())->fValue);
gStyle->SetOptStat(1111111);
h->Draw();
gPad->Modified();
gPad->Update();
}