Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSVG.cxx
Go to the documentation of this file.
1// @(#)root/postscript:$Id$
2// Author: Olivier Couet
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifdef WIN32
13#pragma optimize("",off)
14#endif
15
16#include "TROOT.h"
17#include "TDatime.h"
18#include "TBase64.h"
19#include "TColor.h"
20#include "TVirtualPad.h"
21#include "TPoint.h"
22#include "TPoints.h"
23#include "TImage.h"
24#include "TSVG.h"
25#include "TStyle.h"
26#include "TMath.h"
27#include "TObjString.h"
28#include "TObjArray.h"
29
30#include <cstdlib>
31#include <cstring>
32#include <cctype>
33#include <cmath>
34#include <fstream>
35#include <cstdio>
36
39
40const Double_t kEpsilon = 1e-9;
41
42/** \class TSVG
43\ingroup PS
44
45\brief Interface to SVG
46
47[SVG](http://www.w3.org/Graphics/SVG/Overview.htm8)
48(Scalable Vector Graphics) is a language for describing
49two-dimensional graphics in XML. SVG allows high quality vector graphics in
50HTML pages.
51
52To print a ROOT canvas "c1" into an SVG file simply do:
53~~~ {.cpp}
54 c1->Print("c1.svg");
55~~~
56The result is the ASCII file `c1.svg`.
57
58It can be open directly using a web browser or included in a html document
59the following way:
60~~~ {.cpp}
61<embed width="95%" height="500" src="c1.svg">
62~~~
63It is best viewed with Internet Explorer and you need the
64[Adobe SVG Viewer](http://www.adobe.com/svg/viewer/install/main.html)
65
66To zoom using the Adobe SVG Viewer, position the mouse over
67the area you want to zoom and click the right button.
68
69To define the zoom area,
70use Control+drag to mark the boundaries of the zoom area.
71
72To pan, use Alt+drag.
73By clicking with the right mouse button on the SVG graphics you will get
74a pop-up menu giving other ways to interact with the image.
75
76SVG files can be used directly in compressed mode to minimize the time
77transfer over the network. Compressed SVG files should be created using
78`gzip` on a normal ASCII SVG file and should then be renamed
79using the file extension `.svgz`.
80*/
81
82////////////////////////////////////////////////////////////////////////////////
83/// Default SVG constructor
84
86{
87 gVirtualPS = this;
88 SetTitle("SVG");
89}
90
91////////////////////////////////////////////////////////////////////////////////
92/// Initialize the SVG interface
93///
94/// - fname : SVG file name
95/// - wtype : SVG workstation type. Not used in the SVG driver. But as TSVG
96/// inherits from TVirtualPS it should be kept. Anyway it is not
97/// necessary to specify this parameter at creation time because it
98/// has a default value (which is ignore in the SVG case).
99
101{
102 SetTitle("SVG");
104 Open(fname, wtype);
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Open a SVG file
109
110void TSVG::Open(const char *fname, Int_t wtype)
111{
112 if (fStream) {
113 Warning("Open", "SVG file already open");
114 return;
115 }
116
117 fLenBuffer = 0;
118 fType = std::abs(wtype);
124 if (gPad) {
125 Double_t ww = gPad->GetWw();
126 Double_t wh = gPad->GetWh();
127 ww *= gPad->GetWNDC();
128 wh *= gPad->GetHNDC();
129 Double_t ratio = wh/ww;
130 xrange = fXsize;
131 yrange = fXsize*ratio;
132 if (yrange > fYsize) { yrange = fYsize; xrange = yrange/ratio;}
134 }
135
136 // Open OS file
137 if (!OpenStream(fname)) {
138 Error("Open", "Cannot open file: %s", fname);
139 return;
140 }
141
142 gVirtualPS = this;
143
144 ClearBuffer();
145
147
148 fRange = kFALSE;
149
150 // Set a default range
152
153 NewPage();
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Default SVG destructor
158
160{
161 Close();
162}
163
164////////////////////////////////////////////////////////////////////////////////
165/// Close a SVG file
166
168{
169 if (!gVirtualPS || !fStream)
170 return;
171 if (gPad)
172 gPad->Update();
173 PrintStr("</svg>@");
174
175 // Close file stream
176 CloseStream();
177
178 gVirtualPS = nullptr;
179}
180
181////////////////////////////////////////////////////////////////////////////////
182/// Activate an already open SVG file
183
185{
186 // fType is used to know if the SVG file is open. Unlike TPostScript, TSVG
187 // has no "workstation type". In fact there is only one SVG type.
188
189 if (!fType) {
190 Error("On", "no SVG file open");
191 Off();
192 return;
193 }
194 gVirtualPS = this;
195}
196
197////////////////////////////////////////////////////////////////////////////////
198/// Deactivate an already open SVG file
199
201{
202 gVirtualPS = nullptr;
203}
204
205////////////////////////////////////////////////////////////////////////////////
206/// Draw a Box
207
209{
210 Double_t x[4], y[4];
215 Int_t fillis = fFillStyle/1000;
216 Int_t fillsi = fFillStyle%1000;
217
218 if (fillis == 3 || fillis == 2) {
219 if (fillsi > 99) {
220 x[0] = x1; y[0] = y1;
221 x[1] = x2; y[1] = y1;
222 x[2] = x2; y[2] = y2;
223 x[3] = x1; y[3] = y2;
224 return;
225 }
226 if (fillsi > 0 && fillsi < 26) {
227 x[0] = x1; y[0] = y1;
228 x[1] = x2; y[1] = y1;
229 x[2] = x2; y[2] = y2;
230 x[3] = x1; y[3] = y2;
231 DrawPS(-4, &x[0], &y[0]);
232 }
233 if (fillsi == -3) {
234 PrintStr("@");
235 PrintFast(9,"<rect x=\"");
237 PrintFast(5,"\" y=\"");
239 PrintFast(9,"\" width=\"");
241 PrintFast(10,"\" height=\"");
243 PrintFast(7,"\" fill=");
245 PrintFast(2,"/>");
246 }
247 }
248 if (fillis == 1) {
249 PrintStr("@");
250 PrintFast(9,"<rect x=\"");
252 PrintFast(5,"\" y=\"");
254 PrintFast(9,"\" width=\"");
256 PrintFast(10,"\" height=\"");
258 PrintFast(7,"\" fill=");
260 PrintFast(2,"/>");
261 }
262 if (fillis == 0) {
263 if (fLineWidth<=0) return;
264 PrintStr("@");
265 PrintFast(9,"<rect x=\"");
267 PrintFast(5,"\" y=\"");
269 PrintFast(9,"\" width=\"");
271 PrintFast(10,"\" height=\"");
273 PrintFast(21,"\" fill=\"none\" stroke=");
275 PrintFast(2,"/>");
276 }
277}
278
279////////////////////////////////////////////////////////////////////////////////
280/// Print a svg path statement for specified points
281
283{
284 Double_t idx = 0, idy = 0;
285
286 Double_t ixd0 = convert ? XtoSVG(xps[0]) : xps[0];
287 Double_t iyd0 = convert ? YtoSVG(yps[0]) : yps[0];
289
290 PrintFast(1,"M");
292 PrintFast(1,",");
294
295 for (Int_t i = 1; i < n; i++) {
296 Double_t ixdi = convert ? XtoSVG(xps[i]) : xps[i];
297 Double_t iydi = convert ? YtoSVG(yps[i]) : yps[i];
298
299 Double_t ix = ixdi - ixd0;
300 Double_t iy = iydi - iyd0;
301
302 if (fCompact && (TMath::Abs(ix) < kEpsilon))
303 ix = 0;
304 if (fCompact && (TMath::Abs(iy) < kEpsilon))
305 iy = 0;
306
307 ixd0 = ixdi;
308 iyd0 = iydi;
309 if(ix && iy) {
310 if(idx) {
311 MovePS(idx, 0);
312 idx = 0;
313 }
314 if(idy) {
315 MovePS(0, idy);
316 idy = 0;
317 }
318 MovePS(ix, iy);
319 continue;
320 }
321 if (ix) {
322 if(idy) {
323 MovePS(0, idy);
324 idy = 0;
325 }
326 if(!idx || (ix*idx > 0)) {
327 idx += ix;
328 } else {
329 MovePS(idx, 0);
330 idx = ix;
331 }
332 continue;
333 }
334 if(iy) {
335 if(idx) {
336 MovePS(idx, 0);
337 idx = 0;
338 }
339 if(!idy || (iy*idy > 0)) {
340 idy += iy;
341 } else {
342 MovePS(0, idy);
343 idy = iy;
344 }
345 }
346 }
347 if(idx)
348 MovePS(idx, 0);
349 if(idy)
350 MovePS(0, idy);
351
353 PrintFast(1, "z");
354}
355
356////////////////////////////////////////////////////////////////////////////////
357/// Draw a Frame around a box
358///
359/// - mode = -1 the box looks as it is behind the screen
360/// - mode = 1 the box looks as it is in front of the screen
361/// - border is the border size in already pre-computed SVG units dark is the
362/// color for the dark part of the frame light is the color for the light
363/// part of the frame
364
366 Int_t mode, Int_t border, Int_t dark, Int_t light)
367{
368 Double_t xps[7], yps[7];
369
370 //- Draw top&left part of the box
371 xps[0] = XtoSVG(xl); yps[0] = YtoSVG(yl);
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];
375 xps[4] = XtoSVG(xt); yps[4] = YtoSVG(yt);
376 xps[5] = xps[0]; yps[5] = yps[4];
377 xps[6] = xps[0]; yps[6] = yps[0];
378
379 PrintStr("@");
380 PrintFast(9,"<path d=\"");
381 PrintPath(kFALSE, 7, xps, yps);
382 PrintFast(7,"\" fill=");
383 SetColorAlpha(mode == -1 ? dark : light);
385 PrintFast(2,"/>");
386
387 //- Draw bottom&right part of the box
388 xps[0] = XtoSVG(xl); yps[0] = YtoSVG(yl);
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;
392 xps[4] = XtoSVG(xt); yps[4] = YtoSVG(yt);
393 xps[5] = xps[4]; yps[5] = yps[0];
394 xps[6] = xps[0]; yps[6] = yps[0];
395
396 PrintStr("@");
397 PrintFast(9,"<path d=\"");
398 PrintPath(kFALSE, 7, xps, yps);
399 PrintFast(7,"\" fill=");
400 SetColorAlpha(mode == -1 ? light : dark);
402 PrintFast(2,"/>");
403}
404
405////////////////////////////////////////////////////////////////////////////////
406/// Draw a PolyLine
407///
408/// Draw a polyline through the points xy.
409/// - If NN=1 moves only to point x,y.
410/// - If NN=0 the x,y are written in the SVG file
411/// according to the current transformation.
412/// - If NN>0 the line is clipped as a line.
413/// - If NN<0 the line is clipped as a fill area.
414
416{
417 Warning("DrawPolyLine", "not implemented");
418}
419
420////////////////////////////////////////////////////////////////////////////////
421/// Draw a PolyLine in NDC space
422///
423/// Draw a polyline through the points xy.
424/// --If NN=1 moves only to point x,y.
425/// --If NN=0 the x,y are written in the SVG file
426/// according to the current transformation.
427/// --If NN>0 the line is clipped as a line.
428/// - If NN<0 the line is clipped as a fill area.
429
431{
432 Warning("DrawPolyLineNDC", "not implemented");
433}
434
435////////////////////////////////////////////////////////////////////////////////
436/// Implementation of polymarker printing
437
438template<typename T>
440{
441 Float_t s2x = 1. / Float_t(gPad->GetWw() * gPad->GetAbsWNDC());
442 // Rescale size of marker on SVG coordinates
443 Float_t scale = UtoSVG(s2x) - UtoSVG(0);
444
445 Int_t markerSize = 0;
446 std::vector<TPoint> points;
447 auto shape = GetMarkerShape(markerSize, points, scale, kDotAsCircle);
448
449 PrintStr("@");
450
451 bool draw_circles = (shape == kShapeFilledCircle) || (shape == kShapeCircle);
452 bool draw_fill = (shape == kShapeFilledCircle) || (shape == kShapeFilledArea) || (shape == kShapeTriangles);
453
454 if (draw_circles)
455 PrintStr("<g ");
456 else
457 PrintStr("<path ");
458
459 if (draw_fill) {
460 PrintStr("fill=");
462 } else {
463 PrintStr("stroke=");
465 PrintStr(" stroke-width=\"");
467 PrintStr("\" fill=\"none\"");
469 }
470 if (draw_circles)
471 PrintStr(">@");
472 else
473 PrintStr(" d=\"");
474
475 for (Int_t k = 0; k < n; k++) {
476 Double_t px = XtoSVG(xw[k]);
477 Double_t py = YtoSVG(yw[k]);
478 // add space between markers
479 if ((k > 0) && !draw_circles)
480 PrintStr(" ");
481
482 switch(shape) {
483 case kShapeDot:
484 PrintStr("M");
485 WriteReal(px-1, kFALSE);
486 PrintStr(",");
487 WriteReal(py, kFALSE);
488 PrintStr("h1");
489 break;
490 case kShapeCircle:
491 case kShapeFilledCircle: {
492 PrintStr("<circle cx=\"");
493 WriteReal(px, kFALSE);
494 PrintStr("\" cy=\"");
495 WriteReal(py, kFALSE);
496 PrintStr("\" r=\"");
497 WriteInteger(markerSize/2, kFALSE);
498 PrintStr("\"/>@");
499 break;
500 }
501 case kShapePolyLine:
502 case kShapeFilledArea:
503 PrintStr("M");
504 WriteReal(px + points.front().fX, kFALSE);
505 PrintStr(",");
506 WriteReal(py + points.front().fY, kFALSE);
507 for (std::size_t i = 1; i < points.size(); i++) {
508 PrintStr("l");
509 WriteInteger(points[i].fX - points[i-1].fX, kFALSE);
510 PrintStr(",");
511 WriteInteger(points[i].fY - points[i-1].fY, kFALSE);
512 }
513 if ((shape == kShapeFilledArea) || (points.front() == points.back()))
514 PrintStr("z");
515 break;
516 case kShapeSegments:
517 for (std::size_t i = 0; i + 1 < points.size(); i += 2) {
518 PrintStr("M");
519 WriteReal(px + points[i].fX, kFALSE);
520 PrintStr(",");
521 WriteReal(py + points[i].fY, kFALSE);
522 PrintStr("l");
523 WriteInteger(points[i+1].fX - points[i].fX, kFALSE);
524 PrintStr(",");
525 WriteInteger(points[i+1].fY - points[i].fY, kFALSE);
526 }
527 break;
528 case kShapeTriangles:
529 for (std::size_t i = 0; i + 2 < points.size(); i += 3) {
530 PrintStr("M");
531 WriteReal(px + points[i].fX, kFALSE);
532 PrintStr(",");
533 WriteReal(py + points[i].fY, kFALSE);
534 PrintStr("l");
535 WriteInteger(points[i+1].fX - points[i].fX, kFALSE);
536 PrintStr(",");
537 WriteInteger(points[i+1].fY - points[i].fY, kFALSE);
538 PrintStr("l");
539 WriteInteger(points[i+2].fX - points[i+1].fX, kFALSE);
540 PrintStr(",");
541 WriteInteger(points[i+2].fY - points[i+1].fY, kFALSE);
542 PrintStr("z");
543 }
544 break;
545 }
546 }
547 if (draw_circles)
548 PrintStr("</g>@");
549 else
550 PrintStr("\"/>");
551}
552
553////////////////////////////////////////////////////////////////////////////////
554/// Paint PolyMarker
555
560
561
562////////////////////////////////////////////////////////////////////////////////
563/// Paint PolyMarker
564
569
570
571////////////////////////////////////////////////////////////////////////////////
572/// Print line style attributes on the end of "path" string
573
575{
576 PrintFast(21,"\" fill=\"none\" stroke=");
578 if(fLineWidth > 1.) {
579 PrintFast(15," stroke-width=\"");
581 PrintFast(1,"\"");
582 }
583 if (fLineStyle > 1) {
584 PrintFast(19," stroke-dasharray=\"");
586 TObjArray *tokens = st.Tokenize(" ");
587 for (Int_t j = 0; j<tokens->GetEntries(); j++) {
588 Int_t it;
589 sscanf(((TObjString*)tokens->At(j))->GetName(), "%d", &it);
590 if (j>0) PrintFast(1,",");
591 WriteReal(it/4);
592 }
593 delete tokens;
594 PrintFast(1,"\"");
595 }
596}
597
598////////////////////////////////////////////////////////////////////////////////
599/// Print line join attributes - if present
600
602{
603 if (fgLineJoin)
604 PrintStr(TString::Format(" stroke-linejoin=\"%s\"", fgLineJoin == 1 ? "round" : "bevel"));
605 if (fgLineCap)
606 PrintStr(TString::Format(" stroke-linecap=\"%s\"", fgLineCap == 1 ? "round" : "square"));
607}
608
609
610////////////////////////////////////////////////////////////////////////////////
611/// This function defines a path with xw and yw and draw it according the
612/// value of nn:
613///
614/// - If nn>0 a line is drawn.
615/// - If nn<0 a closed polygon is drawn.
616
618{
619 Int_t n, fais = 0, fasi = 0;
620
621 if (nn > 0) {
622 if (fLineWidth <= 0)
623 return;
624 n = nn;
625 } else {
626 n = -nn;
627 fais = fFillStyle/1000;
628 fasi = fFillStyle%1000;
629 if (fais == 3 || fais == 2) {
630 if (fasi > 100 && fasi <125) {
631 return;
632 }
633 if (fasi > 0 && fasi < 26) {
634 }
635 }
636 }
637
638 if(n <= 1) {
639 Error("DrawPS", "Two points are needed");
640 return;
641 }
642
643 PrintStr("@");
644 PrintFast(9,"<path d=\"");
645
646 PrintPath(kTRUE, n, xw, yw, nn < 0);
647
648 if (nn > 0)
650 else {
651 PrintFast(7,"\" fill=");
652 if (fais == 0) {
653 PrintFast(14,"\"none\" stroke=");
655 } else {
657 }
658 }
660 PrintFast(2,"/>");
661}
662
663////////////////////////////////////////////////////////////////////////////////
664/// This method draw N segments
666{
667 if (fLineWidth < 0)
668 return;
669
670 if(n < 1) {
671 Error("DrawSegments", "At least one segment has to be provided");
672 return;
673 }
674
675 PrintStr("@");
676 PrintFast(9,"<path d=\"");
677
678 for(Int_t i = 0; i < 2*n; i += 2) {
679 Double_t ixd0 = XtoSVG(xw[i]);
680 Double_t iyd0 = YtoSVG(yw[i]);
681 Double_t ixd1 = XtoSVG(xw[i+1]);
682 Double_t iyd1 = YtoSVG(yw[i+1]);
683
684 Double_t dx = ixd1 - ixd0;
685 Double_t dy = iyd1 - iyd0;
686
687 if (fCompact && (TMath::Abs(dx) < kEpsilon))
688 dx = 0;
689 if (fCompact && (TMath::Abs(dy) < kEpsilon))
690 dy = 0;
691
692 if (dx || dy) {
693 PrintFast(1,"M");
695 PrintFast(1,",");
697 MovePS(dx, dy);
698 }
699 }
700
703 PrintFast(2,"/>");
704}
705
706
707////////////////////////////////////////////////////////////////////////////////
708/// Begin the Cell Array painting
709
711{
713 Double_t svgx2 = XtoSVG(x1 + (x2 - x1) * width);
715 Double_t svgy2 = YtoSVG(y1 - (y2 - y1) * height);
716
717 PrintStr("@<g transform=\"translate(");
720 PrintStr(") scale(");
723 PrintStr(")\">@");
724 PrintStr(TString::Format("<image width=\"%d\" height=\"%d\" href=\"data:image/png;base64,", width, height));
725}
726
727////////////////////////////////////////////////////////////////////////////////
728/// Paint the Cell Array as single pixel
729
731{
732 Warning("CellArrayFill", "not implemented");
733}
734
735////////////////////////////////////////////////////////////////////////////////
736/// Paint the Cell Array as png image
737/// Disabled in compact mode to avoid creation of large SVG files
738
739void TSVG::CellArrayPng(char *buffer, int size)
740{
741 if (!fCompact) {
742 TString base64 = TBase64::Encode(reinterpret_cast<char *>(buffer), size);
743 PrintFast(base64.Length(), base64.Data());
744 }
745}
746
747////////////////////////////////////////////////////////////////////////////////
748/// End the Cell Array painting
749
751{
752 PrintStr("\"></image>@");
753 PrintStr("</g>@");
754}
755
756////////////////////////////////////////////////////////////////////////////////
757/// Draw image in the SVG
758/// Replaces CellArray methods calling
759
761{
762 Int_t width = img->GetWidth();
763 Int_t height = img->GetHeight();
764
765 auto x1 = gPad->AbsPixeltoX(x);
766 auto x2 = gPad->AbsPixeltoX(x + width);
767 auto y1 = gPad->AbsPixeltoY(y);
768 auto y2 = gPad->AbsPixeltoY(y + height);
769
774
775 char *buffer = nullptr;
776 int size = 0;
777
778 img->GetImageBuffer(&buffer, &size, TImage::kPng);
779 if (!buffer) {
780 Error("DrawImage", "Fail to get PNG format of the image");
781 return;
782 }
783
784 TString base64 = TBase64::Encode(reinterpret_cast<char *>(buffer), size);
785 free(buffer);
786
787 PrintStr("@<g transform=\"translate(");
790 PrintStr(") scale(");
793 PrintStr(")\">@");
794 PrintStr(TString::Format("<image width=\"%d\" height=\"%d\" href=\"data:image/png;base64,", width, height));
795
796 if (!fCompact)
797 PrintFast(base64.Length(), base64.Data());
798
799 PrintStr("\"></image>@");
800 PrintStr("</g>@");
801}
802
803////////////////////////////////////////////////////////////////////////////////
804/// Initialize the SVG file. The main task of the function is to output the
805/// SVG header file which consist in `<title>`, `<desc>` and `<defs>`. The
806/// HeaderPS provided by the user program is written in the `<defs>` part.
807
809{
810 // Title
811 PrintStr("<title>@");
812 PrintStr(GetName());
813 PrintStr("@");
814 PrintStr("</title>@");
815
816 if (fCompact)
817 return;
818
819 // Description
820 PrintStr("<desc>@");
821 PrintFast(22,"Creator: ROOT Version ");
822 PrintStr(gROOT->GetVersion());
823 PrintStr("@");
824 PrintFast(14,"CreationDate: ");
825 TDatime t;
826 PrintStr(t.AsString());
827 //Check a special header is defined in the current style
829 if (nh) {
831 }
832 PrintStr("</desc>@");
833
834 // Definitions
835 PrintStr("<defs>@");
836 PrintStr("</defs>@");
837
838}
839
840////////////////////////////////////////////////////////////////////////////////
841/// Write float value into output stream
842/// In compact form try to store only first 2-3 significant digits
843
845{
846 if (fCompact) {
847 auto a = std::abs(r);
848 if (a > 10)
849 TVirtualPS::WriteInteger(std::lround(r), space);
850 else if (a < 0.005)
851 TVirtualPS::WriteReal(r, space);
852 else {
853 char str[15];
854 snprintf(str, 15, (a > 1) ? "%3.1f" : "%5.3f", r);
855 if(space)
856 PrintFast(1," ");
857 PrintStr(str);
858 }
859 } else
860 TVirtualPS::WriteReal(r, space);
861}
862
863////////////////////////////////////////////////////////////////////////////////
864/// Move to a new position (ix, iy). The move is done in relative coordinates
865/// which allows to have short numbers which decrease the size of the file.
866/// This function use the full power of the SVG's paths by using the
867/// horizontal and vertical move whenever it is possible.
868
870{
871 if (ix != 0 && iy != 0) {
872 PrintFast(1,"l");
873 WriteReal(ix);
874 PrintFast(1,",");
875 WriteReal(iy);
876 } else if (ix != 0) {
877 PrintFast(1,"h");
878 WriteReal(ix);
879 } else if (iy != 0) {
880 PrintFast(1,"v");
881 WriteReal(iy);
882 }
883}
884
885////////////////////////////////////////////////////////////////////////////////
886/// Start the SVG page. This function initialize the pad conversion
887/// coefficients and output the `<svg>` directive which is close later in the
888/// the function Close.
889
891{
892 // Compute pad conversion coefficients
893 if (gPad) {
894 Double_t ww = gPad->GetWw();
895 Double_t wh = gPad->GetWh();
896 fYsize = fXsize*wh/ww;
897 } else {
898 fYsize = 27;
899 }
900
901 // <svg> directive. It defines the viewBox.
902 if(!fBoundingBox) {
903 PrintStr("@<?xml version=\"1.0\" standalone=\"no\"?>");
904 PrintStr("@<svg width=\"");
906 PrintStr("\" height=\"");
909 PrintStr("\" viewBox=\"0 0");
912 PrintStr("\" xmlns=\"http://www.w3.org/2000/svg\" shape-rendering=\"crispEdges\">");
913 PrintStr("@");
914 Initialize();
916 }
917}
918
919////////////////////////////////////////////////////////////////////////////////
920/// Set the range for the paper in centimetres
921
923{
924 fXsize = xsize;
925 fYsize = ysize;
926 fRange = kTRUE;
927}
928
929////////////////////////////////////////////////////////////////////////////////
930/// Set color index for fill areas
931
936
937////////////////////////////////////////////////////////////////////////////////
938/// Set color index for lines
939
944
945////////////////////////////////////////////////////////////////////////////////
946/// Set the value of the global parameter TSVG::fgLineJoin.
947/// This parameter determines the appearance of joining lines in a SVG
948/// output.
949/// It takes one argument which may be:
950/// - 0 (miter join)
951/// - 1 (round join)
952/// - 2 (bevel join)
953/// The default value is 0 (miter join).
954///
955/// \image html postscript_1.png
956///
957/// To change the line join behaviour just do:
958/// ~~~ {.cpp}
959/// gStyle->SetJoinLinePS(2); // Set the PS line join to bevel.
960/// ~~~
961
963{
965 if (fgLineJoin<0) fgLineJoin=0;
966 if (fgLineJoin>2) fgLineJoin=2;
967}
968
969////////////////////////////////////////////////////////////////////////////////
970/// Set the value of the global parameter TSVG::fgLineCap.
971/// This parameter determines the appearance of line caps in a SVG
972/// output.
973/// It takes one argument which may be:
974/// - 0 (butt caps)
975/// - 1 (round caps)
976/// - 2 (projecting caps)
977/// The default value is 0 (butt caps).
978///
979/// \image html postscript_2.png
980///
981/// To change the line cap behaviour just do:
982/// ~~~ {.cpp}
983/// gStyle->SetCapLinePS(2); // Set the PS line cap to projecting.
984/// ~~~
985
987{
989 if (fgLineCap<0) fgLineCap=0;
990 if (fgLineCap>2) fgLineCap=2;
991}
992
993////////////////////////////////////////////////////////////////////////////////
994/// Change the line style
995///
996/// - linestyle = 2 dashed
997/// - linestyle = 3 dotted
998/// - linestyle = 4 dash-dotted
999/// - linestyle = else solid (1 in is used most of the time)
1000
1005
1006////////////////////////////////////////////////////////////////////////////////
1007/// Set the lines width.
1008
1013
1014////////////////////////////////////////////////////////////////////////////////
1015/// Set color index for markers.
1016
1021
1022////////////////////////////////////////////////////////////////////////////////
1023/// Set RGBa color with its color index
1024
1026{
1027 if (color < 0)
1028 color = 0;
1029 TColor *col = gROOT->GetColor(color);
1030 if (col) {
1031 SetColor(col->GetRed(), col->GetGreen(), col->GetBlue());
1032 Float_t a = col->GetAlpha();
1033 if ((a < 1.) && fill)
1034 PrintStr(TString::Format(" fill-opacity=\"%3.2f\"",a));
1035 if ((a < 1.) && stroke)
1036 PrintStr(TString::Format(" stroke-opacity=\"%3.2f\"",a));
1037 } else {
1038 SetColor(1., 1., 1.);
1039 }
1040}
1041
1042////////////////////////////////////////////////////////////////////////////////
1043/// Set RGB (without alpha channel) color with its color index
1044
1046{
1047 if (color < 0) color = 0;
1048 TColor *col = gROOT->GetColor(color);
1049 if (col) {
1050 SetColor(col->GetRed(), col->GetGreen(), col->GetBlue());
1051 } else {
1052 SetColor(1., 1., 1.);
1053 }
1054}
1055
1056////////////////////////////////////////////////////////////////////////////////
1057/// Set color with its R G B components
1058///
1059/// - r: % of red in [0,1]
1060/// --g: % of green in [0,1]
1061/// - b: % of blue in [0,1]
1062
1064{
1065 if (r <= 0. && g <= 0. && b <= 0. ) {
1066 PrintFast(7,"\"black\"");
1067 } else if (r >= 1. && g >= 1. && b >= 1. ) {
1068 PrintFast(7,"\"white\"");
1069 } else {
1070 char str[12];
1071 snprintf(str,12,"\"#%2.2x%2.2x%2.2x\"",Int_t(255.*r)
1072 ,Int_t(255.*g)
1073 ,Int_t(255.*b));
1074 PrintStr(str);
1075 }
1076}
1077
1078////////////////////////////////////////////////////////////////////////////////
1079/// Set color index for text
1080
1085
1086////////////////////////////////////////////////////////////////////////////////
1087/// Draw text
1088///
1089/// - xx: x position of the text
1090/// - yy: y position of the text
1091/// - chars: text to be drawn
1092
1094{
1095 static const char *fontFamily[] = {
1096 "Times" , "Times" , "Times",
1097 "Helvetica", "Helvetica", "Helvetica" , "Helvetica",
1098 "Courier" , "Courier" , "Courier" , "Courier",
1099 "Times" ,"Times" , "ZapfDingbats", "Times"};
1100
1101 static const char *fontWeight[] = {
1102 "normal", "bold", "bold",
1103 "normal", "normal", "bold" , "bold",
1104 "normal", "normal", "bold" , "bold",
1105 "normal", "normal", "normal", "normal"};
1106
1107 static const char *fontStyle[] = {
1108 "italic", "normal" , "italic",
1109 "normal", "oblique", "normal", "oblique",
1110 "normal", "oblique", "normal", "oblique",
1111 "normal", "normal" , "normal", "italic"};
1112
1113 Double_t ix = XtoSVG(xx);
1114 Double_t iy = YtoSVG(yy);
1116 if (txalh <1) txalh = 1; else if (txalh > 3) txalh = 3;
1118 if (txalv <1) txalv = 1; else if (txalv > 3) txalv = 3;
1119
1120 Double_t wh = (Double_t)gPad->GetPadWidth();
1121 Double_t hh = (Double_t)gPad->GetPadHeight();
1122 Float_t fontrap = 1.09; //scale down compared to X11
1124
1125 Int_t font = abs(fTextFont)/10;
1126 if (font > 15 || font < 1)
1127 font = 1;
1128 if (wh < hh) {
1129 ftsize = fTextSize*fXsize*gPad->GetAbsWNDC();
1130 } else {
1131 ftsize = fTextSize*fYsize*gPad->GetAbsHNDC();
1132 }
1133 Int_t ifont = font-1;
1134
1136 if( fontsize <= 0) return;
1137
1138 if (txalv == 3) iy = iy+fontsize;
1139 if (txalv == 2) iy = iy+(fontsize/2);
1140
1141 if (fTextAngle != 0.) {
1142 PrintStr("@");
1143 PrintFast(21,"<g transform=\"rotate(");
1145 PrintFast(1,",");
1146 WriteReal(ix, kFALSE);
1147 PrintFast(1,",");
1148 WriteReal(iy, kFALSE);
1149 PrintFast(3,")\">");
1150 }
1151
1152 PrintStr("@");
1153 PrintFast(30,"<text xml:space=\"preserve\" x=\"");
1154 WriteReal(ix, kFALSE);
1155 PrintFast(5,"\" y=\"");
1156 WriteReal(iy, kFALSE);
1157 PrintFast(1,"\"");
1158 if (txalh == 2) {
1159 PrintFast(21," text-anchor=\"middle\"");
1160 } else if (txalh == 3) {
1161 PrintFast(18," text-anchor=\"end\"");
1162 }
1163 PrintFast(6," fill=");
1165 PrintFast(12," font-size=\"");
1167 PrintFast(15,"\" font-family=\"");
1169 if (strcmp(fontWeight[ifont],"normal")) {
1170 PrintFast(15,"\" font-weight=\"");
1172 }
1173 if (strcmp(fontStyle[ifont],"normal")) {
1174 PrintFast(14,"\" font-style=\"");
1176 }
1177 PrintFast(2,"\">");
1178
1179 if (font == 12 || font == 15) {
1180 Int_t ichar = chars[0]+848;
1181 Int_t ic = ichar;
1182
1183 // Math Symbols (cf: http://www.fileformat.info/info/unicode/category/Sm/list.htm)
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; // SUPERSET OF
1205 if (ic == 794) ichar = 8839; // SUPERSET OF OR EQUAL TO
1206 if (ic == 795) ichar = 8836; // NOT A SUBSET OF
1207 if (ic == 796) ichar = 8834;
1208 if (ic == 893) ichar = 8722;
1209 if (ic == 803) ichar = 169; // COPYRIGHT SIGN
1210 if (ic == 819) ichar = 169; // COPYRIGHT SIGN
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; // LEFT PARENTHESIS LOWER HOOK
1216 if (ic == 822) ichar = 9115; // LEFT PARENTHESIS UPPER HOOK
1217 if (ic == 767) ichar = 8595; // DOWNWARDS ARROW
1218 if (ic == 763) ichar = 8596; // LEFT RIGHT ARROW
1219 if (ic == 764) ichar = 8592; // LEFTWARDS ARROW
1220 if (ic == 788) ichar = 8855; // CIRCLED TIMES
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; // LEFTWARDS DOUBLE ARROW
1226 if (ic == 817) ichar = 60; // LESS-THAN SIGN
1227 if (ic == 833) ichar = 62; // GREATER-THAN SIGN
1228 if (ic == 778) ichar = 8803; // STRICTLY EQUIVALENT TO
1229 if (ic == 809) ichar = 8743; // LOGICAL AND
1230 if (ic == 802) ichar = 9415; // CIRCLED LATIN CAPITAL LETTER R
1231 if (ic == 780) ichar = 8230; // HORIZONTAL ELLIPSIS
1232 if (ic == 801) ichar = 8711; // NABLA
1233 if (ic == 783) ichar = 8629; // DOWNWARDS ARROW WITH CORNER LEFTWARDS
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; // UPWARDS ARROW
1239 if (ic == 789) ichar = 8853; // CIRCLED PLUS
1240 if (ic == 813) ichar = 8657; // UPWARDS DOUBLE ARROW
1241 if (ic == 773) ichar = 8733; // PROPORTIONAL TO
1242 if (ic == 790) ichar = 8709; // EMPTY SET
1243 if (ic == 810) ichar = 8744;
1244 if (ic == 756) ichar = 8260;
1245 if (ic == 807) ichar = 8231;
1246 if (ic == 808) ichar = 8989; // TOP RIGHT CORNER
1247 if (ic == 814) ichar = 8658; // RIGHTWARDS DOUBLE ARROW
1248 if (ic == 806) ichar = 8730; // SQUARE ROOT
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; // FOR ALL
1255 if (ic == 884) ichar = 8707; // THERE EXISTS
1256 if (ic == 815) ichar = 8659; // DOWNWARDS DOUBLE ARROW
1257 if (ic == 811) ichar = 8660; // LEFT RIGHT DOUBLE ARROW
1258 if (ic == 826) ichar = 124; // VERTICAL LINE
1259 if (ic == 818) ichar = 9415; // CIRCLED LATIN CAPITAL LETTER R
1260 if (ic == 820) ichar = 8482; // TRADEMARK SIGN
1261
1262 // Greek characters
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; // ELEMENT OF, TeX traditionally assigns \epsilon to GREEK LUNATE EPSILON SYMBOL (ϵ), compared to the curly \varepsilon to the GREEK SMALL LETTER EPSILON (Ɛ)
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;
1297 PrintStr(TString::Format("&#%4.4d;",ichar));
1298 } else {
1300 for (Int_t i=0; i<len;i++) {
1301 if (chars[i]!='\n') {
1302 if (chars[i]=='<') {
1303 PrintFast(4,"&lt;");
1304 } else if (chars[i]=='>') {
1305 PrintFast(4,"&gt;");
1306 } else if (chars[i]=='\305') {
1307 PrintFast(7,"&#8491;"); // ANGSTROM SIGN
1308 } else if (chars[i]=='\345') {
1309 PrintFast(6,"&#229;");
1310 } else if (chars[i]=='&') {
1311 PrintFast(5,"&amp;");
1312 } else {
1313 PrintFast(1,&chars[i]);
1314 }
1315 }
1316 }
1317 }
1318
1319 PrintStr("@");
1320 PrintFast(7,"</text>");
1321
1322 if (fTextAngle != 0.) {
1323 PrintStr("@");
1324 PrintFast(4,"</g>");
1325 }
1326}
1327
1328////////////////////////////////////////////////////////////////////////////////
1329/// Draw text with URL.
1330///
1331
1332void TSVG::TextUrl(Double_t x, Double_t y, const char *chars, const char *url)
1333{
1334 PrintStr("@");
1335 PrintFast(9,"<a href=\"");
1336 PrintStr(url);
1337 PrintFast(2,"\">");
1338 PrintStr("@");
1339 Text(x, y, chars);
1340 PrintStr("@");
1341 PrintFast(4,"</a>");
1342 PrintStr("@");
1343}
1344
1345////////////////////////////////////////////////////////////////////////////////
1346/// Write a string of characters in NDC
1347
1349{
1350 Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
1351 Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
1352 Text(x, y, chars);
1353}
1354
1355////////////////////////////////////////////////////////////////////////////////
1356/// Convert U from NDC coordinate to SVG
1357
1359{
1360 Double_t cm = fXsize*(gPad->GetAbsXlowNDC() + u*gPad->GetAbsWNDC());
1361 return 0.5 + 72*cm/2.54;
1362}
1363
1364////////////////////////////////////////////////////////////////////////////////
1365/// Convert V from NDC coordinate to SVG
1366
1368{
1369 Double_t cm = fYsize*(gPad->GetAbsYlowNDC() + v*gPad->GetAbsHNDC());
1370 return 0.5 + 72*cm/2.54;
1371}
1372
1373////////////////////////////////////////////////////////////////////////////////
1374/// Convert X from world coordinate to SVG
1375
1377{
1378 Double_t u = (x - gPad->GetX1())/(gPad->GetX2() - gPad->GetX1());
1379 return UtoSVG(u);
1380}
1381
1382////////////////////////////////////////////////////////////////////////////////
1383/// Convert Y from world coordinate to SVG
1384
1386{
1387 Double_t v = (y - gPad->GetY1())/(gPad->GetY2() - gPad->GetY1());
1388 return fYsizeSVG-VtoSVG(v);
1389}
1390
1391////////////////////////////////////////////////////////////////////////////////
1392/// Not needed in SVG case
1393
1395{
1396 Warning("TSVG::DrawPS", "not yet implemented");
1397}
free(fBuffer)
#define b(i)
Definition RSha256.hxx:100
#define g(i)
Definition RSha256.hxx:105
#define a(i)
Definition RSha256.hxx:99
#define e(i)
Definition RSha256.hxx:103
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
short Style_t
Style number (short)
Definition RtypesCore.h:97
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
short Color_t
Color number (short)
Definition RtypesCore.h:100
short Width_t
Line width (short)
Definition RtypesCore.h:99
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t cindex
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 width
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
#define gROOT
Definition TROOT.h:417
const Double_t kEpsilon
Definition TSVG.cxx:40
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
R__EXTERN TVirtualPS * gVirtualPS
Definition TVirtualPS.h:93
#define gPad
Style_t fFillStyle
Fill area style.
Definition TAttFill.h:25
Color_t fFillColor
Fill area color.
Definition TAttFill.h:24
Width_t fLineWidth
Line width.
Definition TAttLine.h:26
Style_t fLineStyle
Line style.
Definition TAttLine.h:25
Color_t fLineColor
Line color.
Definition TAttLine.h:24
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition TAttMarker.h:35
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition TAttMarker.h:34
Color_t fMarkerColor
Marker color.
Definition TAttMarker.h:25
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)
@ kShapeTriangles
Definition TAttMarker.h:48
@ kShapeFilledArea
Definition TAttMarker.h:48
@ kShapeFilledCircle
Definition TAttMarker.h:48
Color_t fTextColor
Text color.
Definition TAttText.h:27
Float_t fTextAngle
Text angle.
Definition TAttText.h:24
Font_t fTextFont
Text font.
Definition TAttText.h:28
Short_t fTextAlign
Text alignment.
Definition TAttText.h:26
Float_t fTextSize
Text size.
Definition TAttText.h:25
static TString Encode(const char *data)
Transform data into a null terminated base64 string.
Definition TBase64.cxx:106
The color creation and management class.
Definition TColor.h:22
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition TDatime.cxx:98
An abstract interface to image processing library.
Definition TImage.h:29
@ kPng
Definition TImage.h:40
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
An array of TObjects.
Definition TObjArray.h:31
Collectable string class.
Definition TObjString.h:28
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
SCoord_t fY
Definition TPoint.h:36
SCoord_t fX
Definition TPoint.h:35
2-D graphics point (world coordinates).
Definition TPoints.h:19
static Int_t fgLineJoin
Appearance of joining lines.
Definition TSVG.h:31
Double_t UtoSVG(Double_t u)
Convert U from NDC coordinate to SVG.
Definition TSVG.cxx:1358
void MovePS(Double_t x, Double_t y)
Move to a new position (ix, iy).
Definition TSVG.cxx:869
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.
Definition TSVG.cxx:365
void DrawPolyLineNDC(Int_t, TPoints *)
Draw a PolyLine in NDC space.
Definition TSVG.cxx:430
Double_t fYsizeSVG
Page's Y size in SVG units.
Definition TSVG.h:29
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.
Definition TSVG.cxx:739
void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y) override
Paint PolyMarker.
Definition TSVG.cxx:556
void TextUrl(Double_t x, Double_t y, const char *string, const char *url) override
Draw text with URL.
Definition TSVG.cxx:1332
void Close(Option_t *opt="") override
Close a SVG file.
Definition TSVG.cxx:167
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Draw a Box.
Definition TSVG.cxx:208
Bool_t fRange
True when a range has been defined.
Definition TSVG.h:28
void Text(Double_t x, Double_t y, const char *string) override
Draw text.
Definition TSVG.cxx:1093
Double_t YtoSVG(Double_t y)
Convert Y from world coordinate to SVG.
Definition TSVG.cxx:1385
void PrintLineJointAttributes()
Print line join attributes - if present.
Definition TSVG.cxx:601
void SetFillColor(Color_t cindex=1) override
Set color index for fill areas.
Definition TSVG.cxx:932
void SetLineWidth(Width_t linewidth=1) override
Set the lines width.
Definition TSVG.cxx:1009
void Initialize()
Initialize the SVG file.
Definition TSVG.cxx:808
void DrawPS(Int_t n, Float_t *xw, Float_t *yw) override
Not needed in SVG case.
Definition TSVG.cxx:1394
void CellArrayEnd() override
End the Cell Array painting.
Definition TSVG.cxx:750
void CellArrayFill(Int_t r, Int_t g, Int_t b) override
Paint the Cell Array as single pixel.
Definition TSVG.cxx:730
void NewPage() override
Start the SVG page.
Definition TSVG.cxx:890
void PrintLineStyleOnEndOfPath()
Print line style attributes on the end of "path" string.
Definition TSVG.cxx:574
void SetColor(Int_t color=1)
Set RGB (without alpha channel) color with its color index.
Definition TSVG.cxx:1045
Int_t fType
Workstation type used to know if the SVG is open.
Definition TSVG.h:25
void SetLineCap(Int_t linecap=0)
Set the value of the global parameter TSVG::fgLineCap.
Definition TSVG.cxx:986
void DrawPolyLine(Int_t, TPoints *)
Draw a PolyLine.
Definition TSVG.cxx:415
void Off()
Deactivate an already open SVG file.
Definition TSVG.cxx:200
void Range(Float_t xrange, Float_t yrange)
Set the range for the paper in centimetres.
Definition TSVG.cxx:922
void SetLineScale(Float_t=3)
Definition TSVG.h:81
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.
Definition TSVG.cxx:710
void SetLineStyle(Style_t linestyle=1) override
Change the line style.
Definition TSVG.cxx:1001
void On()
Activate an already open SVG file.
Definition TSVG.cxx:184
TSVG()
Default SVG constructor.
Definition TSVG.cxx:85
void SetTextColor(Color_t cindex=1) override
Set color index for text.
Definition TSVG.cxx:1081
void DrawImage(TImage *img, Int_t x, Int_t y, Int_t flags=0) override
Draw image in the SVG Replaces CellArray methods calling.
Definition TSVG.cxx:760
Double_t CMtoSVG(Double_t u)
Definition TSVG.h:53
Double_t XtoSVG(Double_t x)
Convert X from world coordinate to SVG.
Definition TSVG.cxx:1376
Bool_t fCompact
True when the SVG header is printed.
Definition TSVG.h:26
Bool_t fBoundingBox
True when the SVG header is printed.
Definition TSVG.h:27
Float_t fXsize
Page size along X.
Definition TSVG.h:23
void SetMarkerColor(Color_t cindex=1) override
Set color index for markers.
Definition TSVG.cxx:1017
Float_t fYsize
Page size along Y.
Definition TSVG.h:24
void DrawSegments(Int_t n, Double_t *xw, Double_t *yw) override
This method draw N segments.
Definition TSVG.cxx:665
void TextNDC(Double_t u, Double_t v, const char *string)
Write a string of characters in NDC.
Definition TSVG.cxx:1348
~TSVG() override
Default SVG destructor.
Definition TSVG.cxx:159
void SetLineColor(Color_t cindex=1) override
Set color index for lines.
Definition TSVG.cxx:940
void SetColorAlpha(Int_t color=1, Bool_t fill=kTRUE, Bool_t stroke=kTRUE)
Set RGBa color with its color index.
Definition TSVG.cxx:1025
void SetLineJoin(Int_t linejoin=0)
Set the value of the global parameter TSVG::fgLineJoin.
Definition TSVG.cxx:962
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.
Definition TSVG.cxx:282
void Open(const char *filename, Int_t type=-111) override
Open a SVG file.
Definition TSVG.cxx:110
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.
Definition TSVG.cxx:844
void PrintPolyMarkerShape(Int_t n, T *x, T *y)
Implementation of polymarker printing.
Definition TSVG.cxx:439
static Int_t fgLineCap
Appearance of line caps.
Definition TSVG.h:32
Double_t VtoSVG(Double_t v)
Convert V from NDC coordinate to SVG.
Definition TSVG.cxx:1367
Basic string class.
Definition TString.h:137
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2460
Int_t GetJoinLinePS() const
Returns the line join method used for PostScript, PDF and SVG output. See TPostScript::SetLineJoin fo...
Definition TStyle.h:289
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
Definition TStyle.cxx:1167
Int_t GetCapLinePS() const
Returns the line cap method used for PostScript, PDF and SVG output. See TPostScript::SetLineCap for ...
Definition TStyle.h:290
void GetPaperSize(Float_t &xsize, Float_t &ysize) const
Set paper size for PostScript output.
Definition TStyle.cxx:1184
const char * GetHeaderPS() const
Definition TStyle.h:286
Float_t GetLineScalePS() const
Definition TStyle.h:291
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
Definition TVirtualPS.h:32
Int_t fLenBuffer
Definition TVirtualPS.h:40
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.
std::ofstream * fStream
Definition TVirtualPS.h:43
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.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122