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

Last change on this file since 367 was 367, checked in by pinsard, 16 years ago

typo and translation

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.1 KB
Line 
1;+
2;
3; @file_comments
4; From a ration 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
7; proportion.
8;
9; @categories
10; Graphics
11;
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)
15;
16; @param marge {in}{required}{type=vector}
17; Vector made of 4 elements containing the size of the left, right, up and
18; bottom margin having to surround the graph.
19; All is measured in lines of characters.
20;
21; @param margebar {in}{required}{type=vector}
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
24; corner, having to surround the color bar. All is measured in lines of characters.
25;
26; @param smalldraw {in}{required}{type=vector}
27; 2 possibilities:
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
32; left bottom corner.
33;    It is a vector made of 3 elements giving the number of column to be done in the
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]
37;
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}
45; See POSFENTERE but for the color bar. Same comment to position the color bar, !p.position=POSBAR
46;
47; @keyword REMPLI
48; Force the drawing to fill the biggest possible place defined by
49; SMALLDRAW without respect the y/x ratio.
50;
51; @keyword YXASPECT
52; Force the y/x ratio to take the value RAPPORTYX*YXASPECT.
53; This keyword can be used in 2 cases:
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
56;   is too different of the one of SMALLDRAW.
57;   2) YXASPECT=n : multiply by n the aspect ratio given by default.
58;   For example in <proidl>plt</proidl>, RAPPORTYX is calculated to the
59;   reference be orthonormal,
60;   to have a reference where the y axis is 2 time bigger than the x one, YXASPECT=2.
61;       
62; @keyword PORTRAIT
63; Force the page or the window to be in standing position.
64;
65; @keyword LANDSCAPE
66; Force the page or the window on the screen to be in lengthened position.
67;
68; @keyword _EXTRA
69; Used to pass keywords
70;
71; @uses
72; common.pro
73;
74; @history
75; Sebastien Masson (smasson\@lodyc.jussieu.fr)
76;                       11/12/98
77;
78; @version
79; $Id$
80;
81;-
82PRO calibre, rapportyx, marge, margebar, smalldraw, posfenetre, posbar $
83             , REMPLI=rempli, YXASPECT=yxaspect, PORTRAIT=portrait $
84             , LANDSCAPE=lanscape, _EXTRA=ex
85;
86  compile_opt idl2, strictarrsubs
87;
88@cm_4ps
89  IF NOT keyword_set(key_forgetold) THEN BEGIN
90@updatenew
91@updatekwd
92  ENDIF
93;---------------------------------------------------------
94;------------------------------------------------------------
95   tempsun = systime(1)         ; For key_performance
96;
97;-------------------------------------------------------------
98   if keyword_set(portrait) then key_portrait=1
99   if keyword_set(landscape) then key_portrait=0
100   if keyword_set(yxaspect) then begin
101      rapportyx=rapportyx*yxaspect
102      test2=0
103   endif else begin
104      yxaspect=1.
105      test2=1
106    ENDELSE
107;
108    mipgsz = min(page_size, max = mapgsz)
109;------------------------------------------------------------
110; choice of Landscape or Portrait
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;-------------------------------------------------------------
117; If smalldraw is count like in matlab
118;-------------------------------------------------------------
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
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
129      numlig = numero/nbrecol
130      numcol = numero-numlig*nbrecol
131      bas = mipgsz*key_portrait+mapgsz*(1-key_portrait)
132      cote = mapgsz*key_portrait+mipgsz*(1-key_portrait)
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]]
136   endif
137;------------------------------------------------------------
138; determination of the size of characters (!p.charsize)
139;------------------------------------------------------------
140   nombre_de_mots_ds_titre = 60.
141   !p.charsize=1.*(smalldraw[2]-smalldraw[0])*!d.x_px_cm / $
142    (nombre_de_mots_ds_titre* !d.y_ch_size)
143   if !p.charsize gt 1 then !p.charsize=1
144;------------------------------------------------------------
145; transfert of margin in cm
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;------------------------------------------------------------
151; definition of the part of the leaf where we draw
152;------------------------------------------------------------
153   if key_portrait eq 0 then begin
154      big=smalldraw[2]-smalldraw[0]
155      small=smalldraw[3]-smalldraw[1]
156   endif else begin
157      small=smalldraw[2]-smalldraw[0]
158      big=smalldraw[3]-smalldraw[1]
159   endelse
160   if key_portrait eq 0 then $
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])
163;------------------------------------------------------------
164; If YXASPECT is not specified, we modify the value of RAPPORTYX
165; to it match better with the leaf's proportions.
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;------------------------------------------------------------
185; in the case where we do a Landscape:
186;------------------------------------------------------------
187   if key_portrait eq 0 then begin
188      if keyword_set(rempli) then begin
189         xs=big
190         ys=small
191      endif else begin
192         if rapportyx le rapportmax then begin
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
198            endif
199         endif else begin
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]
205            endif
206         endelse
207      endelse
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
214   endif $
215;------------------------------------------------------------
216; In the case where we do a portrait:
217;------------------------------------------------------------
218   else begin
219      if keyword_set(rempli) then begin
220         xs=small
221         ys=big
222      endif else begin
223         if rapportyx le rapportmax then begin
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
229            endif
230         endif else begin
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]
236            endif
237         endelse
238      endelse
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
245      xset = xoff
246      yset = yoff
247   endelse
248;------------------------------------------------------------
249   bas=mapgsz*(1-key_portrait)+mipgsz*key_portrait
250   cote=mipgsz*(1-key_portrait)+mapgsz*key_portrait
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;------------------------------------------------------------
256   if keyword_set(key_performance) THEN print, 'temps calibre', systime(1)-tempsun
257
258  IF NOT keyword_set(key_forgetold) THEN BEGIN
259   @updateold
260  ENDIF
261
262   return
263end
Note: See TracBrowser for help on using the repository browser.