function varargout = gltpda(varargin)
% GLTPDA M-file for gltpda.fig
%      GLTPDA, by itself, creates a new GLTPDA or raises the existing
%      singleton*.
%
%      H = GLTPDA returns the handle to a new GLTPDA or the handle to
%      the existing singleton*.
%
%      GLTPDA('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GLTPDA.M with the given input arguments.
%
%      GLTPDA('Property','Value',...) creates a new GLTPDA or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before gltpda_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to gltpda_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help gltpda

% Last Modified by GUIDE v2.5 15-Feb-2007 10:18:41

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @gltpda_OpeningFcn, ...
                   'gui_OutputFcn',  @gltpda_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before gltpda is made visible.
function gltpda_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to gltpda (see VARARGIN)

% Choose default command line output for gltpda
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes gltpda wait for user response (see UIRESUME)
% uiwait(handles.main);

%----------------------
% Some setup stuff
%----------------------

gltpda_params;

% add functions/ to path
addpath(settings.general.functions_path)

% make settings structure
setappdata(handles.main, 'settings', settings);

% now we have the functions path the rest can go in init()
handles = gltpda_init(handles);




% --- Outputs from this function are returned to the command line.
function varargout = gltpda_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on selection change in aoList.
function aoList_Callback(hObject, eventdata, handles)
% hObject    handle to aoList (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns aoList contents as cell array
%        contents{get(hObject,'Value')} returns selected item from aoList

gltpda_setPlots(handles);


% --- Executes during object creation, after setting all properties.
function aoList_CreateFcn(hObject, eventdata, handles)
% hObject    handle to aoList (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in aoImportBtn.
function aoImportBtn_Callback(hObject, eventdata, handles)
% hObject    handle to aoImportBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

handles = gltpda_aoImport(handles);


% --- Executes on button press in aoPlotBtn.
function aoPlotBtn_Callback(hObject, eventdata, handles)
% hObject    handle to aoPlotBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

figure;
gltpda_aoPlot(handles, gca);


% --- Executes on button press in aoViewHistBtn.
function aoViewHistBtn_Callback(hObject, eventdata, handles)
% hObject    handle to aoViewHistBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

figure
gltpda_plotHist(handles, gca);

% --- Executes on selection change in analysisList.
function analysisList_Callback(hObject, eventdata, handles)
% hObject    handle to analysisList (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns analysisList contents as cell array
%        contents{get(hObject,'Value')} returns selected item from analysisList


% --- Executes during object creation, after setting all properties.
function analysisList_CreateFcn(hObject, eventdata, handles)
% hObject    handle to analysisList (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in aoSaveBtn.
function aoSaveBtn_Callback(hObject, eventdata, handles)
% hObject    handle to aoSaveBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in aoPoolClearBtn.
function aoPoolClearBtn_Callback(hObject, eventdata, handles)
% hObject    handle to aoPoolClearBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in aoDeleteBtn.
function aoDeleteBtn_Callback(hObject, eventdata, handles)
% hObject    handle to aoDeleteBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in analysisParamsEditBtn.
function analysisParamsEditBtn_Callback(hObject, eventdata, handles)
% hObject    handle to analysisParamsEditBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in analysisAnalyseBtn.
function analysisAnalyseBtn_Callback(hObject, eventdata, handles)
% hObject    handle to analysisAnalyseBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

gltpda_analyse(handles);

% --- Executes on button press in analysisPlusBtn.
function analysisPlusBtn_Callback(hObject, eventdata, handles)
% hObject    handle to analysisPlusBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

gltpda_plus(handles);

% --- Executes on button press in analysisMinusBtn.
function analysisMinusBtn_Callback(hObject, eventdata, handles)
% hObject    handle to analysisMinusBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

gltpda_minus(handles);

% --- Executes on button press in analysisTimesBtn.
function analysisTimesBtn_Callback(hObject, eventdata, handles)
% hObject    handle to analysisTimesBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

gltpda_times(handles);

% --- Executes on button press in analysisDivideBtn.
function analysisDivideBtn_Callback(hObject, eventdata, handles)
% hObject    handle to analysisDivideBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

gltpda_divide(handles);

