function junk = readprops(h)
%READPROPS  Read properties from Response Object into Property Editor

%   Author(s): A. DiVergilio
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.6 $  $Date: 2000/06/14 20:15:13 $

junk = []; %---Temporary fix

%--- Notes: 1) Use localGetField for properties which do not exist for all response objects
%---        2) Use getfont response method for font properties (do not exist in RespStruct)
%---        3) Use getscale response method for axes scale properties (do not exist in RespStruct)

if h.enable_readprops

   %---Response Object
   RespObj = h.Target.UserData;
   RespStruct = get(RespObj,'Undocumented');

   h.Data.ResponseType          = RespStruct.ResponseType;
   h.Data.Title                 = RespStruct.Title;
   h.Data.Xlabel                = RespStruct.Xlabel;
   h.Data.Ylabel                = RespStruct.Ylabel;
   h.Data.XlimMode              = RespStruct.XlimMode;
   h.Data.Xlim                  = RespStruct.Xlim;
   h.Data.YlimMode              = RespStruct.YlimMode;
   h.Data.Ylim                  = RespStruct.Ylim;

   h.Data.FrequencyUnits        = localGetField(RespStruct,'FrequencyUnits');
   if isempty(h.Data.FrequencyUnits)
      h.Data.FrequencyScale     = '';
   else
      h.Data.FrequencyScale     = getscale(RespObj,'FrequencyScale');
   end

   h.Data.MagnitudeUnits        = localGetField(RespStruct,'MagnitudeUnits');
   if isempty(h.Data.MagnitudeUnits)
      h.Data.MagnitudeScale     = '';
   else
      h.Data.MagnitudeScale     = getscale(RespObj,'MagnitudeScale');
   end

   h.Data.PhaseUnits            = localGetField(RespStruct,'PhaseUnits');
   %---Clear Phase Units if bodemag
   if strcmpi(RespStruct.ResponseType,'bodemag')
      h.Data.PhaseUnits         = '';
   end

   h.Data.Grid                  = RespStruct.Grid;
   h.Data.GridLabelType         = localGetField(RespStruct,'GridLabelType');
   h.Data.TitleFontSize         = getfont(RespObj,'Title','FontSize');
   h.Data.TitleFontWeight       = getfont(RespObj,'Title','FontWeight');
   h.Data.TitleFontAngle        = getfont(RespObj,'Title','FontAngle');
   h.Data.XYLabelsFontSize      = getfont(RespObj,'XLabel','FontSize');
   h.Data.XYLabelsFontWeight    = getfont(RespObj,'XLabel','FontWeight');
   h.Data.XYLabelsFontAngle     = getfont(RespObj,'XLabel','FontAngle');
   h.Data.AxesFontSize          = getfont(RespObj,'Axes','FontSize');
   h.Data.AxesFontWeight        = getfont(RespObj,'Axes','FontWeight');
   h.Data.AxesFontAngle         = getfont(RespObj,'Axes','FontAngle');
   h.Data.IOLabelsFontSize      = getfont(RespObj,'IOLabels','FontSize');
   h.Data.IOLabelsFontWeight    = getfont(RespObj,'IOLabels','FontWeight');
   h.Data.IOLabelsFontAngle     = getfont(RespObj,'IOLabels','FontAngle');
   h.Data.AxesForegroundColor   = getcolor(RespObj,'AxesForegroundColor');
   h.Data.PeakResponse          = localGetField(RespStruct,'PeakResponse');
   h.Data.SettlingTime          = localGetField(RespStruct,'SettlingTime');
   h.Data.SettlingTimeThreshold = localGetField(RespStruct,'SettlingTimeThreshold');
   h.Data.RiseTime              = localGetField(RespStruct,'RiseTime');
   h.Data.RiseTimeLimits        = localGetField(RespStruct,'RiseTimeLimits');
   h.Data.SteadyState           = localGetField(RespStruct,'SteadyState');
   h.Data.StabilityMargin       = localGetField(RespStruct,'StabilityMargin');
   h.Data.AllStabilityMargin    = localGetField(RespStruct,'AllStabilityMargin');

   h.Data.UnwrapPhase           = localGetField(RespStruct,'UnwrapPhase');
   %---Clear Phase Wrapping if bodemag
   if strcmpi(RespStruct.ResponseType,'bodemag')
      h.Data.UnwrapPhase        = '';
   end

   %---Clear Stability Margin if not in Viewer
   if ~isfield(RespStruct.UIContextMenu.PlotOptions,'StabilityMargin')   
      h.Data.StabilityMargin    = '';
      h.Data.AllStabilityMargin = '';
   end

   h.Data.InputLabel            = RespStruct.InputLabel;
   h.Data.OutputLabel           = RespStruct.OutputLabel;

   %---Set Property Editor title
   h.GUI.setTitle(sprintf('Property Editor: %s',RespStruct.Title));

end


%%%%%%%%%%%%%%%%%
% localGetField %
%%%%%%%%%%%%%%%%%
function Value = localGetField(Structure,FieldName)
%
%---Since the built-in getfield command won't return [] for
%--- queries on non-existant fields, we break this into 2 cases
if isfield(Structure,FieldName)
   Value = getfield(Structure,FieldName);
else
   Value = '';
end
