00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 enum PropertyIndex
00026 {
00027 HISTITLE,
00028 HISCLASS,
00029 HISENTRIES,
00030 HISX,
00031 HISXSTAT,
00032 HISY,
00033 HISYSTAT,
00034 HISZ,
00035 HISZSTAT,
00036 HISSIZE,
00037 HISTIME
00038 };
00039
00040
00041
00042 void TGo4HistogramInfo::init()
00043 {
00044 setAcceptDrops( TRUE );
00045 fbRemotedrop=true;
00046 fxLastHistogram=0;
00047 TGo4LockGuard glob;
00048 fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00049 char SlotName[64];
00050 char Caption[64];
00051 snprintf(SlotName,63,"%s","Go4HistogramInfo_Slots" );
00052 snprintf(Caption,63,"%s","Histogram Info:");
00053 setCaption( trUtf8( Caption ) );
00054 fxTGo4HistogramInfoSlots = (TGo4HistogramInfoSlots *) fxTGo4GUIRegistry->GetSlotClass(SlotName);
00055 if(fxTGo4HistogramInfoSlots !=0) {
00056 fxTGo4HistogramInfoSlots->SetGUI(this);
00057 }else{
00058 fxTGo4HistogramInfoSlots = new TGo4HistogramInfoSlots (SlotName, "Slots Class for Qt GUI", this);
00059 }
00060 fxTGo4HistogramInfoStatus= dynamic_cast <TGo4HistogramInfoStatus *> (fxTGo4HistogramInfoSlots->GetStatus());
00061 }
00062
00063 void TGo4HistogramInfo::destroy()
00064 {
00065 TGo4LockGuard glob;
00066 fxTGo4GUIRegistry->UnRegisterClass(fxTGo4HistogramInfoSlots,fxTGo4HistogramInfoStatus);
00067 delete fxTGo4HistogramInfoSlots;
00068 delete fxLastHistogram;
00069 }
00070
00071 void TGo4HistogramInfo::closeEvent( QCloseEvent *ce )
00072 {
00073 TGo4LockGuard glob;
00074 ce->accept();
00075 fxTGo4HistogramInfoSlots->SetGUI(0);
00076 delete this;
00077 }
00078
00079
00080
00081
00082 void TGo4HistogramInfo::RefreshHistogramInfo(TGo4HistogramStatus* hstate)
00083 {
00084 if(hstate==0) return;
00085 TGo4LockGuard glob;
00086 char buffer[256];
00087 snprintf(buffer,256,"%s",hstate->GetTitle());
00088 PropertyBox->changeItem(buffer,HISTITLE);
00089 snprintf(buffer,255,"%s",hstate->GetObjectClass());
00090 PropertyBox->changeItem(buffer,HISCLASS);
00091 snprintf(buffer,256,"Entries:%.5g",hstate->GetEntries());
00092 PropertyBox->changeItem(buffer,HISENTRIES);
00093 snprintf(buffer,256,"X:%d [%.3g,%.3g]",
00094 hstate->GetXbins(), hstate->GetXmin(), hstate->GetXmax());
00095 PropertyBox->changeItem(buffer,HISX);
00096 snprintf(buffer,256,"Xm=%.1f, Xrms=%.1f",
00097 hstate->GetXmean(), hstate->GetXrms());
00098 PropertyBox->changeItem(buffer,HISXSTAT);
00099 int dime=hstate->GetDimension();
00100 if(dime>1)
00101 {
00102 snprintf(buffer,256,"Y:%d [%.3g,%.3g]",
00103 hstate->GetYbins(), hstate->GetYmin(), hstate->GetYmax());
00104 PropertyBox->changeItem(buffer,HISY);
00105 snprintf(buffer,256,"Ym=%.1f, Yrms=%.1f",
00106 hstate->GetYmean(), hstate->GetYrms());
00107 PropertyBox->changeItem(buffer,HISYSTAT);
00108 if(dime>2)
00109 {
00110 snprintf(buffer,256,"Z:%d [%.3g,%.3g]",
00111 hstate->GetZbins(), hstate->GetZmin(), hstate->GetZmax());
00112 PropertyBox->changeItem(buffer,HISZ);
00113 snprintf(buffer,256,"Zm=%.1f, Zrms=%.1f",
00114 hstate->GetZmean(), hstate->GetZrms());
00115 PropertyBox->changeItem(buffer,HISZSTAT);
00116 }
00117 else
00118 {
00119 PropertyBox->changeItem("-",HISZ);
00120 PropertyBox->changeItem("-",HISZSTAT);
00121 }
00122 }
00123 else
00124 {
00125 PropertyBox->changeItem("-",HISY);
00126 PropertyBox->changeItem("-",HISYSTAT);
00127 PropertyBox->changeItem("-",HISZ);
00128 PropertyBox->changeItem("-",HISZSTAT);
00129 }
00130 snprintf(buffer,256,"size:%d b",hstate->GetObjectSize());
00131 PropertyBox->changeItem(buffer,HISSIZE);
00132 snprintf(buffer,256,"%s",hstate->GetTimeString());
00133 PropertyBox->changeItem(buffer,HISTIME);
00134 polish();
00135 update();
00136 show();
00137 raise();
00138 if(TGo4Log::IsAutoEnabled()) PrintoutLog();
00139 }
00140
00141 void TGo4HistogramInfo::ClearHistogramInfo()
00142 {
00143 TGo4LockGuard glob;
00144 PropertyBox->changeItem("Title" ,HISTITLE);
00145 PropertyBox->changeItem("Class" ,HISCLASS);
00146 PropertyBox->changeItem("Entries" ,HISENTRIES);
00147 PropertyBox->changeItem("Xrange" ,HISX);
00148 PropertyBox->changeItem("Xstats" ,HISXSTAT);
00149 PropertyBox->changeItem("Yrange" ,HISY);
00150 PropertyBox->changeItem("Ystats" ,HISYSTAT);
00151 PropertyBox->changeItem("Title" ,HISZ);
00152 PropertyBox->changeItem("Zstats" ,HISZSTAT);
00153 PropertyBox->changeItem("Size" ,HISSIZE);
00154 TDatime now;
00155 PropertyBox->changeItem(now.AsSQLString() ,HISTIME);
00156 polish();
00157 update();
00158 show();
00159 raise();
00160 }
00161
00162
00163 void TGo4HistogramInfo::HistogramInfo()
00164 {
00165 ClearHistogramInfo();
00166 fxTGo4HistogramInfoSlots->SendHistogramInfoCommand();
00167 fbRemotedrop=true;
00168 }
00169
00170 void TGo4HistogramInfo::PrintHistograms()
00171 {
00172 fxTGo4HistogramInfoSlots->SendHistogramPrintCommand();
00173 }
00174
00175
00176
00177
00178 const char* TGo4HistogramInfo::GetHistogramName()
00179 {
00180 const char* histoname=HisnameEdit->text().stripWhiteSpace();
00181 return histoname;
00182 }
00183
00184
00185 void TGo4HistogramInfo::SetHistogramName( const char * name )
00186 {
00187 HisnameEdit->setText(name);
00188 }
00189
00190
00191 void TGo4HistogramInfo::DrawHistogram()
00192 {
00193 if(fbRemotedrop)
00194 {
00195 fxTGo4HistogramInfoSlots->SendHistogramRequestCommand();
00196 }
00197 else
00198 {
00199 if(fxLastHistogram)
00200 {
00201 TGo4MainWindow* mw= (TGo4MainWindow*) fxTGo4GUIRegistry->GetMainWindow();
00202 TGo4PreviewPanel* viewpanel =mw->ViewPanelSlot(1);
00203 TQRootCanvas* can=viewpanel->GetQCanvas();
00204 TPad* pad=viewpanel->GetActivePad();
00205 TGo4SlotsBaseClass* membrowser= fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots");
00206 membrowser->AddObject(fxLastHistogram,can,pad);
00207 }
00208 }
00209 }
00210
00211 void TGo4HistogramInfo::dropEvent( QDropEvent *e )
00212 {
00213 TGo4LockGuard glob;
00214 QListView *dragsource=dynamic_cast <QListView *> (e->source());
00215 if(dragsource==0) return;
00216 TGo4QTHItem *dragitem= dynamic_cast <TGo4QTHItem *>(dragsource->currentItem());
00217 if(dragitem==0) return;
00218
00219 if(dynamic_cast<TGo4QPicItem*>(dragitem)) return;
00220 if(dynamic_cast<TGo4QTHStackItem*>(dragitem)) return;
00221 if(dynamic_cast<TGo4QGraphItem*>(dragitem)) return;
00222 if(dynamic_cast<TGo4QMultiGraphItem*>(dragitem)) return;
00223
00224 if(strcmp(e->source()->name(),"ListViewRemote")==0)
00225 fbRemotedrop=true;
00226 else if(strcmp(e->source()->name(),"FileListView")==0)
00227 fbRemotedrop=false;
00228 else if(strcmp(dragsource->name(),"ListViewLocal")==0)
00229 fbRemotedrop=false;
00230 QString name;
00231 QCString plain = "plain";
00232 bool decoded = QTextDrag::decode(e, name, plain);
00233
00234 if (! decoded) decoded = QTextDrag::decode(e, name);
00235 HisnameEdit->setText(name);
00236 delete fxLastHistogram;
00237 fxLastHistogram=0;
00238 if(fbRemotedrop)
00239 {
00240 HistogramInfo();
00241 }
00242 else
00243 {
00244 TH1* draghisto=dynamic_cast<TH1*>(dragitem->GetWorkObject());
00245 ShowProperties(draghisto);
00246 }
00247 dragsource->clearSelection();
00248 dragsource->setSelected(dragitem,true);
00249 e->acceptAction();
00250 }
00251
00252 void TGo4HistogramInfo::dragEnterEvent( QDragEnterEvent *Event)
00253 {
00254 if ( QTextDrag::canDecode( Event )){
00255 Event->accept();
00256 }
00257 }
00258
00259
00260
00261
00262
00263 void TGo4HistogramInfo::PrintoutLog()
00264 {
00265 QString textbuffer;
00266 textbuffer="Histogram ";
00267 textbuffer+=HisnameEdit->text();
00268 textbuffer+=" Status: \n ";
00269 textbuffer+="Title: ";
00270 textbuffer+=PropertyBox->item(HISTITLE)->text();
00271 textbuffer+=" Class: ";
00272 textbuffer+=PropertyBox->item(HISCLASS)->text();
00273 textbuffer+=" ";
00274 textbuffer+=PropertyBox->item(HISENTRIES)->text();
00275 textbuffer+="\n ";
00276 textbuffer+=PropertyBox->item(HISX)->text();
00277 textbuffer+=" ";
00278 textbuffer+=PropertyBox->item(HISXSTAT)->text();
00279 textbuffer+="\n ";
00280 textbuffer+=PropertyBox->item(HISY)->text();
00281 textbuffer+=" ";
00282 textbuffer+=PropertyBox->item(HISYSTAT)->text();
00283 textbuffer+="\n ";
00284 textbuffer+=PropertyBox->item(HISZ)->text();
00285 textbuffer+=" ";
00286 textbuffer+=PropertyBox->item(HISZSTAT)->text();
00287 textbuffer+="\n ";
00288 textbuffer+=PropertyBox->item(HISSIZE)->text();
00289 textbuffer+=" Status received at: ";
00290 textbuffer+=PropertyBox->item(HISTIME)->text();
00291
00292 TGo4Log::Message(1,(const char*) textbuffer);
00293 }
00294
00295
00296 void TGo4HistogramInfo::ShowProperties( TH1 * his)
00297 {
00298 if(his==0) return;
00299 fbRemotedrop=false;
00300 HisnameEdit->setText(his->GetName());
00301 TGo4HistogramStatus hstate(his,kTRUE);
00302 fxTGo4HistogramInfoSlots->AddObject(&hstate);
00303 delete fxLastHistogram;
00304 fxLastHistogram=dynamic_cast<TH1*>(his->Clone());
00305 }
00306
00307
00308
00309