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

Last change on this file since 144 was 144, checked in by pinsard, 18 years ago

add files for xxx documentation see mini_notice.html

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 5.5 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 avalaible
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
271|2)
28# screen capture to be commented by frames and callouts images
29capture="figpng/xxx_${1}.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_2.png)
50capture_xsize=1211 #++ should be obtain by parsing identify result
51capture_ysize=630 #++ 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=4
59zone_t[1]="Page layout"
60zone_l[1]="pagelayout"
61zone_rect[1]="70,55 200,80"
62zone_t[2]="Calendar"
63zone_l[2]="calendar"
64zone_rect[2]="10,140 230,180"
65zone_t[3]="Domain"
66zone_l[3]="domain"
67zone_rect[3]="10,200 300,400"
68zone_t[4]="Specify"
69zone_l[4]="specify"
70zone_rect[4]="10,450 350,500"
71#
72# the next three lines are here to check calcultation of CALSPAIR units
73# see http://www.docbook.org/tdg/en/html/area.html
74# if you want to use it, please add one to zone_nb
75zone_t[5]="just to check full size rectangle"
76zone_l[5]="check"
77zone_rect[5]="0,0 ${capture_xsize},${capture_ysize}"
78;;
79figpng/xxx_1.png)
80capture_xsize=520 #++ should be obtain by parsing identify result
81capture_ysize=309 #++ should be obtain by parsing identify result
82#
83# description of frames (title, xmin,ymin, xmax,ymax)
84# nb : title and label are not yet used but they may be added in a kind of
85# comments
86# later in xml as id or label
87# now they are only here to remind us what we do
88zone_nb=2
89zone_t[1]="Data file"
90zone_l[1]="datafile"
91zone_rect[1]="5,55 515,90"
92zone_t[2]="Init file"
93zone_l[2]="initfile"
94zone_rect[2]="5,150 515,200"
95;;
96*)
97   echo " eee : ${capture} not implemented"
98   exit 3
99;;
100esac
101
102#
103# calculation of % of the rectangle of each zone for Calspair
104iz=1
105while [ ${iz} -le ${zone_nb} ]
106do
107   xymin=$(echo ${zone_rect[${iz}]} | awk '{print $1}')
108   xymax=$(echo ${zone_rect[${iz}]} | awk '{print $2}')
109   xmin=$(echo ${xymin} | awk -F "," '{print $1}')
110   xmax=$(echo ${xymax} | awk -F "," '{print $1}')
111   ymin=$(echo ${xymin} | awk -F "," '{print $2}')
112   ymax=$(echo ${xymax} | awk -F "," '{print $2}')
113   xmin_pc=$(echo "(${xmin} / ${capture_xsize}) * 10000" | bc -l)
114   xmin_pc=$(echo ${xmin_pc} } | awk -F "." '{print $1}')
115   ymin_pc=$(echo "(${ymin} / ${capture_ysize}) * 10000" | bc -l)
116   ymin_pc=$(echo ${ymin_pc} } | awk -F "." '{print $1}')
117   xmax_pc=$(echo "(${xmax} / ${capture_xsize}) * 10000" | bc -l)
118   xmax_pc=$(echo ${xmax_pc} } | awk -F "." '{print $1}')
119   ymax_pc=$(echo "(${ymax} / ${capture_ysize}) * 10000" | bc -l)
120   ymax_pc=$(echo ${ymax_pc} } | awk -F "." '{print $1}')
121   #echo "xmin_pc zone ${iz} = ${xmin_pc}"
122   #echo "ymin_pc zone ${iz} = ${ymin_pc}"
123   #echo "xmax_pc zone ${iz} = ${xmax_pc}"
124   #echo "ymax_pc zone ${iz} = ${ymax_pc}"
125   #read a
126   zone_rect_pc[${iz}]="${xmin_pc},${ymin_pc} ${xmax_pc},${ymax_pc}"
127   iz=$(( ${iz} + 1 ))
128done
129# build the new image ie build the convert command to be run
130# first part : use the capture image and prepare black border and white
131# rectangles insertion
132cmd="convert -size ${capture_xsize}x${capture_ysize} \
133    ${capture} \
134    -linewidth 2 \
135    -stroke black \
136    -fill transparent"
137#
138# then loop on the frames to be drawed
139iz=1
140while [ ${iz} -le ${zone_nb} ]
141do
142   leftcorner=$(echo ${zone_rect[${iz}]} | awk '{print $1}')
143   cmd="${cmd} -draw \"rectangle ${zone_rect[${iz}]}\" \
144   -draw \"image over ${leftcorner} ${callout_xsize},${callout_ysize} 'images/callouts/${iz}.png'\""
145   iz=$(( ${iz} + 1 ))
146done
147#
148# last component of the convert command : the name of the output image
149framecallouts=$(dirname ${capture})/$(basename ${capture} .png)_complete.png
150cmd="${cmd} ${framecallouts}"
151#
152#echo "cmd = ${cmd}"
153#read a
154#
155# run the convert command
156eval ${cmd}
157convert_status=${?}
158if [ ${convert_status} -ne 0 ]
159then
160   echo " eee : convert doesn't work properly"  >> ${log} 
161   echo " eee : return status = ${return_convert}"  >> ${log}
162   exit 2
163fi
164echo " iii : image ${framecallouts} is ready"
165echo " iii : you can add the following lines in XML/Docbook"
166cat << EOF
167<imageobjectco>
168<areaspec units="calspair">
169EOF
170iz=1
171while [ ${iz} -le ${zone_nb} ]
172do
173   echo "<area id=\"${zone_l[${iz}]}\" coords=\"${zone_rect_pc[${iz}]}\"/>"
174   iz=$(( ${iz} + 1 ))
175done
176cat << EOF
177</areaspec>
178<imageobject>
179<imagedata fileref="${framecallouts}"/> <!-- ++ instead of ${capture} -->
180</imageobject>
181<calloutlist>
182EOF
183iz=1
184while [ ${iz} -le ${zone_nb} ]
185do
186   cat << EOF
187<callout arearefs="${zone_l[${iz}]}">
188<para>${zone_t[${iz}]}</para>
189</callout>
190EOF
191   iz=$(( ${iz} + 1 ))
192done
193cat << EOF
194</calloutlist>
195</imageobjectco>
196EOF
197#
198exit 0
Note: See TracBrowser for help on using the repository browser.