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, B. Eryilmaz
%   Revised: A. Stothert
%   Copyright 1986-2004 The MathWorks, Inc. 
%   $Revision: 1.5.4.1.2.1 $  $Date: 2005/01/08 23:41:14 $

if nargin == 1
   % Return list of valid constraints
   out = {'Phase Margin'; 'Gain Margin'; 'Closed-Loop Peak Gain'; 'Gain-Phase Constraint'};
else
   switch keyword
   case 'Phase Margin'
      Class = 'plotconstr.nicholsphase';
      
   case 'Gain Margin'
      Class = 'plotconstr.nicholsgain';
      
   case 'Closed-Loop Peak Gain'
      Class = 'plotconstr.nicholspeak';
      
   case 'Gain-Phase Constraint'   
      Class = 'plotconstr.nicholslocation';
   end
   
   % Create instance
   if nargin > 2 && isa(CurrentConstr, Class)
      % Recycle existing instance
      Constr = CurrentConstr;  
   else
      % Create new instance
      PlotAxes = getaxes(Editor.Axes);
      Constr = feval(Class,'Parent',PlotAxes,'PatchColor',Editor.ConstraintColor);
      Constr.setDisplayUnits('XUnits',Editor.Axes.XUnits);
      Constr.setDisplayUnits('YUnits','dB');
   end
   out = Constr;
end
