Logo ROOT   6.16/01
Reference Guide
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 <stdlib.h>
17#include <string.h>
18#include <ctype.h>
19
20#include "Riostream.h"
21#include "TROOT.h"
22#include "TColor.h"
23#include "TVirtualPad.h"
24#include "TPoints.h"
25#include "TSVG.h"
26#include "TStyle.h"
27#include "TMath.h"
28#include "TObjString.h"
29#include "TObjArray.h"
30#include "TClass.h"
31
33
34/** \class TSVG
35\ingroup PS
36
37Interface to SVG
38
39[SVG](http://www.w3.org/Graphics/SVG/Overview.htm8)
40(Scalable Vector Graphics) is a language for describing
41two-dimensional graphics in XML. SVG allows high quality vector graphics in
42HTML pages.
43
44To print a ROOT canvas "c1" into an SVG file simply do:
45~~~ {.cpp}
46 c1->Print("c1.svg");
47~~~
48The result is the ASCII file `c1.svg`.
49
50It can be open directly using a web browser or included in a html document
51the following way:
52~~~ {.cpp}
53<embed width="95%" height="500" src="c1.svg">
54~~~
55It is best viewed with Internet Explorer and you need the
56[Adobe SVG Viewer](http://www.adobe.com/svg/viewer/install/main.html)
57
58To zoom using the Adobe SVG Viewer, position the mouse over
59the area you want to zoom and click the right button.
60
61To define the zoom area,
62use Control+drag to mark the boundaries of the zoom area.
63
64To pan, use Alt+drag.
65By clicking with the right mouse button on the SVG graphics you will get
66a pop-up menu giving other ways to interact with the image.
67
68SVG files can be used directly in compressed mode to minimize the time
69transfer over the network. Compressed SVG files should be created using
70`gzip` on a normal ASCII SVG file and should then be renamed
71using the file extension `.svgz`.
72*/
73
74////////////////////////////////////////////////////////////////////////////////
75/// Default SVG constructor
76
78{
79 fStream = 0;
80 fType = 0;
81 gVirtualPS = this;
83 fRange = kFALSE;
84 fXsize = 0.;
85 fYsize = 0.;
86 fYsizeSVG = 0;
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
99TSVG::TSVG(const char *fname, Int_t wtype) : TVirtualPS(fname, wtype)
100{
101 fStream = 0;
102 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 = abs(wtype);
120 Float_t xrange, yrange;
121 if (gPad) {
122 Double_t ww = gPad->GetWw();
123 Double_t wh = gPad->GetWh();
124 ww *= gPad->GetWNDC();
125 wh *= gPad->GetHNDC();
126 Double_t ratio = wh/ww;
127 xrange = fXsize;
128 yrange = fXsize*ratio;
129 if (yrange > fYsize) { yrange = fYsize; xrange = yrange/ratio;}
130 fXsize = xrange; fYsize = yrange;
131 }
132
133 // Open OS file
134 fStream = new std::ofstream(fname,std::ios::out);
135 if (fStream == 0 || !fStream->good()) {
136 printf("ERROR in TSVG::Open: Cannot open file:%s\n",fname);
137 if (fStream == 0) return;
138 }
139
140 gVirtualPS = this;
141
142 for (Int_t i=0;i<fSizBuffer;i++) fBuffer[i] = ' ';
143
145
146 fRange = kFALSE;
147
148 // Set a default range
150
151 NewPage();
152}
153
154////////////////////////////////////////////////////////////////////////////////
155/// Default SVG destructor
156
158{
159 Close();
160}
161
162////////////////////////////////////////////////////////////////////////////////
163/// Close a SVG file
164
166{
167 if (!gVirtualPS) return;
168 if (!fStream) return;
169 if (gPad) gPad->Update();
170 PrintStr("</svg>@");
171
172 // Close file stream
173 if (fStream) { fStream->close(); delete fStream; fStream = 0;}
174
175 gVirtualPS = 0;
176}
177
178////////////////////////////////////////////////////////////////////////////////
179/// Activate an already open SVG file
180
182{
183 // fType is used to know if the SVG file is open. Unlike TPostScript, TSVG
184 // has no "workstation type". In fact there is only one SVG type.
185
186 if (!fType) {
187 Error("On", "no SVG file open");
188 Off();
189 return;
190 }
191 gVirtualPS = this;
192}
193
194////////////////////////////////////////////////////////////////////////////////
195/// Deactivate an already open SVG file
196
198{
199 gVirtualPS = 0;
200}
201
202////////////////////////////////////////////////////////////////////////////////
203/// Draw a Box
204
206{
207 static Double_t x[4], y[4];
210 Double_t iy1 = YtoSVG(TMath::Min(y1,y2));
211 Double_t iy2 = YtoSVG(TMath::Max(y1,y2));
212 Int_t fillis = fFillStyle/1000;
213 Int_t fillsi = fFillStyle%1000;
214
215 if (fillis == 3 || fillis == 2) {
216 if (fillsi > 99) {
217 x[0] = x1; y[0] = y1;
218 x[1] = x2; y[1] = y1;
219 x[2] = x2; y[2] = y2;
220 x[3] = x1; y[3] = y2;
221 return;
222 }
223 if (fillsi > 0 && fillsi < 26) {
224 x[0] = x1; y[0] = y1;
225 x[1] = x2; y[1] = y1;
226 x[2] = x2; y[2] = y2;
227 x[3] = x1; y[3] = y2;
228 DrawPS(-4, &x[0], &y[0]);
229 }
230 if (fillsi == -3) {
231 PrintStr("@");
232 PrintFast(9,"<rect x=\"");
233 WriteReal(ix1, kFALSE);
234 PrintFast(5,"\" y=\"");
235 WriteReal(iy2, kFALSE);
236 PrintFast(9,"\" width=\"");
237 WriteReal(ix2-ix1, kFALSE);
238 PrintFast(10,"\" height=\"");
239 WriteReal(iy1-iy2, kFALSE);
240 PrintFast(7,"\" fill=");
241 SetColor(5);
242 PrintFast(2,"/>");
243 }
244 }
245 if (fillis == 1) {
246 PrintStr("@");
247 PrintFast(9,"<rect x=\"");
248 WriteReal(ix1, kFALSE);
249 PrintFast(5,"\" y=\"");
250 WriteReal(iy2, kFALSE);
251 PrintFast(9,"\" width=\"");
252 WriteReal(ix2-ix1, kFALSE);
253 PrintFast(10,"\" height=\"");
254 WriteReal(iy1-iy2, kFALSE);
255 PrintFast(7,"\" fill=");
257 PrintFast(2,"/>");
258 }
259 if (fillis == 0) {
260 if (fLineWidth<=0) return;
261 PrintStr("@");
262 PrintFast(9,"<rect x=\"");
263 WriteReal(ix1, kFALSE);
264 PrintFast(5,"\" y=\"");
265 WriteReal(iy2, kFALSE);
266 PrintFast(9,"\" width=\"");
267 WriteReal(ix2-ix1, kFALSE);
268 PrintFast(10,"\" height=\"");
269 WriteReal(iy1-iy2, kFALSE);
270 PrintFast(21,"\" fill=\"none\" stroke=");
272 PrintFast(2,"/>");
273 }
274}
275
276////////////////////////////////////////////////////////////////////////////////
277/// Draw a Frame around a box
278///
279/// - mode = -1 the box looks as it is behind the screen
280/// - mode = 1 the box looks as it is in front of the screen
281/// - border is the border size in already pre-computed SVG units dark is the
282/// color for the dark part of the frame light is the color for the light
283/// part of the frame
284
286 Int_t mode, Int_t border, Int_t dark, Int_t light)
287{
288 static Double_t xps[7], yps[7];
289 Int_t i;
290 Double_t ixd0, iyd0, ixdi, iydi, ix, iy;
291 Int_t idx, idy;
292
293 //- Draw top&left part of the box
294
295 xps[0] = XtoSVG(xl); yps[0] = YtoSVG(yl);
296 xps[1] = xps[0] + border; yps[1] = yps[0] - border;
297 xps[2] = xps[1]; yps[2] = YtoSVG(yt) + border;
298 xps[3] = XtoSVG(xt) - border; yps[3] = yps[2];
299 xps[4] = XtoSVG(xt); yps[4] = YtoSVG(yt);
300 xps[5] = xps[0]; yps[5] = yps[4];
301 xps[6] = xps[0]; yps[6] = yps[0];
302
303 ixd0 = xps[0];
304 iyd0 = yps[0];
305 PrintStr("@");
306 PrintFast(10,"<path d=\"M");
307 WriteReal(ixd0, kFALSE);
308 PrintFast(1,",");
309 WriteReal(iyd0, kFALSE);
310
311 idx = 0;
312 idy = 0;
313 for (i=1; i<7; i++) {
314 ixdi = xps[i];
315 iydi = yps[i];
316 ix = ixdi - ixd0;
317 iy = iydi - iyd0;
318 ixd0 = ixdi;
319 iyd0 = iydi;
320 if( ix && iy) {
321 if( idx ) { MovePS(idx,0); idx = 0; }
322 if( idy ) { MovePS(0,idy); idy = 0; }
323 MovePS(ix,iy);
324 continue;
325 }
326 if ( ix ) {
327 if( idy ) { MovePS(0,idy); idy = 0; }
328 if( !idx ) { idx = ix; continue;}
329 if( ix*idx > 0 ) {
330 idx += ix;
331 } else {
332 MovePS(idx,0);
333 idx = ix;
334 }
335 continue;
336 }
337 if( iy ) {
338 if( idx ) { MovePS(idx,0); idx = 0; }
339 if( !idy) { idy = iy; continue;}
340 if( iy*idy > 0 ) {
341 idy += iy;
342 } else {
343 MovePS(0,idy);
344 idy = iy;
345 }
346 }
347 }
348 if( idx ) MovePS(idx,0);
349 if( idy ) MovePS(0,idy);
350 PrintFast(8,"z\" fill=");
351 if (mode == -1) {
352 SetColor(dark);
353 } else {
354 SetColor(light);
355 }
356 PrintFast(2,"/>");
357
358 //- Draw bottom&right part of the box
359 xps[0] = XtoSVG(xl); yps[0] = YtoSVG(yl);
360 xps[1] = xps[0] + border; yps[1] = yps[0] - border;
361 xps[2] = XtoSVG(xt) - border; yps[2] = yps[1];
362 xps[3] = xps[2]; yps[3] = YtoSVG(yt) + border;
363 xps[4] = XtoSVG(xt); yps[4] = YtoSVG(yt);
364 xps[5] = xps[4]; yps[5] = yps[0];
365 xps[6] = xps[0]; yps[6] = yps[0];
366
367 ixd0 = xps[0];
368 iyd0 = yps[0];
369 PrintStr("@");
370 PrintFast(10,"<path d=\"M");
371 WriteReal(ixd0, kFALSE);
372 PrintFast(1,",");
373 WriteReal(iyd0, kFALSE);
374
375 idx = 0;
376 idy = 0;
377 for (i=1;i<7;i++) {
378 ixdi = xps[i];
379 iydi = yps[i];
380 ix = ixdi - ixd0;
381 iy = iydi - iyd0;
382 ixd0 = ixdi;
383 iyd0 = iydi;
384 if( ix && iy) {
385 if( idx ) { MovePS(idx,0); idx = 0; }
386 if( idy ) { MovePS(0,idy); idy = 0; }
387 MovePS(ix,iy);
388 continue;
389 }
390 if ( ix ) {
391 if( idy ) { MovePS(0,idy); idy = 0; }
392 if( !idx ) { idx = ix; continue;}
393 if( ix*idx > 0 ) {
394 idx += ix;
395 } else {
396 MovePS(idx,0);
397 idx = ix;
398 }
399 continue;
400 }
401 if( iy ) {
402 if( idx ) { MovePS(idx,0); idx = 0; }
403 if( !idy) { idy = iy; continue;}
404 if( iy*idy > 0 ) {
405 idy += iy;
406 } else {
407 MovePS(0,idy);
408 idy = iy;
409 }
410 }
411 }
412 if( idx ) MovePS(idx,0);
413 if( idy ) MovePS(0,idy);
414 PrintFast(8,"z\" fill=");
415 if (mode == -1) {
416 SetColor(light);
417 } else {
418 SetColor(dark);
419 }
420 PrintFast(2,"/>");
421}
422
423////////////////////////////////////////////////////////////////////////////////
424/// Draw a PolyLine
425///
426/// Draw a polyline through the points xy.
427/// - If NN=1 moves only to point x,y.
428/// - If NN=0 the x,y are written in the SVG file
429/// according to the current transformation.
430/// - If NN>0 the line is clipped as a line.
431/// - If NN<0 the line is clipped as a fill area.
432
434{
435 Int_t n, idx, idy;
436 Double_t ixd0, iyd0, ixdi, iydi, ix, iy;
437
438 if (nn > 0) {
439 n = nn;
440 } else {
441 n = -nn;
442 }
443
444 ixd0 = XtoSVG(xy[0].GetX());
445 iyd0 = YtoSVG(xy[0].GetY());
446 if( n <= 1) return;
447
448 PrintFast(2," m");
449 idx = 0;
450 idy = 0;
451 for (Int_t i=1;i<n;i++) {
452 ixdi = XtoSVG(xy[i].GetX());
453 iydi = YtoSVG(xy[i].GetY());
454 ix = ixdi - ixd0;
455 iy = iydi - iyd0;
456 ixd0 = ixdi;
457 iyd0 = iydi;
458 if( ix && iy) {
459 if( idx ) { MovePS(idx,0); idx = 0; }
460 if( idy ) { MovePS(0,idy); idy = 0; }
461 MovePS(ix,iy);
462 continue;
463 }
464 if ( ix ) {
465 if( idy ) { MovePS(0,idy); idy = 0; }
466 if( !idx ) { idx = ix; continue;}
467 if( ix*idx > 0 ) {
468 idx += ix;
469 } else {
470 MovePS(idx,0);
471 idx = ix;
472 }
473 continue;
474 }
475 if( iy ) {
476 if( idx ) { MovePS(idx,0); idx = 0; }
477 if( !idy) { idy = iy; continue;}
478 if( iy*idy > 0 ) {
479 idy += iy;
480 } else {
481 MovePS(0,idy);
482 idy = iy;
483 }
484 }
485 }
486 if( idx ) MovePS(idx,0);
487 if( idy ) MovePS(0,idy);
488
489 if (nn > 0 ) {
490 } else {
491 }
492}
493
494////////////////////////////////////////////////////////////////////////////////
495/// Draw a PolyLine in NDC space
496///
497/// Draw a polyline through the points xy.
498/// --If NN=1 moves only to point x,y.
499/// --If NN=0 the x,y are written in the SVG file
500/// according to the current transformation.
501/// --If NN>0 the line is clipped as a line.
502/// - If NN<0 the line is clipped as a fill area.
503
505{
506 Int_t n, idx, idy;
507 Double_t ixd0, iyd0, ixdi, iydi, ix, iy;
508
509 if (nn > 0) {
510 n = nn;
511 } else {
512 n = -nn;
513 }
514
515 ixd0 = UtoSVG(xy[0].GetX());
516 iyd0 = VtoSVG(xy[0].GetY());
517 if( n <= 1) return;
518
519 idx = 0;
520 idy = 0;
521 for (Int_t i=1;i<n;i++) {
522 ixdi = UtoSVG(xy[i].GetX());
523 iydi = VtoSVG(xy[i].GetY());
524 ix = ixdi - ixd0;
525 iy = iydi - iyd0;
526 ixd0 = ixdi;
527 iyd0 = iydi;
528 if( ix && iy) {
529 if( idx ) { MovePS(idx,0); idx = 0; }
530 if( idy ) { MovePS(0,idy); idy = 0; }
531 MovePS(ix,iy);
532 continue;
533 }
534 if ( ix ) {
535 if( idy ) { MovePS(0,idy); idy = 0; }
536 if( !idx ) { idx = ix; continue;}
537 if( ix*idx > 0 ) {
538 idx += ix;
539 } else {
540 MovePS(idx,0);
541 idx = ix;
542 }
543 continue;
544 }
545 if( iy ) {
546 if( idx ) { MovePS(idx,0); idx = 0; }
547 if( !idy) { idy = iy; continue;}
548 if( iy*idy > 0 ) {
549 idy += iy;
550 } else {
551 MovePS(0,idy);
552 idy = iy;
553 }
554 }
555 }
556 if( idx ) MovePS(idx,0);
557 if( idy ) MovePS(0,idy);
558
559 if (nn > 0 ) {
560 if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3," cl");
561 } else {
562 }
563}
564
565////////////////////////////////////////////////////////////////////////////////
566/// Paint PolyMarker
567
569{
570 Int_t ms = abs(fMarkerStyle);
571
572 if (ms >= 6 && ms <= 19) ms = 20;
573 if (ms == 4) ms = 24;
574
575 // Define the marker size
576 Float_t msize = fMarkerSize;
577 if (fMarkerStyle == 1) msize = 0.01;
578 if (fMarkerStyle == 6) msize = 0.02;
579 if (fMarkerStyle == 7) msize = 0.04;
580
581 const Int_t kBASEMARKER = 8;
582 Float_t sbase = msize*kBASEMARKER;
583 Float_t s2x = sbase / Float_t(gPad->GetWw() * gPad->GetAbsWNDC());
584 msize = this->UtoSVG(s2x) - this->UtoSVG(0);
585
586 Double_t m = msize;
587 Double_t m2 = m/2.;
588 Double_t m3 = m/3.;
589 Double_t m6 = m/6.;
590 Double_t m8 = m/8.;
591 Double_t m4 = m/4.;
592 Double_t m0 = m/10.;
593
594 // Draw the marker according to the type
595 PrintStr("@");
596 if ((ms > 19 && ms < 24) || ms == 29 || ms == 33 || ms == 34 ||//) {
597 ms == 39 || ms == 41 || ms == 43 || ms == 45 ||
598 ms == 47 || ms == 48 || ms == 49) {
599 PrintStr("<g stroke=");
601 PrintStr(" stroke-width=\"");
603 PrintStr("\" fill=");
605 PrintStr(">");
606 } else {
607 PrintStr("<g stroke=");
609 PrintStr(" stroke-width=\"");
611 PrintStr("\" fill=\"none\"");
612 PrintStr(">");
613 }
614 Double_t ix,iy;
615 for (Int_t i=0;i<n;i++) {
616 ix = XtoSVG(xw[i]);
617 iy = YtoSVG(yw[i]);
618 PrintStr("@");
619 // Dot (.)
620 if (ms == 1) {
621 PrintStr("<line x1=\"");
622 WriteReal(ix-1, kFALSE);
623 PrintStr("\" y1=\"");
624 WriteReal(iy, kFALSE);
625 PrintStr("\" x2=\"");
626 WriteReal(ix, kFALSE);
627 PrintStr("\" y2=\"");
628 WriteReal(iy, kFALSE);
629 PrintStr("\"/>");
630 // Plus (+)
631 } else if (ms == 2) {
632 PrintStr("<line x1=\"");
633 WriteReal(ix-m2, kFALSE);
634 PrintStr("\" y1=\"");
635 WriteReal(iy, kFALSE);
636 PrintStr("\" x2=\"");
637 WriteReal(ix+m2, kFALSE);
638 PrintStr("\" y2=\"");
639 WriteReal(iy, kFALSE);
640 PrintStr("\"/>");
641
642 PrintStr("<line x1=\"");
643 WriteReal(ix, kFALSE);
644 PrintStr("\" y1=\"");
645 WriteReal(iy-m2, kFALSE);
646 PrintStr("\" x2=\"");
647 WriteReal(ix, kFALSE);
648 PrintStr("\" y2=\"");
649 WriteReal(iy+m2, kFALSE);
650 PrintStr("\"/>");
651 // X shape (X)
652 } else if (ms == 5) {
653 PrintStr("<line x1=\"");
654 WriteReal(ix-m2, kFALSE);
655 PrintStr("\" y1=\"");
656 WriteReal(iy-m2, kFALSE);
657 PrintStr("\" x2=\"");
658 WriteReal(ix+m2, kFALSE);
659 PrintStr("\" y2=\"");
660 WriteReal(iy+m2, kFALSE);
661 PrintStr("\"/>");
662
663 PrintStr("<line x1=\"");
664 WriteReal(ix-m2, kFALSE);
665 PrintStr("\" y1=\"");
666 WriteReal(iy+m2, kFALSE);
667 PrintStr("\" x2=\"");
668 WriteReal(ix+m2, kFALSE);
669 PrintStr("\" y2=\"");
670 WriteReal(iy-m2, kFALSE);
671 PrintStr("\"/>");
672 // Asterisk shape (*)
673 } else if (ms == 3 || ms == 31) {
674 PrintStr("<line x1=\"");
675 WriteReal(ix-m2, kFALSE);
676 PrintStr("\" y1=\"");
677 WriteReal(iy, kFALSE);
678 PrintStr("\" x2=\"");
679 WriteReal(ix+m2, kFALSE);
680 PrintStr("\" y2=\"");
681 WriteReal(iy, kFALSE);
682 PrintStr("\"/>");
683
684 PrintStr("<line x1=\"");
685 WriteReal(ix, kFALSE);
686 PrintStr("\" y1=\"");
687 WriteReal(iy-m2, kFALSE);
688 PrintStr("\" x2=\"");
689 WriteReal(ix, kFALSE);
690 PrintStr("\" y2=\"");
691 WriteReal(iy+m2, kFALSE);
692 PrintStr("\"/>");
693
694 PrintStr("<line x1=\"");
695 WriteReal(ix-m2, kFALSE);
696 PrintStr("\" y1=\"");
697 WriteReal(iy-m2, kFALSE);
698 PrintStr("\" x2=\"");
699 WriteReal(ix+m2, kFALSE);
700 PrintStr("\" y2=\"");
701 WriteReal(iy+m2, kFALSE);
702 PrintStr("\"/>");
703
704 PrintStr("<line x1=\"");
705 WriteReal(ix-m2, kFALSE);
706 PrintStr("\" y1=\"");
707 WriteReal(iy+m2, kFALSE);
708 PrintStr("\" x2=\"");
709 WriteReal(ix+m2, kFALSE);
710 PrintStr("\" y2=\"");
711 WriteReal(iy-m2, kFALSE);
712 PrintStr("\"/>");
713 // Circle
714 } else if (ms == 24 || ms == 20) {
715 PrintStr("<circle cx=\"");
716 WriteReal(ix, kFALSE);
717 PrintStr("\" cy=\"");
718 WriteReal(iy, kFALSE);
719 PrintStr("\" r=\"");
720 if (m2<=0) m2=1;
722 PrintStr("\" fill=\"none\"");
723 PrintStr("/>");
724 // Square
725 } else if (ms == 25 || ms == 21) {
726 PrintStr("<rect x=\"");
727 WriteReal(ix-m2, kFALSE);
728 PrintStr("\" y=\"");
729 WriteReal(iy-m2, kFALSE);
730 PrintStr("\" width=\"");
732 PrintStr("\" height=\"");
734 PrintStr("\" fill=\"none\"");
735 PrintStr("/>");
736 // Down triangle
737 } else if (ms == 26 || ms == 22) {
738 PrintStr("<polygon points=\"");
739 WriteReal(ix); PrintStr(","); WriteReal(iy-m2);
740 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m2);
741 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m2);
742 PrintStr("\"/>");
743 // Up triangle
744 } else if (ms == 23 || ms == 32) {
745 PrintStr("<polygon points=\"");
746 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m2);
747 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m2);
748 WriteReal(ix); PrintStr(","); WriteReal(iy+m2);
749 PrintStr("\"/>");
750 // Diamond
751 } else if (ms == 27 || ms == 33) {
752 PrintStr("<polygon points=\"");
753 WriteReal(ix); PrintStr(","); WriteReal(iy-m2);
754 WriteReal(ix+m3); PrintStr(","); WriteReal(iy);
755 WriteReal(ix); PrintStr(","); WriteReal(iy+m2);
756 WriteReal(ix-m3); PrintStr(","); WriteReal(iy);
757 PrintStr("\"/>");
758 // Cross
759 } else if (ms == 28 || ms == 34) {
760 PrintStr("<polygon points=\"");
761 WriteReal(ix-m6); PrintStr(","); WriteReal(iy-m6);
762 WriteReal(ix-m6); PrintStr(","); WriteReal(iy-m2);
763 WriteReal(ix+m6); PrintStr(","); WriteReal(iy-m2);
764 WriteReal(ix+m6); PrintStr(","); WriteReal(iy-m6);
765 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m6);
766 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m6);
767 WriteReal(ix+m6); PrintStr(","); WriteReal(iy+m6);
768 WriteReal(ix+m6); PrintStr(","); WriteReal(iy+m2);
769 WriteReal(ix-m6); PrintStr(","); WriteReal(iy+m2);
770 WriteReal(ix-m6); PrintStr(","); WriteReal(iy+m6);
771 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m6);
772 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m6);
773 PrintStr("\"/>");
774 } else if (ms == 29 || ms == 30) {
775 PrintStr("<polygon points=\"");
776 WriteReal(ix); PrintStr(","); WriteReal(iy+m2);
777 WriteReal(ix+0.112255*m); PrintStr(","); WriteReal(iy+0.15451*m);
778 WriteReal(ix+0.47552*m); PrintStr(","); WriteReal(iy+0.15451*m);
779 WriteReal(ix+0.181635*m); PrintStr(","); WriteReal(iy-0.05902*m);
780 WriteReal(ix+0.29389*m); PrintStr(","); WriteReal(iy-0.40451*m);
781 WriteReal(ix); PrintStr(","); WriteReal(iy-0.19098*m);
782 WriteReal(ix-0.29389*m); PrintStr(","); WriteReal(iy-0.40451*m);
783 WriteReal(ix-0.181635*m); PrintStr(","); WriteReal(iy-0.05902*m);
784 WriteReal(ix-0.47552*m); PrintStr(","); WriteReal(iy+0.15451*m);
785 WriteReal(ix-0.112255*m); PrintStr(","); WriteReal(iy+0.15451*m);
786 PrintStr("\"/>");
787 } else if (ms == 35) {
788 PrintStr("<polygon points=\"");
789 WriteReal(ix-m2); PrintStr(","); WriteReal(iy );
790 WriteReal(ix ); PrintStr(","); WriteReal(iy-m2);
791 WriteReal(ix+m2); PrintStr(","); WriteReal(iy );
792 WriteReal(ix ); PrintStr(","); WriteReal(iy+m2);
793 WriteReal(ix-m2); PrintStr(","); WriteReal(iy );
794 WriteReal(ix+m2); PrintStr(","); WriteReal(iy );
795 WriteReal(ix ); PrintStr(","); WriteReal(iy+m2);
796 WriteReal(ix ); PrintStr(","); WriteReal(iy-m2);
797 PrintStr("\"/>");
798 } else if (ms == 36) {
799 PrintStr("<polygon points=\"");
800 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m2);
801 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m2);
802 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m2);
803 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m2);
804 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m2);
805 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m2);
806 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m2);
807 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m2);
808 PrintStr("\"/>");
809 } else if (ms == 37 || ms == 39) {
810 PrintStr("<polygon points=\"");
811 WriteReal(ix ); PrintStr(","); WriteReal(iy );
812 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
813 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
814 WriteReal(ix ); PrintStr(","); WriteReal(iy );
815 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
816 WriteReal(ix-m2); PrintStr(","); WriteReal(iy);
817 WriteReal(ix ); PrintStr(","); WriteReal(iy );
818 WriteReal(ix+m2); PrintStr(","); WriteReal(iy );
819 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
820 WriteReal(ix ); PrintStr(","); WriteReal(iy );
821 PrintStr("\"/>");
822 } else if (ms == 38) {
823 PrintStr("<polygon points=\"");
824 WriteReal(ix-m2); PrintStr(","); WriteReal(iy );
825 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m4);
826 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
827 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
828 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m4);
829 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m4);
830 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
831 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
832 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m4);
833 WriteReal(ix-m2); PrintStr(","); WriteReal(iy );
834 WriteReal(ix+m2); PrintStr(","); WriteReal(iy );
835 WriteReal(ix ); PrintStr(","); WriteReal(iy );
836 WriteReal(ix ); PrintStr(","); WriteReal(iy-m2);
837 WriteReal(ix ); PrintStr(","); WriteReal(iy+m2);
838 WriteReal(ix ); PrintStr(","); WriteReal(iy);
839 PrintStr("\"/>");
840 } else if (ms == 40 || ms == 41) {
841 PrintStr("<polygon points=\"");
842 WriteReal(ix ); PrintStr(","); WriteReal(iy );
843 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
844 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m4);
845 WriteReal(ix ); PrintStr(","); WriteReal(iy );
846 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m4);
847 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
848 WriteReal(ix ); PrintStr(","); WriteReal(iy );
849 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
850 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m4);
851 WriteReal(ix ); PrintStr(","); WriteReal(iy );
852 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m4);
853 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
854 WriteReal(ix ); PrintStr(","); WriteReal(iy );
855 PrintStr("\"/>");
856 } else if (ms == 42 || ms == 43) {
857 PrintStr("<polygon points=\"");
858 WriteReal(ix ); PrintStr(","); WriteReal(iy+m2);
859 WriteReal(ix-m8); PrintStr(","); WriteReal(iy+m8);
860 WriteReal(ix-m2); PrintStr(","); WriteReal(iy );
861 WriteReal(ix-m8); PrintStr(","); WriteReal(iy-m8);
862 WriteReal(ix ); PrintStr(","); WriteReal(iy-m2);
863 WriteReal(ix+m8); PrintStr(","); WriteReal(iy-m8);
864 WriteReal(ix+m2); PrintStr(","); WriteReal(iy );
865 WriteReal(ix+m8); PrintStr(","); WriteReal(iy+m8);
866 WriteReal(ix ); PrintStr(","); WriteReal(iy+m2);
867 PrintStr("\"/>");
868 } else if (ms == 44) {
869 PrintStr("<polygon points=\"");
870 WriteReal(ix ); PrintStr(","); WriteReal(iy );
871 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
872 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
873 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
874 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
875 WriteReal(ix ); PrintStr(","); WriteReal(iy );
876 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m4);
877 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m4);
878 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m4);
879 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m4);
880 WriteReal(ix ); PrintStr(","); WriteReal(iy );
881 PrintStr("\"/>");
882 } else if (ms == 45) {
883 PrintStr("<polygon points=\"");
884 WriteReal(ix+m0); PrintStr(","); WriteReal(iy+m0);
885 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
886 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
887 WriteReal(ix-m0); PrintStr(","); WriteReal(iy+m0);
888 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m4);
889 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m4);
890 WriteReal(ix-m0); PrintStr(","); WriteReal(iy-m0);
891 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
892 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
893 WriteReal(ix+m0); PrintStr(","); WriteReal(iy-m0);
894 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m4);
895 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m4);
896 WriteReal(ix+m0); PrintStr(","); WriteReal(iy+m0);
897 PrintStr("\"/>");
898 } else if (ms == 46 || ms == 47) {
899 PrintStr("<polygon points=\"");
900 WriteReal(ix ); PrintStr(","); WriteReal(iy+m4);
901 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
902 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m4);
903 WriteReal(ix-m4); PrintStr(","); WriteReal(iy );
904 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m4);
905 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
906 WriteReal(ix ); PrintStr(","); WriteReal(iy-m4);
907 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
908 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m4);
909 WriteReal(ix+m4); PrintStr(","); WriteReal(iy );
910 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m4);
911 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
912 WriteReal(ix ); PrintStr(","); WriteReal(iy+m4);
913 PrintStr("\"/>");
914 } else if (ms == 48) {
915 PrintStr("<polygon points=\"");
916 WriteReal(ix ); PrintStr(","); WriteReal(iy+m4*1.01);
917 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
918 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m4);
919 WriteReal(ix-m4); PrintStr(","); WriteReal(iy );
920 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m4);
921 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
922 WriteReal(ix ); PrintStr(","); WriteReal(iy-m4);
923 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
924 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m4);
925 WriteReal(ix+m4); PrintStr(","); WriteReal(iy );
926 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m4);
927 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
928 WriteReal(ix ); PrintStr(","); WriteReal(iy+m4*0.99);
929 WriteReal(ix+m4*0.99); PrintStr(","); WriteReal(iy );
930 WriteReal(ix ); PrintStr(","); WriteReal(iy-m4*0.99);
931 WriteReal(ix-m4*0.99); PrintStr(","); WriteReal(iy );
932 WriteReal(ix ); PrintStr(","); WriteReal(iy+m4*0.99);
933 PrintStr("\"/>");
934 } else if (ms == 49) {
935 PrintStr("<polygon points=\"");
936 WriteReal(ix-m6); PrintStr(","); WriteReal(iy-m6*1.01);
937 WriteReal(ix-m6); PrintStr(","); WriteReal(iy-m2);
938 WriteReal(ix+m6); PrintStr(","); WriteReal(iy-m2);
939 WriteReal(ix+m6); PrintStr(","); WriteReal(iy-m6);
940 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m6);
941 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m6);
942 WriteReal(ix+m6); PrintStr(","); WriteReal(iy+m6);
943 WriteReal(ix+m6); PrintStr(","); WriteReal(iy+m2);
944 WriteReal(ix-m6); PrintStr(","); WriteReal(iy+m2);
945 WriteReal(ix-m6); PrintStr(","); WriteReal(iy+m6);
946 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m6);
947 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m6);
948 WriteReal(ix-m6); PrintStr(","); WriteReal(iy-m6*0.99);
949 WriteReal(ix-m6); PrintStr(","); WriteReal(iy+m6);
950 WriteReal(ix+m6); PrintStr(","); WriteReal(iy+m6);
951 WriteReal(ix+m6); PrintStr(","); WriteReal(iy-m6);
952 PrintStr("\"/>");
953 } else {
954 PrintStr("<line x1=\"");
955 WriteReal(ix-1, kFALSE);
956 PrintStr("\" y1=\"");
957 WriteReal(iy, kFALSE);
958 PrintStr("\" x2=\"");
959 WriteReal(ix, kFALSE);
960 PrintStr("\" y2=\"");
961 WriteReal(iy, kFALSE);
962 PrintStr("\"/>");
963 }
964 }
965 PrintStr("@");
966 PrintStr("</g>");
967}
968
969////////////////////////////////////////////////////////////////////////////////
970/// Paint PolyMarker
971
973{
974 Int_t ms = abs(fMarkerStyle);
975
976 if (ms >= 6 && ms <= 19) ms = 20;
977 if (ms == 4) ms = 24;
978
979 // Define the marker size
980 Float_t msize = fMarkerSize;
981 if (fMarkerStyle == 1) msize = 0.01;
982 if (fMarkerStyle == 6) msize = 0.02;
983 if (fMarkerStyle == 7) msize = 0.04;
984
985 const Int_t kBASEMARKER = 8;
986 Float_t sbase = msize*kBASEMARKER;
987 Float_t s2x = sbase / Float_t(gPad->GetWw() * gPad->GetAbsWNDC());
988 msize = this->UtoSVG(s2x) - this->UtoSVG(0);
989
990 Double_t m = msize;
991 Double_t m2 = m/2;
992 Double_t m3 = m/3;
993 Double_t m6 = m/6;
994 Double_t m4 = m/4.;
995 Double_t m8 = m/8.;
996 Double_t m0 = m/10.;
997
998 // Draw the marker according to the type
999 PrintStr("@");
1000 if ((ms > 19 && ms < 24) || ms == 29 || ms == 33 || ms == 34 ||//) {
1001 ms == 39 || ms == 41 || ms == 43 || ms == 45 ||
1002 ms == 47 || ms == 48 || ms == 49) {
1003 PrintStr("<g stroke=");
1005 PrintStr(" stroke-width=\"");
1007 PrintStr("\" fill=");
1009 PrintStr(">");
1010 } else {
1011 PrintStr("<g stroke=");
1013 PrintStr(" stroke-width=\"");
1015 PrintStr("\" fill=\"none\"");
1016 PrintStr(">");
1017 }
1018 Double_t ix,iy;
1019 for (Int_t i=0;i<n;i++) {
1020 ix = XtoSVG(xw[i]);
1021 iy = YtoSVG(yw[i]);
1022 PrintStr("@");
1023 // Dot (.)
1024 if (ms == 1) {
1025 PrintStr("<line x1=\"");
1026 WriteReal(ix-1, kFALSE);
1027 PrintStr("\" y1=\"");
1028 WriteReal(iy, kFALSE);
1029 PrintStr("\" x2=\"");
1030 WriteReal(ix, kFALSE);
1031 PrintStr("\" y2=\"");
1032 WriteReal(iy, kFALSE);
1033 PrintStr("\"/>");
1034 // Plus (+)
1035 } else if (ms == 2) {
1036 PrintStr("<line x1=\"");
1037 WriteReal(ix-m2, kFALSE);
1038 PrintStr("\" y1=\"");
1039 WriteReal(iy, kFALSE);
1040 PrintStr("\" x2=\"");
1041 WriteReal(ix+m2, kFALSE);
1042 PrintStr("\" y2=\"");
1043 WriteReal(iy, kFALSE);
1044 PrintStr("\"/>");
1045
1046 PrintStr("<line x1=\"");
1047 WriteReal(ix, kFALSE);
1048 PrintStr("\" y1=\"");
1049 WriteReal(iy-m2, kFALSE);
1050 PrintStr("\" x2=\"");
1051 WriteReal(ix, kFALSE);
1052 PrintStr("\" y2=\"");
1053 WriteReal(iy+m2, kFALSE);
1054 PrintStr("\"/>");
1055 // X shape (X)
1056 } else if (ms == 5) {
1057 PrintStr("<line x1=\"");
1058 WriteReal(ix-m2, kFALSE);
1059 PrintStr("\" y1=\"");
1060 WriteReal(iy-m2, kFALSE);
1061 PrintStr("\" x2=\"");
1062 WriteReal(ix+m2, kFALSE);
1063 PrintStr("\" y2=\"");
1064 WriteReal(iy+m2, kFALSE);
1065 PrintStr("\"/>");
1066
1067 PrintStr("<line x1=\"");
1068 WriteReal(ix-m2, kFALSE);
1069 PrintStr("\" y1=\"");
1070 WriteReal(iy+m2, kFALSE);
1071 PrintStr("\" x2=\"");
1072 WriteReal(ix+m2, kFALSE);
1073 PrintStr("\" y2=\"");
1074 WriteReal(iy-m2, kFALSE);
1075 PrintStr("\"/>");
1076 // Asterisk shape (*)
1077 } else if (ms == 3 || ms == 31) {
1078 PrintStr("<line x1=\"");
1079 WriteReal(ix-m2, kFALSE);
1080 PrintStr("\" y1=\"");
1081 WriteReal(iy, kFALSE);
1082 PrintStr("\" x2=\"");
1083 WriteReal(ix+m2, kFALSE);
1084 PrintStr("\" y2=\"");
1085 WriteReal(iy, kFALSE);
1086 PrintStr("\"/>");
1087
1088 PrintStr("<line x1=\"");
1089 WriteReal(ix, kFALSE);
1090 PrintStr("\" y1=\"");
1091 WriteReal(iy-m2, kFALSE);
1092 PrintStr("\" x2=\"");
1093 WriteReal(ix, kFALSE);
1094 PrintStr("\" y2=\"");
1095 WriteReal(iy+m2, kFALSE);
1096 PrintStr("\"/>");
1097
1098 PrintStr("<line x1=\"");
1099 WriteReal(ix-m2, kFALSE);
1100 PrintStr("\" y1=\"");
1101 WriteReal(iy-m2, kFALSE);
1102 PrintStr("\" x2=\"");
1103 WriteReal(ix+m2, kFALSE);
1104 PrintStr("\" y2=\"");
1105 WriteReal(iy+m2, kFALSE);
1106 PrintStr("\"/>");
1107
1108 PrintStr("<line x1=\"");
1109 WriteReal(ix-m2, kFALSE);
1110 PrintStr("\" y1=\"");
1111 WriteReal(iy+m2, kFALSE);
1112 PrintStr("\" x2=\"");
1113 WriteReal(ix+m2, kFALSE);
1114 PrintStr("\" y2=\"");
1115 WriteReal(iy-m2, kFALSE);
1116 PrintStr("\"/>");
1117 // Circle
1118 } else if (ms == 24 || ms == 20) {
1119 PrintStr("<circle cx=\"");
1120 WriteReal(ix, kFALSE);
1121 PrintStr("\" cy=\"");
1122 WriteReal(iy, kFALSE);
1123 PrintStr("\" r=\"");
1124 if (m2<=0) m2=1;
1126 PrintStr("\"/>");
1127 // Square
1128 } else if (ms == 25 || ms == 21) {
1129 PrintStr("<rect x=\"");
1130 WriteReal(ix-m2, kFALSE);
1131 PrintStr("\" y=\"");
1132 WriteReal(iy-m2, kFALSE);
1133 PrintStr("\" width=\"");
1134 WriteReal(m, kFALSE);
1135 PrintStr("\" height=\"");
1136 WriteReal(m, kFALSE);
1137 PrintStr("\"/>");
1138 // Down triangle
1139 } else if (ms == 26 || ms == 22) {
1140 PrintStr("<polygon points=\"");
1141 WriteReal(ix); PrintStr(","); WriteReal(iy-m2);
1142 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m2);
1143 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m2);
1144 PrintStr("\"/>");
1145 // Up triangle
1146 } else if (ms == 23 || ms == 32) {
1147 PrintStr("<polygon points=\"");
1148 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m2);
1149 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m2);
1150 WriteReal(ix); PrintStr(","); WriteReal(iy+m2);
1151 PrintStr("\"/>");
1152 // Diamond
1153 } else if (ms == 27 || ms == 33) {
1154 PrintStr("<polygon points=\"");
1155 WriteReal(ix); PrintStr(","); WriteReal(iy-m2);
1156 WriteReal(ix+m3); PrintStr(","); WriteReal(iy);
1157 WriteReal(ix); PrintStr(","); WriteReal(iy+m2);
1158 WriteReal(ix-m3); PrintStr(","); WriteReal(iy);
1159 PrintStr("\"/>");
1160 // Cross
1161 } else if (ms == 28 || ms == 34) {
1162 PrintStr("<polygon points=\"");
1163 WriteReal(ix-m6); PrintStr(","); WriteReal(iy-m6);
1164 WriteReal(ix-m6); PrintStr(","); WriteReal(iy-m2);
1165 WriteReal(ix+m6); PrintStr(","); WriteReal(iy-m2);
1166 WriteReal(ix+m6); PrintStr(","); WriteReal(iy-m6);
1167 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m6);
1168 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m6);
1169 WriteReal(ix+m6); PrintStr(","); WriteReal(iy+m6);
1170 WriteReal(ix+m6); PrintStr(","); WriteReal(iy+m2);
1171 WriteReal(ix-m6); PrintStr(","); WriteReal(iy+m2);
1172 WriteReal(ix-m6); PrintStr(","); WriteReal(iy+m6);
1173 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m6);
1174 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m6);
1175 PrintStr("\"/>");
1176 } else if (ms == 29 || ms == 30) {
1177 PrintStr("<polygon points=\"");
1178 WriteReal(ix); PrintStr(","); WriteReal(iy+m2);
1179 WriteReal(ix+0.112255*m); PrintStr(","); WriteReal(iy+0.15451*m);
1180 WriteReal(ix+0.47552*m); PrintStr(","); WriteReal(iy+0.15451*m);
1181 WriteReal(ix+0.181635*m); PrintStr(","); WriteReal(iy-0.05902*m);
1182 WriteReal(ix+0.29389*m); PrintStr(","); WriteReal(iy-0.40451*m);
1183 WriteReal(ix); PrintStr(","); WriteReal(iy-0.19098*m);
1184 WriteReal(ix-0.29389*m); PrintStr(","); WriteReal(iy-0.40451*m);
1185 WriteReal(ix-0.181635*m); PrintStr(","); WriteReal(iy-0.05902*m);
1186 WriteReal(ix-0.47552*m); PrintStr(","); WriteReal(iy+0.15451*m);
1187 WriteReal(ix-0.112255*m); PrintStr(","); WriteReal(iy+0.15451*m);
1188 PrintStr("\"/>");
1189 } else if (ms == 35) {
1190 PrintStr("<polygon points=\"");
1191 WriteReal(ix-m2); PrintStr(","); WriteReal(iy );
1192 WriteReal(ix ); PrintStr(","); WriteReal(iy-m2);
1193 WriteReal(ix+m2); PrintStr(","); WriteReal(iy );
1194 WriteReal(ix ); PrintStr(","); WriteReal(iy+m2);
1195 WriteReal(ix-m2); PrintStr(","); WriteReal(iy );
1196 WriteReal(ix+m2); PrintStr(","); WriteReal(iy );
1197 WriteReal(ix ); PrintStr(","); WriteReal(iy+m2);
1198 WriteReal(ix ); PrintStr(","); WriteReal(iy-m2);
1199 PrintStr("\"/>");
1200 } else if (ms == 36) {
1201 PrintStr("<polygon points=\"");
1202 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m2);
1203 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m2);
1204 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m2);
1205 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m2);
1206 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m2);
1207 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m2);
1208 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m2);
1209 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m2);
1210 PrintStr("\"/>");
1211 } else if (ms == 37 || ms == 39) {
1212 PrintStr("<polygon points=\"");
1213 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1214 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
1215 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
1216 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1217 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
1218 WriteReal(ix-m2); PrintStr(","); WriteReal(iy);
1219 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1220 WriteReal(ix+m2); PrintStr(","); WriteReal(iy );
1221 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
1222 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1223 PrintStr("\"/>");
1224 } else if (ms == 38) {
1225 PrintStr("<polygon points=\"");
1226 WriteReal(ix-m2); PrintStr(","); WriteReal(iy );
1227 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m4);
1228 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
1229 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
1230 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m4);
1231 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m4);
1232 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
1233 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
1234 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m4);
1235 WriteReal(ix-m2); PrintStr(","); WriteReal(iy );
1236 WriteReal(ix+m2); PrintStr(","); WriteReal(iy );
1237 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1238 WriteReal(ix ); PrintStr(","); WriteReal(iy-m2);
1239 WriteReal(ix ); PrintStr(","); WriteReal(iy+m2);
1240 WriteReal(ix ); PrintStr(","); WriteReal(iy);
1241 PrintStr("\"/>");
1242 } else if (ms == 40 || ms == 41) {
1243 PrintStr("<polygon points=\"");
1244 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1245 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
1246 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m4);
1247 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1248 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m4);
1249 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
1250 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1251 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
1252 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m4);
1253 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1254 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m4);
1255 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
1256 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1257 PrintStr("\"/>");
1258 } else if (ms == 42 || ms == 43) {
1259 PrintStr("<polygon points=\"");
1260 WriteReal(ix ); PrintStr(","); WriteReal(iy+m2);
1261 WriteReal(ix-m8); PrintStr(","); WriteReal(iy+m8);
1262 WriteReal(ix-m2); PrintStr(","); WriteReal(iy );
1263 WriteReal(ix-m8); PrintStr(","); WriteReal(iy-m8);
1264 WriteReal(ix ); PrintStr(","); WriteReal(iy-m2);
1265 WriteReal(ix+m8); PrintStr(","); WriteReal(iy-m8);
1266 WriteReal(ix+m2); PrintStr(","); WriteReal(iy );
1267 WriteReal(ix+m8); PrintStr(","); WriteReal(iy+m8);
1268 WriteReal(ix ); PrintStr(","); WriteReal(iy+m2);
1269 PrintStr("\"/>");
1270 } else if (ms == 44) {
1271 PrintStr("<polygon points=\"");
1272 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1273 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
1274 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
1275 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
1276 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
1277 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1278 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m4);
1279 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m4);
1280 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m4);
1281 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m4);
1282 WriteReal(ix ); PrintStr(","); WriteReal(iy );
1283 PrintStr("\"/>");
1284 } else if (ms == 45) {
1285 PrintStr("<polygon points=\"");
1286 WriteReal(ix+m0); PrintStr(","); WriteReal(iy+m0);
1287 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
1288 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
1289 WriteReal(ix-m0); PrintStr(","); WriteReal(iy+m0);
1290 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m4);
1291 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m4);
1292 WriteReal(ix-m0); PrintStr(","); WriteReal(iy-m0);
1293 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
1294 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
1295 WriteReal(ix+m0); PrintStr(","); WriteReal(iy-m0);
1296 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m4);
1297 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m4);
1298 WriteReal(ix+m0); PrintStr(","); WriteReal(iy+m0);
1299 PrintStr("\"/>");
1300 } else if (ms == 46 || ms == 47) {
1301 PrintStr("<polygon points=\"");
1302 WriteReal(ix ); PrintStr(","); WriteReal(iy+m4);
1303 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
1304 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m4);
1305 WriteReal(ix-m4); PrintStr(","); WriteReal(iy );
1306 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m4);
1307 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
1308 WriteReal(ix ); PrintStr(","); WriteReal(iy-m4);
1309 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
1310 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m4);
1311 WriteReal(ix+m4); PrintStr(","); WriteReal(iy );
1312 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m4);
1313 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
1314 WriteReal(ix ); PrintStr(","); WriteReal(iy+m4);
1315 PrintStr("\"/>");
1316 } else if (ms == 48) {
1317 PrintStr("<polygon points=\"");
1318 WriteReal(ix ); PrintStr(","); WriteReal(iy+m4*1.01);
1319 WriteReal(ix-m4); PrintStr(","); WriteReal(iy+m2);
1320 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m4);
1321 WriteReal(ix-m4); PrintStr(","); WriteReal(iy );
1322 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m4);
1323 WriteReal(ix-m4); PrintStr(","); WriteReal(iy-m2);
1324 WriteReal(ix ); PrintStr(","); WriteReal(iy-m4);
1325 WriteReal(ix+m4); PrintStr(","); WriteReal(iy-m2);
1326 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m4);
1327 WriteReal(ix+m4); PrintStr(","); WriteReal(iy );
1328 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m4);
1329 WriteReal(ix+m4); PrintStr(","); WriteReal(iy+m2);
1330 WriteReal(ix ); PrintStr(","); WriteReal(iy+m4*0.99);
1331 WriteReal(ix+m4*0.99); PrintStr(","); WriteReal(iy );
1332 WriteReal(ix ); PrintStr(","); WriteReal(iy-m4*0.99);
1333 WriteReal(ix-m4*0.99); PrintStr(","); WriteReal(iy );
1334 WriteReal(ix ); PrintStr(","); WriteReal(iy+m4*0.99);
1335 PrintStr("\"/>");
1336 } else if (ms == 49) {
1337 PrintStr("<polygon points=\"");
1338 WriteReal(ix-m6); PrintStr(","); WriteReal(iy-m6*1.01);
1339 WriteReal(ix-m6); PrintStr(","); WriteReal(iy-m2);
1340 WriteReal(ix+m6); PrintStr(","); WriteReal(iy-m2);
1341 WriteReal(ix+m6); PrintStr(","); WriteReal(iy-m6);
1342 WriteReal(ix+m2); PrintStr(","); WriteReal(iy-m6);
1343 WriteReal(ix+m2); PrintStr(","); WriteReal(iy+m6);
1344 WriteReal(ix+m6); PrintStr(","); WriteReal(iy+m6);
1345 WriteReal(ix+m6); PrintStr(","); WriteReal(iy+m2);
1346 WriteReal(ix-m6); PrintStr(","); WriteReal(iy+m2);
1347 WriteReal(ix-m6); PrintStr(","); WriteReal(iy+m6);
1348 WriteReal(ix-m2); PrintStr(","); WriteReal(iy+m6);
1349 WriteReal(ix-m2); PrintStr(","); WriteReal(iy-m6);
1350 WriteReal(ix-m6); PrintStr(","); WriteReal(iy-m6*0.99);
1351 WriteReal(ix-m6); PrintStr(","); WriteReal(iy+m6);
1352 WriteReal(ix+m6); PrintStr(","); WriteReal(iy+m6);
1353 WriteReal(ix+m6); PrintStr(","); WriteReal(iy-m6);
1354 PrintStr("\"/>");
1355 } else {
1356 PrintStr("<line x1=\"");
1357 WriteReal(ix-1, kFALSE);
1358 PrintStr("\" y1=\"");
1359 WriteReal(iy, kFALSE);
1360 PrintStr("\" x2=\"");
1361 WriteReal(ix, kFALSE);
1362 PrintStr("\" y2=\"");
1363 WriteReal(iy, kFALSE);
1364 PrintStr("\"/>");
1365 }
1366 }
1367 PrintStr("@");
1368 PrintStr("</g>");
1369}
1370
1371////////////////////////////////////////////////////////////////////////////////
1372/// This function defines a path with xw and yw and draw it according the
1373/// value of nn:
1374///
1375/// - If nn>0 a line is drawn.
1376/// - If nn<0 a closed polygon is drawn.
1377
1379{
1380 Int_t n, fais, fasi;
1381 Double_t ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
1382 fais = fasi = 0;
1383
1384 if (nn > 0) {
1385 if (fLineWidth<=0) return;
1386 n = nn;
1387 } else {
1388 n = -nn;
1389 fais = fFillStyle/1000;
1390 fasi = fFillStyle%1000;
1391 if (fais == 3 || fais == 2) {
1392 if (fasi > 100 && fasi <125) {
1393 return;
1394 }
1395 if (fasi > 0 && fasi < 26) {
1396 }
1397 }
1398 }
1399
1400 if( n <= 1) {
1401 Error("DrawPS", "Two points are needed");
1402 return;
1403 }
1404
1405 ixd0 = XtoSVG(xw[0]);
1406 iyd0 = YtoSVG(yw[0]);
1407
1408 PrintStr("@");
1409 PrintFast(10,"<path d=\"M");
1410 WriteReal(ixd0, kFALSE);
1411 PrintFast(1,",");
1412 WriteReal(iyd0, kFALSE);
1413
1414 idx = idy = 0;
1415 for (Int_t i=1;i<n;i++) {
1416 ixdi = XtoSVG(xw[i]);
1417 iydi = YtoSVG(yw[i]);
1418 ix = ixdi - ixd0;
1419 iy = iydi - iyd0;
1420 ixd0 = ixdi;
1421 iyd0 = iydi;
1422 if( ix && iy) {
1423 if( idx ) { MovePS(idx,0); idx = 0; }
1424 if( idy ) { MovePS(0,idy); idy = 0; }
1425 MovePS(ix,iy);
1426 } else if ( ix ) {
1427 if( idy ) { MovePS(0,idy); idy = 0;}
1428 if( !idx ) { idx = ix;}
1429 else if( TMath::Sign(ix,idx) == ix ) idx += ix;
1430 else { MovePS(idx,0); idx = ix;}
1431 } else if( iy ) {
1432 if( idx ) { MovePS(idx,0); idx = 0;}
1433 if( !idy) { idy = iy;}
1434 else if( TMath::Sign(iy,idy) == iy) idy += iy;
1435 else { MovePS(0,idy); idy = iy;}
1436 }
1437 }
1438 if (idx) MovePS(idx,0);
1439 if (idy) MovePS(0,idy);
1440
1441 if (nn > 0 ) {
1442 if (xw[0] == xw[n-1] && yw[0] == yw[n-1]) PrintFast(1,"z");
1443 PrintFast(21,"\" fill=\"none\" stroke=");
1445 if(fLineWidth > 1.) {
1446 PrintFast(15," stroke-width=\"");
1448 PrintFast(1,"\"");
1449 }
1450 if (fLineStyle > 1) {
1451 PrintFast(19," stroke-dasharray=\"");
1453 TObjArray *tokens = st.Tokenize(" ");
1454 for (Int_t j = 0; j<tokens->GetEntries(); j++) {
1455 Int_t it;
1456 sscanf(((TObjString*)tokens->At(j))->GetName(), "%d", &it);
1457 if (j>0) PrintFast(1,",");
1458 WriteReal(it/4);
1459 }
1460 delete tokens;
1461 PrintFast(1,"\"");
1462 }
1463 PrintFast(2,"/>");
1464 } else {
1465 PrintFast(8,"z\" fill=");
1466 if (fais == 0) {
1467 PrintFast(14,"\"none\" stroke=");
1469 } else {
1471 }
1472 PrintFast(2,"/>");
1473 }
1474}
1475
1476////////////////////////////////////////////////////////////////////////////////
1477/// Initialize the SVG file. The main task of the function is to output the
1478/// SVG header file which consist in <title>, <desc> and <defs>. The
1479/// HeaderPS provided by the user program is written in the <defs> part.
1480
1482{
1483 // Title
1484 PrintStr("<title>@");
1485 PrintStr(GetName());
1486 PrintStr("@");
1487 PrintStr("</title>@");
1488
1489 // Description
1490 PrintStr("<desc>@");
1491 PrintFast(22,"Creator: ROOT Version ");
1492 PrintStr(gROOT->GetVersion());
1493 PrintStr("@");
1494 PrintFast(14,"CreationDate: ");
1495 TDatime t;
1496 PrintStr(t.AsString());
1497 //Check a special header is defined in the current style
1498 Int_t nh = strlen(gStyle->GetHeaderPS());
1499 if (nh) {
1501 }
1502 PrintStr("</desc>@");
1503
1504 // Definitions
1505 PrintStr("<defs>@");
1506 PrintStr("</defs>@");
1507
1508}
1509
1510////////////////////////////////////////////////////////////////////////////////
1511/// Move to a new position (ix, iy). The move is done in relative coordinates
1512/// which allows to have short numbers which decrease the size of the file.
1513/// This function use the full power of the SVG's paths by using the
1514/// horizontal and vertical move whenever it is possible.
1515
1517{
1518 if (ix != 0 && iy != 0) {
1519 PrintFast(1,"l");
1520 WriteReal(ix);
1521 PrintFast(1,",");
1522 WriteReal(iy);
1523 } else if (ix != 0) {
1524 PrintFast(1,"h");
1525 WriteReal(ix);
1526 } else if (iy != 0) {
1527 PrintFast(1,"v");
1528 WriteReal(iy);
1529 }
1530}
1531
1532////////////////////////////////////////////////////////////////////////////////
1533/// Start the SVG page. This function initialize the pad conversion
1534/// coefficients and output the <svg> directive which is close later in the
1535/// the function Close.
1536
1538{
1539 // Compute pad conversion coefficients
1540 if (gPad) {
1541 Double_t ww = gPad->GetWw();
1542 Double_t wh = gPad->GetWh();
1543 fYsize = fXsize*wh/ww;
1544 } else {
1545 fYsize = 27;
1546 }
1547
1548 // <svg> directive. It defines the viewBox.
1549 if(!fBoundingBox) {
1550 PrintStr("@<?xml version=\"1.0\" standalone=\"no\"?>");
1551 PrintStr("@<svg width=\"");
1553 PrintStr("\" height=\"");
1556 PrintStr("\" viewBox=\"0 0");
1559 PrintStr("\" xmlns=\"http://www.w3.org/2000/svg\" shape-rendering=\"crispEdges\">");
1560 PrintStr("@");
1561 Initialize();
1563 }
1564}
1565
1566////////////////////////////////////////////////////////////////////////////////
1567/// Set the range for the paper in centimetres
1568
1569void TSVG::Range(Float_t xsize, Float_t ysize)
1570{
1571 Float_t xps, yps, xncm, yncm, dxwn, dywn, xwkwn, ywkwn, xymax;
1572
1573 fXsize = xsize;
1574 fYsize = ysize;
1575
1576 xps = xsize;
1577 yps = ysize;
1578
1579 if( xsize <= xps && ysize < yps) {
1580 if ( xps > yps ) xymax = xps;
1581 else xymax = yps;
1582 xncm = xsize/xymax;
1583 yncm = ysize/xymax;
1584 dxwn = ((xps/xymax)-xncm)/2;
1585 dywn = ((yps/xymax)-yncm)/2;
1586 } else {
1587 if (xps/yps < 1) xwkwn = xps/yps;
1588 else xwkwn = 1;
1589 if (yps/xps < 1) ywkwn = yps/xps;
1590 else ywkwn = 1;
1591
1592 if (xsize < ysize) {
1593 xncm = ywkwn*xsize/ysize;
1594 yncm = ywkwn;
1595 dxwn = (xwkwn-xncm)/2;
1596 dywn = 0;
1597 if( dxwn < 0) {
1598 xncm = xwkwn;
1599 dxwn = 0;
1600 yncm = xwkwn*ysize/xsize;
1601 dywn = (ywkwn-yncm)/2;
1602 }
1603 } else {
1604 xncm = xwkwn;
1605 yncm = xwkwn*ysize/xsize;
1606 dxwn = 0;
1607 dywn = (ywkwn-yncm)/2;
1608 if( dywn < 0) {
1609 yncm = ywkwn;
1610 dywn = 0;
1611 xncm = ywkwn*xsize/ysize;
1612 dxwn = (xwkwn-xncm)/2;
1613 }
1614 }
1615 }
1616 fRange = kTRUE;
1617}
1618
1619////////////////////////////////////////////////////////////////////////////////
1620/// Set color index for fill areas
1621
1623{
1624 fFillColor = cindex;
1625 if (gStyle->GetFillColor() <= 0) cindex = 0;
1626}
1627
1628////////////////////////////////////////////////////////////////////////////////
1629/// Set color index for lines
1630
1632{
1633 fLineColor = cindex;
1634}
1635
1636////////////////////////////////////////////////////////////////////////////////
1637/// Change the line style
1638///
1639/// - linestyle = 2 dashed
1640/// - linestyle = 3 dotted
1641/// - linestyle = 4 dash-dotted
1642/// - linestyle = else solid (1 in is used most of the time)
1643
1645{
1646 fLineStyle = linestyle;
1647}
1648
1649////////////////////////////////////////////////////////////////////////////////
1650/// Set the lines width.
1651
1653{
1654 fLineWidth = linewidth;
1655}
1656
1657////////////////////////////////////////////////////////////////////////////////
1658/// Set color index for markers.
1659
1661{
1662 fMarkerColor = cindex;
1663}
1664
1665////////////////////////////////////////////////////////////////////////////////
1666/// Set color with its color index
1667
1669{
1670 if (color < 0) color = 0;
1671 TColor *col = gROOT->GetColor(color);
1672 if (col) {
1673 SetColor(col->GetRed(), col->GetGreen(), col->GetBlue());
1674 Float_t a = col->GetAlpha();
1675 if (a<1.) PrintStr(Form(" fill-opacity=\"%3.2f\" stroke-opacity=\"%3.2f\"",a,a));
1676 } else {
1677 SetColor(1., 1., 1.);
1678 }
1679}
1680
1681////////////////////////////////////////////////////////////////////////////////
1682/// Set color with its R G B components
1683///
1684/// - r: % of red in [0,1]
1685/// --g: % of green in [0,1]
1686/// - b: % of blue in [0,1]
1687
1689{
1690 if (r <= 0. && g <= 0. && b <= 0. ) {
1691 PrintFast(7,"\"black\"");
1692 } else if (r >= 1. && g >= 1. && b >= 1. ) {
1693 PrintFast(7,"\"white\"");
1694 } else {
1695 char str[12];
1696 snprintf(str,12,"\"#%2.2x%2.2x%2.2x\"",Int_t(255.*r)
1697 ,Int_t(255.*g)
1698 ,Int_t(255.*b));
1699 PrintStr(str);
1700 }
1701}
1702
1703////////////////////////////////////////////////////////////////////////////////
1704/// Set color index for text
1705
1707{
1708 fTextColor = cindex;
1709}
1710
1711////////////////////////////////////////////////////////////////////////////////
1712/// Draw text
1713///
1714/// - xx: x position of the text
1715/// - yy: y position of the text
1716/// - chars: text to be drawn
1717
1718void TSVG::Text(Double_t xx, Double_t yy, const char *chars)
1719{
1720 static const char *fontFamily[] = {
1721 "Times" , "Times" , "Times",
1722 "Helvetica", "Helvetica", "Helvetica" , "Helvetica",
1723 "Courier" , "Courier" , "Courier" , "Courier",
1724 "Times" ,"Times" , "ZapfDingbats", "Times"};
1725
1726 static const char *fontWeight[] = {
1727 "normal", "bold", "bold",
1728 "normal", "normal", "bold" , "bold",
1729 "normal", "normal", "bold" , "bold",
1730 "normal", "normal", "normal", "normal"};
1731
1732 static const char *fontStyle[] = {
1733 "italic", "normal" , "italic",
1734 "normal", "oblique", "normal", "oblique",
1735 "normal", "oblique", "normal", "oblique",
1736 "normal", "normal" , "normal", "italic"};
1737
1738 Double_t ix = XtoSVG(xx);
1739 Double_t iy = YtoSVG(yy);
1740 Double_t txalh = fTextAlign/10;
1741 if (txalh <1) txalh = 1; else if (txalh > 3) txalh = 3;
1742 Double_t txalv = fTextAlign%10;
1743 if (txalv <1) txalv = 1; else if (txalv > 3) txalv = 3;
1744
1745 Double_t wh = (Double_t)gPad->XtoPixel(gPad->GetX2());
1746 Double_t hh = (Double_t)gPad->YtoPixel(gPad->GetY1());
1747 Float_t fontrap = 1.09; //scale down compared to X11
1748 Float_t ftsize;
1749
1750 Int_t font = abs(fTextFont)/10;
1751 if (font > 42 || font < 1) font = 1;
1752 if (wh < hh) {
1753 ftsize = fTextSize*fXsize*gPad->GetAbsWNDC();
1754 } else {
1755 ftsize = fTextSize*fYsize*gPad->GetAbsHNDC();
1756 }
1757 Int_t ifont = font-1;
1758
1759 Double_t fontsize = CMtoSVG(ftsize/fontrap);
1760 if( fontsize <= 0) return;
1761
1762 if (txalv == 3) iy = iy+fontsize;
1763 if (txalv == 2) iy = iy+(fontsize/2);
1764
1765 if (fTextAngle != 0.) {
1766 PrintStr("@");
1767 PrintFast(21,"<g transform=\"rotate(");
1769 PrintFast(1,",");
1770 WriteReal(ix, kFALSE);
1771 PrintFast(1,",");
1772 WriteReal(iy, kFALSE);
1773 PrintFast(3,")\">");
1774 }
1775
1776 PrintStr("@");
1777 PrintFast(30,"<text xml:space=\"preserve\" x=\"");
1778 WriteReal(ix, kFALSE);
1779 PrintFast(5,"\" y=\"");
1780 WriteReal(iy, kFALSE);
1781 PrintFast(1,"\"");
1782 if (txalh == 2) {
1783 PrintFast(21," text-anchor=\"middle\"");
1784 } else if (txalh == 3) {
1785 PrintFast(18," text-anchor=\"end\"");
1786 }
1787 PrintFast(6," fill=");
1789 PrintFast(12," font-size=\"");
1790 WriteReal(fontsize, kFALSE);
1791 PrintFast(15,"\" font-family=\"");
1792 PrintStr(fontFamily[ifont]);
1793 if (strcmp(fontWeight[ifont],"normal")) {
1794 PrintFast(15,"\" font-weight=\"");
1795 PrintStr(fontWeight[ifont]);
1796 }
1797 if (strcmp(fontStyle[ifont],"normal")) {
1798 PrintFast(14,"\" font-style=\"");
1799 PrintStr(fontStyle[ifont]);
1800 }
1801 PrintFast(2,"\">");
1802
1803 if (font == 12 || font == 15) {
1804 Int_t ichar = chars[0]+848;
1805 Int_t ic = ichar;
1806
1807 // Math Symbols (cf: http://www.fileformat.info/info/unicode/category/Sm/list.htm)
1808 if (ic == 755) ichar = 8804;
1809 if (ic == 759) ichar = 9827;
1810 if (ic == 760) ichar = 9830;
1811 if (ic == 761) ichar = 9829;
1812 if (ic == 762) ichar = 9824;
1813 if (ic == 766) ichar = 8594;
1814 if (ic == 776) ichar = 247;
1815 if (ic == 757) ichar = 8734;
1816 if (ic == 758) ichar = 402;
1817 if (ic == 771) ichar = 8805;
1818 if (ic == 774) ichar = 8706;
1819 if (ic == 775) ichar = 8226;
1820 if (ic == 779) ichar = 8776;
1821 if (ic == 805) ichar = 8719;
1822 if (ic == 821) ichar = 8721;
1823 if (ic == 834) ichar = 8747;
1824 if (ic == 769) ichar = 177;
1825 if (ic == 772) ichar = 215;
1826 if (ic == 768) ichar = 176;
1827 if (ic == 791) ichar = 8745;
1828 if (ic == 793) ichar = 8835; // SUPERSET OF
1829 if (ic == 794) ichar = 8839; // SUPERSET OF OR EQUAL TO
1830 if (ic == 795) ichar = 8836; // NOT A SUBSET OF
1831 if (ic == 796) ichar = 8834;
1832 if (ic == 893) ichar = 8722;
1833 if (ic == 803) ichar = 169; // COPYRIGHT SIGN
1834 if (ic == 819) ichar = 169; // COPYRIGHT SIGN
1835 if (ic == 804) ichar = 8482;
1836 if (ic == 770) ichar = 34;
1837 if (ic == 823) ichar = 10072;
1838 if (ic == 781) ichar = 10072;
1839 if (ic == 824) ichar = 9117; // LEFT PARENTHESIS LOWER HOOK
1840 if (ic == 822) ichar = 9115; // LEFT PARENTHESIS UPPER HOOK
1841 if (ic == 767) ichar = 8595; // DOWNWARDS ARROW
1842 if (ic == 763) ichar = 8596; // LEFT RIGHT ARROW
1843 if (ic == 764) ichar = 8592; // LEFTWARDS ARROW
1844 if (ic == 788) ichar = 8855; // CIRCLED TIMES
1845 if (ic == 784) ichar = 8501;
1846 if (ic == 777) ichar = 8800;
1847 if (ic == 797) ichar = 8838;
1848 if (ic == 800) ichar = 8736;
1849 if (ic == 812) ichar = 8656; // LEFTWARDS DOUBLE ARROW
1850 if (ic == 817) ichar = 60; // LESS-THAN SIGN
1851 if (ic == 833) ichar = 62; // GREATER-THAN SIGN
1852 if (ic == 778) ichar = 8803; // STRICTLY EQUIVALENT TO
1853 if (ic == 809) ichar = 8743; // LOGICAL AND
1854 if (ic == 802) ichar = 9415; // CIRCLED LATIN CAPITAL LETTER R
1855 if (ic == 780) ichar = 8230; // HORIZONTAL ELLIPSIS
1856 if (ic == 801) ichar = 8711; // NABLA
1857 if (ic == 783) ichar = 8629; // DOWNWARDS ARROW WITH CORNER LEFTWARDS
1858 if (ic == 782) ichar = 8213;
1859 if (ic == 799) ichar = 8713;
1860 if (ic == 792) ichar = 8746;
1861 if (ic == 828) ichar = 9127;
1862 if (ic == 765) ichar = 8593; // UPWARDS ARROW
1863 if (ic == 789) ichar = 8853; // CIRCLED PLUS
1864 if (ic == 813) ichar = 8657; // UPWARDS DOUBLE ARROW
1865 if (ic == 773) ichar = 8733; // PROPORTIONAL TO
1866 if (ic == 790) ichar = 8709; // EMPTY SET
1867 if (ic == 810) ichar = 8744;
1868 if (ic == 756) ichar = 8260;
1869 if (ic == 807) ichar = 8231;
1870 if (ic == 808) ichar = 8989; // TOP RIGHT CORNER
1871 if (ic == 814) ichar = 8658; // RIGHTWARDS DOUBLE ARROW
1872 if (ic == 806) ichar = 8730; // SQUARE ROOT
1873 if (ic == 827) ichar = 9123;
1874 if (ic == 829) ichar = 9128;
1875 if (ic == 786) ichar = 8476;
1876 if (ic == 785) ichar = 8465;
1877 if (ic == 787) ichar = 8472;
1878
1879 // Greek characters
1880 if (ic == 918) ichar = 934;
1881 if (ic == 919) ichar = 915;
1882 if (ic == 920) ichar = 919;
1883 if (ic == 923) ichar = 922;
1884 if (ic == 924) ichar = 923;
1885 if (ic == 925) ichar = 924;
1886 if (ic == 926) ichar = 925;
1887 if (ic == 929) ichar = 920;
1888 if (ic == 930) ichar = 929;
1889 if (ic == 936) ichar = 926;
1890 if (ic == 915) ichar = 935;
1891 if (ic == 937) ichar = 936;
1892 if (ic == 935) ichar = 937;
1893 if (ic == 938) ichar = 918;
1894 if (ic == 951) ichar = 947;
1895 if (ic == 798) ichar = 949;
1896 if (ic == 970) ichar = 950;
1897 if (ic == 952) ichar = 951;
1898 if (ic == 961) ichar = 952;
1899 if (ic == 955) ichar = 954;
1900 if (ic == 956) ichar = 955;
1901 if (ic == 957) ichar = 956;
1902 if (ic == 958) ichar = 957;
1903 if (ic == 968) ichar = 958;
1904 if (ic == 934) ichar = 962;
1905 if (ic == 962) ichar = 961;
1906 if (ic == 966) ichar = 969;
1907 if (ic == 950) ichar = 966;
1908 if (ic == 947) ichar = 967;
1909 if (ic == 969) ichar = 968;
1910 if (ic == 967) ichar = 969;
1911 if (ic == 954) ichar = 966;
1912 if (ic == 922) ichar = 952;
1913 if (ic == 753) ichar = 965;
1914 PrintStr(Form("&#%4.4d;",ichar));
1915 } else {
1916 Int_t len=strlen(chars);
1917 for (Int_t i=0; i<len;i++) {
1918 if (chars[i]!='\n') {
1919 if (chars[i]=='<') {
1920 PrintFast(4,"&lt;");
1921 } else if (chars[i]=='>') {
1922 PrintFast(4,"&gt;");
1923 } else if (chars[i]=='\305') {
1924 PrintFast(7,"&#8491;"); // ANGSTROM SIGN
1925 } else if (chars[i]=='\345') {
1926 PrintFast(6,"&#229;");
1927 } else if (chars[i]=='&') {
1928 PrintFast(5,"&amp;");
1929 } else {
1930 PrintFast(1,&chars[i]);
1931 }
1932 }
1933 }
1934 }
1935
1936 PrintFast(7,"</text>");
1937
1938 if (fTextAngle != 0.) {
1939 PrintStr("@");
1940 PrintFast(4,"</g>");
1941 }
1942}
1943
1944////////////////////////////////////////////////////////////////////////////////
1945/// Write a string of characters in NDC
1946
1947void TSVG::TextNDC(Double_t u, Double_t v, const char *chars)
1948{
1949 Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
1950 Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
1951 Text(x, y, chars);
1952}
1953
1954////////////////////////////////////////////////////////////////////////////////
1955/// Convert U from NDC coordinate to SVG
1956
1958{
1959 Double_t cm = fXsize*(gPad->GetAbsXlowNDC() + u*gPad->GetAbsWNDC());
1960 return 0.5 + 72*cm/2.54;
1961}
1962
1963////////////////////////////////////////////////////////////////////////////////
1964/// Convert V from NDC coordinate to SVG
1965
1967{
1968 Double_t cm = fYsize*(gPad->GetAbsYlowNDC() + v*gPad->GetAbsHNDC());
1969 return 0.5 + 72*cm/2.54;
1970}
1971
1972////////////////////////////////////////////////////////////////////////////////
1973/// Convert X from world coordinate to SVG
1974
1976{
1977 Double_t u = (x - gPad->GetX1())/(gPad->GetX2() - gPad->GetX1());
1978 return UtoSVG(u);
1979}
1980
1981////////////////////////////////////////////////////////////////////////////////
1982/// Convert Y from world coordinate to SVG
1983
1985{
1986 Double_t v = (y - gPad->GetY1())/(gPad->GetY2() - gPad->GetY1());
1987 return fYsizeSVG-VtoSVG(v);
1988}
1989
1990////////////////////////////////////////////////////////////////////////////////
1991/// Begin the Cell Array painting
1992
1994 Double_t)
1995{
1996 Warning("TSVG::CellArrayBegin", "not yet implemented");
1997}
1998
1999////////////////////////////////////////////////////////////////////////////////
2000/// Paint the Cell Array
2001
2003{
2004 Warning("TSVG::CellArrayFill", "not yet implemented");
2005}
2006
2007////////////////////////////////////////////////////////////////////////////////
2008/// End the Cell Array painting
2009
2011{
2012 Warning("TSVG::CellArrayEnd", "not yet implemented");
2013}
2014
2015////////////////////////////////////////////////////////////////////////////////
2016/// Not needed in SVG case
2017
2019{
2020 Warning("TSVG::DrawPS", "not yet implemented");
2021}
SVector< double, 2 > v
Definition: Dict.h:5
ROOT::R::TRInterface & r
Definition: Object.C:4
#define b(i)
Definition: RSha256.hxx:100
#define g(i)
Definition: RSha256.hxx:105
static const double x2[5]
static const double x1[5]
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
short Width_t
Definition: RtypesCore.h:78
double Double_t
Definition: RtypesCore.h:55
short Color_t
Definition: RtypesCore.h:79
short Style_t
Definition: RtypesCore.h:76
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:363
XPoint xy[kMAXMK]
Definition: TGX11.cxx:122
#define gROOT
Definition: TROOT.h:410
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
Definition: TStyle.h:406
R__EXTERN TVirtualPS * gVirtualPS
Definition: TVirtualPS.h:81
#define gPad
Definition: TVirtualPad.h:286
#define snprintf
Definition: civetweb.c:1540
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
Style_t fFillStyle
Fill area style.
Definition: TAttFill.h:23
Color_t fFillColor
Fill area color.
Definition: TAttFill.h:22
Width_t fLineWidth
Line width.
Definition: TAttLine.h:23
Style_t fLineStyle
Line style.
Definition: TAttLine.h:22
Color_t fLineColor
Line color.
Definition: TAttLine.h:21
Color_t fMarkerColor
Marker color.
Definition: TAttMarker.h:22
Size_t fMarkerSize
Marker size.
Definition: TAttMarker.h:24
Style_t fMarkerStyle
Marker style.
Definition: TAttMarker.h:23
Color_t fTextColor
Text color.
Definition: TAttText.h:24
Float_t fTextAngle
Text angle.
Definition: TAttText.h:21
Font_t fTextFont
Text font.
Definition: TAttText.h:25
Short_t fTextAlign
Text alignment.
Definition: TAttText.h:23
Float_t fTextSize
Text size.
Definition: TAttText.h:22
The color creation and management class.
Definition: TColor.h:19
Float_t GetRed() const
Definition: TColor.h:56
Float_t GetAlpha() const
Definition: TColor.h:62
Float_t GetBlue() const
Definition: TColor.h:58
Float_t GetGreen() const
Definition: TColor.h:57
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:164
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
An array of TObjects.
Definition: TObjArray.h:37
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:522
TObject * At(Int_t idx) const
Definition: TObjArray.h:165
Collectable string class.
Definition: TObjString.h:28
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
2-D graphics point (world coordinates).
Definition: TPoints.h:19
Interface to SVG.
Definition: TSVG.h:20
Double_t UtoSVG(Double_t u)
Convert U from NDC coordinate to SVG.
Definition: TSVG.cxx:1957
void SetTextColor(Color_t cindex=1)
Set color index for text.
Definition: TSVG.cxx:1706
void MovePS(Double_t x, Double_t y)
Move to a new position (ix, iy).
Definition: TSVG.cxx:1516
void SetFillColor(Color_t cindex=1)
Set color index for fill areas.
Definition: TSVG.cxx:1622
Double_t fYsizeSVG
Page's Y size in SVG units.
Definition: TSVG.h:28
void DrawPolyLine(Int_t n, TPoints *xy)
Draw a PolyLine.
Definition: TSVG.cxx:433
Bool_t fRange
True when a range has been defined.
Definition: TSVG.h:27
Double_t YtoSVG(Double_t y)
Convert Y from world coordinate to SVG.
Definition: TSVG.cxx:1984
void CellArrayBegin(Int_t W, Int_t H, Double_t x1, Double_t x2, Double_t y1, Double_t y2)
Begin the Cell Array painting.
Definition: TSVG.cxx:1993
void Initialize()
Initialize the SVG file.
Definition: TSVG.cxx:1481
void Text(Double_t x, Double_t y, const char *string)
Draw text.
Definition: TSVG.cxx:1718
void SetLineColor(Color_t cindex=1)
Set color index for lines.
Definition: TSVG.cxx:1631
void CellArrayEnd()
End the Cell Array painting.
Definition: TSVG.cxx:2010
void SetColor(Int_t color=1)
Set color with its color index.
Definition: TSVG.cxx:1668
Int_t fType
Workstation type used to know if the SVG is open.
Definition: TSVG.h:25
void Off()
Deactivate an already open SVG file.
Definition: TSVG.cxx:197
void Range(Float_t xrange, Float_t yrange)
Set the range for the paper in centimetres.
Definition: TSVG.cxx:1569
void Open(const char *filename, Int_t type=-111)
Open a SVG file.
Definition: TSVG.cxx:109
void SetLineScale(Float_t=3)
Definition: TSVG.h:62
void SetMarkerColor(Color_t cindex=1)
Set color index for markers.
Definition: TSVG.cxx:1660
void DrawPS(Int_t n, Float_t *xw, Float_t *yw)
Not needed in SVG case.
Definition: TSVG.cxx:2018
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw a Box.
Definition: TSVG.cxx:205
void SetLineWidth(Width_t linewidth=1)
Set the lines width.
Definition: TSVG.cxx:1652
void On()
Activate an already open SVG file.
Definition: TSVG.cxx:181
TSVG()
Default SVG constructor.
Definition: TSVG.cxx:77
virtual ~TSVG()
Default SVG destructor.
Definition: TSVG.cxx:157
void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y)
Paint PolyMarker.
Definition: TSVG.cxx:568
Double_t CMtoSVG(Double_t u)
Definition: TSVG.h:39
Double_t XtoSVG(Double_t x)
Convert X from world coordinate to SVG.
Definition: TSVG.cxx:1975
Bool_t fBoundingBox
True when the SVG header is printed.
Definition: TSVG.h:26
Float_t fXsize
Page size along X.
Definition: TSVG.h:23
Float_t fYsize
Page size along Y.
Definition: TSVG.h:24
void DrawPolyLineNDC(Int_t n, TPoints *uv)
Draw a PolyLine in NDC space.
Definition: TSVG.cxx:504
void TextNDC(Double_t u, Double_t v, const char *string)
Write a string of characters in NDC.
Definition: TSVG.cxx:1947
void CellArrayFill(Int_t r, Int_t g, Int_t b)
Paint the Cell Array.
Definition: TSVG.cxx:2002
void Close(Option_t *opt="")
Close a SVG file.
Definition: TSVG.cxx:165
void SetLineStyle(Style_t linestyle=1)
Change the line style.
Definition: TSVG.cxx:1644
void NewPage()
Start the SVG page.
Definition: TSVG.cxx:1537
Double_t VtoSVG(Double_t v)
Convert V from NDC coordinate to SVG.
Definition: TSVG.cxx:1966
void DrawFrame(Double_t xl, Double_t yl, Double_t xt, Double_t yt, Int_t mode, Int_t border, Int_t dark, Int_t light)
Draw a Frame around a box.
Definition: TSVG.cxx:285
Basic string class.
Definition: TString.h:131
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2172
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
Definition: TStyle.cxx:970
void GetPaperSize(Float_t &xsize, Float_t &ysize) const
Set paper size for PostScript output.
Definition: TStyle.cxx:988
const char * GetHeaderPS() const
Definition: TStyle.h:271
Float_t GetLineScalePS() const
Definition: TStyle.h:275
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
Definition: TVirtualPS.h:30
Int_t fSizBuffer
Definition: TVirtualPS.h:39
Int_t fLenBuffer
Definition: TVirtualPS.h:38
virtual void PrintStr(const char *string="")
Output the string str in the output buffer.
Definition: TVirtualPS.cxx:72
virtual void PrintFast(Int_t nch, const char *string="")
Fast version of Print.
Definition: TVirtualPS.cxx:103
std::ofstream * fStream
Definition: TVirtualPS.h:41
char * fBuffer
Definition: TVirtualPS.h:42
virtual void WriteReal(Float_t r, Bool_t space=kTRUE)
Write a Real number to the file.
Definition: TVirtualPS.cxx:185
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
static constexpr double ms
static constexpr double cm
static constexpr double m2
static constexpr double m3
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
T1 Sign(T1 a, T2 b)
Definition: TMathBase.h:165
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
auto * m
Definition: textangle.C:8
auto * a
Definition: textangle.C:12