function schema
%SCHEMA  Definition of @BodePlotOptions 

%  Author(s): C. Buhr
%  Copyright 1986-2004 The MathWorks, Inc.
%  $Revision: 1.1.6.1 $ $Date: 2004/12/26 21:51:54 $

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

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

p = schema.prop(c, 'FreqScale', 'MATLAB array');
p.setfunction = {@LocalSetScale, 'FreqScale'};
p.FactoryValue = 'log';

p = schema.prop(c, 'MagUnits', 'MATLAB array');
p.setfunction = {@LocalSetMagUnits};
p.FactoryValue = 'dB';

p = schema.prop(c, 'MagScale', 'MATLAB array');
p.setfunction = {@LocalSetScale, 'MagScale'};
p.FactoryValue = 'linear';

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

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', 'MATLAB array');
p.setfunction = {@LocalSetPhaseUnits};
p.FactoryValue = 'deg';

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

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', 'double');
p.FactoryValue = 0;

p = schema.prop(c, 'PhaseMatchingValue', 'double');
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: LocalSetFreqScale
% Purpose:  Error handling of setting Frequency and Magnitude Scale property
% ------------------------------------------------------------------------%
function valueStored = LocalSetScale(this, ProposedValue, Prop)

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


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

if iscell(ProposedValue)
    ProposedValue  = ProposedValue{1};
end
if any(strcmpi(ProposedValue,{'dB','abs'}))
    this.MagLowerLim = unitconv(this.MagLowerLim,this.MagUnits,ProposedValue);
    valueStored = ProposedValue;
else
     error(sprintf('%s must be ''dB'' or ''abs''.','MagUnits'))
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
