% Program to set up GUI for MODIS HDF plots
% Copyright by Jasmine S Nahorniak, Oregon State University.
% Feb 16 2000

% ***********************************************************************
% open existing GUI
HDFgui
posit=get(gcf,'Position');
set(gcf,'Position',[0 0 posit(3) posit(4)])

GUIbutton('Pushbutton1','WORKING','on');
set(findobj('Tag','Pushbutton1'),'Enable','on');
set(gcf,'Pointer','watch');
pause(0.2)

GUIdefaults;

% **************************************************************************
% implement defaults




% path
set(findobj('Tag','EditText4'),'String',guifilepath);

% list the files in the default path
GUIlistfiles;  

% files
%direc=dir(guifilepath);
%dircell=struct2cell(direc);
%guifiles=dircell(1,3:end);
%set(findobj('Tag','Listbox2'),'Value',1,'String',guifiles)
%clear direc dircell;

% file type
%set(findobj('Tag','PopupMenu2'),'Value',1);

% step size
set(findobj('Tag','EditText5'),'String',guistepsize);
% flag file
set(findobj('Tag','Checkbox2'),'Value',0);

% north latitude
set(findobj('Tag','EditText15'),'String','90');
% south latitude
set(findobj('Tag','EditText17'),'String','-90');
% west longitude
set(findobj('Tag','EditText16'),'String','-180');
% east longitude
set(findobj('Tag','EditText18'),'String','180');


% loaded data
set(findobj('Tag','Listbox1'),'Value',1,'String','');
set(findobj('Tag','Listbox3'),'Value',1,'String','');
set(findobj('Tag','Listbox4'),'Value',1,'String',''); 
% refresh button
GUIbutton('Pushbutton11','refresh','off');
% delete button
GUIbutton('Pushbutton9','delete','off');
set(findobj('Tag','Pushbutton9'),'Enable','off');
% delete all button
GUIbutton('Pushbutton14','delete all','off');
set(findobj('Tag','Pushbutton14'),'Enable','off');
% apply mask button
GUIbutton('Pushbutton16','apply mask','off');
set(findobj('Tag','Pushbutton16'),'Enable','off');
% min
set(findobj('Tag','EditText1'),'String','');
% max
set(findobj('Tag','EditText6'),'String','');
% full range button
GUIbutton('Pushbutton10','full range','off');
set(findobj('Tag','Pushbutton10'),'Enable','off');
% minmax GO button
GUIbutton('Pushbutton4','GO','off');
set(findobj('Tag','Pushbutton4'),'Enable','off');


% figure #
set(findobj('Tag','PopupMenu1'),'String',{'new'},'Value',1);
% north latitude
set(findobj('Tag','EditText8'),'String','90');
% south latitude
set(findobj('Tag','EditText9'),'String','-90');
% west longitude
set(findobj('Tag','EditText10'),'String','-180');
% east longitude
set(findobj('Tag','EditText11'),'String','180');
% center lat
set(findobj('Tag','EditText13'),'String','0');
% center lon
set(findobj('Tag','EditText14'),'String','0');
% title
set(findobj('Tag','EditText2'),'String','');
% makemap GO button
GUIbutton('Pushbutton6','GO','off');
set(findobj('Tag','Pushbutton6'),'Enable','off');
% plot all button
GUIbutton('Pushbutton15','plot all','off');
set(findobj('Tag','Pushbutton15'),'Enable','off');
 
% output data button
GUIbutton('Pushbutton5','output data','off');
set(findobj('Tag','Pushbutton5'),'Enable','off');
% histogram button
GUIbutton('Pushbutton3','histogram','off');
set(findobj('Tag','Pushbutton3'),'Enable','off');
% close figures button
GUIbutton('Pushbutton12','close figures','off');
set(findobj('Tag','Pushbutton12'),'Enable','off');

% figure #
set(findobj('Tag','PopupMenu3'),'String',{'new'},'Value',1);
% X data
set(findobj('Tag','Listbox5'),'String','','Value',1);
% Y data
set(findobj('Tag','Listbox6'),'String','','Value',1);
% x label
set(findobj('Tag','EditText3'),'String','');
% y label
set(findobj('Tag','EditText7'),'String','');
% title
set(findobj('Tag','EditText12'),'String','');
% make 2D plot button
GUIbutton('Pushbutton7','GO','off');
set(findobj('Tag','Pushbutton7'),'Enable','off');

% ******************************************************************
% initialize matrices

if exist('data')==0,
data={};
names={};
files={};
Gmapfig=[];
Glineh=[];
mins=[];
maxs=[];
matrices={};
sizes=[];
region={};
filetype={};
coast=[];
globemovie=[];
l2lat=[];
l2lon=[];
end

% **********************************************************************
% clear GUI parameters
clear guifilepath guistepsize guiprojection guicolormap guicolorbar;
clear guicoastline guiaxislabels guiaxistype guilinetype guilinecolor;
clear guifiles guigrid guicoastdata guioutpath guioutfig posit;
clear guibackgroundcolors guilandcolors guimaskcolors guiaxiscolors;
clear guicolornamelist guicolornumberlist guianimstep guisaveframes;

% LOAD FILE button
GUIbutton('Pushbutton1','GO','off');
set(findobj('Tag','Pushbutton1'),'Enable','off');
set(gcf,'Pointer','arrow');
pause(0.2)
