function schema
%SCHEMA  Definition of @NicholsPlotOptions 
% Options for @respplot

%  Author(s): C. Buhr
%  Copyright 1986-2005 The MathWorks, Inc.
%  $Revision: 1.1.6.1.2.1 $ $Date: 2005/01/10 00:35:16 $

% Register class 
pkg = findpackage('plotopts');
superclass = findclass(pkg, 'RespPlotOptions');
c = schema.class(pkg, 'NicholsPlotOptions', superclass);

% Public attributes
p = schema.prop(c, 'FreqUnits', 'String');  
p.setfunction = {@LocalSetFreqUnits};
p.FactoryValue = 'rad/sec';

p = schema.prop(c, 'MagLowerLimMode', 'MATLAB array');
p.setfunction = {@LocalSetMagLowerLimMode};
p.FactoryValue = 'auto';

p = schema.prop(c, 'MagLowerLim', 'MATLAB array');
p.setfunction = {@LocalSetMagLowerLim};
p.FactoryValue = 0;

p = schema.prop(c, 'PhaseUnits', 'String');
p.setfunction = {@LocalSetPhaseUnits};
p.FactoryValue = 'deg';

p = schema.prop(c, 'PhaseWrapping', 'on/off'); 
p.FactoryValue = 'off';

p = schema.prop(c, 'PhaseMatching', 'on/off');
p.FactoryValue = 'off';

p = schema.prop(c, 'PhaseMatchingFreq', 'MATLAB array');
p.FactoryValue = 0;

p = schema.prop(c, 'PhaseMatchingValue', 'MATLAB array');
p.FactoryValue = 0;
 
%----------------------LOCAL SET FUCTIONS---------------------------------%

% ------------------------------------------------------------------------%
% Function: LocalSetFreqUnits
% Purpose:  Error handling of setting Frequency Units property
% ------------------------------------------------------------------------%
function valueStored = LocalSetFreqUnits(this, ProposedValue)

if iscell(ProposedValue)
    ProposedValue  = ProposedValue{1};
end
if any(strcmpi(ProposedValue,{'Hz','rad/sec', 'rad/s'}))
    this.PhaseMatchingFreq = unitconv(this.PhaseMatchingFreq,this.FreqUnits,ProposedValue);
    valueStored = ProposedValue;
else
    error(sprintf('%s must be ''rad/s'' or ''Hz''.','FreqUnits'))
end

% ------------------------------------------------------------------------%
% Function: LocalSetPhaseUnits
% Purpose:  Error handling of setting Phase Units property
% ------------------------------------------------------------------------%
function valueStored = LocalSetPhaseUnits(this, ProposedValue)

if iscell(ProposedValue)
    ProposedValue  = ProposedValue{1};
end
if any(strcmpi(ProposedValue,{'deg','rad'}))
    this.PhaseMatchingValue = unitconv(this.PhaseMatchingValue,this.PhaseUnits,ProposedValue);
    valueStored = ProposedValue;
else
    error(sprintf('%s must be ''rad'' or ''deg''.', 'PhaseUnits'))
end

% ------------------------------------------------------------------------%
% Function: LocalSetMagLowerLim
% Purpose:  Error handling of setting MagLowerLim property
% ------------------------------------------------------------------------%
function valueStored = LocalSetMagLowerLim(this, ProposedValue)
if isnumeric(ProposedValue) && isscalar(ProposedValue) && ...
        isreal(ProposedValue) &&  ~(ProposedValue==inf)
    valueStored = ProposedValue;
else
    error(sprintf('%s must be a finite real scalar value.','MagLowerLim'))
end

% ------------------------------------------------------------------------%
% Function: LocalSetMagLowerLimMode
% Purpose:  Error handling of setting Mag lower lim mode property
% ------------------------------------------------------------------------%
function valueStored = LocalSetMagLowerLimMode(this, ProposedValue)

if iscell(ProposedValue)
    ProposedValue  = ProposedValue{1};
end
if any(strcmpi(ProposedValue,{'auto','manual'}))
    valueStored = ProposedValue;
else
    error(sprintf('%s must be ''auto'' or ''manual''.','MagLowerLimMode'))
end
