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

Last change on this file since 226 was 226, checked in by pinsard, 17 years ago

corrections of some misspellings in some *.pro

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