Home > atmlab > geoplots > gmt > gmtlab.m

gmtlab

PURPOSE ^

GMTLAB Handling of GMTLAB settings.

SYNOPSIS ^

function value = gmtlab( varargin )

DESCRIPTION ^

 GMTLAB   Handling of GMTLAB settings.

   This function is based on *prstnt_struct* and for general help see 
   the on-line help for that function. 

   Existing fields, and possible settings, are listed below. 

   For adding personal settings at startup, see the file CONFIGURE. To 
   add or change settings after startup, follow the example below. 

   To check all present settings
      gmtlab;

   A specific setting is obtained as
      value = GMTLAB( 'PDFVIEWER' );

   To set a field to a specic value
      GMTLAB( 'PDFVIEWER', 'xpdf' );

   To set all fields to default
      GMTLAB( 'defaults' );

 FORMAT   value = gmtlab( [varargin] )
        
 OUT   value      Setting, if a field is selected. See further 
                  *prstnt_struct*.
 OPT   varargin   Field, field and setting or any option supported by
                  *prstnt_struct*.

----------------------------------------------------------------------------
 OPEN_COMMAND  

 General command to open files with. e.g. gmtlab('OPEN_COMMAND','gnome-open') 
 ---------------------------------------------------------------------------
 OUTDIR

 Directory to output files from created by gmtlab
 ---------------------------------------------------------------------------
 PDFVIEWER

 Command to view PDF files.
----------------------------------------------------------------------------
 PSVIEWER

 Command to view PS or EPS files.
----------------------------------------------------------------------------

 VERBOSITY
 
 The verbosity of Atmlab (gmtlab) functions.  
 Functions writing to the screen set a report level for each output. If the
 the set report level is higher than VERBOSITY, the output is ignored.
 Output obeying this setting is most easily produced with the function *out*.
 Functions can also use VERBOSITY to decide if figures shall be produced
 (which is most easily checked by using *out*).
----------------------------------------------------------------------------

 Created by Salomon Eliasson based entirely on atmlab.m by Patrick Eriksson.
 $Id: gmtlab.m 6920 2011-05-06 12:10:24Z olemke $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

DOWNLOAD ^

gmtlab.m

SOURCE CODE ^

0001 % GMTLAB   Handling of GMTLAB settings.
0002 %
0003 %   This function is based on *prstnt_struct* and for general help see
0004 %   the on-line help for that function.
0005 %
0006 %   Existing fields, and possible settings, are listed below.
0007 %
0008 %   For adding personal settings at startup, see the file CONFIGURE. To
0009 %   add or change settings after startup, follow the example below.
0010 %
0011 %   To check all present settings
0012 %      gmtlab;
0013 %
0014 %   A specific setting is obtained as
0015 %      value = GMTLAB( 'PDFVIEWER' );
0016 %
0017 %   To set a field to a specic value
0018 %      GMTLAB( 'PDFVIEWER', 'xpdf' );
0019 %
0020 %   To set all fields to default
0021 %      GMTLAB( 'defaults' );
0022 %
0023 % FORMAT   value = gmtlab( [varargin] )
0024 %
0025 % OUT   value      Setting, if a field is selected. See further
0026 %                  *prstnt_struct*.
0027 % OPT   varargin   Field, field and setting or any option supported by
0028 %                  *prstnt_struct*.
0029 %
0030 %----------------------------------------------------------------------------
0031 % OPEN_COMMAND
0032 %
0033 % General command to open files with. e.g. gmtlab('OPEN_COMMAND','gnome-open')
0034 % ---------------------------------------------------------------------------
0035 % OUTDIR
0036 %
0037 % Directory to output files from created by gmtlab
0038 % ---------------------------------------------------------------------------
0039 % PDFVIEWER
0040 %
0041 % Command to view PDF files.
0042 %----------------------------------------------------------------------------
0043 % PSVIEWER
0044 %
0045 % Command to view PS or EPS files.
0046 %----------------------------------------------------------------------------
0047 %
0048 % VERBOSITY
0049 %
0050 % The verbosity of Atmlab (gmtlab) functions.
0051 % Functions writing to the screen set a report level for each output. If the
0052 % the set report level is higher than VERBOSITY, the output is ignored.
0053 % Output obeying this setting is most easily produced with the function *out*.
0054 % Functions can also use VERBOSITY to decide if figures shall be produced
0055 % (which is most easily checked by using *out*).
0056 %----------------------------------------------------------------------------
0057 %
0058 % Created by Salomon Eliasson based entirely on atmlab.m by Patrick Eriksson.
0059 % $Id: gmtlab.m 6920 2011-05-06 12:10:24Z olemke $
0060 
0061 function value = gmtlab( varargin )
0062             
0063 persistent B
0064 
0065 if ~isempty(varargin) && iscell(varargin{1})
0066     [B,value] = gmt_prstnt_struct( B, @gmtlab_defs, varargin{:} );
0067 else
0068     [B,value] = gmt_prstnt_struct( B, @gmtlab_defs, varargin );
0069 end
0070 
0071 %%%%%%%%%%%%%%%%
0072 % SUBFUNCTIONS
0073 %
0074 function B = gmtlab_defs
0075 %% gmtlab_defs
0076 B.OPEN_COMMAND      = NaN;
0077 B.OUTDIR            = atmlab('WORK_AREA');
0078 B.PDFVIEWER         = NaN;
0079 B.PSVIEWER          = NaN;
0080 B.VERBOSITY         = 0;
0081 
0082 function [A,value] = gmt_prstnt_struct( A, def_fun, varargin )
0083 %% gmt_prstnt_struct
0084 % More or less cloned from prstnt_struct created by Patrick Eriksson in atmlab.
0085 
0086 if isempty( A )
0087   A = feval( def_fun );
0088 end
0089 
0090 %=== As this function is called with a varargin argument, we have to extract
0091 %=== varargin as given to the calling function.
0092 %
0093 varg = varargin{1};
0094 value = [];
0095 
0096 switch length( varg )
0097   case 0
0098     value = A;
0099   case 1
0100     if strcmp( varg{1}, 'defaults' )
0101       A = feval( def_fun );
0102      else
0103       if ~isfield( A,upper(varg{1}))
0104           error('gmtlab:input:undefined', ...
0105             'The field %s is not defined',upper(varg{1})); 
0106       end
0107       value = A.(upper(varg{1}));
0108     end
0109   case 2
0110       if ~isfield( A, upper(varg{1}))
0111           error('gmtlab:input:undefined','The field %s is not defined.',upper(varg{1}));
0112       end
0113       A.(upper(varg{1})) = varg{2};
0114       value = varg{2};
0115   otherwise
0116     error('gmtlab:input','Too many input arguments.');
0117 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005