Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / yagle / slib / slb_lib.h
1 #ifndef SLIB
2 #define SLIB
3
4 #include MUT_H
5 #include EQT_H
6
7 #define FALSE 0
8 #define TRUE 1
9
10 #define SLIB_PIN_UP 0
11 #define SLIB_PIN_DOWN 1
12 #define SLIB_PIN_LEFT 2
13 #define SLIB_PIN_RIGHT 3
14
15 #define SLIB_T_LINE 2
16 #define SLIB_T_ARC 3
17 #define SLIB_T_CIRCLE 4
18 #define SLIB_T_PIN 5
19
20 #define MOTIF_T_LINE 2
21 #define MOTIF_T_ARC 3
22
23
24 // structure de calcul pour les transformations sur les symbols
25
26 typedef struct vecteur {
27 double ANGLE;
28 double NORME;
29 int SIGX;
30 long X;
31 long Y;
32 } vecteur ;
33
34 // structures propres a MOTIF
35
36 typedef struct motif_arc{
37 long CORNER_X;
38 long CORNER_Y;
39 long R;
40 long ALPHA;
41 long DELTA;
42 } motif_arc ;
43
44 typedef struct motif_line{
45 long START_X;
46 long START_Y;
47 long END_X;
48 long END_Y;
49 } motif_line;
50
51 typedef union {
52 motif_line *MLINE;
53 motif_arc *MARC;
54 void *MOBJ;
55 } motif_obj;
56
57 typedef struct motif_draw {
58 struct motif_draw *NEXT;
59 int TYPE;
60 motif_obj DATA;
61 } motif_draw ;
62
63 typedef struct motif_symlist {
64 struct motif_symlist *NEXT;
65 char *NAME;
66 motif_draw *DRAW;
67 } motif_symlist ;
68
69 typedef struct motif_lib {
70 char *NAME;
71 motif_symlist *SYMB;
72 } motif_lib ;
73
74 // structures propres a SLIB
75
76 typedef struct slib_box {
77 long X_MIN;
78 long X_MAX;
79 long Y_MIN;
80 long Y_MAX;
81 } slib_box;
82
83 typedef struct pin{
84 char *NAME;
85 long X;
86 long Y;
87 int DIRECTION;
88 } pin ;
89
90 typedef struct circle{
91 long X;
92 long Y;
93 long RADIUS;
94 } circle ;
95
96 typedef struct arc{
97 long START_X;
98 long START_Y;
99 long END_X;
100 long END_Y;
101 long CENTER_X;
102 long CENTER_Y;
103 } arc ;
104
105 typedef struct line{
106 long START_X;
107 long START_Y;
108 long END_X;
109 long END_Y;
110 } line;
111
112 typedef union {
113 line *SLINE;
114 arc *SARC;
115 circle *SCIRCLE;
116 pin *SPIN;
117 void *SOBJ;
118 } graph_obj;
119
120 typedef struct draw_list {
121 struct draw_list *NEXT;
122 int TYPE;
123 graph_obj DATA;
124 } draw_list ;
125
126 typedef struct sub_list {
127 struct sub_list *NEXT;
128 struct symbol_list *ROOT;
129 long X;
130 long Y;
131 long ANGLE;
132 } sub_list ;
133
134 typedef struct symbol_list {
135 struct symbol_list *NEXT;
136 char *NAME;
137 sub_list *SUB;
138 draw_list *DRAW;
139 motif_symlist *MOTIF;
140 slib_box *BOX;
141 } symbol_list ;
142
143
144 typedef struct library {
145 char *NAME;
146 symbol_list *SYMB;
147 int GRID;
148 int REFHEIGHT;
149 } library ;
150
151 // fonction assurant le parse du fichier slib
152 library *slib_get_library();
153 //
154 // fonctions 'outils' notaement pour EQT et la 'route_grid' de SLIB
155 void slib_set_function(eqt_ctx *ctx);
156 int slib_sign(float value);
157 void slib_set_lib_grid(library *ptlib, int grid_value);
158 long slib_apply_grid(double value, int grid_value);
159
160 // fonctions d'allocations des differents champs de la structure
161 library *slib_create_lib(char *name);
162 void slib_put_symbol(library *ptlib, symbol_list *ptsym);
163 symbol_list *slib_add_symbol(library *ptlib, char *name);
164 void slib_add_subsymbol(library *ptlib, symbol_list *ptsym, char *name, double center_x, double center_y, double angle);
165 void slib_add_draw_line(symbol_list *ptsym, double arg_0, double arg_1, double arg_2, double arg_3, int grid_value);
166 void slib_add_draw_arc(symbol_list *ptsym, double arg_0, double arg_1, double arg_2, double arg_3, double arg_4, double arg_5, int grid_value);
167 void slib_add_draw_circle(symbol_list *ptsym, double arg_0, double arg_1, float arg_2, int grid_value);
168 void slib_add_draw_pin(symbol_list *ptsym, char *name, double x, double y, int direction, int grid_value);
169
170 // liberation des allocations memoires
171 void slib_free_box(symbol_list *ptsym);
172 void slib_free_motif(motif_symlist *ptm_sym);
173 void slib_free_subsymbols(symbol_list *ptsym);
174 void slib_free_draw(symbol_list *ptsym);
175 void slib_free_symbols(library *ptlib);
176 void slib_free_library(library *ptlib);
177
178 // fonctions permettant de gerer les coordonnees de points apres les subsymbols
179 void slib_vecteur(vecteur *v, double dalpha, double xdebut, double ydebut, double xfinal, double yfinal);
180 void slib_coordonnee(vecteur *v, int grid, double dx, double dy);
181
182 //fonction d'appel d'un symbol et de mise a plat
183 pin *slib_getpin(symbol_list *ptsym, char *name);
184 symbol_list *slib_getsymbol(library *ptlib, char *name);
185 symbol_list *slib_get_flat_symbol(library *ptlib, char *name);
186 void slib_flatsymbol(symbol_list *ptsym, long dx,long dy, long dalpha,symbol_list *ptresult);
187 void slib_flatcalcul(vecteur *name, double dx, double dy, double dalpha, long x, long y);
188 void slib_xbounding_box(slib_box *ptm_box, long value);
189 void slib_ybounding_box(slib_box *ptm_box, long value);
190 void slib_arc_box(symbol_list *ptresult,long x1,long y1,long x2,long y2,long x3,long y3);
191 void slib_line_box(symbol_list *ptresult,long x1,long y1,long x2,long y2);
192 void slib_circle_box(symbol_list *ptresult,long x,long y,long R);
193
194 // fonctions de conversion d'une structure SLIB en une structure MOTIF
195
196 motif_symlist *slib_motifconvert(symbol_list *ptsym);
197 void slib_add_motif_line(motif_draw *ptm_draw, long startx,long starty,long endx,long endy);
198 void slib_add_motif_arc(motif_draw *ptm_draw, long startx,long starty,long endx,long endy,long centerx,long centery);
199 void slib_add_motif_circle(motif_draw *ptm_draw, long cx, long cy, long rayon);
200 //void slib_add_motif_pin();
201
202 // fonctions d'affichages et de test graphique
203 void slib_make_motif_file(library *ptlib);
204 void slib_display_motif(FILE *file, library *ptlib, symbol_list *ptsym);
205 void slib_write_motif(FILE *file,motif_symlist *ptm_sym);
206
207 // fonctions d'affichages et de test thread
208 void slib_view_structslib(library *ptlib);
209 void slib_view_structmotif(library *ptlib);
210 void slib_view_all(library *ptlib);
211 void slib_return_box(symbol_list *pts);
212
213
214 // library cree par le parser
215 library *slib_load_library(char *buff);
216
217 extern library *SLIB_LIBRARY;
218 #endif
219