Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 #include "TGo4BrowserItem.h"
00015 
00016 #include "TCanvas.h"
00017 #include "TH1.h"
00018 
00019 #include "TGo4BrowserProxy.h"
00020 #include "TGo4RootBrowserProxy.h"
00021 #include "TGo4Iter.h"
00022 #include "TGo4Slot.h"
00023 #include "TGo4Proxy.h"
00024 #include "TGo4AnalysisProxy.h"
00025 
00026 #include "TGo4Condition.h"
00027 #include "TGo4Picture.h"
00028 #include "TGo4Interface.h"
00029 
00030 TGo4BrowserItem::TGo4BrowserItem() :
00031    TFolder(),
00032    fParent(0),
00033    fIter(0),
00034    fItemClass(),
00035    fIsFolder(kFALSE),
00036    fBrowser(0)
00037 {
00038 }
00039 
00040 TGo4BrowserItem::TGo4BrowserItem(const char* name, const char* title) :
00041    TFolder(name, title),
00042    fParent(0),
00043    fIter(0),
00044    fItemClass(),
00045    fIsFolder(kTRUE),
00046    fBrowser(0)
00047 {
00048    SetOwner(kTRUE);
00049 }
00050 
00051 TGo4BrowserItem::TGo4BrowserItem(TGo4BrowserItem* parent, TGo4BrowserItem* previtem,
00052                                const char* name, const char* title) :
00053    TFolder(name, title),
00054    fParent(parent),
00055    fIter(0),
00056    fItemClass(),
00057    fIsFolder(kTRUE),
00058    fBrowser(0)
00059 {
00060    SetOwner(kTRUE);
00061    if (parent!=0) {
00062       TList* list = (TList*) parent->GetListOfFolders();
00063       if (previtem==0) list->AddFirst(this);
00064                   else list->AddAfter(previtem, this);
00065    }
00066 }
00067 
00068 TGo4BrowserItem::~TGo4BrowserItem()
00069 {
00070    if (fIter!=0) delete fIter;
00071 }
00072 
00073 void TGo4BrowserItem::SetBrowser(TGo4BrowserProxy* br, TGo4RootBrowserProxy* br2)
00074 {
00075    fBrowser = br;
00076    fRootBrowser = br2;
00077 }
00078 
00079 
00080 TGo4BrowserItem* TGo4BrowserItem::firstChild()
00081 {
00082     if (fIter!=0) delete fIter;
00083     fIter = GetListOfFolders()->MakeIterator();
00084     return (TGo4BrowserItem*) fIter->Next();
00085 }
00086 
00087 TGo4BrowserItem* TGo4BrowserItem::nextChild()
00088 {
00089     if (fIter==0) return 0;
00090     TGo4BrowserItem* res = dynamic_cast<TGo4BrowserItem*> (fIter->Next());
00091     if (res==0) { delete fIter; fIter = 0; }
00092     return res;
00093 }
00094 
00095 void TGo4BrowserItem::deleteChild(TGo4BrowserItem* item)
00096 {
00097    if (item==0) return;
00098    Remove(item);
00099    delete item;
00100 }
00101 
00102 void TGo4BrowserItem::deleteChilds()
00103 {
00104    if (fIter!=0) { delete fIter; fIter = 0; }
00105    GetListOfFolders()->Delete();
00106 }
00107 
00108 void TGo4BrowserItem::ProduceFullName(TString& fullname)
00109 {
00110    if (GetParent()!=0) {
00111      GetParent()->ProduceFullName(fullname);
00112      if (fullname.Length()>0) fullname+="/";
00113      fullname += GetName();
00114    } else
00115      fullname = "";
00116 }
00117 
00118 TString TGo4BrowserItem::GetFullName()
00119 {
00120    TString res;
00121    ProduceFullName(res);
00122    return res;
00123 
00124 }
00125 
00126 void TGo4BrowserItem::Browse(TBrowser* b)
00127 {
00128    if (IsFolder()) TFolder::Browse(b);
00129 
00130    DrawItem();
00131 }
00132 
00133 void TGo4BrowserItem::DrawItem()
00134 {
00135    TString itemname;
00136 
00137    ProduceFullName(itemname);
00138 
00139    fRootBrowser->DrawItem(itemname.Data());
00140 }
00141 
00142 void TGo4BrowserItem::CopyToWorkspace()
00143 {
00144    TString itemname;
00145    ProduceFullName(itemname);
00146    if ((itemname.Length()==0) || (fBrowser==0)) return;
00147 
00148    fBrowser->ProduceExplicitCopy(itemname.Data(), 0, kTRUE);
00149 }
00150 
00151 void TGo4BrowserItem::DeleteItem()
00152 {
00153    if (GetParent()==0) {
00154       TGo4Interface::DeleteInstance();
00155       return;
00156    }
00157 
00158 
00159    TString itemname;
00160    ProduceFullName(itemname);
00161    if ((itemname.Length()==0) || (fBrowser==0)) return;
00162 
00163    TGo4Slot* itemslot = fBrowser->ItemSlot(itemname.Data());
00164    if (itemslot==0) return;
00165 
00166    TGo4Slot* memslot = fBrowser->BrowserMemorySlot();
00167 
00168    if (fBrowser->IsCanDelete(itemslot) || itemslot->IsParent(memslot))
00169      fBrowser->DeleteDataSource(itemslot);
00170 }
00171 
00172 void TGo4BrowserItem::SetMonitorOn()
00173 {
00174    SetMonitorFlag(kTRUE);
00175 }
00176 
00177 void TGo4BrowserItem::SetMonitorOff()
00178 {
00179    SetMonitorFlag(kFALSE);
00180 }
00181 
00182 void TGo4BrowserItem::SetMonitorFlag(Bool_t on)
00183 {
00184    TString itemname;
00185    ProduceFullName(itemname);
00186    if ((itemname.Length()==0) || (fBrowser==0)) return;
00187 
00188    TGo4Slot* itemslot = fBrowser->ItemSlot(itemname.Data());
00189    if (itemslot==0) return;
00190    int kind = fBrowser->ItemKind(itemslot);
00191 
00192    if (kind==TGo4Access::kndFolder) {
00193       TGo4Iter iter(itemslot, kTRUE);
00194       while (iter.next()) {
00195          TGo4Slot* subslot = iter.getslot();
00196          if (fBrowser->ItemKind(subslot)==TGo4Access::kndObject)
00197             fBrowser->SetItemMonitored(subslot, on);
00198       }
00199   } else
00200       fBrowser->SetItemMonitored(itemslot, on);
00201 }
00202 
00203 
00204 void TGo4BrowserItem::ToggleMonitoring(Int_t sec)
00205 {
00206    if (fBrowser!=0)
00207       fBrowser->ToggleMonitoring(sec*1000);
00208 }
00209 
00210 void TGo4BrowserItem::StartAnalysis()
00211 {
00212    TGo4AnalysisProxy* anal = fBrowser->FindAnalysis();
00213    if (anal!=0)
00214       anal->StartAnalysis();
00215 }
00216 
00217 void TGo4BrowserItem::StopAnalysis()
00218 {
00219    TGo4AnalysisProxy* anal = fBrowser->FindAnalysis();
00220    if (anal!=0)
00221       anal->StopAnalysis();
00222 }
00223 
00224 
00225 
00226 void TGo4BrowserItem::Delete(Option_t* option)
00227 {
00228     DeleteItem();
00229 }
00230 
00231 void TGo4BrowserItem::SetName(const char* name)
00232 {
00233    TFolder::SetName(name);
00234 }
00235 
00236 void TGo4BrowserItem::SetTitle(const char* title)
00237 {
00238    TFolder::SetTitle(title);
00239 }
00240 
00241 void TGo4BrowserItem::ls(Option_t* option) const
00242 {
00243    TFolder::ls(option);
00244 }
00245 
00246 #if ROOT_VERSION_CODE < ROOT_VERSION(5,13,6)
00247 void TGo4BrowserItem::SaveAs(const char* filename)
00248 {
00249    TFolder::SaveAs(filename);
00250 }
00251 #else
00252 void TGo4BrowserItem::SaveAs(const char* filename, Option_t *option)
00253 {
00254    TFolder::SaveAs(filename, option);
00255 }
00256 #endif
00257 
00258 void TGo4BrowserItem::DrawClass() const
00259 {
00260    TFolder::DrawClass();
00261 }
00262 
00263 TObject* TGo4BrowserItem::DrawClone(Option_t* option) const
00264 {
00265    return TFolder::DrawClone(option);
00266 }
00267 
00268 void TGo4BrowserItem::Dump() const
00269 {
00270    TFolder::Dump();
00271 }
00272 
00273 void TGo4BrowserItem::Inspect() const
00274 {
00275    TFolder::Inspect();
00276 }
00277 
00278 void TGo4BrowserItem::SetDrawOption(Option_t* option)
00279 {
00280    TFolder::SetDrawOption(option);
00281 }
00282