1616#include < cstdlib>
1717#include < cstring>
1818#include < cctype>
19+ #include < cmath>
1920#include < fstream>
2021
2122#include " TROOT.h"
3233
3334Int_t TSVG::fgLineJoin = 0 ;
3435Int_t TSVG::fgLineCap = 0 ;
35-
36+ Bool_t TSVG::fgCompact = kFALSE ;
3637
3738/* * \class TSVG
3839\ingroup PS
@@ -1512,6 +1513,9 @@ void TSVG::Initialize()
15121513 PrintStr (" @" );
15131514 PrintStr (" </title>@" );
15141515
1516+ if (fgCompact)
1517+ return ;
1518+
15151519 // Description
15161520 PrintStr (" <desc>@" );
15171521 PrintFast (22 ," Creator: ROOT Version " );
@@ -1533,6 +1537,18 @@ void TSVG::Initialize()
15331537
15341538}
15351539
1540+ // //////////////////////////////////////////////////////////////////////////////
1541+ // / Write real value into output stream
1542+ // / In compact form only integer value will be written
1543+
1544+ void TSVG::WriteReal (Float_t r, Bool_t space)
1545+ {
1546+ if (fgCompact)
1547+ TVirtualPS::WriteInteger (std::lround (r), space);
1548+ else
1549+ TVirtualPS::WriteReal (r, space);
1550+ }
1551+
15361552// //////////////////////////////////////////////////////////////////////////////
15371553// / Move to a new position (ix, iy). The move is done in relative coordinates
15381554// / which allows to have short numbers which decrease the size of the file.
@@ -2064,3 +2080,22 @@ void TSVG::DrawPS(Int_t, Float_t *, Float_t *)
20642080{
20652081 Warning (" TSVG::DrawPS" , " not yet implemented" );
20662082}
2083+
2084+ // //////////////////////////////////////////////////////////////////////////////
2085+ // / Set compact mode for svg output
2086+ // / If enabled - discards creation of <desc> and <defs> section in the SVG file
2087+ // / Also all float values will be rounded to nearest integer values
2088+ // / Produced SVG file potentially can have artifacts but let create much smaller SVG files
2089+
2090+ void TSVG::SetCompact (Bool_t on)
2091+ {
2092+ fgCompact = on;
2093+ }
2094+
2095+ // //////////////////////////////////////////////////////////////////////////////
2096+ // / Returns compact mode for svg output
2097+
2098+ Bool_t TSVG::IsCompact ()
2099+ {
2100+ return fgCompact;
2101+ }
0 commit comments