GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4HistogramInfo.cpp
Go to the documentation of this file.
1 // $Id: TGo4HistogramInfo.cpp 3124 2021-03-30 08:47:53Z 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 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, SIGNAL(clicked()), this, SLOT(HisInfoButton_clicked()));
29  QObject::connect(HisPrintButton, SIGNAL(clicked()), this, SLOT(HisPrintButton_clicked()));
30  QObject::connect(HisDrawButton, SIGNAL(clicked()), this, SLOT(HisDrawButton_clicked()));
31  QObject::connect(PrintLog, SIGNAL(clicked()), this, SLOT(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==0 ? false : cl->InheritsFrom(TH1::Class());
55 }
56 
57 void TGo4HistogramInfo::DropItem(const char* itemname, TClass* cl, int kind)
58 {
59  if (cl==0) 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 =
68  dynamic_cast<TGo4HistogramStatus*>(obj);
69  if (hstate!=0)
70  RefreshHistogramInfo(hstate);
71  else
72  RefreshHistogramInfo(dynamic_cast<TH1*> (obj));
73 }
74 
75 void TGo4HistogramInfo::WorkWithHistogram(const char* itemname)
76 {
77  ResetWidget();
78 
79  TGo4BrowserProxy* br = Browser();
80  if (br==0) return;
81 
82  HisnameLbl->setText(itemname);
83 
84  if (br->IsAnalysisItem(itemname)) {
85  TGo4Slot* tgtslot = AddSlot("HistStatus");
86  br->RequestObjectStatus(itemname, tgtslot);
87  // addlink to observe when histogram is removed
88  AddLink(itemname, "HistogramLock");
89  } else {
90  AddLink(itemname, "Histogram");
91  TH1* h1 = dynamic_cast<TH1*> (GetLinked("Histogram",2));
93  }
94  setFocus();
95 }
96 
98 {
100 
101  HisnameLbl->setText("");
102 
103  PropertyBox->item(HISTITLE)->setText("Title");
104  PropertyBox->item(HISCLASS)->setText("Class");
105  PropertyBox->item(HISENTRIES)->setText("Entries");
106  PropertyBox->item(HISX)->setText("Xrange");
107  PropertyBox->item(HISXSTAT)->setText("Xstats");
108  PropertyBox->item(HISY)->setText("Yrange");
109  PropertyBox->item(HISYSTAT)->setText("Ystats");
110  PropertyBox->item(HISZ)->setText("Title");
111  PropertyBox->item(HISZSTAT)->setText("Zstats");
112  PropertyBox->item(HISSIZE)->setText("Size");
113  TDatime now;
114  PropertyBox->item(HISTIME)->setText(now.AsSQLString());
115  ensurePolished();
116  update();
117  show();
118  raise();
119 }
120 
122 {
123  if (h1==0)
124  ResetWidget();
125  else {
126  TGo4HistogramStatus hstate(h1, kTRUE);
127  RefreshHistogramInfo(&hstate);
128  }
129 }
130 
132 {
133  if(hstate==0) return;
134  TString str;
135  PropertyBox->item(HISTITLE)->setText(hstate->GetTitle());
136  PropertyBox->item(HISCLASS)->setText(hstate->GetObjectClass());
137  str.Form("Entries:%.5g",hstate->GetEntries());
138  PropertyBox->item(HISENTRIES)->setText(str.Data());
139  str.Form("X:%d [%.3g,%.3g]",hstate->GetXbins(), hstate->GetXmin(), hstate->GetXmax());
140  PropertyBox->item(HISX)->setText(str.Data());
141  str.Form("Xm=%.1f, Xrms=%.1f", hstate->GetXmean(), hstate->GetXrms());
142  PropertyBox->item(HISXSTAT)->setText(str.Data());
143 
144  PropertyBox->item(HISY)->setText("-");
145  PropertyBox->item(HISYSTAT)->setText("-");
146  PropertyBox->item(HISZ)->setText("-");
147  PropertyBox->item(HISZSTAT)->setText("-");
148 
149  int dime = hstate->GetDimension();
150  if(dime>1) {
151  str.Form("Y:%d [%.3g,%.3g]",hstate->GetYbins(), hstate->GetYmin(), hstate->GetYmax());
152  PropertyBox->item(HISY)->setText(str.Data());
153  str.Form("Ym=%.1f, Yrms=%.1f", hstate->GetYmean(), hstate->GetYrms());
154  PropertyBox->item(HISYSTAT)->setText(str.Data());
155  }
156  if(dime>2) {
157  str.Form("Z:%d [%.3g,%.3g]", hstate->GetZbins(), hstate->GetZmin(), hstate->GetZmax());
158  PropertyBox->item(HISZ)->setText(str.Data());
159  str.Form("Zm=%.1f, Zrms=%.1f", hstate->GetZmean(), hstate->GetZrms());
160  PropertyBox->item(HISZSTAT)->setText(str.Data());
161  }
162  str.Form("size:%d b",hstate->GetObjectSize());
163  PropertyBox->item(HISSIZE)->setText(str.Data());
164  PropertyBox->item(HISTIME)->setText(hstate->GetTimeString());
165  ensurePolished();
166  update();
167  show();
168  raise();
171 }
172 
174 {
175  QString textbuffer;
176  textbuffer="Histogram ";
177  textbuffer+=HisnameLbl->text();
178  textbuffer+=" Status: \n ";
179  textbuffer+="Title: ";
180  textbuffer+=PropertyBox->item(HISTITLE)->text();
181  textbuffer+=" Class: ";
182  textbuffer+=PropertyBox->item(HISCLASS)->text();
183  textbuffer+=" ";
184  textbuffer+=PropertyBox->item(HISENTRIES)->text();
185  textbuffer+="\n ";
186  textbuffer+=PropertyBox->item(HISX)->text();
187  textbuffer+=" ";
188  textbuffer+=PropertyBox->item(HISXSTAT)->text();
189  textbuffer+="\n ";
190  textbuffer+=PropertyBox->item(HISY)->text();
191  textbuffer+=" ";
192  textbuffer+=PropertyBox->item(HISYSTAT)->text();
193  textbuffer+="\n ";
194  textbuffer+=PropertyBox->item(HISZ)->text();
195  textbuffer+=" ";
196  textbuffer+=PropertyBox->item(HISZSTAT)->text();
197  textbuffer+="\n ";
198  textbuffer+=PropertyBox->item(HISSIZE)->text();
199  textbuffer+=" Status received at: ";
200  textbuffer+=PropertyBox->item(HISTIME)->text();
201  TGo4Log::Message(1,textbuffer.toLatin1().constData());
202 }
virtual void ResetWidget()
Definition: QGo4Widget.cpp:52
virtual void DropItem(const char *itemname, TClass *cl, int kind)
virtual void HisDrawButton_clicked()
TObject * GetLinked(const char *linkname, int updatelevel)
Definition: QGo4Widget.cpp:177
Bool_t IsAnalysisItem(const char *name)
TGo4BrowserProxy * Browser()
Definition: QGo4Widget.cpp:224
virtual bool IsAcceptDrag(const char *itemname, TClass *cl, int kind)
virtual void RefreshHistogramInfo(TH1 *h1)
virtual void linkedObjectUpdated(const char *linkname, TObject *obj)
TGo4HistogramInfo(QWidget *parent=0, const char *name=0)
virtual void ResetWidget()
TGo4ViewPanel * DrawItem(const QString &itemname, TGo4ViewPanel *panel=0, TPad *pad=0, bool activate=true, int updatelevel=-1)
Definition: QGo4Widget.cpp:312
void ServiceCall(const char *name, void *par=0)
Definition: QGo4Widget.cpp:405
void RequestObjectStatus(const char *name, TGo4Slot *tgtslot)
static const char * Message(Int_t prio, const char *text,...)
Definition: TGo4Log.cxx:207
const char * GetTimeString() const
virtual void PrintLog_clicked()
const char * GetObjectClass() const
virtual void HisInfoButton_clicked()
virtual void WorkWithHistogram(const char *itemname)
void AddLink(const char *itemname, const char *linkname)
Definition: QGo4Widget.cpp:122
virtual void HisPrintButton_clicked()
Int_t GetObjectSize() const
static Bool_t IsAutoEnabled()
Definition: TGo4Log.cxx:382
TGo4Slot * AddSlot(const char *slotname)
Definition: QGo4Widget.cpp:146