source: trunk/SRC/Documentation/xmldoc/forxxxdoc.sh @ 376

Last change on this file since 376 was 258, checked in by pinsard, 17 years ago

correction for links in documentations. cf 62

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 7.3 KB
Line 
1#! /bin/sh
2#
3# module :
4# add frame and callouts image to an existing one
5#
6# !! exists only because graphics callouts are not yet available
7# with xsl processing on XML/Docbook files (xsl stylesheet 1.70 and
8# DocBook DTD 4.2)
9#
10# thanks to the authors of the following web pages
11# http://www.win.tue.nl/~aeb/linux/misc/convert/convert-draw-text.html
12# http://www.cit.gu.edu.au/~anthony/graphics/imagick6/draw/
13# http://www.cit.gu.edu.au/~anthony/graphics/imagick6/annotating/
14#
15# update :
16# $Id$
17# fplod 2006-07-20T16:05:19Z aedon.locean-ipsl.upmc.fr (Darwin)
18# add a parameter = the number of figpng/xxx_n.png
19# fplod 2006-07-19T12:40:02Z aedon.locean-ipsl.upmc.fr (Darwin)
20# first release
21#
22#
23set -u
24set -o posix
25#
26case "${1}" in
270101|0201|mouse)
28# screen capture to be commented by frames and callouts images
29capture="figpng/xxx_${1}_org.png"
30;;
31*)
32  echo "eee : unknown parameter ${1}"
33  exit 1
34;;
35esac
36#
37if [ ! -f ${capture} ]
38then
39  echo " eee : ${capture} not found"
40  exit 1
41fi
42#
43#
44callout_path=images/callouts/
45callout_xsize=12 # ++ should be obtain by parsing identify result
46callout_ysize=12 # ++ should be obtain by parsing identify result
47#
48case ${capture} in
49figpng/xxx_0101_org.png)
50capture_xsize=520 #++ should be obtain by parsing identify result
51capture_ysize=309 #++ should be obtain by parsing identify result
52#
53# description of frames (title, xmin, ymin, xmax,ymax)
54# nb : title and label are not yet used but they may be added in a kind of
55# comments
56# later in xml as id or label
57# now they are only here to remind us what we do
58zone_nb=3
59zone_t[1]="Data file"
60zone_l[1]="datafile"
61zone_rect[1]="26,53, 485,95"
62zone_t[2]="Init method"
63zone_l[2]="initmethod"
64zone_rect[2]="78,101, 433,152"
65zone_t[3]="Init program"
66zone_l[3]="initprogram"
67zone_rect[3]="3,159, 518,278"
68#zone_t[1]="Data file"
69#zone_l[1]="datafile"
70#zone_rect[1]="5,55 515,90"
71#zone_t[2]="Init file"
72#zone_l[2]="initfile"
73#zone_rect[2]="5,150 515,200"
74;;
75figpng/xxx_0201_org.png)
76capture_xsize=429 #++ should be obtain by parsing identify result
77capture_ysize=630 #++ should be obtain by parsing identify result
78#
79# description of frames (title, xmin, ymin, xmax,ymax)
80# nb : title and label are not yet used but they may be added in a kind of
81# comments
82# later in xml as id or label
83# now they are only here to remind us what we do
84zone_nb=10
85#
86zone_t[1]="Plot type"
87zone_l[1]="plottype"
88zone_rect[1]="3,24, 97,51"
89zone_t[2]="Menu"
90zone_l[2]="menu"
91zone_rect[2]="108,24, 325,53"
92zone_t[3]="OK"
93zone_l[3]="ok"
94zone_rect[3]="5,59, 44,86"
95zone_t[4]="Page layout"
96zone_l[4]="pagelayout"
97zone_rect[4]="70,59, 193,86"
98zone_t[5]="Variables list"
99zone_l[5]="variableslist"
100zone_rect[5]="209,60, 323,85"
101zone_t[6]="Files list"
102zone_l[6]="fileslist"
103zone_rect[6]="2,95, 344,117"
104zone_t[7]="Command text"
105zone_l[7]="commandtext"
106zone_rect[7]="2,126, 346,160"
107zone_t[8]="Calendar"
108zone_l[8]="calendar"
109zone_rect[8]="2,169, 212,216"
110zone_t[9]="Domdef"
111zone_l[9]="domdef"
112zone_rect[9]="16,227, 308,447"
113zone_t[10]="Specifications"
114zone_l[10]="specifications"
115zone_rect[10]="1,458, 345,580"
116# the next three lines are here to check calcultation of CALSPAIR units
117# see http://www.docbook.org/tdg/en/html/area.html
118# if you want to use it, please add one to zone_nb
119zone_t[11]="just to check full size rectangle"
120zone_l[11]="check"
121zone_rect[11]="0,0 ${capture_xsize},${capture_ysize}"
122;;
123figpng/xxx_mouse_org.png)
124capture_xsize=57 #++ should be obtain by parsing identify result
125capture_ysize=82 #++ should be obtain by parsing identify result
126#
127# description of frames (title, xmin, ymin, xmax,ymax)
128# nb : title and label are not yet used but they may be added in a kind of
129# comments
130# later in xml as id or label
131# now they are only here to remind us what we do
132zone_nb=3
133zone_t[1]="Left"
134zone_l[1]="left"
135zone_rect[1]="3,14, 11,21"
136zone_t[2]="Middle"
137zone_l[2]="middle"
138zone_rect[2]="21,14, 28,19"
139zone_t[3]="Right"
140zone_l[3]="right"
141zone_rect[3]="39,14, 46,20"
142;;
143*)
144   echo " eee : ${capture} not implemented"
145   exit 3
146;;
147esac
148
149
150
151
152#
153# calculation of % of the rectangle of each zone for Calspair
154iz=1
155while [ ${iz} -le ${zone_nb} ]
156do
157   xymin=$(echo ${zone_rect[${iz}]} | awk '{print $1}')
158   xymax=$(echo ${zone_rect[${iz}]} | awk '{print $2}')
159   xmin=$(echo ${xymin} | awk -F "," '{print $1}')
160   xmax=$(echo ${xymax} | awk -F "," '{print $1}')
161   ymin=$(echo ${xymin} | awk -F "," '{print $2}')
162   ymax=$(echo ${xymax} | awk -F "," '{print $2}')
163   xmin_pc=$(echo "(${xmin} / ${capture_xsize}) * 10000" | bc -l)
164   xmin_pc=$(echo ${xmin_pc} } | awk -F "." '{print $1}')
165   ymin_pc=$(echo "(${ymin} / ${capture_ysize}) * 10000" | bc -l)
166   ymin_pc=$(echo ${ymin_pc} } | awk -F "." '{print $1}')
167   xmax_pc=$(echo "(${xmax} / ${capture_xsize}) * 10000" | bc -l)
168   xmax_pc=$(echo ${xmax_pc} } | awk -F "." '{print $1}')
169   ymax_pc=$(echo "(${ymax} / ${capture_ysize}) * 10000" | bc -l)
170   ymax_pc=$(echo ${ymax_pc} } | awk -F "." '{print $1}')
171   #echo "xmin_pc zone ${iz} = ${xmin_pc}"
172   #echo "ymin_pc zone ${iz} = ${ymin_pc}"
173   #echo "xmax_pc zone ${iz} = ${xmax_pc}"
174   #echo "ymax_pc zone ${iz} = ${ymax_pc}"
175   #read a
176   zone_rect_pc[${iz}]="${xmin_pc},${ymin_pc} ${xmax_pc},${ymax_pc}"
177   iz=$(( ${iz} + 1 ))
178done
179# build the new image ie build the convert command to be run
180# first part : use the capture image and prepare black border and white
181# rectangles insertion
182cmd="convert -size ${capture_xsize}x${capture_ysize} \
183    ${capture} \
184    -linewidth 2 \
185    -stroke black \
186    -fill transparent"
187#
188# then loop on the frames to be drawed
189iz=1
190while [ ${iz} -le ${zone_nb} ]
191do
192   leftcorner=$(echo ${zone_rect[${iz}]} | awk '{print $1}')
193   cmd="${cmd} -draw \"rectangle ${zone_rect[${iz}]}\" \
194   -draw \"image over ${leftcorner} ${callout_xsize},${callout_ysize} 'images/callouts/${iz}.png'\""
195   iz=$(( ${iz} + 1 ))
196done
197#
198#
199# +++ verrue mal codee...
200# dans le cas mouse, je ne veux pas les cadres
201# a voir si on integre proprement ou si on vire...
202if [ ${1} = mouse ]
203then
204    cmd="convert -size ${capture_xsize}x${capture_ysize} ${capture}"
205    iz=1
206    while [ ${iz} -le ${zone_nb} ]
207    do
208        leftcorner=$(echo ${zone_rect[${iz}]} | awk '{print $1}')
209        cmd="${cmd} -draw \"image over ${leftcorner} ${callout_xsize},${callout_ysize} 'images/callouts/${iz}.png'\""
210        iz=$(( ${iz} + 1 ))
211    done
212   
213fi
214# +++ verrue mal codee...
215#
216#
217# last component of the convert command : the name of the output image
218framecallouts=$(dirname ${capture})/$(basename ${capture} _org.png).png
219cmd="${cmd} ${framecallouts}"
220#
221#echo "cmd = ${cmd}"
222#read a
223#
224# run the convert command
225eval ${cmd}
226convert_status=${?}
227if [ ${convert_status} -ne 0 ]
228then
229   echo " eee : convert doesn't work properly"  >> ${log} 
230   echo " eee : return status = ${return_convert}"  >> ${log}
231   exit 2
232fi
233echo " iii : image ${framecallouts} is ready"
234echo " iii : you can add the following lines in XML/Docbook"
235cat << EOF
236<imageobjectco>
237<areaspec units="calspair">
238EOF
239iz=1
240while [ ${iz} -le ${zone_nb} ]
241do
242   echo "<area id=\"${zone_l[${iz}]}\" coords=\"${zone_rect_pc[${iz}]}\"/>"
243   iz=$(( ${iz} + 1 ))
244done
245cat << EOF
246</areaspec>
247<imageobject>
248<imagedata fileref="${framecallouts}"/> <!-- ++ instead of ${capture} -->
249</imageobject>
250<calloutlist>
251EOF
252iz=1
253while [ ${iz} -le ${zone_nb} ]
254do
255   cat << EOF
256<callout arearefs="${zone_l[${iz}]}">
257<para>${zone_t[${iz}]}</para>
258</callout>
259EOF
260   iz=$(( ${iz} + 1 ))
261done
262cat << EOF
263</calloutlist>
264</imageobjectco>
265EOF
266#
267exit 0
Note: See TracBrowser for help on using the repository browser.