GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4CreateNewHistogram.cpp
Go to the documentation of this file.
1 // $Id: TGo4CreateNewHistogram.cpp 1134 2014-01-22 14:53:40Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4CreateNewHistogram.h"
15 
16 #include "TH1.h"
17 #include "TH2.h"
18 #include "TH3.h"
19 #include "TDirectory.h"
20 #include "TROOT.h"
21 #include "TGo4QSettings.h"
22 #include <QButtonGroup>
23 
25  : QDialog( parent)
26 {
27  setObjectName("Go4CreateNewHistogram");
28  setupUi(this);
29  HisName->setText(go4sett->getHistName());
30  HisTitle->setText(go4sett->getHistTitle());
31 
32  HisClassGrp = new QButtonGroup(this);
33  HisClassGrp->addButton(TH1_b, 1);
34  HisClassGrp->addButton(TH2_b, 2);
35  HisClassGrp->addButton(TH3_b, 3);
36 
37  HisTypeGrp = new QButtonGroup(this);
38  HisTypeGrp->addButton(S_b, 1);
39  HisTypeGrp->addButton(D_b, 2);
40  HisTypeGrp->addButton(F_b, 3);
41  HisTypeGrp->addButton(I_b, 4);
42  HisTypeGrp->addButton(C_b, 5);
43 
44  int htype = go4sett->getHistType();
45  HisClassGrp->button(htype / 10)->setChecked(true);
46  HisTypeGrp->button(htype % 10)->setChecked(true);
47 
48  int npoints;
49  double min, max;
50 
51  go4sett->getHistAxisPars(0, npoints, min, max);
52  XNoOfBins->setText(QString::number(npoints));
53  Xmin->setText(QString::number(min));
54  Xmax->setText(QString::number(max));
55 
56  go4sett->getHistAxisPars(1, npoints, min, max);
57  YNoOfBins->setText(QString::number(npoints));
58  Ymin->setText(QString::number(min));
59  Ymax->setText(QString::number(max));
60 
61  go4sett->getHistAxisPars(2, npoints, min, max);
62  ZNoOfBins->setText(QString::number(npoints));
63  Zmin->setText(QString::number(min));
64  Zmax->setText(QString::number(max));
65 
66  fSelectedCmd = 0;
67 }
68 
70 {
71  CreateRemote->setEnabled(on);
72 }
73 
75 {
76  CreateHistogram->setEnabled(on);
77 }
78 
80 {
81  return fSelectedCmd;
82 }
83 
85 {
86  QByteArray bname = HisName->text().toLatin1();
87  QByteArray btitle = HisTitle->text().toLatin1();
88 
89  const char* hname = bname.constData();
90  const char* htitle = btitle.constData();
91 
92  int htype = HisClassGrp->checkedId()*10 + HisTypeGrp->checkedId();
93 
94  int nxbins = XNoOfBins->text().toInt();
95  int nybins = YNoOfBins->text().toInt();
96  int nzbins = ZNoOfBins->text().toInt();
97 
98  double xmin = Xmin->text().toDouble();
99  double xmax = Xmax->text().toDouble();
100  double ymin = Ymin->text().toDouble();
101  double ymax = Ymax->text().toDouble();
102  double zmin = Zmin->text().toDouble();
103  double zmax = Zmax->text().toDouble();
104 
105  go4sett->setHistName(hname);
106  go4sett->setHistTitle(htitle);
107  go4sett->setHistType(htype);
108  go4sett->setHistAxisPars(0, nxbins, xmin, xmax);
109  go4sett->setHistAxisPars(1, nybins, ymin, ymax);
110  go4sett->setHistAxisPars(2, nzbins, zmin, zmax);
111 
112  TDirectory* savdir = gDirectory;
113  gROOT->cd();
114  TH1* h = 0;
115  switch(htype) {
116  case 11: h = new TH1S(hname, htitle, nxbins, xmin, xmax); break;
117  case 12: h = new TH1D(hname, htitle, nxbins, xmin, xmax); break;
118  case 13: h = new TH1F(hname, htitle, nxbins, xmin, xmax); break;
119  case 14: h = new TH1I(hname, htitle, nxbins, xmin, xmax); break;
120  case 15: h = new TH1C(hname, htitle, nxbins, xmin, xmax); break;
121  case 21: h = new TH2S(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
122  case 22: h = new TH2D(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
123  case 23: h = new TH2F(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
124  case 24: h = new TH2I(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
125  case 25: h = new TH2C(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax); break;
126  case 31: h = new TH3S(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
127  case 32: h = new TH3D(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
128  case 33: h = new TH3F(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
129  case 34: h = new TH3I(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
130  case 35: h = new TH3C(hname, htitle, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax); break;
131  }
132 
133  if (savdir!=0) savdir->cd();
134 
135  return h;
136 }
137 
139 {
140  fSelectedCmd = 1;
141  accept();
142 }
143 
145 {
146  fSelectedCmd = 2;
147  accept();
148 }
149 
150 
void setHistType(int value)
QString getHistName()
void getHistAxisPars(int naxis, int &npoints, double &min, double &max)
void setHistAxisPars(int naxis, int npoints, double min, double max)
void setHistName(const QString &value)
TGo4QSettings * go4sett
void setHistTitle(const QString &value)
TGo4CreateNewHistogram(QWidget *parent=0)
QString getHistTitle()