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) {
631 }
else if (
ms == 2) {
652 }
else if (
ms == 5) {
673 }
else if (
ms == 3 ||
ms == 31) {
714 }
else if (
ms == 24 ||
ms == 20) {
725 }
else if (
ms == 25 ||
ms == 21) {
737 }
else if (
ms == 26 ||
ms == 22) {
744 }
else if (
ms == 23 ||
ms == 32) {
751 }
else if (
ms == 27 ||
ms == 33) {
759 }
else if (
ms == 28 ||
ms == 34) {
774 }
else if (
ms == 29 ||
ms == 30) {
787 }
else if (
ms == 35) {
798 }
else if (
ms == 36) {
809 }
else if (
ms == 37 ||
ms == 39) {
822 }
else if (
ms == 38) {
840 }
else if (
ms == 40 ||
ms == 41) {
856 }
else if (
ms == 42 ||
ms == 43) {
868 }
else if (
ms == 44) {
882 }
else if (
ms == 45) {
898 }
else if (
ms == 46 ||
ms == 47) {
914 }
else if (
ms == 48) {
934 }
else if (
ms == 49) {
976 if (
ms >= 6 &&
ms <= 19)
ms = 20;
977 if (
ms == 4)
ms = 24;
985 const Int_t kBASEMARKER = 8;
986 Float_t sbase = msize*kBASEMARKER;
1000 if ((
ms > 19 &&
ms < 24) ||
ms == 29 ||
ms == 33 ||
ms == 34 ||
1001 ms == 39 ||
ms == 41 ||
ms == 43 ||
ms == 45 ||
1002 ms == 47 ||
ms == 48 ||
ms == 49) {
1019 for (
Int_t i=0;i<
n;i++) {
1035 }
else if (
ms == 2) {
1056 }
else if (
ms == 5) {
1077 }
else if (
ms == 3 ||
ms == 31) {
1118 }
else if (
ms == 24 ||
ms == 20) {
1128 }
else if (
ms == 25 ||
ms == 21) {
1139 }
else if (
ms == 26 ||
ms == 22) {
1146 }
else if (
ms == 23 ||
ms == 32) {
1153 }
else if (
ms == 27 ||
ms == 33) {
1161 }
else if (
ms == 28 ||
ms == 34) {
1176 }
else if (
ms == 29 ||
ms == 30) {
1189 }
else if (
ms == 35) {
1200 }
else if (
ms == 36) {
1211 }
else if (
ms == 37 ||
ms == 39) {
1224 }
else if (
ms == 38) {
1242 }
else if (
ms == 40 ||
ms == 41) {
1258 }
else if (
ms == 42 ||
ms == 43) {
1270 }
else if (
ms == 44) {
1284 }
else if (
ms == 45) {
1300 }
else if (
ms == 46 ||
ms == 47) {
1316 }
else if (
ms == 48) {
1336 }
else if (
ms == 49) {
1381 Double_t ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
1391 if (fais == 3 || fais == 2) {
1392 if (fasi > 100 && fasi <125) {
1395 if (fasi > 0 && fasi < 26) {
1401 Error(
"DrawPS",
"Two points are needed");
1415 for (
Int_t i=1;i<
n;i++) {
1423 if( idx ) {
MovePS(idx,0); idx = 0; }
1424 if( idy ) {
MovePS(0,idy); idy = 0; }
1427 if( idy ) {
MovePS(0,idy); idy = 0;}
1428 if( !idx ) { idx = ix;}
1430 else {
MovePS(idx,0); idx = ix;}
1432 if( idx ) {
MovePS(idx,0); idx = 0;}
1433 if( !idy) { idy = iy;}
1435 else {
MovePS(0,idy); idy = iy;}
1442 if (xw[0] == xw[
n-1] && yw[0] == yw[
n-1])
PrintFast(1,
"z");
1443 PrintFast(21,
"\" fill=\"none\" stroke=");
1456 sscanf(((
TObjString*)tokens->
At(j))->GetName(),
"%d", &it);
1518 if (ix != 0 && iy != 0) {
1523 }
else if (ix != 0) {
1526 }
else if (iy != 0) {
1550 PrintStr(
"@<?xml version=\"1.0\" standalone=\"no\"?>");
1559 PrintStr(
"\" xmlns=\"http://www.w3.org/2000/svg\" shape-rendering=\"crispEdges\">");
1571 Float_t xps, yps, xncm, yncm, dxwn, dywn, xwkwn, ywkwn, xymax;
1579 if( xsize <= xps && ysize < yps) {
1580 if ( xps > yps ) xymax = xps;
1584 dxwn = ((xps/xymax)-xncm)/2;
1585 dywn = ((yps/xymax)-yncm)/2;
1587 if (xps/yps < 1) xwkwn = xps/yps;
1589 if (yps/xps < 1) ywkwn = yps/xps;
1592 if (xsize < ysize) {
1593 xncm = ywkwn*xsize/ysize;
1595 dxwn = (xwkwn-xncm)/2;
1600 yncm = xwkwn*ysize/xsize;
1601 dywn = (ywkwn-yncm)/2;
1605 yncm = xwkwn*ysize/xsize;
1607 dywn = (ywkwn-yncm)/2;
1611 xncm = ywkwn*xsize/ysize;
1612 dxwn = (xwkwn-xncm)/2;
1670 if (color < 0) color = 0;
1675 if (
a<1.)
PrintStr(
Form(
" fill-opacity=\"%3.2f\" stroke-opacity=\"%3.2f\"",
a,
a));
1690 if (
r <= 0. &&
g <= 0. &&
b <= 0. ) {
1692 }
else if (
r >= 1. &&
g >= 1. &&
b >= 1. ) {
1720 static const char *fontFamily[] = {
1721 "Times" ,
"Times" ,
"Times",
1722 "Helvetica",
"Helvetica",
"Helvetica" ,
"Helvetica",
1723 "Courier" ,
"Courier" ,
"Courier" ,
"Courier",
1724 "Times" ,
"Times" ,
"ZapfDingbats",
"Times"};
1726 static const char *fontWeight[] = {
1727 "normal",
"bold",
"bold",
1728 "normal",
"normal",
"bold" ,
"bold",
1729 "normal",
"normal",
"bold" ,
"bold",
1730 "normal",
"normal",
"normal",
"normal"};
1732 static const char *fontStyle[] = {
1733 "italic",
"normal" ,
"italic",
1734 "normal",
"oblique",
"normal",
"oblique",
1735 "normal",
"oblique",
"normal",
"oblique",
1736 "normal",
"normal" ,
"normal",
"italic"};
1741 if (txalh <1) txalh = 1;
else if (txalh > 3) txalh = 3;
1743 if (txalv <1) txalv = 1;
else if (txalv > 3) txalv = 3;
1751 if (font > 42 || font < 1) font = 1;
1757 Int_t ifont = font-1;
1760 if( fontsize <= 0)
return;
1762 if (txalv == 3) iy = iy+fontsize;
1763 if (txalv == 2) iy = iy+(fontsize/2);
1777 PrintFast(30,
"<text xml:space=\"preserve\" x=\"");
1783 PrintFast(21,
" text-anchor=\"middle\"");
1784 }
else if (txalh == 3) {
1793 if (strcmp(fontWeight[ifont],
"normal")) {
1797 if (strcmp(fontStyle[ifont],
"normal")) {
1803 if (font == 12 || font == 15) {
1804 Int_t ichar = chars[0]+848;
1808 if (ic == 755) ichar = 8804;
1809 if (ic == 759) ichar = 9827;
1810 if (ic == 760) ichar = 9830;
1811 if (ic == 761) ichar = 9829;
1812 if (ic == 762) ichar = 9824;
1813 if (ic == 766) ichar = 8594;
1814 if (ic == 776) ichar = 247;
1815 if (ic == 757) ichar = 8734;
1816 if (ic == 758) ichar = 402;
1817 if (ic == 771) ichar = 8805;
1818 if (ic == 774) ichar = 8706;
1819 if (ic == 775) ichar = 8226;
1820 if (ic == 779) ichar = 8776;
1821 if (ic == 805) ichar = 8719;
1822 if (ic == 821) ichar = 8721;
1823 if (ic == 834) ichar = 8747;
1824 if (ic == 769) ichar = 177;
1825 if (ic == 772) ichar = 215;
1826 if (ic == 768) ichar = 176;
1827 if (ic == 791) ichar = 8745;
1828 if (ic == 793) ichar = 8835;
1829 if (ic == 794) ichar = 8839;
1830 if (ic == 795) ichar = 8836;
1831 if (ic == 796) ichar = 8834;
1832 if (ic == 893) ichar = 8722;
1833 if (ic == 803) ichar = 169;
1834 if (ic == 819) ichar = 169;
1835 if (ic == 804) ichar = 8482;
1836 if (ic == 770) ichar = 34;
1837 if (ic == 823) ichar = 10072;
1838 if (ic == 781) ichar = 10072;
1839 if (ic == 824) ichar = 9117;
1840 if (ic == 822) ichar = 9115;
1841 if (ic == 767) ichar = 8595;
1842 if (ic == 763) ichar = 8596;
1843 if (ic == 764) ichar = 8592;
1844 if (ic == 788) ichar = 8855;
1845 if (ic == 784) ichar = 8501;
1846 if (ic == 777) ichar = 8800;
1847 if (ic == 797) ichar = 8838;
1848 if (ic == 800) ichar = 8736;
1849 if (ic == 812) ichar = 8656;
1850 if (ic == 817) ichar = 60;
1851 if (ic == 833) ichar = 62;
1852 if (ic == 778) ichar = 8803;
1853 if (ic == 809) ichar = 8743;
1854 if (ic == 802) ichar = 9415;
1855 if (ic == 780) ichar = 8230;
1856 if (ic == 801) ichar = 8711;
1857 if (ic == 783) ichar = 8629;
1858 if (ic == 782) ichar = 8213;
1859 if (ic == 799) ichar = 8713;
1860 if (ic == 792) ichar = 8746;
1861 if (ic == 828) ichar = 9127;
1862 if (ic == 765) ichar = 8593;
1863 if (ic == 789) ichar = 8853;
1864 if (ic == 813) ichar = 8657;
1865 if (ic == 773) ichar = 8733;
1866 if (ic == 790) ichar = 8709;
1867 if (ic == 810) ichar = 8744;
1868 if (ic == 756) ichar = 8260;
1869 if (ic == 807) ichar = 8231;
1870 if (ic == 808) ichar = 8989;
1871 if (ic == 814) ichar = 8658;
1872 if (ic == 806) ichar = 8730;
1873 if (ic == 827) ichar = 9123;
1874 if (ic == 829) ichar = 9128;
1875 if (ic == 786) ichar = 8476;
1876 if (ic == 785) ichar = 8465;
1877 if (ic == 787) ichar = 8472;
1880 if (ic == 918) ichar = 934;
1881 if (ic == 919) ichar = 915;
1882 if (ic == 920) ichar = 919;
1883 if (ic == 923) ichar = 922;
1884 if (ic == 924) ichar = 923;
1885 if (ic == 925) ichar = 924;
1886 if (ic == 926) ichar = 925;
1887 if (ic == 929) ichar = 920;
1888 if (ic == 930) ichar = 929;
1889 if (ic == 936) ichar = 926;
1890 if (ic == 915) ichar = 935;
1891 if (ic == 937) ichar = 936;
1892 if (ic == 935) ichar = 937;
1893 if (ic == 938) ichar = 918;
1894 if (ic == 951) ichar = 947;
1895 if (ic == 798) ichar = 949;
1896 if (ic == 970) ichar = 950;
1897 if (ic == 952) ichar = 951;
1898 if (ic == 961) ichar = 952;
1899 if (ic == 955) ichar = 954;
1900 if (ic == 956) ichar = 955;
1901 if (ic == 957) ichar = 956;
1902 if (ic == 958) ichar = 957;
1903 if (ic == 968) ichar = 958;
1904 if (ic == 934) ichar = 962;
1905 if (ic == 962) ichar = 961;
1906 if (ic == 966) ichar = 969;
1907 if (ic == 950) ichar = 966;
1908 if (ic == 947) ichar = 967;
1909 if (ic == 969) ichar = 968;
1910 if (ic == 967) ichar = 969;
1911 if (ic == 954) ichar = 966;
1912 if (ic == 922) ichar = 952;
1913 if (ic == 753) ichar = 965;
1916 Int_t len=strlen(chars);
1917 for (
Int_t i=0; i<len;i++) {
1918 if (chars[i]!=
'\n') {
1919 if (chars[i]==
'<') {
1921 }
else if (chars[i]==
'>') {
1923 }
else if (chars[i]==
'\305') {
1925 }
else if (chars[i]==
'\345') {
1927 }
else if (chars[i]==
'&') {
1960 return 0.5 + 72*
cm/2.54;
1969 return 0.5 + 72*
cm/2.54;
1996 Warning(
"TSVG::CellArrayBegin",
"not yet implemented");
2004 Warning(
"TSVG::CellArrayFill",
"not yet implemented");
2012 Warning(
"TSVG::CellArrayEnd",
"not yet implemented");
2020 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 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 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 ms
static constexpr double cm
static constexpr double m2
static constexpr double m3
Short_t Max(Short_t a, Short_t b)
Short_t Min(Short_t a, Short_t b)