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

/Go4QtBaseWidgets/TGo4QMultiGraphItem.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 "TGo4QMultiGraphItem.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TPad.h"
00021 #include "TMultiGraph.h"
00022 
00023 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00024 #include "Go4GUI/TGo4PreviewPanel.h"
00025 #include "Go4GUI/TGo4MonitoredObject.h"
00026 #include "Go4GUI/TGo4BrowserSlots.h"
00027 #include "Go4GUI/TGo4BrowserStatus.h"
00028 #include "Go4GUI/TGo4Browser.h"
00029 #include "Go4GUI/TGo4QRootCanvas.h"
00030 
00031 TGo4QMultiGraphItem::TGo4QMultiGraphItem( QListViewItem* parent, const QString & text, const QString & text1,  const QString & text2)
00032    :TGo4QTHItem (parent, "superimpose.png", text, text1, text2)
00033 {
00034 }
00035 
00036 TGo4QMultiGraphItem::TGo4QMultiGraphItem( QListView* parent, const QString & text, const QString & text1,  const QString & text2)
00037    :TGo4QTHItem (parent, "superimpose.png", text, text1, text2)
00038 {
00039 }
00040 
00041 TGo4QMultiGraphItem::~TGo4QMultiGraphItem(){}
00042 
00043 void TGo4QMultiGraphItem::DrawObj(TGo4PreviewPanel *viewpanel, TPad* currentpad)
00044 {
00045    if(!AssignDrawPanel(viewpanel, currentpad)) return;
00046    TMultiGraph* Gr=dynamic_cast<TMultiGraph *> (GetWorkObject());
00047   if(Gr!=0)
00048       {
00049          QString realname=Gr->GetName();
00050          TGo4BrowserSlots* browserslots = dynamic_cast <TGo4BrowserSlots *>(fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots"));
00051          TGo4Browser* browser=browserslots->GetBrowserGUI();
00052          if(InFileBrowser())
00053             {
00054                if(browserslots)  //browserslots->AddObjectToLocalList(hist,false);
00055                {
00056                 browserslots->AddObject(Gr,fxDrawPanel->GetQCanvas(),fxDrawPad);
00057                 realname=browserslots->GetAddedItemName();
00058                 //cout <<"DrawObj in file browser sends to membrowser" << endl;
00059                // if item was already there with reference to another pad,
00060                // we have to redraw it on the drop pad               
00061                fxDrawPad->cd();
00062                TGo4QItem *memitem = (TGo4QItem*) browser->ListViewLocal->findItem(realname,0);
00063                if (memitem!=0)
00064                   {
00065                      memitem->DrawObj(fxDrawPanel,fxDrawPad);
00066                   }
00067                }// if(browserslots)
00068             } // if(InFileBrowser())
00069          else
00070             {
00071                TPad* padsav=fxDrawPanel->GetActivePad();
00072                fxDrawPanel->SetActivePad(fxDrawPad);
00073                fxDrawPanel->ClearPad();
00074                Gr->Draw("AP");
00075                fxDrawPanel->UpdatePad(fxDrawPad, Gr);
00076                fxDrawPanel->SetActivePad(padsav);
00077             }
00078       } //if(Gr!=0)
00079 
00080 
00081 }
00082 
00083 void TGo4QMultiGraphItem::UpdateOnline(TObject *fxObj)
00084 {
00085 TMultiGraph* LocalGraph=dynamic_cast <TMultiGraph*>(GetWorkObject());
00086 if(LocalGraph )
00087 {
00088    fxDrawPanel->ClearLegend(fxDrawPad,true); // avoid crash of lost label references to overwritten objects
00089    TGo4QItem::UpdateOnline(fxObj); // overwrite local object in memory list
00090    DrawObj(fxDrawPanel,fxDrawPad);
00091    UpdateDrawPad();
00092 }
00093 
00094 //bool keepscale=IsKeepScale();
00095 //TGraph* LocalGraph=dynamic_cast <TGraph*>(GetWorkObject());
00096 //TGraph* NewGraph=dynamic_cast <TGraph*>(fxObj);
00097 //if(LocalGraph )
00098 //   {
00099 //   if(LocalGraph->GetN()>=1)
00100 //      {
00101 //      TH1* axeshistogram=LocalGraph->GetHistogram();
00102 //      Int_t xminbin=0;
00103 //      Int_t xmaxbin=0;
00104 //      Double_t ymin=0;
00105 //      Double_t ymax=0;
00106 //      if(keepscale && axeshistogram)
00107 //         {
00108 //         xminbin=axeshistogram->GetXaxis()->GetFirst();
00109 //         xmaxbin=axeshistogram->GetXaxis()->GetLast();
00110 //         ymin=axeshistogram->GetMinimum();
00111 //         ymax=axeshistogram->GetMaximum();
00112 //         }
00113 //      // reset graph on canvas:
00114 //      LocalGraph->Set(0); // clear array of points
00115 //      // copy contents of new graph to old one:
00116 //      Int_t pn=NewGraph->GetN();
00117 //      Double_t xp=0;
00118 //      Double_t yp=0;
00119 //      for(Int_t i=0; i<pn; ++i)
00120 //         {
00121 //           NewGraph->GetPoint(i,xp,yp);
00122 //           LocalGraph->SetPoint(i,xp,yp);
00123 //         }
00124 //      axeshistogram=LocalGraph->GetHistogram();
00125 //      if(keepscale && axeshistogram)
00126 //         {
00127 //         TAxis* xax=axeshistogram->GetXaxis();
00128 //         if(xax) xax->SetRange(xminbin,xmaxbin);
00129 //         LocalGraph->SetMinimum(ymin);
00130 //         LocalGraph->SetMaximum(ymax);
00131 //         }
00132 //      else
00133 //         {
00134 //          if(axeshistogram)
00135 //              {
00136 //              axeshistogram->ResetBit(TH1::kIsZoomed);
00137 //              Double_t oldmin=0;
00138 //              Double_t oldmax=0;
00139 //              TH1* newhis=NewGraph->GetHistogram();
00140 //              if(newhis)
00141 //                 {
00142 //                     oldmin=newhis->GetMinimum();
00143 //                     oldmax=1.1 * newhis->GetMaximum();
00144 //                 }
00145 //              LocalGraph->SetMinimum(oldmin);
00146 //              LocalGraph->SetMaximum(oldmax);
00147 //              }
00148 //         }
00149 //      } // if(LocalGraph->GetN()>=1)
00150 //   else
00151 //      {
00152 //          // case of graph without points: replace old and draw
00153 //          TGo4QItem::UpdateOnline(fxObj); // overwrite local object in memory list
00154 //          DrawObj(fxDrawPanel);
00155 //      }
00156 
00157 
00158 //   UpdateDrawPad();
00159 //}// if(LocalGraph)
00160 
00161 }
00162 
00163 
00164 
00165 
00166 //----------------------------END OF GO4 SOURCE FILE ---------------------

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