GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ASImage.cpp
Go to the documentation of this file.
1 // $Id: TGo4ASImage.cpp 2763 2020-04-16 13:43:05Z 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 fuer 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 "TGo4ViewPanel.h"
20 
22  TASImage(),
23  fxPanel(0),
24  fxPad(0),
25  fxMinX(0),
26  fxMaxX(1),
27  fxMinY(0),
28  fxMaxY(1),
29  fdWidth(0),
30  fdHeight(0)
31 {
32  SetConstRatio(kFALSE);
33 }
34 
36 {
38 }
39 
41 {
42  if (histo==0) return;
43 
44  Int_t numx = histo->GetNbinsX();
45  Int_t numy = histo->GetNbinsY();
46 
47  TArrayD arr(numx*numy);
48  for (int x=1; x<=numx; x++)
49  for (int y=1; y<=numy; y++)
50  arr[(y-1)*numx + (x-1)] = histo->GetBinContent(x, y);
51 
52  SetImage(arr, numx);
53  SetName(histo->GetName());
54 
55  fdWidth = numx;
56  fdHeight = numy;
57 }
58 
59 void TGo4ASImage::SetDrawData(TH2* histo, TGo4ViewPanel* panel, TPad* pad)
60 {
61  fxPanel = panel;
62  fxPad = pad;
63 
64  if (histo==0) return;
65 
66  fxMinX = histo->GetXaxis()->GetXmin();
67  fxMaxX = histo->GetXaxis()->GetXmax();
68  fxMinY = histo->GetYaxis()->GetXmin();
69  fxMaxY = histo->GetYaxis()->GetXmax();
70 }
71 
72 void TGo4ASImage::SetSelectedRange(double rxmin, double rxmax, double rymin, double rymax)
73 {
74  if ((rxmin>=rxmax) && (rymin>=rymax)) {
75  TASImage::UnZoom();
76  return;
77  }
78 
79  UInt_t offX = 0;
80  UInt_t offY = 0;
81  UInt_t width = UInt_t(fdWidth);
82  UInt_t height = UInt_t(fdHeight);
83 
84  if ((rxmin<rxmax) && (fxMinX<fxMaxX)) {
85  if (rxmin>=fxMinX)
86  offX = UInt_t((rxmin-fxMinX)/(fxMaxX-fxMinX)*fdWidth);
87  if (rxmax<=fxMaxX)
88  width = UInt_t((rxmax-fxMinX)/(fxMaxX-fxMinX)*fdWidth) - offX;
89  }
90 
91  if ((rymin<rymax) && (fxMinY<fxMaxY)) {
92  if (rymin>=fxMinY)
93  offY = UInt_t((rymin-fxMinY)/(fxMaxY-fxMinY)*fdHeight);
94  if (rymax<=fxMaxY)
95  height = UInt_t((rymax-fxMinY)/(fxMaxY-fxMinY)*fdHeight) - offY;
96  }
97 
98  TASImage::Zoom(offX, offY, width, height);
99 }
100 
101 void TGo4ASImage::Zoom(UInt_t offX, UInt_t offY, UInt_t width, UInt_t height)
102 {
103  TASImage::Zoom(offX, offY, width, height);
104 
105  double rxmin = fZoomOffX/fdWidth*(fxMaxX-fxMinX)+fxMinX;
106  double rxmax = (fZoomOffX+fZoomWidth)/fdWidth*(fxMaxX-fxMinX)+fxMinX;
107  double rymin = fZoomOffY/fdHeight*(fxMaxY-fxMinY)+fxMinY;
108  double rymax = (fZoomOffY+fZoomHeight)/fdHeight*(fxMaxY-fxMinY)+fxMinY;
109 
110  if (fxPanel!=0)
111  fxPanel->PadRangeAxisChanged(fxPad, rxmin, rxmax, rymin, rymax);
112 }
113 
115 {
116  TASImage::UnZoom();
117  if (fxPanel!=0)
118  fxPanel->PadRangeAxisChanged(fxPad,0.,0.,0.,0.);
119 }
120 
122 {
123  if(fPaletteEditor!=0) {
124  fPaletteEditor->CloseWindow();
125  fPaletteEditor=0;
126  }
127 }
128 
129 #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:59
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:35
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:72
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:40