1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; NAME: calibre |
---|
6 | ; |
---|
7 | ; PURPOSE:a partir d''un rapport d''aspect et des valeurs (en ligne de |
---|
8 | ; characteres) des differentes marges, calcul posfenetre et posbar qui |
---|
9 | ; servent a placer le dessin et la barre de couleur grace a |
---|
10 | ; !p.position sur une feuille ou |
---|
11 | ; sur une sortie ecran dont la fenetre a les memes proportions |
---|
12 | ; |
---|
13 | ; CATEGORY: positionnement du graphe |
---|
14 | ; |
---|
15 | ; CALLING SEQUENCE: |
---|
16 | ; calibre, rapportyx,marge,margebar, smalldraw,posfenetre, posbar |
---|
17 | ; |
---|
18 | ; INPUTS: |
---|
19 | ; rapportyx: rapport d''echelle entre la longueur de l''axe des |
---|
20 | ; y et celle des x. par ex pour une carte xy, |
---|
21 | ; rapportyx=(lat2-lat1)/(lon2-lon1) |
---|
22 | ; |
---|
23 | ; marge: vecteur de 4 elements contenant la taille des marges a gauche, |
---|
24 | ; a droite, en bas et en haut devant entourer le graphe. tout est |
---|
25 | ; mesure en lignes de characteres |
---|
26 | ; |
---|
27 | ; margebar: vecteur de 4 elements contenant la taille des marges a gauche, |
---|
28 | ; a droite, en bas et -ATTENTION- le dernier element est cette fois-ci |
---|
29 | ; la position de coin en haut a droite, devant entourer la barre de |
---|
30 | ; couleur. tout est mesure en lignes de characteres |
---|
31 | ; |
---|
32 | ; smalldraw: 2 possiblites |
---|
33 | ; un vecteur de 4 elements donnant (en portrait ou |
---|
34 | ; en landscape) la position de cadre ds lequel doit rentrer le |
---|
35 | ; dessin. cette position est donne par les coordonnes des 2 coins du |
---|
36 | ; cadre: en bas a gauche et en haut a droite. elle s''exprime tjs |
---|
37 | ; (pour un postscript ou une sortie ecran) en cm, l''origine etant le |
---|
38 | ; coin en bas a gauche. |
---|
39 | ; un vecteur de 3 elements donnant le nombre de colonnes a |
---|
40 | ; faire de le dessin, le nombre de lignes et enfin le numero de la |
---|
41 | ; case que doit occuper le dessin (cf matlab). par ex pour faire 6 |
---|
42 | ; dessin en 2 colonnes et 3 lignes et occuper la 4 eme case, small=[2,3,4] |
---|
43 | ; |
---|
44 | ; KEYWORD PARAMETERS: |
---|
45 | ; |
---|
46 | ; /REMPLI:oblige le dessin a occuper l'espace maximum definit |
---|
47 | ; par smalldraw sans resperter le rapport y sur x. |
---|
48 | ; |
---|
49 | ; YXASPECT: force le rapport y sur x a prendre la valeur |
---|
50 | ; rapportyx*yxaspect. ce mot cle est utile ds deux cas: |
---|
51 | ; 1) yxaspect=1 : oblige rapportyx a etre bien respecte sinon |
---|
52 | ; calibre se reserve le droit de changer un peu celui-ci dans |
---|
53 | ; le cas ou le rapport d''aspect de small dessin est trop |
---|
54 | ; different de celui de smalldraw. |
---|
55 | ; 2) yxaspect=n : multiplie par n le rapport d''aspect donne par |
---|
56 | ; defaut.par ex ds plt, rapportyx est calcule pour que le |
---|
57 | ; repere soit orthonorme, pour avoir un repere ou l''axe des y |
---|
58 | ; est 2 fois plus dilate que celui des y YXASPECT=2 |
---|
59 | ; |
---|
60 | ; PORTRAIT et LANDSCAPE: mots cles plus utilises mais tjs fonctionnels |
---|
61 | ; |
---|
62 | ; OUTPUTS: |
---|
63 | ; posfenetre: un vecteur de 4 elements contenant la position de |
---|
64 | ; cadre contenant les legendes + le graphe en coordonnes |
---|
65 | ; normalises. Rq: pour positionner le dessin il faut apres |
---|
66 | ; l''appelle de calibre faire !p.position=posfenetre |
---|
67 | ; |
---|
68 | ; posbar: cf posfentre mais pour la barre de couleur. meme |
---|
69 | ; remarque pour positionner la barre de couleur, !p.position=posbar |
---|
70 | ; |
---|
71 | ; COMMON BLOCKS: |
---|
72 | ; common.pro |
---|
73 | ; |
---|
74 | ; SIDE EFFECTS: |
---|
75 | ; |
---|
76 | ; RESTRICTIONS: |
---|
77 | ; |
---|
78 | ; EXAMPLE: |
---|
79 | ; |
---|
80 | ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
81 | ; 11/12/98 |
---|
82 | ;- |
---|
83 | ;------------------------------------------------------------ |
---|
84 | ;------------------------------------------------------------ |
---|
85 | ;------------------------------------------------------------ |
---|
86 | pro calibre, rapportyx, marge, margebar, smalldraw, posfenetre, posbar $ |
---|
87 | , REMPLI = rempli, YXASPECT = yxaspect, PORTRAIT = portrait $ |
---|
88 | , LANDSCAPE = lanscape, _extra = ex |
---|
89 | ;--------------------------------------------------------- |
---|
90 | @cm_4ps |
---|
91 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
92 | @updatenew |
---|
93 | @updatekwd |
---|
94 | ENDIF |
---|
95 | ;--------------------------------------------------------- |
---|
96 | ;------------------------------------------------------------ |
---|
97 | tempsun = systime(1) ; pour key_performance |
---|
98 | ;------------------------------------------------------------- |
---|
99 | if keyword_set(portrait) then key_portrait=1 |
---|
100 | if keyword_set(landscape) then key_portrait=0 |
---|
101 | if keyword_set(yxaspect) then begin |
---|
102 | rapportyx=rapportyx*yxaspect |
---|
103 | test2=0 |
---|
104 | endif else begin |
---|
105 | yxaspect=1. |
---|
106 | test2=1 |
---|
107 | ENDELSE |
---|
108 | ; |
---|
109 | mipgsz = min(page_size, max = mapgsz) |
---|
110 | ;------------------------------------------------------------ |
---|
111 | ; choix de Landscape ou Portrait |
---|
112 | ;------------------------------------------------------------ |
---|
113 | if n_elements(key_portrait) eq 0 then begin |
---|
114 | if rapportyx ge 1 then key_portrait=1 |
---|
115 | if rapportyx lt 1 then key_portrait=0 |
---|
116 | endif |
---|
117 | ;------------------------------------------------------------- |
---|
118 | ; si smalldraw est compte comme ds matlab |
---|
119 | ;------------------------------------------------------------- |
---|
120 | if n_elements(smalldraw) EQ 3 then begin |
---|
121 | if n_elements(page_margins) EQ 0 then page_margins = [1, 1, 1, 1] |
---|
122 | smalldraw = long(smalldraw) |
---|
123 | nbrecol = smalldraw[0] |
---|
124 | nbrelig = smalldraw[1] |
---|
125 | numero = smalldraw[2]-1 |
---|
126 | numlig = numero/nbrecol |
---|
127 | numcol = numero-numlig*nbrecol |
---|
128 | bas = mipgsz*key_portrait+mapgsz*(1-key_portrait) |
---|
129 | cote = mapgsz*key_portrait+mipgsz*(1-key_portrait) |
---|
130 | poscol = page_margins[0]+findgen(nbrecol+1)*(1.*(bas-(page_margins[0]+page_margins[1]))/nbrecol) |
---|
131 | poslig = cote-page_margins[3]-findgen(nbrelig+1)*(1.*(cote-(page_margins[2]+page_margins[3]))/nbrelig) |
---|
132 | smalldraw = [poscol[numcol], poslig[numlig+1], poscol[numcol+1], poslig[numlig]] |
---|
133 | endif |
---|
134 | ;------------------------------------------------------------ |
---|
135 | ; determination de la taille des characteres (!p.charsize) |
---|
136 | ;------------------------------------------------------------ |
---|
137 | nombre_de_mots_ds_titre = 60. |
---|
138 | !p.charsize=1.*(smalldraw[2]-smalldraw[0])*!d.x_px_cm / $ |
---|
139 | (nombre_de_mots_ds_titre* !d.y_ch_size) |
---|
140 | if !p.charsize gt 1 then !p.charsize=1 |
---|
141 | ;------------------------------------------------------------ |
---|
142 | ; transfert de marge en cm |
---|
143 | ;------------------------------------------------------------ |
---|
144 | cm=1.*!d.x_px_cm |
---|
145 | marge=1.* marge * !d.y_ch_size * !p.charsize / cm |
---|
146 | margebar=1.* margebar * !d.y_ch_size * !p.charsize / cm |
---|
147 | ;------------------------------------------------------------ |
---|
148 | ; definition de la portion de feuille ou on dessine |
---|
149 | ;------------------------------------------------------------ |
---|
150 | if key_portrait eq 0 then begin |
---|
151 | big=smalldraw[2]-smalldraw[0] |
---|
152 | small=smalldraw[3]-smalldraw[1] |
---|
153 | endif else begin |
---|
154 | small=smalldraw[2]-smalldraw[0] |
---|
155 | big=smalldraw[3]-smalldraw[1] |
---|
156 | endelse |
---|
157 | if key_portrait eq 0 then $ |
---|
158 | rapportmax=1.*(small-marge[3]-marge[1])/(big-marge[2]-marge[0]) $ |
---|
159 | else rapportmax=1.*(small-marge[2]-marge[0])/(big-marge[3]-marge[1]) |
---|
160 | ;------------------------------------------------------------ |
---|
161 | ; si yxaspect n'est pas specifie on modifie la valeur de rapportyx pour que |
---|
162 | ; ca colle un peu plus aux proportions de la feuille |
---|
163 | ;------------------------------------------------------------ |
---|
164 | if rapportyx le rapportmax then begin |
---|
165 | if test2 then begin |
---|
166 | rap=1.*rapportmax/rapportyx |
---|
167 | if rap ge 5. and rap lt 6. then rapportyx=rapportyx*1.5 |
---|
168 | if rap ge 6. and rap lt 7. then rapportyx=rapportyx*2. |
---|
169 | if rap ge 7. and rap lt 8. then rapportyx=rapportyx*2.5 |
---|
170 | if rap ge 8. then rapportyx=rapportyx*3. |
---|
171 | endif |
---|
172 | endif else begin |
---|
173 | if test2 then begin |
---|
174 | rap=1.*rapportmax/rapportyx |
---|
175 | if rap lt 1./5. and rap ge 1./6. then rapportyx=rapportyx/1.5 |
---|
176 | if rap lt 1./6. and rap ge 1./7. then rapportyx=rapportyx/2. |
---|
177 | if rap lt 1./7. and rap ge 1./8. then rapportyx=rapportyx/2.5 |
---|
178 | if rap lt 1./8. then rapportyx=rapportyx*3. |
---|
179 | endif |
---|
180 | endelse |
---|
181 | ;------------------------------------------------------------ |
---|
182 | ; dans le cas ou on fait un Landscape: |
---|
183 | ;------------------------------------------------------------ |
---|
184 | if key_portrait eq 0 then begin |
---|
185 | if keyword_set(rempli) then begin |
---|
186 | xs=big |
---|
187 | ys=small |
---|
188 | endif else begin |
---|
189 | if rapportyx le rapportmax then begin |
---|
190 | xs=big |
---|
191 | ys=1.*(big-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] |
---|
192 | if ys gt small then begin |
---|
193 | xs=1.*(small-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] |
---|
194 | ys=small |
---|
195 | endif |
---|
196 | endif else begin |
---|
197 | xs=1.*(small-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] |
---|
198 | ys=small |
---|
199 | if xs gt big then begin |
---|
200 | xs=big |
---|
201 | ys=1.*(big-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] |
---|
202 | endif |
---|
203 | endelse |
---|
204 | endelse |
---|
205 | xoff=1.*(small-ys)/2.+smalldraw[1] |
---|
206 | yoff=1.*(big-xs)/2.+xs+mapgsz-smalldraw[2] |
---|
207 | a=1.*(mapgsz-yoff)/mapgsz |
---|
208 | b=1.*xoff/mipgsz |
---|
209 | c=a+1.*xs/mapgsz |
---|
210 | d=b+1.*ys/mipgsz |
---|
211 | endif $ |
---|
212 | ;------------------------------------------------------------ |
---|
213 | ; dans le cas ou on fait un portrait: |
---|
214 | ;------------------------------------------------------------ |
---|
215 | else begin |
---|
216 | if keyword_set(rempli) then begin |
---|
217 | xs=small |
---|
218 | ys=big |
---|
219 | endif else begin |
---|
220 | if rapportyx le rapportmax then begin |
---|
221 | xs=small |
---|
222 | ys=1.*(small-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] |
---|
223 | if ys gt big then begin |
---|
224 | xs=1.*(big-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] |
---|
225 | ys=big |
---|
226 | endif |
---|
227 | endif else begin |
---|
228 | xs=1.*(big-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] |
---|
229 | ys=big |
---|
230 | if xs gt small then begin |
---|
231 | xs=small |
---|
232 | ys=1.*(small-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] |
---|
233 | endif |
---|
234 | endelse |
---|
235 | endelse |
---|
236 | xoff=1.*(small-xs)/2.+smalldraw[0] |
---|
237 | yoff=1.*(big-ys)/2.+smalldraw[1] |
---|
238 | a=1.*xoff/mipgsz |
---|
239 | b=1.*yoff/mapgsz |
---|
240 | c=a+1.*xs/mipgsz |
---|
241 | d=b+1.*ys/mapgsz |
---|
242 | xset = xoff |
---|
243 | yset = yoff |
---|
244 | endelse |
---|
245 | ;------------------------------------------------------------ |
---|
246 | bas=mapgsz*(1-key_portrait)+mipgsz*key_portrait |
---|
247 | cote=mipgsz*(1-key_portrait)+mapgsz*key_portrait |
---|
248 | posfenetre=[a,b,c,d]+[ marge[0]/bas, marge[2]/cote $ |
---|
249 | ,-marge[1]/bas,-marge[3]/cote ] |
---|
250 | posbar=[a,b,c,d]+[ margebar[0]/bas, margebar[2]/cote $ |
---|
251 | ,-margebar[1]/bas,(-ys+margebar[3])/cote ] |
---|
252 | ;------------------------------------------------------------ |
---|
253 | if keyword_set(key_performance) THEN print, 'temps calibre', systime(1)-tempsun |
---|
254 | |
---|
255 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
256 | @updateold |
---|
257 | ENDIF |
---|
258 | |
---|
259 | return |
---|
260 | end |
---|