Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / tas / xtas / xtas_common.c
1 /****************************************************************************/
2 /* */
3 /* Chaine de CAO & VLSI Alliance */
4 /* */
5 /* Produit : XTAS Version 5 */
6 /* Fichier : xtas_common.c */
7 /* */
8 /* (c) copyright 1991-1998 Laboratoire LIP6 equipe ASIM */
9 /* Tous droits reserves */
10 /* Support : e-mail alliance-support@asim.lip6.fr */
11 /* */
12 /* Author(s) : Nizar ABDALLAH Date : 01/04/1993 */
13 /* */
14 /* Modified by : Stephane PICAULT Date : 30/07/1998 */
15 /* Modified by : Date : ../../.... */
16 /* Modified by : Date : ../../.... */
17 /* */
18 /****************************************************************************/
19 /* */
20 /* */
21 /****************************************************************************/
22
23
24 /*--------------------------------------------------------------------------*/
25 /* INCLUDE FILES */
26 /*--------------------------------------------------------------------------*/
27 #include "xtas.h"
28 #include "bitmaps.h"
29
30 /*--------------------------------------------------------------------------*/
31 /* WORK VARIABLES */
32 /*--------------------------------------------------------------------------*/
33
34 static Widget *Xtas_pt_buttons;
35 static struct XalButtonsItem *Xtas_final_menus;
36
37 XalBitmapsStruct Xtas_bitmaps[] = {
38 {"xtas_al2spice",xtas_al2spice_bits,xtas_al2spice_width,xtas_al2spice_height},
39 {"xtas_all_paths",xtas_all_paths_bits,xtas_all_paths_width,xtas_all_paths_height},
40 {"xtas_all_sig",xtas_all_sig_bits,xtas_all_sig_width,xtas_all_sig_height},
41 {"xtas_break",xtas_break_bits,xtas_break_width,xtas_break_height},
42 {"xtas_capa",xtas_capa_bits,xtas_capa_width,xtas_capa_height},
43 {"xtas_close",xtas_close_bits,xtas_close_width,xtas_close_height},
44 {"xtas_command",xtas_command_bits,xtas_command_width,xtas_command_height},
45 {"xtas_connectors",xtas_connectors_bits,xtas_connectors_width,xtas_connectors_height},
46 {"xtas_deb",xtas_deb_bits,xtas_deb_width,xtas_deb_height},
47 {"xtas_detail",xtas_detail_bits,xtas_detail_width,xtas_detail_height},
48 {"xtas_dummy",xtas_dummy_bits,xtas_dummy_width,xtas_dummy_height},
49 {"xtas_fpath",xtas_false_path_bits,xtas_false_path_width,xtas_false_path_height},
50 {"xtas_f_edge",xtas_f_edge_bits,xtas_f_edge_width,xtas_f_edge_height},
51 {"xtas_gate",xtas_gate_bits,xtas_gate_width,xtas_gate_height},
52 {"xtas_h_resistance",xtas_h_resistance_bits,xtas_h_resistance_width,xtas_h_resistance_height},
53 {"xtas_l_resistance",xtas_l_resistance_bits,xtas_l_resistance_width,xtas_l_resistance_height},
54 {"xtas_info",xtas_info_bits,xtas_info_width,xtas_info_height},
55 {"xtas_main_win",xtas_main_win_bits,xtas_main_win_width,xtas_main_win_height},
56 {"xtas_memo",xtas_memo_bits,xtas_memo_width,xtas_memo_height},
57 {"xtas_open",xtas_open_bits,xtas_open_width,xtas_open_height},
58 {"xtas_paths",xtas_paths_bits,xtas_paths_width,xtas_paths_height},
59 {"xtas_prech",xtas_prech_bits,xtas_prech_width,xtas_prech_height},
60 {"xtas_rc",xtas_rc_bits,xtas_rc_width,xtas_rc_height},
61 {"xtas_r_edge",xtas_r_edge_bits,xtas_r_edge_width,xtas_r_edge_height},
62 {"xtas_save",xtas_save_bits,xtas_save_width,xtas_save_height},
63 {"xtas_time",xtas_time_bits,xtas_time_width,xtas_time_height},
64 {"xtas_time",xtas_time_bits,xtas_time_width,xtas_time_height},
65 {"xtas_stb",xtas_stb_bits,xtas_stb_width,xtas_stb_height} ,
66 {"xtas_false",xtas_falsemap_bits,xtas_falsemap_width,xtas_falsemap_height},
67 {"xtas_true",xtas_truemap_bits,xtas_truemap_width,xtas_truemap_height} ,
68 {"xtas_tas",xtas_tas_bits,xtas_tas_width,xtas_tas_height} ,
69 {"xtas_tma",xtas_tma_bits,xtas_tma_width,xtas_tma_height} ,
70 {"xtas_xya",xtas_xya_bits,xtas_xya_width,xtas_xya_height} ,
71 {"xtas_vis",xtas_visual_bits,xtas_visual_width,xtas_visual_height} ,
72 {"xtas_cmd",xtas_cmd_bits,xtas_cmd_width,xtas_cmd_height} ,
73 {"xtas_simu",xtas_simu_bits,xtas_simu_width,xtas_simu_height} ,
74 {"xtas_ctki",xtas_ctk_info_bits,xtas_ctk_info_width,xtas_ctk_info_height} ,
75 {"xtas_noise",xtas_noise_bits,xtas_noise_width,xtas_noise_height} ,
76 {"xtas_scores",xtas_scores_bits,xtas_scores_width,xtas_scores_height}} ;
77
78 /*---------------------------------------------------------------------------*/
79 /* FUNCTIONS */
80 /*---------------------------------------------------------------------------*/
81
82 /*---------------------------------------------------------------------------*/
83 int XtasSizeLong(l)
84 long l ;
85 {
86 char buf[1024] ;
87
88 sprintf(buf,"%ld",l) ;
89 return(strlen(buf)) ;
90 }
91
92 int XtasSizeFloatUnit(l)
93 long l ;
94 {
95 char buf[1024] ;
96
97 sprintf(buf,"%.1f",l/TTV_UNIT) ;
98 return(strlen(buf)) ;
99 }
100
101 /*---------------------------------------------------------------------------*/
102 void XtasPrintType(number,type,buf,maxsize)
103 long number ;
104 char *type ;
105 char *buf ;
106 int maxsize ;
107 {
108 int len ;
109 char *pt ;
110
111 pt = buf ;
112
113 len = XtasSizeLong(number) ;
114 len = maxsize - len - strlen(type) - 3 ;
115
116 while(len--)
117 {
118 *pt = ' ' ;
119 pt++ ;
120 }
121
122 sprintf(pt,"%ld : %s",number,type) ;
123 }
124
125 /*---------------------------------------------------------------------------*/
126
127 void XtasCalcSize(ttvfig,sizetype,sizedelay,sizeotherdelay,sizecumul,sizeothercumul,sizeslope,sizeotherslope,sizename1,sizename2,type,chain,delay,otherdelay,infos,w)
128 ttvfig_list *ttvfig ;
129 int *sizetype ;
130 int *sizedelay ;
131 int *sizeotherdelay ;
132 int *sizecumul ;
133 int *sizeothercumul ;
134 int *sizeslope ;
135 int *sizeotherslope ;
136 int *sizename1 ;
137 int *sizename2 ;
138 char type ;
139 chain_list *chain ;
140 long *delay ;
141 long *otherdelay ;
142 long infos ;
143 long w ;
144 {
145 char buf[1024] ;
146 ttvcritic_list *critic ;
147 ttvpath_list *path ;
148 int auxtype ;
149 int auxdelay ;
150 int auxotherdelay ;
151 int auxslope ;
152 int auxotherslope ;
153 int auxcumul ;
154 int auxothercumul ;
155 int auxname1 ;
156 int auxname2 ;
157 int first ;
158 long i ;
159
160 *sizetype = 4 ;
161
162 if((type == 'd') || (type == 'm') || (type == 'p')) {
163 if (infos == XTAS_SIMU) {
164 *sizedelay = 6 ;
165 *sizeslope = 9 ;
166 *sizecumul = 9 ;
167 auxcumul = 9 ;
168 *sizeotherdelay = 8 ;
169 *sizeotherslope = 11 ;
170 *sizeothercumul = 11 ;
171 auxothercumul = 11 ;
172 }
173 else if (infos == XTAS_CTK) {
174 *sizedelay = 6 ;
175 *sizeslope = 9 ;
176 *sizecumul = 9 ;
177 auxcumul = 9 ;
178 *sizeotherdelay = 6 ;
179 *sizeotherslope = 9 ;
180 *sizeothercumul = 9 ;
181 auxothercumul = 9 ;
182 }
183 else {
184 *sizedelay = 5 ;
185 *sizeslope = 5 ;
186 *sizecumul = 5 ;
187 auxcumul = 5 ;
188 *sizeotherdelay = 0 ;
189 *sizeotherslope = 0 ;
190 *sizeothercumul = 0 ;
191 auxothercumul = 0 ;
192 *otherdelay = 0 ;
193 }
194 }
195 else {
196 *sizedelay = 5 ;
197 *sizeslope = 5 ;
198 *sizecumul = 5 ;
199 auxcumul = 5 ;
200 if (sizeotherdelay)
201 *sizeotherdelay = 0 ;
202 if (sizeotherslope)
203 *sizeotherslope = 0 ;
204 if (sizeothercumul)
205 *sizeothercumul = 0 ;
206 auxothercumul = 0 ;
207 if (otherdelay)
208 *otherdelay = 0 ;
209 }
210 *sizename1 = 5 ;
211 *sizename2 = 5 ;
212
213
214
215 if((type == 'd') || (type == 'm') || (type == 'p') || (type == 'l'))
216 {
217 first = 0 ;
218 *delay = (long)0 ;
219 i = 1 ;
220 while(chain != NULL)
221 {
222 critic = (ttvcritic_list *)chain->DATA ;
223 for(; critic != NULL ; critic = critic->NEXT)
224 {
225 if (infos == XTAS_SIMU) {
226 *delay += critic->REFDELAY ;
227 auxdelay = XtasSizeLong(critic->REFDELAY) ;
228 if(auxdelay > *sizedelay)
229 *sizedelay = auxdelay ;
230 auxslope = XtasSizeLong(critic->REFSLOPE) ;
231 if(auxslope > *sizeslope)
232 *sizeslope = auxslope ;
233 *otherdelay += critic->SIMDELAY ;
234 auxotherdelay = XtasSizeLong(critic->SIMDELAY) ;
235 if(auxotherdelay > *sizeotherdelay)
236 *sizeotherdelay = auxotherdelay ;
237 auxotherslope = XtasSizeLong(critic->SIMSLOPE) ;
238 if(auxotherslope > *sizeotherslope)
239 *sizeotherslope = auxotherslope ;
240 }
241 else if (infos == XTAS_CTK){
242 *delay += critic->REFDELAY ;
243 auxdelay = XtasSizeLong(critic->REFDELAY) ;
244 if(auxdelay > *sizedelay)
245 *sizedelay = auxdelay ;
246 auxslope = XtasSizeLong(critic->REFSLOPE) ;
247 if(auxslope > *sizeslope)
248 *sizeslope = auxslope ;
249 *otherdelay += critic->DELAY ;
250 auxotherdelay = XtasSizeLong(critic->DELAY) ;
251 if(auxotherdelay > *sizeotherdelay)
252 *sizeotherdelay = auxotherdelay ;
253 auxotherslope = XtasSizeLong(critic->SLOPE) ;
254 if(auxotherslope > *sizeotherslope)
255 *sizeotherslope = auxotherslope ;
256 }
257 else {
258 *delay += critic->DELAY ;
259 auxdelay = XtasSizeLong(critic->DELAY) ;
260 if(auxdelay > *sizedelay)
261 *sizedelay = auxdelay ;
262 auxslope = XtasSizeLong(critic->SLOPE) ;
263 if(auxslope > *sizeslope)
264 *sizeslope = auxslope ;
265 }
266 if(critic->NEXT != NULL)
267 {
268 auxname1 = strlen(critic->NAME) ;
269 if(auxname1 > *sizename1)
270 *sizename1 = auxname1 ;
271 }
272 if(first != 0)
273 {
274 auxname2 = strlen(critic->NAME) ;
275 if(auxname2 > *sizename2)
276 *sizename2 = auxname2 ;
277 }
278 first = 1 ;
279 }
280 *sizecumul = XtasSizeLong(*delay) ;
281 if(*sizecumul < auxcumul) *sizecumul = auxcumul ;
282 if (*otherdelay > 0)
283 *sizeothercumul = XtasSizeLong(*otherdelay) ;
284 if(*sizeothercumul < auxothercumul) *sizeothercumul = auxothercumul ;
285 *sizetype = 4 ;
286 if(type == 'l')
287 {
288 i++ ;
289 *sizecumul = 0 ;
290 if(i > w )
291 break ;
292 chain = chain->NEXT ;
293 }
294 else
295 break ;
296 }
297 }
298 else if(type == 'T')
299 {
300 i = 1 ;
301 for(; chain != NULL ; chain = chain->NEXT)
302 {
303 critic = (ttvcritic_list *)chain->DATA ;
304 auxdelay = XtasSizeLong(critic->NEXT->DELAY) ;
305 if(auxdelay > *sizedelay)
306 *sizedelay = auxdelay ;
307 auxslope = XtasSizeLong(critic->NEXT->SLOPE) ;
308 if(auxslope > *sizeslope)
309 *sizeslope = auxslope ;
310 auxname1 = strlen(critic->NAME) ;
311 if(auxname1 > *sizename1)
312 *sizename1 = auxname1 ;
313 auxname2 = strlen(critic->NEXT->NAME) ;
314 if(auxname2 > *sizename2)
315 *sizename2 = auxname2 ;
316 auxtype = XtasSizeLong(i) + 5 ;
317 if(auxtype > *sizetype)
318 *sizetype = auxtype ;
319 i++ ;
320 if(i > w )
321 break ;
322 }
323 *sizecumul = 0 ;
324 }
325 else
326 {
327 i = 1 ;
328 for(; chain != NULL ; chain = chain->NEXT)
329 {
330 path = (ttvpath_list *)chain ;
331
332 auxdelay = XtasSizeLong(path->DELAY) ;
333 if(auxdelay > *sizedelay)
334 *sizedelay = auxdelay ;
335 auxslope = XtasSizeLong(path->SLOPE) ;
336 if(auxslope > *sizeslope)
337 *sizeslope = auxslope ;
338 auxname1 = strlen(ttv_getsigname(ttvfig,buf,path->NODE->ROOT)) ;
339 if(auxname1 > *sizename1)
340 *sizename1 = auxname1 ;
341 auxname2 = strlen(ttv_getsigname(ttvfig,buf,path->ROOT->ROOT)) ;
342 if(auxname2 > *sizename2)
343 *sizename2 = auxname2 ;
344 auxtype = XtasSizeLong(i) + 8 ;
345 if(auxtype > *sizetype)
346 *sizetype = auxtype ;
347 i++ ;
348 if(i > w )
349 break ;
350 }
351 *sizecumul = 0 ;
352 }
353 }
354
355 /*---------------------------------------------------------------------------*/
356
357 void XtasPrintFirstEnd(file,sizetype,sizedelay,sizeotherdelay,sizecumul,sizeothercumul,sizeslope,sizeotherslope,sizename1,sizename2,infos)
358 FILE *file ;
359 int sizetype ;
360 int sizedelay ;
361 int sizeotherdelay ;
362 int sizecumul ;
363 int sizeothercumul ;
364 int sizeslope ;
365 int sizeotherslope ;
366 int sizename1 ;
367 int sizename2 ;
368 long infos ;
369 {
370 char buf[2048] ;
371 char *pt ;
372 int len ;
373
374 pt = buf ;
375
376 if(sizetype > 0)
377 {
378 len = sizetype ;
379 while(len--)
380 {
381 *pt = ' ' ;
382 pt++ ;
383 }
384 *pt = ' ' ;
385 pt++ ;
386 }
387
388 if(sizedelay > 0)
389 {
390 if (infos == XTAS_SIMU) {
391 len = sizedelay - 6 ;
392 while(len--)
393 {
394 *pt = ' ' ;
395 pt++ ;
396 }
397 strcpy(pt,"TAS Tp") ;
398 pt += 6 ;
399 }
400 else if (infos == XTAS_CTK) {
401 len = sizedelay - 6 ;
402 while(len--)
403 {
404 *pt = ' ' ;
405 pt++ ;
406 }
407 strcpy(pt,"Ref Tp") ;
408 pt += 6 ;
409 }
410 else {
411 len = sizedelay - 2 ;
412 while(len--)
413 {
414 *pt = ' ' ;
415 pt++ ;
416 }
417 strcpy(pt,"Tp") ;
418 pt += 2 ;
419 }
420 *pt = ' ' ;
421 pt++ ;
422 }
423
424 if(sizeotherdelay > 0)
425 {
426 if (infos == XTAS_SIMU) {
427 len = sizeotherdelay - 8 ;
428 while(len--)
429 {
430 *pt = ' ' ;
431 pt++ ;
432 }
433 strcpy(pt,"SPICE Tp") ;
434 pt += 8 ;
435 }
436 else {
437 len = sizeotherdelay - 6 ;
438 while(len--)
439 {
440 *pt = ' ' ;
441 pt++ ;
442 }
443 strcpy(pt,"Tp CTK") ;
444 pt += 6 ;
445 }
446 *pt = ' ' ;
447 pt++ ;
448 }
449
450 if(sizecumul > 0)
451 {
452 if (infos == XTAS_SIMU) {
453 len = sizecumul - 9 ;
454 while(len--)
455 {
456 *pt = ' ' ;
457 pt++ ;
458 }
459 strcpy(pt,"TAS Total") ;
460 pt += 9 ;
461 }
462 else if (infos == XTAS_CTK) {
463 len = sizecumul - 9 ;
464 while(len--)
465 {
466 *pt = ' ' ;
467 pt++ ;
468 }
469 strcpy(pt,"Ref Total") ;
470 pt += 9 ;
471 }
472 else {
473 len = sizecumul - 5 ;
474 while(len--)
475 {
476 *pt = ' ' ;
477 pt++ ;
478 }
479 strcpy(pt,"Total") ;
480 pt += 5 ;
481 }
482 *pt = ' ' ;
483 pt++ ;
484 }
485
486 if(sizeothercumul > 0)
487 {
488 if (infos == XTAS_SIMU) {
489 len = sizeothercumul - 11 ;
490 while(len--)
491 {
492 *pt = ' ' ;
493 pt++ ;
494 }
495 strcpy(pt,"SPICE Total") ;
496 pt += 11 ;
497 }
498 else {
499 len = sizeothercumul - 9 ;
500 while(len--)
501 {
502 *pt = ' ' ;
503 pt++ ;
504 }
505 strcpy(pt,"Total CTK") ;
506 pt += 9 ;
507 }
508 *pt = ' ' ;
509 pt++ ;
510 }
511
512 if(sizeslope > 0)
513 {
514 if (infos == XTAS_SIMU) {
515 len = sizeslope - 9 ;
516 while(len--)
517 {
518 *pt = ' ' ;
519 pt++ ;
520 }
521 strcpy(pt,"TAS Slope") ;
522 pt += 9 ;
523 }
524 else if (infos == XTAS_CTK) {
525 len = sizeslope - 9 ;
526 while(len--)
527 {
528 *pt = ' ' ;
529 pt++ ;
530 }
531 strcpy(pt,"Ref Slope") ;
532 pt += 9 ;
533 }
534 else {
535 len = sizeslope - 5 ;
536 while(len--)
537 {
538 *pt = ' ' ;
539 pt++ ;
540 }
541 strcpy(pt,"Slope") ;
542 pt += 5 ;
543 }
544 *pt = ' ' ;
545 pt++ ;
546 }
547
548 if(sizeotherslope > 0)
549 {
550 if (infos == XTAS_SIMU) {
551 len = sizeotherslope - 11 ;
552 while(len--)
553 {
554 *pt = ' ' ;
555 pt++ ;
556 }
557 strcpy(pt,"SPICE Slope") ;
558 pt += 11;
559 }
560 else {
561 len = sizeotherslope - 9 ;
562 while(len--)
563 {
564 *pt = ' ' ;
565 pt++ ;
566 }
567 strcpy(pt,"Slope CTK") ;
568 pt += 9 ;
569 }
570 *pt = ' ' ;
571 pt++ ;
572 }
573
574 if(sizename1 > 0)
575 {
576 len = sizename1 - 4 ;
577 while(len--)
578 {
579 *pt = ' ' ;
580 pt++ ;
581 }
582 strcpy(pt,"From ") ;
583 pt += 8 ;
584 }
585
586 if(sizename2 > 0)
587 {
588 strcpy(pt,"To") ;
589 pt += 2 ;
590 len = sizename2 - 2 ;
591 while(len--)
592 {
593 *pt = ' ' ;
594 pt++ ;
595 }
596 }
597
598 *pt = '\0' ;
599
600 fprintf(file,"%s\n",buf) ;
601 }
602
603 /*---------------------------------------------------------------------------*/
604
605 void XtasPrintLinesepar(file,sizetype,sizedelay,sizeotherdelay,sizecumul,sizeothercumul,sizeslope,sizeotherslope,sizename1,sizename2)
606 FILE *file ;
607 int sizetype ;
608 int sizedelay ;
609 int sizeotherdelay ;
610 int sizecumul ;
611 int sizeothercumul ;
612 int sizeslope ;
613 int sizeotherslope ;
614 int sizename1 ;
615 int sizename2 ;
616 {
617 char buf[2048] ;
618 char *pt ;
619 int len ;
620
621 fprintf(file,"#") ;
622 pt = buf ;
623
624 if(sizetype > 0)
625 {
626 len = sizetype - 1 ;
627 while(len--)
628 {
629 *pt = '-' ;
630 pt++ ;
631 }
632 *pt = ' ' ;
633 pt++ ;
634 }
635
636 if(sizedelay > 0)
637 {
638 len = sizedelay ;
639 while(len--)
640 {
641 *pt = '-' ;
642 pt++ ;
643 }
644 *pt = ' ' ;
645 pt++ ;
646 }
647
648 if(sizeotherdelay > 0)
649 {
650 len = sizeotherdelay ;
651 while(len--)
652 {
653 *pt = '-' ;
654 pt++ ;
655 }
656 *pt = ' ' ;
657 pt++ ;
658 }
659
660 if(sizecumul > 0)
661 {
662 len = sizecumul ;
663 while(len--)
664 {
665 *pt = '-' ;
666 pt++ ;
667 }
668 *pt = ' ' ;
669 pt++ ;
670 }
671
672 if(sizeothercumul > 0)
673 {
674 len = sizeothercumul ;
675 while(len--)
676 {
677 *pt = '-' ;
678 pt++ ;
679 }
680 *pt = ' ' ;
681 pt++ ;
682 }
683
684 if(sizeslope > 0)
685 {
686 len = sizeslope ;
687 while(len--)
688 {
689 *pt = '-' ;
690 pt++ ;
691 }
692 *pt = ' ' ;
693 pt++ ;
694 }
695
696 if(sizeotherslope > 0)
697 {
698 len = sizeotherslope ;
699 while(len--)
700 {
701 *pt = '-' ;
702 pt++ ;
703 }
704 *pt = ' ' ;
705 pt++ ;
706 }
707
708 if(sizename1 > 0)
709 {
710 len = sizename1 ;
711 while(len--)
712 {
713 *pt = '-' ;
714 pt++ ;
715 }
716 *pt = ' ' ;
717 pt++ ;
718 strcpy(pt,"-- ") ;
719 pt+= 3 ;
720 }
721
722 if(sizename2 > 0)
723 {
724 len = sizename2 ;
725 while(len--)
726 {
727 *pt = '-' ;
728 pt++ ;
729 }
730 }
731
732 *pt = '\0' ;
733
734 fprintf(file,"%s\n",buf) ;
735 }
736
737 /*---------------------------------------------------------------------------*/
738
739 void XtasPrintLine(file,typedelay,sizetype,delay,sizedelay,otherdelay,sizeotherdelay,cumul,sizecumul,othercumul,sizeothercumul,
740 slope,sizeslope,otherslope,sizeotherslope,name1,sizename1,slope1,slope2,
741 name2,sizename2)
742 FILE *file ;
743 char *typedelay ;
744 int sizetype ;
745 long delay ;
746 int sizedelay ;
747 long otherdelay ;
748 int sizeotherdelay ;
749 long cumul ;
750 int sizecumul ;
751 long othercumul ;
752 int sizeothercumul ;
753 long slope ;
754 int sizeslope ;
755 long otherslope ;
756 int sizeotherslope ;
757 char *name1 ;
758 int sizename1 ;
759 char slope1 ;
760 char slope2 ;
761 char *name2 ;
762 int sizename2 ;
763 {
764 char buf[2048] ;
765 char *pt ;
766 int len ;
767
768 if(sizetype > 0)
769 {
770 fprintf(file,"%s ",typedelay) ;
771 }
772
773 pt = buf ;
774
775 if(sizedelay > 0)
776 {
777 len = XtasSizeLong(delay) ;
778 len = sizedelay - len ;
779 while(len--)
780 {
781 *pt = ' ' ;
782 pt++ ;
783 }
784 sprintf(pt,"%.1f ",delay/TTV_UNIT) ;
785 pt += (XtasSizeFloatUnit(delay) + 1) ;
786 }
787
788 if(sizeotherdelay > 0)
789 {
790 len = XtasSizeLong(otherdelay) ;
791 len = sizeotherdelay - len ;
792 while(len--)
793 {
794 *pt = ' ' ;
795 pt++ ;
796 }
797 sprintf(pt,"%.1f ",otherdelay/TTV_UNIT) ;
798 pt += (XtasSizeFloatUnit(otherdelay) + 1) ;
799 }
800
801 if(sizecumul > 0)
802 {
803 len = XtasSizeLong(cumul) ;
804 len = sizecumul - len ;
805 while(len--)
806 {
807 *pt = ' ' ;
808 pt++ ;
809 }
810 sprintf(pt,"%.1f ",cumul/TTV_UNIT) ;
811 pt += (XtasSizeFloatUnit(cumul) + 1) ;
812 }
813
814 if(sizeothercumul > 0)
815 {
816 len = XtasSizeLong(othercumul) ;
817 len = sizeothercumul - len ;
818 while(len--)
819 {
820 *pt = ' ' ;
821 pt++ ;
822 }
823 sprintf(pt,"%.1f ",othercumul/TTV_UNIT) ;
824 pt += (XtasSizeFloatUnit(othercumul) + 1) ;
825 }
826
827 if(sizeslope > 0)
828 {
829 len = XtasSizeLong(slope) ;
830 len = sizeslope - len ;
831 while(len--)
832 {
833 *pt = ' ' ;
834 pt++ ;
835 }
836 sprintf(pt,"%.1f ",slope/TTV_UNIT) ;
837 pt += (XtasSizeFloatUnit(slope) + 1) ;
838 }
839
840 if(sizeotherslope > 0)
841 {
842 len = XtasSizeLong(otherslope) ;
843 len = sizeotherslope - len ;
844 while(len--)
845 {
846 *pt = ' ' ;
847 pt++ ;
848 }
849 sprintf(pt,"%.1f ",otherslope/TTV_UNIT) ;
850 pt += (XtasSizeFloatUnit(otherslope) + 1) ;
851 }
852
853 if(sizename1 > 0)
854 {
855 len = strlen(name1) ;
856 len = sizename1 - len ;
857 while(len--)
858 {
859 *pt = ' ' ;
860 pt++ ;
861 }
862 sprintf(pt,"%s %c%c ",name1,slope1,slope2) ;
863 pt = pt + strlen(name1) + 4 ;
864 }
865
866 if(sizename2 > 0)
867 {
868 sprintf(pt,"%s",name2) ;
869 len = strlen(name2) ;
870 pt += len ;
871 len = sizename2 - len ;
872 while(len--)
873 {
874 *pt = ' ' ;
875 pt++ ;
876 }
877 }
878
879 *pt = '\0' ;
880
881 fprintf(file,"%s\n",buf) ;
882 }
883
884 /*---------------------------------------------------------------------------*/
885 /* */
886 /* FUNCTION : XtasGetMask */
887 /* */
888 /* IN ARGS : mask_widget : mask widget */
889 /* */
890 /* OUT ARGS : ( void ) */
891 /* */
892 /* OBJECT : this function is called to build a mask chain from a text */
893 /* widget. */
894 /* */
895 /*---------------------------------------------------------------------------*/
896 chain_list *XtasGetMask( mask_widget )
897 Widget mask_widget;
898 {
899 static chain_list *mask;
900 char *prompt;
901 char *p;
902
903 prompt = XmTextGetString( mask_widget ) ;
904
905 if (strlen( prompt ) == 0)
906 {
907 return( NULL );
908 }
909
910 mask = addchain(NULL,NULL) ;
911
912 if ( (p = strrchr(prompt, ' ')) == NULL)
913 {
914 mask->DATA = namealloc( prompt );
915 }
916 else
917 {
918 *p = '\0';
919 p++;
920 mask->DATA = namealloc( p );
921 while ((p = strrchr(prompt, ' ')) != NULL)
922 {
923 *p = '\0';
924 p++;
925 mask = addchain( mask, (char *)namealloc( p ));
926 }
927 mask = addchain( mask, (char *)namealloc( prompt ));
928 }
929 XtFree( prompt );
930 return( mask );
931 }
932
933
934 /*---------------------------------------------------------------------------*/
935 /* */
936 /* FUNCTION : XtasSuppresStringSpace */
937 /* */
938 /* IN ARGS : s : string */
939 /* */
940 /* OUT ARGS : ( void ) */
941 /* */
942 /* OBJECT : this function is called to supress the blank char in the begin */
943 /* and the end of s. */
944 /* */
945 /*---------------------------------------------------------------------------*/
946 char* XtasSuppresStringSpace( s )
947 char* s;
948 {
949 int i,j;
950
951 while (!strncmp(s," ",1))
952 {
953 strcpy(s,s+1);
954 }
955
956 for ( i=strlen(s); i>=0; i-- )
957 {
958 if (s[i]==' ')
959 {
960 for ( j = i; j<(int)strlen(s); j++ )
961 {
962 s[j]=s[j+1];
963 }
964 }
965 }
966 return s;
967 }
968
969 /*---------------------------------------------------------------------------*/
970 /* */
971 /* FUNCTION : XtasSetLabelString */
972 /* */
973 /* IN ARGS : label_widget : label widget */
974 /* text : text to set */
975 /* */
976 /* OUT ARGS : ( void ) */
977 /* */
978 /* OBJECT : this function is called to set a string in a label widget. */
979 /* */
980 /*---------------------------------------------------------------------------*/
981 void XtasSetLabelString( label_widget , text )
982
983 Widget label_widget;
984 char *text;
985
986 {
987 XmString label;
988 Arg args[1];
989 int n;
990
991 n = 0;
992 label = XmStringCreateSimple( text );
993 XtSetArg( args[n], XmNlabelString, label ); n++;
994 XtSetValues( label_widget, args, n);
995 XmStringFree( label );
996 }
997
998 /*---------------------------------------------------------------------------*/
999 /* */
1000 /* FUNCTION : XtasDestroyAllFig */
1001 /* */
1002 /* IN ARGS : ( none ) */
1003 /* */
1004 /* OUT ARGS : ( void ) */
1005 /* */
1006 /* OBJECT : Remove all figure */
1007 /* */
1008 /*---------------------------------------------------------------------------*/
1009 void XtasDestroyAllFig()
1010 {
1011 ttvfig_list *ttvfig ;
1012
1013 for(ttvfig = TTV_LIST_TTVFIG ; ttvfig != NULL ; ttvfig = ttvfig->NEXT)
1014 if(ttvfig == XtasMainParam->ttvfig)
1015 break ;
1016 if(ttvfig == NULL)
1017 {
1018 XtasRemovePathSession(NULL);
1019 XtasRemoveDetailPathSession(NULL) ;
1020 XtasRemoveStbSession(NULL) ;
1021 XtasSigsRemove();
1022 XtasMainParam->ttvfig = NULL ;
1023 }
1024 }
1025
1026 /*---------------------------------------------------------------------------*/
1027 /* */
1028 /* FUNCTION : XtasMainPopupCallback */
1029 /* */
1030 /* IN ARGS : .widget : The widget on which the event occurs. */
1031 /* .client_data : Widget to popup. */
1032 /* .call_data : Not significant. */
1033 /* */
1034 /* OUT ARGS : ( void ) */
1035 /* */
1036 /* OBJECT : This function is called from other sub-windows in order to */
1037 /* make the main window appears at the top of the screen or */
1038 /* the client_data != NULL */
1039 /*---------------------------------------------------------------------------*/
1040 void XtasMainPopupCallback( widget, client_data, call_data )
1041 Widget widget;
1042 XtPointer client_data;
1043 XtPointer call_data;
1044 {
1045 XtVaSetValues( XtasTopLevel, XmNiconic, False, NULL );
1046 XtPopup( XtasTopLevel, XtGrabNone );
1047 }
1048
1049 /*---------------------------------------------------------------------------*/
1050 /* */
1051 /* FUNCTION : XtasReloadInfCallback */
1052 /* */
1053 /* IN ARGS : .widget : The widget on which the event occurs. */
1054 /* .client_data : Not significant. */
1055 /* .call_data : Not significant. */
1056 /* */
1057 /* OUT ARGS : ( void ) */
1058 /* */
1059 /* OBJECT : Reload the INF file from any Xtas window. */
1060 /*---------------------------------------------------------------------------*/
1061 void XtasReloadInfCallback( widget, client_data, call_data )
1062 Widget widget;
1063 XtPointer client_data;
1064 XtPointer call_data;
1065 {
1066 if (XtasMainParam->ttvfig == NULL) {
1067 XalDrawMessage( XtasErrorWidget, XTAS_NODBERR );
1068 return;
1069 }
1070 else {
1071 XtasPasqua();
1072 if(sigsetjmp( XtasMyEnv , 1 ) == 0)
1073 {
1074
1075 XtasSetLabelString(XtasDeskMessageField, " ");
1076 XalForceUpdate( XtasTopLevel );
1077 XalSetCursor( XtasTopLevel, WAIT );
1078 inf_Dirty(XtasMainParam->ttvfig->INFO->FIGNAME);
1079 infRead(XtasMainParam->ttvfig->INFO->FIGNAME,'E') ;
1080 ttv_getinffile (XtasMainParam->ttvfig);
1081 tas_update_mcctemp (getloadedinffig(XtasMainParam->ttvfig->INFO->FIGNAME)); /*mise a jour de la temperature pour une eventuelle simu */
1082 XtasGetWarningMess() ;
1083 XtasFirePasqua();
1084 XalSetCursor( XtasTopLevel, NORMAL );
1085 XtasSetLabelString(XtasDeskMessageField, "INF file Reloaded");
1086 XalForceUpdate( XtasTopLevel );
1087 }
1088 else {
1089 XtasGetWarningMess() ;
1090 XtasFirePasqua();
1091 XtasSetLabelString(XtasDeskMessageField, "INF file Not Reloaded");
1092 XalForceUpdate( XtasTopLevel );
1093 }
1094 }
1095 }
1096
1097 /*---------------------------------------------------------------------------*/
1098 /* */
1099 /* FUNCTION : XtasAppNotReady */
1100 /* */
1101 /* IN ARGS : ( None ) */
1102 /* */
1103 /* OUT ARGS : 1: Not Ready, 0: Ready. */
1104 /* */
1105 /* OBJECT : Changes the current state of the current session. */
1106 /* */
1107 /*---------------------------------------------------------------------------*/
1108 int XtasAppNotReady()
1109 {
1110 if(XtasMainParam->ttvfig == NULL)
1111 {
1112 XalDrawMessage( XtasErrorWidget, XTAS_NODBERR );
1113 return( 1 );
1114 }
1115 return( 0 );
1116 }
1117
1118 /*---------------------------------------------------------------------------*/
1119 /* */
1120 /* FUNCTION : XtasDestroyWidgetCallback */
1121 /* */
1122 /* IN ARGS : .widget : The widget on which the event occurs. */
1123 /* .client_data : Not significant. */
1124 /* .call_data : Not significant. */
1125 /* */
1126 /* OUT ARGS : ( void ) */
1127 /* */
1128 /* OBJECT : The callback function for all destroy commands. All it does is */
1129 /* to destroy the widget. */
1130 /* */
1131 /*---------------------------------------------------------------------------*/
1132 void XtasDestroyWidgetCallback( widget, root_widget, call_data )
1133
1134 Widget widget;
1135 XtPointer root_widget;
1136 XtPointer call_data;
1137
1138 {
1139 XtDestroyWidget( root_widget );
1140 }
1141
1142 /*---------------------------------------------------------------------------*/
1143 /* */
1144 /* FUNCTION : XtasCancelCallback */
1145 /* */
1146 /* IN ARGS : .widget : The widget on which the event occurs. */
1147 /* .client_data : Not significant. */
1148 /* .call_data : Not significant. */
1149 /* */
1150 /* OUT ARGS : ( void ) */
1151 /* */
1152 /* OBJECT : The callback function for all Cancel commands. All it does is */
1153 /* to unmanage the widget to be canceled. */
1154 /* */
1155 /*---------------------------------------------------------------------------*/
1156 void XtasCancelCallback( widget, root_widget, call_data )
1157
1158 Widget widget;
1159 XtPointer root_widget;
1160 XtPointer call_data;
1161
1162 {
1163 XtUnmanageChild( root_widget );
1164 // XalLeaveLimitedLoop();
1165 }
1166
1167
1168 /*---------------------------------------------------------------------------*/
1169 /* */
1170 /* FUNCTION : XtasDummyCallback */
1171 /* */
1172 /* IN ARGS : .widget : The widget on which the event occurs. */
1173 /* .client_data : Not significant. */
1174 /* .call_data : Not significant. */
1175 /* */
1176 /* OUT ARGS : ( void ) */
1177 /* */
1178 /* OBJECT : This is just a dummy function in order to do nothing. */
1179 /* */
1180 /*---------------------------------------------------------------------------*/
1181 void XtasDummyCallback( widget, client_data, call_data )
1182
1183 Widget widget;
1184 XtPointer client_data;
1185 XtPointer call_data;
1186 {
1187 }
1188
1189 /*---------------------------------------------------------------------------*/
1190 /* */
1191 /* FUNCTION : XtasNotYetCallback */
1192 /* */
1193 /* IN ARGS : .widget : The widget on which the event occurs. */
1194 /* .client_data : Not significant. */
1195 /* .call_data : Not significant. */
1196 /* */
1197 /* OUT ARGS : ( void ) */
1198 /* */
1199 /* OBJECT : This is to display a message for functions under development. */
1200 /* */
1201 /*---------------------------------------------------------------------------*/
1202 void XtasNotYetCallback( widget, client_data, call_data )
1203
1204 Widget widget;
1205 XtPointer client_data ;
1206 XtPointer call_data;
1207
1208 {
1209 XalDrawMessage( XtasNotYetWidget , XTAS_NYETWAR );
1210 }
1211
1212
1213 /*---------------------------------------------------------------------------*/
1214 /* */
1215 /* FUNCTION : XtasAddDummyButton */
1216 /* */
1217 /* IN ARGS : .widget : Parent widget id. */
1218 /* */
1219 /* OUT ARGS : ( none ) */
1220 /* */
1221 /* OBJECT : Adds a dummy Button in order to have at least one. */
1222 /* */
1223 /*---------------------------------------------------------------------------*/
1224 void XtasAddDummyButton( widget )
1225 Widget widget;
1226 {
1227 GC gc;
1228 Pixel fg;
1229 Pixel bg;
1230
1231 XtVaGetValues( widget, XmNforeground, &fg, XmNbackground, &bg, NULL );
1232 gc = XCreateGC(XtDisplay(widget), RootWindowOfScreen(XtScreen(widget)), 0, 0);
1233 XSetForeground(XtDisplay(widget), gc, fg);
1234 XSetBackground(XtDisplay(widget), gc, bg);
1235 XFreeGC(XtDisplay(widget),gc) ;
1236
1237 XtVaCreateManagedWidget( "dbutton",
1238 xmDrawnButtonWidgetClass,
1239 widget,
1240 XmNwidth, 40,
1241 XmNheight, 40,
1242 XmNpushButtonEnabled, False,
1243 XmNsensitive, False,
1244 XmNshadowThickness, 0,
1245 NULL);
1246 }
1247
1248
1249 /*---------------------------------------------------------------------------*/
1250 /* */
1251 /* FUNCTION : XtasButtonsChangedCallback */
1252 /* */
1253 /* IN ARGS : .widget : The widget on which the event occurs. */
1254 /* .new_state : Pointer to the specific "selected" field. */
1255 /* .call_data : The toggle callback structure. */
1256 /* */
1257 /* OUT ARGS : ( void ) */
1258 /* */
1259 /* OBJECT : The callback function for the Options/Buttons command when */
1260 /* a Button is selected or unselected. */
1261 /* */
1262 /*---------------------------------------------------------------------------*/
1263 void XtasButtonsChangedCallback( widget, new_state, cbs )
1264 Widget widget;
1265 XtPointer new_state;
1266 XtPointer cbs;
1267 {
1268 Boolean *res = (Boolean *)new_state ;
1269
1270 XmToggleButtonCallbackStruct *state = (XmToggleButtonCallbackStruct *) cbs ;
1271
1272 *res = state->set;
1273 }
1274
1275
1276 /*---------------------------------------------------------------------------*/
1277 /* */
1278 /* FUNCTION : XtasButtonsOkCallback */
1279 /* */
1280 /* IN ARGS : .widget : The widget on which the event occurs. */
1281 /* .options : User New choices. */
1282 /* .call_data : Not significant. */
1283 /* */
1284 /* OUT ARGS : ( void ) */
1285 /* */
1286 /* OBJECT : The callback function for the Options/Buttons command when */
1287 /* the OK Button is selected. */
1288 /* */
1289 /*---------------------------------------------------------------------------*/
1290 void XtasButtonsOkCallback( widget, client_data, call_data )
1291
1292 Widget widget;
1293 XtPointer client_data;
1294 XtPointer call_data;
1295
1296 {
1297 int n, i;
1298 Arg args[10];
1299 Widget parent;
1300 struct XalButtonsItem *options = (struct XalButtonsItem *)client_data ;
1301
1302 for ( i=0;
1303 Xtas_final_menus[i].pix_file != -1 ;
1304 i++ )
1305 {
1306 Xtas_final_menus[i].selected = options[i].selected;
1307 }
1308
1309 parent = XtParent( *Xtas_pt_buttons );
1310 XtDestroyWidget( *Xtas_pt_buttons );
1311
1312 n = 0;
1313 XtSetArg( args[n], XmNnumColumns, 1 ); n++;
1314 XtSetArg( args[n], XmNorientation, XmHORIZONTAL ); n++;
1315 *Xtas_pt_buttons = XalButtonMenus( parent,
1316 Xtas_final_menus,
1317 args, n,
1318 40, 40 );
1319 XtasAddDummyButton( *Xtas_pt_buttons );
1320 XtManageChild( *Xtas_pt_buttons );
1321 XmAddTabGroup( *Xtas_pt_buttons );
1322
1323 // XalLeaveLimitedLoop();
1324 }
1325
1326 /*---------------------------------------------------------------------------*/
1327 /* */
1328 /* FUNCTION : XtasOptionsButtonsTreat */
1329 /* */
1330 /* IN ARGS : .parent : The parent widget. */
1331 /* .pt_buttons_widget : Pointer to the Button's Bar. */
1332 /* .button_menus : The Menu's table. */
1333 /* .button_options : The Button's name list. */
1334 /* */
1335 /* OUT ARGS : ( void ) */
1336 /* */
1337 /* OBJECT : A function to customize the button's bar menu. */
1338 /* */
1339 /*---------------------------------------------------------------------------*/
1340 void XtasOptionsButtonsTreat( parent, pt_buttons_widget, button_menus, button_options )
1341
1342 Widget parent;
1343 Widget *pt_buttons_widget;
1344 struct XalButtonsItem button_menus[];
1345 struct XalButtonsItem button_options[];
1346 {
1347 int n;
1348 int i;
1349 int height;
1350 Arg args[10];
1351 XmString text;
1352 Widget prompt;
1353 Widget scroll;
1354 Widget form;
1355 Widget main_row;
1356 Widget sub_row;
1357 Widget buttons;
1358 Widget toggle;
1359 Atom WM_DELETE_WINDOW;
1360
1361
1362 Xtas_pt_buttons = pt_buttons_widget;
1363 Xtas_final_menus = button_menus;
1364
1365 /*= PromptDialog prompt =*/
1366 n = 0;
1367 XtSetArg( args[n], XmNtitle, XTAS_NAME": Button's Configuration" ); n++;
1368 XtSetArg( args[n], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); n++;
1369 prompt = XmCreatePromptDialog( parent,
1370 "XtasInfosBox",
1371 args, n );
1372 XtUnmanageChild(XmSelectionBoxGetChild( prompt, XmDIALOG_TEXT));
1373 XtUnmanageChild(XmSelectionBoxGetChild( prompt, XmDIALOG_PROMPT_LABEL));
1374 XtAddCallback( prompt,
1375 XmNokCallback,
1376 XtasButtonsOkCallback,
1377 (XtPointer)button_options );
1378 XtAddCallback( prompt,
1379 XmNcancelCallback,
1380 XtasCancelCallback,
1381 (XtPointer)prompt );
1382
1383 WM_DELETE_WINDOW = XmInternAtom(XtDisplay(parent), "WM_DELETE_WINDOW", False);
1384 XmAddWMProtocolCallback(XtParent(prompt), WM_DELETE_WINDOW, XtasCancelCallback, (XtPointer )prompt);
1385
1386 /*= Form form =*/
1387 n = 0;
1388 form = XmCreateForm( prompt,
1389 "XtasButtonsForm",
1390 args, n);
1391 XtManageChild( form );
1392
1393 /*= ScrolledWindow scroll =*/
1394 for ( i=0, height=0;
1395 button_options[i].pix_file != -1 ;
1396 i++, height +=45 );
1397 {
1398 height += 10;
1399 }
1400 n = 0;
1401 XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ); n++;
1402 XtSetArg( args[n], XmNbottomAttachment, XmATTACH_FORM ); n++;
1403 XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ); n++;
1404 XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ); n++;
1405 XtSetArg( args[n], XmNscrollingPolicy, XmAUTOMATIC ); n++;
1406 XtSetArg( args[n], XmNheight, height ); n++;
1407 XtSetArg( args[n], XmNwidth, 250 ); n++;
1408 scroll = XmCreateScrolledWindow( form,
1409 "XtasButtonsScroll",
1410 args, n );
1411 XtManageChild( scroll );
1412
1413 /*= Widget Row : main_row =*/
1414 n = 0;
1415 XtSetArg( args[n], XmNorientation, XmHORIZONTAL ); n++;
1416 main_row = XtCreateManagedWidget( "XtasButtonsRow",
1417 xmRowColumnWidgetClass,
1418 scroll,
1419 args, n );
1420 /*= Widget Column : buttons =*/
1421 for ( i=0;
1422 button_options[i].pix_file != -1 ;
1423 i++ )
1424 {
1425 button_options[i].selected = True;
1426 }
1427
1428 n = 0;
1429 XtSetArg( args[n], XmNorientation, XmVERTICAL ); n++;
1430 buttons = XalButtonMenus( main_row, button_options, args, n, 40, 40 );
1431 XtManageChild( buttons );
1432
1433 /*= Widget Column : sub_row =*/
1434 n = 0;
1435 XtSetArg( args[n], XmNorientation, XmVERTICAL ); n++;
1436 XtSetArg( args[n], XmNspacing, 21 ); n++;
1437 sub_row = XtCreateManagedWidget( "XtasButtonsRow",
1438 xmRowColumnWidgetClass,
1439 main_row,
1440 args, n );
1441 /*= Widget ToggleButton : toggle =*/
1442 for ( i=0; button_menus[i].pix_file != -1 ; i++ )
1443 {
1444 n = 0;
1445 text = XmStringCreateSimple( button_options[i].callback_data );
1446 XtSetArg( args[n], XmNlabelString, text); n++;
1447 XtSetArg( args[n], XmNindicatorType, XmN_OF_MANY); n++;
1448 XtSetArg( args[n], XmNset, False); n++;
1449 toggle = XtCreateManagedWidget( "XtasButtonsToggles",
1450 xmToggleButtonWidgetClass,
1451 sub_row,
1452 args, n );
1453 XmStringFree( text );
1454
1455 if ( button_menus[i].selected == True )
1456 {
1457 n = 0;
1458 XtSetArg( args[n], XmNset, True ); n++;
1459 XtSetValues( toggle, args, n );
1460 }
1461 else
1462 {
1463 button_options[i].selected = False;
1464 }
1465
1466 XtAddCallback( toggle,
1467 XmNvalueChangedCallback,
1468 XtasButtonsChangedCallback,
1469 &button_options[i].selected );
1470 }
1471 XtManageChild( prompt );
1472 // XalLimitedLoop( prompt );
1473 }
1474