13#pragma optimize("",off)
116 Warning(
"Open",
"SVG file already open");
130 ww *=
gPad->GetWNDC();
131 wh *=
gPad->GetHNDC();
135 if (yrange >
fYsize) { yrange =
fYsize; xrange = yrange/ratio;}
140 fStream =
new std::ofstream(fname,std::ios::out);
142 printf(
"ERROR in TSVG::Open: Cannot open file:%s\n",fname);
193 Error(
"On",
"no SVG file open");
221 if (fillis == 3 || fillis == 2) {
223 x[0] =
x1;
y[0] = y1;
224 x[1] =
x2;
y[1] = y1;
225 x[2] =
x2;
y[2] = y2;
226 x[3] =
x1;
y[3] = y2;
229 if (fillsi > 0 && fillsi < 26) {
230 x[0] =
x1;
y[0] = y1;
231 x[1] =
x2;
y[1] = y1;
232 x[2] =
x2;
y[2] = y2;
233 x[3] =
x1;
y[3] = y2;
276 PrintFast(21,
"\" fill=\"none\" stroke=");
296 Double_t ixd0, iyd0, ixdi, iydi, ix, iy;
302 xps[1] = xps[0] + border; yps[1] = yps[0] - border;
303 xps[2] = xps[1]; yps[2] =
YtoSVG(yt) + border;
304 xps[3] =
XtoSVG(xt) - border; yps[3] = yps[2];
306 xps[5] = xps[0]; yps[5] = yps[4];
307 xps[6] = xps[0]; yps[6] = yps[0];
319 for (i=1; i<7; i++) {
327 if( idx ) {
MovePS(idx,0); idx = 0; }
328 if( idy ) {
MovePS(0,idy); idy = 0; }
333 if( idy ) {
MovePS(0,idy); idy = 0; }
334 if( !idx ) { idx = ix;
continue;}
344 if( idx ) {
MovePS(idx,0); idx = 0; }
345 if( !idy) { idy = iy;
continue;}
370 xps[1] = xps[0] + border; yps[1] = yps[0] - border;
371 xps[2] =
XtoSVG(xt) - border; yps[2] = yps[1];
372 xps[3] = xps[2]; yps[3] =
YtoSVG(yt) + border;
374 xps[5] = xps[4]; yps[5] = yps[0];
375 xps[6] = xps[0]; yps[6] = yps[0];
395 if( idx ) {
MovePS(idx,0); idx = 0; }
396 if( idy ) {
MovePS(0,idy); idy = 0; }
401 if( idy ) {
MovePS(0,idy); idy = 0; }
402 if( !idx ) { idx = ix;
continue;}
412 if( idx ) {
MovePS(idx,0); idx = 0; }
413 if( !idy) { idy = iy;
continue;}
450 Double_t ixd0, iyd0, ixdi, iydi, ix, iy;
473 if( idx ) {
MovePS(idx,0); idx = 0; }
474 if( idy ) {
MovePS(0,idy); idy = 0; }
479 if( idy ) {
MovePS(0,idy); idy = 0; }
480 if( !idx ) { idx = ix;
continue;}
490 if( idx ) {
MovePS(idx,0); idx = 0; }
491 if( !idy) { idy = iy;
continue;}
521 Double_t ixd0, iyd0, ixdi, iydi, ix, iy;
543 if( idx ) {
MovePS(idx,0); idx = 0; }
544 if( idy ) {
MovePS(0,idy); idy = 0; }
549 if( idy ) {
MovePS(0,idy); idy = 0; }
550 if( !idx ) { idx = ix;
continue;}
560 if( idx ) {
MovePS(idx,0); idx = 0; }
561 if( !idy) { idy = iy;
continue;}
589 else if (
ms >= 6 &&
ms <= 8)
591 else if (
ms >= 9 &&
ms <= 19)
600 const Int_t kBASEMARKER = 8;
601 Float_t sbase = msize*kBASEMARKER;
615 if ((
ms > 19 &&
ms < 24) ||
ms == 29 ||
ms == 33 ||
ms == 34 ||
616 ms == 39 ||
ms == 41 ||
ms == 43 ||
ms == 45 ||
617 ms == 47 ||
ms == 48 ||
ms == 49) {
650 }
else if (
ms == 2) {
671 }
else if (
ms == 5) {
692 }
else if (
ms == 3 ||
ms == 31) {
733 }
else if (
ms == 24 ||
ms == 20) {
744 }
else if (
ms == 25 ||
ms == 21) {
756 }
else if (
ms == 26 ||
ms == 22) {
763 }
else if (
ms == 23 ||
ms == 32) {
770 }
else if (
ms == 27 ||
ms == 33) {
778 }
else if (
ms == 28 ||
ms == 34) {
793 }
else if (
ms == 29 ||
ms == 30) {
806 }
else if (
ms == 35) {
817 }
else if (
ms == 36) {
828 }
else if (
ms == 37 ||
ms == 39) {
841 }
else if (
ms == 38) {
859 }
else if (
ms == 40 ||
ms == 41) {
875 }
else if (
ms == 42 ||
ms == 43) {
887 }
else if (
ms == 44) {
901 }
else if (
ms == 45) {
917 }
else if (
ms == 46 ||
ms == 47) {
933 }
else if (
ms == 48) {
953 }
else if (
ms == 49) {
998 else if (
ms >= 6 &&
ms <= 8)
1000 else if (
ms >= 9 &&
ms <= 19)
1009 const Int_t kBASEMARKER = 8;
1010 Float_t sbase = msize*kBASEMARKER;
1024 if ((
ms > 19 &&
ms < 24) ||
ms == 29 ||
ms == 33 ||
ms == 34 ||
1025 ms == 39 ||
ms == 41 ||
ms == 43 ||
ms == 45 ||
1026 ms == 47 ||
ms == 48 ||
ms == 49) {
1043 for (
Int_t i=0;i<
n;i++) {
1059 }
else if (
ms == 2) {
1080 }
else if (
ms == 5) {
1101 }
else if (
ms == 3 ||
ms == 31) {
1142 }
else if (
ms == 24 ||
ms == 20) {
1152 }
else if (
ms == 25 ||
ms == 21) {
1163 }
else if (
ms == 26 ||
ms == 22) {
1170 }
else if (
ms == 23 ||
ms == 32) {
1177 }
else if (
ms == 27 ||
ms == 33) {
1185 }
else if (
ms == 28 ||
ms == 34) {
1200 }
else if (
ms == 29 ||
ms == 30) {
1213 }
else if (
ms == 35) {
1224 }
else if (
ms == 36) {
1235 }
else if (
ms == 37 ||
ms == 39) {
1248 }
else if (
ms == 38) {
1266 }
else if (
ms == 40 ||
ms == 41) {
1282 }
else if (
ms == 42 ||
ms == 43) {
1294 }
else if (
ms == 44) {
1308 }
else if (
ms == 45) {
1324 }
else if (
ms == 46 ||
ms == 47) {
1340 }
else if (
ms == 48) {
1360 }
else if (
ms == 49) {
1405 Double_t ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
1415 if (fais == 3 || fais == 2) {
1416 if (fasi > 100 && fasi <125) {
1419 if (fasi > 0 && fasi < 26) {
1425 Error(
"DrawPS",
"Two points are needed");
1439 for (
Int_t i=1;i<
n;i++) {
1447 if( idx ) {
MovePS(idx,0); idx = 0; }
1448 if( idy ) {
MovePS(0,idy); idy = 0; }
1451 if( idy ) {
MovePS(0,idy); idy = 0;}
1452 if( !idx ) { idx = ix;}
1454 else {
MovePS(idx,0); idx = ix;}
1456 if( idx ) {
MovePS(idx,0); idx = 0;}
1457 if( !idy) { idy = iy;}
1459 else {
MovePS(0,idy); idy = iy;}
1466 if (xw[0] == xw[
n-1] && yw[0] == yw[
n-1])
PrintFast(1,
"z");
1467 PrintFast(21,
"\" fill=\"none\" stroke=");
1480 sscanf(((
TObjString*)tokens->
At(j))->GetName(),
"%d", &it);
1545 if (ix != 0 && iy != 0) {
1550 }
else if (ix != 0) {
1553 }
else if (iy != 0) {
1577 PrintStr(
"@<?xml version=\"1.0\" standalone=\"no\"?>");
1586 PrintStr(
"\" xmlns=\"http://www.w3.org/2000/svg\" shape-rendering=\"crispEdges\">");
1598 Float_t xps, yps, xncm, yncm, dxwn, dywn, xwkwn, ywkwn, xymax;
1606 if( xsize <= xps && ysize < yps) {
1607 if ( xps > yps ) xymax = xps;
1611 dxwn = ((xps/xymax)-xncm)/2;
1612 dywn = ((yps/xymax)-yncm)/2;
1614 if (xps/yps < 1) xwkwn = xps/yps;
1616 if (yps/xps < 1) ywkwn = yps/xps;
1619 if (xsize < ysize) {
1620 xncm = ywkwn*xsize/ysize;
1622 dxwn = (xwkwn-xncm)/2;
1627 yncm = xwkwn*ysize/xsize;
1628 dywn = (ywkwn-yncm)/2;
1632 yncm = xwkwn*ysize/xsize;
1634 dywn = (ywkwn-yncm)/2;
1638 xncm = ywkwn*xsize/ysize;
1639 dxwn = (xwkwn-xncm)/2;
1745 if (color < 0) color = 0;
1750 if (
a<1.)
PrintStr(
Form(
" fill-opacity=\"%3.2f\" stroke-opacity=\"%3.2f\"",
a,
a));
1761 if (color < 0) color = 0;
1779 if (
r <= 0. &&
g <= 0. &&
b <= 0. ) {
1781 }
else if (
r >= 1. &&
g >= 1. &&
b >= 1. ) {
1809 static const char *fontFamily[] = {
1810 "Times" ,
"Times" ,
"Times",
1811 "Helvetica",
"Helvetica",
"Helvetica" ,
"Helvetica",
1812 "Courier" ,
"Courier" ,
"Courier" ,
"Courier",
1813 "Times" ,
"Times" ,
"ZapfDingbats",
"Times"};
1815 static const char *fontWeight[] = {
1816 "normal",
"bold",
"bold",
1817 "normal",
"normal",
"bold" ,
"bold",
1818 "normal",
"normal",
"bold" ,
"bold",
1819 "normal",
"normal",
"normal",
"normal"};
1821 static const char *fontStyle[] = {
1822 "italic",
"normal" ,
"italic",
1823 "normal",
"oblique",
"normal",
"oblique",
1824 "normal",
"oblique",
"normal",
"oblique",
1825 "normal",
"normal" ,
"normal",
"italic"};
1830 if (txalh <1) txalh = 1;
else if (txalh > 3) txalh = 3;
1832 if (txalv <1) txalv = 1;
else if (txalv > 3) txalv = 3;
1840 if (font > 42 || font < 1) font = 1;
1846 Int_t ifont = font-1;
1849 if( fontsize <= 0)
return;
1851 if (txalv == 3) iy = iy+fontsize;
1852 if (txalv == 2) iy = iy+(fontsize/2);
1866 PrintFast(30,
"<text xml:space=\"preserve\" x=\"");
1872 PrintFast(21,
" text-anchor=\"middle\"");
1873 }
else if (txalh == 3) {
1882 if (strcmp(fontWeight[ifont],
"normal")) {
1886 if (strcmp(fontStyle[ifont],
"normal")) {
1892 if (font == 12 || font == 15) {
1893 Int_t ichar = chars[0]+848;
1897 if (ic == 755) ichar = 8804;
1898 if (ic == 759) ichar = 9827;
1899 if (ic == 760) ichar = 9830;
1900 if (ic == 761) ichar = 9829;
1901 if (ic == 762) ichar = 9824;
1902 if (ic == 766) ichar = 8594;
1903 if (ic == 776) ichar = 247;
1904 if (ic == 757) ichar = 8734;
1905 if (ic == 758) ichar = 402;
1906 if (ic == 771) ichar = 8805;
1907 if (ic == 774) ichar = 8706;
1908 if (ic == 775) ichar = 8226;
1909 if (ic == 779) ichar = 8776;
1910 if (ic == 805) ichar = 8719;
1911 if (ic == 821) ichar = 8721;
1912 if (ic == 834) ichar = 8747;
1913 if (ic == 769) ichar = 177;
1914 if (ic == 772) ichar = 215;
1915 if (ic == 768) ichar = 176;
1916 if (ic == 791) ichar = 8745;
1917 if (ic == 793) ichar = 8835;
1918 if (ic == 794) ichar = 8839;
1919 if (ic == 795) ichar = 8836;
1920 if (ic == 796) ichar = 8834;
1921 if (ic == 893) ichar = 8722;
1922 if (ic == 803) ichar = 169;
1923 if (ic == 819) ichar = 169;
1924 if (ic == 804) ichar = 8482;
1925 if (ic == 770) ichar = 34;
1926 if (ic == 823) ichar = 10072;
1927 if (ic == 781) ichar = 10072;
1928 if (ic == 824) ichar = 9117;
1929 if (ic == 822) ichar = 9115;
1930 if (ic == 767) ichar = 8595;
1931 if (ic == 763) ichar = 8596;
1932 if (ic == 764) ichar = 8592;
1933 if (ic == 788) ichar = 8855;
1934 if (ic == 784) ichar = 8501;
1935 if (ic == 777) ichar = 8800;
1936 if (ic == 797) ichar = 8838;
1937 if (ic == 800) ichar = 8736;
1938 if (ic == 812) ichar = 8656;
1939 if (ic == 817) ichar = 60;
1940 if (ic == 833) ichar = 62;
1941 if (ic == 778) ichar = 8803;
1942 if (ic == 809) ichar = 8743;
1943 if (ic == 802) ichar = 9415;
1944 if (ic == 780) ichar = 8230;
1945 if (ic == 801) ichar = 8711;
1946 if (ic == 783) ichar = 8629;
1947 if (ic == 782) ichar = 8213;
1948 if (ic == 799) ichar = 8713;
1949 if (ic == 792) ichar = 8746;
1950 if (ic == 828) ichar = 9127;
1951 if (ic == 765) ichar = 8593;
1952 if (ic == 789) ichar = 8853;
1953 if (ic == 813) ichar = 8657;
1954 if (ic == 773) ichar = 8733;
1955 if (ic == 790) ichar = 8709;
1956 if (ic == 810) ichar = 8744;
1957 if (ic == 756) ichar = 8260;
1958 if (ic == 807) ichar = 8231;
1959 if (ic == 808) ichar = 8989;
1960 if (ic == 814) ichar = 8658;
1961 if (ic == 806) ichar = 8730;
1962 if (ic == 827) ichar = 9123;
1963 if (ic == 829) ichar = 9128;
1964 if (ic == 786) ichar = 8476;
1965 if (ic == 785) ichar = 8465;
1966 if (ic == 787) ichar = 8472;
1969 if (ic == 918) ichar = 934;
1970 if (ic == 919) ichar = 915;
1971 if (ic == 920) ichar = 919;
1972 if (ic == 923) ichar = 922;
1973 if (ic == 924) ichar = 923;
1974 if (ic == 925) ichar = 924;
1975 if (ic == 926) ichar = 925;
1976 if (ic == 929) ichar = 920;
1977 if (ic == 930) ichar = 929;
1978 if (ic == 936) ichar = 926;
1979 if (ic == 915) ichar = 935;
1980 if (ic == 937) ichar = 936;
1981 if (ic == 935) ichar = 937;
1982 if (ic == 938) ichar = 918;
1983 if (ic == 951) ichar = 947;
1984 if (ic == 798) ichar = 949;
1985 if (ic == 970) ichar = 950;
1986 if (ic == 952) ichar = 951;
1987 if (ic == 961) ichar = 952;
1988 if (ic == 955) ichar = 954;
1989 if (ic == 956) ichar = 955;
1990 if (ic == 957) ichar = 956;
1991 if (ic == 958) ichar = 957;
1992 if (ic == 968) ichar = 958;
1993 if (ic == 934) ichar = 962;
1994 if (ic == 962) ichar = 961;
1995 if (ic == 966) ichar = 969;
1996 if (ic == 950) ichar = 966;
1997 if (ic == 947) ichar = 967;
1998 if (ic == 969) ichar = 968;
1999 if (ic == 967) ichar = 969;
2000 if (ic == 954) ichar = 966;
2001 if (ic == 922) ichar = 952;
2002 if (ic == 753) ichar = 965;
2005 Int_t len=strlen(chars);
2006 for (
Int_t i=0; i<len;i++) {
2007 if (chars[i]!=
'\n') {
2008 if (chars[i]==
'<') {
2010 }
else if (chars[i]==
'>') {
2012 }
else if (chars[i]==
'\305') {
2014 }
else if (chars[i]==
'\345') {
2016 }
else if (chars[i]==
'&') {
2049 return 0.5 + 72*
cm/2.54;
2058 return 0.5 + 72*
cm/2.54;
2085 Warning(
"TSVG::CellArrayBegin",
"not yet implemented");
2093 Warning(
"TSVG::CellArrayFill",
"not yet implemented");
2101 Warning(
"TSVG::CellArrayEnd",
"not yet implemented");
2109 Warning(
"TSVG::DrawPS",
"not yet implemented");
static const double x2[5]
static const double x1[5]
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
R__EXTERN TVirtualPS * gVirtualPS
virtual Color_t GetFillColor() const
Return the fill area color.
Style_t fFillStyle
Fill area style.
Color_t fFillColor
Fill area color.
Width_t fLineWidth
Line width.
Style_t fLineStyle
Line style.
Color_t fLineColor
Line color.
Color_t fMarkerColor
Marker color.
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
Size_t fMarkerSize
Marker size.
Style_t fMarkerStyle
Marker style.
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
Color_t fTextColor
Text color.
Float_t fTextAngle
Text angle.
Font_t fTextFont
Text font.
Short_t fTextAlign
Text alignment.
Float_t fTextSize
Text size.
The color creation and management class.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
const char * AsString() const
Return the date & time as a string (ctime() format).
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual const char * GetName() const
Returns name of object.
Int_t GetEntries() const
Return the number of objects in array (i.e.
TObject * At(Int_t idx) const
Collectable string class.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
2-D graphics point (world coordinates).
static Int_t fgLineJoin
Appearance of joining lines.
Double_t UtoSVG(Double_t u)
Convert U from NDC coordinate to SVG.
void SetTextColor(Color_t cindex=1)
Set color index for text.
void MovePS(Double_t x, Double_t y)
Move to a new position (ix, iy).
void SetFillColor(Color_t cindex=1)
Set color index for fill areas.
Double_t fYsizeSVG
Page's Y size in SVG units.
void DrawPolyLine(Int_t n, TPoints *xy)
Draw a PolyLine.
Bool_t fRange
True when a range has been defined.
Double_t YtoSVG(Double_t y)
Convert Y from world coordinate to SVG.
void CellArrayBegin(Int_t W, Int_t H, Double_t x1, Double_t x2, Double_t y1, Double_t y2)
Begin the Cell Array painting.
void Initialize()
Initialize the SVG file.
void Text(Double_t x, Double_t y, const char *string)
Draw text.
void SetLineColor(Color_t cindex=1)
Set color index for lines.
void CellArrayEnd()
End the Cell Array painting.
void SetColor(Int_t color=1)
Set RGB (without alpha channel) color with its color index.
Int_t fType
Workstation type used to know if the SVG is open.
void SetLineCap(Int_t linecap=0)
Set the value of the global parameter TSVG::fgLineCap.
void Off()
Deactivate an already open SVG file.
void Range(Float_t xrange, Float_t yrange)
Set the range for the paper in centimetres.
void Open(const char *filename, Int_t type=-111)
Open a SVG file.
void SetLineScale(Float_t=3)
void SetMarkerColor(Color_t cindex=1)
Set color index for markers.
void DrawPS(Int_t n, Float_t *xw, Float_t *yw)
Not needed in SVG case.
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw a Box.
void SetLineWidth(Width_t linewidth=1)
Set the lines width.
void On()
Activate an already open SVG file.
TSVG()
Default SVG constructor.
virtual ~TSVG()
Default SVG destructor.
void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y)
Paint PolyMarker.
Double_t CMtoSVG(Double_t u)
Double_t XtoSVG(Double_t x)
Convert X from world coordinate to SVG.
Bool_t fBoundingBox
True when the SVG header is printed.
Float_t fXsize
Page size along X.
Float_t fYsize
Page size along Y.
void DrawPolyLineNDC(Int_t n, TPoints *uv)
Draw a PolyLine in NDC space.
void TextNDC(Double_t u, Double_t v, const char *string)
Write a string of characters in NDC.
void CellArrayFill(Int_t r, Int_t g, Int_t b)
Paint the Cell Array.
void SetColorAlpha(Int_t color=1)
Set RGBa color with its color index.
void Close(Option_t *opt="")
Close a SVG file.
void SetLineJoin(Int_t linejoin=0)
Set the value of the global parameter TSVG::fgLineJoin.
void SetLineStyle(Style_t linestyle=1)
Change the line style.
void NewPage()
Start the SVG page.
static Int_t fgLineCap
Appearance of line caps.
Double_t VtoSVG(Double_t v)
Convert V from NDC coordinate to SVG.
void DrawFrame(Double_t xl, Double_t yl, Double_t xt, Double_t yt, Int_t mode, Int_t border, Int_t dark, Int_t light)
Draw a Frame around a box.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Int_t GetJoinLinePS() const
Returns the line join method used for PostScript, PDF and SVG output. See TPostScript::SetLineJoin fo...
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
Int_t GetCapLinePS() const
Returns the line cap method used for PostScript, PDF and SVG output. See TPostScript::SetLineCap for ...
void GetPaperSize(Float_t &xsize, Float_t &ysize) const
Set paper size for PostScript output.
const char * GetHeaderPS() const
Float_t GetLineScalePS() const
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
virtual void PrintStr(const char *string="")
Output the string str in the output buffer.
virtual void PrintFast(Int_t nch, const char *string="")
Fast version of Print.
virtual void WriteReal(Float_t r, Bool_t space=kTRUE)
Write a Real number to the file.
static constexpr double cm
static constexpr double ms
static constexpr double m3
static constexpr double m2
Short_t Max(Short_t a, Short_t b)
Double_t Floor(Double_t x)
Short_t Min(Short_t a, Short_t b)