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

Last change on this file since 430 was 430, checked in by pinsard, 14 years ago

indent shell scripts

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 7.8 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
27   0101|0201|mouse)
28      # screen capture to be commented by frames and callouts images
29      capture="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
49   figpng/xxx_0101_org.png)
50      capture_xsize=520 #++ should be obtain by parsing identify result
51      capture_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
58      zone_nb=3
59      zone_t[1]="Data file"
60      zone_l[1]="datafile"
61      zone_rect[1]="26,53, 485,95"
62      zone_t[2]="Init method"
63      zone_l[2]="initmethod"
64      zone_rect[2]="78,101, 433,152"
65      zone_t[3]="Init program"
66      zone_l[3]="initprogram"
67      zone_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   ;;
75   figpng/xxx_0201_org.png)
76      capture_xsize=429 #++ should be obtain by parsing identify result
77      capture_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
84      zone_nb=10
85      #
86      zone_t[1]="Plot type"
87      zone_l[1]="plottype"
88      zone_rect[1]="3,24, 97,51"
89      zone_t[2]="Menu"
90      zone_l[2]="menu"
91      zone_rect[2]="108,24, 325,53"
92      zone_t[3]="OK"
93      zone_l[3]="ok"
94      zone_rect[3]="5,59, 44,86"
95      zone_t[4]="Page layout"
96      zone_l[4]="pagelayout"
97      zone_rect[4]="70,59, 193,86"
98      zone_t[5]="Variables list"
99      zone_l[5]="variableslist"
100      zone_rect[5]="209,60, 323,85"
101      zone_t[6]="Files list"
102      zone_l[6]="fileslist"
103      zone_rect[6]="2,95, 344,117"
104      zone_t[7]="Command text"
105      zone_l[7]="commandtext"
106      zone_rect[7]="2,126, 346,160"
107      zone_t[8]="Calendar"
108      zone_l[8]="calendar"
109      zone_rect[8]="2,169, 212,216"
110      zone_t[9]="Domdef"
111      zone_l[9]="domdef"
112      zone_rect[9]="16,227, 308,447"
113      zone_t[10]="Specifications"
114      zone_l[10]="specifications"
115      zone_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
119      zone_t[11]="just to check full size rectangle"
120      zone_l[11]="check"
121      zone_rect[11]="0,0 ${capture_xsize},${capture_ysize}"
122   ;;
123   figpng/xxx_mouse_org.png)
124      capture_xsize=57 #++ should be obtain by parsing identify result
125      capture_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
132      zone_nb=3
133      zone_t[1]="Left"
134      zone_l[1]="left"
135      zone_rect[1]="3,14, 11,21"
136      zone_t[2]="Middle"
137      zone_l[2]="middle"
138      zone_rect[2]="21,14, 28,19"
139      zone_t[3]="Right"
140      zone_l[3]="right"
141      zone_rect[3]="39,14, 46,20"
142   ;;
143   *)
144      echo " eee : ${capture} not implemented"
145      exit 3
146   ;;
147esac
148#
149# calculation of % of the rectangle of each zone for Calspair
150iz=1
151while [ ${iz} -le ${zone_nb} ]
152do
153   xymin=$(echo ${zone_rect[${iz}]} | awk '{print $1}')
154   xymax=$(echo ${zone_rect[${iz}]} | awk '{print $2}')
155   xmin=$(echo ${xymin} | awk -F "," '{print $1}')
156   xmax=$(echo ${xymax} | awk -F "," '{print $1}')
157   ymin=$(echo ${xymin} | awk -F "," '{print $2}')
158   ymax=$(echo ${xymax} | awk -F "," '{print $2}')
159   xmin_pc=$(echo "(${xmin} / ${capture_xsize}) * 10000" | bc -l)
160   xmin_pc=$(echo ${xmin_pc} } | awk -F "." '{print $1}')
161   ymin_pc=$(echo "(${ymin} / ${capture_ysize}) * 10000" | bc -l)
162   ymin_pc=$(echo ${ymin_pc} } | awk -F "." '{print $1}')
163   xmax_pc=$(echo "(${xmax} / ${capture_xsize}) * 10000" | bc -l)
164   xmax_pc=$(echo ${xmax_pc} } | awk -F "." '{print $1}')
165   ymax_pc=$(echo "(${ymax} / ${capture_ysize}) * 10000" | bc -l)
166   ymax_pc=$(echo ${ymax_pc} } | awk -F "." '{print $1}')
167   #echo "xmin_pc zone ${iz} = ${xmin_pc}"
168   #echo "ymin_pc zone ${iz} = ${ymin_pc}"
169   #echo "xmax_pc zone ${iz} = ${xmax_pc}"
170   #echo "ymax_pc zone ${iz} = ${ymax_pc}"
171   #read a
172   zone_rect_pc[${iz}]="${xmin_pc},${ymin_pc} ${xmax_pc},${ymax_pc}"
173   iz=$(( ${iz} + 1 ))
174done
175# build the new image ie build the convert command to be run
176# first part : use the capture image and prepare black border and white
177# rectangles insertion
178cmd="convert -size ${capture_xsize}x${capture_ysize} \
179   ${capture} \
180   -linewidth 2 \
181   -stroke black \
182   -fill transparent"
183#
184# then loop on the frames to be drawed
185iz=1
186while [ ${iz} -le ${zone_nb} ]
187do
188   leftcorner=$(echo ${zone_rect[${iz}]} | awk '{print $1}')
189   cmd="${cmd} -draw \"rectangle ${zone_rect[${iz}]}\" \
190   -draw \"image over ${leftcorner} ${callout_xsize},${callout_ysize} 'images/callouts/${iz}.png'\""
191   iz=$(( ${iz} + 1 ))
192done
193#
194#
195# +++ verrue mal codee...
196# dans le cas mouse, je ne veux pas les cadres
197# a voir si on integre proprement ou si on vire...
198if [ ${1} = mouse ]
199then
200    cmd="convert -size ${capture_xsize}x${capture_ysize} ${capture}"
201    iz=1
202    while [ ${iz} -le ${zone_nb} ]
203    do
204        leftcorner=$(echo ${zone_rect[${iz}]} | awk '{print $1}')
205        cmd="${cmd} -draw \"image over ${leftcorner} ${callout_xsize},${callout_ysize} 'images/callouts/${iz}.png'\""
206        iz=$(( ${iz} + 1 ))
207    done
208   
209fi
210# +++ verrue mal codee...
211#
212#
213# last component of the convert command : the name of the output image
214framecallouts=$(dirname ${capture})/$(basename ${capture} _org.png).png
215cmd="${cmd} ${framecallouts}"
216#
217#echo "cmd = ${cmd}"
218#read a
219#
220# run the convert command
221eval ${cmd}
222convert_status=${?}
223if [ ${convert_status} -ne 0 ]
224then
225   echo " eee : convert doesn't work properly"  >> ${log} 
226   echo " eee : return status = ${return_convert}"  >> ${log}
227   exit 2
228fi
229echo " iii : image ${framecallouts} is ready"
230echo " iii : you can add the following lines in XML/Docbook"
231cat << EOF
232<imageobjectco>
233<areaspec units="calspair">
234EOF
235iz=1
236while [ ${iz} -le ${zone_nb} ]
237do
238   echo "<area id=\"${zone_l[${iz}]}\" coords=\"${zone_rect_pc[${iz}]}\"/>"
239   iz=$(( ${iz} + 1 ))
240done
241cat << EOF
242</areaspec>
243<imageobject>
244<imagedata fileref="${framecallouts}"/> <!-- ++ instead of ${capture} -->
245</imageobject>
246<calloutlist>
247EOF
248iz=1
249while [ ${iz} -le ${zone_nb} ]
250do
251   cat << EOF
252<callout arearefs="${zone_l[${iz}]}">
253<para>${zone_t[${iz}]}</para>
254</callout>
255EOF
256   iz=$(( ${iz} + 1 ))
257done
258cat << EOF
259</calloutlist>
260</imageobjectco>
261EOF
262#
263exit 0
Note: See TracBrowser for help on using the repository browser.