[2] | 1 | ;+ |
---|
[231] | 2 | ; |
---|
[150] | 3 | ; @file_comments |
---|
[226] | 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 |
---|
[150] | 7 | ; proportion. |
---|
[2] | 8 | ; |
---|
[226] | 9 | ; @categories |
---|
[157] | 10 | ; Graphics |
---|
[2] | 11 | ; |
---|
[150] | 12 | ; @param RAPPORTYX {in}{required} |
---|
[226] | 13 | ; Scale rapport between the length of the y axis and the x one. For example, |
---|
[150] | 14 | ; for an xy map: RAPPORTYX=(lat2-lat1)/(lon2-lon1) |
---|
[2] | 15 | ; |
---|
[163] | 16 | ; @param MARGE {in}{required}{type=vector} |
---|
[226] | 17 | ; Vector made of 4 elements containing the size of the left, right, up and |
---|
[150] | 18 | ; bottom margin having to surround the graph. All is measured in lines of characters. |
---|
[2] | 19 | ; |
---|
[163] | 20 | ; @param MARGEBAR {in}{required}{type=vector} |
---|
[226] | 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 |
---|
[150] | 23 | ; corner, having to surround the color bar. All is measured in lines of characters. |
---|
[2] | 24 | ; |
---|
[163] | 25 | ; @param SMALLDRAW {in}{required}{type=vector} |
---|
[150] | 26 | ; 2 possibilities: |
---|
[226] | 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 |
---|
[150] | 31 | ; left bottom corner. |
---|
[226] | 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 |
---|
[150] | 35 | ; the 4th case, small=[2,3,4] |
---|
[2] | 36 | ; |
---|
[150] | 37 | ; @keyword REMPLI |
---|
[226] | 38 | ; Force the drawing to occupy the biggest possible place defined by |
---|
[150] | 39 | ; SMALLDRAW without respect the rapport y on x. |
---|
[2] | 40 | ; |
---|
[150] | 41 | ; @keyword YXASPECT |
---|
[226] | 42 | ; Force the rapport y on x to take the value RAPPORTYX*YXASPECT. |
---|
[150] | 43 | ; This keyword can be used in 2 cases: |
---|
[226] | 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. |
---|
[150] | 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. |
---|
[2] | 50 | ; |
---|
[226] | 51 | ; @keyword PORTRAIT |
---|
[150] | 52 | ; Force the page or the window to be in standing position. |
---|
[226] | 53 | ; |
---|
| 54 | ; @keyword LANDSCAPE |
---|
[163] | 55 | ; Force the page or the window on the screen to be in lengthened position. |
---|
[226] | 56 | ; |
---|
[150] | 57 | ; @keyword _EXTRA |
---|
[231] | 58 | ; Used to pass keywords |
---|
[2] | 59 | ; |
---|
[163] | 60 | ; @param POSFENETRE {type=vector} |
---|
[226] | 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 |
---|
[150] | 64 | ; after the call of calibre. |
---|
[2] | 65 | ; |
---|
[163] | 66 | ; @param POSBAR {type=vector} |
---|
[226] | 67 | ; See POSFENTERE but for the color bar. Same comment to position the color bar, !p.position=POSBAR |
---|
[2] | 68 | ; |
---|
[150] | 69 | ; @uses |
---|
| 70 | ; common.pro |
---|
[2] | 71 | ; |
---|
[150] | 72 | ; @history |
---|
[157] | 73 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[150] | 74 | ; 11/12/98 |
---|
[2] | 75 | ; |
---|
[150] | 76 | ; @version |
---|
| 77 | ; $Id$ |
---|
[2] | 78 | ;- |
---|
[231] | 79 | ; |
---|
| 80 | PRO calibre, rapportyx, marge, margebar, smalldraw, posfenetre, posbar $ |
---|
[16] | 81 | , REMPLI = rempli, YXASPECT = yxaspect, PORTRAIT = portrait $ |
---|
[232] | 82 | , LANDSCAPE = lanscape, _EXTRA = ex |
---|
[114] | 83 | ; |
---|
| 84 | compile_opt idl2, strictarrsubs |
---|
| 85 | ; |
---|
[16] | 86 | @cm_4ps |
---|
| 87 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 88 | @updatenew |
---|
| 89 | @updatekwd |
---|
| 90 | ENDIF |
---|
| 91 | ;--------------------------------------------------------- |
---|
[2] | 92 | ;------------------------------------------------------------ |
---|
[150] | 93 | tempsun = systime(1) ; For key_performance |
---|
[222] | 94 | ; |
---|
[2] | 95 | ;------------------------------------------------------------- |
---|
| 96 | if keyword_set(portrait) then key_portrait=1 |
---|
| 97 | if keyword_set(landscape) then key_portrait=0 |
---|
[16] | 98 | if keyword_set(yxaspect) then begin |
---|
[226] | 99 | rapportyx=rapportyx*yxaspect |
---|
[2] | 100 | test2=0 |
---|
| 101 | endif else begin |
---|
[16] | 102 | yxaspect=1. |
---|
[2] | 103 | test2=1 |
---|
[16] | 104 | ENDELSE |
---|
[226] | 105 | ; |
---|
[16] | 106 | mipgsz = min(page_size, max = mapgsz) |
---|
[2] | 107 | ;------------------------------------------------------------ |
---|
[150] | 108 | ; choice of Landscape or Portrait |
---|
[2] | 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 | ;------------------------------------------------------------- |
---|
[150] | 115 | ; If smalldraw is count like in matlab |
---|
[2] | 116 | ;------------------------------------------------------------- |
---|
[222] | 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 |
---|
[16] | 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 |
---|
[2] | 127 | numlig = numero/nbrecol |
---|
| 128 | numcol = numero-numlig*nbrecol |
---|
[226] | 129 | bas = mipgsz*key_portrait+mapgsz*(1-key_portrait) |
---|
| 130 | cote = mapgsz*key_portrait+mipgsz*(1-key_portrait) |
---|
[16] | 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]] |
---|
[2] | 134 | endif |
---|
| 135 | ;------------------------------------------------------------ |
---|
[150] | 136 | ; determination of the size of characters (!p.charsize) |
---|
[2] | 137 | ;------------------------------------------------------------ |
---|
| 138 | nombre_de_mots_ds_titre = 60. |
---|
[16] | 139 | !p.charsize=1.*(smalldraw[2]-smalldraw[0])*!d.x_px_cm / $ |
---|
[2] | 140 | (nombre_de_mots_ds_titre* !d.y_ch_size) |
---|
| 141 | if !p.charsize gt 1 then !p.charsize=1 |
---|
| 142 | ;------------------------------------------------------------ |
---|
[150] | 143 | ; transfert of margin in cm |
---|
[2] | 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 | ;------------------------------------------------------------ |
---|
[150] | 149 | ; definition of the part of the leaf where we draw |
---|
[2] | 150 | ;------------------------------------------------------------ |
---|
| 151 | if key_portrait eq 0 then begin |
---|
[16] | 152 | big=smalldraw[2]-smalldraw[0] |
---|
| 153 | small=smalldraw[3]-smalldraw[1] |
---|
[2] | 154 | endif else begin |
---|
[16] | 155 | small=smalldraw[2]-smalldraw[0] |
---|
| 156 | big=smalldraw[3]-smalldraw[1] |
---|
[2] | 157 | endelse |
---|
| 158 | if key_portrait eq 0 then $ |
---|
[16] | 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]) |
---|
[2] | 161 | ;------------------------------------------------------------ |
---|
[226] | 162 | ; If YXASPECT is not specified, we modify the value of RAPPORTYX |
---|
[150] | 163 | ; to it match better with the leaf's proportions. |
---|
[2] | 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 | ;------------------------------------------------------------ |
---|
[150] | 183 | ; in the case where we do a Landscape: |
---|
[2] | 184 | ;------------------------------------------------------------ |
---|
[226] | 185 | if key_portrait eq 0 then begin |
---|
[2] | 186 | if keyword_set(rempli) then begin |
---|
[16] | 187 | xs=big |
---|
| 188 | ys=small |
---|
[2] | 189 | endif else begin |
---|
| 190 | if rapportyx le rapportmax then begin |
---|
[16] | 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 |
---|
[2] | 196 | endif |
---|
| 197 | endif else begin |
---|
[16] | 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] |
---|
[2] | 203 | endif |
---|
| 204 | endelse |
---|
| 205 | endelse |
---|
[16] | 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 |
---|
[2] | 212 | endif $ |
---|
| 213 | ;------------------------------------------------------------ |
---|
[150] | 214 | ; In the case where we do a portrait: |
---|
[2] | 215 | ;------------------------------------------------------------ |
---|
[226] | 216 | else begin |
---|
[2] | 217 | if keyword_set(rempli) then begin |
---|
[16] | 218 | xs=small |
---|
| 219 | ys=big |
---|
[2] | 220 | endif else begin |
---|
| 221 | if rapportyx le rapportmax then begin |
---|
[16] | 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 |
---|
[2] | 227 | endif |
---|
| 228 | endif else begin |
---|
[16] | 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] |
---|
[2] | 234 | endif |
---|
| 235 | endelse |
---|
| 236 | endelse |
---|
[16] | 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 |
---|
[2] | 243 | xset = xoff |
---|
| 244 | yset = yoff |
---|
| 245 | endelse |
---|
| 246 | ;------------------------------------------------------------ |
---|
[16] | 247 | bas=mapgsz*(1-key_portrait)+mipgsz*key_portrait |
---|
| 248 | cote=mipgsz*(1-key_portrait)+mapgsz*key_portrait |
---|
[2] | 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 | ;------------------------------------------------------------ |
---|
[226] | 254 | if keyword_set(key_performance) THEN print, 'temps calibre', systime(1)-tempsun |
---|
[16] | 255 | |
---|
| 256 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 257 | @updateold |
---|
[226] | 258 | ENDIF |
---|
| 259 | |
---|
[2] | 260 | return |
---|
| 261 | end |
---|