GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4HistogramInfo.cpp
Go to the documentation of this file.
1 // $Id$
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 fuer 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 "TGo4HistogramInfo.h"
15 
16 #include "TClass.h"
17 #include "TH1.h"
18 #include "TDatime.h"
19 
20 #include "TGo4BrowserProxy.h"
21 #include "TGo4Log.h"
22 #include "TGo4HistogramStatus.h"
23 
24 TGo4HistogramInfo::TGo4HistogramInfo(QWidget *parent, const char *name)
25  : QGo4Widget(parent, name)
26 {
27  setupUi(this);
28  QObject::connect(HisInfoButton, &QPushButton::clicked, this, &TGo4HistogramInfo::HisInfoButton_clicked);
29  QObject::connect(HisPrintButton, &QPushButton::clicked, this, &TGo4HistogramInfo::HisPrintButton_clicked);
30  QObject::connect(HisDrawButton, &QPushButton::clicked, this, &TGo4HistogramInfo::HisDrawButton_clicked);
31  QObject::connect(PrintLog, &QPushButton::clicked, this, &TGo4HistogramInfo::PrintLog_clicked);
32 
33  setWindowTitle("Histogram Info:");
34  ResetWidget();
35 }
36 
38 {
39  ServiceCall("PrintAnalysisHistograms");
40 }
41 
43 {
44  DrawItem(HisnameLbl->text());
45 }
46 
48 {
49  WorkWithHistogram(HisnameLbl->text().toLatin1().constData());
50 }
51 
52 bool TGo4HistogramInfo::IsAcceptDrag(const char *itemname, TClass *cl, int kind)
53 {
54  return !cl ? false : cl->InheritsFrom(TH1::Class());
55 }
56 
57 void TGo4HistogramInfo::DropItem(const char *itemname, TClass *cl, int kind)
58 {
59  if (!cl) return;
60 
61  if (cl->InheritsFrom(TH1::Class()))
62  WorkWithHistogram(itemname);
63 }
64 
65 void TGo4HistogramInfo::linkedObjectUpdated(const char *linkname, TObject *obj)
66 {
67  TGo4HistogramStatus* hstate = dynamic_cast<TGo4HistogramStatus*>(obj);
68  if (hstate)
69  RefreshHistogramInfo(hstate);
70  else
71  RefreshHistogramInfo(dynamic_cast<TH1 *> (obj));
72 }
73 
74 void TGo4HistogramInfo::WorkWithHistogram(const char *itemname)
75 {
76  ResetWidget();
77 
78  TGo4BrowserProxy *br = Browser();
79  if (!br) return;
80 
81  HisnameLbl->setText(itemname);
82 
83  if (br->IsAnalysisItem(itemname)) {
84  TGo4Slot *tgtslot = AddSlot("HistStatus");
85  br->RequestObjectStatus(itemname, tgtslot);
86  // addlink to observe when histogram is removed
87  AddLink(itemname, "HistogramLock");
88  } else {
89  AddLink(itemname, "Histogram");
90  TH1 *h1 = GetLinkedCast<TH1>("Histogram", 2);
92  }
93  setFocus();
94 }
95 
97 {
99 
100  HisnameLbl->setText("");
101 
102  PropertyBox->item(HISTITLE)->setText("Title");
103  PropertyBox->item(HISCLASS)->setText("Class");
104  PropertyBox->item(HISENTRIES)->setText("Entries");
105  PropertyBox->item(HISX)->setText("Xrange");
106  PropertyBox->item(HISXSTAT)->setText("Xstats");
107  PropertyBox->item(HISY)->setText("Yrange");
108  PropertyBox->item(HISYSTAT)->setText("Ystats");
109  PropertyBox->item(HISZ)->setText("Title");
110  PropertyBox->item(HISZSTAT)->setText("Zstats");
111  PropertyBox->item(HISSIZE)->setText("Size");
112  TDatime now;
113  PropertyBox->item(HISTIME)->setText(now.AsSQLString());
114  ensurePolished();
115  update();
116  show();
117  raise();
118 }
119 
121 {
122  if (!h1) {
123  ResetWidget();
124  } else {
125  TGo4HistogramStatus hstate(h1, kTRUE);
126  RefreshHistogramInfo(&hstate);
127  }
128 }
129 
131 {
132  if(!hstate) return;
133  TString str;
134  PropertyBox->item(HISTITLE)->setText(hstate->GetTitle());
135  PropertyBox->item(HISCLASS)->setText(hstate->GetObjectClass());
136  str.Form("Entries:%.5g",hstate->GetEntries());
137  PropertyBox->item(HISENTRIES)->setText(str.Data());
138  str.Form("X:%d [%.3g,%.3g]",hstate->GetXbins(), hstate->GetXmin(), hstate->GetXmax());
139  PropertyBox->item(HISX)->setText(str.Data());
140  str.Form("Xm=%.1f, Xrms=%.1f", hstate->GetXmean(), hstate->GetXrms());
141  PropertyBox->item(HISXSTAT)->setText(str.Data());
142 
143  PropertyBox->item(HISY)->setText("-");
144  PropertyBox->item(HISYSTAT)->setText("-");
145  PropertyBox->item(HISZ)->setText("-");
146  PropertyBox->item(HISZSTAT)->setText("-");
147 
148  int dime = hstate->GetDimension();
149  if(dime>1) {
150  str.Form("Y:%d [%.3g,%.3g]",hstate->GetYbins(), hstate->GetYmin(), hstate->GetYmax());
151  PropertyBox->item(HISY)->setText(str.Data());
152  str.Form("Ym=%.1f, Yrms=%.1f", hstate->GetYmean(), hstate->GetYrms());
153  PropertyBox->item(HISYSTAT)->setText(str.Data());
154  }
155  if(dime>2) {
156  str.Form("Z:%d [%.3g,%.3g]", hstate->GetZbins(), hstate->GetZmin(), hstate->GetZmax());
157  PropertyBox->item(HISZ)->setText(str.Data());
158  str.Form("Zm=%.1f, Zrms=%.1f", hstate->GetZmean(), hstate->GetZrms());
159  PropertyBox->item(HISZSTAT)->setText(str.Data());
160  }
161  str.Form("size:%d b",hstate->GetObjectSize());
162  PropertyBox->item(HISSIZE)->setText(str.Data());
163  PropertyBox->item(HISTIME)->setText(hstate->GetTimeString());
164  ensurePolished();
165  update();
166  show();
167  raise();
170 }
171 
173 {
174  QString textbuffer;
175  textbuffer="Histogram ";
176  textbuffer+=HisnameLbl->text();
177  textbuffer+=" Status: \n ";
178  textbuffer+="Title: ";
179  textbuffer+=PropertyBox->item(HISTITLE)->text();
180  textbuffer+=" Class: ";
181  textbuffer+=PropertyBox->item(HISCLASS)->text();
182  textbuffer+=" ";
183  textbuffer+=PropertyBox->item(HISENTRIES)->text();
184  textbuffer+="\n ";
185  textbuffer+=PropertyBox->item(HISX)->text();
186  textbuffer+=" ";
187  textbuffer+=PropertyBox->item(HISXSTAT)->text();
188  textbuffer+="\n ";
189  textbuffer+=PropertyBox->item(HISY)->text();
190  textbuffer+=" ";
191  textbuffer+=PropertyBox->item(HISYSTAT)->text();
192  textbuffer+="\n ";
193  textbuffer+=PropertyBox->item(HISZ)->text();
194  textbuffer+=" ";
195  textbuffer+=PropertyBox->item(HISZSTAT)->text();
196  textbuffer+="\n ";
197  textbuffer+=PropertyBox->item(HISSIZE)->text();
198  textbuffer+=" Status received at: ";
199  textbuffer+=PropertyBox->item(HISTIME)->text();
200  TGo4Log::Message(1, "%s", textbuffer.toLatin1().constData());
201 }
virtual void ResetWidget()
Definition: QGo4Widget.cpp:52
Stat_t GetEntries() const
void ResetWidget() override
virtual void HisDrawButton_clicked()
Bool_t IsAnalysisItem(const char *name)
void ServiceCall(const char *name, void *par=nullptr)
Definition: QGo4Widget.cpp:398
TGo4ViewPanel * DrawItem(const QString &itemname, TGo4ViewPanel *panel=nullptr, TPad *pad=nullptr, bool activate=true, int updatelevel=-1)
Definition: QGo4Widget.cpp:305
TGo4BrowserProxy * Browser()
Definition: QGo4Widget.cpp:219
virtual void RefreshHistogramInfo(TH1 *h1)
const char * GetObjectClass() const
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
Definition: TGo4Log.cxx:206
Int_t GetDimension() const
TGo4HistogramInfo(QWidget *parent=nullptr, const char *name=nullptr)
void linkedObjectUpdated(const char *linkname, TObject *obj) override
Int_t GetObjectSize() const
const char * GetTimeString() const
void RequestObjectStatus(const char *name, TGo4Slot *tgtslot)
virtual void PrintLog_clicked()
virtual void HisInfoButton_clicked()
virtual void WorkWithHistogram(const char *itemname)
bool IsAcceptDrag(const char *itemname, TClass *cl, int kind) override
void AddLink(const char *itemname, const char *linkname)
Definition: QGo4Widget.cpp:117
virtual void HisPrintButton_clicked()
void DropItem(const char *itemname, TClass *cl, int kind) override
static Bool_t IsAutoEnabled()
Definition: TGo4Log.cxx:378
TGo4Slot * AddSlot(const char *slotname)
Definition: QGo4Widget.cpp:141