%
%  Name:   dataplot
%
%  Usage:  dataplot
%
%  Starts the  main data plotting and overlaying window
% 
%  Version SWD960816
%
%  Author(s): Phillip Cornwell, cornwell@lanl.gov
%	modified by Scott W. Doebling, doebling@lanl.gov
%
%  Institution: Los Alamos National Laboratory,
%               ESA-EA
%
%  Copyright (c) 1996, The Regents of the University
%       of California. (See top level of code for
%       full copyright statement.)
%

   clear G1syn

   onHndlVector=handact(onHndlVector,hndlMatrix,1);

%==========================================
% Define initial parameters
%=========================================
   
   nds = 1;
	assignG
   filename = filename1;

   if nfunc == 2,
	iylog=0;
   else
	iylog = 1;
   end

   iyscale = 1;

%   If no modes, turn off synthesis buttons
%   If only complex modes, turn on real/complex selector and set to complex

   nomodes;
   if imodes~=1,
      hideall(onHndlVector([2 3])),
   elseif imodesr~=1,
      hideall(onHndlVector(3)),
      ipltcmplx=2;
   elseif imodesr==1,
	ipltcmplx=1;
   end
 
%
%   If no secondary data set, turn off selector
%

   if exist('filename2') ~= 1, 
     set(onHndlVector(12),'visible','off')
   end

 	iresp = str2num(get(hplttl(18),'string'));
	iref = str2num(get(hplttl(20),'string'));

   nn=1;
   mm=1;

   fmin=cf-sp/2;
   fmax=cf+sp/2;
   df=sp/(nlines-1);
   freq=fmin:df:fmax;

     fminm = fmin;
     fmaxm = fmax;

   hideall(onHndlVector(14))
   hideall(onHndlVector(15))


%
%  Define the axes for plottools
%

   haxes = onHndlVector(13);
   hlegax = onHndlVector(16);

   hallaxes = onHndlVector(13:15);


   lnst = '- ';
   lnco = 'y';
	set(hplttl(11),'string','Primary Data')

%
%  Reset the statistics button
%

   set(onHndlVector(5),'string','Add Statistics')

%
%  Turn off the upper/lower popup
%

   hideall(onHndlVector(8))
   
%
%  Make the Initial Plot
%

	set(hplttl(14),'value',iyscale)
	set(hplttl(15),'value',iylog)

        eval(get(hplttl(16),'call'))

%
%  Set the variables for Plottools
%

	flim = get(onHndlVector(13),'xlim');
	ylim = get(onHndlVector(13),'ylim');

	set(hplttl(3),'string',num2str(flim(1)))
	set(hplttl(5),'string',num2str(flim(2)))
	set(hplttl(7),'string',num2str(ylim(1)))
	set(hplttl(9),'string',num2str(ylim(2)))

	yminm = ylim(1);
        ymaxm = ylim(2);

