GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ASImage.cpp
Go to the documentation of this file.
1 // $Id: TGo4ASImage.cpp 579 2010-02-17 09:57:34Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4ASImage.h"
15 
16 #ifndef __NOGO4ASI__
17 
18 #include "TH2.h"
19 #include "TGo4Log.h"
20 #include "TGo4ViewPanel.h"
21 
23  TASImage(),
24  fxPanel(0),
25  fxPad(0),
26  fxMinX(0),
27  fxMaxX(1),
28  fxMinY(0),
29  fxMaxY(1),
30  fdWidth(0),
31  fdHeight(0)
32 {
33  SetConstRatio(kFALSE);
34 }
35 
37 {
39 }
40 
42 {
43  if (histo==0) return;
44 
45  Int_t numx = histo->GetNbinsX();
46  Int_t numy = histo->GetNbinsY();
47 
48  TArrayD arr(numx*numy);
49  for (int x=1; x<=numx; x++)
50  for (int y=1; y<=numy; y++)
51  arr[(y-1)*numx + (x-1)] = histo->GetBinContent(x, y);
52 
53  SetImage(arr, numx);
54  SetName(histo->GetName());
55 
56  fdWidth = numx;
57  fdHeight = numy;
58 }
59 
60 void TGo4ASImage::SetDrawData(TH2* histo, TGo4ViewPanel* panel, TPad* pad)
61 {
62  fxPanel = panel;
63  fxPad = pad;
64 
65  if (histo==0) return;
66 
67  fxMinX = histo->GetXaxis()->GetXmin();
68  fxMaxX = histo->GetXaxis()->GetXmax();
69  fxMinY = histo->GetYaxis()->GetXmin();
70  fxMaxY = histo->GetYaxis()->GetXmax();
71 }
72 
73 void TGo4ASImage::SetSelectedRange(double rxmin, double rxmax, double rymin, double rymax)
74 {
75  if ((rxmin>=rxmax) && (rymin>=rymax)) {
76  TASImage::UnZoom();
77  return;
78  }
79 
80  UInt_t offX = 0;
81  UInt_t offY = 0;
82  UInt_t width = UInt_t(fdWidth);
83  UInt_t height = UInt_t(fdHeight);
84 
85  if ((rxmin<rxmax) && (fxMinX<fxMaxX)) {
86  if (rxmin>=fxMinX)
87  offX = UInt_t((rxmin-fxMinX)/(fxMaxX-fxMinX)*fdWidth);
88  if (rxmax<=fxMaxX)
89  width = UInt_t((rxmax-fxMinX)/(fxMaxX-fxMinX)*fdWidth) - offX;
90  }
91 
92  if ((rymin<rymax) && (fxMinY<fxMaxY)) {
93  if (rymin>=fxMinY)
94  offY = UInt_t((rymin-fxMinY)/(fxMaxY-fxMinY)*fdHeight);
95  if (rymax<=fxMaxY)
96  height = UInt_t((rymax-fxMinY)/(fxMaxY-fxMinY)*fdHeight) - offY;
97  }
98 
99  TASImage::Zoom(offX, offY, width, height);
100 }
101 
102 void TGo4ASImage::Zoom(UInt_t offX, UInt_t offY, UInt_t width, UInt_t height)
103 {
104  TASImage::Zoom(offX, offY, width, height);
105 
106  double rxmin = fZoomOffX/fdWidth*(fxMaxX-fxMinX)+fxMinX;
107  double rxmax = (fZoomOffX+fZoomWidth)/fdWidth*(fxMaxX-fxMinX)+fxMinX;
108  double rymin = fZoomOffY/fdHeight*(fxMaxY-fxMinY)+fxMinY;
109  double rymax = (fZoomOffY+fZoomHeight)/fdHeight*(fxMaxY-fxMinY)+fxMinY;
110 
111  if (fxPanel!=0)
112  fxPanel->PadRangeAxisChanged(fxPad, rxmin, rxmax, rymin, rymax);
113 }
114 
116 {
117  TASImage::UnZoom();
118  if (fxPanel!=0)
119  fxPanel->PadRangeAxisChanged(fxPad,0.,0.,0.,0.);
120 }
121 
123 {
124  if(fPaletteEditor!=0) {
125  fPaletteEditor->CloseWindow();
126  fPaletteEditor=0;
127  }
128 }
129 
130 #endif // asimage disable switch
TPad * fxPad
Definition: TGo4ASImage.h:65
double fdWidth
Definition: TGo4ASImage.h:72
void SetDrawData(TH2 *histo, TGo4ViewPanel *panel, TPad *pad)
Definition: TGo4ASImage.cpp:60
void ClosePaletteEditor()
double fxMaxY
Definition: TGo4ASImage.h:70
double fxMinX
Definition: TGo4ASImage.h:67
virtual void UnZoom()
virtual void PadRangeAxisChanged(TPad *pad)
double fdHeight
original width of image (histogram)
Definition: TGo4ASImage.h:73
virtual ~TGo4ASImage()
Definition: TGo4ASImage.cpp:36
virtual void Zoom(UInt_t offX, UInt_t offY, UInt_t width, UInt_t height)
void SetSelectedRange(double rxmin, double rxmax, double rymin, double rymax)
Definition: TGo4ASImage.cpp:73
double fxMaxX
Definition: TGo4ASImage.h:68
double fxMinY
Definition: TGo4ASImage.h:69
TGo4ViewPanel * fxPanel
Definition: TGo4ASImage.h:63
void SetHistogramContent(TH2 *histo)
Definition: TGo4ASImage.cpp:41