Skip to content

Commit 255a367

Browse files
committed
Save histogram in TMultiGraph::SavePrimitive
Like in TGraph, store histogram which used for axis painting. Resolves problem that GetHistogram or GetAxis methods force recreation of histogram object and updating the pad.
1 parent 3c57749 commit 255a367

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

hist/hist/src/TMultiGraph.cxx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,8 @@ void TMultiGraph::RecursiveRemove(TObject *obj)
15941594

15951595
void TMultiGraph::SavePrimitive(std::ostream &out, Option_t *option)
15961596
{
1597+
thread_local Int_t frameNumber = 0;
1598+
15971599
SavePrimitiveConstructor(out, Class(), "multigraph");
15981600
SavePrimitiveNameTitle(out, "multigraph");
15991601

@@ -1602,21 +1604,22 @@ void TMultiGraph::SavePrimitive(std::ostream &out, Option_t *option)
16021604
while (auto g = iter())
16031605
g->SavePrimitive(out, TString::Format("multigraph%s", iter.GetOption()).Data());
16041606

1607+
if (fHistogram) {
1608+
TString hname = fHistogram->GetName();
1609+
fHistogram->SetName(TString::Format("MGraph_histogram%d", ++frameNumber).Data());
1610+
fHistogram->SavePrimitive(out, "nodraw");
1611+
out << " " << fHistogram->GetName() << "->GetXaxis()->SetLimits(" << fHistogram->GetXaxis()->GetXmin() << ", " << fHistogram->GetXaxis()->GetXmax() << ");\n";
1612+
out << " multigraph->SetHistogram(" << fHistogram->GetName() << ");\n";
1613+
out << " \n";
1614+
fHistogram->SetName(hname.Data());
1615+
}
1616+
16051617
const char *l = strstr(option, "th2poly");
16061618
if (l)
16071619
out << " " << l + 7 << "->AddBin(multigraph);\n";
16081620
else
16091621
SavePrimitiveDraw(out, "multigraph", option);
16101622

1611-
TAxis *xaxis = GetXaxis();
1612-
TAxis *yaxis = GetYaxis();
1613-
1614-
if (xaxis) {
1615-
out << " multigraph->GetXaxis()->SetLimits(" << xaxis->GetXmin() << ", " << xaxis->GetXmax() << ");\n";
1616-
xaxis->SaveAttributes(out, "multigraph", "->GetXaxis()");
1617-
}
1618-
if (yaxis)
1619-
yaxis->SaveAttributes(out, "multigraph", "->GetYaxis()");
16201623
if (fMinimum != -1111)
16211624
out << " multigraph->SetMinimum(" << fMinimum << ");\n";
16221625
if (fMaximum != -1111)

0 commit comments

Comments
 (0)