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

Last change on this file since 163 was 163, checked in by navarro, 18 years ago

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.4 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;
15; @param RAPPORTYX {in}{required}
16; Scale rapport between the length of the y axis and the x one. For example,
17; for an xy map: RAPPORTYX=(lat2-lat1)/(lon2-lon1)
18;
19; @param MARGE {in}{required}{type=vector}
20; Vector made of 4 elements containing the size of the left, right, up and
21; bottom margin having to surround the graph. All is measured in lines of characters.
22;
23; @param MARGEBAR {in}{required}{type=vector}
24; Vector made of 4 elements containing the size of the left, right and bottom
25; margin and -BEWARE- the last element is this time the position of the right up
26; corner, having to surround the color bar. All is measured in lines of characters.
27;
28; @param SMALLDRAW {in}{required}{type=vector}
29; 2 possibilities:
30;    It is vector made of 4 elements giving (in portrait or landscape) the position
31; of the frame in which the drawing must go in. This position is given by coordinates
32; of the 2 corners of the frame: in the left bottom and the right up. It is always
33; (for a postscript or a screen output) express in cm, the origin being the
34; left bottom corner.
35;    It is a vector made of 3 elements giving the number of column to be done in the
36; drawing, the number of line and the number of the case the number have to occupy
37; (see matlab). For example, to do 6 drawing in 3 columns and 2 lines and occupy
38; the 4th case, small=[2,3,4]
39;
40; @keyword REMPLI
41; Force the drawing to occupy the biggest possible place defined by
42; SMALLDRAW without respect the rapport y on x.
43;
44; @keyword YXASPECT
45; Force the rapport y on x to take the value RAPPORTYX*YXASPECT.
46; This keyword can be used in 2 cases:
47;   1) YXASPECT=1 : force RAPPORTYX to be respected otherwise, Calibre take the
48;   initiative to change it a little in the case of the aspect rapport of SMALL
49;   is too different of the one of SMALLDRAW.
50;   2) YXASPECT=n : multiply by n the aspect rapport given by default.
51;   For example in plt, RAPPORTYX is calculated to the reference be orthonormal,
52;   to have a reference where the y axis is 2 time bigger than the x one, YXASPECT=2.
53;       
54; @keyword PORTRAIT       
55; Force the page or the window to be in standing position.
56;
57; @keyword LANDSCAPE       
58; Force the page or the window on the screen to be in lengthened position.
59;
60; @keyword _EXTRA
61; Used to pass your keywords
62;
63; @param POSFENETRE {type=vector}
64; It is a vector made of 4 elements containing the position of the frame
65; containing captions + the graph in normalized coordinates.
66; Comment: to position the drawing, we have to do !p.position=POSFENETRE
67; after the call of calibre.
68;
69; @param POSBAR {type=vector}
70; See POSFENTRE but for the color bar. Same comment to position the color bar, !p.position=POSBAR
71;
72; @uses
73; common.pro
74;
75; @history
76; Sebastien Masson (smasson\@lodyc.jussieu.fr)
77;                       11/12/98
78;
79; @version
80; $Id$
81;-
82;------------------------------------------------------------
83;------------------------------------------------------------
84;------------------------------------------------------------
85pro calibre, rapportyx, marge, margebar, smalldraw, posfenetre, posbar $
86             , REMPLI = rempli, YXASPECT = yxaspect, PORTRAIT = portrait $
87             , LANDSCAPE = lanscape, _extra = ex
88;---------------------------------------------------------
89;
90  compile_opt idl2, strictarrsubs
91;
92@cm_4ps
93  IF NOT keyword_set(key_forgetold) THEN BEGIN
94@updatenew
95@updatekwd
96  ENDIF
97;---------------------------------------------------------
98;------------------------------------------------------------
99   tempsun = systime(1)         ; For key_performance
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 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.