Rev 4303 | Rev 12023 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | reyssat | 1 | #! /bin/sh |
2 | # |
||
3 | # Mandatary parms: $1=plot number. $2=session number. |
||
4 | # environment parms: ins_source. |
||
5 | # reserved words: insplot_set (setup), insplot_data, ins_border (border size). |
||
6 | |||
7 | if [ -z "$2" ]; then exit; fi |
||
8 | |||
9 | CONVERT_DIS=2 |
||
10 | CONVERT_OPT="-quality 90 -dispose $CONVERT_DIS" |
||
11 | |||
12 | GNUPLOT_HEADER='Pi=pi |
||
13 | PI=pi |
||
14 | e=exp(1) |
||
15 | E=exp(1) |
||
16 | sign(x) = sgn(x) |
||
17 | ln(x) = log(x) |
||
18 | lg(x) = log10(x) |
||
19 | ch(x) = cosh(x) |
||
20 | sh(x) = sinh(x) |
||
21 | th(x) = tanh(x) |
||
22 | arccos(x) = acos(x) |
||
23 | arcsin(x) = asin(x) |
||
24 | tg(x) = tan(x) |
||
25 | arctan(x) = atan(x) |
||
26 | arctg(x) = atan(x) |
||
27 | Argch(x) = acosh(x) |
||
28 | Argsh(x) = asinh(x) |
||
29 | Argth(x) = atanh(x) |
||
30 | argch(x) = acosh(x) |
||
31 | argsh(x) = asinh(x) |
||
32 | argth(x) = atanh(x) |
||
33 | cotan(x) = (1/tan(x)) |
||
34 | cot(x) = (1/tan(x)) |
||
35 | ctg(x) = (1/tan(x)) |
||
36 | sec(x) = (1/cos(x)) |
||
37 | csc(x) = (1/sin(x)) |
||
38 | max(x,y) = (x>y? x : y) |
||
39 | min(x,y) = (x<y? x : y) |
||
40 | round(x) = floor(x+0.5) |
||
41 | rint(x) = floor(x+0.5) |
||
42 | set samples 400 |
||
43 | ' |
||
44 | |||
45 | plot_cmd_2D=plot |
||
46 | plot_cmd_3D=splot |
||
47 | insplot_cmd= |
||
48 | if [ "$insplot_method" = "2D" ]; then insplot_cmd=$plot_cmd_2D; fi |
||
49 | if [ "$insplot_method" = "3D" ]; then insplot_cmd=$plot_cmd_3D; fi |
||
50 | if [ -z $insplot_cmd ]; then exit; fi |
||
51 | |||
52 | rm -f $2/insert$w_wims_inssub-$1* 2>/dev/null |
||
53 | |||
54 | # data file names |
||
55 | plot_parm=`echo "$ins_source" | sed "s!insplot_data!$2/insplot_data!g"` |
||
56 | insplot_parm=`echo "$insplot_source" | sed "s!insplot_data!$2/insplot_data!g"` |
||
57 | |||
58 | if [ ! -z "$w_insplot_data" ]; then |
||
59 | cat >$2/insplot_data <<@ |
||
60 | $w_insplot_data |
||
61 | @ |
||
62 | fi |
||
63 | if [ -z "$w_ins_anim_loop" ]; then w_ins_anim_loop=0; fi |
||
64 | insplot_colors=`echo $w_insplot_colors | tr ';\12' ' '` |
||
65 | |||
66 | if [ ! -z $w_insplot_transparent ]; then |
||
67 | gnuplot_transp=transparent |
||
68 | # A bad fix for convert transparency incompatibility trouble |
||
69 | # convert_transp="-transparent $w_insplot_transparent" |
||
1058 | bpr | 70 | convert_transp="-transparent rgb(255,255,255)" |
14 | reyssat | 71 | else |
72 | convert_transp= |
||
73 | fi |
||
74 | |||
75 | if [ "$w_anim_format" != "mng" ]; then |
||
76 | w_anim_format=gif |
||
77 | fi |
||
78 | |||
79 | if [ -z "$w_gnuplot_format" ] || [ "$w_gnuplot_format" = "default" ]; then |
||
80 | intermediate_format=$w_ins_format |
||
81 | else |
||
82 | intermediate_format=$w_gnuplot_format |
||
83 | fi |
||
84 | |||
892 | bpr | 85 | ###fix compatibility with gnuplot 4 |
4303 | bpr | 86 | ### and adress new chroot... |
87 | chroot_version=`cat $w_wims_home/chroot/version` |
||
88 | if [ "$chroot_version" = "4" ] ; then |
||
89 | gnuplot_version=4 |
||
90 | else |
||
91 | gnuplot_version=`gnuplot --version | awk '{ print $2 }' | awk -F '.' '{ print $1 }'` |
||
92 | fi |
||
892 | bpr | 93 | if [ "$gnuplot_version" -lt "4" ] || [ -z "$gnuplot_version" ]; then |
94 | insplot_termset="set terminal $intermediate_format $gnuplot_transp $w_insplot_font size 500,400 $insplot_colors" |
||
95 | else |
||
96 | testsize=`echo $insplot_set | perl -e 'if (<> =~ /size (\d+\.\d+),(\d+\.\d+)/) {$sx=$1*500 ; $sy=$2*400 ; print "size $sx,$sy" ; } else {print "size 500,400"}'` |
||
97 | insplot_termset="set terminal $intermediate_format $gnuplot_transp $w_insplot_font $testsize $insplot_colors" |
||
98 | # insplot_set=`echo $insplot_set | perl -e '$ins_set=<> ; $ins_set =~ s/(set +size +\d+\.\d+,\d+\.\d+)// ; $ins_set =~ s/set/\nset/g ; print $ins_set;'` |
||
7152 | bpr | 99 | insplot_set=`echo "$insplot_set" | sed "s/set[ ]*size *[0-9]\.[0-9]*,[0-9]\.[0-9]*//g"` |
892 | bpr | 100 | fi |
101 | |||
1059 | bpr | 102 | ### todo : dans les nouvelles versions de gnuplot, transformer "set noxxx" en "unset xxx" |
14 | reyssat | 103 | if [ ! -z "$multiplot" ]; then |
104 | plotcmd="set multiplot" |
||
105 | i=1 |
||
106 | until [ $i -gt $multiplot ]; do |
||
107 | tt=`echo "$insplot_parm" | awk 'FNR=='$i' {print;exit}'` |
||
108 | t2=`echo "$w_insplot_split" \ |
||
109 | | awk -F ';' 'FNR=='$i' {for(j=1;j<=NF;j++) print "set "$j;exit}'` |
||
110 | c1=`echo $tt | awk '{print $1}'` |
||
111 | c2=`echo $tt | awk '{print substr($0,3)}'` |
||
112 | if [ $c1 = "2D" ]; then |
||
113 | cc="$plot_cmd_2D $c2" |
||
114 | else |
||
115 | if [ $c1 = "3D" ]; then |
||
116 | cc="$plot_cmd_3D $c2" |
||
117 | else |
||
118 | cc="$insplot_cmd $tt" |
||
119 | fi |
||
120 | fi |
||
121 | plotcmd="$plotcmd |
||
122 | $t2 |
||
123 | $cc" |
||
124 | i=$(( $i+1 )) |
||
125 | done |
||
126 | plotcmd="$plotcmd |
||
127 | set nomultiplot" |
||
128 | else |
||
129 | plotcmd="$insplot_cmd $plot_parm" |
||
130 | fi |
||
131 | |||
132 | plot_content= |
||
133 | anim_list= |
||
134 | i=0 |
||
135 | while [ $i -lt $ins_anim_frames ]; do |
||
136 | plot_content="$plot_content |
||
137 | step=$i |
||
138 | animstep=$i |
||
139 | anim_step=$i |
||
140 | s=$i/$ins_anim_frames.0 |
||
141 | $insplot_set |
||
142 | $insplot_termset |
||
143 | set output \"$2/insert$w_wims_inssub-$1-$i.$intermediate_format\" |
||
144 | $plotcmd |
||
145 | " |
||
146 | anim_list="$anim_list $2/insert$w_wims_inssub-$1-$i.$intermediate_format" |
||
147 | i=$(( $i+1 )) |
||
148 | done |
||
149 | |||
150 | bin/ch..root gnuplot <<@ |
||
151 | $GNUPLOT_HEADER |
||
152 | $plot_content |
||
153 | @ |
||
154 | |||
155 | echo "$GNUPLOT_HEADER |
||
156 | $plot_content" >$2/gnuplot.cmd |
||
157 | |||
158 | alist= |
||
159 | for i in $anim_list |
||
160 | do |
||
161 | if [ -s $i ]; then alist="$alist $i"; fi |
||
162 | done |
||
163 | |||
164 | if [ $ins_anim_frames -lt 2 ]; then |
||
165 | if [ $w_ins_format = $intermediate_format ]; then |
||
166 | bin/ch..root mv $2/insert$w_wims_inssub-$1-0.$w_ins_format $2/insert$w_wims_inssub-$1.$w_ins_format |
||
167 | else |
||
168 | bin/ch..root convert $CONVERT_OPT $convert_transp -density $w_ins_density $2/insert$w_wims_inssub-$1-0.$intermediate_format $2/insert$w_wims_inssub-$1.$w_ins_format 2>$2/convert.err || bin/convert..switch $2/convert.err |
||
169 | fi |
||
170 | else |
||
171 | w_ins_format=$w_anim_format |
||
172 | if [ "$intermediate_format" = "gif" ] && [ "$w_ins_format" = "gif" ]; then |
||
173 | whirlgif -disp prev -time $ins_anim_delay -loop $w_ins_anim_loop -o $2/insert$w_wims_inssub-$1.gif $alist |
||
174 | else |
||
175 | bin/ch..root convert $CONVERT_OPT $convert_transp -delay $ins_anim_delay -loop $w_ins_anim_loop $alist $2/insert$w_wims_inssub-$1.$w_ins_format 2>$2/convert.err || bin/convert..switch $2/convert.err |
||
176 | fi |
||
177 | fi |
||
178 | |||
179 | # Remove zero-sized jpeg file, for otherwise netscape doesn't understand, |
||
180 | # and waits forever trying to interprete it. |
||
181 | if [ ! -s $2/insert$w_wims_inssub-$1.$w_ins_format ]; then rm -f $2/insert$w_wims_inssub-$1.$w_ins_format; fi |
||
182 | |||
183 | echo "$plot_content" >$2/insplot_cmd |
||
184 |