00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4QGraphItem.h"
00017
00018 #include <iostream.h>
00019
00020 #include "TPad.h"
00021 #include "TGraph.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 TGo4QGraphItem::TGo4QGraphItem( QListViewItem* parent, const QString & text, const QString & text1, const QString & text2)
00032 :TGo4QTHItem (parent, "tgraph.png", text, text1, text2)
00033 {
00034 }
00035
00036 TGo4QGraphItem::TGo4QGraphItem( QListView* parent, const QString & text, const QString & text1, const QString & text2)
00037 :TGo4QTHItem (parent, "tgraph.png", text, text1, text2)
00038 {
00039 }
00040
00041 TGo4QGraphItem::~TGo4QGraphItem(){}
00042
00043 void TGo4QGraphItem::DrawObj(TGo4PreviewPanel *viewpanel, TPad* currentpad)
00044 {
00045 if(!AssignDrawPanel(viewpanel, currentpad)) return;
00046 TGraph* Gr=dynamic_cast<TGraph *> (GetWorkObject());
00047 if(Gr!=0 && Gr->GetN()>=1)
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)
00055 {
00056 browserslots->AddObject(Gr,fxDrawPanel->GetQCanvas(),fxDrawPad);
00057 realname=browserslots->GetAddedItemName();
00058
00059
00060
00061 fxDrawPad->cd();
00062 TGo4QItem *memitem = (TGo4QItem*) browser->ListViewLocal->findItem(realname,0);
00063 if (memitem!=0)
00064 {
00065 memitem->DrawObj(fxDrawPanel,fxDrawPad);
00066 }
00067 }
00068 }
00069 else
00070 {
00071 TPad* padsav=fxDrawPanel->GetActivePad();
00072 fxDrawPanel->SetActivePad(fxDrawPad);
00073 fxDrawPanel->ClearPad();
00074 Gr->Draw("AP");
00075 fxDrawPanel->UpdatePad(fxDrawPad, Gr->GetHistogram(),false);
00076 fxDrawPanel->SetActivePad(padsav);
00077 }
00078 }
00079 }
00080
00081 void TGo4QGraphItem::UpdateOnline(TObject *fxObj)
00082 {
00083 bool keepscale=IsKeepScale();
00084 TGraph* LocalGraph=dynamic_cast <TGraph*>(GetWorkObject());
00085 TGraph* NewGraph=dynamic_cast <TGraph*>(fxObj);
00086 if(LocalGraph )
00087 {
00088 if(LocalGraph->GetN()>=1)
00089 {
00090 TH1* axeshistogram=LocalGraph->GetHistogram();
00091 Int_t xminbin=0;
00092 Int_t xmaxbin=0;
00093 Double_t ymin=0;
00094 Double_t ymax=0;
00095 if(keepscale && axeshistogram)
00096 {
00097 xminbin=axeshistogram->GetXaxis()->GetFirst();
00098 xmaxbin=axeshistogram->GetXaxis()->GetLast();
00099 ymin=axeshistogram->GetMinimum();
00100 ymax=axeshistogram->GetMaximum();
00101 }
00102
00103 LocalGraph->Set(0);
00104
00105 Int_t pn=NewGraph->GetN();
00106 Double_t xp=0;
00107 Double_t yp=0;
00108 for(Int_t i=0; i<pn; ++i)
00109 {
00110 NewGraph->GetPoint(i,xp,yp);
00111 LocalGraph->SetPoint(i,xp,yp);
00112 }
00113 axeshistogram=LocalGraph->GetHistogram();
00114 if(keepscale && axeshistogram)
00115 {
00116 TAxis* xax=axeshistogram->GetXaxis();
00117 if(xax) xax->SetRange(xminbin,xmaxbin);
00118 LocalGraph->SetMinimum(ymin);
00119 LocalGraph->SetMaximum(ymax);
00120 }
00121 else
00122 {
00123 if(axeshistogram)
00124 {
00125 axeshistogram->ResetBit(TH1::kIsZoomed);
00126 Double_t oldmin=0;
00127 Double_t oldmax=0;
00128 TH1* newhis=NewGraph->GetHistogram();
00129 if(newhis)
00130 {
00131 oldmin=newhis->GetMinimum();
00132 oldmax=1.1 * newhis->GetMaximum();
00133 }
00134 LocalGraph->SetMinimum(oldmin);
00135 LocalGraph->SetMaximum(oldmax);
00136 }
00137 }
00138 }
00139 else
00140 {
00141
00142 TGo4QItem::UpdateOnline(fxObj);
00143 DrawObj(fxDrawPanel);
00144 }
00145 UpdateDrawPad();
00146 }
00147
00148 }
00149
00150