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

/Go4GUI/TGo4ASImage.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 #ifdef __GO4USEASIMAGE__
00017 #include "TGo4ASImage.h"
00018 #include "TH2.h"
00019 #include "Go4Log/TGo4Log.h"
00020 
00021 
00022 TGo4ASImage::TGo4ASImage (TH2* histogram)
00023 : TASImage(), fxHistogram(histogram)
00024 {
00025 TArrayD* arr=0;
00026 Int_t width=0;
00027 Int_t arsize=0;
00028 if(histogram)
00029    {
00030       TString iname=histogram->GetName();
00031       if(histogram->InheritsFrom("TH2I"))
00032          {
00033             TH2I* hi=dynamic_cast<TH2I*>(histogram);
00034             arsize=hi->GetSize();
00035             width=hi->GetNbinsX()+2;
00036             arr=new TArrayD(arsize);
00037             for(Int_t t=0;t<arsize;++t)
00038              {
00039                arr->AddAt(hi->At(t),t);
00040              }
00041          }
00042       else if(histogram->InheritsFrom("TH2F"))
00043          {
00044             TH2F* hf=dynamic_cast<TH2F*>(histogram);
00045             arsize=hf->GetSize();
00046             width=hf->GetNbinsX()+2;
00047             arr=new TArrayD(arsize);
00048             for(Int_t t=0;t<arsize;++t)
00049              {
00050                arr->AddAt(hf->At(t),t);
00051              }
00052          }
00053       else if(histogram->InheritsFrom("TH2D"))
00054          {
00055             TH2D* hd=dynamic_cast<TH2D*>(histogram);
00056             arsize=hd->GetSize();
00057             width=hd->GetNbinsX()+2;
00058             arr=new TArrayD(arsize);
00059             for(Int_t t=0;t<arsize;++t)
00060              {
00061                arr->AddAt(hd->At(t),t);
00062              }
00063          }
00064       else if(histogram->InheritsFrom("TH2S"))
00065          {
00066             TH2S* hs=dynamic_cast<TH2S*>(histogram);
00067             arsize=hs->GetSize();
00068             width=hs->GetNbinsX()+2;
00069             arr=new TArrayD(arsize);
00070             for(Int_t t=0;t<arsize;++t)
00071              {
00072                arr->AddAt(hs->At(t),t);
00073              }
00074          }
00075      else if(histogram->InheritsFrom("TH2C"))
00076          {
00077             TH2C* hc=dynamic_cast<TH2C*>(histogram);
00078             arsize=hc->GetSize();
00079             width=hc->GetNbinsX()+2;
00080             arr=new TArrayD(arsize);
00081             for(Int_t t=0;t<arsize;++t)
00082              {
00083                arr->AddAt(hc->At(t),t);
00084              }
00085          }
00086      else
00087        {
00088          // unknown type: default dummy
00089          arr=new TArrayD(100);
00090          width=10;
00091          TGo4Log::Warn("TGo4ASImage could not convert histogram %s",
00092                histogram->GetName());
00093        }
00094    SetImage(*arr,width);
00095    SetName(histogram->GetName());
00096    SetZoom(histogram);
00097    SetConstRatio(kFALSE);
00098    delete arr;
00099    }
00100 
00101 
00102 }
00103 
00104 TGo4ASImage::~TGo4ASImage()
00105 {
00106 ClosePaletteEditor();
00107 }
00108 
00109 
00110 void TGo4ASImage::SetHistogramRanges(TH2* histo)
00111 {
00112 if(histo==0) return;
00113 Int_t minx=fZoomOffX; // minimum bin x
00114 Int_t maxx=fZoomOffX+fZoomWidth; // maximum bin x
00115 Int_t miny=fZoomOffY; // minimum bin y
00116 Int_t maxy=fZoomOffY+fZoomHeight; // maximum bin y
00117 histo->GetXaxis()->SetRange(minx,maxx);
00118 histo->GetYaxis()->SetRange(miny,maxy);
00119 
00120 }
00121 
00122 void TGo4ASImage::SetZoom(TH2* histogram)
00123 {
00124 if(histogram==0) return;
00125 UInt_t minx=histogram->GetXaxis()->GetFirst();
00126 UInt_t maxx=histogram->GetXaxis()->GetLast();
00127 UInt_t miny=histogram->GetYaxis()->GetFirst();
00128 UInt_t maxy=histogram->GetYaxis()->GetLast();
00129 UInt_t xo=minx; // minimum bin x
00130 UInt_t yo=miny; // minimum bin y
00131 UInt_t w=maxx-minx; // maximum bin x - minbin x
00132 UInt_t h=maxy-miny; // maximum bin y - minbin y
00133 Zoom(xo,yo,w,h);
00134 }
00135 
00136 void TGo4ASImage::ClosePaletteEditor()
00137 {
00138 if(fPaletteEditor)
00139    {
00140       fPaletteEditor->CloseWindow();
00141       fPaletteEditor=0;
00142    }
00143 
00144 }
00145 
00146 #endif // asimage disable switch
00147 
00148 //----------------------------END OF GO4 SOURCE FILE ---------------------

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