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