Skip to content

Commit 38c45cd

Browse files
committed
Add custom stats and palette test to stressGraphics
To be sure that such modifications reliably works
1 parent c950eca commit 38c45cd

File tree

6 files changed

+1169
-1
lines changed

6 files changed

+1169
-1
lines changed

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ ROOT_ADD_TEST(test-stresslinear-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${
162162

163163
#--stressGraphics------------------------------------------------------------------------------------
164164
if(ROOT_opengl_FOUND AND TARGET TreeViewer)
165-
ROOT_EXECUTABLE(stressGraphics stressGraphics.cxx LIBRARIES Graf Gpad Postscript TreeViewer)
165+
ROOT_EXECUTABLE(stressGraphics stressGraphics.cxx LIBRARIES Graf Gpad Postscript TreeViewer HistPainter)
166166
if(MSVC)
167167
set_property(TARGET stressGraphics APPEND_STRING PROPERTY LINK_FLAGS "/STACK:4000000")
168168
endif()

test/stressGraphics.cxx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
#include "TAnnotation.h"
9090
#include "TRatioPlot.h"
9191
#include "TGaxis.h"
92+
#include "TPaletteAxis.h"
9293
#include "TSpline.h"
9394
#include "TPolyMarker.h"
9495
#include "TScatter.h"
@@ -2082,6 +2083,54 @@ void th2_custom_axis_labels()
20822083
}
20832084

20842085

2086+
////////////////////////////////////////////////////////////////////////////////
2087+
/// Test editing of stats and palette attributes
2088+
2089+
void th2_stats_palette_edit()
2090+
{
2091+
auto C = StartTest(600, 600);
2092+
2093+
gStyle->SetOptStat();
2094+
2095+
auto hist = new TH2F("th2_stats_palette", "Modify histogram stats and palette", 40, -4, 4, 40, -20, 20);
2096+
TRandom3 rnr;
2097+
2098+
float px, py;
2099+
for (int i = 0; i < 25000; i++) {
2100+
rnr.Rannor(px,py);
2101+
hist->Fill(px,5*py);
2102+
}
2103+
2104+
C->SetRightMargin(0.18);
2105+
auto palette = new TPaletteAxis(4.3, -18, 4.8, 10, hist);
2106+
hist->GetListOfFunctions()->Add(palette);
2107+
2108+
C->Add(hist, "colz");
2109+
2110+
C->Update();
2111+
2112+
TPaveStats *ps = (TPaveStats*)C->GetPrimitive("stats");
2113+
ps->SetName("mystats");
2114+
TList *listOfLines = ps->GetListOfLines();
2115+
2116+
// Remove the RMS line
2117+
while (auto tconst = ps->GetLineWith("Dev"))
2118+
listOfLines->Remove(tconst);
2119+
2120+
// Add a new line in the stat box.
2121+
// Note that "=" is a control character
2122+
TLatex *myt = new TLatex(0,0, "Test = 10");
2123+
myt ->SetTextFont(42);
2124+
myt ->SetTextSize(0.04);
2125+
myt ->SetTextColor(kRed);
2126+
listOfLines->Add(myt);
2127+
2128+
// the following line is needed to avoid that the automatic redrawing of stats
2129+
hist->SetStats(0);
2130+
2131+
TestReport(C, "TH2 with modified palette and stats", "", 0, "th2_stats_palette_edit");
2132+
}
2133+
20852134
////////////////////////////////////////////////////////////////////////////////
20862135
/// TEllipse test.
20872136

@@ -4360,6 +4409,7 @@ void stressGraphics(Int_t verbose = 0, Bool_t generate = kFALSE, Bool_t keep_fil
43604409
th2_candle ();
43614410
th2_violin ();
43624411
th2_custom_axis_labels();
4412+
th2_stats_palette_edit();
43634413
tellipse ();
43644414
feynman ();
43654415
ratioplot ();

test/stressGraphics.ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Test# PS1Ref# PS1Err# PDFRef# PDFErr# JPGRef# JPGErr# PNGRef# PN
3333
23 113353 1000 71394 500 136880 40000 51345 20000 115314 1000
3434
23 73316 500 84161 500 85037 20000 34733 15000 73223 500
3535
24 4878 600 14375 100 17419 5000 11709 1800 5770 600
36+
24 27107 300 19227 300 30587 14000 16531 7000 27039 500
3637
25 4131 40 15272 100 34038 2500 12258 1400 4162 40
3738
26 7813 300 23840 150 11085 6000 6973 3100 8081 300
3839
27 19418 150 21141 300 14104 14800 7386 2800 14493 150

test/stressGraphics_builtinzlib.ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Test# PS1Ref# PS1Err# PDFRef# PDFErr# JPGRef# JPGErr# PNGRef# PN
3333
23 113353 1000 71394 500 136880 40000 51345 20000 115314 1000
3434
23 73316 500 84161 500 85037 20000 34733 15000 73223 500
3535
24 4878 600 14375 100 17419 5000 11709 1800 5770 600
36+
24 27107 300 19227 300 30587 14000 16531 7000 27039 500
3637
25 4130 40 15193 50 34790 2500 12156 1400 4161 40
3738
26 7825 300 23672 100 11087 6000 7008 3100 8097 300
3839
27 19420 150 21350 300 13257 14800 6444 2800 14424 150

test/stressGraphics_web.ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Test# SVG1Ref# SVG1Err# PDFRef# PDFErr# JPGRef# JPGErr# PNGRef# PN
3333
23 85700 200 196500 1500 375000 120000 138091 30000 85800 200
3434
23 42606 100 112200 1500 220000 70000 78079 20000 42622 100
3535
24 5830 50 10700 400 42000 10000 35922 11000 5850 100
36+
24 15010 50 34603 500 84000 25000 40859 15000 15010 50
3637
25 2572 50 9271 50 109238 42213 49000 17000 2572 50
3738
26 16403 50 25282 50 25505 3408 23000 8000 16403 50
3839
27 23949 118 26549 349 27746 3988 17000 4000 19192 112

0 commit comments

Comments
 (0)