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

/Go4QtBaseWidgets/TGo4QCanvasItem.cpp

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 "TGo4QCanvasItem.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TCanvas.h"
00021 #include "TObject.h"
00022 #include "TH1.h"
00023 
00024 #include "Go4StatusBase/TGo4CanvasWrapper.h"
00025 #include "Go4CommandsAnalysis/TGo4ComGetCanvas.h"
00026 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00027 #include "Go4GUI/TGo4PreviewPanel.h"
00028 #include "Go4GUI/TGo4MainWindow.h"
00029 #include "Go4GUI/TGo4QRootCanvas.h"
00030 #include "Go4GUI/TGo4MonitoredListSlots.h"
00031 #include "Go4GUI/TGo4MonitoredListStatus.h"
00032 #include "Go4GUI/TGo4MonitoredListSlots.h"
00033 #include "Go4GUI/TGo4MonitoredObject.h"
00034 #include "Go4GUI/TGo4BrowserSlots.h"
00035 #include "Go4GUI/TGo4BrowserStatus.h"
00036 
00037 TGo4QCanvasItem::TGo4QCanvasItem( QListViewItem* parent, const QString & text, const QString & text1,  const QString & text2)
00038    :TGo4QDragDrop(parent, "canvas.png", text, text1, text2)
00039 {
00040 }
00041 
00042 TGo4QCanvasItem::TGo4QCanvasItem( QListView* parent, const QString & text, const QString & text1,  const QString & text2)
00043    :TGo4QDragDrop (parent, "canvas.png", text, text1, text2)
00044 {
00045 }
00046 
00047 TGo4QCanvasItem::~TGo4QCanvasItem()
00048 {
00049 }
00050 
00051 void TGo4QCanvasItem::ItemDBkLocal()
00052 {
00053    TGo4PreviewPanel *viewPanel=0;
00054    TGo4MainWindow  *mw= dynamic_cast <TGo4MainWindow *> (fxTGo4GUIRegistry->GetMainWindow());
00055    if(mw!=0) viewPanel =mw->ViewPanelSlot();
00056    DrawObj(viewPanel);
00057 }
00058 
00059 void TGo4QCanvasItem::ItemDBkRemote()
00060 {
00061       GetRemoteObj();
00062 }
00063 
00064 void TGo4QCanvasItem::DrawObj(TGo4PreviewPanel *viewpanel, TPad* currentpad)
00065 {
00066    if(!AssignDrawPanel(viewpanel, currentpad)) return;
00067    TCanvas *FC=dynamic_cast<TCanvas*>(GetWorkObject());
00068    if(FC==0) return;
00069    TPad* padsav=fxDrawPanel->GetActivePad();
00070    fxDrawPanel->SetActivePad(fxDrawPad);
00071    fxDrawPanel->ClearPad();
00072    TGo4QRootCanvas *fxC=fxDrawPanel->GetQCanvas();
00073    TDirectory* filsav=gDirectory;// test
00074    gROOT->cd();// test
00075    fxC->InsertCanvas(FC, fxDrawPad);
00076    filsav->cd();// test
00077    fxDrawPanel->SetActivePad(padsav);
00078    if(InFileBrowser() || InMemoryBrowser())
00079       AddHistosToMemBrowser(fxDrawPad);
00080 }
00081 void TGo4QCanvasItem::DropAction(QWidget *Recvr)
00082 {
00083    TGo4PreviewPanel *fxPanel=dynamic_cast<TGo4PreviewPanel *>(Recvr);
00084    if(fxPanel!=0)DrawObj(fxPanel);
00085 
00086 }
00087 void TGo4QCanvasItem::GetOnlineObj()
00088 {
00089    TGo4MonitoredListSlots* fxTGo4MonitoredListSlots;
00090    fxTGo4MonitoredListSlots=dynamic_cast <TGo4MonitoredListSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4MonitoredListSlots"));
00091    TGo4ComGetCanvas* com = new TGo4ComGetCanvas(text(0).data());
00092    fxTGo4GUIRegistry->SubmitCommand(com,text(0).data(),fxTGo4MonitoredListSlots,kTRUE);
00093 
00094 }
00095 
00096 void TGo4QCanvasItem::UpdateOnline(TObject *ob)
00097 {
00098    TObject* oldobject=GetWorkObject();
00099    TObject* newcopy=0;
00100    Text_t obname[256];
00101    if(ob) snprintf(obname,256,"%s",ob->GetName());
00102    if(fbMonitorDone)
00103       {
00104       // memory list update
00105       //cout <<"TGo4QItem::UpdateOnline for memory" << endl;
00106       TGo4BrowserSlots* brslots=dynamic_cast <TGo4BrowserSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots"));
00107       if(brslots)
00108         {
00109             TGo4BrowserStatus* brstat=dynamic_cast <TGo4BrowserStatus *> (brslots->GetStatus());
00110             brstat->OverWriteLocalObject(dynamic_cast <TNamed*>(ob));
00111             newcopy=brstat->GetObjectfromLocalList(obname);
00112             //cout <<"CanvasItem::UpdateOnline has newcopy:"<<newcopy << endl;
00113             fxItemObject=newcopy;
00114         }
00115      }
00116    else
00117       {
00118        // update in monitoring list
00119        //cout <<"TGo4QItem::UpdateOnline for monitor" << endl;
00120        TGo4MonitoredListSlots* monslots=dynamic_cast <TGo4MonitoredListSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4MonitoredListSlots"));
00121       if(monslots)
00122         {
00123            TGo4MonitoredListStatus* monstat=dynamic_cast <TGo4MonitoredListStatus *> (monslots->GetStatus());
00124            TObject* addedobject=0;
00125             TGo4CanvasWrapper* cwrap=dynamic_cast<TGo4CanvasWrapper*>(ob);
00126             if(cwrap)
00127                {
00128                   //cout <<"CanvasItem::UpdateOnline has canvas wrapper." << endl;
00129                   addedobject=cwrap->GetCanvas(kFALSE);
00130                }
00131             else
00132                {
00133                   addedobject=ob;
00134                }
00135            newcopy=addedobject->Clone();
00136            if(newcopy)
00137               {
00138                  monstat->RemoveMonitoredObject(oldobject);
00139                  monstat->AddToMonitoredObjectList(newcopy);
00140                  TGo4MonitoredObject* MonitoredObj = monstat->GetMonitoredObject(obname);
00141                  if(MonitoredObj)
00142                     {
00143                        MonitoredObj->SetMonitoredObject(newcopy);
00144                        MonitoredObj->SetMonObjItem(this);
00145                     }
00146                  fxItemObject=MonitoredObj;
00147               } //if(newcopy)
00148         }//if(monslots)
00149       }//if(fbMonitorDone)
00150 
00151    // viewpanel may have been closed already!
00152    // AssignViewPanel does not check if viewpanel is there...
00153    if(IsExisting(fxDrawCanvas, fxDrawPad))
00154       DrawObj(fxDrawPanel, fxDrawPad); // redraw the canvas if old view still exists
00155 
00156 }
00157 
00158 void TGo4QCanvasItem::GetRemoteObj()
00159 {
00160    TGo4ComGetCanvas* com = new TGo4ComGetCanvas(text(0).data());
00161     fxTGo4GUIRegistry->SubmitCommand(com,text(0).data());
00162 }
00163 
00164 void TGo4QCanvasItem::AddHistosToMemBrowser(TPad* pad)
00165 {
00166 if(pad==0) return;
00167 TGo4BrowserSlots* browserslots = dynamic_cast <TGo4BrowserSlots *>(fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots"));
00168 if(browserslots)
00169 {
00171  //TH1* hist=fxDrawPanel->GetPadHistogram(fxDrawPad);
00172  // browserslots->AddObject(hist);
00174  TObject* ob=0;
00175  TList* primlist=pad->GetListOfPrimitives();
00176  TIterator* priter=primlist->MakeIterator();
00177  while((ob=priter->Next())!=0)
00178     {
00179        if(ob->InheritsFrom("TH1"))
00180           {
00181              TH1* hist=dynamic_cast<TH1*>(ob);
00182              //browserslots->AddObject(hist);
00183              browserslots->AddObjectToLocalList(hist, kFALSE, kFALSE); // register without cloning
00184              //cout <<"AddHistosToMembrowser sends canhisto "<< hist->GetName()<< " to membrowser" << endl;
00185           }
00186        else if(ob->InheritsFrom("TPad"))
00187           {
00188              TPad* subp=dynamic_cast<TPad*>(ob);
00189              AddHistosToMemBrowser(subp);
00190           }
00191     }
00192    delete priter;
00193 }// if(browserslots)
00194 
00195 }
00196 
00197 
00198 //----------------------------END OF GO4 SOURCE FILE ---------------------

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