Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPaletteAxis.cxx
Go to the documentation of this file.
1// @(#)root/histpainter:$Id$
2// Author: Rene Brun 15/11/2002
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TROOT.h"
13#include "TPaletteAxis.h"
14#include "TVirtualPad.h"
15#include "TStyle.h"
16#include "TMath.h"
17#include "TView.h"
18#include "TH1.h"
19#include "TGaxis.h"
20#include "TLatex.h"
21
22#include <cstdio>
23#include <iostream>
24#include <memory>
25
26
27
28////////////////////////////////////////////////////////////////////////////////
29
30/*! \class TPaletteAxis
31 \ingroup Histpainter
32 \brief The palette painting class.
33
34A `TPaletteAxis` object is used to display the color palette when
35drawing 2-d histograms.
36
37The `TPaletteAxis` is automatically created drawn when drawing a 2-D
38histogram when the option "Z" is specified.
39
40A `TPaletteAxis` object is added to the histogram list of functions and
41can be retrieved doing:
42
43 TPaletteAxis *palette = (TPaletteAxis*)h->GetListOfFunctions()->FindObject("palette");
44
45then the pointer `palette` can be used to change the palette attributes.
46
47Because the palette is created at painting time only, one must issue a:
48
49 gPad->Update();
50
51before retrieving the palette pointer in order to create the palette. The following
52macro gives an example.
53
54Begin_Macro(source)
55{
56 auto h2 = new TH2F("h2","Example of a resized palette ",40,-4,4,40,-20,20);
57 Float_t px, py;
58 for (Int_t i = 0; i < 25000; i++) {
59 gRandom->Rannor(px,py);
60 h2->Fill(px,5*py);
61 }
62 gStyle->SetPalette(1);
63 h2->Draw("COLZ");
64 gPad->Update();
65 auto palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette");
66 palette->SetY2NDC(0.7);
67}
68End_Macro
69
70`TPaletteAxis` inherits from `TBox` and `TPave`. The methods
71allowing to specify the palette position are inherited from these two classes.
72
73The palette can be interactively moved and resized. The context menu
74can be used to set the axis attributes.
75
76It is possible to select a range on the axis to set the min/max in z
77
78As default labels and ticks are drawn by `TGAxis` at equidistant (lin or log)
79points as controlled by SetNdivisions.
80If option "CJUST" is given labels and ticks are justified at the
81color boundaries defined by the contour levels.
82In this case no optimization can be done. It is responsibility of the
83user to adjust minimum, maximum of the histogram and/or the contour levels
84to get a reasonable look of the plot.
85Only overlap of the labels is avoided if too many contour levels are used.
86
87This option is especially useful with user defined contours.
88An example is shown here:
89
90Begin_Macro(source)
91{
92 gStyle->SetOptStat(0);
93 auto c = new TCanvas("c","exa_CJUST",300,10,400,400);
94 auto hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
95 // Fill histograms randomly
96 TRandom3 randomNum;
97 Float_t px, py;
98 for (Int_t i = 0; i < 25000; i++) {
99 randomNum.Rannor(px,py);
100 hpxpy->Fill(px,py);
101 }
102 hpxpy->SetMaximum(200);
103 Double_t zcontours[5] = {0, 20, 40, 80, 120};
104 hpxpy->SetContour(5, zcontours);
105 hpxpy->GetZaxis()->SetTickSize(0.01);
106 hpxpy->GetZaxis()->SetLabelOffset(0.01);
107 gPad->SetRightMargin(0.13);
108 hpxpy->SetTitle("User contours, CJUST");
109 hpxpy->Draw("COL Z CJUST");
110}
111End_Macro
112*/
113
114
115////////////////////////////////////////////////////////////////////////////////
116/// Palette default constructor.
117
119{
120 fH = nullptr;
121 fLog = 0;
122 SetName("");
123}
124
125
126////////////////////////////////////////////////////////////////////////////////
127/// Palette normal constructor.
128
130 : TPave(x1, y1, x2, y2)
131{
132 fH = h;
133 fLog = 0;
134 if (!fH) return;
135 SetName("palette");
136 TAxis *zaxis = fH->GetZaxis();
138 if (gPad->GetView()) SetBit(kHasView);
139}
140
141
142////////////////////////////////////////////////////////////////////////////////
143/// Palette normal constructor.
144
146 : TPave(x1, y1, x2, y2)
147{
148 fH = nullptr;
149 fLog = 0;
150 fAxis.SetWmin(min);
151 fAxis.SetWmax(max);
152 SetName("palette");
153 if (gPad->GetView()) SetBit(kHasView);
154}
155
156
157////////////////////////////////////////////////////////////////////////////////
158/// Palette normal constructor.
159
161 : TPave(x1, y1, x2, y2)
162{
163 fH = nullptr;
164 fLog = 0;
165 SetName("palette");
167 if (gPad->GetView()) SetBit(kHasView);
168}
169
170
171////////////////////////////////////////////////////////////////////////////////
172/// Palette destructor.
173
177
178
179////////////////////////////////////////////////////////////////////////////////
180/// Palette copy constructor.
181
183{
184 palette.TPaletteAxis::Copy(*this);
185}
186
187
188////////////////////////////////////////////////////////////////////////////////
189/// Assignment operator.
190
192{
193 if (this != &orig)
194 orig.TPaletteAxis::Copy(*this);
195 return *this;
196}
197
198
199////////////////////////////////////////////////////////////////////////////////
200/// Copy a palette to a palette.
201
203{
204 TPave::Copy(obj);
205 ((TPaletteAxis&)obj).fH = fH;
206}
207
208////////////////////////////////////////////////////////////////////////////////
209/// Check if mouse on the axis region.
210
212{
213 Bool_t isHorizontal = GetX2NDC() - GetX1NDC() > GetY2NDC() - GetY1NDC();
214 Int_t plxmin = gPad->XtoAbsPixel(GetX1());
215 Int_t plxmax = gPad->XtoAbsPixel(GetX2());
216 Int_t plymin = gPad->YtoAbsPixel(GetY1());
217 Int_t plymax = gPad->YtoAbsPixel(GetY2());
218
219 if (isHorizontal) {
220 if (px >= plxmin && px <= plxmax && py > plymin && py <= plymin + 30)
221 return py - plymin;
222 } else {
223 if (px > plxmax && px < plxmax + 30 && py >= plymax && py <= plymin)
224 return px - plxmax;
225 }
226
227 //otherwise check if inside the box
228 return TPave::DistancetoPrimitive(px, py);
229}
230
232 public:
237 {
238 Double_t r = 0;
239 if (fHorizontal)
240 r = (parent.AbsPixeltoX(px) - x1) / (x2 - x1);
241 else
242 r = (parent.AbsPixeltoY(py) - y1) / (y2 - y1);
243
244 ratio2 = r;
245 if (first)
246 ratio1 = r;
247 }
248
250 {
251 if (fHorizontal)
252 parent.PaintBox(x1 + ratio1 * (x2 - x1), y1, x1 + ratio2 * (x2 - x1), y2, "ilpaletteaxis");
253 else
254 parent.PaintBox(x1, y1 + ratio1 * (y2 - y1), x2, y1 + ratio2 * (y2 - y1), "ilpaletteaxis");
255 }
256
257
258};
259
260////////////////////////////////////////////////////////////////////////////////
261/// Check if mouse on the axis region.
262
264{
265 if (!gPad) return;
266
267 auto &parent = *gPad;
268
269 auto inter0 = parent.GetInteractive<TVirtualPad::TInteractive>(this);
270 auto inter = parent.GetInteractive<TPaletteAxisInteractive>(this);
271
272 Bool_t isHorizontal = GetX2NDC() - GetX1NDC() > GetY2NDC() - GetY1NDC();
273
274 // when mouse pointer over palette itself - use TBox interactivity
275 Bool_t useBoxHandler = isHorizontal ? (py <= parent.YtoAbsPixel(GetY1())) : (px <= parent.XtoAbsPixel(GetX2()));
276
277 if (!inter && (inter0 || useBoxHandler)) {
278 TBox::ExecuteEvent(event, px, py);
279 return;
280 }
281
282 parent.SetCursor(kHand);
283
284 switch (event) {
285
286 case kButton1Down:
287 inter = parent.MakeInteractive<TPaletteAxisInteractive>(this, isHorizontal);
288 // No break !!!
289
290 case kButton1Motion:
291 if (inter) {
292 inter->SetPosition(parent, px, py, GetX1(), GetY1(), GetX2(), GetY2(), event == kButton1Down);
293 inter->Paint(parent, GetX1(), GetY1(), GetX2(), GetY2());
294 parent.UpdateAsync();
295 }
296 break;
297
298 case kButton1Up:
299 if (gROOT->IsEscaped()) {
300 gROOT->SetEscape(kFALSE);
301 break;
302 }
303 if (!inter)
304 break;
305
306 inter->SetPosition(parent, px, py, GetX1(), GetY1(), GetX2(), GetY2());
307 if (inter->ratio1 > inter->ratio2)
308 std::swap(inter->ratio1, inter->ratio2);
309 if ((inter->ratio2 - inter->ratio1 > 0.05) && fH && (fH->GetDimension() == 2)) {
310 Double_t zmin = fH->GetMinimum();
311 Double_t zmax = fH->GetMaximum();
312 if (GetLog()) {
313 if (zmin <= 0 && zmax > 0)
314 zmin = TMath::Min((Double_t)1, (Double_t)0.001 * zmax);
315 zmin = TMath::Log10(zmin);
316 zmax = TMath::Log10(zmax);
317 }
318 Double_t newmin = zmin + (zmax - zmin) * inter->ratio1;
319 Double_t newmax = zmin + (zmax - zmin) * inter->ratio2;
320 if (newmin < zmin)
321 newmin = fH->GetBinContent(fH->GetMinimumBin());
322 if (newmax > zmax)
323 newmax = fH->GetBinContent(fH->GetMaximumBin());
324 if (GetLog()) {
325 newmin = TMath::Exp(2.302585092994 * newmin);
326 newmax = TMath::Exp(2.302585092994 * newmax);
327 }
328 fH->SetMinimum(newmin);
329 fH->SetMaximum(newmax);
331 parent.Modified(kTRUE);
332 }
333 parent.FreeInteractive(this);
334 break;
335 }
336}
337
338////////////////////////////////////////////////////////////////////////////////
339/// Returns whether the palette is in log scale.
340///
341/// By default, the palette axis is logarithmic if the TPad's option Logz is set.
342/// However, in some cases, such as with TScatter2D, the color represents a fourth dimension,
343/// and the log scale is not defined by the Z axis but by a dedicated setting specified
344/// through a separate option.
345///
346/// This method handles these various cases and returns the correct state of the palette axis.
347
349{
350 if (fLog == 0) return gPad->GetLogz();
351 return fLog-1;
352}
353
354////////////////////////////////////////////////////////////////////////////////
355/// Returns the color index of the bin (i,j).
356///
357/// This function should be used after an histogram has been plotted with the
358/// option COL or COLZ like in the following example:
359///
360/// h2->Draw("COLZ");
361/// gPad->Update();
362/// TPaletteAxis *palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette");
363/// Int_t ci = palette->GetBinColor(20,15);
364///
365/// Then it is possible to retrieve the RGB components in the following way:
366///
367/// TColor *c = gROOT->GetColor(ci);
368/// float x,y,z;
369/// c->GetRGB(x,y,z);
370
372{
373 if (!fH) return 0;
374 Double_t zc = fH->GetBinContent(i, j);
375 return GetValueColor(zc);
376}
377
378
379////////////////////////////////////////////////////////////////////////////////
380/// Displays the z value corresponding to cursor position py.
381
382char *TPaletteAxis::GetObjectInfo(Int_t /* px */, Int_t py) const
383{
384 Double_t z;
385 static char info[64];
386
387 Double_t zmin = 0.;
388 Double_t zmax = 0.;
389 if (fH) {
390 zmin = fH->GetMinimum();
391 zmax = fH->GetMaximum();
392 }
393 Int_t y1 = gPad->GetWh() - gPad->VtoPixel(fY1NDC);
394 Int_t y2 = gPad->GetWh() - gPad->VtoPixel(fY2NDC);
395 Int_t y = gPad->GetWh() - py;
396
397 if (GetLog()) {
398 if (zmin <= 0 && zmax > 0) zmin = TMath::Min((Double_t)1,
399 (Double_t)0.001 * zmax);
400 Double_t zminl = TMath::Log10(zmin);
401 Double_t zmaxl = TMath::Log10(zmax);
402 Double_t zl = (zmaxl - zminl) * ((Double_t)(y - y1) / (Double_t)(y2 - y1)) + zminl;
403 z = TMath::Power(10., zl);
404 } else {
405 z = (zmax - zmin) * ((Double_t)(y - y1) / (Double_t)(y2 - y1)) + zmin;
406 }
407
408 snprintf(info, 64, "(z=%g)", z);
409 return info;
410}
411
412
413////////////////////////////////////////////////////////////////////////////////
414/// Returns the color index of the given z value
415///
416/// This function should be used after an histogram has been plotted with the
417/// option COL or COLZ like in the following example:
418///
419/// h2->Draw("COLZ");
420/// gPad->Update();
421/// TPaletteAxis *palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette");
422/// Int_t ci = palette->GetValueColor(30.);
423///
424/// Then it is possible to retrieve the RGB components in the following way:
425///
426/// TColor *c = gROOT->GetColor(ci);
427/// float x,y,z;
428/// c->GetRGB(x,y,z);
429
431{
432 if (!fH) return 0;
433
436 Double_t wlmin = wmin;
437 Double_t wlmax = wmax;
438
439 if (GetLog()) {
440 if (wmin <= 0 && wmax > 0) wmin = TMath::Min((Double_t)1,
441 (Double_t)0.001 * wmax);
442 wlmin = TMath::Log10(wmin);
443 wlmax = TMath::Log10(wmax);
444 }
445
446 Int_t ncolors = gStyle->GetNumberOfColors();
447 Int_t ndivz =0;
448 if (fH) ndivz = fH->GetContour();
449 if (ndivz == 0) return 0;
450 ndivz = TMath::Abs(ndivz);
451 Int_t theColor, color;
452 Double_t scale = ndivz / (wlmax - wlmin);
453
454 if (fH->TestBit(TH1::kUserContour) && GetLog()) zc = TMath::Log10(zc);
455 if (zc < wlmin) zc = wlmin;
456
457 color = Int_t(0.01 + (zc - wlmin) * scale);
458
459 theColor = Int_t((color + 0.99) * Double_t(ncolors) / Double_t(ndivz));
460 return gStyle->GetColorPalette(theColor);
461}
462
463
464////////////////////////////////////////////////////////////////////////////////
465/// Paint the palette.
466
468{
470
471 SetFillStyle(1001);
472 Double_t ymin = GetY1();
473 Double_t ymax = GetY2();
474 Double_t xmin = GetX1();
475 Double_t xmax = GetX2();
477 if (fH) {
478 wmin = fH->GetMinimum();
479 wmax = fH->GetMaximum();
480 } else {
481 wmin = fAxis.GetWmin();
482 wmax = fAxis.GetWmax();
483 }
484 Double_t wlmin = wmin;
485 Double_t wlmax = wmax;
486 Double_t b1, b2, w1, w2, zc;
487
488 if ((wlmax - wlmin) <= 0) {
489 Double_t mz = wlmin * 0.1;
490 if (mz == 0) mz = 0.1;
491 wlmin = wlmin - mz;
492 wlmax = wlmax + mz;
493 wmin = wlmin;
494 wmax = wlmax;
495 }
496
497 Bool_t isHorizontal = GetX2NDC() - GetX1NDC() > GetY2NDC() - GetY1NDC();
498
499 if (GetLog()) {
500 if (wmin <= 0 && wmax > 0) wmin = TMath::Min((Double_t)1, (Double_t)0.001 * wmax);
501 wlmin = TMath::Log10(wmin);
502 wlmax = TMath::Log10(wmax);
503 }
504 Double_t ws = wlmax - wlmin;
505 Int_t ncolors = gStyle->GetNumberOfColors();
506 Int_t ndivz;
507 if (fH)
508 ndivz = fH->GetContour();
509 else
510 ndivz = ncolors;
511 if (ndivz == 0)
512 return;
513 ndivz = TMath::Abs(ndivz);
514 Int_t theColor, color;
515 // import Attributes already here since we might need them for CJUST
516 if (fH && fH->GetDimension() == 2) {
518 TString ztit = fAxis.GetTitle();
519 if (ztit.Index(";") > 0) {
520 ztit.Remove(ztit.Index(";"), ztit.Length());
521 fAxis.SetTitle(ztit.Data());
522 }
523 }
524 // the 3D histogram's title is stored in Zaxis
525 if (fH && fH->GetDimension() > 2) {
526 TString ztit = fH->GetZaxis()->GetTitle();
527 fAxis.SetTitle("");
528 if (ztit.Index(";")>0) {
529 ztit.Remove(0,ztit.Index(";")+1);
530 fAxis.SetTitle(ztit.Data());
531 }
532 }
533 // case option "CJUST": put labels directly at color boundaries
534 std::unique_ptr<TLatex> label;
535 std::unique_ptr<TLine> line;
536 Double_t prevlab = 0;
537 if (fH) {
538 TString opt(fH->GetDrawOption());
539 if (opt.Contains("CJUST", TString::kIgnoreCase)) {
540 label = std::make_unique<TLatex>();
541 label->SetTextFont(fAxis.GetLabelFont());
542 label->SetTextColor(fAxis.GetLabelColor());
543 if (isHorizontal)
544 label->SetTextAlign(kHAlignCenter + kVAlignTop);
545 else
546 label->SetTextAlign(kHAlignLeft + kVAlignCenter);
547 line = std::make_unique<TLine>();
549 if (isHorizontal)
551 else
553 }
554 }
555 Double_t scale = ndivz / (wlmax - wlmin);
556 Double_t dw = (wlmax - wlmin) / ndivz;
557 for (Int_t i = 0; i < ndivz; i++) {
558
559 if (fH) zc = fH->GetContourLevel(i);
560 else zc = wlmin + i*dw;
561 if (fH && fH->TestBit(TH1::kUserContour) && GetLog())
562 zc = TMath::Log10(zc);
563 w1 = zc;
564 if (w1 < wlmin) w1 = wlmin;
565
566 w2 = wlmax;
567 if (i < ndivz - 1) {
568 if (fH) zc = fH->GetContourLevel(i + 1);
569 else zc = wlmin + (i+1)*dw;
570 if (fH && fH->TestBit(TH1::kUserContour) && GetLog())
571 zc = TMath::Log10(zc);
572 w2 = zc;
573 }
574
575 if (w2 <= wlmin) continue;
576 if (isHorizontal) {
577 b1 = xmin + (w1 - wlmin) * (xmax - xmin) / ws;
578 b2 = xmin + (w2 - wlmin) * (xmax - xmin) / ws;
579 } else {
580 b1 = ymin + (w1 - wlmin) * (ymax - ymin) / ws;
581 b2 = ymin + (w2 - wlmin) * (ymax - ymin) / ws;
582 }
583
584 if (fH && fH->TestBit(TH1::kUserContour)) {
585 color = i;
586 } else {
587 color = Int_t(0.01 + (w1 - wlmin) * scale);
588 }
589
590 theColor = Int_t((color + 0.99) * Double_t(ncolors) / Double_t(ndivz));
593 if (isHorizontal)
594 gPad->PaintBox(b1, ymin, b2, ymax);
595 else
596 gPad->PaintBox(xmin, b1, xmax, b2);
597 // case option "CJUST": put labels directly
598 if (fH && label) {
599 Double_t lof = fAxis.GetLabelOffset()*(gPad->GetUxmax()-gPad->GetUxmin());
600 // the following assumes option "S"
601 Double_t tlength = fAxis.GetTickSize() * (gPad->GetUxmax()-gPad->GetUxmin());
602 Double_t lsize = fAxis.GetLabelSize();
603 Double_t lsize_user = lsize*(gPad->GetUymax()-gPad->GetUymin());
604 Double_t zlab = fH->GetContourLevel(i);
605 if (GetLog() && !fH->TestBit(TH1::kUserContour)) {
606 zlab = TMath::Power(10, zlab);
607 }
608 // make sure labels dont overlap
609 if (i == 0 || (b1 - prevlab) > 1.5*lsize_user) {
610 if (isHorizontal)
611 label->PaintLatex(b1, ymin - lof, 0, lsize, TString::Format("%g", zlab));
612 else
613 label->PaintLatex(xmax + lof, b1, 0, lsize, TString::Format("%g", zlab));
614 prevlab = b1;
615 }
616 if (isHorizontal)
617 line->PaintLine(b2, ymin + tlength, b2, ymin);
618 else
619 line->PaintLine(xmax - tlength, b1, xmax, b1);
620 if (i == ndivz - 1) {
621 // label + tick at top of axis
622 if (fH && (b2 - prevlab > 1.5*lsize_user)) {
623 if (isHorizontal)
624 label->PaintLatex(b2, ymin - lof, 0, lsize, TString::Format("%g", fH->GetMaximum()));
625 else
626 label->PaintLatex(xmax + lof, b2, 0, lsize, TString::Format("%g", fH->GetMaximum()));
627 }
628 if (isHorizontal)
629 line->PaintLine(b1, ymin + tlength, b1, ymin);
630 else
631 line->PaintLine(xmax - tlength, b2, xmax, b2);
632 }
633 }
634 }
635
636 // case option "CJUST" - just cleanup
637 if (label)
638 return;
639
640 // Take primary divisions only
641 Int_t ndiv;
642 if (fH)
643 ndiv = fH->GetZaxis()->GetNdivisions();
644 else
645 ndiv = fAxis.GetNdiv();
646 Bool_t isOptimized = ndiv > 0;
647 Int_t absDiv = TMath::Abs(ndiv);
648 Int_t maxD = absDiv / 1000000;
649 ndiv = absDiv % 100 + maxD * 1000000;
650
651 TString chopt = "S+L";
652 if (!isOptimized)
653 chopt.Append("N");
654 if (GetLog()) {
655 wmin = TMath::Power(10., wlmin);
656 wmax = TMath::Power(10., wlmax);
657 chopt.Append("G");
658 }
659 if (isHorizontal)
660 fAxis.PaintAxis(xmin, ymin, xmax, ymin, wmin, wmax, ndiv, chopt);
661 else
662 fAxis.PaintAxis(xmax, ymin, xmax, ymax, wmin, wmax, ndiv, chopt);
663}
664
665
666////////////////////////////////////////////////////////////////////////////////
667/// Save primitive as a C++ statement(s) on output stream out.
668
669void TPaletteAxis::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
670{
671 if (!fH)
672 return;
673
675 out << " palette->SetNdivisions(" << fH->GetZaxis()->GetNdivisions() << ");\n";
676 out << " palette->SetAxisColor(" << TColor::SavePrimitiveColor(fH->GetZaxis()->GetAxisColor()) << ");\n";
677 out << " palette->SetLabelColor(" << TColor::SavePrimitiveColor(fH->GetZaxis()->GetLabelColor()) << ");\n";
678 out << " palette->SetLabelFont(" << fH->GetZaxis()->GetLabelFont() << ");\n";
679 out << " palette->SetLabelOffset(" << fH->GetZaxis()->GetLabelOffset() << ");\n";
680 out << " palette->SetLabelSize(" << fH->GetZaxis()->GetLabelSize() << ");\n";
681 out << " palette->SetMaxDigits(" << fH->GetZaxis()->GetMaxDigits() << ");\n";
682 out << " palette->SetTickLength(" << fH->GetZaxis()->GetTickLength() << ");\n";
683 out << " palette->SetTitleOffset(" << fH->GetZaxis()->GetTitleOffset() << ");\n";
684 out << " palette->SetTitleSize(" << fH->GetZaxis()->GetTitleSize() << ");\n";
685 out << " palette->SetTitleColor(" << TColor::SavePrimitiveColor(fH->GetZaxis()->GetTitleColor()) << ");\n";
686 out << " palette->SetTitleFont(" << fH->GetZaxis()->GetTitleFont() << ");\n";
687 out << " palette->SetTitle(\"" << TString(fH->GetZaxis()->GetTitle()).ReplaceSpecialCppChars() << "\");\n";
688 SaveFillAttributes(out, "palette", -1, -1);
689 SaveLineAttributes(out, "palette", 1, 1, 1);
690}
691
692////////////////////////////////////////////////////////////////////////////////
693/// Unzoom the palette
694
696{
697 if (!fH)
698 return;
699 // if view exists - it will be deleted
700 if (gPad)
701 gPad->SetView(nullptr);
702 fH->GetZaxis()->SetRange(0, 0);
703 if (fH->GetDimension() == 2) {
704 fH->SetMinimum();
705 fH->SetMaximum();
707 }
708}
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
@ kButton1Down
Definition Buttons.h:17
@ kHand
Definition GuiTypes.h:375
#define h(i)
Definition RSha256.hxx:106
cudaEvent_t event
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
@ kVAlignTop
Definition TAttText.h:62
@ kVAlignCenter
Definition TAttText.h:62
@ kHAlignLeft
Definition TAttText.h:61
@ kHAlignCenter
Definition TAttText.h:61
Option_t Option_t SetFillStyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t wmin
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t SetFillColor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t wmax
Option_t Option_t TPoint TPoint const char y1
float xmin
float ymin
float xmax
float ymax
#define gROOT
Definition TROOT.h:417
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
#define gPad
virtual Color_t GetTitleColor() const
Definition TAttAxis.h:47
virtual Color_t GetLabelColor() const
Definition TAttAxis.h:39
virtual Int_t GetNdivisions() const
Definition TAttAxis.h:37
virtual Color_t GetAxisColor() const
Definition TAttAxis.h:38
virtual Style_t GetTitleFont() const
Definition TAttAxis.h:48
virtual Float_t GetLabelOffset() const
Definition TAttAxis.h:41
virtual Int_t GetMaxDigits() const
Definition TAttAxis.h:43
virtual Style_t GetLabelFont() const
Definition TAttAxis.h:40
virtual Float_t GetTitleSize() const
Definition TAttAxis.h:45
virtual Float_t GetLabelSize() const
Definition TAttAxis.h:42
virtual Float_t GetTickLength() const
Definition TAttAxis.h:46
virtual Float_t GetTitleOffset() const
Definition TAttAxis.h:44
virtual void Modify()
Change current fill area attributes if necessary.
Definition TAttFill.cxx:212
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Definition TAttFill.cxx:240
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:36
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:44
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
Definition TAttLine.cxx:289
Class to manage histogram axis.
Definition TAxis.h:32
const char * GetTitle() const override
Returns title of object.
Definition TAxis.h:137
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis using bin numbers.
Definition TAxis.cxx:1068
Double_t GetX1() const
Definition TBox.h:51
Double_t GetX2() const
Definition TBox.h:52
Double_t GetY1() const
Definition TBox.h:53
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TBox.cxx:232
Double_t GetY2() const
Definition TBox.h:54
static TString SavePrimitiveColor(Int_t ci)
Convert color in C++ statement which can be used in SetColor directives Produced statement either inc...
Definition TColor.cxx:2569
virtual void PaintAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Double_t &wmin, Double_t &wmax, Int_t &ndiv, Option_t *chopt="", Double_t gridlength=0, Bool_t drawGridOnly=kFALSE)
Control function to draw an axis.
Definition TGaxis.cxx:1006
Double_t GetWmin() const
Definition TGaxis.h:91
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition TGaxis.cxx:2910
Float_t GetLabelOffset() const
Definition TGaxis.h:82
virtual void ImportAxisAttributes(TAxis *axis)
Internal method to import TAxis attributes to this TGaxis.
Definition TGaxis.cxx:953
Int_t GetLabelFont() const
Definition TGaxis.h:81
const char * GetTitle() const override
Returns title of object.
Definition TGaxis.h:88
void SetWmax(Double_t wmax)
Definition TGaxis.h:135
Int_t GetLabelColor() const
Definition TGaxis.h:80
Float_t GetTickSize() const
Definition TGaxis.h:93
void SetWmin(Double_t wmin)
Definition TGaxis.h:134
Int_t GetNdiv() const
Definition TGaxis.h:90
Double_t GetWmax() const
Definition TGaxis.h:92
Float_t GetLabelSize() const
Definition TGaxis.h:83
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
TAxis * GetZaxis()
Definition TH1.h:573
virtual Int_t GetDimension() const
Definition TH1.h:527
@ kUserContour
User specified contour levels.
Definition TH1.h:404
@ kIsZoomed
Bit set when zooming on Y axis.
Definition TH1.h:407
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
Definition TH1.cxx:8778
virtual void SetMaximum(Double_t maximum=-1111)
Definition TH1.h:652
virtual void SetMinimum(Double_t minimum=-1111)
Definition TH1.h:653
virtual Int_t GetMaximumBin() const
Return location of bin with maximum value in the range.
Definition TH1.cxx:8810
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition TH1.cxx:5239
virtual Int_t GetContour(Double_t *levels=nullptr)
Return contour values into array levels if pointer levels is non zero.
Definition TH1.cxx:8640
virtual Double_t GetContourLevel(Int_t level) const
Return value of contour number level.
Definition TH1.cxx:8659
virtual Int_t GetMinimumBin() const
Return location of bin with minimum value in the range.
Definition TH1.cxx:8898
virtual Double_t GetMinimum(Double_t minval=-FLT_MAX) const
Return minimum value larger than minval of bins in the range, unless the value has been overridden by...
Definition TH1.cxx:8868
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition TLine.cxx:260
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Mother of all ROOT objects.
Definition TObject.h:42
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition TObject.cxx:444
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:886
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
Definition TObject.cxx:776
void ResetBit(UInt_t f)
Definition TObject.h:203
void SetPosition(TVirtualPad &parent, Int_t px, Int_t py, Double_t x1, Double_t y1, Double_t x2, Double_t y2, Bool_t first=kFALSE)
void Paint(TVirtualPad &parent, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
The palette painting class.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Check if mouse on the axis region.
void Paint(Option_t *option="") override
Paint the palette.
TGaxis fAxis
Palette axis.
TPaletteAxis & operator=(const TPaletteAxis &)
Assignment operator.
~TPaletteAxis() override
Palette destructor.
char * GetObjectInfo(Int_t px, Int_t py) const override
Displays the z value corresponding to cursor position py.
TPaletteAxis()
Palette default constructor.
Int_t GetBinColor(Int_t i, Int_t j)
Returns the color index of the bin (i,j).
void Copy(TObject &palette) const override
Copy a palette to a palette.
TH1 * fH
! Pointer to parent histogram
virtual void UnZoom()
Unzoom the palette.
Int_t fLog
Log option: 0 use Logz, 1 is linear, 2 is log.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Check if mouse on the axis region.
Int_t GetLog() const
Returns whether the palette is in log scale.
Int_t GetValueColor(Double_t zc)
Returns the color index of the given z value.
static TClass * Class()
A TBox with a bordersize and a shadow option.
Definition TPave.h:19
Double_t GetY2NDC() const
Definition TPave.h:64
virtual void ConvertNDCtoPad()
Convert pave coordinates from NDC to Pad coordinates.
Definition TPave.cxx:138
Double_t GetX2NDC() const
Definition TPave.h:62
TString GetSavePaveArgs(const char *extra_arg=nullptr, Bool_t save_option=kTRUE)
Returns arguments which should be used when saving primitive constructor Check if coordinates are ini...
Definition TPave.cxx:610
void Copy(TObject &pave) const override
Copy this pave to pave.
Definition TPave.cxx:185
virtual void SetName(const char *name="")
Definition TPave.h:81
Double_t GetY1NDC() const
Definition TPave.h:63
Double_t fY2NDC
Y2 point in NDC coordinates.
Definition TPave.h:25
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a pave.
Definition TPave.cxx:207
Double_t fY1NDC
Y1 point in NDC coordinates.
Definition TPave.h:23
Double_t GetX1NDC() const
Definition TPave.h:61
Basic string class.
Definition TString.h:137
Ssiz_t Length() const
Definition TString.h:426
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1122
const char * Data() const
Definition TString.h:385
@ kIgnoreCase
Definition TString.h:284
TString & Remove(Ssiz_t pos)
Definition TString.h:695
TString & Append(const char *cs)
Definition TString.h:582
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2460
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:642
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:661
Int_t GetColorPalette(Int_t i) const
Return color number i in current palette.
Definition TStyle.cxx:1102
Int_t GetNumberOfColors() const
Return number of colors in the color palette.
Definition TStyle.cxx:1176
Helper class to store interactive parameters for individual objects Should be used via MakeInteractiv...
Definition TVirtualPad.h:72
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:53
virtual Double_t AbsPixeltoX(Double_t px)=0
virtual void PaintBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t *option="")=0
virtual Double_t AbsPixeltoY(Double_t py)=0
TLine * line
Double_t y[n]
Definition legend1.C:17
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Definition TMath.h:722
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:734
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:775
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122