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