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

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

modification of headers : mainly blanks around = sign for keywords in declaration of function and pro

  • 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 rapport of 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 occupy
35; (see matlab). For example, to do 6 drawing in 3 columns and 2 lines and occupy
36; 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 occupy the biggest possible place defined by
49; SMALLDRAW without respect the rapport y on x.
50;
51; @keyword YXASPECT
52; Force the rapport y on x 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 rapport of SMALL
56;   is too different of the one of SMALLDRAW.
57;   2) YXASPECT=n : multiply by n the aspect rapport given by default.
58;   For example in plt, RAPPORTYX is calculated to the reference be orthonormal,
59;   to have a reference where the y axis is 2 time bigger than the x one, YXASPECT=2.
60;       
61; @keyword PORTRAIT
62; Force the page or the window to be in standing position.
63;
64; @keyword LANDSCAPE
65; Force the page or the window on the screen to be in lengthened position.
66;
67; @keyword _EXTRA
68; Used to pass keywords
69;
70; @uses
71; common.pro
72;
73; @history
74; Sebastien Masson (smasson\@lodyc.jussieu.fr)
75;                       11/12/98
76;
77; @version
78; $Id$
79;
80;-
81PRO calibre, rapportyx, marge, margebar, smalldraw, posfenetre, posbar $
82             , REMPLI=rempli, YXASPECT=yxaspect, PORTRAIT=portrait $
83             , LANDSCAPE=lanscape, _EXTRA=ex
84;
85  compile_opt idl2, strictarrsubs
86;
87@cm_4ps
88  IF NOT keyword_set(key_forgetold) THEN BEGIN
89@updatenew
90@updatekwd
91  ENDIF
92;---------------------------------------------------------
93;------------------------------------------------------------
94   tempsun = systime(1)         ; For key_performance
95;
96;-------------------------------------------------------------
97   if keyword_set(portrait) then key_portrait=1
98   if keyword_set(landscape) then key_portrait=0
99   if keyword_set(yxaspect) then begin
100      rapportyx=rapportyx*yxaspect
101      test2=0
102   endif else begin
103      yxaspect=1.
104      test2=1
105    ENDELSE
106;
107    mipgsz = min(page_size, max = mapgsz)
108;------------------------------------------------------------
109; choice of Landscape or Portrait
110;------------------------------------------------------------
111   if n_elements(key_portrait) eq 0  then begin
112      if rapportyx ge 1 then key_portrait=1
113      if rapportyx lt 1 then key_portrait=0
114   endif
115;-------------------------------------------------------------
116; If smalldraw is count like in matlab
117;-------------------------------------------------------------
118   if n_elements(smalldraw) EQ 3  then BEGIN
119     IF smalldraw[2] LT 1 OR smalldraw[2] GT smalldraw[0]*smalldraw[1] THEN BEGIN
120       dummy = report('wrong definition of the small keyword, we stop')
121       stop
122     ENDIF
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
128      numlig = numero/nbrecol
129      numcol = numero-numlig*nbrecol
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]]
135   endif
136;------------------------------------------------------------
137; determination of the size of characters (!p.charsize)
138;------------------------------------------------------------
139   nombre_de_mots_ds_titre = 60.
140   !p.charsize=1.*(smalldraw[2]-smalldraw[0])*!d.x_px_cm / $
141    (nombre_de_mots_ds_titre* !d.y_ch_size)
142   if !p.charsize gt 1 then !p.charsize=1
143;------------------------------------------------------------
144; transfert of margin in cm
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; definition of the part of the leaf where we draw
151;------------------------------------------------------------
152   if key_portrait eq 0 then begin
153      big=smalldraw[2]-smalldraw[0]
154      small=smalldraw[3]-smalldraw[1]
155   endif else begin
156      small=smalldraw[2]-smalldraw[0]
157      big=smalldraw[3]-smalldraw[1]
158   endelse
159   if key_portrait eq 0 then $
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])
162;------------------------------------------------------------
163; If YXASPECT is not specified, we modify the value of RAPPORTYX
164; to it match better with the leaf's proportions.
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;------------------------------------------------------------
184; in the case where we do a Landscape:
185;------------------------------------------------------------
186   if key_portrait eq 0 then begin
187      if keyword_set(rempli) then begin
188         xs=big
189         ys=small
190      endif else begin
191         if rapportyx le rapportmax then begin
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
197            endif
198         endif else begin
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]
204            endif
205         endelse
206      endelse
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
213   endif $
214;------------------------------------------------------------
215; In the case where we do a portrait:
216;------------------------------------------------------------
217   else begin
218      if keyword_set(rempli) then begin
219         xs=small
220         ys=big
221      endif else begin
222         if rapportyx le rapportmax then begin
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
228            endif
229         endif else begin
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]
235            endif
236         endelse
237      endelse
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
244      xset = xoff
245      yset = yoff
246   endelse
247;------------------------------------------------------------
248   bas=mapgsz*(1-key_portrait)+mipgsz*key_portrait
249   cote=mipgsz*(1-key_portrait)+mapgsz*key_portrait
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
256
257  IF NOT keyword_set(key_forgetold) THEN BEGIN
258   @updateold
259  ENDIF
260
261   return
262end
Note: See TracBrowser for help on using the repository browser.