function out = newconstr(Editor,keyword,CurrentConstr)
%NEWCONSTR  Interface with dialog for creating new constraints.
%
%   LIST = NEWCONSTR(Editor) returns the list of all available
%   constraint types for this editor.
%
%   CONSTR = NEWCONSTR(Editor,TYPE) creates a constraint of the 
%   specified type.

%   Author(s): P. Gahinet
%   Copyright 1986-2004 The MathWorks, Inc. 
%   $Revision: 1.8.4.1.2.1 $  $Date: 2005/01/08 23:41:12 $

ni = nargin;

if ni==1
    % All options
    out = {'Upper Gain Limit';'Lower Gain Limit'};
else
	 PlotAxes = getaxes(Editor.Axes);
    if ni>2 && isa(CurrentConstr,'plotconstr.bodegain')
       % Recycle existing instance
       Constr = CurrentConstr;
    else
       % Create new instance
       Constr = plotconstr.bodegain('Parent',PlotAxes(1), ...
          'PatchColor',Editor.ConstraintColor);
    end
    switch keyword
    case 'Upper Gain Limit'
        Constr.Type = 'upper';
    case 'Lower Gain Limit'
        Constr.Type = 'lower';
    end
    % Set sample time and units 
    Constr.Ts = Editor.LoopData.Ts;
    Constr.setDisplayUnits('XUnits',Editor.Axes.XUnits);
    Constr.setDisplayUnits('YUnits',Editor.Axes.YUnits{1});
    % Make sure constraint is below Nyquist freq.
    if Constr.Ts
       Constr.Frequency = (pi/Constr.Ts) * [0.01 0.1];
    end
	out = Constr;
end


