source: trunk/SRC/ToBeReviewed/POSTSCRIPT/calibre.pro @ 494

Last change on this file since 494 was 494, checked in by pinsard, 10 years ago

fix some typos in code lines

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