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

/Go4QtBaseWidgets/TGo4QTHStackItem.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 "TGo4QTHStackItem.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "THStack.h"
00021 #include "TPad.h"
00022 #include "TCanvas.h"
00023 
00024 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00025 #include "Go4GUI/TGo4PreviewPanel.h"
00026 #include "Go4GUI/TGo4MonitoredObject.h"
00027 #include "Go4GUI/TGo4BrowserSlots.h"
00028 #include "Go4GUI/TGo4BrowserStatus.h"
00029 #include "Go4GUI/TGo4Browser.h"
00030 #include "Go4GUI/TGo4QRootCanvas.h"
00031 
00032 TGo4QTHStackItem::TGo4QTHStackItem( QListViewItem* parent, const QString & text, const QString & text1,  const QString & text2)
00033    :TGo4QTHItem (parent, "superimpose.png", text, text1, text2)
00034 {
00035 }
00036 
00037 TGo4QTHStackItem::TGo4QTHStackItem( QListView* parent, const QString & text, const QString & text1,  const QString & text2)
00038    :TGo4QTHItem (parent, "superimpose.png", text, text1, text2)
00039 {
00040 }
00041 
00042 TGo4QTHStackItem::~TGo4QTHStackItem(){}
00043 
00044 void TGo4QTHStackItem::DrawObj(TGo4PreviewPanel *viewpanel, TPad* currentpad)
00045 {
00046    if(!AssignDrawPanel(viewpanel,currentpad)) return;
00047    THStack* stack=dynamic_cast<THStack*>(GetWorkObject());
00048    if(stack)
00049       {
00050          QString realname=stack->GetName();
00051          TGo4BrowserSlots* browserslots = dynamic_cast <TGo4BrowserSlots *>(fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots"));
00052          TGo4Browser* browser=browserslots->GetBrowserGUI();
00053          if(InFileBrowser())
00054             {
00055                if(browserslots)  //browserslots->AddObjectToLocalList(hist,false);
00056                {
00057                    browserslots->AddObject(stack,fxDrawPanel->GetQCanvas(),fxDrawPad);
00058                    realname=browserslots->GetAddedItemName();
00059                    //cout <<"DrawObj in file browser sends to membrowser" << endl;
00060                   // if item was already there with reference to another pad,
00061                   // we have to redraw it on the drop pad               
00062                   fxDrawPad->cd();
00063                   TGo4QItem *memitem = (TGo4QItem*) browser->ListViewLocal->findItem(realname,0);
00064                   if (memitem!=0)
00065                      {
00066                         memitem->DrawObj(fxDrawPanel,fxDrawPad);
00067                      }
00068                }// if(browserslots)
00069             } // if(InFileBrowser())
00070          else
00071             {
00072                TPad* padsav=fxDrawPanel->GetActivePad();
00073                fxDrawPanel->SetActivePad(fxDrawPad);
00074                fxDrawPanel->ClearPad();
00075                stack->Draw("nostack");
00076                fxDrawPanel->UpdatePad(fxDrawPad, stack);
00077                fxDrawPanel->SetActivePad(padsav);
00078             }
00079       }
00080 }
00081 
00082 void TGo4QTHStackItem::UpdateOnline(TObject *fxObj)
00083 {
00084    bool keepscale=IsKeepScale();
00085    THStack* monstack=dynamic_cast <THStack*>(GetWorkObject());
00086    THStack* newstack=dynamic_cast <THStack*>(fxObj);
00087    if(monstack!=0 && newstack!=0)
00088       {
00089       TList* newlist=newstack->GetHists();
00090       TIterator* newliter=newlist->MakeIterator();
00091       TList* oldlist=monstack->GetHists();
00092       TObject* hob=0;
00093       while((hob=newliter->Next())!=0)
00094         {
00095            TH1* newhi=dynamic_cast<TH1*>(hob);
00096            if(newhi)
00097               {
00098                 const Text_t* hisname=newhi->GetName();
00099                 TH1* monhis= dynamic_cast<TH1*>(oldlist->FindObject(hisname));
00100                 if(monhis)
00101                    {
00102                      Double_t ymin,ymax;
00103                      if(keepscale)
00104                         {
00105                            ymin=monhis->GetMinimum();
00106                            ymax=monhis->GetMaximum();
00107                            //printf("UpdateOnline TH1 found scales: %f %f %f %f\n",xmin,xmax,ymin,ymax);
00108                         }
00109                      monhis->Reset();
00110                      monhis->Add(newhi);
00111                      if(keepscale)
00112                         {
00113                            monhis->SetMinimum(ymin);
00114                            monhis->SetMaximum(ymax);
00115                            //printf("UpdateOnline TH1 restored scales: \n");
00116                         }
00117                    }
00118                 else
00119                    {
00120                       // not found, we add the new one to our stack:
00121                        TH1* newhist = (TH1*) newhi->Clone();
00122                        TH1* lasthist=(TH1*) oldlist->Last();
00123                        newhist->SetLineColor(lasthist->GetLineColor()+1);
00124                        monstack->Add(newhist);
00125                    }
00126               } // if(newhi)
00127         }// while
00128       delete newliter;
00129       UpdateDrawPad();
00130    }// if(monstack!=0 && newstack!=0)
00131 }
00132 
00133 
00134 
00135 
00136 //----------------------------END OF GO4 SOURCE FILE ---------------------

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