13#pragma optimize("",off)
113 Warning(
"Open",
"SVG file already open");
118 fType = std::abs(wtype);
127 ww *=
gPad->GetWNDC();
128 wh *=
gPad->GetHNDC();
132 if (yrange >
fYsize) { yrange =
fYsize; xrange = yrange/ratio;}
138 Error(
"Open",
"Cannot open file: %s", fname);
190 Error(
"On",
"no SVG file open");
218 if (fillis == 3 || fillis == 2) {
226 if (fillsi > 0 && fillsi < 26) {
273 PrintFast(21,
"\" fill=\"none\" stroke=");
288 Double_t firstx = ixd0, firsty = iyd0;
295 for (
Int_t i = 1; i <
n; i++) {
326 if(!idx || (ix*idx > 0)) {
339 if(!idy || (iy*idy > 0)) {
372 xps[1] = xps[0] + border; yps[1] = yps[0] - border;
373 xps[2] = xps[1]; yps[2] =
YtoSVG(yt) + border;
374 xps[3] =
XtoSVG(xt) - border; yps[3] = yps[2];
376 xps[5] = xps[0]; yps[5] = yps[4];
377 xps[6] = xps[0]; yps[6] = yps[0];
389 xps[1] = xps[0] + border; yps[1] = yps[0] - border;
390 xps[2] =
XtoSVG(xt) - border; yps[2] = yps[1];
391 xps[3] = xps[2]; yps[3] =
YtoSVG(yt) + border;
393 xps[5] = xps[4]; yps[5] = yps[0];
394 xps[6] = xps[0]; yps[6] = yps[0];
417 Warning(
"DrawPolyLine",
"not implemented");
432 Warning(
"DrawPolyLineNDC",
"not implemented");
445 Int_t markerSize = 0;
446 std::vector<TPoint>
points;
475 for (
Int_t k = 0; k <
n; k++) {
479 if ((k > 0) && !draw_circles)
507 for (std::size_t i = 1; i <
points.size(); i++) {
517 for (std::size_t i = 0; i + 1 <
points.size(); i += 2) {
529 for (std::size_t i = 0; i + 2 <
points.size(); i += 3) {
558 PrintPolyMarkerShape<Float_t>(
n, xw, yw);
567 PrintPolyMarkerShape<Double_t>(
n, xw, yw);
576 PrintFast(21,
"\" fill=\"none\" stroke=");
589 sscanf(((
TObjString*)tokens->
At(j))->GetName(),
"%d", &it);
619 Int_t n, fais = 0, fasi = 0;
629 if (fais == 3 || fais == 2) {
630 if (fasi > 100 && fasi <125) {
633 if (fasi > 0 && fasi < 26) {
639 Error(
"DrawPS",
"Two points are needed");
671 Error(
"DrawSegments",
"At least one segment has to be provided");
678 for(
Int_t i = 0; i < 2*
n; i += 2) {
717 PrintStr(
"@<g transform=\"translate(");
732 Warning(
"CellArrayFill",
"not implemented");
765 auto x1 =
gPad->AbsPixeltoX(
x);
767 auto y1 =
gPad->AbsPixeltoY(
y);
775 char *buffer =
nullptr;
780 Error(
"DrawImage",
"Fail to get PNG format of the image");
787 PrintStr(
"@<g transform=\"translate(");
847 auto a = std::abs(
r);
854 snprintf(str, 15, (
a > 1) ?
"%3.1f" :
"%5.3f",
r);
871 if (ix != 0 && iy != 0) {
876 }
else if (ix != 0) {
879 }
else if (iy != 0) {
903 PrintStr(
"@<?xml version=\"1.0\" standalone=\"no\"?>");
912 PrintStr(
"\" xmlns=\"http://www.w3.org/2000/svg\" shape-rendering=\"crispEdges\">");
1033 if ((
a < 1.) && fill)
1035 if ((
a < 1.) && stroke)
1047 if (color < 0) color = 0;
1065 if (
r <= 0. &&
g <= 0. &&
b <= 0. ) {
1067 }
else if (
r >= 1. &&
g >= 1. &&
b >= 1. ) {
1071 snprintf(str,12,
"\"#%2.2x%2.2x%2.2x\"",
Int_t(255.*
r)
1095 static const char *fontFamily[] = {
1096 "Times" ,
"Times" ,
"Times",
1097 "Helvetica",
"Helvetica",
"Helvetica" ,
"Helvetica",
1098 "Courier" ,
"Courier" ,
"Courier" ,
"Courier",
1099 "Times" ,
"Times" ,
"ZapfDingbats",
"Times"};
1101 static const char *fontWeight[] = {
1102 "normal",
"bold",
"bold",
1103 "normal",
"normal",
"bold" ,
"bold",
1104 "normal",
"normal",
"bold" ,
"bold",
1105 "normal",
"normal",
"normal",
"normal"};
1107 static const char *fontStyle[] = {
1108 "italic",
"normal" ,
"italic",
1109 "normal",
"oblique",
"normal",
"oblique",
1110 "normal",
"oblique",
"normal",
"oblique",
1111 "normal",
"normal" ,
"normal",
"italic"};
1116 if (txalh <1) txalh = 1;
else if (txalh > 3) txalh = 3;
1118 if (txalv <1) txalv = 1;
else if (txalv > 3) txalv = 3;
1126 if (font > 15 || font < 1)
1133 Int_t ifont = font-1;
1136 if( fontsize <= 0)
return;
1138 if (txalv == 3) iy = iy+fontsize;
1139 if (txalv == 2) iy = iy+(fontsize/2);
1153 PrintFast(30,
"<text xml:space=\"preserve\" x=\"");
1159 PrintFast(21,
" text-anchor=\"middle\"");
1160 }
else if (txalh == 3) {
1169 if (strcmp(fontWeight[ifont],
"normal")) {
1173 if (strcmp(fontStyle[ifont],
"normal")) {
1179 if (font == 12 || font == 15) {
1180 Int_t ichar = chars[0]+848;
1184 if (ic == 755) ichar = 8804;
1185 if (ic == 759) ichar = 9827;
1186 if (ic == 760) ichar = 9830;
1187 if (ic == 761) ichar = 9829;
1188 if (ic == 762) ichar = 9824;
1189 if (ic == 766) ichar = 8594;
1190 if (ic == 776) ichar = 247;
1191 if (ic == 757) ichar = 8734;
1192 if (ic == 758) ichar = 402;
1193 if (ic == 771) ichar = 8805;
1194 if (ic == 774) ichar = 8706;
1195 if (ic == 775) ichar = 8226;
1196 if (ic == 779) ichar = 8776;
1197 if (ic == 805) ichar = 8719;
1198 if (ic == 821) ichar = 8721;
1199 if (ic == 834) ichar = 8747;
1200 if (ic == 769) ichar = 177;
1201 if (ic == 772) ichar = 215;
1202 if (ic == 768) ichar = 176;
1203 if (ic == 791) ichar = 8745;
1204 if (ic == 793) ichar = 8835;
1205 if (ic == 794) ichar = 8839;
1206 if (ic == 795) ichar = 8836;
1207 if (ic == 796) ichar = 8834;
1208 if (ic == 893) ichar = 8722;
1209 if (ic == 803) ichar = 169;
1210 if (ic == 819) ichar = 169;
1211 if (ic == 804) ichar = 8482;
1212 if (ic == 770) ichar = 34;
1213 if (ic == 823) ichar = 10072;
1214 if (ic == 781) ichar = 10072;
1215 if (ic == 824) ichar = 9117;
1216 if (ic == 822) ichar = 9115;
1217 if (ic == 767) ichar = 8595;
1218 if (ic == 763) ichar = 8596;
1219 if (ic == 764) ichar = 8592;
1220 if (ic == 788) ichar = 8855;
1221 if (ic == 784) ichar = 8501;
1222 if (ic == 777) ichar = 8800;
1223 if (ic == 797) ichar = 8838;
1224 if (ic == 800) ichar = 8736;
1225 if (ic == 812) ichar = 8656;
1226 if (ic == 817) ichar = 60;
1227 if (ic == 833) ichar = 62;
1228 if (ic == 778) ichar = 8803;
1229 if (ic == 809) ichar = 8743;
1230 if (ic == 802) ichar = 9415;
1231 if (ic == 780) ichar = 8230;
1232 if (ic == 801) ichar = 8711;
1233 if (ic == 783) ichar = 8629;
1234 if (ic == 782) ichar = 8213;
1235 if (ic == 799) ichar = 8713;
1236 if (ic == 792) ichar = 8746;
1237 if (ic == 828) ichar = 9127;
1238 if (ic == 765) ichar = 8593;
1239 if (ic == 789) ichar = 8853;
1240 if (ic == 813) ichar = 8657;
1241 if (ic == 773) ichar = 8733;
1242 if (ic == 790) ichar = 8709;
1243 if (ic == 810) ichar = 8744;
1244 if (ic == 756) ichar = 8260;
1245 if (ic == 807) ichar = 8231;
1246 if (ic == 808) ichar = 8989;
1247 if (ic == 814) ichar = 8658;
1248 if (ic == 806) ichar = 8730;
1249 if (ic == 827) ichar = 9123;
1250 if (ic == 829) ichar = 9128;
1251 if (ic == 786) ichar = 8476;
1252 if (ic == 785) ichar = 8465;
1253 if (ic == 787) ichar = 8472;
1254 if (ic == 882) ichar = 8704;
1255 if (ic == 884) ichar = 8707;
1256 if (ic == 815) ichar = 8659;
1257 if (ic == 811) ichar = 8660;
1258 if (ic == 826) ichar = 124;
1259 if (ic == 818) ichar = 9415;
1260 if (ic == 820) ichar = 8482;
1263 if (ic == 918) ichar = 934;
1264 if (ic == 919) ichar = 915;
1265 if (ic == 920) ichar = 919;
1266 if (ic == 923) ichar = 922;
1267 if (ic == 924) ichar = 923;
1268 if (ic == 925) ichar = 924;
1269 if (ic == 926) ichar = 925;
1270 if (ic == 929) ichar = 920;
1271 if (ic == 930) ichar = 929;
1272 if (ic == 936) ichar = 926;
1273 if (ic == 915) ichar = 935;
1274 if (ic == 937) ichar = 936;
1275 if (ic == 935) ichar = 937;
1276 if (ic == 938) ichar = 918;
1277 if (ic == 951) ichar = 947;
1278 if (ic == 798) ichar = 8712;
1279 if (ic == 970) ichar = 950;
1280 if (ic == 952) ichar = 951;
1281 if (ic == 961) ichar = 952;
1282 if (ic == 955) ichar = 954;
1283 if (ic == 956) ichar = 955;
1284 if (ic == 957) ichar = 956;
1285 if (ic == 958) ichar = 957;
1286 if (ic == 968) ichar = 958;
1287 if (ic == 934) ichar = 962;
1288 if (ic == 962) ichar = 961;
1289 if (ic == 966) ichar = 969;
1290 if (ic == 950) ichar = 966;
1291 if (ic == 947) ichar = 967;
1292 if (ic == 969) ichar = 968;
1293 if (ic == 967) ichar = 969;
1294 if (ic == 954) ichar = 966;
1295 if (ic == 922) ichar = 952;
1296 if (ic == 753) ichar = 965;
1301 if (chars[i]!=
'\n') {
1302 if (chars[i]==
'<') {
1304 }
else if (chars[i]==
'>') {
1306 }
else if (chars[i]==
'\305') {
1308 }
else if (chars[i]==
'\345') {
1310 }
else if (chars[i]==
'&') {
1361 return 0.5 + 72*cm/2.54;
1370 return 0.5 + 72*cm/2.54;
1396 Warning(
"TSVG::DrawPS",
"not yet implemented");
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
short Style_t
Style number (short)
int Int_t
Signed integer 4 bytes (int)
short Color_t
Color number (short)
short Width_t
Line width (short)
float Float_t
Float 4 bytes (float)
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char y1
R__EXTERN TStyle * gStyle
R__EXTERN TVirtualPS * 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.
virtual Style_t GetMarkerStyle() const
Return the marker style.
virtual Color_t GetMarkerColor() const
Return the marker color.
Color_t fMarkerColor
Marker color.
EMarkerShape GetMarkerShape(Int_t &sz, std::vector< TPoint > &points, Float_t scale=1., UInt_t flags=0) const
Return marker shape.
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
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.
The color creation and management class.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
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).
An abstract interface to image processing library.
virtual UInt_t GetWidth() const
virtual void GetImageBuffer(char **, int *, EImageFileTypes=TImage::kPng)
virtual UInt_t GetHeight() const
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.
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.
void DrawImage(TImage *img, Int_t x, Int_t y, Int_t flags=0) override
Draw image in the SVG Replaces CellArray methods calling.
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.
void PrintPolyMarkerShape(Int_t n, T *x, T *y)
Implementation of polymarker printing.
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.
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 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.
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.
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.