[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 |
---|
[2] | 100 | ;------------------------------------------------------------- |
---|
| 101 | if keyword_set(portrait) then key_portrait=1 |
---|
| 102 | if keyword_set(landscape) then key_portrait=0 |
---|
[16] | 103 | if keyword_set(yxaspect) then begin |
---|
| 104 | rapportyx=rapportyx*yxaspect |
---|
[2] | 105 | test2=0 |
---|
| 106 | endif else begin |
---|
[16] | 107 | yxaspect=1. |
---|
[2] | 108 | test2=1 |
---|
[16] | 109 | ENDELSE |
---|
| 110 | ; |
---|
| 111 | mipgsz = min(page_size, max = mapgsz) |
---|
[2] | 112 | ;------------------------------------------------------------ |
---|
[150] | 113 | ; choice of Landscape or Portrait |
---|
[2] | 114 | ;------------------------------------------------------------ |
---|
| 115 | if n_elements(key_portrait) eq 0 then begin |
---|
| 116 | if rapportyx ge 1 then key_portrait=1 |
---|
| 117 | if rapportyx lt 1 then key_portrait=0 |
---|
| 118 | endif |
---|
| 119 | ;------------------------------------------------------------- |
---|
[150] | 120 | ; If smalldraw is count like in matlab |
---|
[2] | 121 | ;------------------------------------------------------------- |
---|
[219] | 122 | if n_elements(smalldraw) EQ 3 then begin |
---|
[16] | 123 | if n_elements(page_margins) EQ 0 then page_margins = [1, 1, 1, 1] |
---|
| 124 | smalldraw = long(smalldraw) |
---|
| 125 | nbrecol = smalldraw[0] |
---|
| 126 | nbrelig = smalldraw[1] |
---|
| 127 | numero = smalldraw[2]-1 |
---|
[2] | 128 | numlig = numero/nbrecol |
---|
| 129 | numcol = numero-numlig*nbrecol |
---|
[16] | 130 | bas = mipgsz*key_portrait+mapgsz*(1-key_portrait) |
---|
| 131 | cote = mapgsz*key_portrait+mipgsz*(1-key_portrait) |
---|
| 132 | poscol = page_margins[0]+findgen(nbrecol+1)*(1.*(bas-(page_margins[0]+page_margins[1]))/nbrecol) |
---|
| 133 | poslig = cote-page_margins[3]-findgen(nbrelig+1)*(1.*(cote-(page_margins[2]+page_margins[3]))/nbrelig) |
---|
| 134 | smalldraw = [poscol[numcol], poslig[numlig+1], poscol[numcol+1], poslig[numlig]] |
---|
[2] | 135 | endif |
---|
| 136 | ;------------------------------------------------------------ |
---|
[150] | 137 | ; determination of the size of characters (!p.charsize) |
---|
[2] | 138 | ;------------------------------------------------------------ |
---|
| 139 | nombre_de_mots_ds_titre = 60. |
---|
[16] | 140 | !p.charsize=1.*(smalldraw[2]-smalldraw[0])*!d.x_px_cm / $ |
---|
[2] | 141 | (nombre_de_mots_ds_titre* !d.y_ch_size) |
---|
| 142 | if !p.charsize gt 1 then !p.charsize=1 |
---|
| 143 | ;------------------------------------------------------------ |
---|
[150] | 144 | ; transfert of margin in cm |
---|
[2] | 145 | ;------------------------------------------------------------ |
---|
| 146 | cm=1.*!d.x_px_cm |
---|
| 147 | marge=1.* marge * !d.y_ch_size * !p.charsize / cm |
---|
| 148 | margebar=1.* margebar * !d.y_ch_size * !p.charsize / cm |
---|
| 149 | ;------------------------------------------------------------ |
---|
[150] | 150 | ; definition of the part of the leaf where we draw |
---|
[2] | 151 | ;------------------------------------------------------------ |
---|
| 152 | if key_portrait eq 0 then begin |
---|
[16] | 153 | big=smalldraw[2]-smalldraw[0] |
---|
| 154 | small=smalldraw[3]-smalldraw[1] |
---|
[2] | 155 | endif else begin |
---|
[16] | 156 | small=smalldraw[2]-smalldraw[0] |
---|
| 157 | big=smalldraw[3]-smalldraw[1] |
---|
[2] | 158 | endelse |
---|
| 159 | if key_portrait eq 0 then $ |
---|
[16] | 160 | rapportmax=1.*(small-marge[3]-marge[1])/(big-marge[2]-marge[0]) $ |
---|
| 161 | else rapportmax=1.*(small-marge[2]-marge[0])/(big-marge[3]-marge[1]) |
---|
[2] | 162 | ;------------------------------------------------------------ |
---|
[150] | 163 | ; If YXASPECT is not specified, we modify the value of RAPPORTYX |
---|
| 164 | ; to it match better with the leaf's proportions. |
---|
[2] | 165 | ;------------------------------------------------------------ |
---|
| 166 | if rapportyx le rapportmax then begin |
---|
| 167 | if test2 then begin |
---|
| 168 | rap=1.*rapportmax/rapportyx |
---|
| 169 | if rap ge 5. and rap lt 6. then rapportyx=rapportyx*1.5 |
---|
| 170 | if rap ge 6. and rap lt 7. then rapportyx=rapportyx*2. |
---|
| 171 | if rap ge 7. and rap lt 8. then rapportyx=rapportyx*2.5 |
---|
| 172 | if rap ge 8. then rapportyx=rapportyx*3. |
---|
| 173 | endif |
---|
| 174 | endif else begin |
---|
| 175 | if test2 then begin |
---|
| 176 | rap=1.*rapportmax/rapportyx |
---|
| 177 | if rap lt 1./5. and rap ge 1./6. then rapportyx=rapportyx/1.5 |
---|
| 178 | if rap lt 1./6. and rap ge 1./7. then rapportyx=rapportyx/2. |
---|
| 179 | if rap lt 1./7. and rap ge 1./8. then rapportyx=rapportyx/2.5 |
---|
| 180 | if rap lt 1./8. then rapportyx=rapportyx*3. |
---|
| 181 | endif |
---|
| 182 | endelse |
---|
| 183 | ;------------------------------------------------------------ |
---|
[150] | 184 | ; in the case where we do a Landscape: |
---|
[2] | 185 | ;------------------------------------------------------------ |
---|
| 186 | if key_portrait eq 0 then begin |
---|
| 187 | if keyword_set(rempli) then begin |
---|
[16] | 188 | xs=big |
---|
| 189 | ys=small |
---|
[2] | 190 | endif else begin |
---|
| 191 | if rapportyx le rapportmax then begin |
---|
[16] | 192 | xs=big |
---|
| 193 | ys=1.*(big-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] |
---|
| 194 | if ys gt small then begin |
---|
| 195 | xs=1.*(small-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] |
---|
| 196 | ys=small |
---|
[2] | 197 | endif |
---|
| 198 | endif else begin |
---|
[16] | 199 | xs=1.*(small-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] |
---|
| 200 | ys=small |
---|
| 201 | if xs gt big then begin |
---|
| 202 | xs=big |
---|
| 203 | ys=1.*(big-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] |
---|
[2] | 204 | endif |
---|
| 205 | endelse |
---|
| 206 | endelse |
---|
[16] | 207 | xoff=1.*(small-ys)/2.+smalldraw[1] |
---|
| 208 | yoff=1.*(big-xs)/2.+xs+mapgsz-smalldraw[2] |
---|
| 209 | a=1.*(mapgsz-yoff)/mapgsz |
---|
| 210 | b=1.*xoff/mipgsz |
---|
| 211 | c=a+1.*xs/mapgsz |
---|
| 212 | d=b+1.*ys/mipgsz |
---|
[2] | 213 | endif $ |
---|
| 214 | ;------------------------------------------------------------ |
---|
[150] | 215 | ; In the case where we do a portrait: |
---|
[2] | 216 | ;------------------------------------------------------------ |
---|
| 217 | else begin |
---|
| 218 | if keyword_set(rempli) then begin |
---|
[16] | 219 | xs=small |
---|
| 220 | ys=big |
---|
[2] | 221 | endif else begin |
---|
| 222 | if rapportyx le rapportmax then begin |
---|
[16] | 223 | xs=small |
---|
| 224 | ys=1.*(small-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] |
---|
| 225 | if ys gt big then begin |
---|
| 226 | xs=1.*(big-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] |
---|
| 227 | ys=big |
---|
[2] | 228 | endif |
---|
| 229 | endif else begin |
---|
[16] | 230 | xs=1.*(big-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] |
---|
| 231 | ys=big |
---|
| 232 | if xs gt small then begin |
---|
| 233 | xs=small |
---|
| 234 | ys=1.*(small-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] |
---|
[2] | 235 | endif |
---|
| 236 | endelse |
---|
| 237 | endelse |
---|
[16] | 238 | xoff=1.*(small-xs)/2.+smalldraw[0] |
---|
| 239 | yoff=1.*(big-ys)/2.+smalldraw[1] |
---|
| 240 | a=1.*xoff/mipgsz |
---|
| 241 | b=1.*yoff/mapgsz |
---|
| 242 | c=a+1.*xs/mipgsz |
---|
| 243 | d=b+1.*ys/mapgsz |
---|
[2] | 244 | xset = xoff |
---|
| 245 | yset = yoff |
---|
| 246 | endelse |
---|
| 247 | ;------------------------------------------------------------ |
---|
[16] | 248 | bas=mapgsz*(1-key_portrait)+mipgsz*key_portrait |
---|
| 249 | cote=mipgsz*(1-key_portrait)+mapgsz*key_portrait |
---|
[2] | 250 | posfenetre=[a,b,c,d]+[ marge[0]/bas, marge[2]/cote $ |
---|
| 251 | ,-marge[1]/bas,-marge[3]/cote ] |
---|
| 252 | posbar=[a,b,c,d]+[ margebar[0]/bas, margebar[2]/cote $ |
---|
| 253 | ,-margebar[1]/bas,(-ys+margebar[3])/cote ] |
---|
| 254 | ;------------------------------------------------------------ |
---|
| 255 | if keyword_set(key_performance) THEN print, 'temps calibre', systime(1)-tempsun |
---|
[16] | 256 | |
---|
| 257 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 258 | @updateold |
---|
| 259 | ENDIF |
---|
| 260 | |
---|
[2] | 261 | return |
---|
| 262 | end |
---|