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 <cstdlib>
17#include <cstring>
18#include <cctype>
19#include <cmath>
20#include <fstream>
21
22#include "TROOT.h"
23#include "TDatime.h"
24#include "TBase64.h"
25#include "TColor.h"
26#include "TVirtualPad.h"
27#include "TPoint.h"
28#include "TPoints.h"
29#include "TSVG.h"
30#include "TStyle.h"
31#include "TMath.h"
32#include "TObjString.h"
33#include "TObjArray.h"
34#include "snprintf.h"
35
38
39const Double_t kEpsilon = 1e-9;
40
41/** \class TSVG
42\ingroup PS
43
44\brief Interface to SVG
45
46[SVG](http://www.w3.org/Graphics/SVG/Overview.htm8)
47(Scalable Vector Graphics) is a language for describing
48two-dimensional graphics in XML. SVG allows high quality vector graphics in
49HTML pages.
50
51To print a ROOT canvas "c1" into an SVG file simply do:
52~~~ {.cpp}
53 c1->Print("c1.svg");
54~~~
55The result is the ASCII file `c1.svg`.
56
57It can be open directly using a web browser or included in a html document
58the following way:
59~~~ {.cpp}
60<embed width="95%" height="500" src="c1.svg">
61~~~
62It is best viewed with Internet Explorer and you need the
63[Adobe SVG Viewer](http://www.adobe.com/svg/viewer/install/main.html)
64
65To zoom using the Adobe SVG Viewer, position the mouse over
66the area you want to zoom and click the right button.
67
68To define the zoom area,
69use Control+drag to mark the boundaries of the zoom area.
70
71To pan, use Alt+drag.
72By clicking with the right mouse button on the SVG graphics you will get
73a pop-up menu giving other ways to interact with the image.
74
75SVG files can be used directly in compressed mode to minimize the time
76transfer over the network. Compressed SVG files should be created using
77`gzip` on a normal ASCII SVG file and should then be renamed
78using the file extension `.svgz`.
79*/
80
81////////////////////////////////////////////////////////////////////////////////
82/// Default SVG constructor
83
85{
86 gVirtualPS = this;
87 SetTitle("SVG");
88}
89
90////////////////////////////////////////////////////////////////////////////////
91/// Initialize the SVG interface
92///
93/// - fname : SVG file name
94/// - wtype : SVG workstation type. Not used in the SVG driver. But as TSVG
95/// inherits from TVirtualPS it should be kept. Anyway it is not
96/// necessary to specify this parameter at creation time because it
97/// has a default value (which is ignore in the SVG case).
98
100{
101 SetTitle("SVG");
103 Open(fname, wtype);
104}
105
106////////////////////////////////////////////////////////////////////////////////
107/// Open a SVG file
108
109void TSVG::Open(const char *fname, Int_t wtype)
110{
111 if (fStream) {
112 Warning("Open", "SVG file already open");
113 return;
114 }
115
116 fLenBuffer = 0;
117 fType = std::abs(wtype);
123 if (gPad) {
124 Double_t ww = gPad->GetWw();
125 Double_t wh = gPad->GetWh();
126 ww *= gPad->GetWNDC();
127 wh *= gPad->GetHNDC();
128 Double_t ratio = wh/ww;
129 xrange = fXsize;
130 yrange = fXsize*ratio;
131 if (yrange > fYsize) { yrange = fYsize; xrange = yrange/ratio;}
133 }
134
135 // Open OS file
136 if (!OpenStream(fname)) {
137 Error("Open", "Cannot open file: %s", fname);
138 return;
139 }
140
141 gVirtualPS = this;
142
143 ClearBuffer();
144
146
147 fRange = kFALSE;
148
149 // Set a default range
151
152 NewPage();
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Default SVG destructor
157
159{
160 Close();
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Close a SVG file
165
167{
168 if (!gVirtualPS || !fStream)
169 return;
170 if (gPad)
171 gPad->Update();
172 PrintStr("</svg>@");
173
174 // Close file stream
175 CloseStream();
176
177 gVirtualPS = nullptr;
178}
179
180////////////////////////////////////////////////////////////////////////////////
181/// Activate an already open SVG file
182
184{
185 // fType is used to know if the SVG file is open. Unlike TPostScript, TSVG
186 // has no "workstation type". In fact there is only one SVG type.
187
188 if (!fType) {
189 Error("On", "no SVG file open");
190 Off();
191 return;
192 }
193 gVirtualPS = this;
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Deactivate an already open SVG file
198
200{
201 gVirtualPS = nullptr;
202}
203
204////////////////////////////////////////////////////////////////////////////////
205/// Draw a Box
206
208{
209 Double_t x[4], y[4];
214 Int_t fillis = fFillStyle/1000;
215 Int_t fillsi = fFillStyle%1000;
216
217 if (fillis == 3 || fillis == 2) {
218 if (fillsi > 99) {
219 x[0] = x1; y[0] = y1;
220 x[1] = x2; y[1] = y1;
221 x[2] = x2; y[2] = y2;
222 x[3] = x1; y[3] = y2;
223 return;
224 }
225 if (fillsi > 0 && fillsi < 26) {
226 x[0] = x1; y[0] = y1;
227 x[1] = x2; y[1] = y1;
228 x[2] = x2; y[2] = y2;
229 x[3] = x1; y[3] = y2;
230 DrawPS(-4, &x[0], &y[0]);
231 }
232 if (fillsi == -3) {
233 PrintStr("@");
234 PrintFast(9,"<rect x=\"");
236 PrintFast(5,"\" y=\"");
238 PrintFast(9,"\" width=\"");
240 PrintFast(10,"\" height=\"");
242 PrintFast(7,"\" fill=");
244 PrintFast(2,"/>");
245 }
246 }
247 if (fillis == 1) {
248 PrintStr("@");
249 PrintFast(9,"<rect x=\"");
251 PrintFast(5,"\" y=\"");
253 PrintFast(9,"\" width=\"");
255 PrintFast(10,"\" height=\"");
257 PrintFast(7,"\" fill=");
259 PrintFast(2,"/>");
260 }
261 if (fillis == 0) {
262 if (fLineWidth<=0) return;
263 PrintStr("@");
264 PrintFast(9,"<rect x=\"");
266 PrintFast(5,"\" y=\"");
268 PrintFast(9,"\" width=\"");
270 PrintFast(10,"\" height=\"");
272 PrintFast(21,"\" fill=\"none\" stroke=");
274 PrintFast(2,"/>");
275 }
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Print a svg path statement for specified points
280
282{
283 Double_t idx = 0, idy = 0;
284
285 Double_t ixd0 = convert ? XtoSVG(xps[0]) : xps[0];
286 Double_t iyd0 = convert ? YtoSVG(yps[0]) : yps[0];
288
289 PrintFast(1,"M");
291 PrintFast(1,",");
293
294 for (Int_t i = 1; i < n; i++) {
295 Double_t ixdi = convert ? XtoSVG(xps[i]) : xps[i];
296 Double_t iydi = convert ? YtoSVG(yps[i]) : yps[i];
297
298 Double_t ix = ixdi - ixd0;
299 Double_t iy = iydi - iyd0;
300
301 if (fCompact && (TMath::Abs(ix) < kEpsilon))
302 ix = 0;
303 if (fCompact && (TMath::Abs(iy) < kEpsilon))
304 iy = 0;
305
306 ixd0 = ixdi;
307 iyd0 = iydi;
308 if(ix && iy) {
309 if(idx) {
310 MovePS(idx, 0);
311 idx = 0;
312 }
313 if(idy) {
314 MovePS(0, idy);
315 idy = 0;
316 }
317 MovePS(ix, iy);
318 continue;
319 }
320 if (ix) {
321 if(idy) {
322 MovePS(0, idy);
323 idy = 0;
324 }
325 if(!idx || (ix*idx > 0)) {
326 idx += ix;
327 } else {
328 MovePS(idx, 0);
329 idx = ix;
330 }
331 continue;
332 }
333 if(iy) {
334 if(idx) {
335 MovePS(idx, 0);
336 idx = 0;
337 }
338 if(!idy || (iy*idy > 0)) {
339 idy += iy;
340 } else {
341 MovePS(0, idy);
342 idy = iy;
343 }
344 }
345 }
346 if(idx)
347 MovePS(idx, 0);
348 if(idy)
349 MovePS(0, idy);
350
352 PrintFast(1, "z");
353}
354
355////////////////////////////////////////////////////////////////////////////////
356/// Draw a Frame around a box
357///
358/// - mode = -1 the box looks as it is behind the screen
359/// - mode = 1 the box looks as it is in front of the screen
360/// - border is the border size in already pre-computed SVG units dark is the
361/// color for the dark part of the frame light is the color for the light
362/// part of the frame
363
365 Int_t mode, Int_t border, Int_t dark, Int_t light)
366{
367 Double_t xps[7], yps[7];
368
369 //- Draw top&left part of the box
370 xps[0] = XtoSVG(xl); yps[0] = YtoSVG(yl);
371 xps[1] = xps[0] + border; yps[1] = yps[0] - border;
372 xps[2] = xps[1]; yps[2] = YtoSVG(yt) + border;
373 xps[3] = XtoSVG(xt) - border; yps[3] = yps[2];
374 xps[4] = XtoSVG(xt); yps[4] = YtoSVG(yt);
375 xps[5] = xps[0]; yps[5] = yps[4];
376 xps[6] = xps[0]; yps[6] = yps[0];
377
378 PrintStr("@");
379 PrintFast(9,"<path d=\"");
380 PrintPath(kFALSE, 7, xps, yps);
381 PrintFast(7,"\" fill=");
382 SetColorAlpha(mode == -1 ? dark : light);
384 PrintFast(2,"/>");
385
386 //- Draw bottom&right part of the box
387 xps[0] = XtoSVG(xl); yps[0] = YtoSVG(yl);
388 xps[1] = xps[0] + border; yps[1] = yps[0] - border;
389 xps[2] = XtoSVG(xt) - border; yps[2] = yps[1];
390 xps[3] = xps[2]; yps[3] = YtoSVG(yt) + border;
391 xps[4] = XtoSVG(xt); yps[4] = YtoSVG(yt);
392 xps[5] = xps[4]; yps[5] = yps[0];
393 xps[6] = xps[0]; yps[6] = yps[0];
394
395 PrintStr("@");
396 PrintFast(9,"<path d=\"");
397 PrintPath(kFALSE, 7, xps, yps);
398 PrintFast(7,"\" fill=");
399 SetColorAlpha(mode == -1 ? light : dark);
401 PrintFast(2,"/>");
402}
403
404////////////////////////////////////////////////////////////////////////////////
405/// Draw a PolyLine
406///
407/// Draw a polyline through the points xy.
408/// - If NN=1 moves only to point x,y.
409/// - If NN=0 the x,y are written in the SVG file
410/// according to the current transformation.
411/// - If NN>0 the line is clipped as a line.
412/// - If NN<0 the line is clipped as a fill area.
413
415{
416 Warning("DrawPolyLine", "not implemented");
417}
418
419////////////////////////////////////////////////////////////////////////////////
420/// Draw a PolyLine in NDC space
421///
422/// Draw a polyline through the points xy.
423/// --If NN=1 moves only to point x,y.
424/// --If NN=0 the x,y are written in the SVG file
425/// according to the current transformation.
426/// --If NN>0 the line is clipped as a line.
427/// - If NN<0 the line is clipped as a fill area.
428
430{
431 Warning("DrawPolyLineNDC", "not implemented");
432}
433
434////////////////////////////////////////////////////////////////////////////////
435/// Implementation of polymarker printing
436
437template<typename T>
439{
440 Float_t s2x = 1. / Float_t(gPad->GetWw() * gPad->GetAbsWNDC());
441 // Rescale size of marker on SVG coordinates
442 Float_t scale = UtoSVG(s2x) - UtoSVG(0);
443
444 Int_t markerSize = 0;
445 std::vector<TPoint> points;
446 auto shape = GetMarkerShape(markerSize, points, scale, kDotAsCircle);
447
448 PrintStr("@");
449
450 bool draw_circles = (shape == kShapeFilledCircle) || (shape == kShapeCircle);
451 bool draw_fill = (shape == kShapeFilledCircle) || (shape == kShapeFilledArea) || (shape == kShapeTriangles);
452
453 if (draw_circles)
454 PrintStr("<g ");
455 else
456 PrintStr("<path ");
457
458 if (draw_fill) {
459 PrintStr("fill=");
461 } else {
462 PrintStr("stroke=");
464 PrintStr(" stroke-width=\"");
466 PrintStr("\" fill=\"none\"");
468 }
469 if (draw_circles)
470 PrintStr(">@");
471 else
472 PrintStr(" d=\"");
473
474 for (Int_t k = 0; k < n; k++) {
475 Double_t px = XtoSVG(xw[k]);
476 Double_t py = YtoSVG(yw[k]);
477 // add space between markers
478 if ((k > 0) && !draw_circles)
479 PrintStr(" ");
480
481 switch(shape) {
482 case kShapeDot:
483 PrintStr("M");
484 WriteReal(px-1, kFALSE);
485 PrintStr(",");
486 WriteReal(py, kFALSE);
487 PrintStr("h1");
488 break;
489 case kShapeCircle:
490 case kShapeFilledCircle: {
491 PrintStr("<circle cx=\"");
492 WriteReal(px, kFALSE);
493 PrintStr("\" cy=\"");
494 WriteReal(py, kFALSE);
495 PrintStr("\" r=\"");
496 WriteInteger(markerSize/2, kFALSE);
497 PrintStr("\"/>@");
498 break;
499 }
500 case kShapePolyLine:
501 case kShapeFilledArea:
502 PrintStr("M");
503 WriteReal(px + points.front().fX, kFALSE);
504 PrintStr(",");
505 WriteReal(py + points.front().fY, kFALSE);
506 for (std::size_t i = 1; i < points.size(); i++) {
507 PrintStr("l");
508 WriteInteger(points[i].fX - points[i-1].fX, kFALSE);
509 PrintStr(",");
510 WriteInteger(points[i].fY - points[i-1].fY, kFALSE);
511 }
512 if ((shape == kShapeFilledArea) || (points.front() == points.back()))
513 PrintStr("z");
514 break;
515 case kShapeSegments:
516 for (std::size_t i = 0; i + 1 < points.size(); i += 2) {
517 PrintStr("M");
518 WriteReal(px + points[i].fX, kFALSE);
519 PrintStr(",");
520 WriteReal(py + points[i].fY, kFALSE);
521 PrintStr("l");
522 WriteInteger(points[i+1].fX - points[i].fX, kFALSE);
523 PrintStr(",");
524 WriteInteger(points[i+1].fY - points[i].fY, kFALSE);
525 }
526 break;
527 case kShapeTriangles:
528 for (std::size_t i = 0; i + 2 < points.size(); i += 3) {
529 PrintStr("M");
530 WriteReal(px + points[i].fX, kFALSE);
531 PrintStr(",");
532 WriteReal(py + points[i].fY, kFALSE);
533 PrintStr("l");
534 WriteInteger(points[i+1].fX - points[i].fX, kFALSE);
535 PrintStr(",");
536 WriteInteger(points[i+1].fY - points[i].fY, kFALSE);
537 PrintStr("l");
538 WriteInteger(points[i+2].fX - points[i+1].fX, kFALSE);
539 PrintStr(",");
540 WriteInteger(points[i+2].fY - points[i+1].fY, kFALSE);
541 PrintStr("z");
542 }
543 break;
544 }
545 }
546 if (draw_circles)
547 PrintStr("</g>@");
548 else
549 PrintStr("\"/>");
550}
551
552////////////////////////////////////////////////////////////////////////////////
553/// Paint PolyMarker
554
559
560
561////////////////////////////////////////////////////////////////////////////////
562/// Paint PolyMarker
563
568
569
570////////////////////////////////////////////////////////////////////////////////
571/// Print line style attributes on the end of "path" string
572
574{
575 PrintFast(21,"\" fill=\"none\" stroke=");
577 if(fLineWidth > 1.) {
578 PrintFast(15," stroke-width=\"");
580 PrintFast(1,"\"");
581 }
582 if (fLineStyle > 1) {
583 PrintFast(19," stroke-dasharray=\"");
585 TObjArray *tokens = st.Tokenize(" ");
586 for (Int_t j = 0; j<tokens->GetEntries(); j++) {
587 Int_t it;
588 sscanf(((TObjString*)tokens->At(j))->GetName(), "%d", &it);
589 if (j>0) PrintFast(1,",");
590 WriteReal(it/4);
591 }
592 delete tokens;
593 PrintFast(1,"\"");
594 }
595}
596
597////////////////////////////////////////////////////////////////////////////////
598/// Print line join attributes - if present
599
601{
602 if (fgLineJoin)
603 PrintStr(TString::Format(" stroke-linejoin=\"%s\"", fgLineJoin == 1 ? "round" : "bevel"));
604 if (fgLineCap)
605 PrintStr(TString::Format(" stroke-linecap=\"%s\"", fgLineCap == 1 ? "round" : "square"));
606}
607
608
609////////////////////////////////////////////////////////////////////////////////
610/// This function defines a path with xw and yw and draw it according the
611/// value of nn:
612///
613/// - If nn>0 a line is drawn.
614/// - If nn<0 a closed polygon is drawn.
615
617{
618 Int_t n, fais = 0, fasi = 0;
619
620 if (nn > 0) {
621 if (fLineWidth <= 0)
622 return;
623 n = nn;
624 } else {
625 n = -nn;
626 fais = fFillStyle/1000;
627 fasi = fFillStyle%1000;
628 if (fais == 3 || fais == 2) {
629 if (fasi > 100 && fasi <125) {
630 return;
631 }
632 if (fasi > 0 && fasi < 26) {
633 }
634 }
635 }
636
637 if(n <= 1) {
638 Error("DrawPS", "Two points are needed");
639 return;
640 }
641
642 PrintStr("@");
643 PrintFast(9,"<path d=\"");
644
645 PrintPath(kTRUE, n, xw, yw, nn < 0);
646
647 if (nn > 0)
649 else {
650 PrintFast(7,"\" fill=");
651 if (fais == 0) {
652 PrintFast(14,"\"none\" stroke=");
654 } else {
656 }
657 }
659 PrintFast(2,"/>");
660}
661
662////////////////////////////////////////////////////////////////////////////////
663/// This method draw N segments
665{
666 if (fLineWidth < 0)
667 return;
668
669 if(n < 1) {
670 Error("DrawSegments", "At least one segment has to be provided");
671 return;
672 }
673
674 PrintStr("@");
675 PrintFast(9,"<path d=\"");
676
677 for(Int_t i = 0; i < 2*n; i += 2) {
678 Double_t ixd0 = XtoSVG(xw[i]);
679 Double_t iyd0 = YtoSVG(yw[i]);
680 Double_t ixd1 = XtoSVG(xw[i+1]);
681 Double_t iyd1 = YtoSVG(yw[i+1]);
682
683 Double_t dx = ixd1 - ixd0;
684 Double_t dy = iyd1 - iyd0;
685
686 if (fCompact && (TMath::Abs(dx) < kEpsilon))
687 dx = 0;
688 if (fCompact && (TMath::Abs(dy) < kEpsilon))
689 dy = 0;
690
691 if (dx || dy) {
692 PrintFast(1,"M");
694 PrintFast(1,",");
696 MovePS(dx, dy);
697 }
698 }
699
702 PrintFast(2,"/>");
703}
704
705
706////////////////////////////////////////////////////////////////////////////////
707/// Begin the Cell Array painting
708
710{
712 Double_t svgx2 = XtoSVG(x1 + (x2 - x1) * width);
714 Double_t svgy2 = YtoSVG(y1 - (y2 - y1) * height);
715
716 PrintStr("@<g transform=\"translate(");
719 PrintStr(") scale(");
722 PrintStr(")\">@");
723 PrintStr(TString::Format("<image width=\"%d\" height=\"%d\" href=\"data:image/png;base64,", width, height));
724}
725
726////////////////////////////////////////////////////////////////////////////////
727/// Paint the Cell Array as single pixel
728
730{
731 Warning("CellArrayFill", "not implemented");
732}
733
734////////////////////////////////////////////////////////////////////////////////
735/// Paint the Cell Array as png image
736/// Disabled in compact mode to avoid creation of large SVG files
737
738void TSVG::CellArrayPng(char *buffer, int size)
739{
740 if (!fCompact) {
741 TString base64 = TBase64::Encode(reinterpret_cast<char *>(buffer), size);
742 PrintFast(base64.Length(), base64.Data());
743 }
744}
745
746////////////////////////////////////////////////////////////////////////////////
747/// End the Cell Array painting
748
750{
751 PrintStr("\"></image>@");
752 PrintStr("</g>@");
753}
754
755////////////////////////////////////////////////////////////////////////////////
756/// Initialize the SVG file. The main task of the function is to output the
757/// SVG header file which consist in `<title>`, `<desc>` and `<defs>`. The
758/// HeaderPS provided by the user program is written in the `<defs>` part.
759
761{
762 // Title
763 PrintStr("<title>@");
764 PrintStr(GetName());
765 PrintStr("@");
766 PrintStr("</title>@");
767
768 if (fCompact)
769 return;
770
771 // Description
772 PrintStr("<desc>@");
773 PrintFast(22,"Creator: ROOT Version ");
774 PrintStr(gROOT->GetVersion());
775 PrintStr("@");
776 PrintFast(14,"CreationDate: ");
777 TDatime t;
778 PrintStr(t.AsString());
779 //Check a special header is defined in the current style
781 if (nh) {
783 }
784 PrintStr("</desc>@");
785
786 // Definitions
787 PrintStr("<defs>@");
788 PrintStr("</defs>@");
789
790}
791
792////////////////////////////////////////////////////////////////////////////////
793/// Write float value into output stream
794/// In compact form try to store only first 2-3 significant digits
795
797{
798 if (fCompact) {
799 auto a = std::abs(r);
800 if (a > 10)
801 TVirtualPS::WriteInteger(std::lround(r), space);
802 else if (a < 0.005)
803 TVirtualPS::WriteReal(r, space);
804 else {
805 char str[15];
806 snprintf(str, 15, (a > 1) ? "%3.1f" : "%5.3f", r);
807 if(space)
808 PrintFast(1," ");
809 PrintStr(str);
810 }
811 } else
812 TVirtualPS::WriteReal(r, space);
813}
814
815////////////////////////////////////////////////////////////////////////////////
816/// Move to a new position (ix, iy). The move is done in relative coordinates
817/// which allows to have short numbers which decrease the size of the file.
818/// This function use the full power of the SVG's paths by using the
819/// horizontal and vertical move whenever it is possible.
820
822{
823 if (ix != 0 && iy != 0) {
824 PrintFast(1,"l");
825 WriteReal(ix);
826 PrintFast(1,",");
827 WriteReal(iy);
828 } else if (ix != 0) {
829 PrintFast(1,"h");
830 WriteReal(ix);
831 } else if (iy != 0) {
832 PrintFast(1,"v");
833 WriteReal(iy);
834 }
835}
836
837////////////////////////////////////////////////////////////////////////////////
838/// Start the SVG page. This function initialize the pad conversion
839/// coefficients and output the `<svg>` directive which is close later in the
840/// the function Close.
841
843{
844 // Compute pad conversion coefficients
845 if (gPad) {
846 Double_t ww = gPad->GetWw();
847 Double_t wh = gPad->GetWh();
848 fYsize = fXsize*wh/ww;
849 } else {
850 fYsize = 27;
851 }
852
853 // <svg> directive. It defines the viewBox.
854 if(!fBoundingBox) {
855 PrintStr("@<?xml version=\"1.0\" standalone=\"no\"?>");
856 PrintStr("@<svg width=\"");
858 PrintStr("\" height=\"");
861 PrintStr("\" viewBox=\"0 0");
864 PrintStr("\" xmlns=\"http://www.w3.org/2000/svg\" shape-rendering=\"crispEdges\">");
865 PrintStr("@");
866 Initialize();
868 }
869}
870
871////////////////////////////////////////////////////////////////////////////////
872/// Set the range for the paper in centimetres
873
875{
876 fXsize = xsize;
877 fYsize = ysize;
878 fRange = kTRUE;
879}
880
881////////////////////////////////////////////////////////////////////////////////
882/// Set color index for fill areas
883
888
889////////////////////////////////////////////////////////////////////////////////
890/// Set color index for lines
891
896
897////////////////////////////////////////////////////////////////////////////////
898/// Set the value of the global parameter TSVG::fgLineJoin.
899/// This parameter determines the appearance of joining lines in a SVG
900/// output.
901/// It takes one argument which may be:
902/// - 0 (miter join)
903/// - 1 (round join)
904/// - 2 (bevel join)
905/// The default value is 0 (miter join).
906///
907/// \image html postscript_1.png
908///
909/// To change the line join behaviour just do:
910/// ~~~ {.cpp}
911/// gStyle->SetJoinLinePS(2); // Set the PS line join to bevel.
912/// ~~~
913
915{
917 if (fgLineJoin<0) fgLineJoin=0;
918 if (fgLineJoin>2) fgLineJoin=2;
919}
920
921////////////////////////////////////////////////////////////////////////////////
922/// Set the value of the global parameter TSVG::fgLineCap.
923/// This parameter determines the appearance of line caps in a SVG
924/// output.
925/// It takes one argument which may be:
926/// - 0 (butt caps)
927/// - 1 (round caps)
928/// - 2 (projecting caps)
929/// The default value is 0 (butt caps).
930///
931/// \image html postscript_2.png
932///
933/// To change the line cap behaviour just do:
934/// ~~~ {.cpp}
935/// gStyle->SetCapLinePS(2); // Set the PS line cap to projecting.
936/// ~~~
937
939{
941 if (fgLineCap<0) fgLineCap=0;
942 if (fgLineCap>2) fgLineCap=2;
943}
944
945////////////////////////////////////////////////////////////////////////////////
946/// Change the line style
947///
948/// - linestyle = 2 dashed
949/// - linestyle = 3 dotted
950/// - linestyle = 4 dash-dotted
951/// - linestyle = else solid (1 in is used most of the time)
952
957
958////////////////////////////////////////////////////////////////////////////////
959/// Set the lines width.
960
965
966////////////////////////////////////////////////////////////////////////////////
967/// Set color index for markers.
968
973
974////////////////////////////////////////////////////////////////////////////////
975/// Set RGBa color with its color index
976
978{
979 if (color < 0)
980 color = 0;
981 TColor *col = gROOT->GetColor(color);
982 if (col) {
983 SetColor(col->GetRed(), col->GetGreen(), col->GetBlue());
984 Float_t a = col->GetAlpha();
985 if ((a < 1.) && fill)
986 PrintStr(TString::Format(" fill-opacity=\"%3.2f\"",a));
987 if ((a < 1.) && stroke)
988 PrintStr(TString::Format(" stroke-opacity=\"%3.2f\"",a));
989 } else {
990 SetColor(1., 1., 1.);
991 }
992}
993
994////////////////////////////////////////////////////////////////////////////////
995/// Set RGB (without alpha channel) color with its color index
996
998{
999 if (color < 0) color = 0;
1000 TColor *col = gROOT->GetColor(color);
1001 if (col) {
1002 SetColor(col->GetRed(), col->GetGreen(), col->GetBlue());
1003 } else {
1004 SetColor(1., 1., 1.);
1005 }
1006}
1007
1008////////////////////////////////////////////////////////////////////////////////
1009/// Set color with its R G B components
1010///
1011/// - r: % of red in [0,1]
1012/// --g: % of green in [0,1]
1013/// - b: % of blue in [0,1]
1014
1016{
1017 if (r <= 0. && g <= 0. && b <= 0. ) {
1018 PrintFast(7,"\"black\"");
1019 } else if (r >= 1. && g >= 1. && b >= 1. ) {
1020 PrintFast(7,"\"white\"");
1021 } else {
1022 char str[12];
1023 snprintf(str,12,"\"#%2.2x%2.2x%2.2x\"",Int_t(255.*r)
1024 ,Int_t(255.*g)
1025 ,Int_t(255.*b));
1026 PrintStr(str);
1027 }
1028}
1029
1030////////////////////////////////////////////////////////////////////////////////
1031/// Set color index for text
1032
1037
1038////////////////////////////////////////////////////////////////////////////////
1039/// Draw text
1040///
1041/// - xx: x position of the text
1042/// - yy: y position of the text
1043/// - chars: text to be drawn
1044
1046{
1047 static const char *fontFamily[] = {
1048 "Times" , "Times" , "Times",
1049 "Helvetica", "Helvetica", "Helvetica" , "Helvetica",
1050 "Courier" , "Courier" , "Courier" , "Courier",
1051 "Times" ,"Times" , "ZapfDingbats", "Times"};
1052
1053 static const char *fontWeight[] = {
1054 "normal", "bold", "bold",
1055 "normal", "normal", "bold" , "bold",
1056 "normal", "normal", "bold" , "bold",
1057 "normal", "normal", "normal", "normal"};
1058
1059 static const char *fontStyle[] = {
1060 "italic", "normal" , "italic",
1061 "normal", "oblique", "normal", "oblique",
1062 "normal", "oblique", "normal", "oblique",
1063 "normal", "normal" , "normal", "italic"};
1064
1065 Double_t ix = XtoSVG(xx);
1066 Double_t iy = YtoSVG(yy);
1068 if (txalh <1) txalh = 1; else if (txalh > 3) txalh = 3;
1070 if (txalv <1) txalv = 1; else if (txalv > 3) txalv = 3;
1071
1072 Double_t wh = (Double_t)gPad->GetPadWidth();
1073 Double_t hh = (Double_t)gPad->GetPadHeight();
1074 Float_t fontrap = 1.09; //scale down compared to X11
1076
1077 Int_t font = abs(fTextFont)/10;
1078 if (font > 15 || font < 1)
1079 font = 1;
1080 if (wh < hh) {
1081 ftsize = fTextSize*fXsize*gPad->GetAbsWNDC();
1082 } else {
1083 ftsize = fTextSize*fYsize*gPad->GetAbsHNDC();
1084 }
1085 Int_t ifont = font-1;
1086
1088 if( fontsize <= 0) return;
1089
1090 if (txalv == 3) iy = iy+fontsize;
1091 if (txalv == 2) iy = iy+(fontsize/2);
1092
1093 if (fTextAngle != 0.) {
1094 PrintStr("@");
1095 PrintFast(21,"<g transform=\"rotate(");
1097 PrintFast(1,",");
1098 WriteReal(ix, kFALSE);
1099 PrintFast(1,",");
1100 WriteReal(iy, kFALSE);
1101 PrintFast(3,")\">");
1102 }
1103
1104 PrintStr("@");
1105 PrintFast(30,"<text xml:space=\"preserve\" x=\"");
1106 WriteReal(ix, kFALSE);
1107 PrintFast(5,"\" y=\"");
1108 WriteReal(iy, kFALSE);
1109 PrintFast(1,"\"");
1110 if (txalh == 2) {
1111 PrintFast(21," text-anchor=\"middle\"");
1112 } else if (txalh == 3) {
1113 PrintFast(18," text-anchor=\"end\"");
1114 }
1115 PrintFast(6," fill=");
1117 PrintFast(12," font-size=\"");
1119 PrintFast(15,"\" font-family=\"");
1121 if (strcmp(fontWeight[ifont],"normal")) {
1122 PrintFast(15,"\" font-weight=\"");
1124 }
1125 if (strcmp(fontStyle[ifont],"normal")) {
1126 PrintFast(14,"\" font-style=\"");
1128 }
1129 PrintFast(2,"\">");
1130
1131 if (font == 12 || font == 15) {
1132 Int_t ichar = chars[0]+848;
1133 Int_t ic = ichar;
1134
1135 // Math Symbols (cf: http://www.fileformat.info/info/unicode/category/Sm/list.htm)
1136 if (ic == 755) ichar = 8804;
1137 if (ic == 759) ichar = 9827;
1138 if (ic == 760) ichar = 9830;
1139 if (ic == 761) ichar = 9829;
1140 if (ic == 762) ichar = 9824;
1141 if (ic == 766) ichar = 8594;
1142 if (ic == 776) ichar = 247;
1143 if (ic == 757) ichar = 8734;
1144 if (ic == 758) ichar = 402;
1145 if (ic == 771) ichar = 8805;
1146 if (ic == 774) ichar = 8706;
1147 if (ic == 775) ichar = 8226;
1148 if (ic == 779) ichar = 8776;
1149 if (ic == 805) ichar = 8719;
1150 if (ic == 821) ichar = 8721;
1151 if (ic == 834) ichar = 8747;
1152 if (ic == 769) ichar = 177;
1153 if (ic == 772) ichar = 215;
1154 if (ic == 768) ichar = 176;
1155 if (ic == 791) ichar = 8745;
1156 if (ic == 793) ichar = 8835; // SUPERSET OF
1157 if (ic == 794) ichar = 8839; // SUPERSET OF OR EQUAL TO
1158 if (ic == 795) ichar = 8836; // NOT A SUBSET OF
1159 if (ic == 796) ichar = 8834;
1160 if (ic == 893) ichar = 8722;
1161 if (ic == 803) ichar = 169; // COPYRIGHT SIGN
1162 if (ic == 819) ichar = 169; // COPYRIGHT SIGN
1163 if (ic == 804) ichar = 8482;
1164 if (ic == 770) ichar = 34;
1165 if (ic == 823) ichar = 10072;
1166 if (ic == 781) ichar = 10072;
1167 if (ic == 824) ichar = 9117; // LEFT PARENTHESIS LOWER HOOK
1168 if (ic == 822) ichar = 9115; // LEFT PARENTHESIS UPPER HOOK
1169 if (ic == 767) ichar = 8595; // DOWNWARDS ARROW
1170 if (ic == 763) ichar = 8596; // LEFT RIGHT ARROW
1171 if (ic == 764) ichar = 8592; // LEFTWARDS ARROW
1172 if (ic == 788) ichar = 8855; // CIRCLED TIMES
1173 if (ic == 784) ichar = 8501;
1174 if (ic == 777) ichar = 8800;
1175 if (ic == 797) ichar = 8838;
1176 if (ic == 800) ichar = 8736;
1177 if (ic == 812) ichar = 8656; // LEFTWARDS DOUBLE ARROW
1178 if (ic == 817) ichar = 60; // LESS-THAN SIGN
1179 if (ic == 833) ichar = 62; // GREATER-THAN SIGN
1180 if (ic == 778) ichar = 8803; // STRICTLY EQUIVALENT TO
1181 if (ic == 809) ichar = 8743; // LOGICAL AND
1182 if (ic == 802) ichar = 9415; // CIRCLED LATIN CAPITAL LETTER R
1183 if (ic == 780) ichar = 8230; // HORIZONTAL ELLIPSIS
1184 if (ic == 801) ichar = 8711; // NABLA
1185 if (ic == 783) ichar = 8629; // DOWNWARDS ARROW WITH CORNER LEFTWARDS
1186 if (ic == 782) ichar = 8213;
1187 if (ic == 799) ichar = 8713;
1188 if (ic == 792) ichar = 8746;
1189 if (ic == 828) ichar = 9127;
1190 if (ic == 765) ichar = 8593; // UPWARDS ARROW
1191 if (ic == 789) ichar = 8853; // CIRCLED PLUS
1192 if (ic == 813) ichar = 8657; // UPWARDS DOUBLE ARROW
1193 if (ic == 773) ichar = 8733; // PROPORTIONAL TO
1194 if (ic == 790) ichar = 8709; // EMPTY SET
1195 if (ic == 810) ichar = 8744;
1196 if (ic == 756) ichar = 8260;
1197 if (ic == 807) ichar = 8231;
1198 if (ic == 808) ichar = 8989; // TOP RIGHT CORNER
1199 if (ic == 814) ichar = 8658; // RIGHTWARDS DOUBLE ARROW
1200 if (ic == 806) ichar = 8730; // SQUARE ROOT
1201 if (ic == 827) ichar = 9123;
1202 if (ic == 829) ichar = 9128;
1203 if (ic == 786) ichar = 8476;
1204 if (ic == 785) ichar = 8465;
1205 if (ic == 787) ichar = 8472;
1206 if (ic == 882) ichar = 8704; // FOR ALL
1207 if (ic == 884) ichar = 8707; // THERE EXISTS
1208 if (ic == 815) ichar = 8659; // DOWNWARDS DOUBLE ARROW
1209 if (ic == 811) ichar = 8660; // LEFT RIGHT DOUBLE ARROW
1210 if (ic == 826) ichar = 124; // VERTICAL LINE
1211 if (ic == 818) ichar = 9415; // CIRCLED LATIN CAPITAL LETTER R
1212 if (ic == 820) ichar = 8482; // TRADEMARK SIGN
1213
1214 // Greek characters
1215 if (ic == 918) ichar = 934;
1216 if (ic == 919) ichar = 915;
1217 if (ic == 920) ichar = 919;
1218 if (ic == 923) ichar = 922;
1219 if (ic == 924) ichar = 923;
1220 if (ic == 925) ichar = 924;
1221 if (ic == 926) ichar = 925;
1222 if (ic == 929) ichar = 920;
1223 if (ic == 930) ichar = 929;
1224 if (ic == 936) ichar = 926;
1225 if (ic == 915) ichar = 935;
1226 if (ic == 937) ichar = 936;
1227 if (ic == 935) ichar = 937;
1228 if (ic == 938) ichar = 918;
1229 if (ic == 951) ichar = 947;
1230 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 (Ɛ)
1231 if (ic == 970) ichar = 950;
1232 if (ic == 952) ichar = 951;
1233 if (ic == 961) ichar = 952;
1234 if (ic == 955) ichar = 954;
1235 if (ic == 956) ichar = 955;
1236 if (ic == 957) ichar = 956;
1237 if (ic == 958) ichar = 957;
1238 if (ic == 968) ichar = 958;
1239 if (ic == 934) ichar = 962;
1240 if (ic == 962) ichar = 961;
1241 if (ic == 966) ichar = 969;
1242 if (ic == 950) ichar = 966;
1243 if (ic == 947) ichar = 967;
1244 if (ic == 969) ichar = 968;
1245 if (ic == 967) ichar = 969;
1246 if (ic == 954) ichar = 966;
1247 if (ic == 922) ichar = 952;
1248 if (ic == 753) ichar = 965;
1249 PrintStr(TString::Format("&#%4.4d;",ichar));
1250 } else {
1252 for (Int_t i=0; i<len;i++) {
1253 if (chars[i]!='\n') {
1254 if (chars[i]=='<') {
1255 PrintFast(4,"&lt;");
1256 } else if (chars[i]=='>') {
1257 PrintFast(4,"&gt;");
1258 } else if (chars[i]=='\305') {
1259 PrintFast(7,"&#8491;"); // ANGSTROM SIGN
1260 } else if (chars[i]=='\345') {
1261 PrintFast(6,"&#229;");
1262 } else if (chars[i]=='&') {
1263 PrintFast(5,"&amp;");
1264 } else {
1265 PrintFast(1,&chars[i]);
1266 }
1267 }
1268 }
1269 }
1270
1271 PrintStr("@");
1272 PrintFast(7,"</text>");
1273
1274 if (fTextAngle != 0.) {
1275 PrintStr("@");
1276 PrintFast(4,"</g>");
1277 }
1278}
1279
1280////////////////////////////////////////////////////////////////////////////////
1281/// Draw text with URL.
1282///
1283
1284void TSVG::TextUrl(Double_t x, Double_t y, const char *chars, const char *url)
1285{
1286 PrintStr("@");
1287 PrintFast(9,"<a href=\"");
1288 PrintStr(url);
1289 PrintFast(2,"\">");
1290 PrintStr("@");
1291 Text(x, y, chars);
1292 PrintStr("@");
1293 PrintFast(4,"</a>");
1294 PrintStr("@");
1295}
1296
1297////////////////////////////////////////////////////////////////////////////////
1298/// Write a string of characters in NDC
1299
1301{
1302 Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
1303 Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
1304 Text(x, y, chars);
1305}
1306
1307////////////////////////////////////////////////////////////////////////////////
1308/// Convert U from NDC coordinate to SVG
1309
1311{
1312 Double_t cm = fXsize*(gPad->GetAbsXlowNDC() + u*gPad->GetAbsWNDC());
1313 return 0.5 + 72*cm/2.54;
1314}
1315
1316////////////////////////////////////////////////////////////////////////////////
1317/// Convert V from NDC coordinate to SVG
1318
1320{
1321 Double_t cm = fYsize*(gPad->GetAbsYlowNDC() + v*gPad->GetAbsHNDC());
1322 return 0.5 + 72*cm/2.54;
1323}
1324
1325////////////////////////////////////////////////////////////////////////////////
1326/// Convert X from world coordinate to SVG
1327
1329{
1330 Double_t u = (x - gPad->GetX1())/(gPad->GetX2() - gPad->GetX1());
1331 return UtoSVG(u);
1332}
1333
1334////////////////////////////////////////////////////////////////////////////////
1335/// Convert Y from world coordinate to SVG
1336
1338{
1339 Double_t v = (y - gPad->GetY1())/(gPad->GetY2() - gPad->GetY1());
1340 return fYsizeSVG-VtoSVG(v);
1341}
1342
1343////////////////////////////////////////////////////////////////////////////////
1344/// Not needed in SVG case
1345
1347{
1348 Warning("TSVG::DrawPS", "not yet implemented");
1349}
#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:39
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
R__EXTERN TVirtualPS * gVirtualPS
Definition TVirtualPS.h:88
#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
Float_t GetRed() const
Definition TColor.h:61
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1939
Float_t GetAlpha() const
Definition TColor.h:67
Float_t GetBlue() const
Definition TColor.h:63
Float_t GetGreen() const
Definition TColor.h:62
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:101
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:1310
void MovePS(Double_t x, Double_t y)
Move to a new position (ix, iy).
Definition TSVG.cxx:821
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:364
void DrawPolyLineNDC(Int_t, TPoints *)
Draw a PolyLine in NDC space.
Definition TSVG.cxx:429
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:738
void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y) override
Paint PolyMarker.
Definition TSVG.cxx:555
void TextUrl(Double_t x, Double_t y, const char *string, const char *url) override
Draw text with URL.
Definition TSVG.cxx:1284
void Close(Option_t *opt="") override
Close a SVG file.
Definition TSVG.cxx:166
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Draw a Box.
Definition TSVG.cxx:207
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:1045
Double_t YtoSVG(Double_t y)
Convert Y from world coordinate to SVG.
Definition TSVG.cxx:1337
void PrintLineJointAttributes()
Print line join attributes - if present.
Definition TSVG.cxx:600
void SetFillColor(Color_t cindex=1) override
Set color index for fill areas.
Definition TSVG.cxx:884
void SetLineWidth(Width_t linewidth=1) override
Set the lines width.
Definition TSVG.cxx:961
void Initialize()
Initialize the SVG file.
Definition TSVG.cxx:760
void DrawPS(Int_t n, Float_t *xw, Float_t *yw) override
Not needed in SVG case.
Definition TSVG.cxx:1346
void CellArrayEnd() override
End the Cell Array painting.
Definition TSVG.cxx:749
void CellArrayFill(Int_t r, Int_t g, Int_t b) override
Paint the Cell Array as single pixel.
Definition TSVG.cxx:729
void NewPage() override
Start the SVG page.
Definition TSVG.cxx:842
void PrintLineStyleOnEndOfPath()
Print line style attributes on the end of "path" string.
Definition TSVG.cxx:573
void SetColor(Int_t color=1)
Set RGB (without alpha channel) color with its color index.
Definition TSVG.cxx:997
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:938
void DrawPolyLine(Int_t, TPoints *)
Draw a PolyLine.
Definition TSVG.cxx:414
void Off()
Deactivate an already open SVG file.
Definition TSVG.cxx:199
void Range(Float_t xrange, Float_t yrange)
Set the range for the paper in centimetres.
Definition TSVG.cxx:874
void SetLineScale(Float_t=3)
Definition TSVG.h:78
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:709
void SetLineStyle(Style_t linestyle=1) override
Change the line style.
Definition TSVG.cxx:953
void On()
Activate an already open SVG file.
Definition TSVG.cxx:183
TSVG()
Default SVG constructor.
Definition TSVG.cxx:84
void SetTextColor(Color_t cindex=1) override
Set color index for text.
Definition TSVG.cxx:1033
Double_t CMtoSVG(Double_t u)
Definition TSVG.h:50
Double_t XtoSVG(Double_t x)
Convert X from world coordinate to SVG.
Definition TSVG.cxx:1328
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:969
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:664
void TextNDC(Double_t u, Double_t v, const char *string)
Write a string of characters in NDC.
Definition TSVG.cxx:1300
~TSVG() override
Default SVG destructor.
Definition TSVG.cxx:158
void SetLineColor(Color_t cindex=1) override
Set color index for lines.
Definition TSVG.cxx:892
void SetColorAlpha(Int_t color=1, Bool_t fill=kTRUE, Bool_t stroke=kTRUE)
Set RGBa color with its color index.
Definition TSVG.cxx:977
void SetLineJoin(Int_t linejoin=0)
Set the value of the global parameter TSVG::fgLineJoin.
Definition TSVG.cxx:914
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:281
void Open(const char *filename, Int_t type=-111) override
Open a SVG file.
Definition TSVG.cxx:109
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:796
void PrintPolyMarkerShape(Int_t n, T *x, T *y)
Implementation of polymarker printing.
Definition TSVG.cxx:438
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:1319
Basic string class.
Definition TString.h:138
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:2459
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:30
Int_t fLenBuffer
Definition TVirtualPS.h:38
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:41
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