NEURON
epsprint.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 #if HAVE_IV // to end of file
3 
4 #include "epsprint.h"
5 
6 // ps_prolog copied from InterViews's printer.cpp
7 static const char* ps_prolog =
8  "\
9 save 20 dict begin\n\
10 \n\
11 /sf { % scale /fontName => - (set current font)\n\
12  {findfont} stopped {pop /Courier findfont} if\n\
13  exch scalefont setfont\n\
14 } def\n\
15 \n\
16 /ws {\n\
17  4 index 6 4 roll moveto sub\n\
18  2 index stringwidth pop sub\n\
19  exch div 0 8#40 4 3 roll\n\
20  widthshow\n\
21 } def\n\
22 \n\
23 /as {\n\
24  4 index 6 4 roll moveto sub\n\
25  2 index stringwidth pop sub\n\
26  exch div 0 3 2 roll\n\
27  ashow\n\
28 } def\n\
29 \n\
30 ";
31 
32 EPSPrinter::EPSPrinter(std::ostream* o)
33  : Printer(o) {}
34 
36 
37 void EPSPrinter::eps_prolog(std::ostream& out, Coord width, Coord height, const char* creator) {
38  int bbw = int(width);
39  int bbh = int(height);
40  // need to describe it as EPSF = "encapsulated postscript"
41  out << "%!PS-Adobe-2.0 EPSF-1.2\n";
42 
43  out << "%%Creator: " << creator << "\n";
44  out << "%%Pages: atend\n";
45 
46  // adding a bounding box makes this "encapsulated"
47  // bbw and bbh are the width and height of the bounding box 1/72 of an inch
48  out << "%%BoundingBox: 0 0 " << bbw << " " << bbh << "\n";
49 
50  out << "%%EndComments\n";
51  out << ps_prolog;
52  out << "%%EndProlog\n";
53 }
54 
55 #endif
#define Coord
Definition: _defines.h:17
#define Printer
Definition: _defines.h:209
EPSPrinter(std::ostream *)
virtual ~EPSPrinter()
virtual void eps_prolog(std::ostream &, Coord width, Coord height, const char *creator="InterViews")