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