root/trunk/jps2ps/jps2ps.pl

Revision 12, 24.9 kB (checked in by jpv, 6 months ago)

--

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl
2 use Getopt::Long;
3
4 ##### ##### ##### ##### ##### ##### ##### #####
5 #####
6 ##### but : recoit en argument un nom ".jps", le traite et l'imprime
7 ##### sur la sortie standard ou sur le fichier ".ps" associe
8 #####
9 ##### ##### ##### ##### ##### ##### ##### #####
10
11 $pi = 3.14159265358979;
12
13 ############################################
14 ###                                      ###
15 ###           no de version              ###
16 ###                                      ###
17 ############################################
18
19 $version = "jps2ps version 0.019, 27 mai 2008";
20
21 ############################################
22 ###                                      ###
23 ### localisation des differents fichiers ###
24 ###                                      ###
25 ############################################
26
27 ## tentative pour reperer automatiquement la localisation du script
28
29 $montest = `ps a`;
30 $montest =~ s/([^\n]*jps2ps[^ ]*)//;
31 $montest = $1;
32 $montest =~ s/([^ ]*jps2ps[^ ]*)//;
33 $montest = $1;
34 ## print (STDOUT "resultat :\n$montest \n");
35 $ok = 1;
36 $i = 0;
37 while ($ok and ($i < 10)) {
38 ##    print (STDOUT "Passage...\n");
39     $localisation = `ls -l $montest`;
40 ##     print (STDOUT "$localisation\n");
41     if ($localisation =~ /^l/) {
42 ##      print (STDOUT "c'est un lien\n");
43         $montest = $localisation;
44         $montest =~ s/.*-> //;
45 ##      print (STDOUT "$montest\n");
46         $i++;
47     } else {
48         $ok = 0;
49     }
50 }
51 ### le repertoire d'installation de jps2ps
52 if (($i < 9) and ($montest =~ /jps2ps/)) {
53     $montest =~ s/jps2ps\.pl//;
54     $montest =~ s/\n//g;
55 ##     print (STDOUT "finle : $montest\n");
56     $JPS2PS_DIR = "$montest";
57 } else {
58 ## on n'a pas reussi a trouver, on utilise la donnee "en dur"
59     $JPS2PS_DIR = "/opt/syracuse/app/jps2ps/";
60 }
61
62 ### le repertoire d'installation de BBgraf
63 $BBGRAF_DIR = "/var/www/syracuse/bbgraf/";
64
65 ##$JPS2PS_DIR = "/opt/syracuse/app/jps2ps/";
66
67 ############################################
68 ###                                      ###
69 ### lecture de la ligne de commande      ###
70 ###                                      ###
71 ############################################
72
73 ## but : analyse les arguments recus
74 ## 5 arguments pris en compte : -a, -pst, -lpst, -i, et le nom du fichier
75
76 ##print "@ARGV \n";     ## la liste des arguments
77 $nbarg = $#ARGV;  ## le nb d'arguments
78
79 $source = "-";
80 $sortieimposee = 0;
81 $sortielpst = 0;
82 $sortiepst = 0;
83
84 ## on recupere le nom du  source
85 ## ce doit etre la derniere chaine de la ligne de commande, et il ne doit
86 ## pas commencer par un tiret.  s'il n'y a rien, on lit l'entree
87 ## standard. rque : si on tape 'jps2ps -i ok.txt -i noh', le source lu
88 ## sera 'noh.jps', ce qui n'est pas le but. Il faut alors taper 'jps2ps
89 ## -i=ok.txt -i=noh'
90
91 for $i (0 .. $nbarg) {
92     $argument = $ARGV[$i];
93     if ($argument !~ /^-/) {
94         $source = $argument;
95         ## si le nom de fichier n'a pas de suffixe, on rajoute '.jps'
96         if ($source !~ /\./) {
97             $source = $source . "\.jps";
98         };
99     }
100 }
101
102 ## print ("jps2ps : $source\n");
103
104 GetOptions (
105    "i=s" => \@includefile,
106 ##    "o" => \$fichiersortie,
107 ##    "s" => \$fichiersource,
108    "v" => \$demandeversion,
109    "a" => \$sortieimposee,
110    "pst" => \$sortiepst,
111    "lpst" => \$sortielpst,
112 );
113
114 if ($demandeversion) {
115     print (STDOUT "$version\n");
116     exit (0);
117 }
118
119 ##$source = "@ARGV[0]";
120
121 require $JPS2PS_DIR . "labels.pl";     ## les labels TeX
122 require $JPS2PS_DIR . "listpps.pl";    ## les fichiers .pps
123 require $JPS2PS_DIR . "priorite.pl";   ## le tableau des ordres de priorite
124 require $JPS2PS_DIR . "dephash.pl";    ## le hachage des dependances
125 ##require $JPS2PS_DIR . "exp2rpn.pl";    ## polonaise inverse -> cartesien
126 $exp2rpn = $JPS2PS_DIR . "exp2rpn.pl -v'a b c d e f g h i j k l m n o p q r s t u v w x y z xmin xmax ymin ymax tmin tmax pi' ";
127 $filtre = $JPS2PS_DIR . "filtre-file.pl";
128
129 ##### ##### ##### ##### ##### ##### ##### #####
130 #####
131 ##### les instructions traitees a part (valeurs par defaut)
132 #####
133 ##### ##### ##### ##### ##### ##### ##### #####
134
135 sub init_vars {
136    $xmin_str = "/xmin -6 def\n";
137    $xmax_str = "/xmax 6 def\n";
138    $ymin_str = "/ymin -6 def\n";
139    $ymax_str = "/ymax 6 def\n";
140    $border_str = "/border 7.5 def\n";
141    $xmin = -6;
142    $xmax = 6;
143    $ymin = -6;
144    $ymax = 6;
145    $border = 7.5;
146    $rotate = 0;
147    $angle_repere = 90;
148    $xunit = 0;
149    $yunit = 0;
150    $generic = 0;
151    $autocrop = 0;
152    ## $width = 0;
153    ## $height = 0;
154   
155    $width_str = "/width 250 def\n";
156    $height_str = "/height 250 def\n";
157 };
158
159 init_vars;
160 ## $width_str = "";
161 ## $height_str = "";
162
163 ##### ##### ##### ##### ##### ##### ##### #####
164 #####
165 ##### analyse du source .jps
166 #####
167 ##### ##### ##### ##### ##### ##### ##### #####
168
169 ## temoins pour les lectures de setxrange et setyrange
170 ## = 1 si pas lu, et 0 si deja lu
171 $xtem = 1;
172 $ytem = 1;
173
174 $format = "";        ## initialisation du rapport width/height
175 $xyrapport = 1;      ## initialisation du rapport x/y
176
177 ## lecture du source, et stockage ds le tableau @le_source
178 $i = 0;
179 ## on lit d'abord les fichiers à inclure
180 if (defined @includefile) {
181     foreach $file (@includefile) {
182         open (FILE, $file) or die "ouverture du fichier $file impossible";
183         while (<FILE>) {
184             $le_source [$i] = $_;
185             $i++;
186         };
187         close (FILE);
188     }
189 }
190 ## puis on lit le source
191 open (SRC, $source) or die "ouverture du fichier source $source impossible";
192 while (<SRC>) {
193     $le_source [$i] = $_;
194     $i = $i + 1;
195 };
196 close (SRC);
197
198 ## ici, on traite la saisie des donnees pour le  calcul de la BB
199 ## ainsi que le scan pour le traitement des dependances
200
201 foreach $line (@le_source) {
202     $ligne = $line;
203     ## on elimine les commentaires
204     if ($ligne =~ /%/) {
205         $ligne =~ s/%.*$//;
206     };
207     if ($ligne =~ /\t/) {
208         $ligne =~ s/\t/ /g;
209     };
210     ## traitement des mots cles particuliers (format image)
211     if ($ligne =~ /^autocrop/) {
212         $autocrop = 1;
213     };
214     if ($ligne =~ /^[^[%]*make_generic/) {
215         $generic = 1;
216     };
217     if ($ligne =~ /setunit/) {
218           ($xunit = $ligne) =~ s/^([0-9-.]*) ([0-9.]*) .*[\n]?$/$1/;
219           ($yunit = $ligne) =~ s/^([0-9-.]*) ([0-9.]*) .*[\n]?$/$2/;
220     };
221     if ($ligne =~ /setxunit/) {
222            $xunit = $ligne;
223            $xunit =~ s/ setxunit.*[\n]?$//;
224     };
225     if ($ligne =~ /setyunit/) {
226            $yunit = $ligne;
227            $yunit =~ s/ setyunit.*[\n]?$//;
228     };
229     if ($ligne =~ /setxrange[^3]/ and $xtem =~ 1) {
230            $xmin_str = "";
231            $xmax_str = "";
232            $xtem = 0;
233            ($xmin = $ligne) =~ s/^([0-9-.]*) ([0-9.]*) .*[\n]?$/$1/;
234            ($xmax = $ligne) =~ s/^([0-9-.]*) ([0-9-.]*) .*[\n]?$/$2/;
235            $setxrange_str = $ligne;
236     };
237     if ($ligne =~ /setyrange[^3]/ and $ytem =~ 1) {
238            $ymin_str = "";
239            $ymax_str = "";
240            $ytem = 0;
241            ($ymin = $ligne) =~ s/^([0-9-.]*) ([0-9.]*) .*[\n]?$/$1/;
242            ($ymax = $ligne) =~ s/^([0-9-.]*) ([0-9-.]*) .*[\n]?$/$2/;
243            $setyrange_str = $ligne;
244     };
245 ##     if ($ligne =~ /^\/xmin/) {
246 ##         $xmin_str = $ligne;
247 ##         ($xmin = $xmin_str) =~ s/\/xmin[ {]*(.*)[ }]*def.*\n/$1/
248 ##     };
249 ##     if ($ligne =~ /^\/xmax/) {
250 ##         $xmax_str = $ligne;
251 ##         ($xmax = $xmax_str) =~ s/\/xmax[ {]*(.*)[ }]*def.*\n/$1/;
252 ##     };
253 ##     if ($ligne =~ /^\/ymin/) {
254 ##         $ymin_str = $ligne;
255 ##         ($ymin = $ymin_str) =~ s/\/ymin (.*) def.*\n/$1/;
256 ##     };
257 ##     if ($ligne =~ /^\/ymax/) {
258 ##         $ymax_str = $ligne;
259 ##         ($ymax = $ymax_str) =~ s/\/ymax (.*) def.*\n/$1/;
260 ##     };
261 ##     if ($ligne =~ /^\/border /) {
262 ##         $border_str = $ligne;
263 ##         ($border = $border_str) =~ s/\/border (.*) def.*\n/$1/;
264 ##     };
265     if ($ligne =~ /setborder/) {
266         $border_str = $ligne;
267         ($border = $border_str) =~ s/ setborder.*[\n]?$//;
268     };
269     if ($ligne =~ /setxyrapport/) {
270         $xyrapport = $ligne;
271         $xyrapport =~ s/ setxyrapport.*[\n]?$//;
272     };
273     if ($ligne =~ /setformat/) {
274         $format = $ligne;
275         $format =~ s/ setformat.*[\n]?$//;
276     };
277     if ($ligne =~ /setrotate/) {
278         $rotate = $ligne;
279         $rotate =~ s/ setrotate.*[\n]?$//;
280     };
281     if ($ligne =~ /setangle_repere/) {
282         $angle_repere = $ligne;
283         $angle_repere =~ s/ setangle_repere.*[\n]?$//;
284     };
285 ##     if ($ligne =~ /^\/width/) {
286 ##            $width_str = $ligne;
287 ##            $width = $ligne;
288 ##            $width =~ s/^\/width[ ]*(.*) def.*[\n]?$/$1/;
289 ##     };
290     if ($ligne =~ /setwidth/) {
291            $width_str = $ligne;
292            $width = $ligne;
293            $width =~ s/ setwidth.*[\n]?$//;
294     };
295 ##     if ($ligne =~ /^\/height/) {
296 ##            $height_str = $ligne;
297 ##            $height = $ligne;
298 ##            $height =~ s/^\/height[ ]*(.*) def.*[\n]?$/$1/;
299 ##     };
300     if ($ligne =~ /setheight/) {
301            $height_str = $ligne;
302            ($height = $ligne) =~ s/ setheight.*[\n]?$//;
303     };
304
305     ### puis traitement standard
306     ###
307     ## on elimine les commentaires
308
309     if ($ligne =~ /%/) {
310            $ligne =~ s/%.*$//;
311     }
312     if ($ligne =~ /\(|\)|{|}|!|\[|\]|\//) {
313            $ligne =~ s/\(|\)|!|{|}|\[|\]|\// /g;
314     }
315     if ($ligne =~ /  /) {
316            $ligne =~ s/  / /g;
317     }   
318    $ligne =~ s/\r\n//;
319    $ligne =~ s/\n//;
320    @contenu = split (/ /, $ligne);
321    foreach $mot (@contenu) {
322         if ($mot =~ /[a-zA-Z]/) {
323 ## modif 01/07/00   while ($mot =~ /[0-9]/) {$mot =~ s/[0-9]//;};
324 #modif 02/01/04#            if ($mot =~ /[0-9]/) {$mot =~ s/[0-9]//g;};
325 ##            ### impression pour deboguage
326 ##            print "%%%%% $mot=="."\n";
327             ##### on fixe les dependances
328             foreach $dep (@{ $dependances {$mot} }) {
329                $besoin {$dep} = 1;
330 ##               ### impression pour deboguage
331 ##               print "%% === $dep\n";
332             }
333         }
334    }
335 };
336    
337 $besoin {AAA} = 1;
338 $besoin {AAAnode} = 1;
339 $besoin {AAAscale} = 1;
340 $besoin {mulv} = 1;
341 $besoin {addv} = 1;
342 #close FICHIER;
343
344 ## ##### impression pour deboguage
345 ## print "%%%%% ======= on trouve =======\n";
346 ## print '%' x 80 . "\n";
347 ##
348 ## foreach $word (@cles) {
349 ##    print "%% " . "$word   " . $besoin {$word} . "\n";
350 ## }
351
352 ##### ##### ##### ##### ##### ##### ##### #####
353 #####
354 ##### Si necessaire, on calcule les donnees manquantes
355 #####
356 ##### ##### ##### ##### ##### ##### ##### #####
357
358 ## ##### impression pour deboguage
359 ## print "%% xmin = $xmin \n";
360 ## print "%% xmax = $xmax \n";
361 ## print "%% ymin = $ymin \n";
362 ## print "%% ymax = $ymax \n";
363 ## print "%% scale = $scale \n";
364 ## print "%% width = $width \n";
365 ## print "%% height = $height \n";
366 ## print "%% xyrapport = $xyrapport"."\n";
367 ## print "%% format = $format"."\n";
368 ## print "%% xunit = $xunit"."\n";
369 ## print "%% yunit = $yunit"."\n";
370 ##  print "%% angle_repere = $angle_repere"."\n";
371 ##  print "%% angle_repere = " . sin ($angle_repere * $pi / 180) ."\n";
372
373 $dx = $xmax - $xmin;
374 $dy = $ymax - $ymin; #* sin ($angle_repere * $pi / 180);
375
376 ## les xunit et yunit sont prioritaires
377 if ($xunit != 0) {
378     $width = $dx * $xunit;
379     $width_str = "/width $width def\n";
380 };
381 if ($yunit != 0) {
382     $height = $dy * $yunit;
383     $height_str = "/height $height def\n";
384 };
385
386 ## Ici, on a recupere toutes les donnees de format presentes dans le source jps.
387 ## Les variables xmin, xmax, ymin, ymax, border et xyrapport sont initialisees.
388
389 ##### calcul des donnees manquantes pour la Bounding Box si necessaire
390 ##### on veut qu'il y ait au moins une des 2 variables $width et $height
391 ##### qui soit initialisee
392
393 if ((not $width) and (not $height)) {
394     if ($dx > $dy) {
395         $height = 250;
396     }
397     else {
398         $width = 250;
399     }
400 }
401
402 if ($width and $height) {
403     ## rien a faire
404 }
405 elsif ($format) {
406     if ($width) {
407         ## on a $width et $format
408         $height = $width / $format;
409         $height_str = "/height $height def\n";
410     } else {
411         ## on a $height et $format
412         $width = $height * $format;
413         $width_str = "/width $width def\n";
414     }
415 }
416 else {
417     if ($width) {
418         $height = $dy * sin ($angle_repere * $pi / 180) * $width / ($xyrapport * $dx);
419         $height_str = "/height $height def\n";
420     }
421     else {
422         $width = $height * ($xyrapport * $dx) / ($dy * sin ($angle_repere * $pi / 180));
423         $width_str = "/width $width def\n";
424     }
425 }
426
427 ## ##### on impose egalement width et height < 1000 pour eviter des problemes
428 ## ##### lors de la convertion au format jpeg par les ImageMagick
429 ## if ($width > 1000) {
430 ##     $width = 1000;
431 ## };
432 ## if ($height > 1000) {
433 ##     $height = 1000;
434 ## };
435
436 ## ##### impression pour deboguage
437 ##
438 ## print "%% xmin = $xmin \n";
439 ## print "%% xmax = $xmax \n";
440 ## print "%% ymin = $ymin \n";
441 ## print "%% ymax = $ymax \n";
442 ## print "%% scale = $scale \n";
443 ## print "%% width = $width \n";
444 ## print "%% height = $height \n";
445 ## print "%% border = $border \n";
446 ## print "%% xyrapport = $xyrapport"."\n";
447 ## print "%% format = $format"."\n";
448
449 ### les dimensions de la Bounding Box
450 ### (probleme ici si border, width ou height n'ont pas ete lus correctement)
451
452 $bbx = $width + 2 * $border;
453 $bby = $height + 2 * $border;
454 ### puis on tronque
455 $bbx = int ($bbx);
456 $bby = int ($bby);
457
458 sub max {
459     my ($x, $y) = @_;
460     if ($x>$y) {
461         return ($x);
462     } else {
463         return ($y);
464     }
465 }
466
467 sub min {
468     my ($x, $y) = @_;
469     if ($x > $y) {
470         return ($y);
471     } else {
472         return ($x);
473     }
474 }
475
476 $alpha = $rotate * ($pi / 180);
477
478 ## print ("bbx : $bbx\n");
479 ## print ("bby : $bby\n");
480 ## print ("rotate : $rotate,\n");
481 ## print (sin ($alpha) . "\n");
482
483 $dlx = min (-$bby * sin ($alpha), 0);
484 $dlx = min ($dlx, $bbx * cos ($alpha));
485 $dlx = min ($dlx, $bbx * cos ($alpha) - $bby * sin ($alpha));
486 $dly = min ($bby * cos ($alpha), 0);
487 $dly = min ($dly, $bbx * sin ($alpha));
488 $dly = min ($dly, $bbx * sin ($alpha) + $bby * cos ($alpha));
489
490 $dlx = int ($dlx);
491 $dly = int ($dly);
492
493 ## print ("dlx : $dlx\n");
494 ## print ("dly : $dly\n");
495
496 $urx = max (-$bby * sin ($alpha), 0);
497 $urx = max ($urx, $bbx * cos ($alpha));
498 $urx = max ($urx, $bbx * cos ($alpha) - $bby * sin ($alpha));
499 $ury = max ($bby * cos ($alpha), 0);
500 $ury = max ($ury, $bbx * sin ($alpha));
501 $ury = max ($ury, $bbx * sin ($alpha) + $bby * cos ($alpha));
502
503 $urx = int ($urx);
504 $ury = int ($ury);
505
506 ## print ("urx : $urx\n");
507 ## print ("ury : $ury\n");
508
509 ### la relative Bounding Box par rapport a l'origine du repere (utile pour PSTricks)
510 $botx = ($xmin * $width) / ($xmax - $xmin) - $border ;
511 $boty = ($ymin * $height) / ($ymax - $ymin) - $border ;
512 $topx = ($xmax * $width) / ($xmax - $xmin) + $border ;
513 $topy = ($ymax * $height) / ($ymax - $ymin) + $border ;
514 ### puis on tronque
515 $botx = (int ($botx * 100)) / 100;
516 $boty = (int ($boty * 100)) / 100;
517 $topx = (int ($topx * 100)) / 100;
518 $topy = (int ($topy * 100)) / 100;
519 ## print "%% botx = $botx \n";
520 ## print "%% boty = $boty \n";
521 ## print "%% topx = $topx \n";
522 ## print "%% topy = $topy \n";
523 ### unites pour PSTricks
524 $PSTxunit = (int (($width / $dx) * 100)) / 100 ;
525 $PSTyunit = (int (($height / $dy) * 100)) / 100 ;
526 ### placement de la boite pour epsfbox dans PSTricks
527 $PSTOx = $xmin + ($dx/2);
528 $PSTOy = $ymin + ($dy/2);
529
530 ##### ##### ##### ##### ##### ##### ##### #####
531 #####
532 ##### Impressions pour PSTricks
533 #####
534 ##### ##### ##### ##### ##### ##### ##### #####
535
536 if ($sortiepst or $sortielpst) {
537     $dimptx = $bbx;
538     $dimpty = $bby;
539     ## on la calcule en mm
540     $dimx = ($dimptx / 72.27) * 25.4;
541     $dimy = ($dimpty / 72.27) * 25.4;
542     ### puis on tronque
543     $dimx = (int ($dimx * 100)) / 100;
544     $dimy = (int ($dimy * 100)) / 100;
545     print "%% xsize: $dimx mm, $dimptx pt\n";
546     print "%% ysize: $dimy mm, $dimpty pt\n";
547     print "\\psset{unit=1pt}\n";
548     if ($sortiepst) {
549         print "\\pspicture($botx,$boty)($topx,$topy)\n";
550         print "\\psset{xunit=$PSTxunit,yunit=$PSTyunit}\n";
551         print "\\rput($PSTOx,$PSTOy){\\epsfbox{img}}\n";
552         print "\\endpspicture\n";
553     }
554     else {
555         print "\\begin{pspicture}($botx,$boty)($topx,$topy)\n";
556         print "\\psset{xunit=$PSTxunit,yunit=$PSTyunit}\n";
557         print "\\rput($PSTOx,$PSTOy){\\includegraphics{img}}\n";
558         print "\\end{pspicture}\n";
559     }
560 }
561
562 ##### ##### ##### ##### ##### ##### ##### #####
563 #####
564 ##### On selectionne la sortie
565 #####
566 ##### ##### ##### ##### ##### ##### ##### #####
567
568 if ((not $autocrop) and $sortieimposee) {
569     $sortie = $source;
570     $sortie =~ s/\.jps/\.ps/;
571     open (SORTIE, ">$sortie") or die "ouverture du fichier $sortie impossible";
572     select (SORTIE);
573 }
574 if ($autocrop) {
575 #   $tmp_sortie = $JPS2PS_DIR . "tmp/$$.ps";
576 #   $log = $JPS2PS_DIR . "tmp/$$.log";
577    $tmp_sortie = "/tmp/$$.ps";
578    $log = "/tmp/$$.log";
579    open (SORTIE, ">$tmp_sortie") or die "ouverture du fichier $tmp_sortie impossible";
580    select (SORTIE);
581 }
582
583 ##### ##### ##### ##### ##### ##### ##### #####
584 #####
585 ##### On imprime les en-tetes et le minimum
586 #####
587 ##### ##### ##### ##### ##### ##### ##### #####
588
589 print "%!PS-Adobe-3.0 EPSF \n";
590
591 sub affiche_en_tete_BB {
592    print "%%Title:  \n";
593    print "%%Creator: $version \n";
594    print "%%Pages:  1 \n";
595    ## print "%%BoundingBox: 0 0 $bbx $bby \n";
596    print "%%BoundingBox: $dlx $dly $urx $ury \n";
597 };
598
599 sub affiche_en_tete_suite {
600    print "%%Pspicture: ($botx,$boty)($topx,$topy)\n";
601    print "%%PSTunit: xunit=$PSTxunit,yunit=$PSTyunit\n";
602    print "%%OriginePspicture: ($PSTOx,$PSTOy)\n";
603    print "%%EndComments \n";
604    print "%%Page: 1 1\n";
605 };
606
607 if (not $autocrop) {
608     affiche_en_tete_BB;
609 }
610 # &affiche_en_tete;
611 &affiche_en_tete_suite;
612
613 ##### ##### ##### ##### ##### ##### ##### #####
614 #####
615 ##### On ouvre 2 nouveaux dictionnaires
616 #####
617 ##### ##### ##### ##### ##### ##### ##### #####
618
619 print "/Pictdic 50 dict def Pictdic begin \n";
620 print "/jpsdic 500 dict def \n";
621 print "gsave \n";
622 print "jpsdic begin \n";
623 print "/pathdict 4 dict def \n";
624 print "/setrotate {pop} def\n";
625 print "/setformat {pop} def\n";
626 print "/setxyrapport {pop} def\n";
627 print "$rotate rotate\n";
628
629 ##### ##### ##### ##### ##### ##### ##### #####
630 #####
631 ##### On imprime les cles particulieres
632 #####
633 ##### ##### ##### ##### ##### ##### ##### #####
634
635 print ("%%%%%%%%%%%%%%%%%%%% la BoundingBox %%%%%%%%%%%%%%%%%%%%%\n");
636
637 if ($besoin {setwidth}) {
638     print (`cat ${setwidth}`);
639     }
640 if ($besoin {setheight}) {
641     print (`cat ${setheight}`);
642     }
643 if ($besoin {setborder}) {
644     print (`cat ${setborder}`);
645     }
646 print $width_str;
647 print $height_str;
648 print $border_str;
649
650 print ("%%%%%%%%%%%%%%%% les bornes sur les axes %%%%%%%%%%%%%%%%\n");
651
652 print $xmin_str;
653 print $xmax_str;
654 print $ymin_str;
655 print $ymax_str;
656
657 if ($besoin {setxrange}) {
658     print (`cat ${setxrange}`);
659     print $setxrange_str;}
660 if ($besoin {setyrange}) {
661     print (`cat ${setyrange}`);
662     print $setyrange_str;}
663
664 print ("/angle_repere " . $angle_repere . " def\n");
665 ## print `cat $mulv`;
666 ## print `cat $addv`;
667 ## print `cat $base_01`;
668 ## print `cat $base_02`;
669 ## print `cat $math`;
670 ## print `cat $masque`;
671 #print ("masque\n");
672
673 ## print ("newpath\n");
674 ## print ("$border $border moveto\n");
675 ## print ($bbx-2*$border . " 0 rlineto\n");
676 ## print ("0 " . $bby-2*$border . " lineto\n");
677 ## print (-$bbx+2*$border . " 0 rlineto\n");
678 ## print ("closepath\n");
679 ## print ("clip\n");
680
681 ## ##### impression pour deboguage
682 ##
683 ## print "%%%% le test : $dependances{xtick}[0] \n";
684 ##
685 ## print "%" x 20 . " mots cles recherches " . "=" x 20 . "\n";
686 ##
687 ## foreach $word (@cles) {
688 ##     print "%%% $word\n";                                 ## le mot cle
689 ##     print "%%%    ==> "."@{ $dependances {$word} }"." \n";   ## le tableau des dependances
690 ##     print "%%%    ==> ";
691 ##     foreach $dep (@{ $dependances {$word} }) {               ## les elts du tableau des deps
692 ##     print "$dep ";}
693 ##     print "\n";
694 ## }
695 ##
696 ## print "=" x 40 . "\n";
697
698 ##### ##### ##### ##### ##### ##### ##### #####
699 #####
700 ##### impression pour deboguage
701 #####
702 ##### ##### ##### ##### ##### ##### ##### #####
703
704 ### print "\n";
705 ###
706 ### ##
707 ### ##
708 ## print "%%%%% ======= on trouve =======\n";
709 ## print '%' x 80 . "\n";
710 ##
711 ## foreach $word (sort (@cles)) {
712 ##    print "%% " . "$word   " . $besoin {$word} . "\n";
713 ## }
714
715 ##### ##### ##### ##### ##### ##### ##### #####
716 #####
717 ##### routine d'affichage du source jps
718 #####
719 ##### ##### ##### ##### ##### ##### ##### #####
720
721 sub affiche_source_jps {
722    ##### puis on imprime le source ## en omettant les cles particulieres
723 #   open (FICHIER, $source) or die "ouverture du fichier $source impossible";
724   
725    ## while (<FICHIER>) {
726    ##     if (not ($_ =~ /^\/(xmin|xmax|ymin|ymax)/)) {print $_;};
727    ## }
728   
729    $label_en_cours = 0;
730    $label_tex = "";
731
732    $expr_en_cours = 0;
733    $expr_cart = "";
734
735    print ("\n" . "%"x20 . " debut du code jps " . "%"x20 . "\n");
736    
737    foreach $ligne (@le_source) {
738    #while ($ligne = <FICHIER>) {
739        if (($ligne =~ /^<tex>/) or ($ligne =~ /^<latex>/)) {
740            $label_en_cours = 1;
741        };
742        if ($ligne =~ /^#rpn#/) {
743 #           open (LOG, ">/var/www/syracuse/bbgraf/tmp/jps2ps.log") or die "ouverture du fichier log impossible";
744 #          print (LOG "$ligne....\n");
745            $ligne =~ s/\#rpn\#//;
746            $ligne =~ s/\n//g;
747            $ligne =~ s/[^a-zA-Z0-9\+\*\-\^\/\^\(\)\.,;]//g;
748            print (LOG "apres la manip : " . "$ligne" . "____\n");
749 #          close (LOG);
750 #          $ligne = &exp2rpn ($ligne) . "\n";
751            $ligne = `$exp2rpn ' $ligne'` . "\n";
752        };
753        if ($ligne =~ /^#inc#/) {
754            $ligne =~ s/#inc#//;
755            print (`cat $ligne`);
756            $ligne = "";
757        };
758        if ($ligne =~ /^#tex#/) {
759            $ligne =~ s/#tex#//;
760 #          print (STDOUT $ligne);
761            ($inclusion, $dim_label, @tablefont) = &traite_label ("<tex>\n" . "$ligne", @tablefont);
762            print ($inclusion);
763            print ($dim_label);
764            $ligne = "";
765        };
766        if ($ligne =~ /^#latex#/) {
767            $ligne =~ s/#latex#//;
768 #          print (STDOUT $ligne);
769            ($inclusion, $dim_label, @tablefont) = &traite_label ("<latex>\n" . "$ligne", @tablefont);
770            print ($inclusion);
771            print ($dim_label);
772            $ligne = "";
773        };
774        if (not $label_en_cours){
775            print ($ligne);
776        } else {
777            $label_tex = $label_tex . $ligne;
778        };
779        if (($ligne =~ /^<\/tex>/) or ($ligne =~ /^<\/latex>/)) {
780            $label_en_cours = 0;
781            ($inclusion, $dim_label, @tablefont) = &traite_label ($label_tex, @tablefont);
782            print ($inclusion);
783            print ($dim_label);
784            $label_tex = "";
785        };
786    }
787    print ("\n" . "%"x20 . " fin du code jps " . "%"x20 . "\n");
788 };
789
790 ##### ##### ##### ##### ##### ##### ##### #####
791 #####
792 ##### puis on imprime ce dont on a besoin
793 #####
794 ##### ##### ##### ##### ##### ##### ##### #####
795
796 if ($generic) {
797    foreach $word (sort (@cles)) {
798        print ("%======= fichier $word =========\n");
799        print (`cat ${$word}`);
800    }
801    print ("%"x20 . " debut du preliminaire pour generique " . "%"x20 . "\n");
802    print ("/make_generic {} def\n");
803    print ("setTimesRoman\n");
804
805    print ("(fichier générique, $version) O show_dim ptojpoint pop /b exch def pop /a exch def pop pop\n");
806    print ("(fichier générique, $version) xmin ymin xmax ymax milieu [xmax xmin sub .9 mul b a sub div dup] cctext\n");
807 #   print ("(fichier générique, $version) O [xmax xmin sub .9 mul b a sub div dup] cctext\n");
808    print "\n";
809    print ("%"x20 . " fin du preliminaire pour generique " . "%"x20 . "\n");
810 } else {
811    foreach $word (sort (@cles)) {
812       if ($besoin {$word}) {
813           print ("%% ======== fichier $word ======== %%\n");
814           print ("%% ======== ${$word} ======== %%\n");
815           print (`cat ${$word}`);
816       };
817    }
818    print "\n";
819    print ("newpath\n");
820    print ("   xmin ymin smoveto\n");
821    print ("   xmax ymin slineto\n");
822    print ("   xmax ymax slineto\n");
823    print ("   xmin ymax slineto\n");
824    print ("   closepath\n");
825    print ("clip\n");
826    ## encore un truc en dur : si "camview" est utilise, on calcule
827    ## la position par defaut de la camera
828    if ($besoin {camview}) {
829        print (`cat $camview_default`)}
830 };
831
832 &affiche_source_jps;
833
834 sub affiche_conclusion {
835    ##### et la conclusion
836    print "\n";
837    print "end\n";