source: trunk/MESOSCALE_DEV/PLOT/MINIMAL/fsc/psconfig.pro @ 251

Last change on this file since 251 was 85, checked in by aslmd, 14 years ago

LMD_MM_MARS et LMD_LES_MARS: ajout des routines IDL pour tracer les sorties --> voir mesoscale/PLOT

File size: 15.2 KB
Line 
1;+
2; NAME:
3;   PSCONFIG
4;
5; PURPOSE:
6;
7;   This program is simply a function wrapper for the FSC_PSCONFIG
8;   object program (fsc_psconfig__define.pro). It was written so
9;   that it could serve as a drop-in replacement for the PS_FORM
10;   program it replaces. It calls the object program's graphical
11;   user interface as a modal widget and returns the DEVICE keywords
12;   collected from the form in a form that is appropriate for
13;   configuring the PostScript device.
14;
15;   It is now possible to call the program without a graphical user
16;   interface, thus getting the default keywords directly. This is
17;   appropriate for many applications. Use the NOGUI keyword when
18;   you call the program. For example, like this:
19;
20;       Set_Plot, 'PS'
21;       Device, _Extra=PSConfig(/NoGUI, Filename='myfilename.eps')
22;
23; AUTHOR:
24;
25;   FANNING SOFTWARE CONSULTING
26;   David Fanning, Ph.D.
27;   1645 Sheely Drive
28;   Fort Collins, CO 80526 USA
29;   Phone: 970-221-0438
30;   E-mail: davidf@dfanning.com
31;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
32;
33; CALLING SEQUENCE:
34;
35;   psKeywords = PSConfig()
36;
37; CATEGORY:
38;
39;   Configuring PostScript output.
40;
41; DOCUMENTATION:
42;
43;   Complete documentation for the FSC_PSCONFIG object, including
44;   keyword and method descriptions, and example programs using the object
45;   can be found on the Coyote's Guide to IDL Programming web page:
46;
47;     http://www.dfanning.com/programs/docs/fsc_psconfig.html
48;
49; INPUT:
50;
51;    psConfigObject -- An optional FSC_PSCONFIG object reference can be
52;       passed as an argument to the function. The object is not destroyed
53;       if passed in as an argument.
54;
55;       psConfigObject = Obj_New("FSC_PSCONFIG")
56;       keywords = PSConfig(psConfigObject)
57;
58;    Having the object means that you have an on-going and current record
59;    of exactly how your PostScript device is configured. Be sure to destroy
60;    the object when you are finished with it.
61;
62; KEYWORDS:
63;
64;   NOGUI:   Setting this keyword returns the default keyword settings directly,
65;            without allowing user interaction.
66;
67;   Any keyword accepted by the FSC_PSCONFIG object can be used with
68;   this program. Here are a few of the most popular keywords.
69;
70;   Bits_per_Pixel - The number of image bits saved for each image pixel: 2, 4, or 8. The default is 8.
71;   Color - Set this keyword to select Color PostScript output. Turned on by default.
72;   DefaultSetup - Set this keyword to the "name" of a default style. Current styles (you can easily
73;     create and add your own to the source code) are the following:
74;
75;       "System (Portrait)" - The normal "default" system set-up. Also, "System".
76;       "System (Landcape)" - The normal "default" landscape system set-up.
77;       "Centered (Portrait)" - The window centered on the page. Also, "Center" or "Centered".
78;       "Centered (Landscape)" - The window centered on the landscape page. Also, "Landscape".
79;       "Square (Portrait)" - A square plot, centered on the page.
80;       "Square (Landscape)" - A square plot, centered on the landscape page.
81;       "Figure (Small)" - A small encapsulated figure size, centered on page. Also, "Encapsulated" or "Encapsulate".
82;       "Figure (Large)" - A larger encapsulated figure size, centered on page. Also, "Figure".
83;       "Color (Portrait)" - A "centered" plot, with color turned on. Also, "Color".
84;       "Color (Landscape)" - A "centered" landscape plot, with color turned on.
85;
86;   Directory - Set this keyword to the name of the starting directory. The current directory is used by default.
87;   Encapsulate - Set this keyword to select Encapsulated PostScript output. Turned off by default.
88;   European - Set this keyword to indicate "european" mode (i.e., A4 page and centimeter units). Turned off by default.
89;   Filename - Set thie keyword to the name of the PostScript file. The default is "idl.ps".
90;   Inches - Set this keyword to indicate sizes and offsets are in inches as opposed to centimeters. Set by European keyword by default.
91;   Landscape - Set this keyword to select Landscape page output. Portrait page output is the default.
92;   PageType - Set this keyword to the "type" of page. Possible values are:
93;       "Letter" - 8.5 by 11 inches. (Default, unless the European keyword is set.)
94;       "Legal" - 8.5 by 14 inches.
95;       "Ledger" - 11 by 17 inches.
96;       "A4" - 21.0 by 29.7 centimeters. (Default, if the European keyword is set.)
97;   XOffset - Set this keyword to the X Offset. Uses "System (Portrait)" defaults. (Note: offset calculated from lower-left corner of page.)
98;   XSize - Set this keyword to the X size of the PostScript "window". Uses "System (Portrait)" defaults.
99;   YOffset - Set this keyword to the Y Offset. Uses "System (Portrait)" defaults. (Note: offset calculated from lower-left corner of page.)
100;   YSize - Set this keyword to the Y size of the PostScript "window". Uses "System (Portrait)" defaults.
101;
102;   In addition, the following keywords can be used:
103;
104;   CANCEL -- An output keyword that will be set to 1 if the user
105;   chooses the Cancel button on the form. It will be 0 otherwise.
106;
107;   FONTINFO -- Set this keyword is you wish to have font information
108;   appear on the form. The default is to not include font information.
109;
110;   FONTTYPE -- Set this keyword to a named variable that will indicate
111;   the user's preference for font type. Values will be -1 (Hershey fonts),
112;   0 (hardware fonts), and 1 (true-type fonts). This keyword will always
113;   return -1 unless the FONTINFO keyword has also been set.
114;
115;   GROUP_LEADER -- Set this keyword to a widget identifier of the widget
116;   you wish to be a group leader for this program.
117;
118; EXAMPLE:
119;
120;   To have the user specify PostScript configuration parameters, use
121;   the program like this:
122;
123;     keywords = PSConfig(Cancel=cancelled)
124;     IF cancelled THEN RETURN
125;     thisDevice = !D.Name
126;     Set_Plot, 'PS'
127;     Device, _Extra=keywords
128;     Plot, findgen(11) ; Or whatever graphics commands you use.
129;     Device, /Close_File
130;     Set_Plot, thisDevice
131;
132; OTHER PROGRAMS NEEDED:
133;
134;   The following programs are required to run this one:
135;
136;     fsc_droplist.pro
137;     fsc_fileselect.pro
138;     fsc_inputfield.pro
139;     fsc_plotwindow
140;     fsc_psconfig__define.pro
141;
142; MODIFICATIONS:
143;
144;   Written by David W. Fanning, 31 January 2000.
145;   Added NOGUI keyword to allow default keywords to be obtained without
146;     user interaction. 11 Oct 2004. DWF.
147;   Added CMYK option 24 August 2007. Requires LANGUAGE_LEVEL=2 printer. L. Anderson
148;-
149;###########################################################################
150;
151; LICENSE
152;
153; This software is OSI Certified Open Source Software.
154; OSI Certified is a certification mark of the Open Source Initiative.
155;
156; Copyright (c) 2000-2007 Fanning Software Consulting
157;
158; This software is provided "as-is", without any express or
159; implied warranty. In no event will the authors be held liable
160; for any damages arising from the use of this software.
161;
162; Permission is granted to anyone to use this software for any
163; purpose, including commercial applications, and to alter it and
164; redistribute it freely, subject to the following restrictions:
165;
166; 1. The origin of this software must not be misrepresented; you must
167;    not claim you wrote the original software. If you use this software
168;    in a product, an acknowledgment in the product documentation
169;    would be appreciated, but is not required.
170;
171; 2. Altered source versions must be plainly marked as such, and must
172;    not be misrepresented as being the original software.
173;
174; 3. This notice may not be removed or altered from any source distribution.
175;
176; For more information on Open Source Software, visit the Open Source
177; web site: http://www.opensource.org.
178;
179;###########################################################################
180
181
182FUNCTION PSConfig,                    $
183   psObject,                          $ ; A FSC_PSCONFIG object. If psObject is present, all input keywords
184                                        ; except Group_Leader and FontInfo are ignored.
185   AvantGarde=avantgarde,             $ ; Set this keyword to select the AvantGarde font.
186   Bits_per_Pixel=bits_per_pixel,     $ ; The number of image bits saved for each image pixel: 2, 4, or 8.
187   Bold=bold,                         $ ; Set this keyword to select the Bold font style.
188   BookStyle=book,                    $ ; Set this keyword to select the Book font style.
189   Bkman=bookman,                     $ ; Set this keyword to select the Bookman font.
190   Cancel=cancelled,                  $ ; This output keyword will be set to 1 if the user CANCELs. Set to 0 otherwise.
191   Color=color,                       $ ; Set this keyword to select Color PostScript output.
192   Courier=courier,                   $ ; Set this keyword to select the Courier font.
193   CMYK=cmyk,                         $ ; Set this keyword to use CMYK colors instead of RGB. (Requires LANGUAGE_LEVEL=2 printer.)
194   Debug=debug,                       $ ; Set this keyword to get traceback information when errors are encountered.
195   DefaultSetup=defaultsetup,         $ ; Set this keyword to the "name" of a default style.
196   Demi=demi,                         $ ; Set this keyword to select the Demi font style.
197   Directory=directory,               $ ; Set thie keyword to the name of the starting directory. Current directory by default.
198   Encapsulate=encapsulate,           $ ; Set this keyword to select Encapsulated PostScript output.
199   European=european,                 $ ; Set this keyword to indicate "european" mode (i.e., A4 page and centimeter units).
200   Filename=filename,                 $ ; Set this keyword to the name of the file. Default: 'idl.ps'
201   FontInfo=fontinfo,                 $ ; Set this keyword if you want font information in the FSC_PSCONFIG GUI.
202   FontSize=fontsize,                 $ ; Set this keyword to the font size. Between 6 and 36. Default is 12.
203   FontType=fonttype,                 $ ; An input/output keyword that will have the FontType. Will be !P.Font unless FontInfo is selected.
204   Group_Leader=group_leader,         $ ; The group leader of the PSConfig modal widget.
205   Helvetica=helvetica,               $ ; Set this keyword to select the Helvetica font.
206   Inches=inches,                     $ ; Set this keyword to indicate sizes and offsets are in inches as opposed to centimeters.
207   Italic=italic,                     $ ; Set this keyword to select the Italic font style.
208   Isolatin=isolatin,                 $ ; Set this keyword to select ISOlatin1 encoding.
209   Landscape=landscape,               $ ; Set this keyword to select Landscape output.
210   Light=light,                       $ ; Set this keyword to select the Light font style.
211   Medium=medium,                     $ ; Set this keyword to select the Medium font style.
212   Name=name,                         $ ; The "name" of the object.
213   Narrow=narrow,                     $ ; Set this keyword to select the Narrow font style.
214   NOGUI=nogui, $                     $ ; Return the default keywords directly, without user interaction.
215   Oblique=oblique, $                 $ ; Set this keyword to select the Oblique font style.
216   PageType=pagetype,                 $ ; Set this keyword to the "type" of page: 'Letter', 'Legal', 'Ledger', or 'A4'.
217   Palatino=palatino,                 $ ; Set this keyword to select the Palatino font.
218   Preview=preview,                   $ ; Set this keyword to select Preview mode: 0, 1, or 2.
219   Schoolbook=schoolbook,             $ ; Set this keyword to select the Schoolbook font.
220   Set_Font=set_font,                 $ ; Set this keyword to the name of a font passed to PostScript with Set_Plot keyword.
221   Symbol=symbol,                     $ ; Set this keyword to select the Symbol font.
222   Times=times,                       $ ; Set this keyword to select the Times font.
223   TrueType=truetype,                 $ ; Set this keyword to select True-Type fonts.
224   XOffset=xoffset,                   $ ; Set this keyword to the XOffset. (Note: offset calculated from lower-left corner of page.)
225   XSize=xsize,                       $ ; Set this keyword to the X size of the PostScript "window".
226   YOffset=yoffset,                   $ ; Set this keyword to the YOffset. (Note: offset calculated from lower-left corner of page.)
227   YSize=ysize,                       $ ; Set this keyword to the Y size of the PostScript "window".
228   ZapfChancery=zapfchancery,         $ ; Set this keyword to select the ZapfChancery font.
229   ZapfDingbats=zapfdingbats            ; Set this keyword to select the ZapfDingbats font.
230
231On_Error, 2
232
233IF N_Elements(psObject) EQ 0 THEN BEGIN
234   psObject = Obj_New('FSC_PSCONFIG', $
235      AvantGarde=avantgarde,             $
236      Bits_per_Pixel=bits_per_pixel,     $
237      Bold=bold,                         $
238      BookStyle=book,                    $
239      Bkman=bookman,                     $
240      CMYK=cmyk,                         $
241      Color=color,                       $
242      Courier=courier,                   $
243      Debug=debug,                       $
244      DefaultSetup=defaultsetup,         $
245      Demi=demi,                         $
246      Directory=directory,               $
247      Encapsulate=encapsulate,           $
248      European=european,                 $
249      Filename=filename,                 $
250      FontSize=fontsize,                 $
251      FontType=fonttype,                 $
252      Helvetica=helvetica,               $
253      Inches=inches,                     $
254      Italic=italic,                     $
255      Isolatin=isolatin,                 $
256      Landscape=landscape,               $
257      Light=light,                       $
258      Medium=medium,                     $
259      Name=name,                         $
260      Narrow=narrow,                     $
261      Oblique=oblique,                   $
262      PageType=pagetype,                 $
263      Palatino=palatino,                 $
264      Preview=preview,                   $
265      Schoolbook=schoolbook,             $
266      Set_Font=set_font,                 $
267      Symbol=symbol,                     $
268      Times=times,                       $
269      TrueType=truetype,                 $
270      XOffset=xoffset,                   $
271      XSize=xsize,                       $
272      YOffset=yoffset,                   $
273      YSize=ysize,                       $
274      ZapfChancery=zapfchancery,         $
275      ZapfDingbats=zapfdingbats )
276      create = 1
277ENDIF ELSE BEGIN
278   type = Size(psObject, /Type)
279   IF type NE 11 THEN BEGIN
280      Message, 'Object Reference required as an argument'
281   ENDIF
282   create = 0
283ENDELSE
284
285   ; Call the GUI of the FSC_PSCONFIG object.
286
287IF Keyword_Set(nogui) EQ 0 THEN $
288   psObject->GUI, Group_Leader=group_leader, Cancel=cancelled, FontInfo=Keyword_Set(fontinfo)
289
290   ; Get the PostScript device keywords, along with the font type information.
291
292keywords = psObject->GetKeywords(FontType=fonttype)
293
294   ; If this program created the psObject, destroy it. Otherwise leave it.
295
296IF create THEN Obj_Destroy, psObject
297
298   ; Return the PostScript device keywords.
299
300RETURN, keywords
301END ;----------------------------------------------------------------------
302
303
Note: See TracBrowser for help on using the repository browser.