Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TTeXDump.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 <fstream>
20
21#include "TROOT.h"
22#include "TColor.h"
23#include "TVirtualPad.h"
24#include "TPoints.h"
25#include "TTeXDump.h"
26#include "TStyle.h"
27#include "TMath.h"
28
30
31/** \class TTeXDump
32\ingroup PS
33
34\brief Interface to TeX.
35
36This class allow to generate <b>PGF/TikZ</b> vector graphics output
37which can be included in TeX and LaTeX documents.
38
39PGF is a TeX macro package for generating graphics. It is platform
40and format-independent and works together with the most important TeX
41backend drivers, including pdftex and dvips. It comes with a
42user-friendly syntax layer called TikZ.
43
44To generate a such file it is enough to do:
45~~~ {.cpp}
46 gStyle->SetPaperSize(10.,10.);
47 hpx->Draw();
48 gPad->Print("hpx.tex");
49~~~
50
51Then, the generated file (`hpx.tex`) can be included in a
52LaTeX document (`simple.tex`) in the following way:
53~~~ {.cpp}
54\documentclass{article}
55\usepackage{tikz}
56\usetikzlibrary{patterns}
57\usetikzlibrary{plotmarks}
58\title{A simple LaTeX example}
59\date{July 2013}
60\begin{document}
61\maketitle
62The following image as been generated using the TTeXDump class:
63\par
64\input{hpx.tex}
65\end{document}
66~~~
67
68Note the three directives needed at the top of the LaTeX file:
69~~~ {.cpp}
70\usepackage{tikz}
71\usetikzlibrary{patterns}
72\usetikzlibrary{plotmarks}
73~~~
74
75Then including the picture in the document is done with the
76`\input` directive.
77
78 The command `pdflatex simple.tex` will generate the
79corresponding pdf file `simple.pdf`.
80*/
81
82////////////////////////////////////////////////////////////////////////////////
83/// Default TeX constructor
84
86{
87 fStream = nullptr;
88 fType = 0;
89 gVirtualPS = this;
91 fRange = kFALSE;
92 fXsize = 0.;
93 fYsize = 0.;
94 fCurrentRed = -1.;
95 fCurrentGreen = -1.;
96 fCurrentBlue = -1.;
97 fCurrentAlpha = 1.;
98 fLineScale = 0.;
99}
100
101////////////////////////////////////////////////////////////////////////////////
102/// Initialize the TeX interface
103///
104/// --fname : TeX file name
105/// - wtype : TeX workstation type. Not used in the TeX driver. But as TTeXDump
106/// inherits from TVirtualPS it should be kept. Anyway it is not
107/// necessary to specify this parameter at creation time because it
108/// has a default value (which is ignore in the TeX case).
109
110TTeXDump::TTeXDump(const char *fname, Int_t wtype) : TVirtualPS(fname, wtype)
111{
112 fStream = nullptr;
113 fType = 0;
114 gVirtualPS = this;
116 fRange = kFALSE;
117 fXsize = 0.;
118 fYsize = 0.;
119 fCurrentRed = -1.;
120 fCurrentGreen = -1.;
121 fCurrentBlue = -1.;
122 fCurrentAlpha = 1.;
123 fLineScale = 0.;
124
125 Open(fname, wtype);
126}
127
128////////////////////////////////////////////////////////////////////////////////
129/// Open a TeX file
130
131void TTeXDump::Open(const char *fname, Int_t wtype)
132{
133 if (fStream) {
134 Warning("Open", "TeX file already open");
135 return;
136 }
137
139 fLenBuffer = 0;
140 fType = abs(wtype);
141
143
144 Float_t xrange, yrange;
145 if (gPad) {
146 Double_t ww = gPad->GetWw();
147 Double_t wh = gPad->GetWh();
148 ww *= gPad->GetWNDC();
149 wh *= gPad->GetHNDC();
150 Double_t ratio = wh/ww;
151 xrange = fXsize;
152 yrange = fXsize*ratio;
153 if (yrange > fYsize) { yrange = fYsize; xrange = yrange/ratio;}
154 fXsize = xrange; fYsize = yrange;
155 }
156
157 // Open OS file
158 fStream = new std::ofstream(fname,std::ios::out);
159 if (!fStream || !fStream->good()) {
160 printf("ERROR in TTeXDump::Open: Cannot open file:%s\n",fname);
161 if (!fStream) return;
162 }
163
164 gVirtualPS = this;
165
166 for (Int_t i=0;i<fSizBuffer;i++) fBuffer[i] = ' ';
167
169 fRange = kFALSE;
171
172 // Set a default range
174
175 if (strstr(GetTitle(),"Standalone")) fStandalone = kTRUE;
176 if (fStandalone) {
177 PrintStr("\\documentclass{standalone}@");
178 PrintStr("\\usepackage{tikz}@");
179 PrintStr("\\usetikzlibrary{patterns,plotmarks}@");
180 PrintStr("\\begin{document}@");
181 } else {
182 PrintStr("%\\documentclass{standalone}@");
183 PrintStr("%\\usepackage{tikz}@");
184 PrintStr("%\\usetikzlibrary{patterns,plotmarks}@");
185 PrintStr("%\\begin{document}@");
186 }
187
188 NewPage();
189}
190
191////////////////////////////////////////////////////////////////////////////////
192/// Default TeX destructor
193
195{
196 Close();
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Close a TeX file
201
203{
204 if (!gVirtualPS) return;
205 if (!fStream) return;
206 if (gPad) gPad->Update();
207 PrintStr("@");
208 PrintStr("\\end{tikzpicture}@");
209 if (fStandalone) {
210 PrintStr("\\end{document}@");
211 } else {
212 PrintStr("%\\end{document}@");
213 }
214
215 // Close file stream
216 if (fStream) { fStream->close(); delete fStream; fStream = nullptr;}
217
218 gVirtualPS = nullptr;
219}
220
221////////////////////////////////////////////////////////////////////////////////
222/// Activate an already open TeX file
223
225{
226 // fType is used to know if the TeX file is open. Unlike TPostScript, TTeXDump
227 // has no "workstation type". In fact there is only one TeX type.
228
229 if (!fType) {
230 Error("On", "no TeX file open");
231 Off();
232 return;
233 }
234 gVirtualPS = this;
235}
236
237////////////////////////////////////////////////////////////////////////////////
238/// Deactivate an already open TeX file
239
241{
242 gVirtualPS = nullptr;
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Draw a Box
247
249{
250 Float_t x1c = XtoTeX(x1);
251 Float_t y1c = YtoTeX(y1);
252 Float_t x2c = XtoTeX(x2);
253 Float_t y2c = YtoTeX(y2);
254
255 Int_t fillis = fFillStyle/1000;
256 Int_t fillsi = fFillStyle%1000;
257
258 if (fillis==1) {
260 PrintStr("@");
261 PrintStr("\\draw [color=c, fill=c");
262 if (fCurrentAlpha != 1.) {
263 PrintStr(", fill opacity=");
265 }
266 PrintStr("] (");
267 WriteReal(x1c, kFALSE);
268 PrintFast(1,",");
269 WriteReal(y1c, kFALSE);
270 PrintStr(") rectangle (");
271 WriteReal(x2c, kFALSE);
272 PrintFast(1,",");
273 WriteReal(y2c, kFALSE);
274 PrintStr(");");
275 }
276 if (fillis>1 && fillis<4) {
278 PrintStr("@");
279 PrintStr("\\draw [pattern=");
280 switch (fillsi) {
281 case 1 :
282 PrintStr("crosshatch dots");
283 break;
284 case 2 :
285 case 3 :
286 PrintStr("dots");
287 break;
288 case 4 :
289 PrintStr("north east lines");
290 break;
291 case 5 :
292 PrintStr("north west lines");
293 break;
294 case 6 :
295 PrintStr("vertical lines");
296 break;
297 case 7 :
298 PrintStr("horizontal lines");
299 break;
300 case 10 :
301 PrintStr("bricks");
302 break;
303 case 13 :
304 PrintStr("crosshatch");
305 break;
306 }
307 PrintStr(", draw=none, pattern color=c");
308 if (fCurrentAlpha != 1.) {
309 PrintStr(", fill opacity=");
311 }
312 PrintStr("] (");
313 WriteReal(x1c, kFALSE);
314 PrintFast(1,",");
315 WriteReal(y1c, kFALSE);
316 PrintStr(") rectangle (");
317 WriteReal(x2c, kFALSE);
318 PrintFast(1,",");
319 WriteReal(y2c, kFALSE);
320 PrintStr(");");
321 }
322 if (fillis == 0) {
323 if (fLineWidth<=0) return;
325 PrintStr("@");
326 PrintStr("\\draw [c");
327 PrintStr(",line width=");
329 if (fCurrentAlpha != 1.) {
330 PrintStr(", opacity=");
332 }
333 PrintStr("] (");
334 WriteReal(x1c, kFALSE);
335 PrintFast(1,",");
336 WriteReal(y1c, kFALSE);
337 PrintStr(") -- (");
338 WriteReal(x1c, kFALSE);
339 PrintFast(1,",");
340 WriteReal(y2c, kFALSE);
341 PrintStr(") -- (");
342 WriteReal(x2c, kFALSE);
343 PrintFast(1,",");
344 WriteReal(y2c, kFALSE);
345 PrintStr(") -- (");
346 WriteReal(x2c, kFALSE);
347 PrintFast(1,",");
348 WriteReal(y1c, kFALSE);
349 PrintStr(") -- (");
350 WriteReal(x1c, kFALSE);
351 PrintFast(1,",");
352 WriteReal(y1c, kFALSE);
353 PrintStr(");");
354 }
355}
356
357////////////////////////////////////////////////////////////////////////////////
358/// Draw a Frame around a box
359///
360/// mode = -1 the box looks as it is behind the screen
361/// mode = 1 the box looks as it is in front of the screen
362/// border is the border size in already pre-computed TeX units dark is the
363/// color for the dark part of the frame light is the color for the light
364/// part of the frame
365
368{
369 Warning("DrawFrame", "not yet implemented");
370}
371
372////////////////////////////////////////////////////////////////////////////////
373/// Draw a PolyLine
374///
375/// Draw a polyline through the points xy.
376/// - If NN=1 moves only to point x,y.
377/// - If NN=0 the x,y are written in the TeX file
378/// according to the current transformation.
379/// - If NN>0 the line is clipped as a line.
380/// - If NN<0 the line is clipped as a fill area.
381
383{
384 Warning("DrawPolyLine", "not yet implemented");
385}
386
387////////////////////////////////////////////////////////////////////////////////
388/// Draw a PolyLine in NDC space
389///
390/// Draw a polyline through the points xy.
391/// - If NN=1 moves only to point x,y.
392/// - If NN=0 the x,y are written in the TeX file
393/// according to the current transformation.
394/// - If NN>0 the line is clipped as a line.
395/// - If NN<0 the line is clipped as a fill area.
396
398{
399 Warning("DrawPolyLineNDC", "not yet implemented");
400}
401
402////////////////////////////////////////////////////////////////////////////////
403/// Paint PolyMarker
404
406{
407 Warning("DrawPolyMarker", "not yet implemented");
408}
409
410////////////////////////////////////////////////////////////////////////////////
411/// Paint PolyMarker
412
414{
415 Float_t x, y;
416
418
419 PrintStr("@");
420 PrintStr("\\foreach \\P in {");
421
422 x = XtoTeX(xw[0]);
423 y = YtoTeX(yw[0]);
424
425 PrintStr("(");
427 PrintFast(1,",");
429 PrintStr(")");
430
431 for (Int_t i=1;i<n;i++) {
432 x = XtoTeX(xw[i]);
433 y = YtoTeX(yw[i]);
434 PrintFast(3,", (");
436 PrintFast(1,",");
438 PrintFast(1,")");
439 }
440
441 PrintStr("}{\\draw[mark options={color=c,fill=c");
442
443 if (fCurrentAlpha != 1.) {
444 PrintStr(",opacity=");
446 }
447
449
452 PrintStr(", mark=");
454 case 1 :
455 PrintStr("*");
456 PrintStr(",mark size=1pt");
457 break;
458 case 2 :
459 PrintStr("+");
460 break;
461 case 3 :
462 PrintStr("asterisk");
463 break;
464 case 4 :
465 PrintStr("o");
466 break;
467 case 5 :
468 PrintStr("x");
469 break;
470 case 20 :
471 PrintStr("*");
472 break;
473 case 21 :
474 PrintStr("square*");
475 break;
476 case 22 :
477 PrintStr("triangle*");
478 break;
479 case 23 :
480 PrintStr("triangle*");
481 break;
482 case 24 :
483 PrintStr("o");
484 break;
485 case 25 :
486 PrintStr("square");
487 break;
488 case 26 :
489 PrintStr("triangle");
490 break;
491 case 27 :
492 PrintStr("diamond");
493 break;
494 case 28 :
495 PrintStr("cross");
496 break;
497 case 29 :
498 PrintStr("newstar*");
499 break;
500 case 30 :
501 PrintStr("newstar");
502 break;
503 case 31 :
504 PrintStr("10-pointed star");
505 break;
506 case 32 :
507 PrintStr("triangle");
508 break;
509 case 33 :
510 PrintStr("diamond*");
511 break;
512 case 34 :
513 PrintStr("cross*");
514 break;
515 }
516 PrintStr("] plot coordinates {\\P};}");
517}
518
519////////////////////////////////////////////////////////////////////////////////
520/// This function defines a path with xw and yw and draw it according the
521/// value of nn:
522///
523/// - If nn>0 a line is drawn.
524/// - If nn<0 a closed polygon is drawn.
525
527{
528 Int_t n = TMath::Abs(nn);;
529 Float_t x, y;
530
531 if( n <= 1) {
532 Error("DrawPS", "Two points are needed");
533 return;
534 }
535
536 x = XtoTeX(xw[0]);
537 y = YtoTeX(yw[0]);
538
539 Int_t fillis = fFillStyle/1000;
540 Int_t fillsi = fFillStyle%1000;
541
542 if (nn>0) {
543 if (fLineWidth<=0) return;
545 PrintStr("@");
546 PrintStr("\\draw [c");
548 TString tikzSpec;
549 TString stripped = TString{spec.Strip(TString::kBoth)};
550 if (stripped.Length()) {
551 tikzSpec.Append(",dash pattern=");
552 Ssiz_t i{0}, j{0};
553 bool on{true}, iterate{true};
554
555 while (iterate){
556 j = stripped.Index(" ", 1, i, TString::kExact);
557 if (j == kNPOS){
558 iterate = false;
559 j = stripped.Length();
560 }
561
562 if (on) {
563 tikzSpec.Append("on ");
564 on = false;
565 } else {
566 tikzSpec.Append("off ");
567 on = true;
568 }
569 int num = TString{stripped(i, j - i)}.Atoi();
570 float pt = 0.2*num;
571 tikzSpec.Append(TString::Format("%.2fpt ", pt));
572 i = j + 1;
573 }
574 PrintStr(tikzSpec.Data());
575 }
576 PrintStr(",line width=");
578 if (fCurrentAlpha != 1.) {
579 PrintStr(",opacity=");
581 }
582 } else {
584 if (fillis==1) {
585 PrintStr("@");
586 PrintStr("\\draw [c, fill=c");
587 } else if (fillis==0) {
588 PrintStr("@");
589 PrintStr("\\draw [c");
590 } else {
591 PrintStr("\\draw [pattern=");
592 switch (fillsi) {
593 case 1 :
594 PrintStr("crosshatch dots");
595 break;
596 case 2 :
597 case 3 :
598 PrintStr("dots");
599 break;
600 case 4 :
601 PrintStr("north east lines");
602 break;
603 case 5 :
604 PrintStr("north west lines");
605 break;
606 case 6 :
607 PrintStr("vertical lines");
608 break;
609 case 7 :
610 PrintStr("horizontal lines");
611 break;
612 case 10 :
613 PrintStr("bricks");
614 break;
615 case 13 :
616 PrintStr("crosshatch");
617 break;
618 }
619 PrintStr(", draw=none, pattern color=c");
620 }
621 if (fCurrentAlpha != 1.) {
622 PrintStr(", fill opacity=");
624 }
625 }
626 PrintStr("] (");
628 PrintFast(1,",");
630 PrintStr(") -- ");
631
632 for (Int_t i=1;i<n;i++) {
633 x = XtoTeX(xw[i]);
634 y = YtoTeX(yw[i]);
635 PrintFast(1,"(");
637 PrintFast(1,",");
639 PrintFast(1,")");
640 if (i<n-1) PrintStr(" -- ");
641 else PrintStr(";@");
642 }
643}
644
645////////////////////////////////////////////////////////////////////////////////
646/// Start the TeX page. This function starts the tikzpicture environment
647
649{
650 // Compute pad conversion coefficients
651 if (gPad) {
652 Double_t ww = gPad->GetWw();
653 Double_t wh = gPad->GetWh();
654 fYsize = fXsize*wh/ww;
655 } else {
656 fYsize = 27;
657 }
658
659 if(!fBoundingBox) {
660 PrintStr("\\begin{tikzpicture}@");
661 PrintStr("\\def\\CheckTikzLibraryLoaded#1{ \\ifcsname tikz@library@#1@loaded\\endcsname \\else \\PackageWarning{tikz}{usetikzlibrary{#1} is missing in the preamble.} \\fi }@");
662 PrintStr("\\CheckTikzLibraryLoaded{patterns}@");
663 PrintStr("\\CheckTikzLibraryLoaded{plotmarks}@");
666 }
667}
668
669////////////////////////////////////////////////////////////////////////////////
670/// Set the range for the paper in centimetres
671
673{
674 fXsize = xsize;
675 fYsize = ysize;
676
677 fRange = kTRUE;
678}
679
680////////////////////////////////////////////////////////////////////////////////
681/// Set color index for fill areas
682
684{
686}
687
688////////////////////////////////////////////////////////////////////////////////
689/// Set color index for lines
690
692{
694}
695
696////////////////////////////////////////////////////////////////////////////////
697/// Change the line style
698///
699/// - linestyle = 2 dashed
700/// - linestyle = 3 dotted
701/// - linestyle = 4 dash-dotted
702/// - linestyle = else solid (1 in is used most of the time)
703
705{
706 fLineStyle = linestyle;
707}
708
709////////////////////////////////////////////////////////////////////////////////
710/// Set the lines width.
711
713{
714 fLineWidth = linewidth;
715}
716
717////////////////////////////////////////////////////////////////////////////////
718/// Set size for markers.
719
721{
722 fMarkerSize = msize;
723}
724
725////////////////////////////////////////////////////////////////////////////////
726/// Set color index for markers.
727
729{
731}
732
733////////////////////////////////////////////////////////////////////////////////
734/// Set color with its color index
735
737{
738 if (color < 0) color = 0;
739 TColor *col = gROOT->GetColor(color);
740
741 if (col) {
742 SetColor(col->GetRed(), col->GetGreen(), col->GetBlue());
743 fCurrentAlpha = col->GetAlpha();
744 } else {
745 SetColor(1., 1., 1.);
746 fCurrentAlpha = 1.;
747 }
748}
749
750////////////////////////////////////////////////////////////////////////////////
751/// Set color with its R G B components
752///
753/// - r: % of red in [0,1]
754/// - g: % of green in [0,1]
755/// - b: % of blue in [0,1]
756
758{
759 if (fCurrentRed == r && fCurrentGreen == g && fCurrentBlue == b) return;
760
761 fCurrentRed = r;
763 fCurrentBlue = b;
764 PrintStr("@");
765 PrintStr("\\definecolor{c}{rgb}{");
767 PrintFast(1,",");
769 PrintFast(1,",");
771 PrintFast(2,"};");
772}
773
774////////////////////////////////////////////////////////////////////////////////
775/// Set color index for text
776
778{
780}
781
782////////////////////////////////////////////////////////////////////////////////
783/// Draw text
784///
785/// - xx: x position of the text
786/// - yy: y position of the text
787/// - chars: text to be drawn
788
789void TTeXDump::Text(Double_t x, Double_t y, const char *chars)
790{
791 Double_t wh = (Double_t)gPad->XtoPixel(gPad->GetX2());
792 Double_t hh = (Double_t)gPad->YtoPixel(gPad->GetY1());
793 Float_t tsize, ftsize;
794 if (wh < hh) {
795 tsize = fTextSize*wh;
796 Int_t sizeTTF = (Int_t)(tsize+0.5);
797 ftsize = (sizeTTF*fXsize*gPad->GetAbsWNDC())/wh;
798 } else {
799 tsize = fTextSize*hh;
800 Int_t sizeTTF = (Int_t)(tsize+0.5);
801 ftsize = (sizeTTF*fYsize*gPad->GetAbsHNDC())/hh;
802 }
803 ftsize *= 2.22097;
804 if (ftsize <= 0) return;
805
806 TString t(chars);
807 if (t.Index("\\")>=0 || t.Index("^{")>=0 || t.Index("_{")>=0) {
808 t.Prepend("$");
809 t.Append("$");
810 } else {
811 t.ReplaceAll("<","$<$");
812 t.ReplaceAll(">","$>$");
813 t.ReplaceAll("_","\\_");
814 }
815 t.ReplaceAll("&","\\&");
816 t.ReplaceAll("#","\\#");
817 t.ReplaceAll("%","\\%");
818
819 Int_t txalh = fTextAlign/10;
820 if (txalh <1) txalh = 1; else if (txalh > 3) txalh = 3;
821 Int_t txalv = fTextAlign%10;
822 if (txalv <1) txalv = 1; else if (txalv > 3) txalv = 3;
824 PrintStr("@");
825 PrintStr("\\draw");
826 if (txalh!=2 || txalv!=2) {
827 PrintStr(" [anchor=");
828 if (txalv==1) PrintStr("base");
829 if (txalv==3) PrintStr("north");
830 if (txalh==1) PrintStr(" west");
831 if (txalh==3) PrintStr(" east");
832 PrintFast(1,"]");
833 }
834 PrintFast(2," (");
836 PrintFast(1,",");
838 PrintStr(") node[scale=");
839 WriteReal(ftsize, kFALSE);
840 PrintStr(", color=c");
841 if (fCurrentAlpha != 1.) {
842 PrintStr(",opacity=");
844 }
845 PrintStr(", rotate=");
847 PrintFast(2,"]{");
848 PrintStr(t.Data());
849 PrintFast(2,"};");
850}
851
852////////////////////////////////////////////////////////////////////////////////
853/// Write a string of characters in NDC
854
855void TTeXDump::TextNDC(Double_t u, Double_t v, const char *chars)
856{
857 Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
858 Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
859 Text(x, y, chars);
860}
861
862////////////////////////////////////////////////////////////////////////////////
863/// Convert U from NDC coordinate to TeX
864
866{
867 Double_t cm = fXsize*(gPad->GetAbsXlowNDC() + u*gPad->GetAbsWNDC());
868 return cm;
869}
870
871////////////////////////////////////////////////////////////////////////////////
872/// Convert V from NDC coordinate to TeX
873
875{
876 Double_t cm = fYsize*(gPad->GetAbsYlowNDC() + v*gPad->GetAbsHNDC());
877 return cm;
878}
879
880////////////////////////////////////////////////////////////////////////////////
881/// Convert X from world coordinate to TeX
882
884{
885 Double_t u = (x - gPad->GetX1())/(gPad->GetX2() - gPad->GetX1());
886 return UtoTeX(u);
887}
888
889////////////////////////////////////////////////////////////////////////////////
890/// Convert Y from world coordinate to TeX
891
893{
894 Double_t v = (y - gPad->GetY1())/(gPad->GetY2() - gPad->GetY1());
895 return VtoTeX(v);
896}
897
898////////////////////////////////////////////////////////////////////////////////
899/// Begin the Cell Array painting
900
902 Double_t)
903{
904 Warning("CellArrayBegin", "not yet implemented");
905}
906
907////////////////////////////////////////////////////////////////////////////////
908/// Paint the Cell Array
909
911{
912 Warning("CellArrayFill", "not yet implemented");
913}
914
915////////////////////////////////////////////////////////////////////////////////
916/// End the Cell Array painting
917
919{
920 Warning("CellArrayEnd", "not yet implemented");
921}
922
923////////////////////////////////////////////////////////////////////////////////
924/// Not needed in TeX case
925
927{
928 Warning("DrawPS", "not yet implemented");
929}
930
931////////////////////////////////////////////////////////////////////////////////
932/// add additional pgfplotmarks
933
935{
936 // open cross
937 PrintStr("\\pgfdeclareplotmark{cross} {@");
938 PrintStr("\\pgfpathmoveto{\\pgfpoint{-0.3\\pgfplotmarksize}{\\pgfplotmarksize}}@");
939 PrintStr("\\pgfpathlineto{\\pgfpoint{+0.3\\pgfplotmarksize}{\\pgfplotmarksize}}@");
940 PrintStr("\\pgfpathlineto{\\pgfpoint{+0.3\\pgfplotmarksize}{0.3\\pgfplotmarksize}}@");
941 PrintStr("\\pgfpathlineto{\\pgfpoint{+1\\pgfplotmarksize}{0.3\\pgfplotmarksize}}@");
942 PrintStr("\\pgfpathlineto{\\pgfpoint{+1\\pgfplotmarksize}{-0.3\\pgfplotmarksize}}@");
943 PrintStr("\\pgfpathlineto{\\pgfpoint{+0.3\\pgfplotmarksize}{-0.3\\pgfplotmarksize}}@");
944 PrintStr("\\pgfpathlineto{\\pgfpoint{+0.3\\pgfplotmarksize}{-1.\\pgfplotmarksize}}@");
945 PrintStr("\\pgfpathlineto{\\pgfpoint{-0.3\\pgfplotmarksize}{-1.\\pgfplotmarksize}}@");
946 PrintStr("\\pgfpathlineto{\\pgfpoint{-0.3\\pgfplotmarksize}{-0.3\\pgfplotmarksize}}@");
947 PrintStr("\\pgfpathlineto{\\pgfpoint{-1.\\pgfplotmarksize}{-0.3\\pgfplotmarksize}}@");
948 PrintStr("\\pgfpathlineto{\\pgfpoint{-1.\\pgfplotmarksize}{0.3\\pgfplotmarksize}}@");
949 PrintStr("\\pgfpathlineto{\\pgfpoint{-0.3\\pgfplotmarksize}{0.3\\pgfplotmarksize}}@");
950 PrintStr("\\pgfpathclose@");
951 PrintStr("\\pgfusepathqstroke@");
952 PrintStr("}@");
953
954 // filled cross
955 PrintStr("\\pgfdeclareplotmark{cross*} {@");
956 PrintStr("\\pgfpathmoveto{\\pgfpoint{-0.3\\pgfplotmarksize}{\\pgfplotmarksize}}@");
957 PrintStr("\\pgfpathlineto{\\pgfpoint{+0.3\\pgfplotmarksize}{\\pgfplotmarksize}}@");
958 PrintStr("\\pgfpathlineto{\\pgfpoint{+0.3\\pgfplotmarksize}{0.3\\pgfplotmarksize}}@");
959 PrintStr("\\pgfpathlineto{\\pgfpoint{+1\\pgfplotmarksize}{0.3\\pgfplotmarksize}}@");
960 PrintStr("\\pgfpathlineto{\\pgfpoint{+1\\pgfplotmarksize}{-0.3\\pgfplotmarksize}}@");
961 PrintStr("\\pgfpathlineto{\\pgfpoint{+0.3\\pgfplotmarksize}{-0.3\\pgfplotmarksize}}@");
962 PrintStr("\\pgfpathlineto{\\pgfpoint{+0.3\\pgfplotmarksize}{-1.\\pgfplotmarksize}}@");
963 PrintStr("\\pgfpathlineto{\\pgfpoint{-0.3\\pgfplotmarksize}{-1.\\pgfplotmarksize}}@");
964 PrintStr("\\pgfpathlineto{\\pgfpoint{-0.3\\pgfplotmarksize}{-0.3\\pgfplotmarksize}}@");
965 PrintStr("\\pgfpathlineto{\\pgfpoint{-1.\\pgfplotmarksize}{-0.3\\pgfplotmarksize}}@");
966 PrintStr("\\pgfpathlineto{\\pgfpoint{-1.\\pgfplotmarksize}{0.3\\pgfplotmarksize}}@");
967 PrintStr("\\pgfpathlineto{\\pgfpoint{-0.3\\pgfplotmarksize}{0.3\\pgfplotmarksize}}@");
968 PrintStr("\\pgfpathclose@");
969 PrintStr("\\pgfusepathqfillstroke@");
970 PrintStr("}@");
971
972 // open star
973 PrintStr("\\pgfdeclareplotmark{newstar} {@");
974 PrintStr("\\pgfpathmoveto{\\pgfqpoint{0pt}{\\pgfplotmarksize}}@");
975 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{44}{0.5\\pgfplotmarksize}}@");
976 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{18}{\\pgfplotmarksize}}@");
977 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{-20}{0.5\\pgfplotmarksize}}@");
978 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{-54}{\\pgfplotmarksize}}@");
979 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{-90}{0.5\\pgfplotmarksize}}@");
980 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{234}{\\pgfplotmarksize}}@");
981 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{198}{0.5\\pgfplotmarksize}}@");
982 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{162}{\\pgfplotmarksize}}@");
983 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{134}{0.5\\pgfplotmarksize}}@");
984 PrintStr("\\pgfpathclose@");
985 PrintStr("\\pgfusepathqstroke@");
986 PrintStr("}@");
987
988 // filled star
989 PrintStr("\\pgfdeclareplotmark{newstar*} {@");
990 PrintStr("\\pgfpathmoveto{\\pgfqpoint{0pt}{\\pgfplotmarksize}}@");
991 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{44}{0.5\\pgfplotmarksize}}@");
992 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{18}{\\pgfplotmarksize}}@");
993 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{-20}{0.5\\pgfplotmarksize}}@");
994 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{-54}{\\pgfplotmarksize}}@");
995 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{-90}{0.5\\pgfplotmarksize}}@");
996 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{234}{\\pgfplotmarksize}}@");
997 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{198}{0.5\\pgfplotmarksize}}@");
998 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{162}{\\pgfplotmarksize}}@");
999 PrintStr("\\pgfpathlineto{\\pgfqpointpolar{134}{0.5\\pgfplotmarksize}}@");
1000 PrintStr("\\pgfpathclose@");
1001 PrintStr("\\pgfusepathqfillstroke@");
1002 PrintStr("}@");
1003}
#define b(i)
Definition RSha256.hxx:100
#define g(i)
Definition RSha256.hxx:105
short Style_t
Definition RtypesCore.h:89
int Int_t
Definition RtypesCore.h:45
short Color_t
Definition RtypesCore.h:92
float Size_t
Definition RtypesCore.h:96
short Width_t
Definition RtypesCore.h:91
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:124
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
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 on
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 y2
Option_t Option_t TPoint TPoint const char y1
#define gROOT
Definition TROOT.h:407
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
R__EXTERN TVirtualPS * gVirtualPS
Definition TVirtualPS.h:81
#define gPad
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
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
Size_t fMarkerSize
Marker size.
Definition TAttMarker.h:24
Style_t fMarkerStyle
Marker style.
Definition TAttMarker.h:23
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
Color_t fTextColor
Text color.
Definition TAttText.h:24
Float_t fTextAngle
Text angle.
Definition TAttText.h:21
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:58
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:1823
Float_t GetAlpha() const
Definition TColor.h:64
Float_t GetBlue() const
Definition TColor.h:60
Float_t GetGreen() const
Definition TColor.h:59
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:973
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:987
2-D graphics point (world coordinates).
Definition TPoints.h:19
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:421
Int_t Atoi() const
Return integer value of string.
Definition TString.cxx:1966
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition TString.cxx:1151
const char * Data() const
Definition TString.h:380
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
@ kBoth
Definition TString.h:278
@ kExact
Definition TString.h:279
TString & Prepend(const char *cs)
Definition TString.h:673
TString & Append(const char *cs)
Definition TString.h:576
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:2356
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:651
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
Definition TStyle.cxx:1162
void GetPaperSize(Float_t &xsize, Float_t &ysize) const
Set paper size for PostScript output.
Definition TStyle.cxx:1179
Float_t GetLineScalePS() const
Definition TStyle.h:287
Interface to TeX.
Definition TTeXDump.h:20
void CellArrayFill(Int_t r, Int_t g, Int_t b) override
Paint the Cell Array.
Definition TTeXDump.cxx:910
void SetLineStyle(Style_t linestyle=1) override
Change the line style.
Definition TTeXDump.cxx:704
void SetLineScale(Float_t scale=1)
Definition TTeXDump.h:67
void DrawPS(Int_t n, Float_t *xw, Float_t *yw) override
Not needed in TeX case.
Definition TTeXDump.cxx:926
void Close(Option_t *opt="") override
Close a TeX file.
Definition TTeXDump.cxx:202
void DrawPolyLineNDC(Int_t n, TPoints *uv)
Draw a PolyLine in NDC space.
Definition TTeXDump.cxx:397
void On()
Activate an already open TeX file.
Definition TTeXDump.cxx:224
void Open(const char *filename, Int_t type=-111) override
Open a TeX file.
Definition TTeXDump.cxx:131
Bool_t fStandalone
True when a TeX file should be standalone.
Definition TTeXDump.h:28
void DefineMarkers()
add additional pgfplotmarks
Definition TTeXDump.cxx:934
Bool_t fBoundingBox
True when the TeX header is printed.
Definition TTeXDump.h:26
Float_t fCurrentRed
Current Red component.
Definition TTeXDump.h:29
Float_t fXsize
Page size along X.
Definition TTeXDump.h:23
void SetLineWidth(Width_t linewidth=1) override
Set the lines width.
Definition TTeXDump.cxx:712
Float_t VtoTeX(Double_t v)
Convert V from NDC coordinate to TeX.
Definition TTeXDump.cxx:874
void NewPage() override
Start the TeX page. This function starts the tikzpicture environment.
Definition TTeXDump.cxx:648
Bool_t fRange
True when a range has been defined.
Definition TTeXDump.h:27
void SetFillColor(Color_t cindex=1) override
Set color index for fill areas.
Definition TTeXDump.cxx:683
~TTeXDump() override
Default TeX destructor.
Definition TTeXDump.cxx:194
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 TTeXDump.cxx:366
void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y) override
Paint PolyMarker.
Definition TTeXDump.cxx:405
void Range(Float_t xrange, Float_t yrange)
Set the range for the paper in centimetres.
Definition TTeXDump.cxx:672
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Draw a Box.
Definition TTeXDump.cxx:248
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 TTeXDump.cxx:901
void SetTextColor(Color_t cindex=1) override
Set color index for text.
Definition TTeXDump.cxx:777
void SetLineColor(Color_t cindex=1) override
Set color index for lines.
Definition TTeXDump.cxx:691
Float_t fCurrentAlpha
Current Alpha value.
Definition TTeXDump.h:32
void CellArrayEnd() override
End the Cell Array painting.
Definition TTeXDump.cxx:918
Float_t fLineScale
Line width scale factor.
Definition TTeXDump.h:33
void TextNDC(Double_t u, Double_t v, const char *string)
Write a string of characters in NDC.
Definition TTeXDump.cxx:855
Int_t fType
Workstation type used to know if the Tex is open.
Definition TTeXDump.h:25
Float_t UtoTeX(Double_t u)
Convert U from NDC coordinate to TeX.
Definition TTeXDump.cxx:865
Float_t YtoTeX(Double_t y)
Convert Y from world coordinate to TeX.
Definition TTeXDump.cxx:892
void DrawPolyLine(Int_t n, TPoints *xy)
Draw a PolyLine.
Definition TTeXDump.cxx:382
void Off()
Deactivate an already open TeX file.
Definition TTeXDump.cxx:240
TTeXDump()
Default TeX constructor.
Definition TTeXDump.cxx:85
Float_t fCurrentGreen
Current Green component.
Definition TTeXDump.h:30
Float_t fYsize
Page size along Y.
Definition TTeXDump.h:24
void Text(Double_t x, Double_t y, const char *string) override
Draw text.
Definition TTeXDump.cxx:789
void SetMarkerSize(Size_t msize=1) override
Set size for markers.
Definition TTeXDump.cxx:720
void SetColor(Int_t color=1)
Set color with its color index.
Definition TTeXDump.cxx:736
Float_t fCurrentBlue
Current Blue component.
Definition TTeXDump.h:31
Float_t XtoTeX(Double_t x)
Convert X from world coordinate to TeX.
Definition TTeXDump.cxx:883
void SetMarkerColor(Color_t cindex=1) override
Set color index for markers.
Definition TTeXDump.cxx:728
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.
virtual void PrintFast(Int_t nch, const char *string="")
Fast version of Print.
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.
TPaveText * pt
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
int iterate(rng_state_t *X)
Definition mixmax.icc:34
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
Definition TMath.h:680
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123