Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4ASImage.cpp

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE 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 "TGo4ASImage.h"
00017 
00018 #ifdef __GO4ASI__
00019 
00020 #include "TH2.h"
00021 #include "TGo4Log.h"
00022 #include "TGo4ViewPanel.h"
00023 
00024 TGo4ASImage::TGo4ASImage() :
00025    TASImage(),
00026    fxPanel(0),
00027    fxPad(0),
00028    fxMinX(0),
00029    fxMaxX(1),
00030    fxMinY(0),
00031    fxMaxY(1)
00032 {
00033    SetConstRatio(kFALSE);
00034 }
00035 
00036 TGo4ASImage::~TGo4ASImage()
00037 {
00038    ClosePaletteEditor();
00039 }
00040 
00041 void TGo4ASImage::SetHistogramContent(TH2* histo)
00042 {
00043    if (histo==0) return;
00044 
00045    Int_t arsize = (histo->GetNbinsX()+2) * (histo->GetNbinsY()+2);
00046    Int_t width = histo->GetNbinsX()+2;
00047    TArrayD arr(arsize);
00048    for(int n=0;n<arsize;n++)
00049       arr[n] = histo->GetBinContent(n);
00050 
00051    SetImage(arr,width);
00052    SetName(histo->GetName());
00053 }
00054 
00055 void TGo4ASImage::SetDrawData(TH2* histo, TGo4ViewPanel* panel, TPad* pad)
00056 {
00057    fxPanel = panel;
00058    fxPad = pad;
00059 
00060    if (histo==0) return;
00061 
00062    fxMinX = histo->GetXaxis()->GetXmin();
00063    fxMaxX = histo->GetXaxis()->GetXmax();
00064    fxMinY = histo->GetYaxis()->GetXmin();
00065    fxMaxY = histo->GetYaxis()->GetXmax();
00066 }
00067 
00068 void TGo4ASImage::SetSelectedRange(double rxmin, double rxmax, double rymin, double rymax)
00069 {
00070    if ((rxmin>=rxmax) && (rymin>=rymax)) {
00071       TASImage::UnZoom();
00072       return;
00073    }
00074 
00075    UInt_t offX = 0;
00076    UInt_t offY = 0;
00077    UInt_t width = GetWidth();
00078    UInt_t height = GetHeight();
00079 
00080    if ((rxmin<rxmax) && (fxMinX<fxMaxX)) {
00081       if (rxmin>=fxMinX)
00082         offX = UInt_t((rxmin-fxMinX)/(fxMaxX-fxMinX)*GetWidth());
00083       if (rxmax<=fxMaxX)
00084         width = UInt_t((rxmax-fxMinX)/(fxMaxX-fxMinX)*GetWidth()) - offX;
00085    }
00086 
00087    if ((rymin<rymax) && (fxMinY<fxMaxY)) {
00088       if (rymin>=fxMinY)
00089         offY = UInt_t((rymin-fxMinY)/(fxMaxY-fxMinY)*GetHeight());
00090       if (rymax<=fxMaxY)
00091         height = UInt_t((rymax-fxMinY)/(fxMaxY-fxMinY)*GetHeight()) - offY;
00092    }
00093 
00094    TASImage::Zoom(offX, offY, width, height);
00095 }
00096 
00097 
00098 void TGo4ASImage::Zoom(UInt_t offX, UInt_t offY, UInt_t width, UInt_t height)
00099 {
00100    TASImage::Zoom(offX, offY, width, height);
00101 
00102    double rxmin = 1.*offX/GetWidth()*(fxMaxX-fxMinX)+fxMinX;
00103    double rxmax = 1.*(offX+width)/GetWidth()*(fxMaxX-fxMinX)+fxMinX;
00104    double rymin = 1.*offY/GetHeight()*(fxMaxY-fxMinY)+fxMinY;
00105    double rymax = 1.*(offY+height)/GetHeight()*(fxMaxY-fxMinY)+fxMinY;
00106    if (fxPanel!=0)
00107       fxPanel->PadRangeAxisChanged(fxPad, rxmin, rxmax, rymin, rymax);
00108 }
00109 
00110 void TGo4ASImage::UnZoom()
00111 {
00112    TASImage::UnZoom();
00113    if (fxPanel!=0)
00114       fxPanel->PadRangeAxisChanged(fxPad,0.,0.,0.,0.);
00115 }
00116 
00117 void TGo4ASImage::ClosePaletteEditor()
00118 {
00119    if(fPaletteEditor!=0) {
00120       fPaletteEditor->CloseWindow();
00121       fPaletteEditor=0;
00122    }
00123 }
00124 
00125 #endif // asimage disable switch
00126 
00127 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:20 2008 for Go4-v3.04-1 by  doxygen 1.4.2