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

« back to all changes in this revision

Viewing changes to src/ui/figgrafport.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 1999, 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 _FIGGRAFPORT_H 
 
23
#define _FIGGRAFPORT_H
 
24
 
 
25
#include "grafport.h"
 
26
#include <stdio.h>
 
27
 
 
28
/// Fig Grafport Class
 
29
class FigGrafport: public Grafport {
 
30
/*@Doc: {\large {\bf scope:} GUI} */
 
31
public:
 
32
        /// open grafport to filename, When filename = "", stdout is used.
 
33
        FigGrafport(const char *fileName);
 
34
        ///
 
35
        virtual ~FigGrafport();
 
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
        void DrawStringLeftUnderlined(double x, double y, const char *str);
 
80
        ///
 
81
        void DrawStringCenteredUnderlined(double x, double y, const char *str);
 
82
        ///
 
83
        void DrawStringRightUnderlined(double x, double y, const char *str);
 
84
 
 
85
// Drawing Lines.
 
86
        ///
 
87
//      void DrawLine(double x1, double y1, double x2, double y2);
 
88
        ///
 
89
        void DrawUnzoomedLine(double x1, double y1, double x2, double y2);
 
90
 
 
91
 
 
92
// Drawing Points.
 
93
        ///
 
94
        void DrawPoint(double x, double y);
 
95
 
 
96
// Drawing Ellipses.
 
97
        ///
 
98
        void DrawEllipse(double x, double y, double wd, double ht);
 
99
        ///
 
100
        void FillEllipse(double x, double y, double wd, double ht);
 
101
 
 
102
// Drawing Arcs.
 
103
        ///
 
104
        /* virtual */ void FillSegment(double x, double y, double wd, double ht,
 
105
                int arc1, int arc2);
 
106
 
 
107
// Drawing Polygons.
 
108
        /// draw n lines between the first n points in list.
 
109
        void DrawPolygon(const Point *points, int n);
 
110
        ///
 
111
        void FillPolygon(const Point *points, int n);
 
112
        ///
 
113
        /* virtual */ void FillPolygon(const DPoint *points, int n);
 
114
 
 
115
// thingies.
 
116
        /// generate Fig header.
 
117
        void Header(bool landscape=False);
 
118
 
 
119
        /// set grafport font.
 
120
        void SetFont(XFont *font);
 
121
 
 
122
        ///
 
123
        void SetPageSize(double x, double y) {width = x; height = y;}
 
124
        ///
 
125
        void SetFactor(double f) {factor = f;}
 
126
 
 
127
        ///
 
128
        void SetTexFonts(bool b) {texFonts=b;}
 
129
        ///
 
130
        bool IsTexFonts() {return texFonts;}
 
131
 
 
132
protected:
 
133
        ///
 
134
        /* virtual */ void DrawSimpleArc(double x, double y,
 
135
                double wd, double ht, int arc1, int arc2);
 
136
        ///
 
137
        /* virtual */ void DrawSimplePolygon(const DPoint *points,
 
138
                int n);
 
139
        ///
 
140
        /* virtual */ void DrawSimpleCurve(const DPoint *p);
 
141
        ///
 
142
        void FillCurve(const DPoint *p);
 
143
        ///
 
144
        static void MakeFigString(string *str);
 
145
private:
 
146
        /// output file.
 
147
        FILE *fd;
 
148
 
 
149
        /// Factor to convert X coordinates to Fig coordinates.
 
150
        static const double F;
 
151
 
 
152
        /// Load built-in Fig colors.
 
153
        void InitColors();
 
154
 
 
155
        /// Xfig pen color number, set by SetForeground.
 
156
        int penColor;
 
157
        /// Xfig fill color number, set by FillXXXX.
 
158
        int fillColor;
 
159
 
 
160
        ///
 
161
        double width;
 
162
        ///
 
163
        double height;
 
164
        ///
 
165
        double factor;
 
166
        ///
 
167
        bool succes;
 
168
        ///
 
169
        int psFont;
 
170
        ///
 
171
        int texFont;
 
172
 
 
173
        ///
 
174
        bool texFonts;
 
175
 
 
176
        ///
 
177
        void DrawFigPolyLine(List<DPoint *> *points, 
 
178
                        int sub_type, double radius = -1);
 
179
        ///
 
180
        void DrawFigRectangle(double x, double y, double wd, double ht, 
 
181
                        int sub_type, double radius = -1);
 
182
        ///
 
183
        void DrawFigEllipse(double x, double y, double rd_x, double rd_y, int sub_type);
 
184
        ///
 
185
        void DrawFigText(double x, double y, const char *text, int sub_type); 
 
186
 
 
187
        ///
 
188
        void SetFillColor();
 
189
        ///
 
190
        void SetPSFont();
 
191
        ///
 
192
        void SetTexFont();
 
193
        ///
 
194
        void GetFigStringSize(const char *str, double &ht, double &wd);
 
195
};
 
196
#endif