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