JG ROOT Tools libraries  version 5.0 - august 2014
RGHistoTools.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file RGHistoTools.hh
3  *
4  * Include file for class RGHistoTools
5  */
6 //======================================================================
7 
8 #ifndef RG_HISTO_TOOLS_HH
9 #define RG_HISTO_TOOLS_HH
10 
11 #include "RGHistoWindow.hh"
12 #include "GStringList.hh"
13 
14 #include <TLine.h>
15 #include <TAttLine.h>
16 
17 #include <TSystem.h>
18 #include <TPad.h>
19 #include <TCanvas.h>
20 #include <TH1.h>
21 #include <TGFrame.h>
22 #include <TGCanvas.h>
23 #include <TGButton.h>
24 #include <TGLabel.h>
25 #include <TGNumberEntry.h>
26 #include <TGComboBox.h>
27 #include <TRootEmbeddedCanvas.h>
28 #include <TGDoubleSlider.h>
29 #include <TGSplitter.h>
30 #include <TGMenu.h>
31 
32 #include <TColor.h>
33 #include <TGFileDialog.h>
34 #include <TFile.h>
35 
36 #include "RGHistoPlotAttrSelect.hh"
37 
38 #include "RGFitPeak.hh"
39 #include "RGFitDecay.hh"
40 #include "RGFitGaus2D.hh"
41 
42 //======================================================================
43 /*! \class RGHistoTools
44  *
45  * This class defines a graphical user interface to display histograms
46  * from ROOT files.
47  *
48  * It also proposes several simple tools for histograms:
49  * statistics, fitting tools,...
50  */
52 {
53  //------------------------------------------------------------
54  /*! \object_doc{RGHistoTools} */
56  //------------------------------------------------------------
57 
58  ///! Interface menus identification
60  {
61  menuHTFileOpen = 0x00000001,
62  menuHTFileSave = 0x00000002,
63  menuHTFileSaveSelection = 0x00000003,
64  menuHTFileExport = 0x00000011,
65  menuHTFilePrint = 0x00000012,
66  menuHTFileQuit = 0x00000015,
67 
68  menuHTHistoSelect = 0x00000100,
69  menuHTHistoStat = 0x00000140,
70  menuHTHistoFitPeak = 0x00000141,
71  menuHTHistoFitDecay = 0x00000142,
72  menuHTHistoFitGaus2D = 0x00000143
73  };
74 
75  protected:
76 
77  static string root_file_name; ///< Histogram file name
78  static string export_name; ///< Exported file name
79 
80  // variables pour l'interface
81  bool constructed; ///< Flag if GUI is constructed
82  const TGWindow * main_window; ///< Main window of calling application
83 
84  // options pour l'affichage
85  TAttLine att_line_1d; ///< 1D histograms attributes
86  TAttFill att_fill_1d; ///< 1D histograms attributes
87 
88  TAttLine att_line_2d; ///< 2D histograms attributes
89  TAttMarker att_marker_2d; ///< 2D histograms attributes
90  TAttLine att_fill_2d; ///< 2D histograms attributes
91 
92  TAttMarker att_marker_3d; ///< 3D histograms attributes
93 
94  // liste d'histogrammes
95  Int_t previous_dim; ///< Previously displayed histogram dimension
96 
97  Int_t histo_num; ///< Number of histograms read in the file
98  Int_t histo_sel; ///< Selected histogram number (none = -1)
99 #ifndef __MAKECINT__
100  TH1 ** histo_list; ///< Array of histogram pointers
101  string * histo_names; ///< Array of histogram names
102 
103  // données mémorisées pour les fits
104  RFitDataPeak * peak_fit_data; ///< Fit data
105  RFitDataDecay * decay_fit_data; ///< Fit data
107 #endif
108 
109  // Menus
110  TGMenuBar * w_menu_bar; ///< Application menu bar
111  TGPopupMenu * w_menu_file; ///< Files menu
112  TGPopupMenu * w_menu_histo; ///< Histogram menu
113  TGPopupMenu * w_menu_histo_fit; ///< Histogram fit menu
114 
115  // Widgets de l'interface
116  TGVerticalFrame * w_action_frame; ///< Actions frame
117  TGGroupFrame * w_histo_group; ///< Histogram information frame
118  TGVerticalFrame * w_histo_frame_v1; ///< Labels frame
119  TGVerticalFrame * w_histo_frame_v2; ///< Frame for inputs
120  TGTextEntry * w_histo_file_entry; ///< File name widget
121  TGHorizontalFrame * w_histo_name_frame; ///< Frame for histogram selection
122  TGTextEntry * w_histo_name_entry; ///< Histogram name widget
123  TGTextButton * w_histo_prev; ///< Previous histogram button
124  TGTextButton * w_histo_next; ///< Next histogram button
125  TGVerticalFrame * w_histo_frame_v3; ///< Buttons frame
126  TGTextButton * w_histo_file_browse; ///< File browse button
127  TGTextButton * w_histo_select; ///< Histogram selection button
128 
129  RGHistoPlotAttrSelect * w_histo_1d_attr; ///< 1D histogram attributes widget
130  RGHistoPlotAttrSelect * w_histo_2d_attr; ///< 2D histogram attributes widget
131  RGHistoPlotAttrSelect * w_histo_3d_attr; ///< 3D histogram attributes widget
132 
133  TGGroupFrame * w_tools_group; ///< Tools frame
134  TGHorizontalFrame * w_fit_frame; ///< Fit tools frams
135  TGCheckButton * w_fit_error_button; ///< Fit with error histogram button
136  TGTextButton * w_stat_button; ///< Statistics button
137  TGTextButton * w_fit_peak_button; ///< Fit button
138  TGTextButton * w_fit_decay_button; ///< Fit button
139  TGTextButton * w_fit_gaus2d_button; ///< Fit button
140 
141  TGHorizontalFrame * w_buttons_frame; ///< Buttons frame
142 
143  //------------------------------------------------------------
144  public:
145  // Constructor
146  RGHistoTools ( const TGWindow * main = NULL,
147  const string &fname = "",
148  const string &hname = "",
149  const bool autostart = true );
150 
151  protected:
152  RGHistoTools ( const RGHistoTools & original );
153 
154  public:
155  // Destructor
156  virtual ~RGHistoTools ( );
157 
158  //------------------------------------------------------------
159  protected:
160  void ClassInit ( );
161 
162  public:
163  //------------------------------------------------------------
164  // Interface management
165  virtual void Construct ( );
166  virtual void ConstructMenu ( );
167  virtual void ConstructActions ( );
168  virtual void ConstructActionsHisto ( );
169  virtual void ConstructActionsDisplay ( );
170  virtual void ConstructActionsTools ( );
171 
172  virtual void MapSubwindows ( );
173  virtual void RemapToolsFrame ( );
174  virtual void UpdateWindowTitle ( );
175 
176  //------------------------------------------------------------
177  // Functions
178  virtual void Init ( );
179  virtual void Clear ( );
180 
181  virtual Int_t SetFile ( const string &file = "" );
182  virtual Int_t SetHisto ( const string &histo = "" );
183  virtual void PlotHisto ( );
184 
185  //------------------------------------------------------------
186  // Pad actions
187  protected:
188  virtual void UpdateDisplay ( );
189 
190  //------------------------------------------------------------
191  // Updates
192  virtual void FileSelected ( );
193  virtual void HistoSelected ( const bool redraw = true );
194 
195  virtual TH1 * SelectSimilarHisto ( const bool current = false );
196 
197  //----------------------------------------------------------
198  // ACTIONS
199  virtual void PrintPad ( ) const;
200  virtual void ExportPad ( ) const;
201 
202  //----------------------------------------------------------
203  // SLOTS
204  public:
205  virtual void MenuActivated ( Int_t menu );
206 
207  virtual void HistoFileReturnPressed ( );
208  virtual void HistoNameReturnPressed ( );
209  virtual void HistoFileBrowseButton ( );
210  virtual void HistoSelectButton ( );
211  virtual void HistoPrevButton ( );
212  virtual void HistoNextButton ( );
213 
214  virtual void HistoAttChanged ( const bool redraw = true );
215  virtual void PlotModeChanged ( const bool redraw = true );
216 
217  virtual void StatButtonClicked ( );
218  virtual void PeakFitButtonClicked ( );
219  virtual void DecayFitButtonClicked ( );
220  virtual void Gaus2DFitButtonClicked ( );
221 
222  //------------------------------------------------------------
223  /*! For ROOT dictionary.*/
224  public:
226 };
227 
228 //----------------------------------------------------------------------
229 // Inline functions
230 #include "icc/RGHistoTools.icc"
231 
232 //======================================================================
233 #endif
virtual void PeakFitButtonClicked()
Definition: RGHistoTools.cpp:1851
TGTextButton * w_fit_decay_button
Fit button.
Definition: RGHistoTools.hh:138
TGTextButton * w_histo_next
Next histogram button.
Definition: RGHistoTools.hh:124
ClassDef(RGHistoTools, 0)
TAttLine att_line_1d
1D histograms attributes
Definition: RGHistoTools.hh:85
static string export_name
Exported file name.
Definition: RGHistoTools.hh:78
virtual void HistoSelectButton()
Definition: RGHistoTools.cpp:1392
TH1 ** histo_list
Array of histogram pointers.
Definition: RGHistoTools.hh:100
virtual void UpdateWindowTitle()
Definition: RGHistoTools.cpp:680
Definition: RFitDataDecay.hh:28
TGTextButton * w_stat_button
Statistics button.
Definition: RGHistoTools.hh:136
virtual TH1 * SelectSimilarHisto(const bool current=false)
Definition: RGHistoTools.cpp:1133
TGVerticalFrame * w_action_frame
Actions frame.
Definition: RGHistoTools.hh:116
virtual void DecayFitButtonClicked()
Definition: RGHistoTools.cpp:1911
HistoToolsMenus
! Interface menus identification
Definition: RGHistoTools.hh:59
GObject(RGHistoTools)
Int_t previous_dim
Previously displayed histogram dimension.
Definition: RGHistoTools.hh:95
TGTextButton * w_histo_file_browse
File browse button.
Definition: RGHistoTools.hh:126
TAttLine att_line_2d
2D histograms attributes
Definition: RGHistoTools.hh:88
virtual void ConstructActionsTools()
Definition: RGHistoTools.cpp:451
virtual void UpdateDisplay()
Definition: RGHistoTools.cpp:979
TGPopupMenu * w_menu_histo_fit
Histogram fit menu.
Definition: RGHistoTools.hh:113
TGGroupFrame * w_tools_group
Tools frame.
Definition: RGHistoTools.hh:133
virtual void ConstructActions()
Definition: RGHistoTools.cpp:242
TGHorizontalFrame * w_histo_name_frame
Frame for histogram selection.
Definition: RGHistoTools.hh:121
virtual void HistoFileReturnPressed()
Definition: RGHistoTools.cpp:1315
virtual void ConstructActionsDisplay()
Definition: RGHistoTools.cpp:389
TGTextEntry * w_histo_file_entry
File name widget.
Definition: RGHistoTools.hh:120
TGMenuBar * w_menu_bar
Application menu bar.
Definition: RGHistoTools.hh:110
TGPopupMenu * w_menu_file
Files menu.
Definition: RGHistoTools.hh:111
Int_t histo_num
Number of histograms read in the file.
Definition: RGHistoTools.hh:97
virtual Int_t SetFile(const string &file="")
Definition: RGHistoTools.cpp:762
TAttFill att_fill_1d
1D histograms attributes
Definition: RGHistoTools.hh:86
TGTextButton * w_fit_gaus2d_button
Fit button.
Definition: RGHistoTools.hh:139
TGTextButton * w_histo_select
Histogram selection button.
Definition: RGHistoTools.hh:127
RFitDataGaus2D * gaus2d_fit_data
Fit data.
Definition: RGHistoTools.hh:106
virtual void HistoAttChanged(const bool redraw=true)
Definition: RGHistoTools.cpp:1447
virtual ~RGHistoTools()
Definition: RGHistoTools.cpp:84
virtual void MapSubwindows()
Definition: RGHistoTools.cpp:531
Definition: RFitDataGaus2D.hh:30
Definition: RFitDataPeak.hh:28
virtual void FileSelected()
Definition: RGHistoTools.cpp:1008
virtual void HistoNextButton()
Definition: RGHistoTools.cpp:1433
virtual void PrintPad() const
Definition: RGHistoTools.cpp:1236
virtual void HistoSelected(const bool redraw=true)
Definition: RGHistoTools.cpp:1058
static string root_file_name
Histogram file name.
Definition: RGHistoTools.hh:77
RFitDataPeak * peak_fit_data
Fit data.
Definition: RGHistoTools.hh:104
virtual void HistoFileBrowseButton()
Definition: RGHistoTools.cpp:1357
virtual void HistoNameReturnPressed()
Definition: RGHistoTools.cpp:1334
virtual Int_t SetHisto(const string &histo="")
Definition: RGHistoTools.cpp:882
virtual void PlotModeChanged(const bool redraw=true)
Definition: RGHistoTools.cpp:1472
TGGroupFrame * w_histo_group
Histogram information frame.
Definition: RGHistoTools.hh:117
TGVerticalFrame * w_histo_frame_v1
Labels frame.
Definition: RGHistoTools.hh:118
virtual void Init()
Definition: RGHistoTools.cpp:707
virtual void ExportPad() const
Definition: RGHistoTools.cpp:1209
RGHistoTools(const TGWindow *main=NULL, const string &fname="", const string &hname="", const bool autostart=true)
Definition: RGHistoTools.cpp:35
virtual void Clear()
Definition: RGHistoTools.cpp:722
TGHorizontalFrame * w_fit_frame
Fit tools frams.
Definition: RGHistoTools.hh:134
TGTextButton * w_histo_prev
Previous histogram button.
Definition: RGHistoTools.hh:123
virtual void ConstructActionsHisto()
Definition: RGHistoTools.cpp:252
virtual void ConstructMenu()
Definition: RGHistoTools.cpp:179
virtual void MenuActivated(Int_t menu)
Definition: RGHistoTools.cpp:1254
RGHistoPlotAttrSelect * w_histo_2d_attr
2D histogram attributes widget
Definition: RGHistoTools.hh:130
virtual void RemapToolsFrame()
Definition: RGHistoTools.cpp:541
string * histo_names
Array of histogram names.
Definition: RGHistoTools.hh:101
TGHorizontalFrame * w_buttons_frame
Buttons frame.
Definition: RGHistoTools.hh:141
TGVerticalFrame * w_histo_frame_v3
Buttons frame.
Definition: RGHistoTools.hh:125
RGHistoPlotAttrSelect * w_histo_1d_attr
1D histogram attributes widget
Definition: RGHistoTools.hh:129
void ClassInit()
Definition: RGHistoTools.cpp:100
const TGWindow * main_window
Main window of calling application.
Definition: RGHistoTools.hh:82
Definition: RGHistoWindow.hh:97
TAttMarker att_marker_2d
2D histograms attributes
Definition: RGHistoTools.hh:89
Definition: RGHistoPlotAttrSelect.hh:66
virtual void StatButtonClicked()
Definition: RGHistoTools.cpp:1504
virtual void Gaus2DFitButtonClicked()
Definition: RGHistoTools.cpp:1971
virtual void HistoPrevButton()
Definition: RGHistoTools.cpp:1423
TGTextButton * w_fit_peak_button
Fit button.
Definition: RGHistoTools.hh:137
TAttLine att_fill_2d
2D histograms attributes
Definition: RGHistoTools.hh:90
TAttMarker att_marker_3d
3D histograms attributes
Definition: RGHistoTools.hh:92
TGCheckButton * w_fit_error_button
Fit with error histogram button.
Definition: RGHistoTools.hh:135
virtual void Construct()
Definition: RGHistoTools.cpp:158
virtual void PlotHisto()
Definition: RGHistoTools.cpp:949
RGHistoPlotAttrSelect * w_histo_3d_attr
3D histogram attributes widget
Definition: RGHistoTools.hh:131
TGPopupMenu * w_menu_histo
Histogram menu.
Definition: RGHistoTools.hh:112
Definition: RGHistoTools.hh:51
Int_t histo_sel
Selected histogram number (none = -1)
Definition: RGHistoTools.hh:98
bool constructed
Flag if GUI is constructed.
Definition: RGHistoTools.hh:81
TGVerticalFrame * w_histo_frame_v2
Frame for inputs.
Definition: RGHistoTools.hh:119
TGTextEntry * w_histo_name_entry
Histogram name widget.
Definition: RGHistoTools.hh:122
RFitDataDecay * decay_fit_data
Fit data.
Definition: RGHistoTools.hh:105