function ViewerObj = initview(ViewerObj,SystemData,PlotList)
%INITVIEW  Initializes a new LTI Viewer.
%
%   ViewerObj = INITIVIEW(ViewerObj,SystemData).
%
%   See also: LTIVIEW.

%   Authors: K. Gondoly, 1-5-98
%   Revised: A. DiVergilio
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.10 $  $Date: 2000/06/14 20:03:12 $

% Quick property assignment
ViewerObj.SystemNames = SystemData.Names(:);
ViewerObj.Systems = SystemData.Systems(:);

% REVISIT: hack to sync UserData copy (caused failure in calcopt/stabilitymargin
% when importing a system with the margins on)
builtin('set',ViewerObj.Handle,'UserData',ViewerObj);

% Plot styles
if isempty(SystemData.PlotStyles)
   ViewerObj.PlotStyles = struct('Color',cell(length(ViewerObj.Systems),1),...
      'LineStyle',[],'Marker',[],'Legend',[]);
else
   ViewerObj.PlotStyles = SystemData.PlotStyles(:);
end

% SISO Tool hack: configure Viewer as part of INITVIEW to avoid multiple calls
% to PLOTSWITCH and related problems
if nargin>2
    % Adjust plot configuration 
    ViewerObj = arrangeview(ViewerObj,PlotList);
end

% Plot configuration and initialization
ViewerObj = plotswitch(ViewerObj);

% Store updated ViewerObj in figure's UserData
builtin('set',ViewerObj.Handle,'UserData',ViewerObj);

% Status bar
if isempty(ViewerObj.Systems)
   status(ViewerObj,'Use the Import item under the File menu to load an LTI system.',1);
else
   status(ViewerObj,'Right-click on the plot areas for more options.',1);
end

