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