@@ -120,7 +120,7 @@ End_Macro
120
120
121
121
TPaletteAxis::TPaletteAxis (): TPave()
122
122
{
123
- fH = nullptr ;
123
+ fH = nullptr ;
124
124
SetName (" " );
125
125
}
126
126
@@ -132,6 +132,7 @@ TPaletteAxis::TPaletteAxis(Double_t x1, Double_t y1, Double_t x2, Double_t y2,
132
132
: TPave(x1, y1, x2, y2)
133
133
{
134
134
fH = h;
135
+ if (!fH ) return ;
135
136
SetName (" palette" );
136
137
TAxis *zaxis = fH ->GetZaxis ();
137
138
fAxis .ImportAxisAttributes (zaxis);
@@ -259,26 +260,28 @@ void TPaletteAxis::ExecuteEvent(Int_t event, Int_t px, Int_t py)
259
260
ratio2 = temp;
260
261
}
261
262
if (ratio2 - ratio1 > 0.05 ) {
262
- if (fH ->GetDimension () == 2 ) {
263
- Double_t zmin = fH ->GetMinimum ();
264
- Double_t zmax = fH ->GetMaximum ();
265
- if (gPad ->GetLogz ()) {
266
- if (zmin <= 0 && zmax > 0 ) zmin = TMath::Min ((Double_t)1 ,
267
- (Double_t)0.001 * zmax);
268
- zmin = TMath::Log10 (zmin);
269
- zmax = TMath::Log10 (zmax);
263
+ if (fH ) {
264
+ if (fH ->GetDimension () == 2 ) {
265
+ Double_t zmin = fH ->GetMinimum ();
266
+ Double_t zmax = fH ->GetMaximum ();
267
+ if (gPad ->GetLogz ()) {
268
+ if (zmin <= 0 && zmax > 0 ) zmin = TMath::Min ((Double_t)1 ,
269
+ (Double_t)0.001 * zmax);
270
+ zmin = TMath::Log10 (zmin);
271
+ zmax = TMath::Log10 (zmax);
272
+ }
273
+ Double_t newmin = zmin + (zmax - zmin) * ratio1;
274
+ Double_t newmax = zmin + (zmax - zmin) * ratio2;
275
+ if (newmin < zmin)newmin = fH ->GetBinContent (fH ->GetMinimumBin ());
276
+ if (newmax > zmax)newmax = fH ->GetBinContent (fH ->GetMaximumBin ());
277
+ if (gPad ->GetLogz ()) {
278
+ newmin = TMath::Exp (2.302585092994 * newmin);
279
+ newmax = TMath::Exp (2.302585092994 * newmax);
280
+ }
281
+ fH ->SetMinimum (newmin);
282
+ fH ->SetMaximum (newmax);
283
+ fH ->SetBit (TH1::kIsZoomed );
270
284
}
271
- Double_t newmin = zmin + (zmax - zmin) * ratio1;
272
- Double_t newmax = zmin + (zmax - zmin) * ratio2;
273
- if (newmin < zmin)newmin = fH ->GetBinContent (fH ->GetMinimumBin ());
274
- if (newmax > zmax)newmax = fH ->GetBinContent (fH ->GetMaximumBin ());
275
- if (gPad ->GetLogz ()) {
276
- newmin = TMath::Exp (2.302585092994 * newmin);
277
- newmax = TMath::Exp (2.302585092994 * newmax);
278
- }
279
- fH ->SetMinimum (newmin);
280
- fH ->SetMaximum (newmax);
281
- fH ->SetBit (TH1::kIsZoomed );
282
285
}
283
286
gPad ->Modified (kTRUE );
284
287
}
@@ -308,6 +311,7 @@ void TPaletteAxis::ExecuteEvent(Int_t event, Int_t px, Int_t py)
308
311
309
312
Int_t TPaletteAxis::GetBinColor (Int_t i, Int_t j)
310
313
{
314
+ if (!fH ) return 0 ;
311
315
Double_t zc = fH ->GetBinContent (i, j);
312
316
return GetValueColor (zc);
313
317
}
@@ -321,8 +325,12 @@ char *TPaletteAxis::GetObjectInfo(Int_t /* px */, Int_t py) const
321
325
Double_t z;
322
326
static char info[64 ];
323
327
324
- Double_t zmin = fH ->GetMinimum ();
325
- Double_t zmax = fH ->GetMaximum ();
328
+ Double_t zmin = 0 .;
329
+ Double_t zmax = 0 .;
330
+ if (fH ) {
331
+ zmin = fH ->GetMinimum ();
332
+ zmax = fH ->GetMaximum ();
333
+ }
326
334
Int_t y1 = gPad ->GetWh () - gPad ->VtoPixel (fY1NDC );
327
335
Int_t y2 = gPad ->GetWh () - gPad ->VtoPixel (fY2NDC );
328
336
Int_t y = gPad ->GetWh () - py;
@@ -362,6 +370,8 @@ char *TPaletteAxis::GetObjectInfo(Int_t /* px */, Int_t py) const
362
370
363
371
Int_t TPaletteAxis::GetValueColor (Double_t zc)
364
372
{
373
+ if (!fH ) return 0 ;
374
+
365
375
Double_t wmin = fH ->GetMinimum ();
366
376
Double_t wmax = fH ->GetMaximum ();
367
377
Double_t wlmin = wmin;
@@ -375,7 +385,8 @@ Int_t TPaletteAxis::GetValueColor(Double_t zc)
375
385
}
376
386
377
387
Int_t ncolors = gStyle ->GetNumberOfColors ();
378
- Int_t ndivz = fH ->GetContour ();
388
+ Int_t ndivz =0 ;
389
+ if (fH ) ndivz = fH ->GetContour ();
379
390
if (ndivz == 0 ) return 0 ;
380
391
ndivz = TMath::Abs (ndivz);
381
392
Int_t theColor, color;
@@ -396,6 +407,9 @@ Int_t TPaletteAxis::GetValueColor(Double_t zc)
396
407
397
408
void TPaletteAxis::Paint (Option_t *)
398
409
{
410
+
411
+ if (!fH ) return ;
412
+
399
413
ConvertNDCtoPad ();
400
414
401
415
SetFillStyle (1001 );
@@ -555,7 +569,10 @@ void TPaletteAxis::Paint(Option_t *)
555
569
556
570
void TPaletteAxis::SavePrimitive (std::ostream &out, Option_t * /* = ""*/ )
557
571
{
558
- // char quote = '"';
572
+ if (!fH ) return ;
573
+
574
+ char quote = ' "' ;
575
+
559
576
out << " " << std::endl;
560
577
if (gROOT ->ClassSaved (TPaletteAxis::Class ())) {
561
578
out << " " ;
@@ -569,12 +586,19 @@ void TPaletteAxis::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
569
586
out << " palette = new " << ClassName () << " (" << fX1 << " ," << fY1 << " ," << fX2 << " ," << fY2
570
587
<< " ," << fH ->GetName () << " );" << std::endl;
571
588
}
572
- out << " palette->SetLabelColor(" << fAxis .GetLabelColor () << " );" << std::endl;
573
- out << " palette->SetLabelFont(" << fAxis .GetLabelFont () << " );" << std::endl;
574
- out << " palette->SetLabelOffset(" << fAxis .GetLabelOffset () << " );" << std::endl;
575
- out << " palette->SetLabelSize(" << fAxis .GetLabelSize () << " );" << std::endl;
576
- out << " palette->SetTitleOffset(" << fAxis .GetTitleOffset () << " );" << std::endl;
577
- out << " palette->SetTitleSize(" << fAxis .GetTitleSize () << " );" << std::endl;
589
+ out << " palette->SetNdivisions(" << fH ->GetZaxis ()->GetNdivisions () << " );" << std::endl;
590
+ out << " palette->SetAxisColor(" << fH ->GetZaxis ()->GetAxisColor () << " );" << std::endl;
591
+ out << " palette->SetLabelColor(" << fH ->GetZaxis ()->GetLabelColor () << " );" << std::endl;
592
+ out << " palette->SetLabelFont(" << fH ->GetZaxis ()->GetLabelFont () << " );" << std::endl;
593
+ out << " palette->SetLabelOffset(" << fH ->GetZaxis ()->GetLabelOffset () << " );" << std::endl;
594
+ out << " palette->SetLabelSize(" << fH ->GetZaxis ()->GetLabelSize () << " );" << std::endl;
595
+ out << " palette->SetMaxDigits(" << fH ->GetZaxis ()->GetMaxDigits () << " );" << std::endl;
596
+ out << " palette->SetTickLength(" << fH ->GetZaxis ()->GetTickLength () << " );" << std::endl;
597
+ out << " palette->SetTitleOffset(" << fH ->GetZaxis ()->GetTitleOffset () << " );" << std::endl;
598
+ out << " palette->SetTitleSize(" << fH ->GetZaxis ()->GetTitleSize () << " );" << std::endl;
599
+ out << " palette->SetTitleColor(" << fH ->GetZaxis ()->GetTitleColor () << " );" << std::endl;
600
+ out << " palette->SetTitleFont(" << fH ->GetZaxis ()->GetTitleFont () << " );" << std::endl;
601
+ out << " palette->SetTitle(" << quote << fH ->GetZaxis ()->GetTitle () << quote << " );" << std::endl;
578
602
SaveFillAttributes (out, " palette" , -1 , -1 );
579
603
SaveLineAttributes (out, " palette" , 1 , 1 , 1 );
580
604
}
@@ -585,6 +609,7 @@ void TPaletteAxis::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
585
609
586
610
void TPaletteAxis::UnZoom ()
587
611
{
612
+ if (!fH ) return ;
588
613
TView *view = gPad ? gPad ->GetView () : nullptr ;
589
614
if (view) {
590
615
delete view;
0 commit comments