00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4BrowserProxy.h"
00015
00016 #include "RVersion.h"
00017 #include "math.h"
00018
00019 #include "TH1.h"
00020 #include "TH2.h"
00021 #include "TH3.h"
00022 #include "THStack.h"
00023 #include "TProfile.h"
00024 #include "TGraph.h"
00025 #include "TGraphErrors.h"
00026 #include "TGraphAsymmErrors.h"
00027 #include "TMultiGraph.h"
00028 #include "TList.h"
00029 #include "TFolder.h"
00030 #include "TDirectory.h"
00031 #include "TFile.h"
00032 #include "TTree.h"
00033
00034 #include "TCanvas.h"
00035 #include "TTimer.h"
00036 #include "TROOT.h"
00037 #include "TObjString.h"
00038 #include "TDatime.h"
00039 #include "TObjectTable.h"
00040 #include "TLatex.h"
00041
00042 #include "TGo4Log.h"
00043 #include "TGo4LockGuard.h"
00044 #include "TGo4Slot.h"
00045 #include "TGo4ObjectProxy.h"
00046 #include "TGo4DirProxy.h"
00047 #include "TGo4LinkProxy.h"
00048 #include "TGo4Iter.h"
00049 #include "TGo4ObjectManager.h"
00050
00051 #include "TGo4Condition.h"
00052 #include "TGo4Fitter.h"
00053 #include "TGo4Parameter.h"
00054 #include "TGo4Picture.h"
00055 #include "TGo4Condition.h"
00056 #include "TGo4PolyCond.h"
00057 #include "TGo4WinCond.h"
00058 #include "TGo4CondArray.h"
00059 #include "TGo4HistogramEntry.h"
00060 #include "TGo4TreeHistogramEntry.h"
00061 #include "TGo4ExportManager.h"
00062
00063 #include "TGo4AnalysisProxy.h"
00064 #include "TGo4HServProxy.h"
00065 #include "TGo4DabcProxy.h"
00066 #include "TVirtualTreePlayer.h"
00067
00068
00069
00070
00071
00072
00073
00074 class TGo4BrowserObjProxy : public TGo4ObjectProxy {
00075 public:
00076 TGo4BrowserObjProxy() : TGo4ObjectProxy() {}
00077 TGo4BrowserObjProxy(TGo4Slot* slot, TObject* obj, Bool_t owner) : TGo4ObjectProxy(obj, owner)
00078 {
00079 if ((slot!=0) && (obj!=0))
00080 TGo4BrowserProxy::SetItemTimeDate(slot);
00081 }
00082
00083 virtual ~TGo4BrowserObjProxy() {}
00084
00085 virtual Bool_t Use() const { return kFALSE; }
00086
00087 virtual Bool_t AssignObject(TGo4Slot* slot, TObject* obj, Bool_t owner)
00088 {
00089 if (fObject==obj) return kTRUE;
00090
00091 Bool_t updatedone = false;
00092
00093 if ((fObject!=0) && (obj!=0))
00094 if ((fObject->IsA()==obj->IsA()) &&
00095 (strcmp(fObject->GetName(), obj->GetName())==0))
00096 updatedone = TGo4BrowserProxy::UpdateObjectContent(fObject, obj);
00097
00098 if (obj!=0)
00099 TGo4BrowserProxy::SetItemTimeDate(slot);
00100
00101 if (updatedone) {
00102 slot->ForwardEvent(slot, TGo4Slot::evObjUpdated);
00103 if (owner) delete obj;
00104 return kTRUE;
00105 }
00106
00107 return TGo4ObjectProxy::AssignObject(slot, obj, owner);
00108 }
00109
00110 virtual void Update(TGo4Slot* slot, Bool_t strong)
00111 {
00112
00113 if ((fObject==0) && !strong) return;
00114
00115 TGo4Slot* parent = slot->GetParent();
00116 TGo4BrowserProxy* browser = 0;
00117
00118 while(parent!=0) {
00119 browser = dynamic_cast<TGo4BrowserProxy*> (parent->GetProxy());
00120 if (browser!=0) break;
00121 parent = parent->GetParent();
00122 }
00123 if (browser!=0)
00124 browser->RequestBrowserObject(slot);
00125 }
00126 };
00127
00128
00129
00130 TGo4BrowserProxy::TGo4BrowserProxy() :
00131 TGo4Proxy(),
00132 fxDataPath(),
00133 fxBrowserPath(),
00134 fxViewPath(),
00135 fbWithRootBrowser(kFALSE),
00136 fxMemoryPath(),
00137 fxOM(0),
00138 fxBrowserSlot(0),
00139 fiMonitoringPeriod(0),
00140 fxMonitorTimer(0),
00141 fbBlockMonitoring(kFALSE),
00142 fiFilterIndex(0),
00143 fxWaitingList(0),
00144 fxClipboard(0),
00145 fxSyncTimer(0),
00146 fbBlockSync(kFALSE),
00147 fDummyTreePlayer(0)
00148 {
00149 }
00150
00151 TGo4BrowserProxy::TGo4BrowserProxy(const char* datapath,
00152 const char* viewpath,
00153 Bool_t withRootBrowser) :
00154 TGo4Proxy(),
00155 fxDataPath(datapath),
00156 fxBrowserPath(),
00157 fxViewPath(viewpath),
00158 fbWithRootBrowser(withRootBrowser),
00159 fxMemoryPath("Workspace"),
00160 fxOM(0),
00161 fxBrowserSlot(0),
00162 fiMonitoringPeriod(0),
00163 fxMonitorTimer(0),
00164 fbBlockMonitoring(kFALSE),
00165 fiFilterIndex(0),
00166 fxWaitingList(0),
00167 fxClipboard(0),
00168 fxSyncTimer(0),
00169 fbBlockSync(kFALSE),
00170 fDummyTreePlayer(0)
00171 {
00172 }
00173
00174 TGo4BrowserProxy::~TGo4BrowserProxy()
00175 {
00176 if (gDebug>1) Info("~TGo4BrowserProxy","Called");
00177
00178 if (fDummyTreePlayer!=0) {
00179 delete fDummyTreePlayer;
00180 fDummyTreePlayer = 0;
00181 }
00182
00183 if (fxWaitingList!=0) {
00184 fxWaitingList->Delete();
00185 delete fxWaitingList;
00186 fxWaitingList = 0;
00187 }
00188
00189 ClearClipboard();
00190
00191 if (fxSyncTimer!=0) {
00192 delete fxSyncTimer;
00193 fxSyncTimer = 0;
00194 }
00195
00196 if (fxMonitorTimer!=0) {
00197 delete fxMonitorTimer;
00198 fxMonitorTimer = 0;
00199 }
00200
00201 if (gDebug>1) Info("~TGo4BrowserProxy","Finished");
00202 }
00203
00204 void TGo4BrowserProxy::Initialize(TGo4Slot* slot)
00205 {
00206 fxOM = slot->GetOM();
00207 fxBrowserSlot = slot;
00208 fxBrowserPath = "";
00209 fxBrowserSlot->ProduceFullName(fxBrowserPath);
00210
00211 gROOT->GetClass("TH1");
00212 gROOT->GetClass("TH1C");
00213 gROOT->GetClass("TH1D");
00214 gROOT->GetClass("TH1F");
00215 gROOT->GetClass("TH1I");
00216 gROOT->GetClass("TH1S");
00217 gROOT->GetClass("TH2");
00218 gROOT->GetClass("TH2C");
00219 gROOT->GetClass("TH2D");
00220 gROOT->GetClass("TH2F");
00221 gROOT->GetClass("TH2I");
00222 gROOT->GetClass("TH2S");
00223 gROOT->GetClass("TH3");
00224 gROOT->GetClass("TH3C");
00225 gROOT->GetClass("TH3D");
00226 gROOT->GetClass("TH3F");
00227 gROOT->GetClass("TH3I");
00228 gROOT->GetClass("TH3S");
00229
00230 gROOT->GetClass("TGo4WinCond");
00231 gROOT->GetClass("TGo4PolyCond");
00232 gROOT->GetClass("TGo4CondArray");
00233
00234 gROOT->GetClass("TGo4Fitter");
00235 gROOT->GetClass("TGo4Parameter");
00236 gROOT->GetClass("TGo4Picture");
00237
00238 gROOT->GetClass("TGo4DynamicEntry");
00239 gROOT->GetClass("TGo4HistogramEntry");
00240 gROOT->GetClass("TGo4TreeHistogramEntry");
00241 gROOT->GetClass("TLatex");
00242
00243 if (fxOM!=0)
00244 fxOM->RegisterLink(fxOM->GetSlot(fxDataPath.Data()), slot, kTRUE);
00245
00246 fiMonitoringPeriod = 0;
00247 }
00248
00249 void TGo4BrowserProxy::Finalize(TGo4Slot* slot)
00250 {
00251 if (fxOM!=0) fxOM->UnregisterLink(slot);
00252 fxOM = 0;
00253 fxBrowserSlot = 0;
00254 fxBrowserPath = "";
00255 }
00256
00257 Bool_t TGo4BrowserProxy::ProcessEvent(TGo4Slot* slot, TGo4Slot* source, Int_t id, void* param)
00258 {
00259 bool ischildevent = source->IsParent(slot);
00260
00261
00262
00263 if ((source!=slot) && !ischildevent) {
00264 if (source->GetParent()!=0)
00265 if (dynamic_cast<TGo4AnalysisProxy*>(source->GetParent()->GetProxy())!=0)
00266 return kFALSE;
00267
00268 if (!fbBlockSync) {
00269 if (fxSyncTimer==0) fxSyncTimer = new TTimer(this, 10, kTRUE);
00270 fbBlockSync = kTRUE;
00271 fxSyncTimer->Start(10, kTRUE);
00272 }
00273
00274 return kFALSE;
00275 } else
00276 if ((source!=slot) && ischildevent) {
00277 if ((id==TGo4Slot::evObjUpdated) || (id==TGo4Slot::evObjAssigned)) {
00278 CheckWaitingList(source);
00279 slot->ForwardEvent(slot, TGo4Slot::evSubslotUpdated, (void*) source);
00280 CheckPictureMonitor(source);
00281 }
00282 }
00283
00284 return kTRUE;
00285 }
00286
00287 void TGo4BrowserProxy::DataSlotName(const char* item, TString& res)
00288 {
00289 res = fxDataPath;
00290 res += "/";
00291 res += item;
00292 }
00293
00294 void TGo4BrowserProxy::BrowserSlotName(const char* item, TString& res)
00295 {
00296 res = fxBrowserPath;
00297 res += "/";
00298 res += item;
00299 }
00300
00301 TGo4Slot* TGo4BrowserProxy::BrowserSlot(const char* item)
00302 {
00303 TString slotname;
00304 BrowserSlotName(item, slotname);
00305 return fxOM->GetSlot(slotname.Data());
00306 }
00307
00308 TGo4Slot* TGo4BrowserProxy::DataSlot(const char* item)
00309 {
00310 TString slotname;
00311 DataSlotName(item, slotname);
00312 return fxOM->GetSlot(slotname.Data());
00313 }
00314
00315 TGo4Slot* TGo4BrowserProxy::BrowserMemorySlot()
00316 {
00317 return BrowserSlot(fxMemoryPath.Data());
00318 }
00319
00320 Bool_t TGo4BrowserProxy::BrowserItemName(TGo4Slot* itemslot, TString& res)
00321 {
00322 if ((itemslot==0) || (fxBrowserSlot==0) || !itemslot->IsParent(fxBrowserSlot)) return kFALSE;
00323 itemslot->ProduceFullName(res, fxBrowserSlot);
00324 return kTRUE;
00325 }
00326
00327 void TGo4BrowserProxy::UpdateBrowserContent()
00328 {
00329 fxBrowserSlot->Update(kFALSE);
00330
00331 TGo4Iter iter(fxOM->GetSlot(fxDataPath), kTRUE);
00332 while(iter.next()) {
00333 TGo4Slot* subslot = iter.getslot();
00334 TGo4AnalysisProxy* ancont =
00335 dynamic_cast<TGo4AnalysisProxy*>(subslot->GetProxy());
00336 if (ancont!=0) subslot->Update(kTRUE);
00337 }
00338 }
00339
00340 Int_t TGo4BrowserProxy::RequestBrowserObject(const char* name, Int_t wait_time)
00341 {
00342 if ((name==0) || (fxBrowserSlot==0) || (fxOM==0)) return 0;
00343
00344 Int_t kind = ItemKind(name);
00345 if (kind==TGo4Access::kndObject) {
00346 TClass* cl = ItemClass(name);
00347 if ((cl==0) || !cl->IsLoaded()) return 0;
00348 }
00349
00350 TString src, tgt;
00351
00352 DataSlotName(name, src);
00353 BrowserSlotName(name, tgt);
00354
00355 return fxOM->RequestObject(src.Data(), tgt.Data(), wait_time);
00356 }
00357
00358 Int_t TGo4BrowserProxy::RequestBrowserObject(TGo4Slot* slot, Int_t wait_time)
00359 {
00360 if ((slot==0) || !slot->IsParent(fxBrowserSlot)) return 0;
00361 TString name;
00362 slot->ProduceFullName(name, fxBrowserSlot);
00363 return RequestBrowserObject(name.Data(), wait_time);
00364 }
00365
00366 Bool_t TGo4BrowserProxy::ProduceExplicitCopy(const char* itemname, const char* tgtpath, Bool_t forcerequest)
00367 {
00368 return ProduceExplicitCopy(BrowserSlot(itemname), tgtpath, forcerequest);
00369 }
00370
00371 Bool_t TGo4BrowserProxy::ProduceExplicitCopy(TGo4Slot* itemslot, const char* tgtpath, Bool_t forcerequest)
00372 {
00373 TGo4LockGuard lock(0,true);
00374
00375 if (itemslot==0) return kFALSE;
00376
00377
00378
00379 TGo4Slot* memslot = BrowserMemorySlot();
00380 if (itemslot->IsParent(memslot) && (tgtpath==0)) return kFALSE;
00381 if (tgtpath!=0) {
00382 TGo4Slot* tgtslot = BrowserSlot(tgtpath);
00383 if (tgtslot==0) return kFALSE;
00384 if ((tgtslot==itemslot) || tgtslot->IsParent(itemslot)) return kFALSE;
00385 }
00386
00387 if (itemslot->NumChilds()>0) {
00388 Bool_t res = kTRUE;
00389 TObjArray childs;
00390 for (Int_t n=0;n<itemslot->NumChilds();n++)
00391 childs.Add(itemslot->GetChild(n));
00392
00393 TString subpath;
00394
00395 if (tgtpath!=0) {
00396 TGo4Slot* tgtslot = DataSlot(tgtpath);
00397 if (tgtslot==0) return kFALSE;
00398 if (tgtslot->GetSlot(itemslot->GetName(), kTRUE)==0) return kFALSE;
00399
00400
00401 SyncBrowserSlots();
00402
00403 subpath = tgtpath;
00404 subpath += "/";
00405 subpath += itemslot->GetName();
00406
00407 tgtpath = subpath.Data();
00408 }
00409
00410 for (Int_t n=0;n<=childs.GetLast();n++) {
00411 Bool_t res1 = ProduceExplicitCopy((TGo4Slot*)childs.At(n), tgtpath, forcerequest);
00412 res = res || res1;
00413 }
00414
00415 return res;
00416 }
00417
00418 if (ItemKind(itemslot)!=TGo4Access::kndObject) return kFALSE;
00419
00420 TString pathname;
00421 if (tgtpath!=0) {
00422 TGo4Slot* tgtslot = ItemSlot(tgtpath);
00423 if (tgtslot==0) return kFALSE;
00424 if (!tgtslot->IsParent(memslot) && (tgtslot!=memslot)) return kFALSE;
00425 if (itemslot->GetParent()==tgtslot) return kFALSE;
00426 if (memslot!=tgtslot)
00427 tgtslot->ProduceFullName(pathname, memslot);
00428 } else {
00429 if (!BrowserItemName(itemslot->GetParent(), pathname)) return kFALSE;
00430 }
00431
00432 TObject* obj = itemslot->GetAssignedObject();
00433
00434 if ((obj==0) || forcerequest) {
00435 Int_t res = RequestBrowserObject(itemslot);
00436 if (res==0) return kFALSE;
00437 obj = 0;
00438 if ((res==1) || !forcerequest)
00439 obj = itemslot->GetAssignedObject();
00440 }
00441
00442 if (obj!=0) {
00443 TString res = SaveToMemory(pathname, obj->Clone(), kTRUE);
00444 return res.Length()>0;
00445 }
00446
00447 AddWaitingList(itemslot, tgtpath);
00448
00449 return kTRUE;
00450 }
00451
00452 void TGo4BrowserProxy::ClearClipboard()
00453 {
00454 if (fxClipboard!=0) {
00455 fxClipboard->Delete();
00456 delete fxClipboard;
00457 fxClipboard = 0;
00458 }
00459 }
00460
00461 void TGo4BrowserProxy::AddToClipboard(const char* itemname)
00462 {
00463 if (fxClipboard==0) fxClipboard = new TObjArray;
00464
00465 if (fxClipboard->FindObject(itemname)) return;
00466
00467 TGo4Slot* itemslot = BrowserSlot(itemname);
00468 if (itemslot==0) return;
00469
00470
00471 for (Int_t n=0;n<=fxClipboard->GetLast();n++) {
00472 TNamed* nm = (TNamed*) fxClipboard->At(n);
00473 TGo4Slot* slot = ItemSlot(nm->GetName());
00474 if (slot==0) continue;
00475 if (itemslot->IsParent(slot)) return;
00476 }
00477
00478 fxClipboard->Add(new TNamed(itemname, "clipbboard item"));
00479 }
00480
00481 Bool_t TGo4BrowserProxy::IsClipboard()
00482 {
00483 return fxClipboard!=0;
00484 }
00485
00486 void TGo4BrowserProxy::CopyClipboard(const char* tgtpath, Bool_t forcerequest)
00487 {
00488 if (fxClipboard==0) return;
00489
00490 for(Int_t n=0;n<=fxClipboard->GetLast();n++) {
00491 TNamed* nm = (TNamed*) fxClipboard->At(n);
00492
00493
00494 ProduceExplicitCopy(nm->GetName(), tgtpath, forcerequest);
00495 }
00496 }
00497
00498 void TGo4BrowserProxy::OpenFile(const char* fname)
00499 {
00500 if ((fname==0) || (*fname==0)) return;
00501
00502 fxOM->AddFile(fxDataPath.Data(), fname);
00503 }
00504
00505 Bool_t TGo4BrowserProxy::ConnectDabc(const char* nodename)
00506 {
00507 if ((nodename==0) || (*nodename==0)) return kFALSE;
00508
00509 TGo4DabcProxy* proxy = new TGo4DabcProxy();
00510 if (!proxy->Connect(nodename)) {
00511 delete proxy;
00512 return kFALSE;
00513 }
00514
00515 const char* slotname = nodename;
00516 if (strncmp(slotname,"dabc://",7)==0) slotname+=7;
00517
00518 fxOM->AddProxy(fxDataPath.Data(), proxy, slotname, "TGo4DabcProxy");
00519
00520 return kTRUE;
00521 }
00522
00523
00524 Bool_t TGo4BrowserProxy::ConnectHServer(const char* servername,
00525 Int_t portnumber,
00526 const char* basename,
00527 const char* userpass,
00528 const char* filter)
00529 {
00530 Bool_t res = kFALSE;
00531
00532 TGo4HServProxy* hserv = new TGo4HServProxy;
00533
00534 hserv->SetHServConfig(servername,
00535 portnumber,
00536 basename,
00537 userpass,
00538 filter);
00539
00540 if (hserv->RequestHistosList()) {
00541 TString capt = "HServ_";
00542 capt += basename;
00543
00544 fxOM->AddProxy(fxDataPath.Data(), hserv, capt.Data(), "Connection to histogram server");
00545 res = kTRUE;
00546 } else {
00547 delete hserv;
00548 }
00549 return res;
00550 }
00551
00552 void TGo4BrowserProxy::MakeFilesList(TObjArray* arr)
00553 {
00554 if (arr==0) return;
00555 arr->Clear();
00556 TGo4Slot* slot = fxOM->GetSlot(fxDataPath.Data());
00557 if (slot==0) return;
00558
00559 for(Int_t n=0;n<slot->NumChilds();n++) {
00560 TGo4Slot* subslot = slot->GetChild(n);
00561 TGo4DirProxy* pr = dynamic_cast<TGo4DirProxy*> (subslot->GetProxy());
00562 if ((pr!=0) && pr->IsFile())
00563 arr->Add(pr);
00564 }
00565 }
00566
00567 void TGo4BrowserProxy::MakeHServerList(TObjArray* arr)
00568 {
00569 if (arr==0) return;
00570 arr->Clear();
00571 TGo4Slot* slot = fxOM->GetSlot(fxDataPath.Data());
00572 if (slot==0) return;
00573
00574 for(Int_t n=0;n<slot->NumChilds();n++) {
00575 TGo4Slot* subslot = slot->GetChild(n);
00576 TGo4HServProxy* pr = dynamic_cast<TGo4HServProxy*> (subslot->GetProxy());
00577 if (pr!=0) arr->Add(pr);
00578 }
00579 }
00580
00581 void TGo4BrowserProxy::MakeDabcList(TObjArray* arr)
00582 {
00583 if (arr==0) return;
00584 arr->Clear();
00585 TGo4Slot* slot = fxOM->GetSlot(fxDataPath.Data());
00586 if (slot==0) return;
00587
00588 for(Int_t n=0;n<slot->NumChilds();n++) {
00589 TGo4Slot* subslot = slot->GetChild(n);
00590 TGo4DabcProxy* pr = dynamic_cast<TGo4DabcProxy*> (subslot->GetProxy());
00591 if (pr!=0) arr->Add(pr);
00592 }
00593 }
00594
00595
00596 void TGo4BrowserProxy::RequestObjectStatus(const char* name, TGo4Slot* tgtslot)
00597 {
00598 TString objname;
00599 TGo4AnalysisProxy* an = DefineAnalysisObject(name, objname);
00600 if (an!=0)
00601 an->RequestObjectStatus(objname.Data(), tgtslot);
00602 }
00603
00604 void TGo4BrowserProxy::RequestEventStatus(const char* evname,
00605 Bool_t astree,
00606 TGo4Slot* tgtslot)
00607 {
00608 TString objname;
00609 TGo4AnalysisProxy* an = DefineAnalysisObject(evname, objname);
00610 if (an!=0)
00611 an->RequestEventStatus(objname.Data(), astree, tgtslot);
00612 }
00613
00614 void TGo4BrowserProxy::PerformTreeDraw(const char* treename,
00615 const char* Xexp,
00616 const char* Yexp,
00617 const char* Zexp,
00618 const char* cutcond,
00619 const char* hname,
00620 TString& createdhistoname)
00621 {
00622 if (strlen(Xexp)==0) return;
00623
00624 TString varexp(Xexp);
00625
00626 if(strlen(Yexp)>0) {
00627 varexp = TString(Yexp) + TString(":") + varexp;
00628 if(strlen(Zexp)>0)
00629 varexp = TString(Zexp) + TString(":") + varexp;
00630 }
00631
00632 int drawdim = varexp.CountChar(':') + 1;
00633 if (drawdim>3) drawdim = 3;
00634
00635
00636 if (IsItemRemote(treename)) {
00637 TString objname;
00638 TGo4AnalysisProxy* an = DefineAnalysisObject(treename, objname);
00639 if (an!=0) {
00640 TString analhname(hname);
00641
00642 Int_t cnt = 0;
00643 TString anitem = "abcdef";
00644 if (analhname.Length()==0)
00645 while (anitem.Length()>0) {
00646 analhname = "hTreeDraw";
00647 if (cnt>0) { analhname+="_"; analhname+=cnt; }
00648 cnt++;
00649 anitem = FindItemInAnalysis(analhname.Data());
00650 }
00651
00652 an->RemoteTreeDraw(objname.Data(), varexp.Data(), cutcond, analhname.Data());
00653 an->DelayedRefreshNamesList(3);
00654 }
00655
00656 createdhistoname = "";
00657
00658 return;
00659 }
00660
00661
00662
00663 TString treeslotname;
00664 DataSlotName(treename, treeslotname);
00665 TTree* SelectedTree = dynamic_cast<TTree*> (fxOM->GetObject(treeslotname.Data()));
00666 if (SelectedTree==0) return;
00667
00668 TString histoname(hname), hslotname;
00669 BrowserSlotName(hname, hslotname);
00670 TGo4Slot* hslot = fxOM->GetSlot(hslotname.Data());
00671
00672 TH1* histo = 0;
00673
00674 if ((hslot!=0) && !IsItemRemote(hslot)) {
00675 histo = dynamic_cast<TH1*> (GetBrowserObject(hname, 1));
00676 if ((histo!=0) && (drawdim!=histo->GetDimension())) {
00677 histo = 0;
00678 histoname = "";
00679 }
00680 }
00681
00682
00683 int cnt = 0;
00684 if ((histo==0) && (histoname.Length()==0))
00685 do {
00686 histoname = fxMemoryPath;
00687 histoname += "/hTreeDraw_";
00688 histoname += cnt++;
00689 BrowserSlotName(histoname, hslotname);
00690 hslot = fxOM->GetSlot(hslotname.Data());
00691 } while (hslot!=0);
00692
00693 TString hfoldername, hobjectname;
00694 TGo4Slot::ProduceFolderAndName(histoname.Data(), hfoldername, hobjectname);
00695
00696 if (histo!=0)
00697 hobjectname = histo->GetName();
00698
00699 varexp += ">>+";
00700 varexp += hobjectname;
00701
00702 TDirectory* oldhisdir = histo ? histo->GetDirectory() : 0;
00703 TDirectory* savdir = gDirectory;
00704 gDirectory = 0;
00705 TDirectory dummydir("DummyTreeDraw","Dummy directory to call tree draw");
00706 dummydir.cd();
00707 if (histo!=0)
00708 histo->SetDirectory(&dummydir);
00709
00710 SelectedTree->Draw(varexp, cutcond, "goff", 10000000, 0);
00711
00712 if (histo==0) {
00713 histo = dynamic_cast<TH1*> (dummydir.FindObject(hobjectname));
00714 if(histo!=0) {
00715 histo->SetDirectory(0);
00716 createdhistoname = SaveToMemory(0, histo, kTRUE);
00717
00718 SyncBrowserSlots();
00719 }
00720 } else {
00721 histo->SetDirectory(oldhisdir);
00722 TGo4Slot* brslot = BrowserSlot(hname);
00723 if (brslot!=0) brslot->ForwardEvent(brslot, TGo4Slot::evObjUpdated);
00724 }
00725 dummydir.Clear();
00726 savdir->cd();
00727
00728 #if ROOT_VERSION_CODE < ROOT_VERSION(5,13,1)
00729
00730
00731
00732 if (fDummyTreePlayer!=0) delete fDummyTreePlayer;
00733 fDummyTreePlayer = TVirtualTreePlayer::TreePlayer(0);
00734
00735 #endif
00736 }
00737
00738 TGo4Slot* TGo4BrowserProxy::FindAnalysisSlot(Bool_t databranch)
00739 {
00740 TGo4Slot* dataslot = fxOM->GetSlot(fxDataPath.Data());
00741
00742 TGo4Iter iter(dataslot, kTRUE);
00743 TGo4Slot* res = 0;
00744
00745 while (iter.next()) {
00746 TGo4AnalysisProxy* cont = dynamic_cast<TGo4AnalysisProxy*>
00747 (iter.getslot()->GetProxy());
00748 if (cont!=0) {
00749 res = iter.getslot();
00750 break;
00751 }
00752 }
00753
00754 if ((res!=0) && !databranch) {
00755 TString itemname;
00756 res->ProduceFullName(itemname, dataslot);
00757 res = BrowserSlot(itemname.Data());
00758 }
00759
00760 return res;
00761 }
00762
00763 TGo4AnalysisProxy* TGo4BrowserProxy::FindAnalysis(const char* itemname)
00764 {
00765 TString slotname;
00766 DataSlotName(itemname, slotname);
00767
00768 TGo4Slot* slot = fxOM->FindSlot(slotname.Data());
00769 if ((slot==0) || (itemname==0))
00770 slot = FindAnalysisSlot(kTRUE);
00771
00772 return slot==0 ? 0 : dynamic_cast<TGo4AnalysisProxy*>(slot->GetProxy());
00773 }
00774
00775 TString TGo4BrowserProxy::FindItemInAnalysis(const char* objname)
00776 {
00777 TGo4Slot* analslot = FindAnalysisSlot(kTRUE);
00778 if ((analslot==0) || (objname==0)) return TString("");
00779
00780 TGo4Iter iter(analslot);
00781 while (iter.next()) {
00782 if (strcmp(iter.getname(), objname)!=0) continue;
00783 TString res;
00784 analslot->ProduceFullName(res, DataSlot(""));
00785 res+="/";
00786 res+=iter.getfullname();
00787 return res;
00788 }
00789
00790 return TString("");
00791 }
00792
00793 TString TGo4BrowserProxy::FindItem(const char* objname)
00794 {
00795 TGo4Slot* topslot = BrowserTopSlot();
00796 if ((topslot==0) || (objname==0)) return TString("");
00797
00798 TGo4Iter iter(topslot);
00799 while (iter.next())
00800 if (strcmp(iter.getname(), objname)==0)
00801 return iter.getfullname();
00802
00803 return TString("");
00804 }
00805
00806 TGo4AnalysisProxy* TGo4BrowserProxy::DefineAnalysisObject(const char* itemname, TString& analysisname)
00807 {
00808 TString slotname;
00809 DataSlotName(itemname, slotname);
00810 const char* objectname = 0;
00811
00812 TGo4Slot* anslot = fxOM->FindSlot(slotname.Data(), &objectname);
00813
00814 TGo4AnalysisProxy* an = anslot==0 ? 0 :
00815 dynamic_cast<TGo4AnalysisProxy*>(anslot->GetProxy());
00816 if (an!=0)
00817 analysisname = objectname;
00818 return an;
00819 }
00820
00821 TGo4HServProxy* TGo4BrowserProxy::DefineHServerProxy(const char* itemname)
00822 {
00823 TGo4Slot* slot = DataSlot(itemname);
00824 if (slot==0) return 0;
00825
00826 while (slot!=0) {
00827 TGo4HServProxy* pr = dynamic_cast<TGo4HServProxy*> (slot->GetProxy());
00828 if (pr!=0) return pr;
00829 slot = slot->GetParent();
00830 }
00831
00832 return 0;
00833 }
00834
00835 TGo4DabcProxy* TGo4BrowserProxy::DefineDabcProxy(const char* itemname)
00836 {
00837 TGo4Slot* slot = DataSlot(itemname);
00838 if (slot==0) return 0;
00839
00840 while (slot!=0) {
00841 TGo4DabcProxy* pr = dynamic_cast<TGo4DabcProxy*> (slot->GetProxy());
00842 if (pr!=0) return pr;
00843 slot = slot->GetParent();
00844 }
00845
00846 return 0;
00847 }
00848
00849
00850 Bool_t TGo4BrowserProxy::UpdateAnalysisItem(const char* itemname, TObject* obj)
00851 {
00852 TGo4Slot* slot = BrowserSlot(itemname);
00853 if (slot==0) return kFALSE;
00854
00855 if (obj==0) obj = GetBrowserObject(itemname, 0);
00856 if (obj==0) return kFALSE;
00857
00858 const char* analysisname = 0;
00859 TGo4Slot* anslot = 0;
00860 TString slotname;
00861
00862 if (IsItemRemote(itemname)) {
00863 DataSlotName(itemname, slotname);
00864 anslot = fxOM->FindSlot(slotname.Data(), &analysisname);
00865 }
00866
00867 if (anslot==0) {
00868 analysisname = 0;
00869 anslot = FindAnalysisSlot(kTRUE);
00870 }
00871
00872 if (anslot==0) return kFALSE;
00873
00874 TGo4AnalysisProxy* an =
00875 dynamic_cast<TGo4AnalysisProxy*>(anslot->GetProxy());
00876
00877 return an==0 ? kFALSE : an->UpdateAnalysisObject(analysisname, obj);
00878 }
00879
00880 void TGo4BrowserProxy::FetchItem(const char* itemname, Int_t wait_time)
00881 {
00882 TGo4Slot* itemslot = ItemSlot(itemname);
00883 if (itemslot==0) return;
00884
00885 if (ItemKind(itemslot)==TGo4Access::kndObject)
00886 RequestBrowserObject(itemslot, wait_time);
00887
00888 TGo4Iter iter(itemslot, kTRUE);
00889 while (iter.next()) {
00890 TGo4Slot* subslot = iter.getslot();
00891 if (ItemKind(subslot)==TGo4Access::kndObject)
00892 RequestBrowserObject(subslot, wait_time);
00893 }
00894
00895 if (wait_time==0) return;
00896 }
00897
00898 void TGo4BrowserProxy::RedrawItem(const char* itemname)
00899 {
00900 TGo4Slot* slot = BrowserSlot(itemname);
00901 if (slot!=0) {
00902 slot->ForwardEvent(slot, TGo4Slot::evObjUpdated);
00903 SetItemTimeDate(slot);
00904 }
00905 }
00906
00907 TObject* TGo4BrowserProxy::GetBrowserObject(const char* name, int update)
00908
00909
00910
00911
00912 {
00913 if ((name==0) || (fxBrowserSlot==0) || (fxOM==0)) return 0;
00914
00915 TString src, tgt;
00916 BrowserSlotName(name, tgt);
00917 TGo4Slot* guislot = fxOM->GetSlot(tgt.Data());
00918
00919 if (guislot==0) return 0;
00920
00921 TObject* obj = guislot->GetAssignedObject();
00922
00923 if ((update==0) || ((update==1) && (obj!=0))) return obj;
00924
00925 if (guislot->IsParent(BrowserMemorySlot())) return obj;
00926
00927 DataSlotName(name, src);
00928
00929 fxOM->RequestObject(src.Data(), tgt.Data(), (update<10) ? 0 : update);
00930
00931 return guislot->GetAssignedObject();
00932 }
00933
00934 void TGo4BrowserProxy::SetItemsFilter(Int_t filter)
00935 {
00936 fiFilterIndex = filter;
00937 InformBrowserUpdate();
00938 }
00939
00940 void TGo4BrowserProxy::InformBrowserUpdate()
00941 {
00942 if (fxBrowserSlot!=0)
00943 fxBrowserSlot->ForwardEvent(fxBrowserSlot, TGo4Slot::evObjUpdated);
00944 }
00945
00946 Bool_t TGo4BrowserProxy::DeleteDataSource(TGo4Slot* itemslot)
00947 {
00948 if ((itemslot==0) || (fxBrowserSlot==0) || (fxOM==0)) return kFALSE;
00949
00950 Int_t cando = ItemCanDo(itemslot);
00951
00952 Bool_t ismemoryitem = itemslot->IsParent(BrowserMemorySlot());
00953
00954 if (!ismemoryitem && !CanCloseItem(cando) && !IsCanDelete(itemslot)) return kFALSE;
00955
00956 if (itemslot->GetPar("::CopyObject")!=0) {
00957 delete itemslot;
00958 InformBrowserUpdate();
00959 } else {
00960 TString name = itemslot->GetFullName(fxBrowserSlot);
00961 TString src;
00962 DataSlotName(name.Data(), src);
00963 fxOM->DeleteSlot(src.Data());
00964 }
00965 return kTRUE;
00966 }
00967
00968 void TGo4BrowserProxy::DoItemMonitor(TGo4Slot* slot)
00969 {
00970 if ((slot==0) || (!slot->IsParent(fxBrowserSlot))) return;
00971
00972 slot->Update(kFALSE);
00973 }
00974
00975
00976 TGo4Slot* TGo4BrowserProxy::BrowserTopSlot()
00977 {
00978 return fxBrowserSlot;
00979 }
00980
00981 TGo4Slot* TGo4BrowserProxy::ItemSlot(const char* itemname)
00982 {
00983 TString slotname;
00984 BrowserSlotName(itemname, slotname);
00985 return fxOM->GetSlot(slotname.Data());
00986 }
00987
00988
00989 Bool_t TGo4BrowserProxy::DefineTreeName(const char* itemname, TString& treename)
00990 {
00991 TString slotname;
00992 BrowserSlotName(itemname, slotname);
00993 TGo4Slot* slot = fxOM->GetSlot(slotname.Data());
00994 if (slot==0) return kFALSE;
00995
00996 TGo4Slot* treeslot = slot;
00997 while (treeslot!=0) {
00998 TClass* cl = ItemClass(treeslot);
00999 if ((cl!=0) && (cl->InheritsFrom(TTree::Class()))) break;
01000 treeslot = treeslot->GetParent();
01001 }
01002 if (treeslot==0) return kFALSE;
01003
01004 treeslot->ProduceFullName(treename, fxBrowserSlot);
01005
01006 return kTRUE;
01007 }
01008
01009 Bool_t TGo4BrowserProxy::DefineLeafName(const char* itemname, const char* treename, TString& leafname)
01010 {
01011 if ((itemname==0) || (treename==0)) return kFALSE;
01012
01013 TString slotname;
01014 BrowserSlotName(itemname, slotname);
01015 TGo4Slot* slot = fxOM->GetSlot(slotname.Data());
01016 if (slot==0) return kFALSE;
01017
01018 if (ItemKind(slot)!=TGo4Access::kndTreeLeaf) return kFALSE;
01019
01020 int ilen = strlen(itemname);
01021 int tlen = strlen(treename);
01022 if ((ilen<tlen) || (strncmp(itemname, treename, tlen)!=0)) return kFALSE;
01023
01024 leafname = slot->GetName();
01025 return kTRUE;
01026 }
01027
01028 Bool_t TGo4BrowserProxy::DefineRelatedObject(const char* itemname, const char* objname, TString& objectitem)
01029 {
01030 if ((objname==0) || (*objname==0)) return kFALSE;
01031
01032 if (BrowserSlot(objname)!=0) {
01033 objectitem = objname;
01034 return kTRUE;
01035 }
01036
01037 TGo4Slot* picslot = BrowserSlot(itemname);
01038
01039 if (picslot!=0) {
01040 TGo4Slot* searchslot = picslot->GetParent();
01041
01042 while ((searchslot!=0) && (searchslot!=fxBrowserSlot)) {
01043 TString searchname;
01044 searchslot->ProduceFullName(searchname, fxBrowserSlot);
01045 if (*objname!='/') searchname+="/";
01046 searchname+=objname;
01047
01048 TString fullname;
01049 BrowserSlotName(searchname.Data(), fullname);
01050
01051 TGo4Slot* slot = fxOM->GetSlot(searchname.Data());
01052
01053 if (slot!=0)
01054
01055 {
01056 objectitem = searchname;
01057 return kTRUE;
01058 }
01059
01060 searchslot = searchslot->GetParent();
01061 }
01062 }
01063
01064 if (strchr(objname,'/')!=0) return kFALSE;
01065
01066 TGo4Slot* searchslot = (picslot == 0) ? fxBrowserSlot : picslot->GetParent();
01067
01068 do {
01069 TGo4Iter iter(searchslot, kTRUE);
01070 while (iter.next()) {
01071
01072 if (strcmp(objname, iter.getname())!=0) continue;
01073 TGo4Slot* subslot = iter.getslot();
01074
01075
01076 subslot->ProduceFullName(objectitem, fxBrowserSlot);
01077 return kTRUE;
01078 }
01079 if (searchslot==fxBrowserSlot) break;
01080 searchslot = searchslot->GetParent();
01081 } while (searchslot!=0);
01082
01083 return kFALSE;
01084 }
01085
01086 Bool_t TGo4BrowserProxy::DefineFileObject(const char* itemname, TString& fitemname, const char** filepath)
01087 {
01088 TGo4Slot* slot = BrowserSlot(itemname);
01089 if (slot==0) return kFALSE;
01090
01091 if (slot->GetAssignedObject()==0) return kFALSE;
01092
01093 while (slot!=fxBrowserSlot) {
01094 TClass* cl = ItemClass(slot);
01095 if ((cl!=0) && (cl->InheritsFrom(TFile::Class()))) break;
01096 slot = slot->GetParent();
01097 }
01098 if (slot==fxBrowserSlot) return kFALSE;
01099
01100 fitemname = "";
01101 slot->ProduceFullName(fitemname, fxBrowserSlot);
01102
01103 *filepath = itemname + fitemname.Length();
01104 if (**filepath=='/') (*filepath)++;
01105
01106
01107
01108
01109 return kTRUE;
01110 }
01111
01112 Bool_t TGo4BrowserProxy::UpdateObjectInFile(const char* itemname, const char* fileitemname, const char* filepath)
01113 {
01114 TGo4Slot* slot = BrowserSlot(itemname);
01115 if (slot==0) return kFALSE;
01116
01117 TObject* obj = slot->GetAssignedObject();
01118 if (obj==0) return kFALSE;
01119
01120 TGo4Slot* fileslot = DataSlot(fileitemname);
01121 if (fileslot==0) return kFALSE;
01122
01123 TGo4DirProxy* dircont = dynamic_cast<TGo4DirProxy*> (fileslot->GetProxy());
01124 if (dircont==0) return kFALSE;
01125
01126 Bool_t res = dircont->UpdateObjectInFile(filepath, obj);
01127
01128 if(res)
01129 fileslot->ForwardEvent(fileslot, TGo4Slot::evObjUpdated);
01130
01131 return res;
01132 }
01133
01134 Bool_t TGo4BrowserProxy::SaveItemToFile(const char* itemname, const char* filename, const char* subfolder)
01135 {
01136 TGo4Slot* slot = BrowserSlot(itemname);
01137 if (slot==0) return kFALSE;
01138
01139 TObject* obj = slot->GetAssignedObject();
01140 if (obj==0) return kFALSE;
01141
01142 TFile* f = TFile::Open(filename,"UPDATE");
01143 if (f==0) return kFALSE;
01144
01145 TDirectory* dir = f;
01146
01147 if ((subfolder!=0) && (*subfolder!=0)) {
01148 dir = dynamic_cast<TDirectory*> (f->Get(subfolder));
01149 if (dir==0) dir = f;
01150 }
01151
01152 dir->cd();
01153 bool res = dir->WriteTObject(obj, obj->GetName(), "Overwrite") > 0;
01154
01155 if (obj->InheritsFrom(TH1::Class()))
01156 ((TH1*) obj)->SetDirectory(0);
01157
01158 delete f;
01159
01160 return res;
01161 }
01162
01163 void TGo4BrowserProxy::ExportItemsTo(TObjArray* items,
01164 Bool_t fetchitems,
01165 const char* filename,
01166 const char* filedir,
01167 const char* format,
01168 const char* description)
01169 {
01170 if ((items==0) || (items->GetSize()==0)) return;
01171
01172 TString convert;
01173 if(format==0)
01174 convert="ROOT";
01175 else
01176 convert=format;
01177
01178 Go4Export_t filter;
01179 if(convert.Contains("ASCII")) {
01180 TGo4Log::Message(0,"Export filter is ASCII");
01181 filter=GO4EX_ASCII;
01182 } else
01183 if (convert.Contains("Radware")) {
01184 TGo4Log::Message(0,"Export filter is Radware");
01185 filter=GO4EX_RADWARE;
01186 } else
01187 if (convert.Contains("ROOT XML")) {
01188 TGo4Log::Message(0,"Export filter is ROOT XML");
01189 filter=GO4EX_XML;
01190 } else
01191 if (convert.Contains("ROOT")) {
01192 TGo4Log::Message(0,"Export filter is ROOT");
01193 filter=GO4EX_ROOT;
01194 } else {
01195 TGo4Log::Message(0,"Export filter is unknown, using ROOT");
01196 filter=GO4EX_ROOT;
01197 }
01198
01199
01200 if (((filter==GO4EX_ROOT) || (filter==GO4EX_XML)) && (items->GetLast()==0)) {
01201 TObjString* str = dynamic_cast<TObjString*> (items->At(0));
01202
01203 TGo4Slot* itemslot = (str==0) ? 0 : ItemSlot(str->GetName());
01204
01205 TString fname = filename;
01206
01207 if (filter==GO4EX_XML) {
01208 if(!fname.Contains(".xml")) fname.Append(".xml");
01209 } else {
01210 if(!fname.Contains(".root")) fname.Append(".root");
01211 }
01212
01213 if ((itemslot!=0) && (itemslot->NumChilds()>0)) {
01214 SaveBrowserToFile(fname.Data(), fetchitems, str->GetName(), description);
01215 return;
01216 }
01217 }
01218
01219 TGo4ExportManager exman("BrowserExport");
01220 exman.SetOutFile(filename);
01221 exman.SetOutFileComment(description);
01222 exman.SetStartDir();
01223 exman.SetCurrentDir(filedir);
01224
01225 TGo4Log::Message(1,"Exporting selected browser objects to %s",convert.Data());
01226
01227 TObjArray objs;
01228 for (int n=0;n<=items->GetLast();n++) {
01229 TObjString* str = dynamic_cast<TObjString*> (items->At(n));
01230 if (str==0) continue;
01231 TObject* obj = GetBrowserObject(str->GetName(), 0);
01232 if (obj==0)
01233 obj = GetBrowserObject(str->GetName(), 2000);
01234
01235 if (obj!=0) objs.Add(obj);
01236 }
01237
01238 exman.Export(&objs, filter);
01239 }
01240
01241 Bool_t TGo4BrowserProxy::SaveBrowserToFile(const char* filename,
01242 Bool_t prefetch,
01243 const char* selectedpath,
01244 const char* description)
01245 {
01246 TGo4Slot* toppath = BrowserSlot(selectedpath);
01247
01248 if (toppath==0) return kFALSE;
01249
01250 if (prefetch)
01251 FetchItem(selectedpath, 2000);
01252
01253 TFile* f = TFile::Open(filename, "recreate", description);
01254 if (f==0) return kFALSE;
01255
01256 fxOM->SaveDataToFile(f, kTRUE, toppath);
01257
01258 delete f;
01259
01260 return kTRUE;
01261 }
01262
01263 Bool_t TGo4BrowserProxy::IsItemRemote(const char* name)
01264 {
01265 return IsItemRemote(ItemSlot(name));
01266 }
01267
01268 Bool_t TGo4BrowserProxy::IsItemRemote(TGo4Slot* slot)
01269 {
01270 if (slot==0) return kFALSE;
01271 Int_t remote;
01272 if (!slot->GetIntPar("GUI::Remote", remote)) return kFALSE;
01273 return remote!=0;
01274 }
01275
01276 Bool_t TGo4BrowserProxy::IsAnalysisItem(const char* name)
01277 {
01278 TString analysisname;
01279 return DefineAnalysisObject(name, analysisname)!=0;
01280 }
01281
01282
01283 void TGo4BrowserProxy::SetItemTimeDate(TGo4Slot* slot, const char* stime, const char* sdate)
01284 {
01285 if ((stime!=0) && (sdate!=0)) {
01286 slot->SetPar("GUI::Time", stime);
01287 slot->SetPar("GUI::Date", sdate);
01288 return;
01289 }
01290
01291 TDatime t;
01292 const char* datetime = t.AsSQLString();
01293 char* time = (char*) strchr(datetime, ' ');
01294 if (time==0) {
01295 slot->SetPar("GUI::Time",datetime);
01296 slot->SetPar("GUI::Date",datetime);
01297 } else {
01298 slot->SetPar("GUI::Time", time+1);
01299 *time = 0;
01300 slot->SetPar("GUI::Date", datetime);
01301 }
01302 }
01303
01304 const char* TGo4BrowserProxy::ItemTime(TGo4Slot* slot)
01305 {
01306 return slot==0 ? 0 : slot->GetPar("GUI::Time");
01307 }
01308
01309 const char* TGo4BrowserProxy::ItemDate(TGo4Slot* slot)
01310 {
01311 return slot==0 ? 0 : slot->GetPar("GUI::Date");
01312 }
01313
01314 void TGo4BrowserProxy::SetLinkedName(TGo4Slot* slot, const char* itemname)
01315 {
01316 if (slot!=0)
01317 slot->SetPar("::LinkedItem", itemname);
01318 }
01319
01320 const char* TGo4BrowserProxy::GetLinkedName(TGo4Slot* slot)
01321 {
01322 return (slot==0) ? 0 : slot->GetPar("::LinkedItem");
01323 }
01324
01325 Int_t TGo4BrowserProxy::ItemKind(const char* name)
01326 {
01327 return ItemKind(ItemSlot(name));
01328 }
01329
01330 Int_t TGo4BrowserProxy::ItemKind(TGo4Slot* slot)
01331 {
01332 if (slot==0) return TGo4Access::kndNone;
01333 Int_t kind;
01334 if (!slot->GetIntPar("GUI::Kind", kind)) return TGo4Access::kndNone;
01335 return kind;
01336 }
01337
01338 void TGo4BrowserProxy::SetItemKind(TGo4Slot* slot, Int_t kind, const char* classname, const char* info, Int_t sizeinfo)
01339 {
01340 if (slot==0) return;
01341 if (kind>=0) slot->SetIntPar("GUI::Kind", kind);
01342 else slot->RemovePar("GUI::Kind");
01343 slot->SetPar("GUI::Class", classname);
01344 slot->SetPar("GUI::Info", info);
01345 slot->SetIntPar("GUI::SizeInfo", sizeinfo);
01346 }
01347
01348 const char* TGo4BrowserProxy::ItemInfo(TGo4Slot* slot)
01349 {
01350 return slot==0 ? 0 : slot->GetPar("GUI::Info");
01351 }
01352
01353 Int_t TGo4BrowserProxy::ItemSizeInfo(TGo4Slot* slot)
01354 {
01355 if (slot==0) return -1;
01356 Int_t sizeinfo;
01357 if (!slot->GetIntPar("GUI::SizeInfo", sizeinfo)) return -1;
01358 return sizeinfo;
01359 }
01360
01361 void TGo4BrowserProxy::SetCalcSize(TGo4Slot* slot, Int_t size)
01362 {
01363 if (slot!=0)
01364 slot->SetIntPar("GUI::CalcSize", size);
01365 }
01366
01367 Int_t TGo4BrowserProxy::GetCalcSize(TGo4Slot* slot)
01368 {
01369 if (slot==0) return 0;
01370 Int_t size;
01371 if (!slot->GetIntPar("GUI::CalcSize", size)) return 0;
01372 return size;
01373 }
01374
01375 TClass* TGo4BrowserProxy::ItemClass(TGo4Slot* slot)
01376 {
01377 const char* classname = ItemClassName(slot);
01378
01379 return classname==0 ? 0 : gROOT->GetClass(classname);
01380 }
01381
01382
01383 TClass* TGo4BrowserProxy::ItemClass(const char* name)
01384 {
01385 return ItemClass(ItemSlot(name));
01386 }
01387
01388 const char* TGo4BrowserProxy::ItemClassName(TGo4Slot* slot)
01389 {
01390 return slot==0 ? 0 : slot->GetPar("GUI::Class");
01391 }
01392
01393 const char* TGo4BrowserProxy::ItemClassName(const char* name)
01394 {
01395 return ItemClassName(ItemSlot(name));
01396 }
01397
01398 Int_t TGo4BrowserProxy::ItemCanDo(const char* name)
01399 {
01400 return ItemCanDo(ItemSlot(name));
01401 }
01402
01403 Int_t TGo4BrowserProxy::ItemCanDo(TGo4Slot* slot)
01404 {
01405 if (slot==0) return 0;
01406
01407 Int_t cando;
01408 if (!slot->GetIntPar("GUI::CanDo", cando)) return 0;
01409 return cando;
01410 }
01411
01412 void TGo4BrowserProxy::SetItemCanDo(TGo4Slot* slot, Int_t cando)
01413 {
01414 if (slot!=0) slot->SetIntPar("GUI::CanDo", cando);
01415 }
01416
01417 Bool_t TGo4BrowserProxy::IsItemMonitored(TGo4Slot* slot)
01418 {
01419 return slot==0 ? kTRUE : slot->GetPar("GUI::NotMonitored")==0;
01420 }
01421
01422 void TGo4BrowserProxy::SetItemMonitored(TGo4Slot* slot, Bool_t on)
01423 {
01424 if (slot==0) return;
01425
01426 if (ItemKind(slot)==TGo4Access::kndFolder) {
01427 TGo4Iter iter(slot, kTRUE);
01428 while (iter.next()) {
01429 TGo4Slot* subslot = iter.getslot();
01430 if (ItemKind(subslot)==TGo4Access::kndObject)
01431 SetItemMonitored(subslot, on);
01432 }
01433 } else {
01434 if (on) {
01435 slot->RemovePar("GUI::NotMonitored");
01436 CheckPictureMonitor(slot);
01437 } else {
01438 slot->SetPar("GUI::NotMonitored","1");
01439 }
01440 }
01441 }
01442
01443 bool TGo4BrowserProxy::CanExportItem(int cando)
01444 {
01445 return (cando % 10000000) / 1000000 > 0;
01446 }
01447
01448 bool TGo4BrowserProxy::CanInfoItem(int cando)
01449 {
01450 return (cando % 1000000) / 100000 > 0;
01451 }
01452
01453
01454 bool TGo4BrowserProxy::CanCloseItem(int cando)
01455 {
01456 return (cando % 100000) / 10000 > 0;
01457 }
01458
01459 bool TGo4BrowserProxy::CanClearItem(int cando)
01460 {
01461 return (cando % 10000) / 1000 > 0;
01462 }
01463
01464 bool TGo4BrowserProxy::CanDrawItem(int cando)
01465 {
01466 return (cando % 1000) / 100 > 0;
01467 }
01468
01469 bool TGo4BrowserProxy::CanDragItem(int cando)
01470 {
01471 return (cando % 100) / 10 > 0;
01472 }
01473
01474 bool TGo4BrowserProxy::CanEditItem(int cando)
01475 {
01476 return (cando % 10 > 0);
01477 }
01478
01479 void TGo4BrowserProxy::CreateMemoryFolder(const char* foldername)
01480 {
01481 if ((foldername!=0) && (*foldername!=0))
01482 fxMemoryPath = foldername;
01483
01484 TString fullpathname;
01485 DataSlotName(fxMemoryPath, fullpathname);
01486
01487 fxOM->MakeFolder(fullpathname);
01488 }
01489
01490 void TGo4BrowserProxy::CreateMemorySubfolder(const char* itemname, const char* newfoldername)
01491 {
01492 TGo4Slot* itemslot = BrowserSlot(itemname);
01493
01494 if ((itemslot==0) || (newfoldername==0) || (strlen(newfoldername)==0)) return;
01495
01496 TGo4Slot* memslot = BrowserMemorySlot();
01497 if (!itemslot->IsParent(memslot) && (memslot!=itemslot)) return;
01498
01499 TGo4Slot* slot = DataSlot(itemname);
01500 if (slot==0) return;
01501
01502 TGo4Slot* newslot = slot->GetSlot(newfoldername, kTRUE);
01503
01504 if (newslot!=0)
01505 InformBrowserUpdate();
01506 }
01507
01508 void TGo4BrowserProxy::RenameMemoryItem(const char* itemname, const char* newname)
01509 {
01510 TGo4Slot* itemslot = BrowserSlot(itemname);
01511 if ((itemslot==0) || (newname==0) || (strlen(newname)==0)) return;
01512
01513 if ((strchr(newname,'/')!=0) || (strchr(newname,'\\')!=0)) return;
01514
01515 TGo4Slot* memslot = BrowserMemorySlot();
01516 if (!itemslot->IsParent(memslot)) return;
01517
01518 TGo4Slot* slot = DataSlot(itemname);
01519 if (slot==0) return;
01520
01521
01522 if (slot->GetParent()->FindChild(newname)!=0) return;
01523
01524 slot->SetName(newname);
01525 TNamed* n = dynamic_cast<TNamed*> (slot->GetAssignedObject());
01526 if (n!=0) n->SetName(newname);
01527
01528 slot->ForwardEvent(slot, TGo4Slot::evObjAssigned);
01529 }
01530
01531
01532
01533 void TGo4BrowserProxy::ClearMemoryItem(const char* itemname)
01534 {
01535 TGo4Slot* itemslot = BrowserSlot(itemname);
01536 if (itemslot==0) return;
01537
01538 TGo4Slot* memslot = BrowserMemorySlot();
01539 if (!itemslot->IsParent(memslot)) return;
01540
01541 TGo4Slot* slot = DataSlot(itemname);
01542 if (slot==0) return;
01543
01544 TObject* ob = slot->GetAssignedObject();
01545 if (ob==0) return;
01546
01547 if(ob->InheritsFrom(TH1::Class())) {
01548 TH1* his = dynamic_cast<TH1*>(ob);
01549 if (his) his->Reset();
01550 } else
01551 if(ob->InheritsFrom(TGo4DynamicEntry::Class())) {
01552 TGo4DynamicEntry* entry = dynamic_cast<TGo4DynamicEntry*>(ob);
01553 if (entry) entry->Reset();
01554 } else
01555 if(ob->InheritsFrom(TGo4Picture::Class())) {
01556 TGo4Picture* pic = dynamic_cast<TGo4Picture*>(ob);
01557 if (pic) pic->Reset();
01558 } else
01559 if(ob->InheritsFrom(TGraph::Class())) {
01560 TGraph* gr= dynamic_cast<TGraph*>(ob);
01561 if (gr) {
01562 Int_t pn = gr->GetN();
01563 gr->Set(0);
01564 gr->Set(pn);
01565 }
01566 } else
01567 if(ob->InheritsFrom(TMultiGraph::Class())) {
01568 TMultiGraph* mg = dynamic_cast<TMultiGraph*>(ob);
01569 if (mg) {
01570 TIter liter(mg->GetListOfGraphs());
01571 TGraph* gr = 0;
01572 while(( gr = (TGraph*) liter())!=0) {
01573 Int_t pn = gr->GetN();
01574 gr->Set(0);
01575 gr->Set(pn);
01576 }
01577 }
01578 } else {
01579
01580
01581 ob->Clear();
01582 }
01583
01584 itemslot->ForwardEvent(itemslot, TGo4Slot::evObjAssigned);
01585 }
01586
01587 TString TGo4BrowserProxy::SaveToMemory(const char* pathname, TObject* obj, Bool_t ownership, Bool_t overwrite)
01588 {
01589 if (obj==0) return TString("");
01590
01591 TString path = fxMemoryPath;
01592 if ((pathname!=0) && (*pathname!=0)) {
01593 path += "/";
01594 path += pathname;
01595 }
01596
01597
01598 if (overwrite) {
01599 TString itemname = path;
01600 itemname+= "/";
01601 itemname+=obj->GetName();
01602 TGo4Slot* slot = DataSlot(itemname);
01603 if (slot!=0) {
01604 slot->AssignObject(obj, ownership);
01605 return itemname;
01606 }
01607 }
01608
01609 TString fullpathname;
01610 DataSlotName(path.Data(), fullpathname);
01611
01612 TGo4Slot* slot = fxOM->Add(fullpathname.Data(), obj, ownership, kTRUE);
01613
01614 return slot==0 ? TString("") : slot->GetFullName(fxOM->GetSlot(fxDataPath));
01615 }
01616
01617 void TGo4BrowserProxy::CheckPictureMonitor(TGo4Slot* slot)
01618 {
01619 if (slot==0) return;
01620
01621 TObject* obj = slot->GetAssignedObject();
01622 if (obj==0) return;
01623
01624 TGo4Picture* pic = dynamic_cast<TGo4Picture*> (obj);
01625 if (pic==0) return;
01626
01627 if (!IsItemMonitored(slot)) return;
01628
01629 TString picitemname;
01630 if (!BrowserItemName(slot, picitemname)) return;
01631
01632 CheckPictureMonitor(pic, picitemname.Data());
01633 }
01634
01635 void TGo4BrowserProxy::CheckPictureMonitor(TGo4Picture* pic, const char* picitemname)
01636 {
01637 if (pic==0) return;
01638 if (pic->IsDivided())
01639 for(Int_t posy=0; posy<pic->GetDivY(); posy++)
01640 for(Int_t posx=0; posx<pic->GetDivX(); posx++)
01641 CheckPictureMonitor(pic->FindPic(posy,posx), picitemname);
01642
01643 for (Int_t n=0; n<pic->GetNumObjNames(); n++) {
01644
01645 TString drawname;
01646
01647 if (DefineRelatedObject(picitemname, pic->GetObjName(n), drawname))
01648 SetItemMonitored(BrowserSlot(drawname), kTRUE);
01649 }
01650 }
01651
01652 void TGo4BrowserProxy::Scan_gROOT()
01653 {
01654 TIter iter(gROOT->GetList());
01655 TObject* obj = 0;
01656 while ((obj=iter())!=0) {
01657 SaveToMemory("gROOT", obj, kTRUE);
01658 }
01659
01660 gROOT->GetList()->Clear();
01661 }
01662
01663 void TGo4BrowserProxy::SetCanDelete(TGo4Slot* slot, Bool_t on)
01664 {
01665 if (slot!=0){
01666 if(on) slot->SetPar("GUI::CanDelete","1");
01667 else slot->RemovePar("GUI::CanDelete");
01668 }
01669 }
01670
01671 Bool_t TGo4BrowserProxy::IsCanDelete(TGo4Slot* slot)
01672 {
01673 return slot==0 ? kFALSE : slot->GetPar("GUI::CanDelete")!=0;
01674 }
01675
01676 void TGo4BrowserProxy::ToggleMonitoring(Int_t rate)
01677 {
01678 fiMonitoringPeriod = rate;
01679
01680 fbBlockMonitoring = kFALSE;
01681
01682 if (fiMonitoringPeriod>0) {
01683 if (fxMonitorTimer==0)
01684 fxMonitorTimer = new TTimer(this, 10, kTRUE);
01685 fxMonitorTimer->Start(10, kTRUE);
01686 } else {
01687 if (fxMonitorTimer!=0) fxMonitorTimer->Reset();
01688 delete fxMonitorTimer;
01689 fxMonitorTimer = 0;
01690 }
01691
01692 InformBrowserUpdate();
01693 }
01694
01695 Int_t TGo4BrowserProxy::UpdateVisibleAnalysisObjects(bool checkmonitor)
01696 {
01697 TGo4Slot* viewslot = fxOM->GetSlot(fxViewPath.Data());
01698 if (viewslot==0) return 0;
01699
01700 TGo4Slot* brslot = BrowserSlot(0);
01701
01702 TObjArray UniqueItems;
01703
01704
01705 TGo4Iter iter(viewslot, kTRUE);
01706 while (iter.next()) {
01707 TGo4Slot* subslot = iter.getslot();
01708
01709 TGo4LinkProxy* link = dynamic_cast<TGo4LinkProxy*> (subslot->GetProxy());
01710 if (link!=0) {
01711 TGo4Slot* srcslot = link->GetLink();
01712 if ((srcslot!=0) && srcslot->IsParent(brslot) &&
01713 (UniqueItems.FindObject(srcslot)==0))
01714 UniqueItems.Add(srcslot);
01715 }
01716 }
01717
01718 Int_t nrequests = 0;
01719 for (int n=0;n<=UniqueItems.GetLast();n++) {
01720 TGo4Slot* srcslot = (TGo4Slot*)UniqueItems.At(n);
01721 if (!checkmonitor || IsItemMonitored(srcslot)) {
01722 nrequests++;
01723 srcslot->Update(kFALSE);
01724 }
01725 }
01726 return nrequests;
01727 }
01728
01729 Int_t TGo4BrowserProxy::UpdateAllMonitoredObjects()
01730 {
01731 Int_t nrequests = 0;
01732
01733 TGo4Iter iter(BrowserSlot(0),kTRUE);
01734
01735 while (iter.next()) {
01736 TGo4Slot* subslot = iter.getslot();
01737 if (IsItemMonitored(subslot)) {
01738 nrequests++;
01739 subslot->Update(kTRUE);
01740 }
01741 }
01742
01743 return nrequests;
01744 }
01745
01746 Bool_t TGo4BrowserProxy::HandleTimer(TTimer* timer)
01747 {
01748 if (timer==fxSyncTimer) {
01749 SyncBrowserSlots();
01750 return kTRUE;
01751
01752 } else
01753
01754 if (timer==fxMonitorTimer) {
01755
01756 if (fiMonitoringPeriod<=0) return kTRUE;
01757
01758 TGo4AnalysisProxy* an = FindAnalysis();
01759
01760 Bool_t anready = kTRUE;
01761 if (an!=0) anready = an->IsConnected();
01762
01763
01764 if (anready && (TGo4AnalysisProxy::NumberOfWaitingProxyes()<3) && !fbBlockMonitoring) {
01765 if (fbWithRootBrowser) {
01766 UpdateAllMonitoredObjects();
01767 UpdateAllCanvases();
01768 }
01769 else
01770 UpdateVisibleAnalysisObjects(true);
01771 }
01772
01773 Int_t period = fiMonitoringPeriod;
01774
01775
01776 if (fbBlockMonitoring) period = 1000;
01777
01778 fxMonitorTimer->Start(period, kTRUE);
01779
01780 return kTRUE;
01781 }
01782
01783 return kFALSE;
01784 }
01785
01786 void TGo4BrowserProxy::SetProtectionBits(TGo4Slot* slot, Int_t delprot, Int_t clearprot)
01787 {
01788 if (slot==0) return;
01789 if (delprot>=0)
01790 slot->SetIntPar("GUI::DeleteProtect", delprot);
01791 else
01792 slot->RemovePar("GUI::DeleteProtect");
01793 if (clearprot>=0)
01794 slot->SetIntPar("GUI::ResetProtect", clearprot);
01795 else
01796 slot->RemovePar("GUI::ResetProtect");
01797 }
01798
01799 void TGo4BrowserProxy::GetProtectionBits(TGo4Slot* slot, Int_t& delprot, Int_t& clearprot)
01800 {
01801 delprot = -1; clearprot = -1;
01802 if (slot==0) return;
01803 if (!slot->GetIntPar("GUI::DeleteProtect", delprot)) delprot = -1;
01804 if (!slot->GetIntPar("GUI::ResetProtect", clearprot)) clearprot = -1;
01805 }
01806
01807 void TGo4BrowserProxy::SyncBrowserSlots()
01808 {
01809 TGo4LockGuard lock(0,true);
01810
01811 TGo4Slot* targetslot = BrowserTopSlot();
01812
01813 TGo4Slot* source = fxOM->GetSlot(fxDataPath.Data());
01814 if (source==0) return;
01815
01816 TGo4Slot* curfold = targetslot;
01817 if (curfold==0) return;
01818
01819 TGo4Slot* curslot = curfold->GetChild(0);
01820
01821 TGo4Iter iter(source);
01822
01823 const char* EventsFolder = "EventObjects/Events/";
01824
01825 while (curfold!=0) {
01826
01827
01828 Bool_t res = iter.next();
01829
01830
01831 Int_t levelchange = iter.levelchange();
01832
01833
01834 while (levelchange++<0) {
01835 while (curslot!=0) {
01836 TGo4Slot* next = curslot->GetNext();
01837 delete curslot;
01838 curslot = next;
01839 }
01840
01841 curslot = curfold->GetNext();
01842 curfold = curfold->GetParent();
01843 if (curfold==0) break;
01844
01845 }
01846
01847 if (!res) break;
01848
01849
01850 TGo4Slot* find = curslot;
01851 while ((find!=0) && (strcmp(iter.getname(), find->GetName())!=0))
01852 find = find->GetNext();
01853
01854 if (find==0)
01855 find = new TGo4Slot(curfold, iter.getname(), iter.getinfo());
01856
01857 if (find!=curslot) {
01858 curfold->ShiftSlotBefore(find, curslot);
01859 curslot = find;
01860 }
01861
01862 Int_t kind = iter.getkindofitem();
01863 const char* classname = iter.getclassname();
01864 const char* fullname = iter.getfullname();
01865 const char* ppp = strstr(fullname, EventsFolder);
01866 if (ppp!=0) {
01867 ppp += strlen(EventsFolder);
01868 if ((strlen(ppp)!=0) && (strchr(ppp,'/')==0)) {
01869 kind = TGo4Access::kndEventElement;
01870 classname = 0;
01871 }
01872 }
01873
01874
01875
01876 SetItemKind(curslot, kind, classname, iter.getinfo(), iter.getsizeinfo());
01877 curslot->SetIntPar("GUI::Remote", iter.getflag("IsRemote")==1);
01878 SetProtectionBits(curslot, iter.getflag("IsDeleteProtect"), iter.getflag("IsResetProtect"));
01879
01880 if (iter.getslot()!=0)
01881 SetCanDelete(curslot, IsCanDelete(iter.getslot()));
01882
01883 TObject* assobj = 0;
01884 if ((kind==TGo4Access::kndObject) && (iter.getslot()!=0)) {
01885 TObject* obj = iter.getslot()->GetAssignedObject();
01886 if ((obj!=0) && (curslot->GetAssignedObject()==0))
01887 assobj = obj;
01888 }
01889
01890 if (curslot->GetProxy()==0)
01891 curslot->SetProxy(new TGo4BrowserObjProxy(curslot, assobj, kFALSE));
01892 else
01893
01894 if (assobj!=0)
01895 curslot->AssignObject(assobj, kFALSE);
01896
01897 if (iter.isfolder()) {
01898 curfold = curslot;
01899
01900 curslot = curfold->GetChild(0);
01901 } else {
01902 curslot->DeleteChilds();
01903 curslot = curslot->GetNext();
01904 }
01905 }
01906
01907 if ((curslot!=0) && curslot->IsParent(targetslot))
01908 while (curslot!=0) {
01909 TGo4Slot* next = curslot->GetNext();
01910 delete curslot;
01911 curslot = next;
01912 }
01913
01914 CalculateFolderSizes(targetslot);
01915
01916
01917 targetslot->ForwardEvent(targetslot, TGo4Slot::evObjUpdated);
01918
01919 if (fxSyncTimer!=0) fxSyncTimer->Reset();
01920
01921 fbBlockSync = kFALSE;
01922 }
01923
01924 Int_t TGo4BrowserProxy::CalculateFolderSizes(TGo4Slot* topslot)
01925 {
01926 if (topslot==0) return 0;
01927 Int_t sizeinfo = ItemSizeInfo(topslot);
01928 bool verytop = fxBrowserSlot==topslot;
01929 if (!verytop && ItemKind(topslot)!=TGo4Access::kndFolder) return sizeinfo;
01930
01931 Int_t sum = 0;
01932 for (Int_t n=0;n<topslot->NumChilds();n++)
01933 sum += CalculateFolderSizes(topslot->GetChild(n));
01934 if (!verytop) SetCalcSize(topslot, sum);
01935
01936 return sum;
01937 }
01938
01939 Int_t TGo4BrowserProxy::DefineItemProperties(Int_t kind, TClass* cl, TString& pixmap)
01940 {
01941 Int_t cando = 0;
01942
01943
01944
01945
01946 if (kind==TGo4Access::kndObject) {
01947 if (cl!=0) {
01948 if (cl->InheritsFrom(TProfile::Class())) { cando = 1110; pixmap = "profile_t.png"; } else
01949 if (cl->InheritsFrom(TGo4Picture::Class())) { cando = 110; pixmap = "picture.png"; } else
01950 if (cl->InheritsFrom(TGo4Parameter::Class())) { cando = 1011; pixmap = "parameter.png"; } else
01951 if (cl->InheritsFrom(TMultiGraph::Class())) { cando = 1110; pixmap = "superimpose.png"; } else
01952 if (cl->InheritsFrom(THStack::Class())) { cando = 1110; pixmap = "superimpose.png"; } else
01953 if (cl->InheritsFrom(TGraph::Class())) { cando = 1001110; pixmap = "tgraph.png"; } else
01954 if (cl->InheritsFrom(TGo4Fitter::Class())) { cando = 11; pixmap = "fitter.png"; } else
01955 if (cl->InheritsFrom(TCanvas::Class())) { cando = 110; pixmap = "canvas.png"; } else
01956 if (cl->InheritsFrom(TFile::Class())) { pixmap = "rootdb_t.png"; } else
01957 if (cl->InheritsFrom(TTree::Class())) { pixmap = "tree_t.png"; } else
01958 if (cl->InheritsFrom(TFolder::Class())) { pixmap = "folder_t.png"; } else
01959 if (cl->InheritsFrom(TDirectory::Class())) { pixmap = "folder_t.png"; } else
01960 if (cl->InheritsFrom(TH3::Class())) { cando = 1101110; pixmap = "h3_t.png"; } else
01961 if (cl->InheritsFrom(TH2::Class())) { cando = 1101110; pixmap = "h2_t.png"; } else
01962 if (cl->InheritsFrom(TH1::Class())) { cando = 1101110; pixmap = "h1_t.png"; } else
01963 if (cl->InheritsFrom(TGo4WinCond::Class())) { cando = 101011; pixmap = "windcond.png"; } else
01964 if (cl->InheritsFrom(TGo4PolyCond::Class())) { cando = 101011; pixmap = "polycond.png"; } else
01965 if (cl->InheritsFrom(TGo4CondArray::Class())) { cando = 101011; pixmap = "windcondarray.png"; } else
01966 if (cl->InheritsFrom(TGo4TreeHistogramEntry::Class())) { cando = 1011; pixmap = "dynentryx.png"; } else
01967 if (cl->InheritsFrom(TGo4HistogramEntry::Class())) { cando = 1011; pixmap = "dynentryx.png"; } else
01968 if (cl->InheritsFrom(TLatex::Class())) { cando = 110; pixmap = "canvas.png"; }
01969
01970 }
01971 } else
01972 if (kind==TGo4Access::kndFolder) {
01973 pixmap = "folder_t.png";
01974 if ((cl!=0) && cl->InheritsFrom(TTree::Class())) { cando = 10; pixmap = "tree_t.png"; } else
01975 if ((cl!=0) && cl->InheritsFrom(TCanvas::Class())) { cando = 110; pixmap = "canvas.png"; } else
01976 if ((cl!=0) && cl->InheritsFrom(THStack::Class())) { cando = 110; pixmap = "superimpose.png"; } else
01977 if ((cl!=0) && cl->InheritsFrom(TFile::Class())) { cando = 10000; pixmap = "rootdb_t.png"; } else
01978 if ((cl!=0) && cl->InheritsFrom(TGo4HServProxy::Class())) { cando = 10000; pixmap = "histserv.png"; } else
01979 if ((cl!=0) && cl->InheritsFrom(TGo4DabcProxy::Class())) { cando = 10000; pixmap = "dabc.png"; } else
01980 if ((cl!=0) && cl->InheritsFrom(TGo4AnalysisProxy::Class())) { pixmap = "analysiswin.png"; }
01981 } else
01982 if (kind==TGo4Access::kndTreeBranch)
01983 pixmap = "branch_t.png";
01984 else
01985 if (kind==TGo4Access::kndTreeLeaf) {
01986 cando = 11; pixmap = "leaf_t.png";
01987 } else
01988 if (kind==TGo4Access::kndGo4Param) {
01989 cando = 1011; pixmap = "parameter.png";
01990 } else
01991 if (kind==TGo4Access::kndDataMember) {
01992 cando = 10; pixmap = "eventitem.png";
01993 } else
01994 if (kind==TGo4Access::kndEventElement) {
01995 cando = 100010; pixmap = "eventobj.png";
01996 }
01997
01998 return cando;
01999 }
02000
02001 Bool_t TGo4BrowserProxy::CompareAxisValues(Double_t v1, Double_t v2, Double_t scale)
02002 {
02003 if (v1==v2) return kTRUE;
02004
02005 return (fabs(v1-v2) <= scale);
02006 }
02007
02008 Int_t TGo4BrowserProxy::CompareAxis(TAxis* ax1, TAxis* ax2)
02009 {
02010
02011
02012
02013
02014
02015 if ((ax1==0) || (ax2==0)) return 0;
02016
02017 Int_t num1 = ax1->GetNbins();
02018 Int_t num2 = ax2->GetNbins();
02019
02020 Double_t scale = fabs(ax1->GetXmax() - ax1->GetXmin()) / (num1+1.) * 1e-3;
02021
02022 if ((num1!=num2)) {
02023
02024 if ((num1>num2/2) || (num1<2)) return 0;
02025
02026 Int_t rebin = num2/num1;
02027 if (rebin==0) return 0;
02028
02029
02030 if ((ax1->GetXbins()->GetSize()!=0) || (ax1->GetXbins()->GetSize()!=0)) return 0;
02031
02032
02033 if (!CompareAxisValues(ax1->GetXmin(), ax2->GetXmin(), scale)) return 0;
02034
02035 Double_t xmax;
02036
02037 if (num1*rebin!=num2) xmax = ax2->GetBinUpEdge(num1*rebin);
02038 else xmax = ax2->GetXmax();
02039
02040
02041 if (!CompareAxisValues(ax1->GetXmax(), xmax, scale)) return 0;
02042
02043 return rebin;
02044 }
02045
02046 if ((ax1->GetXbins()->GetSize()==0) && (ax1->GetXbins()->GetSize()==0)) {
02047 if (!CompareAxisValues(ax1->GetXmin(), ax2->GetXmin(), scale)) return 0;
02048 if (!CompareAxisValues(ax1->GetXmax(), ax2->GetXmax(), scale)) return 0;
02049 } else
02050 for (Int_t n=1;n<=num1;n++)
02051 if (!CompareAxisValues(ax1->GetBinCenter(n),
02052 ax2->GetBinCenter(n), scale)) return 0;
02053
02054 return 1;
02055 }
02056
02057
02058 Bool_t TGo4BrowserProxy::UpdateObjectContent(TObject* obj, TObject* newobj, Int_t* hasrebinx, Int_t* hasrebiny)
02059 {
02060
02061
02062 Bool_t tdisp=kFALSE;
02063 TString tform;
02064 if (obj->InheritsFrom(TH1::Class())) {
02065 TH1* histo = dynamic_cast<TH1*> (obj);
02066 TH1* histo2 = dynamic_cast<TH1*> (newobj);
02067 if ((histo==0) || (histo2==0)) return kFALSE;
02068
02069 if (dynamic_cast<TProfile*>(obj)!=0) return kFALSE;
02070
02071 if (histo->GetDimension()!=histo2->GetDimension()) return kFALSE;
02072
02073 histo->SetTitle(histo2->GetTitle());
02074
02075 Int_t rebinx = 1, rebiny = 1;
02076
02077 rebinx = CompareAxis(histo->GetXaxis(), histo2->GetXaxis());
02078 if (histo->GetDimension()>1)
02079 rebiny = CompareAxis(histo->GetYaxis(), histo2->GetYaxis());
02080 if (histo->GetDimension()>2)
02081 if (CompareAxis(histo->GetZaxis(), histo2->GetZaxis())!=1) return kFALSE;
02082
02083 if ((rebinx==0) || (rebiny==0)) return kFALSE;
02084
02085
02086
02087 if ((rebinx>1) || (rebiny>1)) {
02088 if ((hasrebinx==0) || (hasrebiny==0)) return kFALSE;
02089
02090 TH1* clon = (TH1*) histo2->Clone("____dummyhisto____");
02091 if (clon==0) return kFALSE;
02092 clon->SetDirectory(0);
02093 Bool_t rebinres = kFALSE;
02094
02095 if (histo->GetDimension()==1) {
02096 clon->Rebin(rebinx);
02097 rebinres = UpdateObjectContent(histo, clon);
02098 }
02099 #if ROOT_VERSION_CODE > ROOT_VERSION(4,3,2)
02100 else
02101 if (histo->GetDimension()==2) {
02102 TH2* h2 = dynamic_cast<TH2*>(clon);
02103 if (h2!=0) h2->Rebin2D(rebinx, rebiny);
02104 rebinres = UpdateObjectContent(histo, h2);
02105 }
02106 #else
02107
02108
02109 #endif
02110
02111 delete clon;
02112
02113 if (rebinres) {
02114 *hasrebinx = rebinx;
02115 *hasrebiny = rebiny;
02116 }
02117
02118 return rebinres;
02119 }
02120
02121
02122 Int_t sz = histo->GetNbinsX()+2;
02123 if (histo->GetDimension()>1)
02124 sz = sz*(histo->GetNbinsY()+2);
02125 if (histo->GetDimension()>2)
02126 sz = sz*(histo->GetNbinsZ()+2);
02127
02128 Bool_t canrebin = histo->TestBit(TH1::kCanRebin);
02129 histo->SetBit(TH1::kCanRebin, kFALSE);
02130
02131 Double_t sum = 0;
02132 for (int n=0;n<sz;n++) {
02133 Stat_t value = histo2->GetBinContent(n);
02134 sum += value;
02135 histo->SetBinContent(n, value);
02136 }
02137 if (canrebin) histo->SetBit(TH1::kCanRebin, kTRUE);
02138
02139 histo->SetEntries(sum);
02140
02141 #if ROOT_VERSION_CODE > ROOT_VERSION(4,3,2)
02142 TArrayD *sumw_tgt = 0, *sumw_src = 0;
02143
02144 if (histo2->GetSumw2N()>0)
02145 sumw_src = histo2->GetSumw2();
02146
02147
02148 if (sumw_src==0) histo->GetSumw2()->Set(0);
02149 else {
02150 histo->Sumw2();
02151 sumw_tgt = histo->GetSumw2();
02152 }
02153
02154 if (sumw_src && sumw_tgt)
02155 sumw_tgt->Set(sz, sumw_src->GetArray());
02156 #endif
02157
02158 return kTRUE;
02159 } else
02160 if (obj->InheritsFrom(TGo4Condition::Class())) {
02161 TGo4Condition* cond = dynamic_cast<TGo4Condition*> (obj);
02162 TGo4Condition* newcond = dynamic_cast<TGo4Condition*> (newobj);
02163 if ((cond==0) || (newcond==0)) return kFALSE;
02164
02165 cond->UpdateFrom(newcond, kTRUE);
02166 cond->SetChanged(kFALSE);
02167
02168 return kTRUE;
02169
02170
02171
02172
02173
02174 } else
02175 if (obj->InheritsFrom(TGraphAsymmErrors::Class())) {
02176 TGraphAsymmErrors* gr = dynamic_cast<TGraphAsymmErrors*> (obj);
02177 TGraph* newgr = dynamic_cast<TGraph*> (newobj);
02178 if ((gr==0) || (newgr==0)) return kFALSE;
02179 SaveAxisTimeProperties(gr,tdisp,tform);
02180 gr->SetTitle(newgr->GetTitle());
02181
02182 Int_t npoints = newgr->GetN();
02183 gr->Set(npoints);
02184 Double_t xp, yp, exh, exl, eyh, eyl;
02185 for (Int_t n=0;n<npoints;n++) {
02186 newgr->GetPoint(n,xp,yp);
02187 gr->SetPoint(n,xp,yp);
02188 #if ROOT_VERSION_CODE > ROOT_VERSION(4,3,2)
02189 exh = newgr->GetErrorXhigh(n);
02190 exl = newgr->GetErrorXlow(n);
02191 eyh = newgr->GetErrorYhigh(n);
02192 eyl = newgr->GetErrorYlow(n);
02193 gr->SetPointError(n, exl, exh, eyl, eyh);
02194 #endif
02195 }
02196 RestoreAxisTimeProperties(gr,tdisp,tform);
02197 return kTRUE;
02198 } else
02199 if (obj->InheritsFrom(TGraphErrors::Class())) {
02200 TGraphErrors* gr = dynamic_cast<TGraphErrors*> (obj);
02201 TGraph* newgr = dynamic_cast<TGraph*> (newobj);
02202 if ((gr==0) || (newgr==0)) return kFALSE;
02203 SaveAxisTimeProperties(gr,tdisp,tform);
02204 gr->SetTitle(newgr->GetTitle());
02205
02206 Int_t npoints = newgr->GetN();
02207 gr->Set(npoints);
02208 Double_t xp, yp, ex, ey;
02209 for (Int_t n=0;n<npoints;n++) {
02210 newgr->GetPoint(n,xp,yp);
02211 gr->SetPoint(n,xp,yp);
02212 ex = newgr->GetErrorX(n);
02213 ey = newgr->GetErrorY(n);
02214 gr->SetPointError(n, ex, ey);
02215 }
02216 RestoreAxisTimeProperties(gr,tdisp,tform);
02217
02218
02219 return kTRUE;
02220 } else
02221 if (obj->InheritsFrom(TGraph::Class())) {
02222 TGraph* gr = dynamic_cast<TGraph*> (obj);
02223 TGraph* newgr = dynamic_cast<TGraph*> (newobj);
02224 if ((gr==0) || (newgr==0)) return kFALSE;
02225
02226 SaveAxisTimeProperties(gr,tdisp,tform);
02227
02228
02229 gr->SetTitle(newgr->GetTitle());
02230
02231 Int_t npoints = newgr->GetN();
02232 gr->Set(npoints);
02233 Double_t xp, yp;
02234 for (Int_t n=0;n<npoints;n++) {
02235 newgr->GetPoint(n,xp,yp);
02236 gr->SetPoint(n,xp,yp);
02237 }
02238 RestoreAxisTimeProperties(gr,tdisp,tform);
02239
02240 return kTRUE;
02241 } else
02242 if (obj->InheritsFrom(TLatex::Class())) {
02243 TLatex* l0 = dynamic_cast<TLatex*> (obj);
02244 TLatex* l1 = dynamic_cast<TLatex*> (newobj);
02245 if ((l1==0) || (l0==0)) return kFALSE;
02246
02247 l0->SetTitle(l1->GetTitle());
02248
02249 return kTRUE;
02250 }
02251
02252 return kFALSE;
02253 }
02254
02255
02256 void TGo4BrowserProxy::SaveAxisTimeProperties(TGraph* gr, Bool_t& timedisplay, TString& format)
02257 {
02258 if(gr==0) return;
02259 TH1* h1=gr->GetHistogram();
02260 TAxis* xax=h1->GetXaxis();
02261 timedisplay=xax->GetTimeDisplay();
02262 format=xax->GetTimeFormat();
02263
02264
02265
02266 }
02267 void TGo4BrowserProxy::RestoreAxisTimeProperties(TGraph* gr, Bool_t& timedisplay, TString& format)
02268 {
02269 if(gr==0) return;
02270 TH1*h1=gr->GetHistogram();
02271 TAxis* xax=h1->GetXaxis();
02272
02273 xax->SetTimeDisplay(timedisplay);
02274 xax->SetTimeFormat(format.Data());
02275
02276 }
02277
02278
02279
02280
02281 void TGo4BrowserProxy::AddWaitingList(TGo4Slot* itemslot, const char* destination)
02282 {
02283 if (itemslot==0) return;
02284 if (fxWaitingList==0) fxWaitingList = new TList;
02285
02286 TString itemname;
02287 if (!BrowserItemName(itemslot, itemname)) return;
02288
02289 TNamed* n = (TNamed*) fxWaitingList->FindObject(itemname.Data());
02290 if (n!=0)
02291 n->SetTitle(destination);
02292 else
02293 fxWaitingList->Add(new TNamed(itemname.Data(), destination));
02294 }
02295
02296 void TGo4BrowserProxy::CheckWaitingList(TGo4Slot* source)
02297 {
02298 if (fxWaitingList==0) return;
02299
02300 TString itemname;
02301 if (!BrowserItemName(source, itemname)) return;
02302
02303 TNamed* n = (TNamed*) fxWaitingList->FindObject(itemname.Data());
02304 if (n!=0) {
02305 const char* dest = n->GetTitle();
02306 if ((dest!=0) && (strlen(dest)==0)) dest = 0;
02307 ProduceExplicitCopy(source, dest, kFALSE);
02308 fxWaitingList->Remove(n);
02309 delete n;
02310 }
02311 }
02312
02313
02314
02315 void TGo4BrowserProxy::UpdateAllCanvases()
02316 {
02317 TIter next(gROOT->GetListOfCanvases());
02318 TPad* pad = 0;
02319 while ((pad = (TPad*) next()) != 0) {
02320 pad->Modified();
02321
02322 TVirtualPad* subpad = 0;
02323 Int_t number = 0;
02324 while ((subpad = pad->GetPad(number++))!=0)
02325 subpad->Modified();
02326
02327 pad->Update();
02328 }
02329 }