function plotwindow
%
%  Name:   plotwindow
%
%  Usage:  plotwindow
%
%  Starts the  main data plotting and overlaying window
% 

%  Version SWD970730
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This matlab source code was originally     %
% developed as part of "DIAMOND" at          %
% Los Alamos National Laboratory. It may     %
% be copied, modified, and distributed in    %
% any form, provided:                        %
%  a) This notice accompanies the files and  %
%     appears near the top of all source     %
%     code files.                            %
%  b) No payment or commercial services are  %
%     received in exchange for the code.     %
%                                            %
% Original copyright is reserved by the      %
% Regents of the University of California,   %
% in addition to Scott W. Doebling, Phillip  %
% J. Cornwell, Erik G. Straser, and Charles  %
% R. Farrar.                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%

global HANDLES DISPLAY DATA MODES indsvec iaxesvec inds iaxes

%  Show and hide the appropriate controls

hideallbtns
showall(HANDLES.hplotb)

%
%  Setup the buttons and other controls
%

%  Turn off the axis lines on the legend axes
   
set(HANDLES.hplotb(16),'visible','off')
   
%   Configure synthesis button
   
if isempty(MODES),
   set(HANDLES.hplotb(2),'visible','off')
end

set(HANDLES.hplotb(2),'string','Add Synthesis')

%   If no secondary data set, turn off selector

if size(DATA) == 1, 
   set(HANDLES.hplotb(12),'visible','off')
end
  
set(HANDLES.hplotb(12),'string','Add Secondary') 
   
%   Hide the upper/lower split axes and configure the button
   
hideall(HANDLES.hplotb(14))
hideall(HANDLES.hplotb(15))
set(HANDLES.hplotb(7),'string','Upper/Lower')

  
%   Configure the statistics button
   
set(HANDLES.hplotb(5),'string','Add Statistics')   
   
%
%  Define the default DISPLAY plot parameters
%

DISPLAY{1}.haxes = HANDLES.hplotb(13);
DISPLAY{1}.specfun{1} = 'FRF';
DISPLAY{1}.displayfun{1} = 'SISO';
DISPLAY{1}.iyscale  = 'MAG';
DISPLAY{1}.iylog = 1;
DISPLAY{1}.idatafile{1} = 1;
DISPLAY{1}.iavg{1} = 1;   % Number of the average to display
DISPLAY{1}.lnst{1} = '- ';
DISPLAY{1}.lnco{1} = 'y';
DISPLAY{1}.marker{1} = 'none';
DISPLAY{1}.xlim = [DATA{1}.cf - DATA{1}.sp/2 , DATA{1}.cf + DATA{1}.sp/2];
DISPLAY{1}.hlegax = HANDLES.hplotb(16);
DISPLAY{1}.iresp{1} = 1;
DISPLAY{1}.iref{1} = 1;
DISPLAY{1}.lnlab{1} = 'Primary Data';
DISPLAY{1}.hcursor = [];


DISPLAY{1}.ioverlay = 0;

dellegend  %  Delete any stray legend items

indsvec = 1; % Only 1 line is visible on this plot
iaxesvec = 1; % Only 1 axis is visible 

iaxes = 1;   % Default axis is number 1
inds = 1;    % Default plot line is number 1

defspecdatavec(1)  % Define the spectral data vector in DISPLAY
defdisplay(1)      % Apply the display function and the yscale selection to the spectral data vector in DISPLAY
plotdisplay(1)      % Plot the data in the DISPLAY global variable in the display window
plotlegend  % Plot the legend for the data in DISPLAY

%  Configure plot tools based on DISPLAY characteristics

configplttl(1,1)