~ubuntu-branches/ubuntu/intrepid/tcm/intrepid

« back to all changes in this revision

Viewing changes to src/ui/psgrafport.h

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//------------------------------------------------------------------------------
 
2
// 
 
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
 
4
// (c) copyright 1995, Vrije Universiteit Amsterdam.
 
5
// Author: Frank Dehne (frank@cs.vu.nl).
 
6
//
 
7
// TCM is free software; you can redistribute it and/or modify
 
8
// it under the terms of the GNU General Public License as published by
 
9
// the Free Software Foundation; either version 2 of the License, or
 
10
// (at your option) any later version.
 
11
//
 
12
// TCM is distributed in the hope that it will be useful,
 
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
// GNU General Public License for more details.
 
16
//
 
17
// You should have received a copy of the GNU General Public License
 
18
// along with TCM; if not, write to the Free Software
 
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
20
// 02111-1307, USA.
 
21
//-----------------------------------------------------------------------------
 
22
#ifndef _PSGRAFPORT_H 
 
23
#define _PSGRAFPORT_H
 
24
 
 
25
#include "grafport.h"
 
26
#include <stdio.h>
 
27
 
 
28
/// PostScript(tm) grafport class.
 
29
class PSGrafport: public Grafport {
 
30
/*@Doc: {\large {\bf scope:} GUI} */
 
31
public:
 
32
        /// open grafport to filename, When filename = "", stdout is used.
 
33
        PSGrafport(const char *fileName);
 
34
        ///
 
35
        virtual ~PSGrafport();
 
36
 
 
37
        ///
 
38
        bool IsSucces() {return succes;}
 
39
 
 
40
// Sizes, refreshments etc.
 
41
        ///
 
42
        void ClearArea(double, double, double, double) {}
 
43
 
 
44
// Line width.
 
45
        ///
 
46
        void SetLineWidth(unsigned n);
 
47
 
 
48
// Colors.
 
49
        ///
 
50
        void SetBackgroundColor(const string *);
 
51
        ///
 
52
        void SetBackgroundColor(const char *);
 
53
        ///
 
54
        void SetForegroundColor(const string *);
 
55
        ///
 
56
        void SetForegroundColor(const char *);
 
57
 
 
58
// Drawing Rectangles.
 
59
        ///
 
60
        void DrawRectangle(double x, double y, double wd, double ht);
 
61
        ///
 
62
        void FillRectangle(double x, double y, double wd, double ht);
 
63
 
 
64
        ///
 
65
        void DrawUnzoomedRectangle(double x, double y, double wd, double ht);
 
66
 
 
67
// Drawing Strings.
 
68
        ///
 
69
        void DrawStringLeft(double x, double y, const char *str);
 
70
        ///
 
71
        void DrawStringCentered(double x, double y, const char *str);
 
72
        ///
 
73
        void DrawStringRight(double x, double y, const char *str);
 
74
        ///
 
75
        void DrawUnzoomedStringLeft(double x, double y, const char *str);
 
76
        ///
 
77
        void DrawUnzoomedStringCentered(double x, double y, const char *str);
 
78
 
 
79
// Drawing Underlined Strings.
 
80
        ///
 
81
        void DrawStringLeftUnderlined(double x, double y, const char *str);
 
82
        ///
 
83
        void DrawStringRightUnderlined(double x, double y, const char *str);
 
84
        ///
 
85
        void DrawStringCenteredUnderlined(double x, double y, const char *str);
 
86
 
 
87
// Drawing Lines.
 
88
        ///
 
89
//      void DrawLine(double x1, double y1, double x2, double y2);
 
90
        ///
 
91
        void DrawUnzoomedLine(double x1, double y1, double x2, double y2);
 
92
 
 
93
 
 
94
// Drawing Points.
 
95
        ///
 
96
        void DrawPoint(double x, double y);
 
97
 
 
98
// Drawing Ellipses.
 
99
        ///
 
100
        void DrawEllipse(double x, double y, double wd, double ht);
 
101
        ///
 
102
        void FillEllipse(double x, double y, double wd, double ht);
 
103
 
 
104
// Drawing Arcs.
 
105
        ///                                                             
 
106
        /* virtual */ void FillSegment(double x, double y,      
 
107
                double wd, double ht, int arc1, int arc2);      
 
108
 
 
109
// Drawing Polygons.
 
110
        ///
 
111
        void DrawPolygon(const Point *points, int n);
 
112
        ///
 
113
        void FillPolygon(const Point *points, int n);
 
114
        ///                                                             
 
115
        /* virtual */ void FillPolygon(const DPoint *points, int n);    
 
116
 
 
117
// Postscript thingies.
 
118
        /// generate postscript header.
 
119
        void Header(const char *title, const char *creator);
 
120
 
 
121
        ///
 
122
        void BeginDrawProc();
 
123
        ///
 
124
        void EndDrawProc();
 
125
        ///
 
126
        void CallDrawProc();
 
127
 
 
128
        /// concat banner from file with name of document.
 
129
        void Banner(const char *title);
 
130
 
 
131
        ///
 
132
        void BeginPage(int i, int j, int nx, int tot);
 
133
 
 
134
        ///
 
135
        void EndPage();
 
136
 
 
137
        /// generate postscript trailer.
 
138
        void Trailer();
 
139
 
 
140
        /// set grafport font.
 
141
        void SetFont(XFont *font);
 
142
 
 
143
        /// header for encapsulated postscript + bounding box
 
144
        void EPSHeader(const char *title, const char *creator, 
 
145
                double llx, double lly, double urx, double ury);
 
146
 
 
147
        ///
 
148
        void EPSProlog(double y, double dy);
 
149
        ///
 
150
        void SetPageSize(double x, double y) {width = x; height = y;}
 
151
        ///
 
152
        void SetFactor(double f) {factor = f;}
 
153
        ///
 
154
        void SetISOLatin1Encoding(bool b) {isoLatin1Encoding = b;}
 
155
        ///
 
156
        void SetShowColors(bool b) {showColors = b;}
 
157
 
 
158
        /// postscript file containing front page for printer.
 
159
        static const char BANNER[]; 
 
160
 
 
161
        ///
 
162
        static const double XOFF;
 
163
        ///
 
164
        static const double YOFF;
 
165
protected:
 
166
        ///
 
167
        /* virtual */ void DrawSimpleArc(double x, double y,
 
168
                double wd, double ht, int arc1, int arc2);      
 
169
        ///                                                             
 
170
        /* virtual */ void DrawSimplePolygon(const DPoint *points,      
 
171
                int n);                                                 
 
172
        ///                                                             
 
173
        /* virtual */ void DrawSimpleCurve(const DPoint *points);       
 
174
        ///
 
175
        static void MakePSString(string *str);
 
176
        ///
 
177
        static void FixEscapeChar(string *str, char c);
 
178
        ///
 
179
        static void FixNonAscii(string *str);
 
180
        ///
 
181
        void FontProlog();
 
182
        ///
 
183
        void InstallIsoLatin1Font(const char *psFont);
 
184
        ///
 
185
        void PageSetup();
 
186
        ///
 
187
        void DrawPSRectangle(double x, double y, double wd, double ht);
 
188
        ///
 
189
        void DrawPSLine(double x1, double y1, double x2, double y2);
 
190
        ///
 
191
        void DrawPSPolygon(const Point *point, int nrPoints);
 
192
private:
 
193
        /// postscript output file.
 
194
        FILE *fd;
 
195
        ///
 
196
        double width;
 
197
        ///
 
198
        double height;
 
199
        ///
 
200
        double factor;
 
201
        ///
 
202
        bool succes;
 
203
        ///
 
204
        bool isoLatin1Encoding;
 
205
        ///
 
206
        bool showColors;
 
207
 
 
208
        /// default PostScript line width.
 
209
        static const double DEFAULT_LINE_WIDTH;
 
210
 
 
211
        ///
 
212
        List<string> definedFonts;
 
213
 
 
214
        ///
 
215
        void SetPSDashes();
 
216
        ///
 
217
        void UnsetPSDashes();
 
218
};
 
219
#endif