11 #include "KVKeyHandler.h"
14 #include "KVHistoManipulator.h"
37 fHasDisabledClasses =
false;
38 fDisabledClasses =
"";
66 fHasDisabledClasses =
false;
67 fDisabledClasses =
"";
84 fHasDisabledClasses =
false;
85 fHasDisabledObject =
false;
86 fDisabledClasses =
"";
125 void KVCanvas::RunAutoExec()
131 ((
TPad*)gPad)->AutoExec();
141 fHasDisabledClasses =
true;
142 fDisabledClasses += className;
152 fHasDisabledClasses =
false;
153 fDisabledClasses =
"";
162 fHasDisabledObject =
true;
163 fDisabledObjects.
Clear();
173 fHasDisabledObject =
true;
192 const Int_t kTMAX = 256;
193 static char atext[kTMAX];
205 if (
event == kKeyPress)
206 snprintf(atext, kTMAX,
"%c", (
char) px);
208 snprintf(atext, kTMAX,
"%d,%d", px, py);
227 if (fFreezed)
return;
255 pad =
Pick(px, py, prevSelObj);
269 TH2* TheHisto = (
TH2*) FindHisto();
285 Double_t ddX = (X1 + X0) * 0.5 - px;
287 if (distX >= 0.5)
return;
295 Double_t ddY = (Y1 + Y0) * 0.5 - py;
297 if (distY >= 0.5)
return;
299 if ((distX <=
size) && (distY <=
size))
return;
300 dX =
TMath::Nint(ddX * (0.05 + 0.05 * fVenerMode));
301 dY =
TMath::Nint(ddY * (0.05 + 0.05 * fVenerMode));
308 if ((X0 - dX > 0) && (X1 - dX < NbinsX)) {
312 if ((Y0 - dY > 0) && (Y1 - dY < NbinsY)) {
350 pad =
Pick(px, py, prevSelObj);
439 ZoomSelected((
TH2*)FindHisto());
451 pad =
Pick(px, py, prevSelObj);
466 theXaxis = ((
TH2*)FindHisto())->GetXaxis();
467 theYaxis = ((
TH2*)FindHisto())->GetYaxis();
470 Xf1 = Xfirst0 = theXaxis->
GetFirst();
471 Xl1 = Xlast0 = theXaxis->
GetLast();
472 Yf1 = Yfirst0 = theYaxis->
GetFirst();
473 Yl1 = Ylast0 = theYaxis->
GetLast();
478 NdisXbins = Xlast0 - Xfirst0 + 1;
479 NdisYbins = Ylast0 - Yfirst0 + 1;
480 XbinPixel = pixelWidthX / (1.0 * NdisXbins);
481 YbinPixel = pixelWidthY / (1.0 * NdisYbins);
494 while ((tc = (
TCanvas*)next()))
509 Int_t dXbins = dX / XbinPixel;
510 Int_t dYbins = dY / YbinPixel;
512 Int_t newXfirst = Xfirst0 - dXbins;
516 newXlast = NdisXbins;
519 newXlast = Xlast0 - dXbins;
520 if (newXlast > NXbins) {
522 newXfirst = newXlast - NdisXbins + 1;
525 if (newXfirst != Xf1) {
531 Int_t newYfirst = Yfirst0 - dYbins;
535 newYlast = NdisYbins;
538 newYlast = Ylast0 - dYbins;
539 if (newYlast > NYbins) {
541 newYfirst = newYlast - NdisYbins + 1;
544 if (newYfirst != Yf1) {
573 pad =
Pick(px, py, prevSelObj);
615 pad =
Pick(px, py, prevSelObj);
630 pad =
Pick(px, py, prevSelObj);
633 sign = (
event ==
kWheelUp ? 1 : -1);
659 void KVCanvas::ZoomSelected(
TH2* TheHisto)
661 if (!TheHisto)
return;
666 if ((ratio2 - ratio1 > 0.05)) ax->
SetRangeUser(xmin, xmax);
672 if ((ratio2 - ratio1 > 0.05)) ax->
SetRangeUser(ymin, ymax);
674 xmax = xmin = ymax = ymin = 0.;
688 TH1* TheHisto = (
TH1*) FindHisto();
704 if (X0tmp >= X1tmp) X0tmp = X1tmp - 1;
705 if (
Sign > 0) dX = (
Int_t)(X0tmp + (X1tmp - X0tmp) * 0.5 - ax->
FindBin(px));
706 if ((X0tmp - dX) < 0) ax->
SetRange(0, X1tmp - X0tmp);
708 else ax->
SetRange(X0tmp - dX, X1tmp - dX);
729 TH2* TheHisto = (
TH2*) FindHisto();
747 if (X0tmp >= X1tmp) X0tmp = X1tmp - 1;
748 if (
Sign > 0) dX = (
Int_t)(X0tmp + (X1tmp - X0tmp) * 0.5 - ax->
FindBin(ppx));
749 if ((X0tmp - dX) < 0) ax->
SetRange(0, X1tmp - X0tmp);
751 else ax->
SetRange(X0tmp - dX, X1tmp - dX);
761 if (Y0tmp >= Y1tmp) Y0tmp = Y1tmp - 1;
762 if (
Sign > 0) dY = (
Int_t)(Y0tmp + (Y1tmp - Y0tmp) * 0.5 - ax->
FindBin(ppy));
763 if ((Y0tmp - dY) < 0) ax->
SetRange(0, Y1tmp - Y0tmp);
765 else ax->
SetRange(Y0tmp - dY, Y1tmp - dY);
787 if (!fEnabledShortcuts)
return kTRUE;
887 while ((obj = next())) {
889 ((
TPad*)obj)->SetGrid(0, 0);
895 while ((obj = next())) {
897 ((
TPad*)obj)->SetGrid();
941 if (ExpandFunctionRange()) {
965 if (FindHisto())
option +=
"same";
974 fAgeOfEmpire = !fAgeOfEmpire;
980 if (!fPPressed && !fJPressed) {
1027 while ((obj = it())) {
1028 ((
TF1*)obj)->SetNpx(((
TF1*)obj)->GetNpx() + 50);
1049 while ((obj = it()))((
TF1*)obj)->SetNpx(((
TF1*)obj)->GetNpx() - 50);
1072 void KVCanvas::MoveAxis(
TAxis* ax,
Int_t sign)
1081 if ((last + 2 < nBins) && (sign > 0)) {
1086 if ((
first - 2 >= 0) && (sign < 0)) {
1097 void KVCanvas::AddShortcutsInfo(
const char* cut,
const char* desc)
1108 std::cout << std::endl << std::endl;
1110 TIter it(&fShortCuts);
1111 while ((info = (
TNamed*)it())) {
1114 std::cout << std::endl;
1130 void KVCanvas::InitInfos()
1132 fEnabledShortcuts = 1;
1135 AddShortcutsInfo(
"<ctrl> c",
"copy the object under cursor");
1136 AddShortcutsInfo(
"<ctrl> d",
"undraw the object under cursor (object not deleted)");
1137 AddShortcutsInfo(
"<ctrl> e",
"show editor");
1138 AddShortcutsInfo(
"<ctrl> f",
"start fit panel (TH1)");
1139 AddShortcutsInfo(
"<ctrl> g",
"set/unset grid on X and Y axes");
1140 AddShortcutsInfo(
"<ctrl> i",
"show shortcuts infos");
1141 AddShortcutsInfo(
"<ctrl> j x",
"draw projection X (TH2)");
1142 AddShortcutsInfo(
"<ctrl> j y",
"draw projection Y (TH2)");
1143 AddShortcutsInfo(
"<ctrl> l",
"set/unset log scale on Y axis (TH1) or Z axis (TH2)");
1144 AddShortcutsInfo(
"<ctrl> n",
"normalize histogram");
1145 AddShortcutsInfo(
"<ctrl> p x",
"draw profile X (TH2)");
1146 AddShortcutsInfo(
"<ctrl> p y",
"draw profile Y (TH2)");
1147 AddShortcutsInfo(
"<ctrl> s",
"save canvas as");
1148 AddShortcutsInfo(
"<ctrl> u",
"update canvas");
1149 AddShortcutsInfo(
"<ctrl> v",
"paste");
1150 AddShortcutsInfo(
"<ctrl> w",
"set/unset 'Age Of Empire' mode (TH2)");
1151 AddShortcutsInfo(
"<ctrl> x",
"cut the object under cursor");
1152 AddShortcutsInfo(
"<ctrl> +",
"set minimum +1 (TH2)");
1153 AddShortcutsInfo(
"<ctrl> -",
"set minimum -1 (TH2)");
1154 AddShortcutsInfo(
"F9",
"set/unset log scale on X axis");
1155 AddShortcutsInfo(
"F10",
"set/unset log scale on Y axis");
1156 AddShortcutsInfo(
"F11",
"set/unset log scale on Z axis");
1157 AddShortcutsInfo(
"F12",
"unzoom");
1158 AddShortcutsInfo(
"Arrows",
"move on histogram or axis");
1165 void KVCanvas::ProfileX(
TH2* hh)
1169 hh->
ProfileX(
"_pfx", 1, -1,
"i,d,same");
1179 void KVCanvas::ProfileY(
TH2* hh)
1199 void KVCanvas::SaveCanvasAs()
1202 if (strcmp(
"", fSavedAs)) {
1206 file.ReplaceAll(
"/",
"");
1208 Form(
"File name '%s' already exists, OK to owerwrite it?",
file.Data()),
1209 kMBIconExclamation, kMBOk | kMBCancel, &ret_val);
1211 if (ret_val & kMBOk) {
1217 const char* SaveAsTypes[] = {
1219 "PostScript",
"*.ps",
1220 "Encapsulated PostScript",
"*.eps",
1224 "ROOT macros",
"*.C",
1225 "ROOT files",
"*.root",
1238 static Int_t typeidx = 0;
1260 TH1* KVCanvas::FindHisto()
1264 while ((hh = (
TObject*)it())) {
1274 Bool_t KVCanvas::ExpandFunctionRange()
1277 TH1* hh = FindHisto();
1281 while ((obj = it())) {
1294 fEnabledShortcuts =
value;
1301 void KVCanvas::ProjectionX(
TH2* hh)
1305 while (
gROOT->FindObject(pname.
Data())) {
1322 for (
int i = 0; i < px->
GetNbinsX(); i++) {
1341 void KVCanvas::ProjectionY(
TH2* hh)
1346 while (
gROOT->FindObject(pname.
Data())) {
1363 for (
int i = 0; i < py->
GetNbinsX(); i++) {
size_t size(const MatrixT &matrix)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint percent
char * Form(const char *fmt,...)
char * StrDup(const char *str)
R__EXTERN TSystem * gSystem
TCanvas with mouse-controlled dynamic zoom and pan & scan.
void ShowShortcutsInfos()
friend class KVKeyHandler
void DisableObject(TObject *obj)
void HandleInput(EEventType event, Int_t px, Int_t py) override
void DisableClass(const char *className)
void ResetDisabledObject()
void SetEnabledShortcuts(Int_t value=1)
void SetVenerMode(Int_t value=1)
void ResetDisabledClass()
TH2 * PermuteAxis(TH2 *hh)
TGraphErrors * MakeGraphFrom(TProfile *pf, Bool_t Error=kTRUE)
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual Int_t FindBin(const char *label)
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
virtual void SetRange(Int_t first=0, Int_t last=0)
virtual void SetStatusText(const char *text=nullptr, Int_t partidx=0)
virtual void ShowEditor(Bool_t show=kTRUE)
void EnterLeave(TPad *prevSelPad, TObject *prevSelObj)
TCanvasImp * GetCanvasImp() const override
Int_t GetEventY() const override
virtual TPad * Pick(Int_t px, Int_t py, TObject *prevSelObj)
virtual void ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject *selected)
Int_t GetEventX() const override
TVirtualPad * cd(Int_t subpadnumber=0) override
TVirtualPad * GetSelectedPad() const override
TContextMenu * fContextMenu
void FeedbackMode(Bool_t set)
Bool_t Contains(const char *name) const
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
void SetName(const char *name="") override
void Draw(Option_t *chopt="") override
void SetTitle(const char *title="") override
virtual Double_t GetBinCenter(Int_t bin) const
virtual Int_t GetNbinsX() const
TList * GetListOfFunctions() const
virtual Int_t GetMaximumBin() const
virtual Double_t GetBinContent(Int_t bin) const
TH1D * ProjectionY(const char *name="_py", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const
TProfile * ProfileX(const char *name="_pfx", Int_t firstybin=1, Int_t lastybin=-1, Option_t *option="") const
TProfile * ProfileY(const char *name="_pfy", Int_t firstxbin=1, Int_t lastxbin=-1, Option_t *option="") const
TH1D * ProjectionX(const char *name="_px", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const
void Clear(Option_t *option="") override
void AddLast(TObject *obj) override
TObject * Remove(const TObjLinkPtr_t &lnk)
const char * GetName() const override
const char * GetTitle() const override
virtual const char * GetName() const
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual TObject * Clone(const char *newname="") const
virtual const char * ClassName() const
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual char * GetObjectInfo(Int_t px, Int_t py) const
virtual void Delete(Option_t *option="")
virtual Bool_t InheritsFrom(const char *classname) const
virtual const char * GetTitle() const
virtual void Draw(Option_t *option="")
Double_t AbsPixeltoY(Int_t py) override
Double_t GetUymax() const override
void SetGrid(Int_t valuex=1, Int_t valuey=1) override
Double_t GetUxmax() const override
Bool_t GetGridx() const override
void SetLogz(Int_t value=1) override
const char * GetTitle() const override
Double_t GetUymin() const override
TList * GetListOfPrimitives() const override
Double_t AbsPixeltoX(Int_t px) override
void Modified(Bool_t flag=1) override
void SetLogy(Int_t value=1) override
Double_t GetUxmin() const override
Bool_t GetGridy() const override
Int_t YtoAbsPixel(Double_t y) const override
void SaveAs(const char *filename="", Option_t *option="") const override
TObject * FindObject(const char *name) const override
TVirtualPad * cd(Int_t subpadnumber=0) override
void SetLogx(Int_t value=1) override
const char * GetName() const override
Int_t XtoAbsPixel(Double_t x) const override
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual const char * DirName(const char *pathname)
virtual Bool_t ChangeDirectory(const char *path)
virtual const char * WorkingDirectory()
Double_t Min(Double_t a, Double_t b)
Double_t Sign(Double_t a, Double_t b)
Double_t Max(Double_t a, Double_t b)