1 /*------------------------------------------------------------\
2 | |
3 | This file is part of the Alliance CAD System Copyright |
4 | (C) Laboratoire LIP6 - D�partement ASIM Universite P&M Curie|
5 | |
6 | Home page : http://www-asim.lip6.fr/alliance/ |
7 | E-mail : mailto:alliance-users@asim.lip6.fr |
8 | |
9 | This progam is free software; you can redistribute it |
10 | and/or modify it under the terms of the GNU General Public |
11 | License as published by the Free Software Foundation; |
12 | either version 2 of the License, or (at your option) any |
13 | later version. |
14 | |
15 | Alliance VLSI CAD System is distributed in the hope that |
16 | it will be useful, but WITHOUT ANY WARRANTY; |
17 | without even the implied warranty of MERCHANTABILITY or |
18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
19 | Public License for more details. |
20 | |
21 | You should have received a copy of the GNU General Public |
22 | License along with the GNU C Library; see the file COPYING. |
23 | If not, write to the Free Software Foundation, Inc., |
24 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
25 | |
26 \------------------------------------------------------------*/
27
28 /*------------------------------------------------------------\
29 | |
30 | Tool : GRAAL |
31 | |
32 | File : Undo.c |
33 | |
34 | Author : Jacomme Ludovic |
35 | |
36 | Date : 28.03.95 |
37 | |
38 \------------------------------------------------------------*/
39 /*------------------------------------------------------------\
40 | |
41 | Include Files |
42 | |
43 \------------------------------------------------------------*/
44
45 # include <stdio.h>
46 # include "mut.h"
47 # include "mph.h"
48 # include "rds.h"
49 # include "rpr.h"
50 # include "rfm.h"
51 # include "GRM.h"
52 # include "GSB.h"
53 # include "GRM_window.h"
54 # include "GRM_undo.h"
55
56 /*------------------------------------------------------------\
57 | |
58 | Variables |
59 | |
60 \------------------------------------------------------------*/
61
62 graalundo *GraalHeadUndo = (graalundo *)NULL;
63 graalundo *GraalHeadRedo = (graalundo *)NULL;
64
65 /*------------------------------------------------------------\
66 | |
67 | Functions |
68 | |
69 \------------------------------------------------------------*/
70 /*------------------------------------------------------------\
71 | |
72 | Alloc Functions |
73 | |
74 \------------------------------------------------------------*/
75 /*------------------------------------------------------------\
76 | |
77 | GraalAllocUndo |
78 | |
79 \------------------------------------------------------------*/
80
GraalAllocUndo()81 graalundo *GraalAllocUndo()
82 {
83 return((graalundo *)rdsalloc(sizeof(graalundo), 1));
84 }
85
86 /*------------------------------------------------------------\
87 | |
88 | GraalAllocUndoRec |
89 | |
90 \------------------------------------------------------------*/
91
GraalAllocUndoRec()92 graalundorec *GraalAllocUndoRec()
93 {
94 return((graalundorec *)rdsalloc(sizeof(graalundorec), 1));
95 }
96
97 /*------------------------------------------------------------\
98 | |
99 | Free Functions |
100 | |
101 \------------------------------------------------------------*/
102 /*------------------------------------------------------------\
103 | |
104 | GraalFreeUndo |
105 | |
106 \------------------------------------------------------------*/
107
GraalFreeUndo(FreeUndo)108 void GraalFreeUndo( FreeUndo )
109
110 graalundo *FreeUndo;
111 {
112 rdsfree((char *)FreeUndo, sizeof(graalundo));
113 }
114
115 /*------------------------------------------------------------\
116 | |
117 | GraalFreeUndoRec |
118 | |
119 \------------------------------------------------------------*/
120
GraalFreeUndoRec(FreeUndoRec)121 void GraalFreeUndoRec( FreeUndoRec )
122
123 graalundorec *FreeUndoRec;
124 {
125 rdsfree((char *)FreeUndoRec, sizeof(graalundorec));
126 }
127
128 /*------------------------------------------------------------\
129 | |
130 | GraalAddUndoRec |
131 | |
132 \------------------------------------------------------------*/
133
GraalAddUndoRec(Rectangle)134 void GraalAddUndoRec( Rectangle )
135
136 rdsrec_list *Rectangle;
137 {
138 graalundorec *UndoRec;
139
140 rdsbegin();
141
142 UndoRec = GraalAllocUndoRec();
143 UndoRec->RECTANGLE = Rectangle;
144 UndoRec->NEXT = GraalHeadUndo->UNDO;
145 GraalHeadUndo->UNDO = UndoRec;
146
147 rdsend();
148 }
149
150 /*------------------------------------------------------------\
151 | |
152 | GraalAddUndo |
153 | |
154 \------------------------------------------------------------*/
155
GraalAddUndo()156 void GraalAddUndo()
157
158 {
159 graalundo *NewUndo;
160
161 rdsbegin();
162
163 GraalDelUndo( &GraalHeadRedo );
164
165 NewUndo = GraalAllocUndo();
166 NewUndo->NEXT = GraalHeadUndo;
167 GraalHeadUndo = NewUndo;
168
169 GraalRecomputeBound = GRAAL_TRUE;
170
171 rdsend();
172 }
173
174 /*------------------------------------------------------------\
175 | |
176 | GraalEraseUndo |
177 | |
178 \------------------------------------------------------------*/
179
GraalEraseUndo(HeadUndo)180 void GraalEraseUndo( HeadUndo )
181
182 graalundo **HeadUndo;
183 {
184 graalundo *ScanUndo;
185 graalundo *DelUndo;
186 graalundorec *ScanUndoRec;
187 graalundorec *DelUndoRec;
188
189 rdsbegin();
190
191 ScanUndo = *HeadUndo;
192 *HeadUndo = (graalundo *)NULL;
193
194 while ( ScanUndo != (graalundo *)NULL )
195 {
196 ScanUndoRec = ScanUndo->UNDO;
197
198 while( ScanUndoRec != (graalundorec *)NULL )
199 {
200 DelUndoRec = ScanUndoRec;
201 ScanUndoRec = ScanUndoRec->NEXT;
202
203 GraalFreeUndoRec( DelUndoRec );
204 }
205
206 DelUndo = ScanUndo;
207 ScanUndo = ScanUndo->NEXT;
208
209 GraalFreeUndo( DelUndo );
210 }
211
212 rdsend();
213 }
214
215 /*------------------------------------------------------------\
216 | |
217 | GraalInitializeUndo |
218 | |
219 \------------------------------------------------------------*/
220
GraalInitializeUndo()221 void GraalInitializeUndo()
222
223 {
224 rdsbegin();
225
226 GraalEraseUndo( &GraalHeadUndo );
227 GraalEraseUndo( &GraalHeadRedo );
228
229 rdsend();
230 }
231
232 /*------------------------------------------------------------\
233 | |
234 | GraalDelUndo |
235 | |
236 \------------------------------------------------------------*/
237
GraalDelUndo(HeadUndo)238 void GraalDelUndo( HeadUndo )
239
240 graalundo **HeadUndo;
241 {
242 graalundo *ScanUndo;
243 graalundo *DelUndo;
244 graalundorec *ScanUndoRec;
245 graalundorec *DelUndoRec;
246 rdsrec_list *ScanRec;
247 graalundorec *HeadDelete;
248 graalundorec *Delete;
249
250 rdsbegin();
251
252 HeadDelete = (graalundorec *)NULL;
253 ScanUndo = *HeadUndo;
254 *HeadUndo = (graalundo *)NULL;
255
256 while ( ScanUndo != (graalundo *)NULL )
257 {
258 ScanUndoRec = ScanUndo->UNDO;
259
260 while( ScanUndoRec != (graalundorec *)NULL )
261 {
262 ScanRec = ScanUndoRec->RECTANGLE;
263
264 if ( IsGraalDeleted( ScanRec ) )
265 {
266 GraalUndeleteRectangle( ScanRec );
267
268 Delete = ScanUndoRec;
269 ScanUndoRec = ScanUndoRec->NEXT;
270 Delete->NEXT = HeadDelete;
271 HeadDelete = Delete;
272 }
273 else
274 {
275 DelUndoRec = ScanUndoRec;
276 ScanUndoRec = ScanUndoRec->NEXT;
277
278 GraalFreeUndoRec( DelUndoRec );
279 }
280 }
281
282 DelUndo = ScanUndo;
283 ScanUndo = ScanUndo->NEXT;
284
285 GraalFreeUndo( DelUndo );
286 }
287
288 while( HeadDelete != (graalundorec *)NULL )
289 {
290 Delete = HeadDelete;
291 HeadDelete = HeadDelete->NEXT;
292
293 if ( IsRdsInstance( Delete->RECTANGLE ) )
294 {
295 GraalDelInstance( GRAAL_PREVIOUS( Delete->RECTANGLE ) );
296 }
297 else
298 {
299 GraalDelRectangle( Delete->RECTANGLE );
300 }
301
302 GraalFreeUndoRec( Delete );
303 }
304
305 rdsend();
306 }
307