Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4GUI/TGo4DiskFileBrowserSlots.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE 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 "TGo4DiskFileBrowserSlots.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TFile.h"
00021 #include "TFolder.h"
00022 #include "TBranch.h"
00023 #include "TObjArray.h"
00024 #include "TArrayC.h"
00025 #include "TROOT.h"
00026 #include "TList.h"
00027 #include "TIterator.h"
00028 #include "TCanvas.h"
00029 #include "TKey.h"
00030 #include "TBranchElement.h"
00031 #include "THStack.h"
00032 #include "TH1.h"
00033 #include "TH2.h"
00034 #include "TH3.h"
00035 #include "TSystem.h"
00036 #include "TSystemFile.h"
00037 #include "TTree.h"
00038 
00039 #include "qlistview.h"
00040 #include "qfileinfo.h"
00041 #include "qtabwidget.h"
00042 #include "qstring.h"
00043 #include "qptrlist.h"
00044 #include "qdir.h"
00045 #include "qmessagebox.h"
00046 
00047 #include "Go4LockGuard/TGo4LockGuard.h"
00048 #include "Go4StatusBase/TGo4Parameter.h"
00049 #include "Go4Event/TGo4CompositeEvent.h"
00050 #include "Go4Analysis/TGo4AnalysisObjectManager.h"
00051 #include "Go4StatusAnalysis/TGo4HistogramStatus.h"
00052 #include "Go4ConditionsBase/TGo4CondArray.h"
00053 
00054 #include "Go4QtBaseWidgets/TGo4QItem.h"
00055 #include "Go4QtBaseWidgets/TGo4QTH1Item.h"
00056 #include "Go4QtBaseWidgets/TGo4QTH2Item.h"
00057 #include "Go4QtBaseWidgets/TGo4QTH3Item.h"
00058 #include "Go4QtBaseWidgets/TGo4QConItem.h"
00059 #include "Go4QtBaseWidgets/TGo4QTreeItem.h"
00060 #include "Go4QtBaseWidgets/TGo4QBranchItem.h"
00061 #include "Go4QtBaseWidgets/TGo4QLeafItem.h"
00062 #include "Go4QtBaseWidgets/TGo4QFileItem.h"
00063 #include "Go4QtBaseWidgets/TGo4QDirItem.h"
00064 #include "Go4QtBaseWidgets/TGo4QFolderItem.h"
00065 #include "Go4QtBaseWidgets/TGo4QParaItem.h"
00066 #include "Go4QtBaseWidgets/TGo4QWinArrayItem.h"
00067 #include "Go4QtBaseWidgets/TGo4QPolyArrayItem.h"
00068 
00069 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00070 #include "TGo4DiskFileBrowser.h"
00071 #include "TGo4DiskFileBrowserStatus.h"
00072 #include "TGo4PreviewPanel.h"
00073 #include "TGo4BrowserSlots.h"
00074 #include "TGo4MainWindow.h"
00075 #include "TGo4DockBrowsers.h"
00076 #include "TGo4HistogramInfo.h"
00077 #include "TGo4ConditionInfo.h"
00078 
00079 TGo4DiskFileBrowserSlots::TGo4DiskFileBrowserSlots(const char * name, const char * title, TGo4DiskFileBrowser * p)
00080                  :TGo4SlotsBaseClass(name , title), fxTGo4DiskFileBrowser(p) {
00081    // TGo4LockGuard Global;
00082 
00083    fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00084    fxTGo4DiskFileBrowserStatus= new TGo4DiskFileBrowserStatus("TGo4DiskFileBrowserStatus", "Disk Browser Status");
00085    fxTGo4GUIRegistry->RegisterSlotClass(this, fxTGo4DiskFileBrowserStatus, p);
00086 //   Event=0;
00087 //   fxFile=0;
00088 //   fxTree=0;
00089    fxMainWin = dynamic_cast <TGo4MainWindow *> (fxTGo4GUIRegistry->GetMainWindow());
00090    fxTGo4DockBrowsers=dynamic_cast <TGo4DockBrowsers *>((fxTGo4DiskFileBrowser->parentWidget()->parentWidget()->parentWidget()->parentWidget()));
00091 }
00092 
00093 void TGo4DiskFileBrowserSlots::OpenSelectedMacro(const char* cName, const char* cPath) 
00094 {
00095 }
00096 
00097 
00098 void TGo4DiskFileBrowserSlots::FileItemDoubleClicked(QListViewItem *SelectedItem) {
00099    // TGo4LockGuard Global;
00100    TGo4QItem *Item=dynamic_cast<TGo4QItem*>(SelectedItem);
00101    if(Item!=0)
00102       {
00103          TFile *ActiveFile =Item->GetRootFile();
00104 
00105          ActiveFile->cd();
00106          fxTGo4DiskFileBrowserStatus->SetActiveFile(ActiveFile);
00107       }
00108    if ((dynamic_cast<TGo4QTHItem*>(SelectedItem))!=0){
00109       PlotLocal();
00110    }else if(Item!=0){
00111       Item->ItemDBkLocal();
00112    }
00113 }
00114 
00115 void TGo4DiskFileBrowserSlots::SuperImposeLocal() {
00116 //TGo4LockGuard Global;
00117 TGo4PreviewPanel * viewpanel = fxMainWin->ViewPanelSlot();
00118 viewpanel->ChangeSuperImpose(true);
00119 if(fxTGo4DiskFileBrowser->FileListView->isMultiSelection()) {
00120    QListViewItemIterator it(fxTGo4DiskFileBrowser->FileListView);
00121    // iterate through all items of the list view
00122     for ( ; it.current(); ++it ) {
00123        if ( it.current()->isSelected() ) {
00124             TGo4QItem* go4qitem=dynamic_cast<TGo4QItem*>(it.current());
00125             if(go4qitem) go4qitem->DrawObj(viewpanel);           
00126         } // if(..isSelected)
00127     } // for
00128 } //if(fxTGo4DiskFileBrowser->FileListView->isMultiSelection()){
00129 }
00130 
00131 void TGo4DiskFileBrowserSlots::PlotLocal() {
00132    // TGo4LockGuard Global;
00133    QPtrList <TGo4QItem> *SelectedLst = fxTGo4DiskFileBrowser->GetSelectedItems();
00134    int PadNo=0;
00135    int NoOfObjects = SelectedLst->count();
00136    TGo4PreviewPanel * viewpanel = fxMainWin->ViewPanelSlot(NoOfObjects);
00137    if(viewpanel!=0) {
00138       TCanvas * canvas = viewpanel->GetCanvas();
00139       canvas->Resize();
00140       QPtrListIterator <TGo4QItem> it(*SelectedLst);
00141       TGo4QItem *Item;
00142       while ( (Item = it.current())!=0){
00143          ++it;
00144          canvas->cd(++PadNo);
00145          Item->DrawObj(viewpanel, (TPad *)gPad);
00146          // previewpanel active pad is not changed here (performance?),
00147          // so we set the real draw pad ourselves
00148       }
00149       canvas->Update();
00150    }
00151    fxTGo4DiskFileBrowser->FileListView->clearSelection();
00152    delete SelectedLst;
00153 }
00154 
00155 void TGo4DiskFileBrowserSlots::EditSelected()
00156 {
00157    // TGo4LockGuard Global;
00158    QPtrList <TGo4QItem> *SelectedLst = fxTGo4DiskFileBrowser->GetSelectedItems();
00159    QPtrListIterator <TGo4QItem> it(*SelectedLst);
00160    TGo4QItem *Item;
00161    while ( (Item = it.current())!=0){
00162       ++it;
00163       FileItemDoubleClicked(Item);
00164    }
00165    delete SelectedLst;
00166 }
00167 
00168 void TGo4DiskFileBrowserSlots::ShowSelectedProperties() 
00169 {
00170    // TGo4LockGuard Global;
00171    QPtrList <TGo4QItem> *SelectedLst = fxTGo4DiskFileBrowser->GetSelectedItems();
00172    QPtrListIterator <TGo4QItem> it(*SelectedLst);
00173    TGo4QItem *Item;
00174    while ( (Item = it.current())!=0){
00175       ++it;
00176       ShowProperties(Item);
00177       break; // only treat first selected item here!
00178    }
00179    delete SelectedLst;
00180 }
00181 
00182 void TGo4DiskFileBrowserSlots::ShowProperties(QListViewItem *Item)
00183 {
00184 TGo4QItem* go4item=dynamic_cast<TGo4QItem*>(Item);
00185 if(go4item==0) return;
00186 TFile *ActiveFile =go4item->GetRootFile();
00187 ActiveFile->cd();
00188 fxTGo4DiskFileBrowserStatus->SetActiveFile(ActiveFile);
00189 QString iname=Item->text(0);
00190 if(dynamic_cast<TGo4QTH1Item*>(Item) || 
00191       dynamic_cast<TGo4QTH2Item*>(Item) ||
00192          dynamic_cast<TGo4QTH3Item*>(Item))
00193    {      
00194          TGo4HistogramInfo* hinfo=fxMainWin->HistogramInfoSlot(0); // no name, no request from analysis!
00195          TH1* his=dynamic_cast<TH1*>(go4item->GetWorkObject());
00196          hinfo->ShowProperties(his);
00197    }
00198 else if (dynamic_cast<TGo4QConItem*>(Item))
00199    {
00200          TGo4ConditionInfo* cinfo=fxMainWin->ConditionInfoSlot(0);// no name, no request from analysis!
00201          TGo4Condition* conny=dynamic_cast<TGo4Condition*>(go4item->GetWorkObject());
00202          cinfo->ShowProperties(conny);
00203    }
00204 else
00205    cout <<"Requested Properties for unknown type item "<<iname.data() << endl;   
00206 }
00207 
00208 void TGo4DiskFileBrowserSlots::SetGUI(TGo4DiskFileBrowser *GUI ) {
00209    // TGo4LockGuard Global;
00210    fxTGo4DiskFileBrowser= GUI;
00211    fxTGo4GUIRegistry->GuiIsChanged(this, GUI);
00212 }
00213 
00214 TGo4Status * TGo4DiskFileBrowserSlots::GetStatus() {
00215    return fxTGo4DiskFileBrowserStatus;
00216 }
00217 
00218 TGo4DiskFileBrowserSlots::~TGo4DiskFileBrowserSlots() {
00219    delete fxTGo4DiskFileBrowserStatus;
00220 }
00221 
00222 
00223 // new code, added by S.Linev 21.11.2003
00224 // added netfile and rfio JA 03.12.2004
00225 
00226 void TGo4DiskFileBrowserSlots::OpenSelectedRootFile(const char* cName, const char* cPath) 
00227 {
00228    TGo4LockGuard Global;
00229    TFile* file =0;
00230    TGo4QFileItem* file_item=0; 
00231    QString Name = cName;
00232    QString Path = cPath;
00233    QString openname;
00234    if(!Name.contains("root:") && 
00235       !Name.contains("rfio:") &&
00236       !Name.contains("http:"))
00237       {
00238          // case of local root file:
00239          QFileInfo fi(Name.data());
00240          file = dynamic_cast <TFile*> (fxTGo4DiskFileBrowserStatus->GetObjectfromFileList((fi.fileName())));
00241          if (file!=0) return; // file already loaded
00242          gSystem->ChangeDirectory(fi.dir().path().data());
00243          openname=fi.fileName();
00244          file = TFile::Open(openname,"READ");
00245          if(file==0 || file->IsZombie() || !file->IsOpen()) return;         
00246          file_item = new TGo4QFileItem(fxTGo4DiskFileBrowser->FileListView, openname,fi, file);
00247     }      
00248    else  // open non local files without Qt file info object:
00249       {
00250          openname=Name;
00251          //cout <<"Try to open file: "<<openname << endl;         
00252          file = TFile::Open(openname,"READ");
00253          if(file==0 || file->IsZombie() || !file->IsOpen()) return;
00254          file_item = new TGo4QFileItem(fxTGo4DiskFileBrowser->FileListView, openname, file); 
00255       }
00256    //file_item->SetRootFile(file); // done in ctors now  
00257 //   cout <<"gDirectory is "<<gDirectory << endl;
00258 //   if(gDirectory) cout <<gDirectory->GetName() << endl; 
00259    
00260    fxTGo4DiskFileBrowserStatus->AddToFileListStatus(file);
00261    fxTGo4DiskFileBrowserStatus->SetActiveFile(file);
00262    TKey *key;
00263    TIter next(file->GetListOfKeys());
00264    while((key=dynamic_cast <TKey*>(next())) !=0) {
00265       TClass* cl=TClass::GetClass(key->GetClassName());
00266       if(cl && cl->InheritsFrom("TTree")){
00267         TTree* tree = dynamic_cast <TTree*> (key->ReadObj());
00268         TGo4QTreeItem* tree_item = new TGo4QTreeItem(file_item,  tree->GetName());
00269         tree_item->SetRootFile(file);
00270         tree_item->SetFileKey(key);
00271         tree_item->SetFileObj(tree);
00272         tree_item->SetItemObject(tree);
00273 
00274         TObjArray *ListOfBranches = tree->GetListOfBranches();
00275         TArrayC UsageOfBranches(ListOfBranches->GetLast()+1);
00276         UsageOfBranches.Reset(0);
00277 
00278         TBranch *fxBranch = dynamic_cast <TBranch*> (ListOfBranches->At(0));
00279         TClass *cl = (fxBranch!=0) ? gROOT->GetClass(fxBranch->GetClassName()) : 0;
00280 
00281         if((cl!=0) && cl->InheritsFrom(TGo4CompositeEvent::Class())) {
00282            //tree with composite event
00283            TGo4CompositeEvent * evt = new TGo4CompositeEvent();
00284            evt->synchronizeWithTree(tree);
00285            file_item->SetComposite(evt);
00286            MapEvent(tree_item, file, tree, evt, ListOfBranches, &UsageOfBranches);
00287         }
00288 
00289         // normal tree or unused branches
00290         TIter next(ListOfBranches);
00291         TObject *entry;
00292         while((entry=next())!=0)
00293           if (UsageOfBranches[ListOfBranches->IndexOf(entry)]==0)
00294             MapBranch(tree_item, file, tree, dynamic_cast<TBranch*>(entry));
00295       } else
00296         MapObject(file_item, file, key, 0);
00297    }
00298 
00299 
00300    QTabWidget * dockbrowsertabs=dynamic_cast <QTabWidget *>((fxTGo4DiskFileBrowser->parentWidget()->parentWidget()->parentWidget()));
00301    dockbrowsertabs->setCurrentPage(0);
00302    //gROOT->cd();
00303 }
00304 
00305 QListViewItem* TGo4DiskFileBrowserSlots::MapBranch(QListViewItem *parent, TFile* file, TTree* tree,
00306                                                    TBranch *branch, Bool_t createbr) {
00307    // TGo4LockGuard Global;
00308 
00309    if ((branch==0) || (parent==0)) return 0;
00310 
00311    QListViewItem* res = createbr ? 0 : parent;
00312 
00313    TObjArray *Elements = branch->GetListOfBranches();
00314 
00315    if (Elements->GetEntries() > 0) {
00316       if (createbr) {
00317          TGo4QBranchItem *item = new TGo4QBranchItem(parent, branch->GetName(), branch->GetClassName());
00318          item->SetRootFile(file);
00319          item->SetRootTree(tree);
00320          res = item;
00321       }
00322       TIter next(Elements);
00323       TObject *entry;
00324       while((entry=next())!=0)
00325         MapBranch(res, file, tree, dynamic_cast<TBranch*>(entry));
00326    } else
00327 
00328    if (createbr) {
00329       TGo4QLeafItem *leafitem = new TGo4QLeafItem(parent, branch->GetName(), branch->GetClassName());
00330       leafitem->SetRootFile(file);
00331       leafitem->SetRootTree(tree);
00332       res = leafitem;
00333    }
00334 
00335    return res;
00336 }
00337 
00338 
00339 QListViewItem* TGo4DiskFileBrowserSlots::MapEvent(QListViewItem* parent, TFile* file, TTree* tree,
00340                                                   TGo4EventElement* elem, TObjArray* ListOfBranches, TArrayC* UsageOfBarnches) {
00341     if (elem==0) return 0;
00342 
00343     QString BranchName = elem->GetName();
00344     BranchName += ".";
00345     TBranch* br = dynamic_cast<TBranch*> (ListOfBranches->FindObject(BranchName.data()));
00346     if (br==0) return 0;
00347 
00348     int indx = ListOfBranches->IndexOf(br);
00349     (*UsageOfBarnches)[indx] = 1; // set flag, that branch is used
00350 
00351 
00352     TGo4QBranchItem *item = new TGo4QBranchItem(parent, elem->GetName(), elem->ClassName(), elem->GetTitle());
00353     item->SetRootFile(file);
00354     item->SetRootTree(tree);
00355     item->SetRootBranchName(BranchName);
00356 
00357     if (elem->InheritsFrom(TGo4CompositeEvent::Class())) {
00358        TGo4CompositeEvent* comp = dynamic_cast<TGo4CompositeEvent*> (elem);
00359 
00360        TIter next(comp->getElements());
00361 
00362        TGo4EventElement* childevent;
00363 
00364        while ((childevent = dynamic_cast<TGo4EventElement*>(next())) !=0 )
00365           MapEvent(item, file, tree, childevent, ListOfBranches, UsageOfBarnches);
00366     }
00367 
00368     MapBranch(item, file, tree, br, kFALSE); // scan only subbrunches
00369 
00370     return item;
00371 }
00372 
00373 QListViewItem* TGo4DiskFileBrowserSlots::MapObject(QListViewItem *parent, TFile* file, TKey* key, TObject* obj) {
00374    if ((key==0) && (obj==0)) return 0;
00375 
00376    TGo4QItem* item = 0;
00377 
00378    bool usekeysonly = (key!=0) && (obj==0);
00379 
00380    if (key!=0)
00381      { 
00382       item = fxTGo4DockBrowsers->CreateListViewItem(parent, key->GetName(), key->GetClassName());
00383      
00384      }
00385    if (item==0) {
00386      if (obj==0) obj = key->ReadObj();
00387      if (obj==0) return 0;
00388      item = fxTGo4DockBrowsers->CreateListViewItem(parent, obj->GetName(), obj->ClassName());
00389    }
00390 
00391    // why Class_Name(), not ClassName() is used
00392 
00393    if (item==0) {
00394       if(obj->InheritsFrom(TGo4Parameter::Class())) {
00395          TGo4Parameter* fxPara= dynamic_cast <TGo4Parameter*> (obj);
00396          item = new TGo4QParaItem(parent, fxPara->GetName(), fxPara->ClassName());
00397       } else if (obj->InheritsFrom(TGo4CondArray::Class())){
00398          TGo4CondArray *fxCond= dynamic_cast <TGo4CondArray *> (obj);
00399          Int_t ArrayType;
00400          fxCond->GetType(ArrayType); //(kWINDOW=1 or kPOLYGON=2).
00401          if(ArrayType==1){ //window conds array
00402             item = new TGo4QWinArrayItem(parent, fxCond->GetName(), fxCond->Class_Name());
00403          }else if(ArrayType==2){  //poly window conds array
00404             item = new TGo4QPolyArrayItem(parent, fxCond->GetName(), fxCond->Class_Name());
00405          }else{
00406             item = new TGo4QItem(parent, 0, obj->GetName(),obj->ClassName());
00407          }
00408       }
00409    }
00410 
00411    if (item!=0) {
00412       item->SetRootFile(file);
00413       item->SetFileKey(key);
00414       item->SetFileObj(obj);
00415       item->SetItemObject(obj);
00416       if(obj) item->setText(2,obj->GetTitle()); // not yet provided in item factory
00417 
00418       //**   special actions has to be taken for some items
00419 
00420       TGo4QDirItem* DirItem = dynamic_cast<TGo4QDirItem*> (item);
00421       TGo4QFolderItem *FolderItem = dynamic_cast<TGo4QFolderItem*> (item);
00422 
00423       if(DirItem!=0){
00424          if (obj==0) obj = key->ReadObj();
00425 
00426          TDirectory *Dir = dynamic_cast <TDirectory *> (obj);
00427          TIter next(Dir->GetListOfKeys());
00428          TKey *childkey;
00429          while((childkey = dynamic_cast <TKey*> (next())) != 0)
00430             if (usekeysonly) MapObject(item, file, childkey, 0);
00431                         else MapObject(item, file, childkey, childkey->ReadObj()); // Why not to always set keys
00432       } else if(FolderItem!=0){
00433          if (obj==0) obj = key->ReadObj();
00434 
00435          TFolder *fxFolder = dynamic_cast <TFolder *> (obj);
00436          TIter next(fxFolder->GetListOfFolders());
00437          TObject *childfolder;
00438          while((childfolder=next()) != 0)
00439             MapObject(item, file, 0,  childfolder);
00440       }
00441 
00442    }
00443 
00444    return item;
00445 }
00446 
00447 const Text_t*  TGo4DiskFileBrowserSlots::SaveObject(TObject* ob, const char* newname)
00448 {
00449     if(ob==0) return 0;
00450     TGo4LockGuard Global;
00451     Text_t obname[256];
00452     if(newname)
00453        snprintf(obname,256,"%s",newname);
00454     else
00455        snprintf(obname,256,"%s",ob->GetName());
00456     
00457     if(fxTGo4DiskFileBrowser)
00458        fxFilename=fxTGo4DiskFileBrowser->SaveFileDialog(obname).data();
00459     else
00460        fxFilename="go4filebrowsersaves.root"; // never come here?
00461     if(fxFilename.IsNull()) return 0;
00462     //cout <<"try to save object as "<< obname << endl;
00463     // open file (append mode)
00464     TDirectory* savdir=gDirectory;
00465     TFile outfile(fxFilename,"UPDATE");
00466     if(!outfile.IsOpen()) return 0;
00467     //Old scheme: look for the go4 folders:
00468     TObject* topob=outfile.Get(TGo4AnalysisObjectManager::fgcTOPFOLDER);
00469     TFolder* top= dynamic_cast<TFolder*>(topob);
00470     if(top)
00471          {
00472           // this is for old type of go4 autosave files with folders
00473           // append clone of condition to conditions folder, overwrite old one
00474            const Text_t* fullpath=top->FindFullPathName(obname);
00475            if(fullpath)
00476               {
00477                  Text_t path[256];
00478                  snprintf(path,256,"%s",fullpath);
00479                  //cout <<"Found full path:"<<fullpath << endl;
00480                  Text_t* pathbegin=strstr(path,TGo4AnalysisObjectManager::fgcTOPFOLDER);
00481                  Text_t* reducedpath=strstr(pathbegin,"/");
00482                  reducedpath+=1;
00483                  Text_t* pathend=strstr(path,obname);
00484                  pathend-=1;
00485                  //snprintf(pathend,1,"\0"); // strip obname from folder path
00486                  *pathend = 0;
00487                  //cout <<"Folder path:"<<reducedpath << endl;
00488                  TFolder* oldfolder=dynamic_cast<TFolder*>(top->FindObject(reducedpath));
00489                  outfile.cd();
00490                  if(oldfolder)
00491                     {
00492                        TObject* oldob=oldfolder->FindObjectAny(obname);
00493                        if(oldob) oldfolder->RecursiveRemove(oldob);
00494                        oldfolder->Add(ob->Clone(obname));
00495                        top->Write(0, TObject::kOverwrite);
00496                     }
00497                  else
00498                     {
00499                       //cout <<"Could not find old folder, write to top" << endl;
00500                       ob->Write(obname, TObject::kOverwrite);
00501                     }
00502               } // if(fullpath)
00503          }
00504     else
00505        {
00506           // new go4 autosave file with subdirectories
00507           outfile.cd(); // default is top of file
00508           if(outfile.FindKeyAny(obname)==0) // will set gDirectory to subdir of key if found
00509              {
00510                 // if this fails, use top dirs for different types of objects
00511                 const Text_t* subfoldername;
00512                 if(ob->InheritsFrom("TGo4Condition"))
00513                    subfoldername=TGo4AnalysisObjectManager::fgcCONDFOLDER;
00514                    //outfile.cd(TGo4AnalysisObjectManager::fgcCONDFOLDER);
00515                 else if (ob->InheritsFrom("TGo4Parameter"))
00516                    subfoldername=TGo4AnalysisObjectManager::fgcPARAFOLDER;
00517                    //outfile.cd(TGo4AnalysisObjectManager::fgcPARAFOLDER);
00518                 else if (ob->InheritsFrom("TGo4DynamicEntry"))
00519                    subfoldername=TGo4AnalysisObjectManager::fgcDYNFOLDER;
00520                    //outfile.cd(TGo4AnalysisObjectManager::fgcDYNFOLDER);
00521                 else if (ob->InheritsFrom("TH1"))
00522                    subfoldername=TGo4AnalysisObjectManager::fgcHISTFOLDER;
00523                    //outfile.cd(TGo4AnalysisObjectManager::fgcHISTFOLDER);
00524                 else if (ob->InheritsFrom("TCanvas"))
00525                    subfoldername=TGo4AnalysisObjectManager::fgcCANVFOLDER;
00526                    //outfile.cd(TGo4AnalysisObjectManager::fgcCANVFOLDER);
00527                 else if (ob->InheritsFrom("TGo4Picture"))
00528                    subfoldername=TGo4AnalysisObjectManager::fgcPICTFOLDER;
00529                    //outfile.cd(TGo4AnalysisObjectManager::fgcPICTFOLDER);
00530                 else
00531                    subfoldername="Others";
00532                    //outfile.cd();
00533                 TDirectory* subdir=dynamic_cast<TDirectory*>(outfile.Get(subfoldername));
00534                 if(subdir==0)
00535                    {
00536                       subdir=outfile.mkdir(subfoldername,"subdir");
00537                    }
00538     
00539                 if(subdir)
00540                    subdir->cd();
00541                    //outfile.cd(subfoldername);
00542                 else
00543                    outfile.cd();
00544     
00545              }
00546     //      const Text_t* oldname=ob->GetName();
00547     //      ob->SetName(obname); // key and object name must match to avoid later problems with load
00548           ob->Write(obname, TObject::kOverwrite);
00549     
00550     //      ob->SetName(oldname); // restore original name
00551        }
00552     outfile.Close();
00553     savdir->cd();
00555     QFileInfo fi(fxFilename.Data());
00556     TFile* oldfile = dynamic_cast <TFile*> (fxTGo4DiskFileBrowserStatus->GetObjectfromFileList((fi.fileName())));
00557     if (oldfile!=0) {
00558        fxTGo4DiskFileBrowser->RemoveFileItem(oldfile->GetName()); // will close file
00559        QString fname = fxFilename.Data();
00560        QString fpath = ".";
00561        OpenSelectedRootFile(fname,fpath);
00562     }
00563     return fxFilename.Data();
00564 }
00565 
00566 
00567 const Text_t* TGo4DiskFileBrowserSlots::LoadObject(TObject** pob, const Text_t* name)
00568 {
00569 if(fxTGo4DiskFileBrowser)
00570    fxFilename=fxTGo4DiskFileBrowser->LoadFileDialog(name).data();
00571 else
00572    fxFilename="go4filebrowsersaves.root"; // never come here?
00573 if(fxFilename.IsNull()) return 0;
00574 TDirectory* savdir=gDirectory;
00575 TFile infile(fxFilename,"READ");
00576 if(!infile.IsOpen()) return 0;
00577 if(infile.FindKeyAny(name)==0) return 0;
00578 TObject* fileob=gDirectory->Get(name);
00579 savdir->cd();
00580 //cout <<"Slots::LoadObject got "<<fileob << endl;
00581 if(fileob) *pob=fileob->Clone(); // file is closed after return, so fileob will be deleted!
00582 //cout <<"Slots::LoadObject cloned to "<< *pob << endl;
00583 return fxFilename.Data();
00584 }
00585 
00586 
00587 
00588 
00589 
00590 
00591 
00592 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:00 2005 for Go4-v2.10-5 by doxygen1.2.15