1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; From a rapport of aspect and values (in line of character) of different margins, |
---|
5 | ; it calculate POSFENETRE and POSBAR which serve to place the drawing and the color |
---|
6 | ; bar thanks to !p.position on a leaf or a screen output whose the window has the same |
---|
7 | ; proportion. |
---|
8 | ; |
---|
9 | ; @categories |
---|
10 | ; Graphics |
---|
11 | ; |
---|
12 | ; @param RAPPORTYX {in}{required} |
---|
13 | ; Scale rapport between the length of the y axis and the x one. For example, |
---|
14 | ; for an xy map: RAPPORTYX=(lat2-lat1)/(lon2-lon1) |
---|
15 | ; |
---|
16 | ; @param MARGE {in}{required}{type=vector} |
---|
17 | ; Vector made of 4 elements containing the size of the left, right, up and |
---|
18 | ; bottom margin having to surround the graph. All is measured in lines of characters. |
---|
19 | ; |
---|
20 | ; @param MARGEBAR {in}{required}{type=vector} |
---|
21 | ; Vector made of 4 elements containing the size of the left, right and bottom |
---|
22 | ; margin and -BEWARE- the last element is this time the position of the right up |
---|
23 | ; corner, having to surround the color bar. All is measured in lines of characters. |
---|
24 | ; |
---|
25 | ; @param SMALLDRAW {in}{required}{type=vector} |
---|
26 | ; 2 possibilities: |
---|
27 | ; It is vector made of 4 elements giving (in portrait or landscape) the position |
---|
28 | ; of the frame in which the drawing must go in. This position is given by coordinates |
---|
29 | ; of the 2 corners of the frame: in the left bottom and the right up. It is always |
---|
30 | ; (for a postscript or a screen output) express in cm, the origin being the |
---|
31 | ; left bottom corner. |
---|
32 | ; It is a vector made of 3 elements giving the number of column to be done in the |
---|
33 | ; drawing, the number of line and the number of the case the number have to occupy |
---|
34 | ; (see matlab). For example, to do 6 drawing in 3 columns and 2 lines and occupy |
---|
35 | ; the 4th case, small=[2,3,4] |
---|
36 | ; |
---|
37 | ; @keyword REMPLI |
---|
38 | ; Force the drawing to occupy the biggest possible place defined by |
---|
39 | ; SMALLDRAW without respect the rapport y on x. |
---|
40 | ; |
---|
41 | ; @keyword YXASPECT |
---|
42 | ; Force the rapport y on x to take the value RAPPORTYX*YXASPECT. |
---|
43 | ; This keyword can be used in 2 cases: |
---|
44 | ; 1) YXASPECT=1 : force RAPPORTYX to be respected otherwise, Calibre take the |
---|
45 | ; initiative to change it a little in the case of the aspect rapport of SMALL |
---|
46 | ; is too different of the one of SMALLDRAW. |
---|
47 | ; 2) YXASPECT=n : multiply by n the aspect rapport given by default. |
---|
48 | ; For example in plt, RAPPORTYX is calculated to the reference be orthonormal, |
---|
49 | ; to have a reference where the y axis is 2 time bigger than the x one, YXASPECT=2. |
---|
50 | ; |
---|
51 | ; @keyword PORTRAIT |
---|
52 | ; Force the page or the window to be in standing position. |
---|
53 | ; |
---|
54 | ; @keyword LANDSCAPE |
---|
55 | ; Force the page or the window on the screen to be in lengthened position. |
---|
56 | ; |
---|
57 | ; @keyword _EXTRA |
---|
58 | ; Used to pass keywords |
---|
59 | ; |
---|
60 | ; @param POSFENETRE {type=vector} |
---|
61 | ; It is a vector made of 4 elements containing the position of the frame |
---|
62 | ; containing captions + the graph in normalized coordinates. |
---|
63 | ; Comment: to position the drawing, we have to do !p.position=POSFENETRE |
---|
64 | ; after the call of calibre. |
---|
65 | ; |
---|
66 | ; @param POSBAR {type=vector} |
---|
67 | ; See POSFENTERE but for the color bar. Same comment to position the color bar, !p.position=POSBAR |
---|
68 | ; |
---|
69 | ; @uses |
---|
70 | ; common.pro |
---|
71 | ; |
---|
72 | ; @history |
---|
73 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
74 | ; 11/12/98 |
---|
75 | ; |
---|
76 | ; @version |
---|
77 | ; $Id$ |
---|
78 | ;- |
---|
79 | ; |
---|
80 | PRO calibre, rapportyx, marge, margebar, smalldraw, posfenetre, posbar $ |
---|
81 | , REMPLI = rempli, YXASPECT = yxaspect, PORTRAIT = portrait $ |
---|
82 | , LANDSCAPE = lanscape, _EXTRA = ex |
---|
83 | ; |
---|
84 | compile_opt idl2, strictarrsubs |
---|
85 | ; |
---|
86 | @cm_4ps |
---|
87 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
88 | @updatenew |
---|
89 | @updatekwd |
---|
90 | ENDIF |
---|
91 | ;--------------------------------------------------------- |
---|
92 | ;------------------------------------------------------------ |
---|
93 | tempsun = systime(1) ; For key_performance |
---|
94 | ; |
---|
95 | ;------------------------------------------------------------- |
---|
96 | if keyword_set(portrait) then key_portrait=1 |
---|
97 | if keyword_set(landscape) then key_portrait=0 |
---|
98 | if keyword_set(yxaspect) then begin |
---|
99 | rapportyx=rapportyx*yxaspect |
---|
100 | test2=0 |
---|
101 | endif else begin |
---|
102 | yxaspect=1. |
---|
103 | test2=1 |
---|
104 | ENDELSE |
---|
105 | ; |
---|
106 | mipgsz = min(page_size, max = mapgsz) |
---|
107 | ;------------------------------------------------------------ |
---|
108 | ; choice of Landscape or Portrait |
---|
109 | ;------------------------------------------------------------ |
---|
110 | if n_elements(key_portrait) eq 0 then begin |
---|
111 | if rapportyx ge 1 then key_portrait=1 |
---|
112 | if rapportyx lt 1 then key_portrait=0 |
---|
113 | endif |
---|
114 | ;------------------------------------------------------------- |
---|
115 | ; If smalldraw is count like in matlab |
---|
116 | ;------------------------------------------------------------- |
---|
117 | if n_elements(smalldraw) EQ 3 then BEGIN |
---|
118 | IF smalldraw[2] LT 1 OR smalldraw[2] GT smalldraw[0]*smalldraw[1] THEN BEGIN |
---|
119 | dummy = report('wrong definition of the small keyword, we stop') |
---|
120 | stop |
---|
121 | ENDIF |
---|
122 | if n_elements(page_margins) EQ 0 then page_margins = [1, 1, 1, 1] |
---|
123 | smalldraw = long(smalldraw) |
---|
124 | nbrecol = smalldraw[0] |
---|
125 | nbrelig = smalldraw[1] |
---|
126 | numero = smalldraw[2]-1 |
---|
127 | numlig = numero/nbrecol |
---|
128 | numcol = numero-numlig*nbrecol |
---|
129 | bas = mipgsz*key_portrait+mapgsz*(1-key_portrait) |
---|
130 | cote = mapgsz*key_portrait+mipgsz*(1-key_portrait) |
---|
131 | poscol = page_margins[0]+findgen(nbrecol+1)*(1.*(bas-(page_margins[0]+page_margins[1]))/nbrecol) |
---|
132 | poslig = cote-page_margins[3]-findgen(nbrelig+1)*(1.*(cote-(page_margins[2]+page_margins[3]))/nbrelig) |
---|
133 | smalldraw = [poscol[numcol], poslig[numlig+1], poscol[numcol+1], poslig[numlig]] |
---|
134 | endif |
---|
135 | ;------------------------------------------------------------ |
---|
136 | ; determination of the size of characters (!p.charsize) |
---|
137 | ;------------------------------------------------------------ |
---|
138 | nombre_de_mots_ds_titre = 60. |
---|
139 | !p.charsize=1.*(smalldraw[2]-smalldraw[0])*!d.x_px_cm / $ |
---|
140 | (nombre_de_mots_ds_titre* !d.y_ch_size) |
---|
141 | if !p.charsize gt 1 then !p.charsize=1 |
---|
142 | ;------------------------------------------------------------ |
---|
143 | ; transfert of margin in cm |
---|
144 | ;------------------------------------------------------------ |
---|
145 | cm=1.*!d.x_px_cm |
---|
146 | marge=1.* marge * !d.y_ch_size * !p.charsize / cm |
---|
147 | margebar=1.* margebar * !d.y_ch_size * !p.charsize / cm |
---|
148 | ;------------------------------------------------------------ |
---|
149 | ; definition of the part of the leaf where we draw |
---|
150 | ;------------------------------------------------------------ |
---|
151 | if key_portrait eq 0 then begin |
---|
152 | big=smalldraw[2]-smalldraw[0] |
---|
153 | small=smalldraw[3]-smalldraw[1] |
---|
154 | endif else begin |
---|
155 | small=smalldraw[2]-smalldraw[0] |
---|
156 | big=smalldraw[3]-smalldraw[1] |
---|
157 | endelse |
---|
158 | if key_portrait eq 0 then $ |
---|
159 | rapportmax=1.*(small-marge[3]-marge[1])/(big-marge[2]-marge[0]) $ |
---|
160 | else rapportmax=1.*(small-marge[2]-marge[0])/(big-marge[3]-marge[1]) |
---|
161 | ;------------------------------------------------------------ |
---|
162 | ; If YXASPECT is not specified, we modify the value of RAPPORTYX |
---|
163 | ; to it match better with the leaf's proportions. |
---|
164 | ;------------------------------------------------------------ |
---|
165 | if rapportyx le rapportmax then begin |
---|
166 | if test2 then begin |
---|
167 | rap=1.*rapportmax/rapportyx |
---|
168 | if rap ge 5. and rap lt 6. then rapportyx=rapportyx*1.5 |
---|
169 | if rap ge 6. and rap lt 7. then rapportyx=rapportyx*2. |
---|
170 | if rap ge 7. and rap lt 8. then rapportyx=rapportyx*2.5 |
---|
171 | if rap ge 8. then rapportyx=rapportyx*3. |
---|
172 | endif |
---|
173 | endif else begin |
---|
174 | if test2 then begin |
---|
175 | rap=1.*rapportmax/rapportyx |
---|
176 | if rap lt 1./5. and rap ge 1./6. then rapportyx=rapportyx/1.5 |
---|
177 | if rap lt 1./6. and rap ge 1./7. then rapportyx=rapportyx/2. |
---|
178 | if rap lt 1./7. and rap ge 1./8. then rapportyx=rapportyx/2.5 |
---|
179 | if rap lt 1./8. then rapportyx=rapportyx*3. |
---|
180 | endif |
---|
181 | endelse |
---|
182 | ;------------------------------------------------------------ |
---|
183 | ; in the case where we do a Landscape: |
---|
184 | ;------------------------------------------------------------ |
---|
185 | if key_portrait eq 0 then begin |
---|
186 | if keyword_set(rempli) then begin |
---|
187 | xs=big |
---|
188 | ys=small |
---|
189 | endif else begin |
---|
190 | if rapportyx le rapportmax then begin |
---|
191 | xs=big |
---|
192 | ys=1.*(big-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] |
---|
193 | if ys gt small then begin |
---|
194 | xs=1.*(small-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] |
---|
195 | ys=small |
---|
196 | endif |
---|
197 | endif else begin |
---|
198 | xs=1.*(small-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] |
---|
199 | ys=small |
---|
200 | if xs gt big then begin |
---|
201 | xs=big |
---|
202 | ys=1.*(big-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] |
---|
203 | endif |
---|
204 | endelse |
---|
205 | endelse |
---|
206 | xoff=1.*(small-ys)/2.+smalldraw[1] |
---|
207 | yoff=1.*(big-xs)/2.+xs+mapgsz-smalldraw[2] |
---|
208 | a=1.*(mapgsz-yoff)/mapgsz |
---|
209 | b=1.*xoff/mipgsz |
---|
210 | c=a+1.*xs/mapgsz |
---|
211 | d=b+1.*ys/mipgsz |
---|
212 | endif $ |
---|
213 | ;------------------------------------------------------------ |
---|
214 | ; In the case where we do a portrait: |
---|
215 | ;------------------------------------------------------------ |
---|
216 | else begin |
---|
217 | if keyword_set(rempli) then begin |
---|
218 | xs=small |
---|
219 | ys=big |
---|
220 | endif else begin |
---|
221 | if rapportyx le rapportmax then begin |
---|
222 | xs=small |
---|
223 | ys=1.*(small-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] |
---|
224 | if ys gt big then begin |
---|
225 | xs=1.*(big-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] |
---|
226 | ys=big |
---|
227 | endif |
---|
228 | endif else begin |
---|
229 | xs=1.*(big-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] |
---|
230 | ys=big |
---|
231 | if xs gt small then begin |
---|
232 | xs=small |
---|
233 | ys=1.*(small-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] |
---|
234 | endif |
---|
235 | endelse |
---|
236 | endelse |
---|
237 | xoff=1.*(small-xs)/2.+smalldraw[0] |
---|
238 | yoff=1.*(big-ys)/2.+smalldraw[1] |
---|
239 | a=1.*xoff/mipgsz |
---|
240 | b=1.*yoff/mapgsz |
---|
241 | c=a+1.*xs/mipgsz |
---|
242 | d=b+1.*ys/mapgsz |
---|
243 | xset = xoff |
---|
244 | yset = yoff |
---|
245 | endelse |
---|
246 | ;------------------------------------------------------------ |
---|
247 | bas=mapgsz*(1-key_portrait)+mipgsz*key_portrait |
---|
248 | cote=mipgsz*(1-key_portrait)+mapgsz*key_portrait |
---|
249 | posfenetre=[a,b,c,d]+[ marge[0]/bas, marge[2]/cote $ |
---|
250 | ,-marge[1]/bas,-marge[3]/cote ] |
---|
251 | posbar=[a,b,c,d]+[ margebar[0]/bas, margebar[2]/cote $ |
---|
252 | ,-margebar[1]/bas,(-ys+margebar[3])/cote ] |
---|
253 | ;------------------------------------------------------------ |
---|
254 | if keyword_set(key_performance) THEN print, 'temps calibre', systime(1)-tempsun |
---|
255 | |
---|
256 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
257 | @updateold |
---|
258 | ENDIF |
---|
259 | |
---|
260 | return |
---|
261 | end |
---|