Subversion Repositories wimsdev

Rev

Rev 12023 | 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
15945 czzmrn 43
set colors classic
14 reyssat 44
'
45
 
46
plot_cmd_2D=plot
47
plot_cmd_3D=splot
48
insplot_cmd=
49
if [ "$insplot_method" = "2D" ]; then insplot_cmd=$plot_cmd_2D; fi
50
if [ "$insplot_method" = "3D" ]; then insplot_cmd=$plot_cmd_3D; fi
51
if [ -z $insplot_cmd ]; then exit; fi
52
 
53
rm -f $2/insert$w_wims_inssub-$1* 2>/dev/null
54
 
55
# data file names
56
plot_parm=`echo "$ins_source" | sed "s!insplot_data!$2/insplot_data!g"`
57
insplot_parm=`echo "$insplot_source" | sed "s!insplot_data!$2/insplot_data!g"`
58
 
59
if [ ! -z "$w_insplot_data" ]; then
60
  cat >$2/insplot_data <<@
61
$w_insplot_data
62
@
12023 bpr 63
fi
14 reyssat 64
if [ -z "$w_ins_anim_loop" ]; then w_ins_anim_loop=0; fi
65
insplot_colors=`echo $w_insplot_colors | tr ';\12' '  '`
66
 
67
if [ ! -z $w_insplot_transparent ]; then
68
 gnuplot_transp=transparent
69
# A bad fix for convert transparency incompatibility trouble
70
# convert_transp="-transparent $w_insplot_transparent"
1058 bpr 71
 convert_transp="-transparent rgb(255,255,255)"
14 reyssat 72
else
73
 convert_transp=
74
fi
75
 
76
if [ "$w_anim_format" != "mng" ]; then
77
 w_anim_format=gif
78
fi
79
 
80
if [ -z "$w_gnuplot_format" ] || [ "$w_gnuplot_format" = "default" ]; then
81
 intermediate_format=$w_ins_format
82
else
83
 intermediate_format=$w_gnuplot_format
84
fi
85
 
12023 bpr 86
###fix compatibility with gnuplot 4
4303 bpr 87
### and adress new chroot...
88
chroot_version=`cat $w_wims_home/chroot/version`
89
if [ "$chroot_version" = "4" ] ; then
90
    gnuplot_version=4
91
else
92
    gnuplot_version=`gnuplot --version | awk '{ print $2 }' | awk -F '.'  '{ print $1 }'`
93
fi
892 bpr 94
if [ "$gnuplot_version" -lt "4" ] || [ -z "$gnuplot_version" ]; then
95
  insplot_termset="set terminal $intermediate_format $gnuplot_transp $w_insplot_font size 500,400 $insplot_colors"
96
else
97
  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"}'`
98
  insplot_termset="set terminal $intermediate_format $gnuplot_transp $w_insplot_font $testsize $insplot_colors"
99
# 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 100
  insplot_set=`echo "$insplot_set" | sed "s/set[ 	]*size *[0-9]\.[0-9]*,[0-9]\.[0-9]*//g"`
12023 bpr 101
  insplot_set=`echo "$insplot_set" | sed "s/set +no/unset /g"`
892 bpr 102
fi
103
 
1059 bpr 104
### todo : dans les nouvelles versions de gnuplot, transformer "set noxxx" en "unset xxx"
14 reyssat 105
if [ ! -z "$multiplot" ]; then
106
 plotcmd="set multiplot"
107
 i=1
108
 until [ $i -gt $multiplot ]; do
109
  tt=`echo "$insplot_parm" | awk 'FNR=='$i' {print;exit}'`
110
  t2=`echo "$w_insplot_split" \
111
	| awk -F ';' 'FNR=='$i' {for(j=1;j<=NF;j++) print "set "$j;exit}'`
12023 bpr 112
  t2=`echo "$t2" | sed "s/set +no/unset /g"`
14 reyssat 113
  c1=`echo $tt | awk '{print $1}'`
114
  c2=`echo $tt | awk '{print substr($0,3)}'`
12023 bpr 115
  if [ $c1 = "2D" ]; then
14 reyssat 116
    cc="$plot_cmd_2D $c2"
117
  else
118
    if [ $c1 = "3D" ]; then
119
      cc="$plot_cmd_3D $c2"
120
    else
121
      cc="$insplot_cmd $tt"
122
    fi
123
  fi
124
  plotcmd="$plotcmd
125
	$t2
126
	$cc"
127
  i=$(( $i+1 ))
128
 done
129
 plotcmd="$plotcmd
12023 bpr 130
	unset multiplot"
14 reyssat 131
else
132
 plotcmd="$insplot_cmd $plot_parm"
133
fi
134
 
135
plot_content=
136
anim_list=
137
i=0
138
while [ $i -lt $ins_anim_frames ]; do
139
plot_content="$plot_content
140
 step=$i
141
 animstep=$i
142
 anim_step=$i
143
 s=$i/$ins_anim_frames.0
144
 $insplot_set
145
 $insplot_termset
146
 set output \"$2/insert$w_wims_inssub-$1-$i.$intermediate_format\"
147
 $plotcmd
148
"
149
anim_list="$anim_list $2/insert$w_wims_inssub-$1-$i.$intermediate_format"
150
i=$(( $i+1 ))
151
done
152
 
153
bin/ch..root gnuplot <<@
154
$GNUPLOT_HEADER
155
$plot_content
156
@
157
 
158
echo "$GNUPLOT_HEADER
159
$plot_content" >$2/gnuplot.cmd
160
 
161
alist=
162
for i in $anim_list
163
do
164
 if [ -s $i ]; then alist="$alist $i"; fi
165
done
166
 
167
if [ $ins_anim_frames -lt 2 ]; then
168
 if [ $w_ins_format = $intermediate_format ]; then
169
  bin/ch..root mv $2/insert$w_wims_inssub-$1-0.$w_ins_format $2/insert$w_wims_inssub-$1.$w_ins_format
170
 else
171
  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
172
 fi
173
else
174
 w_ins_format=$w_anim_format
175
 if [ "$intermediate_format" = "gif" ] && [ "$w_ins_format" = "gif" ]; then
176
  whirlgif -disp prev -time $ins_anim_delay -loop $w_ins_anim_loop -o $2/insert$w_wims_inssub-$1.gif $alist
177
 else
178
  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
179
 fi
180
fi
181
 
182
# Remove zero-sized jpeg file, for otherwise netscape doesn't understand,
183
# and waits forever trying to interprete it.
184
if [ ! -s $2/insert$w_wims_inssub-$1.$w_ins_format ]; then rm -f $2/insert$w_wims_inssub-$1.$w_ins_format; fi
185
 
186
echo "$plot_content" >$2/insplot_cmd
187