]>
Commit | Line | Data |
---|---|---|
f0f9d9a8 | 1 | // $Header$ |
2 | ||
3 | #include "QuadSetEditor.h" | |
4 | #include <Reve/QuadSet.h> | |
5 | ||
6 | #include <Reve/RGValuators.h> | |
7 | #include <Reve/ZTransEditor.h> | |
8 | #include <Reve/RGBAPaletteEditor.h> | |
9 | ||
10 | #include <TVirtualPad.h> | |
11 | #include <TColor.h> | |
12 | #include <TH1F.h> | |
13 | #include <TStyle.h> | |
14 | ||
15 | #include <TGLabel.h> | |
16 | #include <TGButton.h> | |
17 | #include <TGNumberEntry.h> | |
18 | #include <TGColorSelect.h> | |
19 | #include <TGDoubleSlider.h> | |
20 | ||
21 | using namespace Reve; | |
22 | ||
23 | //______________________________________________________________________ | |
24 | // QuadSetEditor | |
25 | // | |
26 | ||
27 | ClassImp(QuadSetEditor) | |
28 | ||
29 | QuadSetEditor::QuadSetEditor(const TGWindow *p, Int_t width, Int_t height, | |
30 | UInt_t options, Pixel_t back) : | |
31 | TGedFrame(p, width, height, options | kVerticalFrame, back), | |
32 | fM(0), | |
33 | fHMTrans (0), | |
34 | fPalette (0) | |
35 | // Initialize widget pointers to 0 | |
36 | { | |
37 | MakeTitle("Transformation matrix"); | |
38 | ||
39 | fHMTrans = new ZTransSubEditor(this); | |
40 | fHMTrans->Connect("UseTrans()", "Reve::QuadSetEditor", this, "Update()"); | |
41 | fHMTrans->Connect("TransChanged()", "Reve::QuadSetEditor", this, "Update()"); | |
42 | AddFrame(fHMTrans, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 0, 0)); | |
43 | ||
44 | ||
45 | MakeTitle("Palette controls"); | |
46 | ||
47 | fPalette = new RGBAPaletteSubEditor(this); | |
48 | fPalette->Connect("Changed", "Reve::QuadSetEditor", this, "Update()"); | |
49 | AddFrame(fPalette, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 0, 0)); | |
50 | ||
51 | ||
52 | MakeTitle("QuadSet"); | |
53 | ||
54 | fHistoButtFrame = new TGHorizontalFrame(this); | |
55 | { | |
56 | TGTextButton* b = 0; | |
57 | ||
58 | b = new TGTextButton(fHistoButtFrame, "Histo"); | |
59 | b->SetToolTipText("Show histogram over full range."); | |
60 | fHistoButtFrame->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0)); | |
61 | b->Connect("Clicked()", "Reve::QuadSetEditor", this, "DoHisto()"); | |
62 | ||
63 | b = new TGTextButton(fHistoButtFrame, "Range Histo"); | |
64 | b->SetToolTipText("Show histogram over selected range."); | |
65 | fHistoButtFrame->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0)); | |
66 | b->Connect("Clicked()", "Reve::QuadSetEditor", this, "DoRangeHisto()"); | |
67 | } | |
68 | AddFrame(fHistoButtFrame, new TGLayoutHints(kLHintsExpandX, 2, 0, 0, 0)); | |
69 | } | |
70 | ||
71 | QuadSetEditor::~QuadSetEditor() | |
72 | {} | |
73 | ||
74 | /**************************************************************************/ | |
75 | ||
76 | void QuadSetEditor::SetModel(TObject* obj) | |
77 | { | |
78 | fM = dynamic_cast<QuadSet*>(obj); | |
79 | ||
80 | fHMTrans->SetDataFromTrans(&fM->fHMTrans); | |
81 | ||
82 | if (fM->fValueIsColor || fM->fPalette == 0) { | |
83 | fPalette->UnmapWindow(); | |
84 | } else { | |
85 | fPalette->SetModel(fM->fPalette); | |
86 | fPalette->MapWindow(); | |
87 | } | |
88 | ||
89 | ||
90 | // Set values of widgets | |
91 | // fXYZZ->SetValue(fM->GetXYZZ()); | |
92 | ||
93 | if (fM->fHistoButtons) | |
94 | fHistoButtFrame->MapWindow(); | |
95 | else | |
96 | fHistoButtFrame->UnmapWindow(); | |
97 | } | |
98 | ||
99 | /**************************************************************************/ | |
100 | ||
101 | void QuadSetEditor::DoHisto() | |
102 | { | |
103 | Int_t min, max; | |
104 | if (fM->fPalette) { | |
105 | min = fM->fPalette->GetLowLimit(); | |
106 | max = fM->fPalette->GetHighLimit(); | |
107 | } else { | |
108 | fM->ScanMinMaxValues(min, max); | |
109 | } | |
110 | PlotHisto(min, max); | |
111 | } | |
112 | ||
113 | void QuadSetEditor::DoRangeHisto() | |
114 | { | |
115 | Int_t min, max; | |
116 | if (fM->fPalette) { | |
117 | min = fM->fPalette->GetMinVal(); | |
118 | max = fM->fPalette->GetMaxVal(); | |
119 | } else { | |
120 | fM->ScanMinMaxValues(min, max); | |
121 | } | |
122 | PlotHisto(min, max); | |
123 | } | |
124 | ||
125 | void QuadSetEditor::PlotHisto(Int_t min, Int_t max) | |
126 | { | |
127 | Int_t nbins = max-min+1; | |
128 | while (nbins > 200) | |
129 | nbins /= 2; | |
130 | ||
131 | TH1F* h = new TH1F(fM->GetName(), fM->GetTitle(), nbins, min-0.5, max+0.5); | |
132 | h->SetDirectory(0); | |
133 | h->SetBit(kCanDelete); | |
134 | VoidCPlex::iterator qi(fM->fPlex); | |
135 | while (qi.next()) | |
136 | h->Fill(((QuadSet::QuadBase*)qi())->fValue); | |
137 | ||
138 | gStyle->SetOptStat(1111111); | |
139 | h->Draw(); | |
140 | gPad->Modified(); | |
141 | gPad->Update(); | |
142 | } |