00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4QCanvasItem.h"
00017
00018 #include <iostream.h>
00019
00020 #include "TCanvas.h"
00021 #include "TObject.h"
00022 #include "TH1.h"
00023
00024 #include "Go4StatusBase/TGo4CanvasWrapper.h"
00025 #include "Go4CommandsAnalysis/TGo4ComGetCanvas.h"
00026 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00027 #include "Go4GUI/TGo4PreviewPanel.h"
00028 #include "Go4GUI/TGo4MainWindow.h"
00029 #include "Go4GUI/TGo4QRootCanvas.h"
00030 #include "Go4GUI/TGo4MonitoredListSlots.h"
00031 #include "Go4GUI/TGo4MonitoredListStatus.h"
00032 #include "Go4GUI/TGo4MonitoredListSlots.h"
00033 #include "Go4GUI/TGo4MonitoredObject.h"
00034 #include "Go4GUI/TGo4BrowserSlots.h"
00035 #include "Go4GUI/TGo4BrowserStatus.h"
00036
00037 TGo4QCanvasItem::TGo4QCanvasItem( QListViewItem* parent, const QString & text, const QString & text1, const QString & text2)
00038 :TGo4QDragDrop(parent, "canvas.png", text, text1, text2)
00039 {
00040 }
00041
00042 TGo4QCanvasItem::TGo4QCanvasItem( QListView* parent, const QString & text, const QString & text1, const QString & text2)
00043 :TGo4QDragDrop (parent, "canvas.png", text, text1, text2)
00044 {
00045 }
00046
00047 TGo4QCanvasItem::~TGo4QCanvasItem()
00048 {
00049 }
00050
00051 void TGo4QCanvasItem::ItemDBkLocal()
00052 {
00053 TGo4PreviewPanel *viewPanel=0;
00054 TGo4MainWindow *mw= dynamic_cast <TGo4MainWindow *> (fxTGo4GUIRegistry->GetMainWindow());
00055 if(mw!=0) viewPanel =mw->ViewPanelSlot();
00056 DrawObj(viewPanel);
00057 }
00058
00059 void TGo4QCanvasItem::ItemDBkRemote()
00060 {
00061 GetRemoteObj();
00062 }
00063
00064 void TGo4QCanvasItem::DrawObj(TGo4PreviewPanel *viewpanel, TPad* currentpad)
00065 {
00066 if(!AssignDrawPanel(viewpanel, currentpad)) return;
00067 TCanvas *FC=dynamic_cast<TCanvas*>(GetWorkObject());
00068 if(FC==0) return;
00069 TPad* padsav=fxDrawPanel->GetActivePad();
00070 fxDrawPanel->SetActivePad(fxDrawPad);
00071 fxDrawPanel->ClearPad();
00072 TGo4QRootCanvas *fxC=fxDrawPanel->GetQCanvas();
00073 TDirectory* filsav=gDirectory;
00074 gROOT->cd();
00075 fxC->InsertCanvas(FC, fxDrawPad);
00076 filsav->cd();
00077 fxDrawPanel->SetActivePad(padsav);
00078 if(InFileBrowser() || InMemoryBrowser())
00079 AddHistosToMemBrowser(fxDrawPad);
00080 }
00081 void TGo4QCanvasItem::DropAction(QWidget *Recvr)
00082 {
00083 TGo4PreviewPanel *fxPanel=dynamic_cast<TGo4PreviewPanel *>(Recvr);
00084 if(fxPanel!=0)DrawObj(fxPanel);
00085
00086 }
00087 void TGo4QCanvasItem::GetOnlineObj()
00088 {
00089 TGo4MonitoredListSlots* fxTGo4MonitoredListSlots;
00090 fxTGo4MonitoredListSlots=dynamic_cast <TGo4MonitoredListSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4MonitoredListSlots"));
00091 TGo4ComGetCanvas* com = new TGo4ComGetCanvas(text(0).data());
00092 fxTGo4GUIRegistry->SubmitCommand(com,text(0).data(),fxTGo4MonitoredListSlots,kTRUE);
00093
00094 }
00095
00096 void TGo4QCanvasItem::UpdateOnline(TObject *ob)
00097 {
00098 TObject* oldobject=GetWorkObject();
00099 TObject* newcopy=0;
00100 Text_t obname[256];
00101 if(ob) snprintf(obname,256,"%s",ob->GetName());
00102 if(fbMonitorDone)
00103 {
00104
00105
00106 TGo4BrowserSlots* brslots=dynamic_cast <TGo4BrowserSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots"));
00107 if(brslots)
00108 {
00109 TGo4BrowserStatus* brstat=dynamic_cast <TGo4BrowserStatus *> (brslots->GetStatus());
00110 brstat->OverWriteLocalObject(dynamic_cast <TNamed*>(ob));
00111 newcopy=brstat->GetObjectfromLocalList(obname);
00112
00113 fxItemObject=newcopy;
00114 }
00115 }
00116 else
00117 {
00118
00119
00120 TGo4MonitoredListSlots* monslots=dynamic_cast <TGo4MonitoredListSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4MonitoredListSlots"));
00121 if(monslots)
00122 {
00123 TGo4MonitoredListStatus* monstat=dynamic_cast <TGo4MonitoredListStatus *> (monslots->GetStatus());
00124 TObject* addedobject=0;
00125 TGo4CanvasWrapper* cwrap=dynamic_cast<TGo4CanvasWrapper*>(ob);
00126 if(cwrap)
00127 {
00128
00129 addedobject=cwrap->GetCanvas(kFALSE);
00130 }
00131 else
00132 {
00133 addedobject=ob;
00134 }
00135 newcopy=addedobject->Clone();
00136 if(newcopy)
00137 {
00138 monstat->RemoveMonitoredObject(oldobject);
00139 monstat->AddToMonitoredObjectList(newcopy);
00140 TGo4MonitoredObject* MonitoredObj = monstat->GetMonitoredObject(obname);
00141 if(MonitoredObj)
00142 {
00143 MonitoredObj->SetMonitoredObject(newcopy);
00144 MonitoredObj->SetMonObjItem(this);
00145 }
00146 fxItemObject=MonitoredObj;
00147 }
00148 }
00149 }
00150
00151
00152
00153 if(IsExisting(fxDrawCanvas, fxDrawPad))
00154 DrawObj(fxDrawPanel, fxDrawPad);
00155
00156 }
00157
00158 void TGo4QCanvasItem::GetRemoteObj()
00159 {
00160 TGo4ComGetCanvas* com = new TGo4ComGetCanvas(text(0).data());
00161 fxTGo4GUIRegistry->SubmitCommand(com,text(0).data());
00162 }
00163
00164 void TGo4QCanvasItem::AddHistosToMemBrowser(TPad* pad)
00165 {
00166 if(pad==0) return;
00167 TGo4BrowserSlots* browserslots = dynamic_cast <TGo4BrowserSlots *>(fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots"));
00168 if(browserslots)
00169 {
00171
00172
00174
00175 TList* primlist=pad->GetListOfPrimitives();
00176 TIterator* priter=primlist->MakeIterator();
00177 while((ob=priter->Next())!=0)
00178 {
00179 if(ob->InheritsFrom("TH1"))
00180 {
00181 TH1* hist=dynamic_cast<TH1*>(ob);
00182
00183 browserslots->AddObjectToLocalList(hist, kFALSE, kFALSE);
00184
00185 }
00186 else if(ob->InheritsFrom("TPad"))
00187 {
00188 TPad* subp=dynamic_cast<TPad*>(ob);
00189 AddHistosToMemBrowser(subp);
00190 }
00191 }
00192 delete priter;
00193 }
00194
00195 }
00196
00197
00198