GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4ASImage.cpp
Go to the documentation of this file.
1// $Id$
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{
24 SetConstRatio(kFALSE);
25}
26
31
33{
34 if (!histo) return;
35
36 Int_t numx = histo->GetNbinsX();
37 Int_t numy = histo->GetNbinsY();
38
39 TArrayD arr(numx * numy);
40 for (int x = 1; x <= numx; x++)
41 for (int y = 1; y <= numy; y++)
42 arr[(y - 1) * numx + (x - 1)] = histo->GetBinContent(x, y);
43
44 SetImage(arr, numx);
45 SetName(histo->GetName());
46
47 fdWidth = numx;
48 fdHeight = numy;
49}
50
51void TGo4ASImage::SetDrawData(TH2 *histo, TGo4ViewPanel *panel, TPad *pad)
52{
53 fxPanel = panel;
54 fxPad = pad;
55
56 if (!histo) return;
57
58 fxMinX = histo->GetXaxis()->GetXmin();
59 fxMaxX = histo->GetXaxis()->GetXmax();
60 fxMinY = histo->GetYaxis()->GetXmin();
61 fxMaxY = histo->GetYaxis()->GetXmax();
62}
63
64void TGo4ASImage::SetSelectedRange(double rxmin, double rxmax, double rymin, double rymax)
65{
66 if ((rxmin >= rxmax) && (rymin >= rymax)) {
67 TASImage::UnZoom();
68 return;
69 }
70
71 UInt_t offX = 0;
72 UInt_t offY = 0;
73 UInt_t width = UInt_t(fdWidth);
74 UInt_t height = UInt_t(fdHeight);
75
76 if ((rxmin < rxmax) && (fxMinX < fxMaxX)) {
77 if (rxmin >= fxMinX)
78 offX = UInt_t((rxmin - fxMinX) / (fxMaxX - fxMinX) * fdWidth);
79 if (rxmax <= fxMaxX)
80 width = UInt_t((rxmax - fxMinX) / (fxMaxX - fxMinX) * fdWidth) - offX;
81 }
82
83 if ((rymin < rymax) && (fxMinY < fxMaxY)) {
84 if (rymin >= fxMinY)
85 offY = UInt_t((rymin - fxMinY) / (fxMaxY - fxMinY) * fdHeight);
86 if (rymax <= fxMaxY)
87 height = UInt_t((rymax - fxMinY) / (fxMaxY - fxMinY) * fdHeight) - offY;
88 }
89
90 TASImage::Zoom(offX, offY, width, height);
91}
92
93void TGo4ASImage::Zoom(UInt_t offX, UInt_t offY, UInt_t width, UInt_t height)
94{
95 TASImage::Zoom(offX, offY, width, height);
96
97 double rxmin = fZoomOffX/fdWidth*(fxMaxX-fxMinX)+fxMinX;
98 double rxmax = (fZoomOffX+fZoomWidth)/fdWidth*(fxMaxX-fxMinX)+fxMinX;
99 double rymin = fZoomOffY/fdHeight*(fxMaxY-fxMinY)+fxMinY;
100 double rymax = (fZoomOffY+fZoomHeight)/fdHeight*(fxMaxY-fxMinY)+fxMinY;
101
102 if (fxPanel)
103 fxPanel->PadRangeAxisChanged(fxPad, rxmin, rxmax, rymin, rymax);
104}
105
107{
108 TASImage::UnZoom();
109 if (fxPanel)
110 fxPanel->PadRangeAxisChanged(fxPad,0.,0.,0.,0.);
111}
112
114{
115 if(fPaletteEditor) {
116 fPaletteEditor->CloseWindow();
117 fPaletteEditor = nullptr;
118 }
119}
120
121#endif // asimage disable switch
void SetDrawData(TH2 *histo, TGo4ViewPanel *panel, TPad *pad)
double fxMaxY
Definition TGo4ASImage.h:70
double fdHeight
original width of image (histogram)
Definition TGo4ASImage.h:73
TPad * fxPad
Definition TGo4ASImage.h:65
void UnZoom() override
double fxMinY
Definition TGo4ASImage.h:69
double fxMaxX
Definition TGo4ASImage.h:68
void ClosePaletteEditor()
Use this to close palette editor properly.
TGo4ViewPanel * fxPanel
Definition TGo4ASImage.h:63
virtual ~TGo4ASImage()
void SetSelectedRange(double rxmin, double rxmax, double rymin, double rymax)
void SetHistogramContent(TH2 *histo)
void Zoom(UInt_t offX, UInt_t offY, UInt_t width, UInt_t height) override
double fxMinX
Definition TGo4ASImage.h:67
double fdWidth
Definition TGo4ASImage.h:72