00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TEveDigitSetEditor.h"
00013 #include "TEveDigitSet.h"
00014
00015 #include "TEveGValuators.h"
00016
00017 #include "TEveRGBAPaletteEditor.h"
00018 #include "TEveGedEditor.h"
00019
00020 #include "TVirtualPad.h"
00021 #include "TColor.h"
00022 #include "TH1F.h"
00023 #include "TStyle.h"
00024
00025 #include "TGLabel.h"
00026 #include "TG3DLine.h"
00027 #include "TGButton.h"
00028 #include "TGNumberEntry.h"
00029 #include "TGColorSelect.h"
00030 #include "TGDoubleSlider.h"
00031
00032
00033
00034
00035
00036
00037 ClassImp(TEveDigitSetEditor)
00038
00039
00040 TEveDigitSetEditor::TEveDigitSetEditor(const TGWindow *p, Int_t width, Int_t height,
00041 UInt_t options, Pixel_t back) :
00042 TGedFrame(p, width, height, options | kVerticalFrame, back),
00043 fM (0),
00044 fPalette (0),
00045
00046 fHistoButtFrame(0),
00047 fInfoFrame(0)
00048 {
00049
00050
00051 MakeTitle("Palette controls");
00052
00053 fPalette = new TEveRGBAPaletteSubEditor(this);
00054 AddFrame(fPalette, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 0, 0));
00055 fPalette->Connect("Changed()", "TEveDigitSetEditor", this, "Update()");
00056
00057 CreateInfoTab();
00058 }
00059
00060
00061
00062
00063 void TEveDigitSetEditor::CreateInfoTab()
00064 {
00065
00066
00067 fInfoFrame = CreateEditorTabSubFrame("Info");
00068
00069 TGCompositeFrame *title1 = new TGCompositeFrame(fInfoFrame, 180, 10,
00070 kHorizontalFrame |
00071 kLHintsExpandX |
00072 kFixedWidth |
00073 kOwnBackground);
00074
00075 title1->AddFrame(new TGLabel(title1, "TEveDigitSet Info"),
00076 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00077 title1->AddFrame(new TGHorizontal3DLine(title1),
00078 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00079 fInfoFrame->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
00080
00081
00082 fHistoButtFrame = new TGHorizontalFrame(fInfoFrame);
00083 TGTextButton* b = 0;
00084 b = new TGTextButton(fHistoButtFrame, "Histo");
00085 b->SetToolTipText("Show histogram over full range.");
00086 fHistoButtFrame->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
00087 b->Connect("Clicked()", "TEveDigitSetEditor", this, "DoHisto()");
00088
00089 b = new TGTextButton(fHistoButtFrame, "Range Histo");
00090 b->SetToolTipText("Show histogram over selected range.");
00091 fHistoButtFrame->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
00092 b->Connect("Clicked()", "TEveDigitSetEditor", this, "DoRangeHisto()");
00093 fInfoFrame->AddFrame(fHistoButtFrame, new TGLayoutHints(kLHintsExpandX, 2, 0, 0, 0));
00094 }
00095
00096
00097
00098
00099 void TEveDigitSetEditor::SetModel(TObject* obj)
00100 {
00101
00102
00103 fM = dynamic_cast<TEveDigitSet*>(obj);
00104
00105 if (fM->fValueIsColor || fM->fPalette == 0) {
00106 fPalette->UnmapWindow();
00107 } else {
00108 fPalette->SetModel(fM->fPalette);
00109 fPalette->MapWindow();
00110 }
00111
00112 if (fM->fHistoButtons)
00113 fHistoButtFrame->MapWindow();
00114 else
00115 fHistoButtFrame->UnmapWindow();
00116 }
00117
00118
00119
00120
00121 void TEveDigitSetEditor::DoHisto()
00122 {
00123
00124
00125 Int_t min, max;
00126 if (fM->fPalette) {
00127 min = fM->fPalette->GetLowLimit();
00128 max = fM->fPalette->GetHighLimit();
00129 } else {
00130 fM->ScanMinMaxValues(min, max);
00131 }
00132 PlotHisto(min, max);
00133 }
00134
00135
00136 void TEveDigitSetEditor::DoRangeHisto()
00137 {
00138
00139
00140 Int_t min, max;
00141 if (fM->fPalette) {
00142 min = fM->fPalette->GetMinVal();
00143 max = fM->fPalette->GetMaxVal();
00144 } else {
00145 fM->ScanMinMaxValues(min, max);
00146 }
00147 PlotHisto(min, max);
00148 }
00149
00150
00151 void TEveDigitSetEditor::PlotHisto(Int_t min, Int_t max)
00152 {
00153
00154
00155 Int_t nbins = max-min+1;
00156 while (nbins > 200)
00157 nbins /= 2;
00158
00159 TH1F* h = new TH1F(fM->GetName(), fM->GetTitle(), nbins, min-0.5, max+0.5);
00160 h->SetDirectory(0);
00161 h->SetBit(kCanDelete);
00162 TEveChunkManager::iterator qi(fM->fPlex);
00163 while (qi.next())
00164 h->Fill(((TEveDigitSet::DigitBase_t*)qi())->fValue);
00165
00166 gStyle->SetOptStat(1111111);
00167 h->Draw();
00168 gPad->Modified();
00169 gPad->Update();
00170 }