[project @ 1996-07-25 20:43:49 by partain]
[ghc-hetmet.git] / ghc / utils / parallel / gp-ext-imp.pl
1 #!/usr/local/bin/perl
2 # #############################################################################
3 #
4 # Usage: gp-ext-imp [options] [<input-file>] [<output-file>]
5 #
6 # A small script to produce half-useful bar graphs from the PostScript
7 # output produced by gnuplot.  
8 # Translation is done in the X axis automatically, and should
9 # be `good enough' for graphs with smallish numbers of bars.
10 #
11 # Original version:          Bryan O'Sullivan <bos@dcs.glasgow.ac.uk> 09.94
12 # New and improved version:  Hans Wolfgang Loidl <hwloidl@dcs.glasgow.ac.uk>
13 #
14 # Options:
15 #  -w <width>      ... width of vertical bars
16 #  -g <gray-level> ... set gray-level (between 0 and 1; 0 means black)
17 #  -m <move>       ... move the graph <move> pixels to the right
18 #  -h              ... help; print this text
19 #  -v              ... verbose mode
20 #
21 # #############################################################################
22
23 require "getopts.pl";
24
25 &Getopts('hvm:w:g:');  
26
27 if ( $opt_h ) {                      
28     open(ME,$0) || die "Can't open myself ($0)";
29     $n = 0;
30     while (<ME>) {
31       last if $_ =~ /^$/;
32       print $_;
33       $n++;
34     }
35     close(ME);
36
37     exit ;
38 }
39
40 $size = $opt_w ? $opt_w : 200;
41 $gray = $opt_g ? $opt_g : 0;
42 $move = $opt_m ? $opt_m : 150;
43
44 $from = $#ARGV >= 0 ? $ARGV[0] : "-";
45 $to = $#ARGV >= 1 ? $ARGV[1] : "-";
46
47 if ( $opt_v ) {
48     print 70 x "-" . "\n";
49     print "\nSetup: \n";
50     print " Input file: $from   Output file: $to\n";
51     print " Width: $size   Gray level: $gray   Move is " . 
52           ($opt_m ? "ON" : "OFF") . " with value $move\n";
53     print 70 x "-" . "\n";
54 }
55
56 open(FROM, "<$from") || die "$from: $!";
57 open(TO, ">$to") || die "$to: $!";
58
59 $l = -1;
60
61 foreach (<FROM>) {
62     if ($l >= 0) {
63         $l--;
64     }
65     if ($l == 0) {
66         if ( $opt_m ) {
67             # This seems to shift everything a little to the right;
68             print TO "$move 0 translate\n";
69         }
70         print TO "$gray setgray\n";
71         print TO "$size setlinewidth\n";
72     }
73     if (/^LT0$/) {
74         $l = 3;
75     } elsif (/^LT1$/) {
76         print TO "-150 0 translate\n";
77     }
78     print TO;
79 }
80
81
82
83
84
85
86