-
Notifications
You must be signed in to change notification settings - Fork 0
/
PostScript.h
68 lines (50 loc) · 1.98 KB
/
PostScript.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
-------------------------------------------------------------------------
OBJECT NAME: PostScript.h
FULL NAME: Printing/PostScript header include file.
DESCRIPTION: Postscript version of class PlotX
COPYRIGHT: University Corporation for Atmospheric Research, 1997-2005
-------------------------------------------------------------------------
*/
#ifndef POSTSCRIPT_H
#define POSTSCRIPT_H
#include <cstdlib>
#include <cstdio>
#include <string>
#include "Printer.h"
/* -------------------------------------------------------------------- */
/**
* Wrapper class for generating PostScript plots.
*/
class PostScript
{
public:
PostScript( const char *outFile, const char progName[],
const std::string& title, float scale);
~PostScript();
void MoveTo(int x, int y) { fprintf(fp,"%d %d m\n", x, y); }
void LineTo(int x, int y) { fprintf(fp,"%d %d l\n", x, y); }
void rMoveTo(int x, int y) { fprintf(fp,"%d %d rm\n", x, y); }
void rLineTo(int x, int y) { fprintf(fp,"%d %d rl\n", x, y); }
void ShowStr(char str[]) { fprintf(fp,"(%s) s\n", str); }
void ShowStr(const std::string & str) { fprintf(fp,"(%s) s\n", str.c_str()); }
void SetLineWidth(int width) { fprintf(fp,"%d setlinewidth\n", width); }
void Rotate(int degrees) { fprintf(fp,"%d rotate\n", degrees); }
void MoveOrigin(int x, int y){ fprintf(fp,"%d %d translate\n", x, y); }
void Stroke() { fprintf(fp,"stroke\n"); }
void SetColor(float *rgb)
{ fprintf(fp, "stroke %g %g %g setrgbcolor\n", rgb[0],rgb[1],rgb[2]); }
void SetFont(int size);
void DrawBox(int th, int lv, int bh, int rv);
void SetClipping(int vd, int hd);
void ClearClipping();
void SetDash(int idx) { fprintf(fp,"stroke [%d] 0 setdash\n", (idx+1)<<3); }
void ClearDash() { fprintf(fp,"[] 0 setdash\n"); }
// Issue generic command.
void Issue(const char str[]) { fprintf(fp, "%s", str); }
private:
FILE *fp;
bool file;
void PSheader(const char progName[], const std::string& title, float scale);
}; // END POSTSCRIPT.H
#endif