GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4BrowserItem.cxx
Go to the documentation of this file.
1 // $Id: TGo4BrowserItem.cxx 1545 2015-06-15 12:31:07Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4BrowserItem.h"
15 
16 #include "TCanvas.h"
17 #include "TH1.h"
18 
19 #include "TGo4BrowserProxy.h"
20 #include "TGo4RootBrowserProxy.h"
21 #include "TGo4Iter.h"
22 #include "TGo4Slot.h"
23 #include "TGo4Proxy.h"
24 #include "TGo4ServerProxy.h"
25 
26 #include "TGo4Condition.h"
27 #include "TGo4Picture.h"
28 #include "TGo4Interface.h"
29 
31  TFolder(),
32  fParent(0),
33  fIter(0),
34  fItemClass(),
35  fIsFolder(kFALSE),
36  fBrowser(0)
37 {
38 }
39 
40 TGo4BrowserItem::TGo4BrowserItem(const char* name, const char* title) :
41  TFolder(name, title),
42  fParent(0),
43  fIter(0),
44  fItemClass(),
45  fIsFolder(kTRUE),
46  fBrowser(0)
47 {
48  SetOwner(kTRUE);
49 }
50 
52  const char* name, const char* title) :
53  TFolder(name, title),
54  fParent(parent),
55  fIter(0),
56  fItemClass(),
57  fIsFolder(kTRUE),
58  fBrowser(0)
59 {
60  SetOwner(kTRUE);
61  if (parent!=0) {
62  TList* list = (TList*) parent->GetListOfFolders();
63  if (previtem==0) list->AddFirst(this);
64  else list->AddAfter(previtem, this);
65  }
66 }
67 
69 {
70  if (fIter!=0) delete fIter;
71 }
72 
74 {
75  fBrowser = br;
76  fRootBrowser = br2;
77 }
78 
79 
81 {
82  if (fIter!=0) delete fIter;
83  fIter = GetListOfFolders()->MakeIterator();
84  return (TGo4BrowserItem*) fIter->Next();
85 }
86 
88 {
89  if (fIter==0) return 0;
90  TGo4BrowserItem* res = dynamic_cast<TGo4BrowserItem*> (fIter->Next());
91  if (res==0) { delete fIter; fIter = 0; }
92  return res;
93 }
94 
96 {
97  if (item==0) return;
98  Remove(item);
99  delete item;
100 }
101 
103 {
104  if (fIter!=0) { delete fIter; fIter = 0; }
105  GetListOfFolders()->Delete();
106 }
107 
108 void TGo4BrowserItem::ProduceFullName(TString& fullname)
109 {
110  if (GetParent()!=0) {
111  GetParent()->ProduceFullName(fullname);
112  if (fullname.Length()>0) fullname+="/";
113  fullname += GetName();
114  } else
115  fullname = "";
116 }
117 
119 {
120  TString res;
121  ProduceFullName(res);
122  return res;
123 
124 }
125 
126 void TGo4BrowserItem::Browse(TBrowser* b)
127 {
128  if (IsFolder()) TFolder::Browse(b);
129 
130  DrawItem();
131 }
132 
134 {
135  TString itemname;
136 
137  ProduceFullName(itemname);
138 
139  fRootBrowser->DrawItem(itemname.Data());
140 }
141 
143 {
144  TString itemname;
145  ProduceFullName(itemname);
146  if ((itemname.Length()==0) || (fBrowser==0)) return;
147 
148  fBrowser->ProduceExplicitCopy(itemname.Data(), 0, kTRUE);
149 }
150 
152 {
153  if (GetParent()==0) {
155  return;
156  }
157 
158 
159  TString itemname;
160  ProduceFullName(itemname);
161  if ((itemname.Length()==0) || (fBrowser==0)) return;
162 
163  TGo4Slot* itemslot = fBrowser->ItemSlot(itemname.Data());
164  if (itemslot==0) return;
165 
166  TGo4Slot* memslot = fBrowser->BrowserMemorySlot();
167 
168  if (fBrowser->IsCanDelete(itemslot) || itemslot->IsParent(memslot))
169  fBrowser->DeleteDataSource(itemslot);
170 }
171 
173 {
174  SetMonitorFlag(kTRUE);
175 }
176 
178 {
179  SetMonitorFlag(kFALSE);
180 }
181 
183 {
184  TString itemname;
185  ProduceFullName(itemname);
186  if ((itemname.Length()==0) || (fBrowser==0)) return;
187 
188  TGo4Slot* itemslot = fBrowser->ItemSlot(itemname.Data());
189  if (itemslot==0) return;
190  int kind = fBrowser->ItemKind(itemslot);
191 
192  if (kind==TGo4Access::kndFolder) {
193  TGo4Iter iter(itemslot, kTRUE);
194  while (iter.next()) {
195  TGo4Slot* subslot = iter.getslot();
196  if (fBrowser->ItemKind(subslot)==TGo4Access::kndObject)
197  fBrowser->SetItemMonitored(subslot, on);
198  }
199  } else
200  fBrowser->SetItemMonitored(itemslot, on);
201 }
202 
203 
205 {
206  if (fBrowser!=0)
207  fBrowser->ToggleMonitoring(sec*1000);
208 }
209 
211 {
213  if (anal!=0)
214  anal->StartAnalysis();
215 }
216 
218 {
220  if (anal!=0)
221  anal->StopAnalysis();
222 }
223 
224 
225 void TGo4BrowserItem::Delete(Option_t* option)
226 {
227  DeleteItem();
228 }
229 
230 void TGo4BrowserItem::SetName(const char* name)
231 {
232  TFolder::SetName(name);
233 }
234 
235 void TGo4BrowserItem::SetTitle(const char* title)
236 {
237  TFolder::SetTitle(title);
238 }
239 
240 void TGo4BrowserItem::ls(Option_t* option) const
241 {
242  TFolder::ls(option);
243 }
244 
245 #if ROOT_VERSION_CODE < ROOT_VERSION(5,13,6)
246 void TGo4BrowserItem::SaveAs(const char* filename)
247 {
248  TFolder::SaveAs(filename);
249 }
250 #else
251 void TGo4BrowserItem::SaveAs(const char* filename, Option_t *option)
252 {
253  TFolder::SaveAs(filename, option);
254 }
255 #endif
256 
258 {
259  TFolder::DrawClass();
260 }
261 
262 TObject* TGo4BrowserItem::DrawClone(Option_t* option) const
263 {
264  return TFolder::DrawClone(option);
265 }
266 
268 {
269  TFolder::Dump();
270 }
271 
273 {
274  TFolder::Inspect();
275 }
276 
277 void TGo4BrowserItem::SetDrawOption(Option_t* option)
278 {
279  TFolder::SetDrawOption(option);
280 }
281 
void deleteChild(TGo4BrowserItem *item)
TGo4BrowserItem * GetParent() const
virtual void DrawItem()
virtual void SetTitle(const char *title="")
TIterator * fIter
virtual void Browse(TBrowser *b)
virtual ~TGo4BrowserItem()
Int_t ItemKind(const char *name)
TGo4BrowserProxy * fBrowser
TGo4RootBrowserProxy * fRootBrowser
TGo4Slot * getslot() const
Definition: TGo4Iter.cxx:167
Bool_t DeleteDataSource(TGo4Slot *itemslot)
virtual void SetName(const char *name)
virtual void ls(Option_t *option="*") const
TGo4ServerProxy * FindServer(const char *itemname=0, Bool_t asanalysis=kTRUE)
virtual void StartAnalysis()
virtual Bool_t IsFolder() const
virtual void StartAnalysis()
virtual void DrawClass() const
Bool_t IsCanDelete(TGo4Slot *slot)
virtual void Inspect() const
Bool_t IsParent(const TGo4Slot *slot) const
Definition: TGo4Slot.cxx:197
virtual void ToggleMonitoring(Int_t sec)
void SetMonitorFlag(Bool_t on)
virtual void StopAnalysis()
virtual void Delete(Option_t *option="")
virtual void SetMonitorOff()
void SetItemMonitored(TGo4Slot *slot, Bool_t on=kTRUE)
TGo4Slot * BrowserMemorySlot()
Bool_t ProduceExplicitCopy(const char *itemname, const char *tgtpath=0, Bool_t forcerequest=kFALSE)
TGo4BrowserItem * nextChild()
void DrawItem(const char *itemname)
virtual void SetMonitorOn()
virtual void Dump() const
virtual void StopAnalysis()
virtual void CopyToWorkspace()
virtual void SetDrawOption(Option_t *option="")
void SetBrowser(TGo4BrowserProxy *br, TGo4RootBrowserProxy *br2)
virtual TObject * DrawClone(Option_t *option="") const
virtual void DeleteItem()
virtual void SaveAs(const char *filename="", Option_t *option="")
TGo4Slot * ItemSlot(const char *itemname)
void ProduceFullName(TString &fullname)
void ToggleMonitoring(Int_t period)
Bool_t next(Bool_t goesinto=kTRUE)
Definition: TGo4Iter.cxx:45
TGo4BrowserItem * firstChild()