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 "TVirtualX.h"
16#include "TStyle.h"
17#include "TMath.h"
18#include "TView.h"
19#include "TH1.h"
20#include "TGaxis.h"
21#include "TLatex.h"
22#include "snprintf.h"
23
24#include <iostream>
25
27
28
29////////////////////////////////////////////////////////////////////////////////
30
31/*! \class TPaletteAxis
32 \ingroup Histpainter
33 \brief The palette painting class.
34
35A `TPaletteAxis` object is used to display the color palette when
36drawing 2-d histograms.
37
38The `TPaletteAxis` is automatically created drawn when drawing a 2-D
39histogram when the option "Z" is specified.
40
41A `TPaletteAxis` object is added to the histogram list of functions and
42can be retrieved doing:
43
44 TPaletteAxis *palette = (TPaletteAxis*)h->GetListOfFunctions()->FindObject("palette");
45
46then the pointer `palette` can be used to change the palette attributes.
47
48Because the palette is created at painting time only, one must issue a:
49
50 gPad->Update();
51
52before retrieving the palette pointer in order to create the palette. The following
53macro gives an example.
54
55Begin_Macro(source)
56{
57 auto h2 = new TH2F("h2","Example of a resized palette ",40,-4,4,40,-20,20);
58 Float_t px, py;
59 for (Int_t i = 0; i < 25000; i++) {
60 gRandom->Rannor(px,py);
61 h2->Fill(px,5*py);
62 }
63 gStyle->SetPalette(1);
64 h2->Draw("COLZ");
65 gPad->Update();
66 auto palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette");
67 palette->SetY2NDC(0.7);
68}
69End_Macro
70
71`TPaletteAxis` inherits from `TBox` and `TPave`. The methods
72allowing to specify the palette position are inherited from these two classes.
73
74The palette can be interactively moved and resized. The context menu
75can be used to set the axis attributes.
76
77It is possible to select a range on the axis to set the min/max in z
78
79As default labels and ticks are drawn by `TGAxis` at equidistant (lin or log)
80points as controlled by SetNdivisions.
81If option "CJUST" is given labels and ticks are justified at the
82color boundaries defined by the contour levels.
83In this case no optimization can be done. It is responsibility of the
84user to adjust minimum, maximum of the histogram and/or the contour levels
85to get a reasonable look of the plot.
86Only overlap of the labels is avoided if too many contour levels are used.
87
88This option is especially useful with user defined contours.
89An example is shown here:
90
91Begin_Macro(source)
92{
93 gStyle->SetOptStat(0);
94 auto c = new TCanvas("c","exa_CJUST",300,10,400,400);
95 auto hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
96 // Fill histograms randomly
97 TRandom3 randomNum;
98 Float_t px, py;
99 for (Int_t i = 0; i < 25000; i++) {
100 randomNum.Rannor(px,py);
101 hpxpy->Fill(px,py);
102 }
103 hpxpy->SetMaximum(200);
104 Double_t zcontours[5] = {0, 20, 40, 80, 120};
105 hpxpy->SetContour(5, zcontours);
106 hpxpy->GetZaxis()->SetTickSize(0.01);
107 hpxpy->GetZaxis()->SetLabelOffset(0.01);
108 gPad->SetRightMargin(0.13);
109 hpxpy->SetTitle("User contours, CJUST");
110 hpxpy->Draw("COL Z CJUST");
111}
112End_Macro
113*/
114
115
116////////////////////////////////////////////////////////////////////////////////
117/// Palette default constructor.
118
120{
121 fH = nullptr;
122 SetName("");
123}
124
125
126////////////////////////////////////////////////////////////////////////////////
127/// Palette normal constructor.
128
130 : TPave(x1, y1, x2, y2)
131{
132 fH = h;
133 if (!fH) return;
134 SetName("palette");
135 TAxis *zaxis = fH->GetZaxis();
137 if (gPad->GetView()) SetBit(kHasView);
138}
139
140
141////////////////////////////////////////////////////////////////////////////////
142/// Palette normal constructor.
143
145 : TPave(x1, y1, x2, y2)
146{
147 fH = nullptr;
148 fAxis.SetWmin(min);
149 fAxis.SetWmax(max);
150 SetName("palette");
151 if (gPad->GetView()) SetBit(kHasView);
152}
153
154
155////////////////////////////////////////////////////////////////////////////////
156/// Palette normal constructor.
157
159 : TPave(x1, y1, x2, y2)
160{
161 fH = nullptr;
162 SetName("palette");
164 if (gPad->GetView()) SetBit(kHasView);
165}
166
167
168////////////////////////////////////////////////////////////////////////////////
169/// Palette destructor.
170
172{
173}
174
175
176////////////////////////////////////////////////////////////////////////////////
177/// Palette copy constructor.
178
180{
181 palette.TPaletteAxis::Copy(*this);
182}
183
184
185////////////////////////////////////////////////////////////////////////////////
186/// Assignment operator.
187
189{
190 if (this != &orig)
191 orig.TPaletteAxis::Copy(*this);
192 return *this;
193}
194
195
196////////////////////////////////////////////////////////////////////////////////
197/// Copy a palette to a palette.
198
200{
201 TPave::Copy(obj);
202 ((TPaletteAxis&)obj).fH = fH;
203}
204
205
206////////////////////////////////////////////////////////////////////////////////
207/// Check if mouse on the axis region.
208
210{
211 Int_t plxmax = gPad->XtoAbsPixel(fX2);
212 Int_t plymin = gPad->YtoAbsPixel(fY1);
213 Int_t plymax = gPad->YtoAbsPixel(fY2);
214 if (px > plxmax && px < plxmax + 30 && py >= plymax && py <= plymin) return px - plxmax;
215
216 //otherwise check if inside the box
217 return TPave::DistancetoPrimitive(px, py);
218}
219
220
221////////////////////////////////////////////////////////////////////////////////
222/// Check if mouse on the axis region.
223
225{
226 if (!gPad) return;
227
228 static Int_t kmode = 0;
229 Int_t plxmin = gPad->XtoAbsPixel(fX1);
230 Int_t plxmax = gPad->XtoAbsPixel(fX2);
231 if (kmode != 0 || px <= plxmax) {
232 if (event == kButton1Down) kmode = 1;
233 TBox::ExecuteEvent(event, px, py);
234 if (event == kButton1Up) kmode = 0;
235 // In case palette coordinates have been modified, recompute NDC coordinates
236 Double_t dpx = gPad->GetX2() - gPad->GetX1();
237 Double_t dpy = gPad->GetY2() - gPad->GetY1();
238 Double_t xp1 = gPad->GetX1();
239 Double_t yp1 = gPad->GetY1();
240 fX1NDC = (fX1 - xp1) / dpx;
241 fY1NDC = (fY1 - yp1) / dpy;
242 fX2NDC = (fX2 - xp1) / dpx;
243 fY2NDC = (fY2 - yp1) / dpy;
244 return;
245 }
246 gPad->SetCursor(kHand);
247 static Double_t ratio1, ratio2;
248 static Int_t px1old, py1old, px2old, py2old;
249 Double_t temp, xmin, xmax;
250
251 switch (event) {
252
253 case kButton1Down:
254 ratio1 = (gPad->AbsPixeltoY(py) - fY1) / (fY2 - fY1);
255 py1old = gPad->YtoAbsPixel(fY1 + ratio1 * (fY2 - fY1));
256 px1old = plxmin;
257 px2old = plxmax;
258 py2old = py1old;
259 gVirtualX->DrawBox(px1old, py1old, px2old, py2old, TVirtualX::kHollow);
260 gVirtualX->SetLineColor(-1);
261 // No break !!!
262
263 case kButton1Motion:
264 gVirtualX->DrawBox(px1old, py1old, px2old, py2old, TVirtualX::kHollow);
265 ratio2 = (gPad->AbsPixeltoY(py) - fY1) / (fY2 - fY1);
266 py2old = gPad->YtoAbsPixel(fY1 + ratio2 * (fY2 - fY1));
267 gVirtualX->DrawBox(px1old, py1old, px2old, py2old, TVirtualX::kHollow);
268 break;
269
270 case kButton1Up:
271 if (gROOT->IsEscaped()) {
272 gROOT->SetEscape(kFALSE);
273 break;
274 }
275
276 ratio2 = (gPad->AbsPixeltoY(py) - fY1) / (fY2 - fY1);
277 xmin = ratio1;
278 xmax = ratio2;
279 if (xmin > xmax) {
280 temp = xmin;
281 xmin = xmax;
282 xmax = temp;
283 temp = ratio1;
284 ratio1 = ratio2;
285 ratio2 = temp;
286 }
287 if (ratio2 - ratio1 > 0.05) {
288 if (fH) {
289 if (fH->GetDimension() == 2) {
290 Double_t zmin = fH->GetMinimum();
291 Double_t zmax = fH->GetMaximum();
292 if (gPad->GetLogz()) {
293 if (zmin <= 0 && zmax > 0) zmin = TMath::Min((Double_t)1,
294 (Double_t)0.001 * zmax);
295 zmin = TMath::Log10(zmin);
296 zmax = TMath::Log10(zmax);
297 }
298 Double_t newmin = zmin + (zmax - zmin) * ratio1;
299 Double_t newmax = zmin + (zmax - zmin) * ratio2;
300 if (newmin < zmin)newmin = fH->GetBinContent(fH->GetMinimumBin());
301 if (newmax > zmax)newmax = fH->GetBinContent(fH->GetMaximumBin());
302 if (gPad->GetLogz()) {
303 newmin = TMath::Exp(2.302585092994 * newmin);
304 newmax = TMath::Exp(2.302585092994 * newmax);
305 }
306 fH->SetMinimum(newmin);
307 fH->SetMaximum(newmax);
309 }
310 }
311 gPad->Modified(kTRUE);
312 }
313 gVirtualX->SetLineColor(-1);
314 kmode = 0;
315 break;
316 }
317}
318
319
320////////////////////////////////////////////////////////////////////////////////
321/// Returns the color index of the bin (i,j).
322///
323/// This function should be used after an histogram has been plotted with the
324/// option COL or COLZ like in the following example:
325///
326/// h2->Draw("COLZ");
327/// gPad->Update();
328/// TPaletteAxis *palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette");
329/// Int_t ci = palette->GetBinColor(20,15);
330///
331/// Then it is possible to retrieve the RGB components in the following way:
332///
333/// TColor *c = gROOT->GetColor(ci);
334/// float x,y,z;
335/// c->GetRGB(x,y,z);
336
338{
339 if (!fH) return 0;
340 Double_t zc = fH->GetBinContent(i, j);
341 return GetValueColor(zc);
342}
343
344
345////////////////////////////////////////////////////////////////////////////////
346/// Displays the z value corresponding to cursor position py.
347
348char *TPaletteAxis::GetObjectInfo(Int_t /* px */, Int_t py) const
349{
350 Double_t z;
351 static char info[64];
352
353 Double_t zmin = 0.;
354 Double_t zmax = 0.;
355 if (fH) {
356 zmin = fH->GetMinimum();
357 zmax = fH->GetMaximum();
358 }
359 Int_t y1 = gPad->GetWh() - gPad->VtoPixel(fY1NDC);
360 Int_t y2 = gPad->GetWh() - gPad->VtoPixel(fY2NDC);
361 Int_t y = gPad->GetWh() - py;
362
363 if (gPad->GetLogz()) {
364 if (zmin <= 0 && zmax > 0) zmin = TMath::Min((Double_t)1,
365 (Double_t)0.001 * zmax);
366 Double_t zminl = TMath::Log10(zmin);
367 Double_t zmaxl = TMath::Log10(zmax);
368 Double_t zl = (zmaxl - zminl) * ((Double_t)(y - y1) / (Double_t)(y2 - y1)) + zminl;
369 z = TMath::Power(10., zl);
370 } else {
371 z = (zmax - zmin) * ((Double_t)(y - y1) / (Double_t)(y2 - y1)) + zmin;
372 }
373
374 snprintf(info, 64, "(z=%g)", z);
375 return info;
376}
377
378
379////////////////////////////////////////////////////////////////////////////////
380/// Returns the color index of the given z value
381///
382/// This function should be used after an histogram has been plotted with the
383/// option COL or COLZ like in the following example:
384///
385/// h2->Draw("COLZ");
386/// gPad->Update();
387/// TPaletteAxis *palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette");
388/// Int_t ci = palette->GetValueColor(30.);
389///
390/// Then it is possible to retrieve the RGB components in the following way:
391///
392/// TColor *c = gROOT->GetColor(ci);
393/// float x,y,z;
394/// c->GetRGB(x,y,z);
395
397{
398 if (!fH) return 0;
399
402 Double_t wlmin = wmin;
403 Double_t wlmax = wmax;
404
405 if (gPad->GetLogz()) {
406 if (wmin <= 0 && wmax > 0) wmin = TMath::Min((Double_t)1,
407 (Double_t)0.001 * wmax);
408 wlmin = TMath::Log10(wmin);
409 wlmax = TMath::Log10(wmax);
410 }
411
412 Int_t ncolors = gStyle->GetNumberOfColors();
413 Int_t ndivz =0;
414 if (fH) ndivz = fH->GetContour();
415 if (ndivz == 0) return 0;
416 ndivz = TMath::Abs(ndivz);
417 Int_t theColor, color;
418 Double_t scale = ndivz / (wlmax - wlmin);
419
420 if (fH->TestBit(TH1::kUserContour) && gPad->GetLogz()) zc = TMath::Log10(zc);
421 if (zc < wlmin) zc = wlmin;
422
423 color = Int_t(0.01 + (zc - wlmin) * scale);
424
425 theColor = Int_t((color + 0.99) * Double_t(ncolors) / Double_t(ndivz));
426 return gStyle->GetColorPalette(theColor);
427}
428
429
430////////////////////////////////////////////////////////////////////////////////
431/// Paint the palette.
432
434{
436
437 SetFillStyle(1001);
438 Double_t ymin = fY1;
439 Double_t ymax = fY2;
440 Double_t xmin = fX1;
441 Double_t xmax = fX2;
443 if (fH) {
444 wmin = fH->GetMinimum();
445 wmax = fH->GetMaximum();
446 } else {
447 wmin = fAxis.GetWmin();
448 wmax = fAxis.GetWmax();
449 }
450 Double_t wlmin = wmin;
451 Double_t wlmax = wmax;
452 Double_t b1, b2, w1, w2, zc;
453 Bool_t kHorizontal = false;
454
455 if ((wlmax - wlmin) <= 0) {
456 Double_t mz = wlmin * 0.1;
457 if (mz == 0) mz = 0.1;
458 wlmin = wlmin - mz;
459 wlmax = wlmax + mz;
460 wmin = wlmin;
461 wmax = wlmax;
462 }
463
464 if (GetX2NDC()-GetX1NDC() > GetY2NDC()-GetY1NDC()) kHorizontal = true;
465
466 if (gPad->GetLogz()) {
467 if (wmin <= 0 && wmax > 0) wmin = TMath::Min((Double_t)1, (Double_t)0.001 * wmax);
468 wlmin = TMath::Log10(wmin);
469 wlmax = TMath::Log10(wmax);
470 }
471 Double_t ws = wlmax - wlmin;
472 Int_t ncolors = gStyle->GetNumberOfColors();
473 Int_t ndivz;
474 if (fH) ndivz = fH->GetContour();
475 else ndivz = ncolors;
476 if (ndivz == 0) return;
477 ndivz = TMath::Abs(ndivz);
478 Int_t theColor, color;
479 // import Attributes already here since we might need them for CJUST
480 if (fH && fH->GetDimension() == 2) {
482 TString ztit = fAxis.GetTitle();
483 if (ztit.Index(";")>0) {
484 ztit.Remove(ztit.Index(";"),ztit.Length());
485 fAxis.SetTitle(ztit.Data());
486 }
487 }
488 // the 3D histogram's title is stored in Zaxis
489 if (fH && fH->GetDimension() > 2) {
490 TString ztit = fH->GetZaxis()->GetTitle();
491 fAxis.SetTitle("");
492 if (ztit.Index(";")>0) {
493 ztit.Remove(0,ztit.Index(";")+1);
494 fAxis.SetTitle(ztit.Data());
495 }
496 }
497 // case option "CJUST": put labels directly at color boundaries
498 TLatex *label = nullptr;
499 TLine *line = nullptr;
500 Double_t prevlab = 0;
501 if (fH) {
502 TString opt(fH->GetDrawOption());
503 if (opt.Contains("CJUST", TString::kIgnoreCase)) {
504 label = new TLatex();
507 if (kHorizontal) label->SetTextAlign(kHAlignCenter+kVAlignTop);
509 line = new TLine();
511 if (kHorizontal) line->PaintLine(xmin, ymin, xmax, ymin);
512 else line->PaintLine(xmax, ymin, xmax, ymax);
513 }
514 }
515 Double_t scale = ndivz / (wlmax - wlmin);
516 Double_t dw = (wlmax - wlmin) / ndivz;
517 for (Int_t i = 0; i < ndivz; i++) {
518
519 if (fH) zc = fH->GetContourLevel(i);
520 else zc = wlmin + i*dw;
521 if (fH && fH->TestBit(TH1::kUserContour) && gPad->GetLogz())
522 zc = TMath::Log10(zc);
523 w1 = zc;
524 if (w1 < wlmin) w1 = wlmin;
525
526 w2 = wlmax;
527 if (i < ndivz - 1) {
528 if (fH) zc = fH->GetContourLevel(i + 1);
529 else zc = wlmin + (i+1)*dw;
530 if (fH && fH->TestBit(TH1::kUserContour) && gPad->GetLogz())
531 zc = TMath::Log10(zc);
532 w2 = zc;
533 }
534
535 if (w2 <= wlmin) continue;
536 if (kHorizontal) {
537 b1 = xmin + (w1 - wlmin) * (xmax - xmin) / ws;
538 b2 = xmin + (w2 - wlmin) * (xmax - xmin) / ws;
539 } else {
540 b1 = ymin + (w1 - wlmin) * (ymax - ymin) / ws;
541 b2 = ymin + (w2 - wlmin) * (ymax - ymin) / ws;
542 }
543
544 if (fH && fH->TestBit(TH1::kUserContour)) {
545 color = i;
546 } else {
547 color = Int_t(0.01 + (w1 - wlmin) * scale);
548 }
549
550 theColor = Int_t((color + 0.99) * Double_t(ncolors) / Double_t(ndivz));
553 if (kHorizontal) gPad->PaintBox(b1, ymin, b2, ymax);
554 else gPad->PaintBox(xmin, b1, xmax, b2);
555 // case option "CJUST": put labels directly
556 if (fH && label) {
557 Double_t lof = fAxis.GetLabelOffset()*(gPad->GetUxmax()-gPad->GetUxmin());
558 // the following assumes option "S"
559 Double_t tlength = fAxis.GetTickSize() * (gPad->GetUxmax()-gPad->GetUxmin());
560 Double_t lsize = fAxis.GetLabelSize();
561 Double_t lsize_user = lsize*(gPad->GetUymax()-gPad->GetUymin());
562 Double_t zlab = fH->GetContourLevel(i);
563 if (gPad->GetLogz()&& !fH->TestBit(TH1::kUserContour)) {
564 zlab = TMath::Power(10, zlab);
565 }
566 // make sure labels dont overlap
567 if (i == 0 || (b1 - prevlab) > 1.5*lsize_user) {
568 if (kHorizontal) label->PaintLatex(b1, ymin - lof, 0, lsize, TString::Format("%g", zlab));
569 else label->PaintLatex(xmax + lof, b1, 0, lsize, TString::Format("%g", zlab));
570 prevlab = b1;
571 }
572 if (kHorizontal) line->PaintLine(b2, ymin+tlength, b2, ymin);
573 else line->PaintLine(xmax-tlength, b1, xmax, b1);
574 if (i == ndivz-1) {
575 // label + tick at top of axis
576 if (fH && (b2 - prevlab > 1.5*lsize_user)) {
577 if (kHorizontal) label->PaintLatex(b2, ymin - lof, 0, lsize, TString::Format("%g",fH->GetMaximum()));
578 else label->PaintLatex(xmax + lof, b2, 0, lsize, TString::Format("%g",fH->GetMaximum()));
579 }
580 if (kHorizontal) line->PaintLine(b1, ymin+tlength, b1, ymin);
581 else line->PaintLine(xmax-tlength, b2, xmax, b2);
582 }
583 }
584 }
585
586 // Take primary divisions only
587 Int_t ndiv;
588 if (fH) ndiv = fH->GetZaxis()->GetNdivisions();
589 else ndiv = fAxis.GetNdiv();
590 Bool_t isOptimized = ndiv>0;
591 Int_t absDiv = abs(ndiv);
592 Int_t maxD = absDiv/1000000;
593 ndiv = absDiv%100 + maxD*1000000;
594 if (!isOptimized) ndiv = -ndiv;
595
596 char chopt[6] = "S ";
597 chopt[1] = 0;
598 strncat(chopt, "+L", 3);
599 if (ndiv < 0) {
600 ndiv = TMath::Abs(ndiv);
601 strncat(chopt, "N", 2);
602 }
603 if (gPad->GetLogz()) {
604 wmin = TMath::Power(10., wlmin);
605 wmax = TMath::Power(10., wlmax);
606 strncat(chopt, "G", 2);
607 }
608 if (label) {
609 // case option "CJUST", cleanup
610 delete label;
611 delete line;
612 } else {
613 // default
614 if (kHorizontal) fAxis.PaintAxis(xmin, ymin, xmax, ymin, wmin, wmax, ndiv, chopt);
615 else fAxis.PaintAxis(xmax, ymin, xmax, ymax, wmin, wmax, ndiv, chopt);
616 }
617}
618
619
620////////////////////////////////////////////////////////////////////////////////
621/// Save primitive as a C++ statement(s) on output stream out.
622
623void TPaletteAxis::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
624{
625 if (!fH) return;
626
627 char quote = '"';
628
629 out << " " << std::endl;
630 if (gROOT->ClassSaved(TPaletteAxis::Class())) {
631 out << " ";
632 } else {
633 out << " " << ClassName() << " *";
634 }
635 if (fOption.Contains("NDC")) {
636 out << "palette = new " << ClassName() << "(" << fX1NDC << "," << fY1NDC << "," << fX2NDC << "," << fY2NDC
637 << "," << fH->GetName() << ");" << std::endl;
638 } else {
639 out << "palette = new " << ClassName() << "(" << fX1 << "," << fY1 << "," << fX2 << "," << fY2
640 << "," << fH->GetName() << ");" << std::endl;
641 }
642 out << " palette->SetNdivisions(" << fH->GetZaxis()->GetNdivisions() << ");" << std::endl;
643 out << " palette->SetAxisColor(" << fH->GetZaxis()->GetAxisColor() << ");" << std::endl;
644 out << " palette->SetLabelColor(" << fH->GetZaxis()->GetLabelColor() << ");" << std::endl;
645 out << " palette->SetLabelFont(" << fH->GetZaxis()->GetLabelFont() << ");" << std::endl;
646 out << " palette->SetLabelOffset(" << fH->GetZaxis()->GetLabelOffset() << ");" << std::endl;
647 out << " palette->SetLabelSize(" << fH->GetZaxis()->GetLabelSize() << ");" << std::endl;
648 out << " palette->SetMaxDigits(" << fH->GetZaxis()->GetMaxDigits() << ");" << std::endl;
649 out << " palette->SetTickLength(" << fH->GetZaxis()->GetTickLength() << ");" << std::endl;
650 out << " palette->SetTitleOffset(" << fH->GetZaxis()->GetTitleOffset() << ");" << std::endl;
651 out << " palette->SetTitleSize(" << fH->GetZaxis()->GetTitleSize() << ");" << std::endl;
652 out << " palette->SetTitleColor(" << fH->GetZaxis()->GetTitleColor() << ");" << std::endl;
653 out << " palette->SetTitleFont(" << fH->GetZaxis()->GetTitleFont() << ");" << std::endl;
654 out << " palette->SetTitle(" << quote << fH->GetZaxis()->GetTitle() << quote << ");" << std::endl;
655 SaveFillAttributes(out, "palette", -1, -1);
656 SaveLineAttributes(out, "palette", 1, 1, 1);
657}
658
659
660////////////////////////////////////////////////////////////////////////////////
661/// Unzoom the palette
662
664{
665 if (!fH) return;
666 TView *view = gPad ? gPad->GetView() : nullptr;
667 if (view) {
668 delete view;
669 gPad->SetView(nullptr);
670 }
671 fH->GetZaxis()->SetRange(0, 0);
672 if (fH->GetDimension() == 2) {
673 fH->SetMinimum();
674 fH->SetMaximum();
676 }
677}
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
@ kButton1Down
Definition Buttons.h:17
@ kHand
Definition GuiTypes.h:374
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
@ kVAlignTop
Definition TAttText.h:54
@ kVAlignCenter
Definition TAttText.h:54
@ kHAlignLeft
Definition TAttText.h:53
@ kHAlignCenter
Definition TAttText.h:53
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 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:406
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
#define gPad
#define gVirtualX
Definition TVirtualX.h:337
#define snprintf
Definition civetweb.c:1540
virtual Color_t GetTitleColor() const
Definition TAttAxis.h:46
virtual Color_t GetLabelColor() const
Definition TAttAxis.h:38
virtual Int_t GetNdivisions() const
Definition TAttAxis.h:36
virtual Color_t GetAxisColor() const
Definition TAttAxis.h:37
virtual Style_t GetTitleFont() const
Definition TAttAxis.h:47
virtual Float_t GetLabelOffset() const
Definition TAttAxis.h:40
virtual Int_t GetMaxDigits() const
Definition TAttAxis.h:42
virtual Style_t GetLabelFont() const
Definition TAttAxis.h:39
virtual Float_t GetTitleSize() const
Definition TAttAxis.h:44
virtual Float_t GetLabelSize() const
Definition TAttAxis.h:41
virtual Float_t GetTickLength() const
Definition TAttAxis.h:45
virtual Float_t GetTitleOffset() const
Definition TAttAxis.h:43
virtual void Modify()
Change current fill area attributes if necessary.
Definition TAttFill.cxx:216
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:239
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:33
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
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:275
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:42
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:44
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition TAttText.h:46
Class to manage histogram axis.
Definition TAxis.h:31
const char * GetTitle() const override
Returns title of object.
Definition TAxis.h:135
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis using bin numbers.
Definition TAxis.cxx:1052
Double_t fX1
X of 1st point.
Definition TBox.h:28
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TBox.cxx:232
Double_t fY2
Y of 2nd point.
Definition TBox.h:31
Double_t fX2
X of 2nd point.
Definition TBox.h:30
Double_t fY1
Y of 1st point.
Definition TBox.h:29
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:1008
Double_t GetWmin() const
Definition TGaxis.h:89
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition TGaxis.cxx:2942
Float_t GetLabelOffset() const
Definition TGaxis.h:80
virtual void ImportAxisAttributes(TAxis *axis)
Internal method to import TAxis attributes to this TGaxis.
Definition TGaxis.cxx:955
Int_t GetLabelFont() const
Definition TGaxis.h:79
const char * GetTitle() const override
Returns title of object.
Definition TGaxis.h:86
void SetWmax(Double_t wmax)
Definition TGaxis.h:133
Int_t GetLabelColor() const
Definition TGaxis.h:78
Float_t GetTickSize() const
Definition TGaxis.h:91
void SetWmin(Double_t wmin)
Definition TGaxis.h:132
Int_t GetNdiv() const
Definition TGaxis.h:88
Double_t GetWmax() const
Definition TGaxis.h:90
Float_t GetLabelSize() const
Definition TGaxis.h:81
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
TAxis * GetZaxis()
Definition TH1.h:326
virtual Int_t GetDimension() const
Definition TH1.h:283
@ kUserContour
User specified contour levels.
Definition TH1.h:166
@ kIsZoomed
Bit set when zooming on Y axis.
Definition TH1.h:169
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:8509
virtual void SetMaximum(Double_t maximum=-1111)
Definition TH1.h:403
virtual void SetMinimum(Double_t minimum=-1111)
Definition TH1.h:404
virtual Int_t GetMaximumBin() const
Return location of bin with maximum value in the range.
Definition TH1.cxx:8541
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition TH1.cxx:5025
virtual Int_t GetContour(Double_t *levels=nullptr)
Return contour values into array levels if pointer levels is non zero.
Definition TH1.cxx:8375
virtual Double_t GetContourLevel(Int_t level) const
Return value of contour number level.
Definition TH1.cxx:8394
virtual Int_t GetMinimumBin() const
Return location of bin with minimum value in the range.
Definition TH1.cxx:8629
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:8599
To draw Mathematical Formula.
Definition TLatex.h:18
virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Main drawing function.
Definition TLatex.cxx:2114
Use the TLine constructor to create a simple line.
Definition TLine.h:22
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition TLine.cxx:399
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:201
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:207
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition TObject.cxx:423
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:780
void ResetBit(UInt_t f)
Definition TObject.h:200
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.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Check if mouse on the axis region.
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:62
virtual void ConvertNDCtoPad()
Convert pave coordinates from NDC to Pad coordinates.
Definition TPave.cxx:139
Double_t GetX2NDC() const
Definition TPave.h:60
void Copy(TObject &pave) const override
Copy this pave to pave.
Definition TPave.cxx:186
virtual void SetName(const char *name="")
Definition TPave.h:79
Double_t fX2NDC
X2 point in NDC coordinates.
Definition TPave.h:24
Double_t GetY1NDC() const
Definition TPave.h:61
TString fOption
Pave style.
Definition TPave.h:30
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:208
Double_t fX1NDC
X1 point in NDC coordinates.
Definition TPave.h:22
Double_t fY1NDC
Y1 point in NDC coordinates.
Definition TPave.h:23
Double_t GetX1NDC() const
Definition TPave.h:59
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
const char * Data() const
Definition TString.h:376
@ kIgnoreCase
Definition TString.h:277
TString & Remove(Ssiz_t pos)
Definition TString.h:685
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:2378
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:651
Int_t GetColorPalette(Int_t i) const
Return color number i in current palette.
Definition TStyle.cxx:1097
Int_t GetNumberOfColors() const
Return number of colors in the color palette.
Definition TStyle.cxx:1171
See TView3D.
Definition TView.h:25
virtual void SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)=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:709
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:721
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:762
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123