Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4BrowserItem.cxx

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

Generated on Fri Nov 28 12:59:27 2008 for Go4-v3.04-1 by  doxygen 1.4.2