GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
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
24TGo4HistogramInfo::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:");
35}
36
38{
39 ServiceCall("PrintAnalysisHistograms");
40}
41
43{
44 DrawItem(HisnameLbl->text());
45}
46
48{
49 WorkWithHistogram(HisnameLbl->text().toLatin1().constData());
50}
51
52bool TGo4HistogramInfo::IsAcceptDrag(const char *itemname, TClass *cl, int kind)
53{
54 return !cl ? false : cl->InheritsFrom(TH1::Class());
55}
56
57void 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
65void TGo4HistogramInfo::linkedObjectUpdated(const char *linkname, TObject *obj)
66{
67 TGo4HistogramStatus* hstate = dynamic_cast<TGo4HistogramStatus*>(obj);
68 if (hstate)
70 else
71 RefreshHistogramInfo(dynamic_cast<TH1 *> (obj));
72}
73
74void TGo4HistogramInfo::WorkWithHistogram(const char *itemname)
75{
77
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}
T * GetLinkedCast(const char *linkname, int updatelevel=0)
Definition QGo4Widget.h:157
virtual void ResetWidget()
TGo4ViewPanel * DrawItem(const QString &itemname, TGo4ViewPanel *panel=nullptr, TPad *pad=nullptr, bool activate=true, int updatelevel=-1)
TGo4Slot * AddSlot(const char *slotname)
add slot with specific name to widget top folder
QGo4Widget(QWidget *parent=nullptr, const char *name=nullptr, Qt::WindowFlags f=Qt::Widget)
void AddLink(const char *itemname, const char *linkname)
create link for item with name linkname
void ServiceCall(const char *name, void *par=nullptr)
TGo4BrowserProxy * Browser()
void RequestObjectStatus(const char *name, TGo4Slot *tgtslot)
Bool_t IsAnalysisItem(const char *name)
virtual void HisDrawButton_clicked()
TGo4HistogramInfo(QWidget *parent=nullptr, const char *name=nullptr)
void DropItem(const char *itemname, TClass *cl, int kind) override
virtual void HisInfoButton_clicked()
virtual void PrintLog_clicked()
virtual void HisPrintButton_clicked()
virtual void RefreshHistogramInfo(TH1 *h1)
void ResetWidget() override
virtual void WorkWithHistogram(const char *itemname)
void linkedObjectUpdated(const char *linkname, TObject *obj) override
bool IsAcceptDrag(const char *itemname, TClass *cl, int kind) override
Runtime status of a histogram object.
static Bool_t IsAutoEnabled()
get current user boolean
Definition TGo4Log.cxx:378
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
Display a message.
Definition TGo4Log.cxx:206
const char * GetTimeString() const
Creation time string; sql format.
const char * GetObjectClass() const
ClassName of the described object.
Int_t GetObjectSize() const
Size of described object in byte.