13#pragma optimize("",off)
112 Warning(
"Open",
"SVG file already open");
124 ww *=
gPad->GetWNDC();
125 wh *=
gPad->GetHNDC();
129 if (yrange >
fYsize) { yrange =
fYsize; xrange = yrange/ratio;}
134 fStream =
new std::ofstream(fname,std::ios::out);
136 printf(
"ERROR in TSVG::Open: Cannot open file:%s\n",fname);
187 Error(
"On",
"no SVG file open");
215 if (fillis == 3 || fillis == 2) {
217 x[0] =
x1;
y[0] = y1;
218 x[1] =
x2;
y[1] = y1;
219 x[2] =
x2;
y[2] = y2;
220 x[3] =
x1;
y[3] = y2;
223 if (fillsi > 0 && fillsi < 26) {
224 x[0] =
x1;
y[0] = y1;
225 x[1] =
x2;
y[1] = y1;
226 x[2] =
x2;
y[2] = y2;
227 x[3] =
x1;
y[3] = y2;
270 PrintFast(21,
"\" fill=\"none\" stroke=");
290 Double_t ixd0, iyd0, ixdi, iydi, ix, iy;
296 xps[1] = xps[0] + border; yps[1] = yps[0] - border;
297 xps[2] = xps[1]; yps[2] =
YtoSVG(yt) + border;
298 xps[3] =
XtoSVG(xt) - border; yps[3] = yps[2];
300 xps[5] = xps[0]; yps[5] = yps[4];
301 xps[6] = xps[0]; yps[6] = yps[0];
313 for (i=1; i<7; i++) {
321 if( idx ) {
MovePS(idx,0); idx = 0; }
322 if( idy ) {
MovePS(0,idy); idy = 0; }
327 if( idy ) {
MovePS(0,idy); idy = 0; }
328 if( !idx ) { idx = ix;
continue;}
338 if( idx ) {
MovePS(idx,0); idx = 0; }
339 if( !idy) { idy = iy;
continue;}
360 xps[1] = xps[0] + border; yps[1] = yps[0] - border;
361 xps[2] =
XtoSVG(xt) - border; yps[2] = yps[1];
362 xps[3] = xps[2]; yps[3] =
YtoSVG(yt) + border;
364 xps[5] = xps[4]; yps[5] = yps[0];
365 xps[6] = xps[0]; yps[6] = yps[0];
385 if( idx ) {
MovePS(idx,0); idx = 0; }
386 if( idy ) {
MovePS(0,idy); idy = 0; }
391 if( idy ) {
MovePS(0,idy); idy = 0; }
392 if( !idx ) { idx = ix;
continue;}
402 if( idx ) {
MovePS(idx,0); idx = 0; }
403 if( !idy) { idy = iy;
continue;}
436 Double_t ixd0, iyd0, ixdi, iydi, ix, iy;
459 if( idx ) {
MovePS(idx,0); idx = 0; }
460 if( idy ) {
MovePS(0,idy); idy = 0; }
465 if( idy ) {
MovePS(0,idy); idy = 0; }
466 if( !idx ) { idx = ix;
continue;}
476 if( idx ) {
MovePS(idx,0); idx = 0; }
477 if( !idy) { idy = iy;
continue;}
507 Double_t ixd0, iyd0, ixdi, iydi, ix, iy;
529 if( idx ) {
MovePS(idx,0); idx = 0; }
530 if( idy ) {
MovePS(0,idy); idy = 0; }
535 if( idy ) {
MovePS(0,idy); idy = 0; }
536 if( !idx ) { idx = ix;
continue;}
546 if( idx ) {
MovePS(idx,0); idx = 0; }
547 if( !idy) { idy = iy;
continue;}
572 if (
ms >= 6 &&
ms <= 19)
ms = 20;
573 if (
ms == 4)
ms = 24;
581 const Int_t kBASEMARKER = 8;
582 Float_t sbase = msize*kBASEMARKER;
596 if ((
ms > 19 &&
ms < 24) ||
ms == 29 ||
ms == 33 ||
ms == 34 ||
597 ms == 39 ||
ms == 41 ||
ms == 43 ||
ms == 45 ||
598 ms == 47 ||
ms == 48 ||
ms == 49) {
627 }
else if (
ms == 2) {
648 }
else if (
ms == 5) {
669 }
else if (
ms == 3 ||
ms == 31) {
710 }
else if (
ms == 24 ||
ms == 20) {
721 }
else if (
ms == 25 ||
ms == 21) {
733 }
else if (
ms == 26 ||
ms == 22) {
740 }
else if (
ms == 23 ||
ms == 32) {
747 }
else if (
ms == 27 ||
ms == 33) {
755 }
else if (
ms == 28 ||
ms == 34) {
770 }
else if (
ms == 29 ||
ms == 30) {
783 }
else if (
ms == 35) {
794 }
else if (
ms == 36) {
805 }
else if (
ms == 37 ||
ms == 39) {
818 }
else if (
ms == 38) {
836 }
else if (
ms == 40 ||
ms == 41) {
852 }
else if (
ms == 42 ||
ms == 43) {
864 }
else if (
ms == 44) {
878 }
else if (
ms == 45) {
894 }
else if (
ms == 46 ||
ms == 47) {
910 }
else if (
ms == 48) {
930 }
else if (
ms == 49) {
972 if (
ms >= 6 &&
ms <= 19)
ms = 20;
973 if (
ms == 4)
ms = 24;
981 const Int_t kBASEMARKER = 8;
982 Float_t sbase = msize*kBASEMARKER;
996 if ((
ms > 19 &&
ms < 24) ||
ms == 29 ||
ms == 33 ||
ms == 34 ||
997 ms == 39 ||
ms == 41 ||
ms == 43 ||
ms == 45 ||
998 ms == 47 ||
ms == 48 ||
ms == 49) {
1011 for (
Int_t i=0;i<
n;i++) {
1027 }
else if (
ms == 2) {
1048 }
else if (
ms == 5) {
1069 }
else if (
ms == 3 ||
ms == 31) {
1110 }
else if (
ms == 24 ||
ms == 20) {
1120 }
else if (
ms == 25 ||
ms == 21) {
1131 }
else if (
ms == 26 ||
ms == 22) {
1138 }
else if (
ms == 23 ||
ms == 32) {
1145 }
else if (
ms == 27 ||
ms == 33) {
1153 }
else if (
ms == 28 ||
ms == 34) {
1168 }
else if (
ms == 29 ||
ms == 30) {
1181 }
else if (
ms == 35) {
1192 }
else if (
ms == 36) {
1203 }
else if (
ms == 37 ||
ms == 39) {
1216 }
else if (
ms == 38) {
1234 }
else if (
ms == 40 ||
ms == 41) {
1250 }
else if (
ms == 42 ||
ms == 43) {
1262 }
else if (
ms == 44) {
1276 }
else if (
ms == 45) {
1292 }
else if (
ms == 46 ||
ms == 47) {
1308 }
else if (
ms == 48) {
1328 }
else if (
ms == 49) {
1373 Double_t ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
1383 if (fais == 3 || fais == 2) {
1384 if (fasi > 100 && fasi <125) {
1387 if (fasi > 0 && fasi < 26) {
1393 Error(
"DrawPS",
"Two points are needed");
1407 for (
Int_t i=1;i<
n;i++) {
1415 if( idx ) {
MovePS(idx,0); idx = 0; }
1416 if( idy ) {
MovePS(0,idy); idy = 0; }
1419 if( idy ) {
MovePS(0,idy); idy = 0;}
1420 if( !idx ) { idx = ix;}
1422 else {
MovePS(idx,0); idx = ix;}
1424 if( idx ) {
MovePS(idx,0); idx = 0;}
1425 if( !idy) { idy = iy;}
1427 else {
MovePS(0,idy); idy = iy;}
1434 if (xw[0] == xw[
n-1] && yw[0] == yw[
n-1])
PrintFast(1,
"z");
1435 PrintFast(21,
"\" fill=\"none\" stroke=");
1448 sscanf(((
TObjString*)tokens->
At(j))->GetName(),
"%d", &it);
1510 if (ix != 0 && iy != 0) {
1515 }
else if (ix != 0) {
1518 }
else if (iy != 0) {
1542 PrintStr(
"@<?xml version=\"1.0\" standalone=\"no\"?>");
1551 PrintStr(
"\" xmlns=\"http://www.w3.org/2000/svg\" shape-rendering=\"crispEdges\">");
1563 Float_t xps, yps, xncm, yncm, dxwn, dywn, xwkwn, ywkwn, xymax;
1571 if( xsize <= xps && ysize < yps) {
1572 if ( xps > yps ) xymax = xps;
1576 dxwn = ((xps/xymax)-xncm)/2;
1577 dywn = ((yps/xymax)-yncm)/2;
1579 if (xps/yps < 1) xwkwn = xps/yps;
1581 if (yps/xps < 1) ywkwn = yps/xps;
1584 if (xsize < ysize) {
1585 xncm = ywkwn*xsize/ysize;
1587 dxwn = (xwkwn-xncm)/2;
1592 yncm = xwkwn*ysize/xsize;
1593 dywn = (ywkwn-yncm)/2;
1597 yncm = xwkwn*ysize/xsize;
1599 dywn = (ywkwn-yncm)/2;
1603 xncm = ywkwn*xsize/ysize;
1604 dxwn = (xwkwn-xncm)/2;
1662 if (color < 0) color = 0;
1667 if (
a<1.)
PrintStr(
Form(
" fill-opacity=\"%3.2f\" stroke-opacity=\"%3.2f\"",
a,
a));
1678 if (color < 0) color = 0;
1696 if (
r <= 0. &&
g <= 0. &&
b <= 0. ) {
1698 }
else if (
r >= 1. &&
g >= 1. &&
b >= 1. ) {
1726 static const char *fontFamily[] = {
1727 "Times" ,
"Times" ,
"Times",
1728 "Helvetica",
"Helvetica",
"Helvetica" ,
"Helvetica",
1729 "Courier" ,
"Courier" ,
"Courier" ,
"Courier",
1730 "Times" ,
"Times" ,
"ZapfDingbats",
"Times"};
1732 static const char *fontWeight[] = {
1733 "normal",
"bold",
"bold",
1734 "normal",
"normal",
"bold" ,
"bold",
1735 "normal",
"normal",
"bold" ,
"bold",
1736 "normal",
"normal",
"normal",
"normal"};
1738 static const char *fontStyle[] = {
1739 "italic",
"normal" ,
"italic",
1740 "normal",
"oblique",
"normal",
"oblique",
1741 "normal",
"oblique",
"normal",
"oblique",
1742 "normal",
"normal" ,
"normal",
"italic"};
1747 if (txalh <1) txalh = 1;
else if (txalh > 3) txalh = 3;
1749 if (txalv <1) txalv = 1;
else if (txalv > 3) txalv = 3;
1757 if (font > 42 || font < 1) font = 1;
1763 Int_t ifont = font-1;
1766 if( fontsize <= 0)
return;
1768 if (txalv == 3) iy = iy+fontsize;
1769 if (txalv == 2) iy = iy+(fontsize/2);
1783 PrintFast(30,
"<text xml:space=\"preserve\" x=\"");
1789 PrintFast(21,
" text-anchor=\"middle\"");
1790 }
else if (txalh == 3) {
1799 if (strcmp(fontWeight[ifont],
"normal")) {
1803 if (strcmp(fontStyle[ifont],
"normal")) {
1809 if (font == 12 || font == 15) {
1810 Int_t ichar = chars[0]+848;
1814 if (ic == 755) ichar = 8804;
1815 if (ic == 759) ichar = 9827;
1816 if (ic == 760) ichar = 9830;
1817 if (ic == 761) ichar = 9829;
1818 if (ic == 762) ichar = 9824;
1819 if (ic == 766) ichar = 8594;
1820 if (ic == 776) ichar = 247;
1821 if (ic == 757) ichar = 8734;
1822 if (ic == 758) ichar = 402;
1823 if (ic == 771) ichar = 8805;
1824 if (ic == 774) ichar = 8706;
1825 if (ic == 775) ichar = 8226;
1826 if (ic == 779) ichar = 8776;
1827 if (ic == 805) ichar = 8719;
1828 if (ic == 821) ichar = 8721;
1829 if (ic == 834) ichar = 8747;
1830 if (ic == 769) ichar = 177;
1831 if (ic == 772) ichar = 215;
1832 if (ic == 768) ichar = 176;
1833 if (ic == 791) ichar = 8745;
1834 if (ic == 793) ichar = 8835;
1835 if (ic == 794) ichar = 8839;
1836 if (ic == 795) ichar = 8836;
1837 if (ic == 796) ichar = 8834;
1838 if (ic == 893) ichar = 8722;
1839 if (ic == 803) ichar = 169;
1840 if (ic == 819) ichar = 169;
1841 if (ic == 804) ichar = 8482;
1842 if (ic == 770) ichar = 34;
1843 if (ic == 823) ichar = 10072;
1844 if (ic == 781) ichar = 10072;
1845 if (ic == 824) ichar = 9117;
1846 if (ic == 822) ichar = 9115;
1847 if (ic == 767) ichar = 8595;
1848 if (ic == 763) ichar = 8596;
1849 if (ic == 764) ichar = 8592;
1850 if (ic == 788) ichar = 8855;
1851 if (ic == 784) ichar = 8501;
1852 if (ic == 777) ichar = 8800;
1853 if (ic == 797) ichar = 8838;
1854 if (ic == 800) ichar = 8736;
1855 if (ic == 812) ichar = 8656;
1856 if (ic == 817) ichar = 60;
1857 if (ic == 833) ichar = 62;
1858 if (ic == 778) ichar = 8803;
1859 if (ic == 809) ichar = 8743;
1860 if (ic == 802) ichar = 9415;
1861 if (ic == 780) ichar = 8230;
1862 if (ic == 801) ichar = 8711;
1863 if (ic == 783) ichar = 8629;
1864 if (ic == 782) ichar = 8213;
1865 if (ic == 799) ichar = 8713;
1866 if (ic == 792) ichar = 8746;
1867 if (ic == 828) ichar = 9127;
1868 if (ic == 765) ichar = 8593;
1869 if (ic == 789) ichar = 8853;
1870 if (ic == 813) ichar = 8657;
1871 if (ic == 773) ichar = 8733;
1872 if (ic == 790) ichar = 8709;
1873 if (ic == 810) ichar = 8744;
1874 if (ic == 756) ichar = 8260;
1875 if (ic == 807) ichar = 8231;
1876 if (ic == 808) ichar = 8989;
1877 if (ic == 814) ichar = 8658;
1878 if (ic == 806) ichar = 8730;
1879 if (ic == 827) ichar = 9123;
1880 if (ic == 829) ichar = 9128;
1881 if (ic == 786) ichar = 8476;
1882 if (ic == 785) ichar = 8465;
1883 if (ic == 787) ichar = 8472;
1886 if (ic == 918) ichar = 934;
1887 if (ic == 919) ichar = 915;
1888 if (ic == 920) ichar = 919;
1889 if (ic == 923) ichar = 922;
1890 if (ic == 924) ichar = 923;
1891 if (ic == 925) ichar = 924;
1892 if (ic == 926) ichar = 925;
1893 if (ic == 929) ichar = 920;
1894 if (ic == 930) ichar = 929;
1895 if (ic == 936) ichar = 926;
1896 if (ic == 915) ichar = 935;
1897 if (ic == 937) ichar = 936;
1898 if (ic == 935) ichar = 937;
1899 if (ic == 938) ichar = 918;
1900 if (ic == 951) ichar = 947;
1901 if (ic == 798) ichar = 949;
1902 if (ic == 970) ichar = 950;
1903 if (ic == 952) ichar = 951;
1904 if (ic == 961) ichar = 952;
1905 if (ic == 955) ichar = 954;
1906 if (ic == 956) ichar = 955;
1907 if (ic == 957) ichar = 956;
1908 if (ic == 958) ichar = 957;
1909 if (ic == 968) ichar = 958;
1910 if (ic == 934) ichar = 962;
1911 if (ic == 962) ichar = 961;
1912 if (ic == 966) ichar = 969;
1913 if (ic == 950) ichar = 966;
1914 if (ic == 947) ichar = 967;
1915 if (ic == 969) ichar = 968;
1916 if (ic == 967) ichar = 969;
1917 if (ic == 954) ichar = 966;
1918 if (ic == 922) ichar = 952;
1919 if (ic == 753) ichar = 965;
1922 Int_t len=strlen(chars);
1923 for (
Int_t i=0; i<len;i++) {
1924 if (chars[i]!=
'\n') {
1925 if (chars[i]==
'<') {
1927 }
else if (chars[i]==
'>') {
1929 }
else if (chars[i]==
'\305') {
1931 }
else if (chars[i]==
'\345') {
1933 }
else if (chars[i]==
'&') {
1966 return 0.5 + 72*
cm/2.54;
1975 return 0.5 + 72*
cm/2.54;
2002 Warning(
"TSVG::CellArrayBegin",
"not yet implemented");
2010 Warning(
"TSVG::CellArrayFill",
"not yet implemented");
2018 Warning(
"TSVG::CellArrayEnd",
"not yet implemented");
2026 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.
Size_t fMarkerSize
Marker size.
Style_t fMarkerStyle
Marker style.
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).
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 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 SetLineStyle(Style_t linestyle=1)
Change the line style.
void NewPage()
Start the SVG page.
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.
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
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)
Short_t Min(Short_t a, Short_t b)