13#pragma optimize("",off)
111 Warning(
"Open",
"SVG file already open");
116 fType = std::abs(wtype);
125 ww *=
gPad->GetWNDC();
126 wh *=
gPad->GetHNDC();
130 if (yrange >
fYsize) { yrange =
fYsize; xrange = yrange/ratio;}
136 Error(
"Open",
"Cannot open file: %s", fname);
188 Error(
"On",
"no SVG file open");
216 if (fillis == 3 || fillis == 2) {
218 x[0] = x1;
y[0] = y1;
219 x[1] = x2;
y[1] = y1;
220 x[2] = x2;
y[2] = y2;
221 x[3] = x1;
y[3] = y2;
224 if (fillsi > 0 && fillsi < 26) {
225 x[0] = x1;
y[0] = y1;
226 x[1] = x2;
y[1] = y1;
227 x[2] = x2;
y[2] = y2;
228 x[3] = x1;
y[3] = y2;
271 PrintFast(21,
"\" fill=\"none\" stroke=");
286 Double_t firstx = ixd0, firsty = iyd0;
293 for (
Int_t i = 1; i <
n; i++) {
324 if(!idx || (ix*idx > 0)) {
337 if(!idy || (iy*idy > 0)) {
370 xps[1] = xps[0] + border; yps[1] = yps[0] - border;
371 xps[2] = xps[1]; yps[2] =
YtoSVG(yt) + border;
372 xps[3] =
XtoSVG(xt) - border; yps[3] = yps[2];
374 xps[5] = xps[0]; yps[5] = yps[4];
375 xps[6] = xps[0]; yps[6] = yps[0];
387 xps[1] = xps[0] + border; yps[1] = yps[0] - border;
388 xps[2] =
XtoSVG(xt) - border; yps[2] = yps[1];
389 xps[3] = xps[2]; yps[3] =
YtoSVG(yt) + border;
391 xps[5] = xps[4]; yps[5] = yps[0];
392 xps[6] = xps[0]; yps[6] = yps[0];
415 Warning(
"DrawPolyLine",
"not implemented");
430 Warning(
"DrawPolyLineNDC",
"not implemented");
444 else if (ms >= 6 && ms <= 8)
446 else if (ms >= 9 && ms <= 19)
455 const Int_t kBASEMARKER = 8;
456 Float_t sbase = msize*kBASEMARKER;
470 if ((ms > 19 && ms < 24) || ms == 29 || ms == 33 || ms == 34 ||
471 ms == 39 || ms == 41 || ms == 43 || ms == 45 ||
472 ms == 47 || ms == 48 || ms == 49) {
485 for (
Int_t i = 0; i <
n; i++) {
501 }
else if (ms == 2) {
522 }
else if (ms == 5) {
543 }
else if (ms == 3 || ms == 31) {
584 }
else if (ms == 24 || ms == 20) {
594 }
else if (ms == 25 || ms == 21) {
605 }
else if (ms == 26 || ms == 22) {
612 }
else if (ms == 23 || ms == 32) {
619 }
else if (ms == 27 || ms == 33) {
627 }
else if (ms == 28 || ms == 34) {
642 }
else if (ms == 29 || ms == 30) {
655 }
else if (ms == 35) {
666 }
else if (ms == 36) {
677 }
else if (ms == 37 || ms == 39) {
690 }
else if (ms == 38) {
708 }
else if (ms == 40 || ms == 41) {
724 }
else if (ms == 42 || ms == 43) {
736 }
else if (ms == 44) {
750 }
else if (ms == 45) {
766 }
else if (ms == 46 || ms == 47) {
782 }
else if (ms == 48) {
802 }
else if (ms == 49) {
860 PrintFast(21,
"\" fill=\"none\" stroke=");
873 sscanf(((
TObjString*)tokens->
At(j))->GetName(),
"%d", &it);
903 Int_t n, fais = 0, fasi = 0;
913 if (fais == 3 || fais == 2) {
914 if (fasi > 100 && fasi <125) {
917 if (fasi > 0 && fasi < 26) {
923 Error(
"DrawPS",
"Two points are needed");
955 Error(
"DrawSegments",
"At least one segment has to be provided");
962 for(
Int_t i = 0; i < 2*
n; i += 2) {
1001 PrintStr(
"@<g transform=\"translate(");
1016 Warning(
"CellArrayFill",
"not implemented");
1084 auto a = std::abs(
r);
1091 snprintf(str, 15, (
a > 1) ?
"%3.1f" :
"%5.3f",
r);
1108 if (ix != 0 && iy != 0) {
1113 }
else if (ix != 0) {
1116 }
else if (iy != 0) {
1140 PrintStr(
"@<?xml version=\"1.0\" standalone=\"no\"?>");
1149 PrintStr(
"\" xmlns=\"http://www.w3.org/2000/svg\" shape-rendering=\"crispEdges\">");
1270 if ((
a < 1.) && fill)
1272 if ((
a < 1.) && stroke)
1284 if (color < 0) color = 0;
1302 if (
r <= 0. &&
g <= 0. &&
b <= 0. ) {
1304 }
else if (
r >= 1. &&
g >= 1. &&
b >= 1. ) {
1332 static const char *fontFamily[] = {
1333 "Times" ,
"Times" ,
"Times",
1334 "Helvetica",
"Helvetica",
"Helvetica" ,
"Helvetica",
1335 "Courier" ,
"Courier" ,
"Courier" ,
"Courier",
1336 "Times" ,
"Times" ,
"ZapfDingbats",
"Times"};
1338 static const char *fontWeight[] = {
1339 "normal",
"bold",
"bold",
1340 "normal",
"normal",
"bold" ,
"bold",
1341 "normal",
"normal",
"bold" ,
"bold",
1342 "normal",
"normal",
"normal",
"normal"};
1344 static const char *fontStyle[] = {
1345 "italic",
"normal" ,
"italic",
1346 "normal",
"oblique",
"normal",
"oblique",
1347 "normal",
"oblique",
"normal",
"oblique",
1348 "normal",
"normal" ,
"normal",
"italic"};
1353 if (txalh <1) txalh = 1;
else if (txalh > 3) txalh = 3;
1355 if (txalv <1) txalv = 1;
else if (txalv > 3) txalv = 3;
1363 if (font > 15 || font < 1)
1370 Int_t ifont = font-1;
1373 if( fontsize <= 0)
return;
1375 if (txalv == 3) iy = iy+fontsize;
1376 if (txalv == 2) iy = iy+(fontsize/2);
1390 PrintFast(30,
"<text xml:space=\"preserve\" x=\"");
1396 PrintFast(21,
" text-anchor=\"middle\"");
1397 }
else if (txalh == 3) {
1406 if (strcmp(fontWeight[ifont],
"normal")) {
1410 if (strcmp(fontStyle[ifont],
"normal")) {
1416 if (font == 12 || font == 15) {
1417 Int_t ichar = chars[0]+848;
1421 if (ic == 755) ichar = 8804;
1422 if (ic == 759) ichar = 9827;
1423 if (ic == 760) ichar = 9830;
1424 if (ic == 761) ichar = 9829;
1425 if (ic == 762) ichar = 9824;
1426 if (ic == 766) ichar = 8594;
1427 if (ic == 776) ichar = 247;
1428 if (ic == 757) ichar = 8734;
1429 if (ic == 758) ichar = 402;
1430 if (ic == 771) ichar = 8805;
1431 if (ic == 774) ichar = 8706;
1432 if (ic == 775) ichar = 8226;
1433 if (ic == 779) ichar = 8776;
1434 if (ic == 805) ichar = 8719;
1435 if (ic == 821) ichar = 8721;
1436 if (ic == 834) ichar = 8747;
1437 if (ic == 769) ichar = 177;
1438 if (ic == 772) ichar = 215;
1439 if (ic == 768) ichar = 176;
1440 if (ic == 791) ichar = 8745;
1441 if (ic == 793) ichar = 8835;
1442 if (ic == 794) ichar = 8839;
1443 if (ic == 795) ichar = 8836;
1444 if (ic == 796) ichar = 8834;
1445 if (ic == 893) ichar = 8722;
1446 if (ic == 803) ichar = 169;
1447 if (ic == 819) ichar = 169;
1448 if (ic == 804) ichar = 8482;
1449 if (ic == 770) ichar = 34;
1450 if (ic == 823) ichar = 10072;
1451 if (ic == 781) ichar = 10072;
1452 if (ic == 824) ichar = 9117;
1453 if (ic == 822) ichar = 9115;
1454 if (ic == 767) ichar = 8595;
1455 if (ic == 763) ichar = 8596;
1456 if (ic == 764) ichar = 8592;
1457 if (ic == 788) ichar = 8855;
1458 if (ic == 784) ichar = 8501;
1459 if (ic == 777) ichar = 8800;
1460 if (ic == 797) ichar = 8838;
1461 if (ic == 800) ichar = 8736;
1462 if (ic == 812) ichar = 8656;
1463 if (ic == 817) ichar = 60;
1464 if (ic == 833) ichar = 62;
1465 if (ic == 778) ichar = 8803;
1466 if (ic == 809) ichar = 8743;
1467 if (ic == 802) ichar = 9415;
1468 if (ic == 780) ichar = 8230;
1469 if (ic == 801) ichar = 8711;
1470 if (ic == 783) ichar = 8629;
1471 if (ic == 782) ichar = 8213;
1472 if (ic == 799) ichar = 8713;
1473 if (ic == 792) ichar = 8746;
1474 if (ic == 828) ichar = 9127;
1475 if (ic == 765) ichar = 8593;
1476 if (ic == 789) ichar = 8853;
1477 if (ic == 813) ichar = 8657;
1478 if (ic == 773) ichar = 8733;
1479 if (ic == 790) ichar = 8709;
1480 if (ic == 810) ichar = 8744;
1481 if (ic == 756) ichar = 8260;
1482 if (ic == 807) ichar = 8231;
1483 if (ic == 808) ichar = 8989;
1484 if (ic == 814) ichar = 8658;
1485 if (ic == 806) ichar = 8730;
1486 if (ic == 827) ichar = 9123;
1487 if (ic == 829) ichar = 9128;
1488 if (ic == 786) ichar = 8476;
1489 if (ic == 785) ichar = 8465;
1490 if (ic == 787) ichar = 8472;
1493 if (ic == 918) ichar = 934;
1494 if (ic == 919) ichar = 915;
1495 if (ic == 920) ichar = 919;
1496 if (ic == 923) ichar = 922;
1497 if (ic == 924) ichar = 923;
1498 if (ic == 925) ichar = 924;
1499 if (ic == 926) ichar = 925;
1500 if (ic == 929) ichar = 920;
1501 if (ic == 930) ichar = 929;
1502 if (ic == 936) ichar = 926;
1503 if (ic == 915) ichar = 935;
1504 if (ic == 937) ichar = 936;
1505 if (ic == 935) ichar = 937;
1506 if (ic == 938) ichar = 918;
1507 if (ic == 951) ichar = 947;
1508 if (ic == 798) ichar = 949;
1509 if (ic == 970) ichar = 950;
1510 if (ic == 952) ichar = 951;
1511 if (ic == 961) ichar = 952;
1512 if (ic == 955) ichar = 954;
1513 if (ic == 956) ichar = 955;
1514 if (ic == 957) ichar = 956;
1515 if (ic == 958) ichar = 957;
1516 if (ic == 968) ichar = 958;
1517 if (ic == 934) ichar = 962;
1518 if (ic == 962) ichar = 961;
1519 if (ic == 966) ichar = 969;
1520 if (ic == 950) ichar = 966;
1521 if (ic == 947) ichar = 967;
1522 if (ic == 969) ichar = 968;
1523 if (ic == 967) ichar = 969;
1524 if (ic == 954) ichar = 966;
1525 if (ic == 922) ichar = 952;
1526 if (ic == 753) ichar = 965;
1529 Int_t len=strlen(chars);
1530 for (
Int_t i=0; i<len;i++) {
1531 if (chars[i]!=
'\n') {
1532 if (chars[i]==
'<') {
1534 }
else if (chars[i]==
'>') {
1536 }
else if (chars[i]==
'\305') {
1538 }
else if (chars[i]==
'\345') {
1540 }
else if (chars[i]==
'&') {
1591 return 0.5 + 72*cm/2.54;
1600 return 0.5 + 72*cm/2.54;
1626 Warning(
"TSVG::DrawPS",
"not yet implemented");
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
short Width_t
Line width (short).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
short Color_t
Color number (short).
short Style_t
Style number (short).
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
externTVirtualPS * gVirtualPS
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 Style_t GetMarkerStyleBase(Style_t style)
Size_t fMarkerSize
Marker size.
Style_t fMarkerStyle
Marker style.
static Width_t GetMarkerLineWidth(Style_t 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.
static TString Encode(const char *data)
Transform data into a null terminated base64 string.
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.
const char * GetName() const override
Returns name of object.
Int_t GetEntries() const override
Return the number of objects in array (i.e.
TObject * At(Int_t idx) const override
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.
void PrintPolyMarker(Int_t n, T *x, T *y)
Implementation of polymarker printing.
Double_t UtoSVG(Double_t u)
Convert U from NDC coordinate to SVG.
void MovePS(Double_t x, Double_t y)
Move to a new position (ix, iy).
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) override
Draw a Frame around a box.
void DrawPolyLineNDC(Int_t, TPoints *)
Draw a PolyLine in NDC space.
Double_t fYsizeSVG
Page's Y size in SVG units.
void CellArrayPng(char *buffer, int size) override
Paint the Cell Array as png image Disabled in compact mode to avoid creation of large SVG files.
void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y) override
Paint PolyMarker.
void TextUrl(Double_t x, Double_t y, const char *string, const char *url) override
Draw text with URL.
void Close(Option_t *opt="") override
Close a SVG file.
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Draw a Box.
Bool_t fRange
True when a range has been defined.
void Text(Double_t x, Double_t y, const char *string) override
Draw text.
Double_t YtoSVG(Double_t y)
Convert Y from world coordinate to SVG.
void PrintLineJointAttributes()
Print line join attributes - if present.
void SetFillColor(Color_t cindex=1) override
Set color index for fill areas.
void SetLineWidth(Width_t linewidth=1) override
Set the lines width.
void Initialize()
Initialize the SVG file.
void DrawPS(Int_t n, Float_t *xw, Float_t *yw) override
Not needed in SVG case.
void CellArrayEnd() override
End the Cell Array painting.
void CellArrayFill(Int_t r, Int_t g, Int_t b) override
Paint the Cell Array as single pixel.
void NewPage() override
Start the SVG page.
void PrintLineStyleOnEndOfPath()
Print line style attributes on the end of "path" string.
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 DrawPolyLine(Int_t, TPoints *)
Draw a PolyLine.
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 SetLineScale(Float_t=3)
void CellArrayBegin(Int_t W, Int_t H, Double_t x1, Double_t x2, Double_t y1, Double_t y2) override
Begin the Cell Array painting.
void SetLineStyle(Style_t linestyle=1) override
Change the line style.
void On()
Activate an already open SVG file.
TSVG()
Default SVG constructor.
void SetTextColor(Color_t cindex=1) override
Set color index for text.
Double_t CMtoSVG(Double_t u)
Double_t XtoSVG(Double_t x)
Convert X from world coordinate to SVG.
Bool_t fCompact
True when the SVG header is printed.
Bool_t fBoundingBox
True when the SVG header is printed.
Float_t fXsize
Page size along X.
void SetMarkerColor(Color_t cindex=1) override
Set color index for markers.
Float_t fYsize
Page size along Y.
void DrawSegments(Int_t n, Double_t *xw, Double_t *yw) override
This method draw N segments.
void TextNDC(Double_t u, Double_t v, const char *string)
Write a string of characters in NDC.
~TSVG() override
Default SVG destructor.
void SetLineColor(Color_t cindex=1) override
Set color index for lines.
void SetColorAlpha(Int_t color=1, Bool_t fill=kTRUE, Bool_t stroke=kTRUE)
Set RGBa color with its color index.
void SetLineJoin(Int_t linejoin=0)
Set the value of the global parameter TSVG::fgLineJoin.
void PrintPath(Bool_t convert, Int_t n, Double_t *xs, Double_t *ys, Bool_t close_path=kTRUE)
Print a svg path statement for specified points.
void Open(const char *filename, Int_t type=-111) override
Open a SVG file.
void WriteReal(Float_t r, Bool_t space=kTRUE) override
Write float value into output stream In compact form try to store only first 2-3 significant digits.
static Int_t fgLineCap
Appearance of line caps.
Double_t VtoSVG(Double_t v)
Convert V from NDC coordinate to SVG.
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
virtual void WriteInteger(Int_t i, Bool_t space=kTRUE)
Write one Integer to the file.
void CloseStream()
Close existing stream.
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.
Bool_t OpenStream(const char *fname, Bool_t binary=kFALSE)
Open output stream.
void ClearBuffer()
Clear content of internal buffer.
TVirtualPS(const TVirtualPS &)=delete
virtual void WriteReal(Float_t r, Bool_t space=kTRUE)
Write a Real number to the file.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.