From 7414f4e5c7d355b8c0fe00b280ec634c93f396be Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Mon, 3 Nov 2025 07:55:50 +0100 Subject: [PATCH] Implement TAnnotation::SavePrimitive Was stored before as TLatex object with Z coordinate --- graf2d/gpad/inc/TAnnotation.h | 1 + graf2d/gpad/src/TAnnotation.cxx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/graf2d/gpad/inc/TAnnotation.h b/graf2d/gpad/inc/TAnnotation.h index 62786c441860a..3311822405dda 100644 --- a/graf2d/gpad/inc/TAnnotation.h +++ b/graf2d/gpad/inc/TAnnotation.h @@ -30,6 +30,7 @@ class TAnnotation : public TLatex { void Paint(Option_t *option="") override; void PaintAnnotation(Double_t x, Double_t y, Double_t z, Double_t angle, Double_t size, const Char_t *text); void Print(Option_t *option="") const override; + void SavePrimitive(std::ostream &out, Option_t *option = "") override; void SetZ(double z) { fZ = z; } // *MENU* double GetZ() const { return fZ; } diff --git a/graf2d/gpad/src/TAnnotation.cxx b/graf2d/gpad/src/TAnnotation.cxx index 644d68cd05f90..6075b5a38f2f6 100644 --- a/graf2d/gpad/src/TAnnotation.cxx +++ b/graf2d/gpad/src/TAnnotation.cxx @@ -131,3 +131,21 @@ void TAnnotation::Print(Option_t *) const if (GetTextAngle() != 0 ) printf(" Angle=%f",GetTextAngle()); printf("\n"); } + +//////////////////////////////////////////////////////////////////////////////// +/// Save primitives in this pad on the C++ source file out. + +void TAnnotation::SavePrimitive(std::ostream &out, Option_t *option) +{ + SavePrimitiveConstructor( + out, Class(), "annotation", + TString::Format("%g, %g, %g, \"%s\"", fX, fY, fZ, TString(GetTitle()).ReplaceSpecialCppChars().Data()), kFALSE); + + SaveTextAttributes(out, "annotation", 11, 0, 1, 62, 0.05); + SaveLineAttributes(out, "annotation", 1, 1, 1); + + if (TestBit(kTextNDC)) + out << " annotation->SetNDC();\n"; + + SavePrimitiveDraw(out, "annotation", option); +}