Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4ASImage.h"
00015
00016 #ifndef __NOGO4ASI__
00017
00018 #include "TH2.h"
00019 #include "TGo4Log.h"
00020 #include "TGo4ViewPanel.h"
00021
00022 TGo4ASImage::TGo4ASImage() :
00023 TASImage(),
00024 fxPanel(0),
00025 fxPad(0),
00026 fxMinX(0),
00027 fxMaxX(1),
00028 fxMinY(0),
00029 fxMaxY(1),
00030 fdWidth(0),
00031 fdHeight(0)
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 numx = histo->GetNbinsX();
00046 Int_t numy = histo->GetNbinsY();
00047
00048 TArrayD arr(numx*numy);
00049 for (int x=1; x<=numx; x++)
00050 for (int y=1; y<=numy; y++)
00051 arr[(y-1)*numx + (x-1)] = histo->GetBinContent(x, y);
00052
00053 SetImage(arr, numx);
00054 SetName(histo->GetName());
00055
00056 fdWidth = numx;
00057 fdHeight = numy;
00058 }
00059
00060 void TGo4ASImage::SetDrawData(TH2* histo, TGo4ViewPanel* panel, TPad* pad)
00061 {
00062 fxPanel = panel;
00063 fxPad = pad;
00064
00065 if (histo==0) return;
00066
00067 fxMinX = histo->GetXaxis()->GetXmin();
00068 fxMaxX = histo->GetXaxis()->GetXmax();
00069 fxMinY = histo->GetYaxis()->GetXmin();
00070 fxMaxY = histo->GetYaxis()->GetXmax();
00071 }
00072
00073 void TGo4ASImage::SetSelectedRange(double rxmin, double rxmax, double rymin, double rymax)
00074 {
00075 if ((rxmin>=rxmax) && (rymin>=rymax)) {
00076 TASImage::UnZoom();
00077 return;
00078 }
00079
00080 UInt_t offX = 0;
00081 UInt_t offY = 0;
00082 UInt_t width = UInt_t(fdWidth);
00083 UInt_t height = UInt_t(fdHeight);
00084
00085 if ((rxmin<rxmax) && (fxMinX<fxMaxX)) {
00086 if (rxmin>=fxMinX)
00087 offX = UInt_t((rxmin-fxMinX)/(fxMaxX-fxMinX)*fdWidth);
00088 if (rxmax<=fxMaxX)
00089 width = UInt_t((rxmax-fxMinX)/(fxMaxX-fxMinX)*fdWidth) - offX;
00090 }
00091
00092 if ((rymin<rymax) && (fxMinY<fxMaxY)) {
00093 if (rymin>=fxMinY)
00094 offY = UInt_t((rymin-fxMinY)/(fxMaxY-fxMinY)*fdHeight);
00095 if (rymax<=fxMaxY)
00096 height = UInt_t((rymax-fxMinY)/(fxMaxY-fxMinY)*fdHeight) - offY;
00097 }
00098
00099 TASImage::Zoom(offX, offY, width, height);
00100 }
00101
00102 void TGo4ASImage::Zoom(UInt_t offX, UInt_t offY, UInt_t width, UInt_t height)
00103 {
00104 TASImage::Zoom(offX, offY, width, height);
00105
00106 double rxmin = fZoomOffX/fdWidth*(fxMaxX-fxMinX)+fxMinX;
00107 double rxmax = (fZoomOffX+fZoomWidth)/fdWidth*(fxMaxX-fxMinX)+fxMinX;
00108 double rymin = fZoomOffY/fdHeight*(fxMaxY-fxMinY)+fxMinY;
00109 double rymax = (fZoomOffY+fZoomHeight)/fdHeight*(fxMaxY-fxMinY)+fxMinY;
00110
00111 if (fxPanel!=0)
00112 fxPanel->PadRangeAxisChanged(fxPad, rxmin, rxmax, rymin, rymax);
00113 }
00114
00115 void TGo4ASImage::UnZoom()
00116 {
00117 TASImage::UnZoom();
00118 if (fxPanel!=0)
00119 fxPanel->PadRangeAxisChanged(fxPad,0.,0.,0.,0.);
00120 }
00121
00122 void TGo4ASImage::ClosePaletteEditor()
00123 {
00124 if(fPaletteEditor!=0) {
00125 fPaletteEditor->CloseWindow();
00126 fPaletteEditor=0;
00127 }
00128 }
00129
00130 #endif // asimage disable switch