source: Sophya/trunk/Poubelle/PI/psfile.h

Last change on this file was 249, checked in by ansari, 26 years ago

modif rz+cmv 22/4/99

File size: 6.6 KB
RevLine 
[222]1#ifndef PSFILE_H_SEEN
2#define PSFILE_H_SEEN
3
4/*
5 * PSFile.h
6 *
7 * 14/06/96, 19/06/96
8 *
9 * Gestion des fichier .ps et .eps
10 *
11 * - L'unite de mesure est lUnite Courante (UC)
12 * Au depart, 1UC == 1cm
13 * - Les reperes sont orientes a la maniere XWindow
14 *
15 * 17/02/97 : modification des constructeurs(1-->eps,2-->ps)
16 * ajout du type enum orientation
17 *
18 */
19
[249]20#include "machdefs.h"
[222]21#include <stdio.h>
22#include <stdlib.h>
23#ifdef __mac__
24#include <stat.h>
25#endif
26#include "pisysdep.h"
27
28
29#include "pigraphgen.h" // Types enumeres repris de Peida:PIFontSize...
30#include PICMAP_H
31
32#include <list>
33#if defined(__KCC__)
34#include <list.h>
35#endif
36
37enum PIPaperSize { PI_A4 = 1, PI_A3 = 2, PI_A5 = 3, PI_NotDefPaperSize = 0};
38
39enum PIOrientation { PI_Landscape = 0, PI_Portrait = 1, PI_Auto = 2 } ;
40
41
42/*
43 *#define PAGE_WIDTH 21.0 == 595 points
44 *#define PAGE_HEIGHT 29.7 == 842 points
45 *#define PORTRAIT 1
46 *#define LANDSCAPE 0
47 */
48
49
50
51/* Valable pour une page, ou un bloc */
52/*typedef struct {
53 * double X0; Coordonnes sommet NO
54 * double Y0; en unites courantes
55 * double Tx; Format
56 * double Ty; en unites courantes
57 * double Dx; Coord sommet SE
58 * double Dy; en unites courantes
59 * int orientation; LANDSCAPE OU PORTRAIT
60 *} Format;
61 */
62
63/*
64 *typedef struct{
65 * char *Name;
66 * int Tx; En 1/72e de pouce !!
67 * int Ty; unite naturelle de ps
68 *} PIMedia;
69 */
70
71
72
73class PSFile{
74
75public:
76 /* Production fichier eps */
77 PSFile (const char * FileName, double sc = 1.0);
78 /* Production fichier ps */
79 PSFile (const char * FileName, PIOrientation orientation,
80 PIPaperSize paperSize= PI_A4,
81 double marginX = 5.0, double marginY = 5.0 ) ;
82
83 virtual ~PSFile();
84
85 virtual int IsEPS();
86 virtual const char* GetFileName();
87
88
89 /* virtual Format* GetFormat(); */
90 /* Attributs graphiques */
91 virtual PIColors GetDrawColor();
92 virtual PIColors GetFillColor();
93 virtual PIFontAtt GetFontAtt();
94 virtual PIFontSize GetFontSize();
95 virtual PILineAtt GetLineAtt();
96 virtual PIMarker GetMarker();
97
98 virtual void NewPage(double Dx, double Dy, PIOrientation orientation);
99 virtual void EndPage();
100 virtual void NewBloc(double x0, double y0, double Tx, double Ty,
101 double Dx, double Dy);
102 virtual void EndBloc();
103
104 virtual void SelForeground(PIColorMap& cmap, int cid) ;
105 virtual void SelBackground(PIColorMap& cmap, int cid) ;
106
107 /* Trace */
108 virtual void DrawString (double x, double y, const char *s,
109 PIColors DrawColor = PI_NotDefColor,
110 PIFontAtt FontAtt = PI_NotDefFontAtt,
111 int FontSize = 8);
112 virtual void DrawLine (double x1, double y1, double x2, double y2,
113 PIColors DrawColor = PI_NotDefColor,
114 PILineAtt LineAtt = PI_NotDefLineAtt);
115 virtual void DrawBox (double x0, double y0, double Tx, double Ty,
116 PIColors DrawColor = PI_NotDefColor,
117 PILineAtt LineAtt = PI_NotDefLineAtt);
118 virtual void DrawFBox (double x0, double y0, double Tx, double Ty,
119 PIColors DrawColor = PI_NotDefColor,
120 PIColors FillColor = PI_NotDefColor,
121 PILineAtt LineAtt = PI_NotDefLineAtt);
122 virtual void DrawCircle (double x0, double y0, double r,
123 PIColors DrawColor = PI_NotDefColor,
124 PILineAtt LineAtt = PI_NotDefLineAtt);
125 virtual void DrawFCircle (double x0, double y0, double r,
126 PIColors DrawColor = PI_NotDefColor,
127 PIColors FillColor = PI_NotDefColor,
128 PILineAtt LineAtt = PI_NotDefLineAtt);
129 virtual void DrawPolygon (double *x, double *y, int n,
130 PIColors DrawColor = PI_NotDefColor,
131 PILineAtt LineAtt = PI_NotDefLineAtt,
132 bool cinc = true);
133 virtual void DrawFPolygon(double *x, double *y, int n,
134 PIColors DrawColor = PI_NotDefColor,
135 PIColors FillColor = PI_NotDefColor,
136 PILineAtt LineAtt = PI_NotDefLineAtt,
137 bool cinc = true);
138 virtual void DrawMarker (double x0, double y0,
139 PIMarker MrkType = PI_NotDefMarker,
140 PIColors DrawColor = PI_NotDefColor,
141 int MarkerSize=14);
142 virtual void DrawMarkers (double *x0, double *y0, int n,
143 PIMarker MrkType = PI_NotDefMarker,
144 PIColors DrawColor = PI_NotDefColor,
145 int MarkerSize=14);
146
147 virtual void Image(double x0, double y0, double Tx, double Ty,
148 int Nx, int Ny,
149 unsigned char *pict,
150 PIColorMap *mColorMap);
151
152// Declarations en public - sinon certains compilateurs cxx , aCC, xlC ont des problemes
153 /* Blocs */
154 typedef struct {
155 int num;
156 char* label;
157 double X0, Y0; /* coordonnees sommet NO */
158 double Tx, Ty; /* Format */
159 double Dx, Dy; /* Repere utilisateur */
160 long begin,end,tmp; /* offsets dans le fichier */
161 } Bloc ;
162 typedef list<Bloc> BlocList; /* STL */
163
164
165 /* Pages */
166 typedef struct {
167 int num;
168 int BlocCounter;
169 double Dx,Dy; /* Sommet SE (unites utilisateur) */
170 PIOrientation orientation;
171 long begin, end, tmp; /* Offsets dans le fichier */
172 BlocList mBlocList; /* Page == Liste de blocs */
173 } Page ;
174 typedef list<Page> PageList; /* STL */
175
176private:
177
178 /* Fichier ps/eps */
179 FILE * mPSFile;
180 const char * mPSFileName;
181 double Tw,Th ; /* Format, en cm */
182 double WMargin,HMargin ; /* Marges minimales */
183 int isEPS; /* Vrai si PostScript Encapsule */
184 long boundingBox; /* Endroit ou est specifiee la bb */
185 double scale; /* boundingbox = Dx*scale ; Dy*scale */
186 PIPaperSize mPaperSize ;
187 int PageCounter; /* nbr pages */
188 int FileEmpty;
189 Page* currentPage; /* Avant empilage */
190 Bloc* currentBloc; /* Avant empilage */
191 PageList mPageList; /* Fichier == Liste de pages */
192
193
194 /* Attributs graphiques, initialises par constructeur */
195 enum PIColors mDrawColor; /* Couleur de trace courante */
196 enum PIColors mFillColor; /* Couleur de remplissage courante */
197 enum PIFontAtt mFontAtt;
198 enum PIFontSize mFontSize;
199 enum PILineAtt mLineAtt; /* Epaisseur d une ligne */
200 enum PIMarker mMarker; /* Marker courant */
201 int mMarkerSize; /* Taille (en points) du marker courant */
202 bool setFontDone ; /* Pour forcer la selection de Marker apres DrawString() */
203} ;
204
205
206#endif/* PSFILE_H_SEEN */
Note: See TracBrowser for help on using the repository browser.