00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4QTHStackItem.h"
00017
00018 #include <iostream.h>
00019
00020 #include "THStack.h"
00021 #include "TPad.h"
00022 #include "TCanvas.h"
00023
00024 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00025 #include "Go4GUI/TGo4PreviewPanel.h"
00026 #include "Go4GUI/TGo4MonitoredObject.h"
00027 #include "Go4GUI/TGo4BrowserSlots.h"
00028 #include "Go4GUI/TGo4BrowserStatus.h"
00029 #include "Go4GUI/TGo4Browser.h"
00030 #include "Go4GUI/TGo4QRootCanvas.h"
00031
00032 TGo4QTHStackItem::TGo4QTHStackItem( QListViewItem* parent, const QString & text, const QString & text1, const QString & text2)
00033 :TGo4QTHItem (parent, "superimpose.png", text, text1, text2)
00034 {
00035 }
00036
00037 TGo4QTHStackItem::TGo4QTHStackItem( QListView* parent, const QString & text, const QString & text1, const QString & text2)
00038 :TGo4QTHItem (parent, "superimpose.png", text, text1, text2)
00039 {
00040 }
00041
00042 TGo4QTHStackItem::~TGo4QTHStackItem(){}
00043
00044 void TGo4QTHStackItem::DrawObj(TGo4PreviewPanel *viewpanel, TPad* currentpad)
00045 {
00046 if(!AssignDrawPanel(viewpanel,currentpad)) return;
00047 THStack* stack=dynamic_cast<THStack*>(GetWorkObject());
00048 if(stack)
00049 {
00050 QString realname=stack->GetName();
00051 TGo4BrowserSlots* browserslots = dynamic_cast <TGo4BrowserSlots *>(fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots"));
00052 TGo4Browser* browser=browserslots->GetBrowserGUI();
00053 if(InFileBrowser())
00054 {
00055 if(browserslots)
00056 {
00057 browserslots->AddObject(stack,fxDrawPanel->GetQCanvas(),fxDrawPad);
00058 realname=browserslots->GetAddedItemName();
00059
00060
00061
00062 fxDrawPad->cd();
00063 TGo4QItem *memitem = (TGo4QItem*) browser->ListViewLocal->findItem(realname,0);
00064 if (memitem!=0)
00065 {
00066 memitem->DrawObj(fxDrawPanel,fxDrawPad);
00067 }
00068 }
00069 }
00070 else
00071 {
00072 TPad* padsav=fxDrawPanel->GetActivePad();
00073 fxDrawPanel->SetActivePad(fxDrawPad);
00074 fxDrawPanel->ClearPad();
00075 stack->Draw("nostack");
00076 fxDrawPanel->UpdatePad(fxDrawPad, stack);
00077 fxDrawPanel->SetActivePad(padsav);
00078 }
00079 }
00080 }
00081
00082 void TGo4QTHStackItem::UpdateOnline(TObject *fxObj)
00083 {
00084 bool keepscale=IsKeepScale();
00085 THStack* monstack=dynamic_cast <THStack*>(GetWorkObject());
00086 THStack* newstack=dynamic_cast <THStack*>(fxObj);
00087 if(monstack!=0 && newstack!=0)
00088 {
00089 TList* newlist=newstack->GetHists();
00090 TIterator* newliter=newlist->MakeIterator();
00091 TList* oldlist=monstack->GetHists();
00092 TObject* hob=0;
00093 while((hob=newliter->Next())!=0)
00094 {
00095 TH1* newhi=dynamic_cast<TH1*>(hob);
00096 if(newhi)
00097 {
00098 const Text_t* hisname=newhi->GetName();
00099 TH1* monhis= dynamic_cast<TH1*>(oldlist->FindObject(hisname));
00100 if(monhis)
00101 {
00102 Double_t ymin,ymax;
00103 if(keepscale)
00104 {
00105 ymin=monhis->GetMinimum();
00106 ymax=monhis->GetMaximum();
00107
00108 }
00109 monhis->Reset();
00110 monhis->Add(newhi);
00111 if(keepscale)
00112 {
00113 monhis->SetMinimum(ymin);
00114 monhis->SetMaximum(ymax);
00115
00116 }
00117 }
00118 else
00119 {
00120
00121 TH1* newhist = (TH1*) newhi->Clone();
00122 TH1* lasthist=(TH1*) oldlist->Last();
00123 newhist->SetLineColor(lasthist->GetLineColor()+1);
00124 monstack->Add(newhist);
00125 }
00126 }
00127 }
00128 delete newliter;
00129 UpdateDrawPad();
00130 }
00131 }
00132
00133
00134
00135
00136