source: trunk/SRC/ToBeReviewed/PLOTS/DIVERS/placedessin.pro @ 503

Last change on this file since 503 was 503, checked in by smasson, 8 years ago

minor add in placedessin

  • 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; Putting into place of the drawing/ opening of the window or of the PS
5;
6; @categories
7; Utilities
8;
9; @param TYPEDESSIN {type=string}
10; It specify what procedure is called by <pro>placedessin</pro> :
11; 'plt', 'pltz' or 'pltt'
12;
13; @param POSFENETRE {out}{type=vector}
14; containing captions and the graph in normalized coordinates.
15;
16; Comment: To position the drawing, we have to do !p.position=posfenetre
17; after the call of the calibre
18;
19; @param POSBAR {out}{type=vector}
20; Like POSFENETRE but for the color bar.
21;
22; Same comment to position the color bar, !p.position=posbar
23;
24; @param dtasize {in}{optional}{type=2 elements vector}
25; used by <pro>pltv</pro> to specify the size of the array that will be plotted
26; and therefore the default yxaspect to be used.
27;
28; @keyword LANDSCAPE
29; Force the page or the window on the screen to be in lengthened position.
30;
31; @keyword LCT {type=integer}
32; It designate the number of the palette of color we want to use for the plot.
33;       
34; @keyword MAP
35; We use it when we want to do a projection.
36;
37; This keyword can be of two types:
38;     MAP=[P0lat,P0lon,Rot]. For the description of these 3 values (see the online help of <proidl>MAP_SET</proidl>).
39;     /MAP: In this case, map is automatically calculated have the value:
40;          map = [0, (lon1+lon2)/2., 0]
41;
42; Comment 1: A good way to choose the type of the projection we want to do is to have a look at IDL demo:
43;   IDL> demo
44; Then choose "Mapping" and "Global Mapping Demo"
45;
46; Comment 2: By default it is a cylindrical projection which is effectuated (with or without the keyword map).
47; If we want an other projection, MAP must be activated and we have to add the keyword: /nom_projection.
48;
49; For example, for a polar projection centered on the south pole:
50;   IDL> domdef,-180,180,-90,-45
51;   IDL> plt, tab, /stereo,map=[-90,0,0]
52;       
53; @keyword NOCOLORBAR
54; We active it if we do not want the colorbar.
55
56; @keyword NOFILL
57; We active it if we only want contours in black and white with a white background.
58;
59; @keyword NOERASE
60; We active it to make a drawing without creating a new frame.
61;
62; @keyword SMALL
63; Vector composed of 3 or 4 elements, applied to make a drawing on a
64; small portion of a page or screen. It delimit the zone where the drawing will be done.
65;
66; If there is 4 elements then is constituted of coordinates (expressed in cm
67; located from the up and left corner of the page or the window (in portrait
68; like in landscape) of the bottom and left corner and of the up and right
69; corner of the drawing zone.
70;
71; If there is 3 elements, we divide the page or the screen in small[0] columns
72; and in small[1] lines, the drawing is made in the box numbered small[2].
73;
74; The numerotation starting up and left by
75; the number 1 and then, following the writing direction.
76;
77; By default, we make the largest drawing we can do, conserving the aspect
78; ratio (except when REMPLI is activated).
79;
80; @keyword PORTRAIT
81; Force the page or the window to be in standing position.
82;
83; @keyword POST
84; Make a postscript.
85;
86; Only works if we made one drawing on the page.
87;
88; If we make several drawing, use \@<pro>ps</pro>.
89;
90; @keyword REMPLI
91; Force the drawing to fill the whole space defined by small.
92;
93; @keyword WINDOW
94; Number of the window on which we want to do the graph (Allow to open several windows).
95;
96; By default, we open 'IDL0'
97;
98; @keyword CB_TITLE
99; The colorbar's title
100;
101; @keyword CONTOUR
102; If we want to trace contours of a different field than the one
103; whose we have the colored drawing (by example E-P in color and QSR in contours).
104;
105; It must be a field respecting same characteristics than the argument number
106; one of <pro>plt</pro>.
107;
108; @keyword ENDPOINTS
109; keyword specifying that we want to make a vertical cut in diagonal.
110;
111; Then coordinated of extremities of these ones are defined by the 4 elements
112; of the vector ENDPOINTS: [x1,y1,x2,y2] which are coordinates.
113;
114; @keyword VECTEUR {type=vector}
115; It is a structure composed by 2 elements containing the 2 fields U
116; and V of values of the zonal and meridian component of the vector of the fields
117; to draw.
118;
119; These fields can be an array or a structure.
120;
121; For example: vecteur={matriceu:lec('unsurface'),matricev:lec('vnsurface')}
122;
123; Comment: name of elements of vectors are inconsequential.
124;       vecteur={u:lec('unsurface'),v:lec('vnsurface')} is also appropriated.
125;
126; @keyword DIREC
127; 't' 'x' 'y' 'z' 'xys' 'xz' 'yz' 'xyz' 'xt' 'yt' 'zt' 'xyt'
128; 'xzt' 'yzt' 'xyzt' Direction on which do averages
129;
130; @keyword _EXTRA
131; Used to pass keywords
132;
133; @keyword COLOR_C
134; To draw the contour in color instead of in black with filling in color
135;
136; @uses
137; <pro>common</pro>
138;
139; @history
140; Sebastien Masson (smasson\@lodyc.jussieu.fr)
141;                       26/4/1999
142;
143; @version
144; $Id$
145;
146;-
147PRO placedessin, typedessin, posfenetre, posbar, dtasize, BARMARGES=barmarges $
148               , NOCOLORBAR=nocolorbar, NOFILL=nofill, COLOR_c=color_c $
149               , CONTOUR=contour $
150               , VECTEUR=vecteur, PORTRAIT=portrait, LANDSCAPE=landscape $
151               , SMALL=small, MARGES=marges, MAP=map $
152               , REMPLI=REMPLI, POST=post, WINDOW=window $
153               , ENDPOINTS=endpoints, TYPE=type, BASICMARGES=basicmarges $
154               , NOERASE=noerase, LCT=lct, DIREC=direc, CB_TITLE=cb_title $
155               , _EXTRA=ex
156;
157  compile_opt idl2, strictarrsubs
158;
159@cm_4ps
160@cm_4mesh
161  IF NOT keyword_set(key_forgetold) THEN BEGIN
162@updatekwd
163  ENDIF
164;-------------------------------------------------------------
165; 1) Determination of the size of margins (unity=number of lines or columns)
166; to the left, to the right, up and down.
167; BEWARE in margebar, the last element is the right up corner
168; instead of the up margin
169;-------------------------------------------------------------
170  if n_elements(typedessin) EQ 0 then typedessin = 'autre'
171  if keyword_set(basicmarges) then begin
172    marge = 1.*[6, 2, 4, 3]
173    if keyword_set(marges) THEN marge = marge+marges
174    margebar = 1.*[marge[0]+1, marge[1]+1,  marge[2]-8,  marge[2]-6]
175    if keyword_set(barmarges) then margebar = margebar+barmarges
176  ENDIF ELSE BEGIN
177    nocolorbar = keyword_set(nocolorbar) + keyword_set(nofill) + keyword_set(color_c)
178    case typedessin of
179      'plt':marge = 1.*[6, 2, 4, 3]
180      'pltv':marge = 1.*[6, 2, 4, 3]
181      'pltt':marge = 1.*[6+4*(type EQ 'xt'), 2, 4, 4]
182      'pltz':marge = 1.*[6, 2, 4, 3]
183      else:marge = 1.*[6, 2, 4, 3]
184    ENDCASE
185    if keyword_set(marges) THEN marge = marge+marges
186    if NOT keyword_set(barmarges) then barmarges = replicate(0, 4)
187    barmarges[3] = -barmarges[3]
188    margebar = 1.*[marge[0]+1, marge[1]+1, 2, 4]+barmarges
189    marge = marge+[0, 0, 4, 0]*keyword_set(cb_title)
190    IF keyword_set(direc) THEN $
191      marge = marge+[0, 0, 2, 0]*(strlowcase(direc) NE 't')
192    marge = marge+[0, 0, 2, 0]*keyword_set(contour)
193    marge = marge+[0, 0, 2, 0]*keyword_set(vecteur)
194    if n_elements(lon1) NE 0 and n_elements(lon2) NE 0 $
195      and n_elements(lat1) NE 0 and n_elements(lat2) NE 0 then begin
196      if keyword_set(type) then $
197        marge = marge+[0, 3*(type EQ 'yt' AND lon1 NE lon2), 0 $
198                       , 2*(type NE 'yt' AND lat1 NE lat2)]*keyword_set(endpoints) $
199      ELSE marge = marge+[0, 0, 0, 2*(lat1 NE lat2)]*keyword_set(endpoints)
200    endif
201    marge = marge+[0, 0, 2+margebar[3], 0]*(1-keyword_set(nocolorbar))
202  ENDELSE
203;--------------------------------------------------------------
204; Portrait or landscape
205;--------------------------------------------------------------
206  IF NOT keyword_set(noerase) THEN BEGIN
207    CASE 1 OF
208      n_elements(portrait) NE 0:key_portrait = portrait
209      n_elements(landscape) NE 0:key_portrait = 1-landscape
210      ELSE:
211    ENDCASE
212  ENDIF
213;--------------------------------------------------------------
214; What type of aspect ratio(it will be crushed if YXASPECT exist)
215;--------------------------------------------------------------
216  case typedessin of
217    'plt':yaspect = 1.*(lat2-lat1)/(lon2-lon1)
218    'pltt':yaspect = 1.
219    'pltz':yaspect = .5
220    'pltv':yaspect = float(dtasize[1])/float(dtasize[0])
221    ELSE:yaspect = 1.
222  ENDCASE
223;-------------------------------------------------------------
224; 2) calculation of !p.position
225; see calibre.pro.
226;------------------------------------------------------------
227;
228  IF NOT keyword_set(small) then small = [1, 1, 1]
229;
230  if keyword_set(map) then rempli = 1
231;
232  calibre, yaspect, marge, margebar, small, posfenetre, posbar, REMPLI = rempli, _extra = ex
233;
234  !p.position = posfenetre
235;------------------------------------------------------------
236; 3) opening of the graphic window or of the postscript
237;------------------------------------------------------------
238  case 1 of
239; case of the first drawing on a postscript
240    keyword_set(post) AND !d.name ne 'PS':openps, _extra = ex
241; case of the first drawing on a screen
242    keyword_set(post) EQ 0 AND keyword_set(noerase) EQ 0 AND !d.name ne 'PS':BEGIN
243; For the using of \@ps,\@oups and \@vzoom
244      if lmgr(/demo) EQ 0 then BEGIN ; Are we in the demo mode??
245        if !journal NE 0 then journal ; We close the journal if it is open
246        homedir = isadirectory(io = homedir, title = 'Bad definition of homedir')
247        def_myuniquetmpdir
248        journal, myuniquetmpdir+'idlsave.pro' ; We open a new one
249        help, /recall_commands, output = listecommande ; We recuperate the last command
250        listecommande = strmid(strcompress(listecommande[1]), 2)
251        journal, listecommande ; We write it in the journal
252      ENDIF
253      windsize = givewindowsize(_extra = ex)
254      IF !d.name EQ 'Z' THEN BEGIN
255        device, set_resolution = windsize
256        erase
257      ENDIF ELSE BEGIN
258        if not keyword_set(window) then winnumb = 0 ELSE winnumb = window
259        IF n_elements(ex) NE 0 THEN BEGIN
260          exorg = ex
261          IF chkstru(ex, 'colors') THEN ex = extractstru(ex, 'colors')
262        ENDIF
263        window, winnumb, xsize = windsize[0], ysize = windsize[1],  retain = 2, _extra = ex
264        IF n_elements(exorg) NE 0 THEN ex = temporary(exorg)
265      ENDELSE
266    END
267    ELSE:
268  endcase
269;------------------------------------------------------------
270  if n_elements(lct) NE 0 then lct, lct, _extra = ex
271;------------------------------------------------------------
272
273  return
274end
Note: See TracBrowser for help on using the repository browser.