Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4HistogramInfo.h"
00015
00016 #include "TClass.h"
00017 #include "TH1.h"
00018 #include "TDatime.h"
00019
00020 #include "TGo4BrowserProxy.h"
00021 #include "TGo4Log.h"
00022 #include "TGo4HistogramStatus.h"
00023
00024
00025 TGo4HistogramInfo::TGo4HistogramInfo(QWidget *parent, const char* name)
00026 : QGo4Widget(parent, name)
00027 {
00028 setupUi(this);
00029 setWindowTitle("Histogram Info:");
00030 ResetWidget();
00031 }
00032
00033 void TGo4HistogramInfo::HisPrintButton_clicked()
00034 {
00035 ServiceCall("PrintAnalysisHistograms");
00036 }
00037
00038 void TGo4HistogramInfo::HisDrawButton_clicked()
00039 {
00040 DrawItem(HisnameLbl->text());
00041 }
00042
00043 void TGo4HistogramInfo::HisInfoButton_clicked()
00044 {
00045 WorkWithHistogram(HisnameLbl->text().toLatin1().constData());
00046 }
00047
00048 bool TGo4HistogramInfo::IsAcceptDrag(const char* itemname, TClass* cl, int kind)
00049 {
00050 return cl==0 ? false : cl->InheritsFrom(TH1::Class());
00051 }
00052
00053 void TGo4HistogramInfo::DropItem(const char* itemname, TClass* cl, int kind)
00054 {
00055 if (cl==0) return;
00056
00057 if (cl->InheritsFrom(TH1::Class()))
00058 WorkWithHistogram(itemname);
00059 }
00060
00061 void TGo4HistogramInfo::linkedObjectUpdated(const char* linkname, TObject* obj)
00062 {
00063 TGo4HistogramStatus* hstate =
00064 dynamic_cast<TGo4HistogramStatus*>(obj);
00065 if (hstate!=0)
00066 RefreshHistogramInfo(hstate);
00067 else
00068 RefreshHistogramInfo(dynamic_cast<TH1*> (obj));
00069 }
00070
00071 void TGo4HistogramInfo::WorkWithHistogram(const char* itemname)
00072 {
00073 ResetWidget();
00074
00075 TGo4BrowserProxy* br = Browser();
00076 if (br==0) return;
00077
00078 HisnameLbl->setText(itemname);
00079
00080 if (br->IsAnalysisItem(itemname)) {
00081 TGo4Slot* tgtslot = AddSlot("HistStatus");
00082 br->RequestObjectStatus(itemname, tgtslot);
00083
00084 AddLink(itemname, "HistogramLock");
00085 } else {
00086 AddLink(itemname, "Histogram");
00087 TH1* h1 = dynamic_cast<TH1*> (GetLinked("Histogram",2));
00088 RefreshHistogramInfo(h1);
00089 }
00090 setFocus();
00091 }
00092
00093 void TGo4HistogramInfo::ResetWidget()
00094 {
00095 QGo4Widget::ResetWidget();
00096
00097 HisnameLbl->setText("");
00098
00099 PropertyBox->item(HISTITLE)->setText("Title");
00100 PropertyBox->item(HISCLASS)->setText("Class");
00101 PropertyBox->item(HISENTRIES)->setText("Entries");
00102 PropertyBox->item(HISX)->setText("Xrange");
00103 PropertyBox->item(HISXSTAT)->setText("Xstats");
00104 PropertyBox->item(HISY)->setText("Yrange");
00105 PropertyBox->item(HISYSTAT)->setText("Ystats");
00106 PropertyBox->item(HISZ)->setText("Title");
00107 PropertyBox->item(HISZSTAT)->setText("Zstats");
00108 PropertyBox->item(HISSIZE)->setText("Size");
00109 TDatime now;
00110 PropertyBox->item(HISTIME)->setText(now.AsSQLString());
00111 ensurePolished();
00112 update();
00113 show();
00114 raise();
00115 }
00116
00117 void TGo4HistogramInfo::RefreshHistogramInfo(TH1* h1)
00118 {
00119 if (h1==0)
00120 ResetWidget();
00121 else {
00122 TGo4HistogramStatus hstate(h1, kTRUE);
00123 RefreshHistogramInfo(&hstate);
00124 }
00125 }
00126
00127 void TGo4HistogramInfo::RefreshHistogramInfo(TGo4HistogramStatus* hstate)
00128 {
00129 if(hstate==0) return;
00130 TString str;
00131 PropertyBox->item(HISTITLE)->setText(hstate->GetTitle());
00132 PropertyBox->item(HISCLASS)->setText(hstate->GetObjectClass());
00133 str.Form("Entries:%.5g",hstate->GetEntries());
00134 PropertyBox->item(HISENTRIES)->setText(str.Data());
00135 str.Form("X:%d [%.3g,%.3g]",hstate->GetXbins(), hstate->GetXmin(), hstate->GetXmax());
00136 PropertyBox->item(HISX)->setText(str.Data());
00137 str.Form("Xm=%.1f, Xrms=%.1f", hstate->GetXmean(), hstate->GetXrms());
00138 PropertyBox->item(HISXSTAT)->setText(str.Data());
00139
00140 PropertyBox->item(HISY)->setText("-");
00141 PropertyBox->item(HISYSTAT)->setText("-");
00142 PropertyBox->item(HISZ)->setText("-");
00143 PropertyBox->item(HISZSTAT)->setText("-");
00144
00145 int dime = hstate->GetDimension();
00146 if(dime>1) {
00147 str.Form("Y:%d [%.3g,%.3g]",hstate->GetYbins(), hstate->GetYmin(), hstate->GetYmax());
00148 PropertyBox->item(HISY)->setText(str.Data());
00149 str.Form("Ym=%.1f, Yrms=%.1f", hstate->GetYmean(), hstate->GetYrms());
00150 PropertyBox->item(HISYSTAT)->setText(str.Data());
00151 }
00152 if(dime>2) {
00153 str.Form("Z:%d [%.3g,%.3g]", hstate->GetZbins(), hstate->GetZmin(), hstate->GetZmax());
00154 PropertyBox->item(HISZ)->setText(str.Data());
00155 str.Form("Zm=%.1f, Zrms=%.1f", hstate->GetZmean(), hstate->GetZrms());
00156 PropertyBox->item(HISZSTAT)->setText(str.Data());
00157 }
00158 str.Form("size:%d b",hstate->GetObjectSize());
00159 PropertyBox->item(HISSIZE)->setText(str.Data());
00160 PropertyBox->item(HISTIME)->setText(hstate->GetTimeString());
00161 ensurePolished();
00162 update();
00163 show();
00164 raise();
00165 if(TGo4Log::IsAutoEnabled())
00166 PrintLog_clicked();
00167 }
00168
00169 void TGo4HistogramInfo::PrintLog_clicked()
00170 {
00171 QString textbuffer;
00172 textbuffer="Histogram ";
00173 textbuffer+=HisnameLbl->text();
00174 textbuffer+=" Status: \n ";
00175 textbuffer+="Title: ";
00176 textbuffer+=PropertyBox->item(HISTITLE)->text();
00177 textbuffer+=" Class: ";
00178 textbuffer+=PropertyBox->item(HISCLASS)->text();
00179 textbuffer+=" ";
00180 textbuffer+=PropertyBox->item(HISENTRIES)->text();
00181 textbuffer+="\n ";
00182 textbuffer+=PropertyBox->item(HISX)->text();
00183 textbuffer+=" ";
00184 textbuffer+=PropertyBox->item(HISXSTAT)->text();
00185 textbuffer+="\n ";
00186 textbuffer+=PropertyBox->item(HISY)->text();
00187 textbuffer+=" ";
00188 textbuffer+=PropertyBox->item(HISYSTAT)->text();
00189 textbuffer+="\n ";
00190 textbuffer+=PropertyBox->item(HISZ)->text();
00191 textbuffer+=" ";
00192 textbuffer+=PropertyBox->item(HISZSTAT)->text();
00193 textbuffer+="\n ";
00194 textbuffer+=PropertyBox->item(HISSIZE)->text();
00195 textbuffer+=" Status received at: ";
00196 textbuffer+=PropertyBox->item(HISTIME)->text();
00197 TGo4Log::Message(1,textbuffer.toLatin1().constData());
00198 }