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.Interactive(this);
270 auto inter = dynamic_cast<TPaletteAxisInteractive *> (inter0);
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 = new TPaletteAxisInteractive(isHorizontal);
288 parent.Interactive(this, inter);
289 // No break !!!
290
291 case kButton1Motion:
292 if (inter) {
293 inter->SetPosition(parent, px, py, GetX1(), GetY1(), GetX2(), GetY2(), event == kButton1Down);
294 inter->Paint(parent, GetX1(), GetY1(), GetX2(), GetY2());
295 parent.UpdateAsync();
296 }
297 break;
298
299 case kButton1Up:
300 if (gROOT->IsEscaped()) {
301 gROOT->SetEscape(kFALSE);
302 break;
303 }
304 if (!inter)
305 break;
306
307 inter->SetPosition(parent, px, py, GetX1(), GetY1(), GetX2(), GetY2());
308 if (inter->ratio1 > inter->ratio2)
309 std::swap(inter->ratio1, inter->ratio2);
310 if ((inter->ratio2 - inter->ratio1 > 0.05) && fH && (fH->GetDimension() == 2)) {
311 Double_t zmin = fH->GetMinimum();
312 Double_t zmax = fH->GetMaximum();
313 if (GetLog()) {
314 if (zmin <= 0 && zmax > 0)
315 zmin = TMath::Min((Double_t)1, (Double_t)0.001 * zmax);
316 zmin = TMath::Log10(zmin);
317 zmax = TMath::Log10(zmax);
318 }
319 Double_t newmin = zmin + (zmax - zmin) * inter->ratio1;
320 Double_t newmax = zmin + (zmax - zmin) * inter->ratio2;
321 if (newmin < zmin)
322 newmin = fH->GetBinContent(fH->GetMinimumBin());
323 if (newmax > zmax)
324 newmax = fH->GetBinContent(fH->GetMaximumBin());
325 if (GetLog()) {
326 newmin = TMath::Exp(2.302585092994 * newmin);
327 newmax = TMath::Exp(2.302585092994 * newmax);
328 }
329 fH->SetMinimum(newmin);
330 fH->SetMaximum(newmax);
332 parent.Modified(kTRUE);
333 }
334 parent.Interactive(); // clear interactive object
335 break;
336 }
337}
338
339////////////////////////////////////////////////////////////////////////////////
340/// Returns whether the palette is in log scale.
341///
342/// By default, the palette axis is logarithmic if the TPad's option Logz is set.
343/// However, in some cases, such as with TScatter2D, the color represents a fourth dimension,
344/// and the log scale is not defined by the Z axis but by a dedicated setting specified
345/// through a separate option.
346///
347/// This method handles these various cases and returns the correct state of the palette axis.
348
350{
351 if (fLog == 0) return gPad->GetLogz();
352 return fLog-1;
353}
354
355////////////////////////////////////////////////////////////////////////////////
356/// Returns the color index of the bin (i,j).
357///
358/// This function should be used after an histogram has been plotted with the
359/// option COL or COLZ like in the following example:
360///
361/// h2->Draw("COLZ");
362/// gPad->Update();
363/// TPaletteAxis *palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette");
364/// Int_t ci = palette->GetBinColor(20,15);
365///
366/// Then it is possible to retrieve the RGB components in the following way:
367///
368/// TColor *c = gROOT->GetColor(ci);
369/// float x,y,z;
370/// c->GetRGB(x,y,z);
371
373{
374 if (!fH) return 0;
375 Double_t zc = fH->GetBinContent(i, j);
376 return GetValueColor(zc);
377}
378
379
380////////////////////////////////////////////////////////////////////////////////
381/// Displays the z value corresponding to cursor position py.
382
383char *TPaletteAxis::GetObjectInfo(Int_t /* px */, Int_t py) const
384{
385 Double_t z;
386 static char info[64];
387
388 Double_t zmin = 0.;
389 Double_t zmax = 0.;
390 if (fH) {
391 zmin = fH->GetMinimum();
392 zmax = fH->GetMaximum();
393 }
394 Int_t y1 = gPad->GetWh() - gPad->VtoPixel(fY1NDC);
395 Int_t y2 = gPad->GetWh() - gPad->VtoPixel(fY2NDC);
396 Int_t y = gPad->GetWh() - py;
397
398 if (GetLog()) {
399 if (zmin <= 0 && zmax > 0) zmin = TMath::Min((Double_t)1,
400 (Double_t)0.001 * zmax);
401 Double_t zminl = TMath::Log10(zmin);
402 Double_t zmaxl = TMath::Log10(zmax);
403 Double_t zl = (zmaxl - zminl) * ((Double_t)(y - y1) / (Double_t)(y2 - y1)) + zminl;
404 z = TMath::Power(10., zl);
405 } else {
406 z = (zmax - zmin) * ((Double_t)(y - y1) / (Double_t)(y2 - y1)) + zmin;
407 }
408
409 snprintf(info, 64, "(z=%g)", z);
410 return info;
411}
412
413
414////////////////////////////////////////////////////////////////////////////////
415/// Returns the color index of the given z value
416///
417/// This function should be used after an histogram has been plotted with the
418/// option COL or COLZ like in the following example:
419///
420/// h2->Draw("COLZ");
421/// gPad->Update();
422/// TPaletteAxis *palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette");
423/// Int_t ci = palette->GetValueColor(30.);
424///
425/// Then it is possible to retrieve the RGB components in the following way:
426///
427/// TColor *c = gROOT->GetColor(ci);
428/// float x,y,z;
429/// c->GetRGB(x,y,z);
430
432{
433 if (!fH) return 0;
434
437 Double_t wlmin = wmin;
438 Double_t wlmax = wmax;
439
440 if (GetLog()) {
441 if (wmin <= 0 && wmax > 0) wmin = TMath::Min((Double_t)1,
442 (Double_t)0.001 * wmax);
443 wlmin = TMath::Log10(wmin);
444 wlmax = TMath::Log10(wmax);
445 }
446
447 Int_t ncolors = gStyle->GetNumberOfColors();
448 Int_t ndivz =0;
449 if (fH) ndivz = fH->GetContour();
450 if (ndivz == 0) return 0;
451 ndivz = TMath::Abs(ndivz);
452 Int_t theColor, color;
453 Double_t scale = ndivz / (wlmax - wlmin);
454
455 if (fH->TestBit(TH1::kUserContour) && GetLog()) zc = TMath::Log10(zc);
456 if (zc < wlmin) zc = wlmin;
457
458 color = Int_t(0.01 + (zc - wlmin) * scale);
459
460 theColor = Int_t((color + 0.99) * Double_t(ncolors) / Double_t(ndivz));
461 return gStyle->GetColorPalette(theColor);
462}
463
464
465////////////////////////////////////////////////////////////////////////////////
466/// Paint the palette.
467
469{
471
472 SetFillStyle(1001);
473 Double_t ymin = GetY1();
474 Double_t ymax = GetY2();
475 Double_t xmin = GetX1();
476 Double_t xmax = GetX2();
478 if (fH) {
479 wmin = fH->GetMinimum();
480 wmax = fH->GetMaximum();
481 } else {
482 wmin = fAxis.GetWmin();
483 wmax = fAxis.GetWmax();
484 }
485 Double_t wlmin = wmin;
486 Double_t wlmax = wmax;
487 Double_t b1, b2, w1, w2, zc;
488
489 if ((wlmax - wlmin) <= 0) {
490 Double_t mz = wlmin * 0.1;
491 if (mz == 0) mz = 0.1;
492 wlmin = wlmin - mz;
493 wlmax = wlmax + mz;
494 wmin = wlmin;
495 wmax = wlmax;
496 }
497
498 Bool_t isHorizontal = GetX2NDC() - GetX1NDC() > GetY2NDC() - GetY1NDC();
499
500 if (GetLog()) {
501 if (wmin <= 0 && wmax > 0) wmin = TMath::Min((Double_t)1, (Double_t)0.001 * wmax);
502 wlmin = TMath::Log10(wmin);
503 wlmax = TMath::Log10(wmax);
504 }
505 Double_t ws = wlmax - wlmin;
506 Int_t ncolors = gStyle->GetNumberOfColors();
507 Int_t ndivz;
508 if (fH)
509 ndivz = fH->GetContour();
510 else
511 ndivz = ncolors;
512 if (ndivz == 0)
513 return;
514 ndivz = TMath::Abs(ndivz);
515 Int_t theColor, color;
516 // import Attributes already here since we might need them for CJUST
517 if (fH && fH->GetDimension() == 2) {
519 TString ztit = fAxis.GetTitle();
520 if (ztit.Index(";") > 0) {
521 ztit.Remove(ztit.Index(";"), ztit.Length());
522 fAxis.SetTitle(ztit.Data());
523 }
524 }
525 // the 3D histogram's title is stored in Zaxis
526 if (fH && fH->GetDimension() > 2) {
527 TString ztit = fH->GetZaxis()->GetTitle();
528 fAxis.SetTitle("");
529 if (ztit.Index(";")>0) {
530 ztit.Remove(0,ztit.Index(";")+1);
531 fAxis.SetTitle(ztit.Data());
532 }
533 }
534 // case option "CJUST": put labels directly at color boundaries
535 std::unique_ptr<TLatex> label;
536 std::unique_ptr<TLine> line;
537 Double_t prevlab = 0;
538 if (fH) {
539 TString opt(fH->GetDrawOption());
540 if (opt.Contains("CJUST", TString::kIgnoreCase)) {
541 label = std::make_unique<TLatex>();
542 label->SetTextFont(fAxis.GetLabelFont());
543 label->SetTextColor(fAxis.GetLabelColor());
544 if (isHorizontal)
545 label->SetTextAlign(kHAlignCenter + kVAlignTop);
546 else
547 label->SetTextAlign(kHAlignLeft + kVAlignCenter);
548 line = std::make_unique<TLine>();
550 if (isHorizontal)
552 else
554 }
555 }
556 Double_t scale = ndivz / (wlmax - wlmin);
557 Double_t dw = (wlmax - wlmin) / ndivz;
558 for (Int_t i = 0; i < ndivz; i++) {
559
560 if (fH) zc = fH->GetContourLevel(i);
561 else zc = wlmin + i*dw;
562 if (fH && fH->TestBit(TH1::kUserContour) && GetLog())
563 zc = TMath::Log10(zc);
564 w1 = zc;
565 if (w1 < wlmin) w1 = wlmin;
566
567 w2 = wlmax;
568 if (i < ndivz - 1) {
569 if (fH) zc = fH->GetContourLevel(i + 1);
570 else zc = wlmin + (i+1)*dw;
571 if (fH && fH->TestBit(TH1::kUserContour) && GetLog())
572 zc = TMath::Log10(zc);
573 w2 = zc;
574 }
575
576 if (w2 <= wlmin) continue;
577 if (isHorizontal) {
578 b1 = xmin + (w1 - wlmin) * (xmax - xmin) / ws;
579 b2 = xmin + (w2 - wlmin) * (xmax - xmin) / ws;
580 } else {
581 b1 = ymin + (w1 - wlmin) * (ymax - ymin) / ws;
582 b2 = ymin + (w2 - wlmin) * (ymax - ymin) / ws;
583 }
584
585 if (fH && fH->TestBit(TH1::kUserContour)) {
586 color = i;
587 } else {
588 color = Int_t(0.01 + (w1 - wlmin) * scale);
589 }
590
591 theColor = Int_t((color + 0.99) * Double_t(ncolors) / Double_t(ndivz));
594 if (isHorizontal)
595 gPad->PaintBox(b1, ymin, b2, ymax);
596 else
597 gPad->PaintBox(xmin, b1, xmax, b2);
598 // case option "CJUST": put labels directly
599 if (fH && label) {
600 Double_t lof = fAxis.GetLabelOffset()*(gPad->GetUxmax()-gPad->GetUxmin());
601 // the following assumes option "S"
602 Double_t tlength = fAxis.GetTickSize() * (gPad->GetUxmax()-gPad->GetUxmin());
603 Double_t lsize = fAxis.GetLabelSize();
604 Double_t lsize_user = lsize*(gPad->GetUymax()-gPad->GetUymin());
605 Double_t zlab = fH->GetContourLevel(i);
606 if (GetLog() && !fH->TestBit(TH1::kUserContour)) {
607 zlab = TMath::Power(10, zlab);
608 }
609 // make sure labels dont overlap
610 if (i == 0 || (b1 - prevlab) > 1.5*lsize_user) {
611 if (isHorizontal)
612 label->PaintLatex(b1, ymin - lof, 0, lsize, TString::Format("%g", zlab));
613 else
614 label->PaintLatex(xmax + lof, b1, 0, lsize, TString::Format("%g", zlab));
615 prevlab = b1;
616 }
617 if (isHorizontal)
618 line->PaintLine(b2, ymin + tlength, b2, ymin);
619 else
620 line->PaintLine(xmax - tlength, b1, xmax, b1);
621 if (i == ndivz - 1) {
622 // label + tick at top of axis
623 if (fH && (b2 - prevlab > 1.5*lsize_user)) {
624 if (isHorizontal)
625 label->PaintLatex(b2, ymin - lof, 0, lsize, TString::Format("%g", fH->GetMaximum()));
626 else
627 label->PaintLatex(xmax + lof, b2, 0, lsize, TString::Format("%g", fH->GetMaximum()));
628 }
629 if (isHorizontal)
630 line->PaintLine(b1, ymin + tlength, b1, ymin);
631 else
632 line->PaintLine(xmax - tlength, b2, xmax, b2);
633 }
634 }
635 }
636
637 // case option "CJUST" - just cleanup
638 if (label)
639 return;
640
641 // Take primary divisions only
642 Int_t ndiv;
643 if (fH)
644 ndiv = fH->GetZaxis()->GetNdivisions();
645 else
646 ndiv = fAxis.GetNdiv();
647 Bool_t isOptimized = ndiv > 0;
648 Int_t absDiv = TMath::Abs(ndiv);
649 Int_t maxD = absDiv / 1000000;
650 ndiv = absDiv % 100 + maxD * 1000000;
651
652 TString chopt = "S+L";
653 if (!isOptimized)
654 chopt.Append("N");
655 if (GetLog()) {
656 wmin = TMath::Power(10., wlmin);
657 wmax = TMath::Power(10., wlmax);
658 chopt.Append("G");
659 }
660 if (isHorizontal)
661 fAxis.PaintAxis(xmin, ymin, xmax, ymin, wmin, wmax, ndiv, chopt);
662 else
663 fAxis.PaintAxis(xmax, ymin, xmax, ymax, wmin, wmax, ndiv, chopt);
664}
665
666
667////////////////////////////////////////////////////////////////////////////////
668/// Save primitive as a C++ statement(s) on output stream out.
669
670void TPaletteAxis::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
671{
672 if (!fH)
673 return;
674
676 out << " palette->SetNdivisions(" << fH->GetZaxis()->GetNdivisions() << ");\n";
677 out << " palette->SetAxisColor(" << TColor::SavePrimitiveColor(fH->GetZaxis()->GetAxisColor()) << ");\n";
678 out << " palette->SetLabelColor(" << TColor::SavePrimitiveColor(fH->GetZaxis()->GetLabelColor()) << ");\n";
679 out << " palette->SetLabelFont(" << fH->GetZaxis()->GetLabelFont() << ");\n";
680 out << " palette->SetLabelOffset(" << fH->GetZaxis()->GetLabelOffset() << ");\n";
681 out << " palette->SetLabelSize(" << fH->GetZaxis()->GetLabelSize() << ");\n";
682 out << " palette->SetMaxDigits(" << fH->GetZaxis()->GetMaxDigits() << ");\n";
683 out << " palette->SetTickLength(" << fH->GetZaxis()->GetTickLength() << ");\n";
684 out << " palette->SetTitleOffset(" << fH->GetZaxis()->GetTitleOffset() << ");\n";
685 out << " palette->SetTitleSize(" << fH->GetZaxis()->GetTitleSize() << ");\n";
686 out << " palette->SetTitleColor(" << TColor::SavePrimitiveColor(fH->GetZaxis()->GetTitleColor()) << ");\n";
687 out << " palette->SetTitleFont(" << fH->GetZaxis()->GetTitleFont() << ");\n";
688 out << " palette->SetTitle(\"" << TString(fH->GetZaxis()->GetTitle()).ReplaceSpecialCppChars() << "\");\n";
689 SaveFillAttributes(out, "palette", -1, -1);
690 SaveLineAttributes(out, "palette", 1, 1, 1);
691}
692
693////////////////////////////////////////////////////////////////////////////////
694/// Unzoom the palette
695
697{
698 if (!fH)
699 return;
700 // if view exists - it will be deleted
701 if (gPad)
702 gPad->SetView(nullptr);
703 fH->GetZaxis()->SetRange(0, 0);
704 if (fH->GetDimension() == 2) {
705 fH->SetMinimum();
706 fH->SetMaximum();
708 }
709}
@ 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:1061
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:261
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 gPad->Interact...
Definition TVirtualPad.h:77
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