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 : XFSM |
31 | |
32 | File : View.c |
33 | |
34 | Authors : Jacomme Ludovic |
35 | |
36 | Date : 04.12.96 |
37 | |
38 \------------------------------------------------------------*/
39 /*------------------------------------------------------------\
40 | |
41 | Include Files |
42 | |
43 \------------------------------------------------------------*/
44
45 # include <stdio.h>
46 # include <Xm/Xm.h>
47
48 # include "mut.h"
49 # include "aut.h"
50 # include "abl.h"
51 # include "bdd.h"
52 # include "fsm.h"
53 # include "XSB.h"
54 # include "XFS.h"
55 # include "XTB.h"
56 # include "XMX.h"
57 # include "XMV.h"
58
59 # include "XMX_grid.h"
60 # include "XMV_view.h"
61
62 /*------------------------------------------------------------\
63 | |
64 | Constants |
65 | |
66 \------------------------------------------------------------*/
67 /*------------------------------------------------------------\
68 | |
69 | Types |
70 | |
71 \------------------------------------------------------------*/
72 /*------------------------------------------------------------\
73 | |
74 | Variables |
75 | |
76 \------------------------------------------------------------*/
77
78 xfsmzoom *XfsmHeadZoom = (xfsmzoom *)NULL;
79
80 int XfsmPercentZoom = XFSM_PERCENT_ZOOM;
81 int XfsmPercentMoveX = XFSM_PERCENT_MOVE;
82 int XfsmPercentMoveY = XFSM_PERCENT_MOVE;
83
84 /*------------------------------------------------------------\
85 | |
86 | Menu |
87 | |
88 \------------------------------------------------------------*/
89 /*------------------------------------------------------------\
90 | |
91 | Functions |
92 | |
93 \------------------------------------------------------------*/
94 /*------------------------------------------------------------\
95 | |
96 | XfsmAllocZoom |
97 | |
98 \------------------------------------------------------------*/
99
XfsmAllocZoom()100 xfsmzoom *XfsmAllocZoom ()
101
102 {
103 return ( (xfsmzoom *) autalloc( sizeof ( xfsmzoom ), 1));
104 }
105
106 /*------------------------------------------------------------\
107 | |
108 | XfsmFreeZoom |
109 | |
110 \------------------------------------------------------------*/
111
XfsmFreeZoom(FreeZoom)112 void XfsmFreeZoom ( FreeZoom )
113
114 xfsmzoom *FreeZoom;
115
116 {
117 autfree( (char *)FreeZoom, sizeof(FreeZoom) );
118 }
119
120 /*------------------------------------------------------------\
121 | |
122 | XfsmAddZoom |
123 | |
124 \------------------------------------------------------------*/
125
XfsmAddZoom()126 void XfsmAddZoom ()
127
128 {
129 xfsmzoom *XfsmZoom;
130
131 autbegin();
132
133 XfsmZoom = XfsmAllocZoom ();
134 XfsmZoom->X = XfsmUnitGridX;
135 XfsmZoom->Y = XfsmUnitGridY;
136 XfsmZoom->DX = XfsmUnitGridDx;
137 XfsmZoom->DY = XfsmUnitGridDy;
138 XfsmZoom->NEXT = XfsmHeadZoom;
139 XfsmHeadZoom = XfsmZoom;
140
141 autend();
142 }
143
144 /*------------------------------------------------------------\
145 | |
146 | XfsmDelZoom |
147 | |
148 \------------------------------------------------------------*/
149
XfsmDelZoom()150 char XfsmDelZoom()
151
152 {
153 xfsmzoom *XfsmZoom;
154
155 if ( XfsmHeadZoom != (xfsmzoom *) NULL )
156 {
157 autbegin();
158
159 XfsmZoom = XfsmHeadZoom;
160 XfsmHeadZoom = XfsmHeadZoom->NEXT;
161 XfsmFreeZoom( XfsmZoom );
162
163 autend();
164 return( XFSM_TRUE );
165 }
166
167 return( XFSM_FALSE );
168 }
169
170 /*------------------------------------------------------------\
171 | |
172 | XfsmInitializeZoom |
173 | |
174 \------------------------------------------------------------*/
175
XfsmInitializeZoom()176 void XfsmInitializeZoom()
177
178 {
179 autbegin();
180
181 while( XfsmDelZoom() != XFSM_FALSE );
182
183 if ( XfsmComputeBound() == XFSM_FALSE )
184 {
185 XfsmInitializeUnitGrid();
186 }
187 else
188 {
189 XfsmUnitGridX = ( XfsmBoundXmin / XFSM_UNIT ) - 1;
190 XfsmUnitGridY = ( XfsmBoundYmin / XFSM_UNIT ) - 1;
191 XfsmUnitGridDx = ( XfsmBoundXmax / XFSM_UNIT );
192 XfsmUnitGridDy = ( XfsmBoundYmax / XFSM_UNIT );
193 XfsmUnitGridDx = XfsmUnitGridDx - XfsmUnitGridX + 1;
194 XfsmUnitGridDy = XfsmUnitGridDy - XfsmUnitGridY + 1;
195
196 XfsmComputeUnitGrid();
197 }
198
199 XfsmComputeAndDisplayMap();
200
201 autend();
202 }
203
204 /*------------------------------------------------------------\
205 | |
206 | XfsmZoomUndo |
207 | |
208 \------------------------------------------------------------*/
209
XfsmZoomUndo()210 void XfsmZoomUndo()
211
212 {
213 autbegin();
214
215 if ( XfsmHeadZoom == (xfsmzoom *)NULL )
216 {
217 XfsmErrorMessage( XfsmMainWindow, "No previous zoom !" );
218 }
219 else
220 {
221 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_WATCH_CURSOR );
222
223 XfsmUnitGridX = XfsmHeadZoom->X;
224 XfsmUnitGridY = XfsmHeadZoom->Y;
225 XfsmUnitGridDx = XfsmHeadZoom->DX;
226 XfsmUnitGridDy = XfsmHeadZoom->DY;
227
228 XfsmComputeUnitGrid();
229 XfsmComputeAndDisplayMap();
230
231 XfsmDisplayFigure( 0, 0,
232 XfsmGraphicDx, XfsmGraphicDy );
233
234 XfsmRefreshGraphicWindow( 0, 0,
235 XfsmGraphicDx, XfsmGraphicDy);
236
237 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_NORMAL_CURSOR );
238
239 XfsmDelZoom();
240 }
241
242 autend();
243 }
244
245 /*------------------------------------------------------------\
246 | |
247 | XfsmZoomRight |
248 | |
249 \------------------------------------------------------------*/
250
XfsmZoomRight()251 void XfsmZoomRight()
252
253 {
254 long Delta;
255 long Offset;
256 long XfsmOldPixelGridX;
257
258 autbegin();
259
260 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_WATCH_CURSOR );
261
262 Delta = ( XfsmPercentMoveX * XfsmUnitGridDx ) / 100;
263
264 if ( Delta == 0 ) Delta = 1;
265
266 XfsmUnitGridX = XfsmUnitGridX + Delta;
267 XfsmOldPixelGridX = XfsmPixelGridX;
268 XfsmPixelGridX = (float)(XfsmUnitGridX) * XfsmUnitGridStep;
269 Offset = XfsmPixelGridX - XfsmOldPixelGridX;
270
271 XCopyArea( XfsmGraphicDisplay,
272 XfsmGraphicPixmap,
273 XfsmGraphicPixmap,
274 XfsmBackgroundGC,
275 Offset, 0,
276 XfsmGraphicDx - Offset,
277 XfsmGraphicDy,
278 0, 0
279 );
280
281 XfsmComputeAndDisplayMap();
282 XfsmDisplayFigure( XfsmGraphicDx - Offset, 0,
283 XfsmGraphicDx, XfsmGraphicDy );
284 XfsmRefreshGraphicWindow( 0, 0,
285 XfsmGraphicDx, XfsmGraphicDy);
286
287 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_NORMAL_CURSOR );
288
289 autend();
290 }
291
292 /*------------------------------------------------------------\
293 | |
294 | XfsmZoomLeft |
295 | |
296 \------------------------------------------------------------*/
297
XfsmZoomLeft()298 void XfsmZoomLeft()
299
300 {
301 long Delta;
302 long Offset;
303 long XfsmOldPixelGridX;
304
305 autbegin();
306
307 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_WATCH_CURSOR );
308
309 Delta = ( XfsmPercentMoveX * XfsmUnitGridDx ) / 100;
310
311 if ( Delta == 0 ) Delta = 1;
312
313 XfsmUnitGridX = XfsmUnitGridX - Delta;
314 XfsmOldPixelGridX = XfsmPixelGridX;
315 XfsmPixelGridX = (float)(XfsmUnitGridX) * XfsmUnitGridStep;
316 Offset = XfsmOldPixelGridX - XfsmPixelGridX;
317
318 XCopyArea( XfsmGraphicDisplay,
319 XfsmGraphicPixmap,
320 XfsmGraphicPixmap,
321 XfsmBackgroundGC,
322 0, 0,
323 XfsmGraphicDx - Offset,
324 XfsmGraphicDy,
325 Offset, 0
326 );
327
328 XfsmComputeAndDisplayMap();
329 XfsmDisplayFigure( 0, 0, Offset, XfsmGraphicDy );
330 XfsmRefreshGraphicWindow( 0, 0, XfsmGraphicDx, XfsmGraphicDy);
331
332 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_NORMAL_CURSOR );
333
334 autend();
335 }
336
337 /*------------------------------------------------------------\
338 | |
339 | XfsmZoomDown |
340 | |
341 \------------------------------------------------------------*/
342
XfsmZoomDown()343 void XfsmZoomDown()
344
345 {
346 long Delta;
347 long Offset;
348 long XfsmOldPixelGridY;
349
350 autbegin();
351
352 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_WATCH_CURSOR );
353
354 Delta = ( XfsmPercentMoveY * XfsmUnitGridDy ) / 100;
355
356 if ( Delta == 0 ) Delta = 1;
357
358 XfsmUnitGridY = XfsmUnitGridY - Delta;
359 XfsmOldPixelGridY = XfsmPixelGridY;
360 XfsmPixelGridY = (float)(XfsmUnitGridY) * XfsmUnitGridStep;
361 Offset = XfsmOldPixelGridY - XfsmPixelGridY;
362
363 XCopyArea( XfsmGraphicDisplay,
364 XfsmGraphicPixmap,
365 XfsmGraphicPixmap,
366 XfsmBackgroundGC,
367 0, Offset,
368 XfsmGraphicDx,
369 XfsmGraphicDy - Offset,
370 0, 0
371 );
372
373 XfsmComputeAndDisplayMap();
374 XfsmDisplayFigure( 0, 0, XfsmGraphicDx, Offset );
375 XfsmRefreshGraphicWindow( 0, 0, XfsmGraphicDx, XfsmGraphicDy);
376
377 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_NORMAL_CURSOR );
378
379 autend();
380 }
381
382 /*------------------------------------------------------------\
383 | |
384 | XfsmZoomUp |
385 | |
386 \------------------------------------------------------------*/
387
XfsmZoomUp()388 void XfsmZoomUp()
389
390 {
391 long Delta;
392 long Offset;
393 long XfsmOldPixelGridY;
394
395 autbegin();
396
397 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_WATCH_CURSOR );
398
399 Delta = ( XfsmPercentMoveY * XfsmUnitGridDy ) / 100;
400
401 if ( Delta == 0 ) Delta = 1;
402
403 XfsmUnitGridY = XfsmUnitGridY + Delta;
404 XfsmOldPixelGridY = XfsmPixelGridY;
405 XfsmPixelGridY = (float)(XfsmUnitGridY) * XfsmUnitGridStep;
406 Offset = XfsmPixelGridY - XfsmOldPixelGridY;
407
408 XCopyArea( XfsmGraphicDisplay,
409 XfsmGraphicPixmap,
410 XfsmGraphicPixmap,
411 XfsmBackgroundGC,
412 0, 0,
413 XfsmGraphicDx,
414 XfsmGraphicDy - Offset,
415 0, Offset
416 );
417
418 XfsmComputeAndDisplayMap();
419 XfsmDisplayFigure( 0, XfsmGraphicDy - Offset,
420 XfsmGraphicDx, XfsmGraphicDy );
421 XfsmRefreshGraphicWindow( 0, 0, XfsmGraphicDx, XfsmGraphicDy);
422
423 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_NORMAL_CURSOR );
424
425 autend();
426 }
427
428 /*------------------------------------------------------------\
429 | |
430 | XfsmZoomMore |
431 | |
432 \------------------------------------------------------------*/
433
XfsmZoomMore()434 void XfsmZoomMore()
435
436 {
437 long DeltaX;
438 long DeltaY;
439
440 autbegin();
441
442 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_WATCH_CURSOR );
443
444 DeltaX = ( XfsmPercentZoom * XfsmUnitGridDx ) / 100;
445 DeltaY = ( XfsmPercentZoom * XfsmUnitGridDy ) / 100;
446
447 if ( ( DeltaX >= 2 ) &&
448 ( DeltaY >= 2 ) )
449 {
450 XfsmAddZoom();
451
452 XfsmUnitGridX = XfsmUnitGridX + (DeltaX >> 1);
453 XfsmUnitGridY = XfsmUnitGridY + (DeltaY >> 1);
454 XfsmUnitGridDx = XfsmUnitGridDx - DeltaX;
455 XfsmUnitGridDy = XfsmUnitGridDy - DeltaY;
456
457 XfsmComputeUnitGrid();
458 XfsmComputeAndDisplayMap();
459 XfsmDisplayFigure( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
460 XfsmRefreshGraphicWindow( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
461 }
462
463 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_NORMAL_CURSOR );
464
465 autend();
466 }
467
468 /*------------------------------------------------------------\
469 | |
470 | XfsmZoomLess |
471 | |
472 \------------------------------------------------------------*/
473
XfsmZoomLess()474 void XfsmZoomLess()
475
476 {
477 long DeltaX;
478 long DeltaY;
479
480 autbegin();
481
482 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_WATCH_CURSOR );
483
484 DeltaX = 100 * XfsmUnitGridDx / ( 100 - XfsmPercentZoom );
485 DeltaY = 100 * XfsmUnitGridDy / ( 100 - XfsmPercentZoom );
486
487 XfsmAddZoom();
488
489 XfsmUnitGridX = XfsmUnitGridX - ((DeltaX - XfsmUnitGridDx) >> 1);
490 XfsmUnitGridY = XfsmUnitGridY - ((DeltaY - XfsmUnitGridDy) >> 1);
491 XfsmUnitGridDx = DeltaX;
492 XfsmUnitGridDy = DeltaY;
493
494 XfsmComputeUnitGrid();
495 XfsmComputeAndDisplayMap();
496 XfsmDisplayFigure( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
497 XfsmRefreshGraphicWindow( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
498
499 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_NORMAL_CURSOR );
500
501 autend();
502 }
503
504 /*------------------------------------------------------------\
505 | |
506 | XfsmZoomFit |
507 | |
508 \------------------------------------------------------------*/
509
XfsmZoomFit()510 void XfsmZoomFit()
511
512 {
513 autbegin();
514
515 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_WATCH_CURSOR );
516
517 if ( XfsmComputeBound() == XFSM_FALSE )
518 {
519 XfsmErrorMessage( XfsmMainWindow, "No element to display !" );
520 }
521 else
522 {
523 XfsmAddZoom();
524
525 XfsmUnitGridX = ( XfsmBoundXmin / XFSM_UNIT ) - 1;
526 XfsmUnitGridY = ( XfsmBoundYmin / XFSM_UNIT ) - 1;
527 XfsmUnitGridDx = XfsmBoundXmax / XFSM_UNIT;
528 XfsmUnitGridDy = XfsmBoundYmax / XFSM_UNIT;
529 XfsmUnitGridDx = XfsmUnitGridDx - XfsmUnitGridX + 1;
530 XfsmUnitGridDy = XfsmUnitGridDy - XfsmUnitGridY + 1;
531
532 XfsmComputeUnitGrid();
533 XfsmComputeAndDisplayMap();
534 XfsmDisplayFigure( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
535 XfsmRefreshGraphicWindow( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
536 }
537
538 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_NORMAL_CURSOR );
539
540 autend();
541 }
542
543 /*------------------------------------------------------------\
544 | |
545 | XfsmZoomCenter |
546 | |
547 \------------------------------------------------------------*/
548
XfsmZoomCenter(UnitX,UnitY)549 void XfsmZoomCenter( UnitX, UnitY )
550
551 long UnitX;
552 long UnitY;
553 {
554 autbegin();
555
556 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_WATCH_CURSOR );
557
558 XfsmUnitGridX = UnitX - ( XfsmUnitGridDx >> 1 );
559 XfsmUnitGridY = UnitY - ( XfsmUnitGridDy >> 1 );
560
561 XfsmComputeUnitGrid();
562 XfsmComputeAndDisplayMap();
563 XfsmDisplayFigure( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
564 XfsmRefreshGraphicWindow( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
565
566 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_NORMAL_CURSOR );
567
568 autend();
569 }
570
571 /*------------------------------------------------------------\
572 | |
573 | XfsmZoomIn |
574 | |
575 \------------------------------------------------------------*/
576
XfsmZoomIn(UnitX1,UnitY1,UnitX2,UnitY2)577 void XfsmZoomIn( UnitX1, UnitY1, UnitX2, UnitY2 )
578
579 long UnitX1;
580 long UnitY1;
581 long UnitX2;
582 long UnitY2;
583 {
584 long Swap;
585
586 autbegin();
587
588 if ( ( UnitX1 != UnitX2 ) &&
589 ( UnitY1 != UnitY2 ) )
590 {
591 if ( UnitX1 > UnitX2 )
592 {
593 Swap = UnitX1; UnitX1 = UnitX2; UnitX2 = Swap;
594 }
595
596 if ( UnitY1 > UnitY2 )
597 {
598 Swap = UnitY1; UnitY1 = UnitY2; UnitY2 = Swap;
599 }
600
601 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_WATCH_CURSOR );
602
603 XfsmAddZoom();
604
605 XfsmUnitGridX = UnitX1;
606 XfsmUnitGridY = UnitY1;
607 XfsmUnitGridDx = UnitX2 - UnitX1;
608 XfsmUnitGridDy = UnitY2 - UnitY1;
609
610 XfsmComputeUnitGrid();
611 XfsmComputeAndDisplayMap();
612 XfsmDisplayFigure( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
613 XfsmRefreshGraphicWindow( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
614
615 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_NORMAL_CURSOR );
616 }
617
618 autend();
619 }
620
621 /*------------------------------------------------------------\
622 | |
623 | XfsmZoomPan |
624 | |
625 \------------------------------------------------------------*/
626
XfsmZoomPan(UnitX1,UnitY1,UnitX2,UnitY2)627 void XfsmZoomPan( UnitX1, UnitY1, UnitX2, UnitY2 )
628
629 long UnitX1;
630 long UnitY1;
631 long UnitX2;
632 long UnitY2;
633 {
634 if ( ( UnitX1 != UnitX2 ) ||
635 ( UnitY1 != UnitY2 ) )
636 {
637 autbegin();
638
639 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_WATCH_CURSOR );
640
641 XfsmUnitGridX = XfsmUnitGridX + ( UnitX1 - UnitX2 );
642 XfsmUnitGridY = XfsmUnitGridY + ( UnitY1 - UnitY2 );
643
644 XfsmComputeUnitGrid();
645 XfsmComputeAndDisplayMap();
646 XfsmDisplayFigure( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
647 XfsmRefreshGraphicWindow( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
648
649 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_NORMAL_CURSOR );
650
651 autend();
652 }
653 }
654
655 /*------------------------------------------------------------\
656 | |
657 | XfsmZoomRefresh |
658 | |
659 \------------------------------------------------------------*/
660
XfsmZoomRefresh()661 void XfsmZoomRefresh()
662
663 {
664 autbegin();
665
666 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_WATCH_CURSOR );
667
668 XfsmDisplayFigure( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
669 XfsmRefreshGraphicWindow( 0, 0, XfsmGraphicDx, XfsmGraphicDy );
670
671 XfsmSetMouseCursor( XfsmGraphicWindow, XFSM_NORMAL_CURSOR );
672
673 autend();
674 }
675