;+ ; ; @file_comments ; From a ration aspect and values (in line of character) of different margins, ; it calculate POSFENETRE and POSBAR which serve to place the drawing and the color ; bar thanks to !p.position on a leaf or a screen output whose the window has the same ; proportion. ; ; @categories ; Graphics ; ; @param rapportyx {in}{required} ; Scale ratio between the length of the y axis and the x one. For example, ; for an xy map: rapportyx=(lat2-lat1)/(lon2-lon1) ; ; @param marge {in}{required}{type=vector} ; Vector made of 4 elements containing the size of the left, right, up and ; bottom margin having to surround the graph. ; All is measured in lines of characters. ; ; @param margebar {in}{required}{type=vector} ; Vector made of 4 elements containing the size of the left, right and bottom ; margin and -BEWARE- the last element is this time the position of the right up ; corner, having to surround the color bar. All is measured in lines of characters. ; ; @param smalldraw {in}{required}{type=vector} ; 2 possibilities: ; It is vector made of 4 elements giving (in portrait or landscape) the position ; of the frame in which the drawing must go in. This position is given by coordinates ; of the 2 corners of the frame: in the left bottom and the right up. It is always ; (for a postscript or a screen output) express in cm, the origin being the ; left bottom corner. ; It is a vector made of 3 elements giving the number of column to be done in the ; drawing, the number of line and the number of the case the number have to fill ; (see matlab). For example, to do 6 drawings in 3 columns and 2 lines and ; fill the 4th case, small=[2,3,4] ; ; @param posfenetre {type=vector} ; It is a vector made of 4 elements containing the position of the frame ; containing captions + the graph in normalized coordinates. ; Comment: to position the drawing, we have to do !p.position=POSFENETRE ; after the call of calibre. ; ; @param posbar {type=vector} ; See POSFENTERE but for the color bar. Same comment to position the color bar, !p.position=POSBAR ; ; @keyword REMPLI ; Force the drawing to fill the biggest possible place defined by ; SMALLDRAW without respect the y/x ratio. ; ; @keyword YXASPECT ; Force the y/x ratio to take the value RAPPORTYX*YXASPECT. ; This keyword can be used in 2 cases: ; 1) YXASPECT=1 : force RAPPORTYX to be respected otherwise, calibre take the ; initiative to change it a little in the case of the aspect ratio of SMALL ; is too different of the one of SMALLDRAW. ; 2) YXASPECT=n : multiply by n the aspect ratio given by default. ; For example in plt, RAPPORTYX is calculated to the ; reference be orthonormal, ; to have a reference where the y axis is 2 time bigger than the x one, YXASPECT=2. ; ; @keyword PORTRAIT ; Force the page or the window to be in standing position. ; ; @keyword LANDSCAPE ; Force the page or the window on the screen to be in lengthened position. ; ; @keyword _EXTRA ; Used to pass keywords ; ; @uses ; common ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; 11/12/98 ; ; @version ; $Id$ ; ;- PRO calibre, rapportyx, marge, margebar, smalldraw, posfenetre, posbar $ , REMPLI=rempli, YXASPECT=yxaspect, PORTRAIT=portrait $ , LANDSCAPE=lanscape, _EXTRA=ex ; compile_opt idl2, strictarrsubs ; @cm_4ps IF NOT keyword_set(key_forgetold) THEN BEGIN @updatenew @updatekwd ENDIF ;--------------------------------------------------------- ;------------------------------------------------------------ tempsun = systime(1) ; For key_performance ; ;------------------------------------------------------------- if keyword_set(portrait) then key_portrait=1 if keyword_set(landscape) then key_portrait=0 if keyword_set(yxaspect) then begin rapportyx=rapportyx*yxaspect test2=0 endif else begin yxaspect=1. test2=1 ENDELSE ; mipgsz = min(page_size, max = mapgsz) ;------------------------------------------------------------ ; choice of Landscape or Portrait ;------------------------------------------------------------ if n_elements(key_portrait) eq 0 then begin if rapportyx ge 1 then key_portrait=1 if rapportyx lt 1 then key_portrait=0 endif ;------------------------------------------------------------- ; If smalldraw is count like in matlab ;------------------------------------------------------------- if n_elements(smalldraw) EQ 3 then BEGIN IF smalldraw[2] LT 1 OR smalldraw[2] GT smalldraw[0]*smalldraw[1] THEN BEGIN dummy = report('wrong definition of the small keyword, we stop') stop ENDIF if n_elements(page_margins) EQ 0 then page_margins = [1, 1, 1, 1] smalldraw = long(smalldraw) nbrecol = smalldraw[0] nbrelig = smalldraw[1] numero = smalldraw[2]-1 numlig = numero/nbrecol numcol = numero-numlig*nbrecol bas = mipgsz*key_portrait+mapgsz*(1-key_portrait) cote = mapgsz*key_portrait+mipgsz*(1-key_portrait) poscol = page_margins[0]+findgen(nbrecol+1)*(1.*(bas-(page_margins[0]+page_margins[1]))/nbrecol) poslig = cote-page_margins[3]-findgen(nbrelig+1)*(1.*(cote-(page_margins[2]+page_margins[3]))/nbrelig) smalldraw = [poscol[numcol], poslig[numlig+1], poscol[numcol+1], poslig[numlig]] endif ;------------------------------------------------------------ ; determination of the size of characters (!p.charsize) ;------------------------------------------------------------ nombre_de_mots_ds_titre = 60. !p.charsize=1.*(smalldraw[2]-smalldraw[0])*!d.x_px_cm / $ (nombre_de_mots_ds_titre* !d.y_ch_size) if !p.charsize gt 1 then !p.charsize=1 ;------------------------------------------------------------ ; transfert of margin in cm ;------------------------------------------------------------ cm=1.*!d.x_px_cm marge=1.* marge * !d.y_ch_size * !p.charsize / cm margebar=1.* margebar * !d.y_ch_size * !p.charsize / cm ;------------------------------------------------------------ ; definition of the part of the leaf where we draw ;------------------------------------------------------------ if key_portrait eq 0 then begin big=smalldraw[2]-smalldraw[0] small=smalldraw[3]-smalldraw[1] endif else begin small=smalldraw[2]-smalldraw[0] big=smalldraw[3]-smalldraw[1] endelse if key_portrait eq 0 then $ rapportmax=1.*(small-marge[3]-marge[1])/(big-marge[2]-marge[0]) $ else rapportmax=1.*(small-marge[2]-marge[0])/(big-marge[3]-marge[1]) ;------------------------------------------------------------ ; If YXASPECT is not specified, we modify the value of RAPPORTYX ; to it match better with the leaf's proportions. ;------------------------------------------------------------ if rapportyx le rapportmax then begin if test2 then begin rap=1.*rapportmax/rapportyx if rap ge 5. and rap lt 6. then rapportyx=rapportyx*1.5 if rap ge 6. and rap lt 7. then rapportyx=rapportyx*2. if rap ge 7. and rap lt 8. then rapportyx=rapportyx*2.5 if rap ge 8. then rapportyx=rapportyx*3. endif endif else begin if test2 then begin rap=1.*rapportmax/rapportyx if rap lt 1./5. and rap ge 1./6. then rapportyx=rapportyx/1.5 if rap lt 1./6. and rap ge 1./7. then rapportyx=rapportyx/2. if rap lt 1./7. and rap ge 1./8. then rapportyx=rapportyx/2.5 if rap lt 1./8. then rapportyx=rapportyx*3. endif endelse ;------------------------------------------------------------ ; in the case where we do a Landscape: ;------------------------------------------------------------ if key_portrait eq 0 then begin if keyword_set(rempli) then begin xs=big ys=small endif else begin if rapportyx le rapportmax then begin xs=big ys=1.*(big-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] if ys gt small then begin xs=1.*(small-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] ys=small endif endif else begin xs=1.*(small-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] ys=small if xs gt big then begin xs=big ys=1.*(big-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] endif endelse endelse xoff=1.*(small-ys)/2.+smalldraw[1] yoff=1.*(big-xs)/2.+xs+mapgsz-smalldraw[2] a=1.*(mapgsz-yoff)/mapgsz b=1.*xoff/mipgsz c=a+1.*xs/mapgsz d=b+1.*ys/mipgsz endif $ ;------------------------------------------------------------ ; In the case where we do a portrait: ;------------------------------------------------------------ else begin if keyword_set(rempli) then begin xs=small ys=big endif else begin if rapportyx le rapportmax then begin xs=small ys=1.*(small-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] if ys gt big then begin xs=1.*(big-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] ys=big endif endif else begin xs=1.*(big-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] ys=big if xs gt small then begin xs=small ys=1.*(small-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] endif endelse endelse xoff=1.*(small-xs)/2.+smalldraw[0] yoff=1.*(big-ys)/2.+smalldraw[1] a=1.*xoff/mipgsz b=1.*yoff/mapgsz c=a+1.*xs/mipgsz d=b+1.*ys/mapgsz xset = xoff yset = yoff endelse ;------------------------------------------------------------ bas=mapgsz*(1-key_portrait)+mipgsz*key_portrait cote=mipgsz*(1-key_portrait)+mapgsz*key_portrait posfenetre=[a,b,c,d]+[ marge[0]/bas, marge[2]/cote $ ,-marge[1]/bas,-marge[3]/cote ] posbar=[a,b,c,d]+[ margebar[0]/bas, margebar[2]/cote $ ,-margebar[1]/bas,(-ys+margebar[3])/cote ] ;------------------------------------------------------------ if keyword_set(key_performance) THEN print, 'temps calibre', systime(1)-tempsun IF NOT keyword_set(key_forgetold) THEN BEGIN @updateold ENDIF return end