function varargout = lepsgui(varargin)
% LEPSGUI M-file for lepsgui.fig
%      LEPSGUI, by itself, creates a new LEPSGUI or raises the existing
%      singleton*.
%
%      H = LEPSGUI returns the handle to a new LEPSGUI or the handle to
%      the existing singleton*.
%
%      LEPSGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in LEPSGUI.M with the given input arguments.
%
%      LEPSGUI('Property','Value',...) creates a new LEPSGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before lepsgui_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to lepsgui_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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help lepsgui

% Last Modified by GUIDE v2.5 17-Apr-2011 19:38:09

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @lepsgui_OpeningFcn, ...
                   'gui_OutputFcn',  @lepsgui_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 lepsgui is made visible.
function lepsgui_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 lepsgui (see VARARGIN)

% Create the data to plot
a = 1;
b = 1;
c = 1;
theta = pi;
xrabi = 2.30;
xrbci = 0.74;
vrabi = -2.70;
vrbci = 0;
H = 0.424;
listno = 1;
cutoff = -20;
stepno = 300;
mep = false;

handles.current_data = plotlepsgui(a,b,c,theta,xrabi,xrbci,vrabi,vrbci,H,listno,cutoff,stepno,mep);

% Choose default command line output for lepsgui
handles.output = hObject;

% Update handles structure
set(hObject,'toolbar','figure');
guidata(hObject, handles);

% UIWAIT makes lepsgui wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = lepsgui_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 atoma.
function atoma_Callback(hObject, eventdata, handles)
% hObject    handle to atoma (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 atoma contents as cell array
%        contents{get(hObject,'Value')} returns selected item from atoma

input = get(hObject,'Value');
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function atoma_CreateFcn(hObject, eventdata, handles)
% hObject    handle to atoma (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in atomb.
function atomb_Callback(hObject, eventdata, handles)
% hObject    handle to atomb (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 atomb contents as cell array
%        contents{get(hObject,'Value')} returns selected item from atomb

input = get(hObject,'Value');
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function atomb_CreateFcn(hObject, eventdata, handles)
% hObject    handle to atomb (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in atomc.
function atomc_Callback(hObject, eventdata, handles)
% hObject    handle to atomc (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 atomc contents as cell array
%        contents{get(hObject,'Value')} returns selected item from atomc

input = get(hObject,'Value');
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function atomc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to atomc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on slider movement.
function angleabc_Callback(hObject, eventdata, handles)
% hObject    handle to angleabc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% Get the new value for the angleabc from the slider
input = get(hObject, 'Value');
% Set the value of the angle text box to the new value set by slider
deg = input * 180;
set(handles.angletext,'String',deg);
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function angleabc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to angleabc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background, change
%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function distanceab_Callback(hObject, eventdata, handles)
% hObject    handle to distanceab (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of distanceab as text
%        str2double(get(hObject,'String')) returns contents of distanceab
%        as a double

input = get(hObject,'String');
value = str2double(input);
if isnan(value);
    errordlg('You must enter a numeric value','Bad Input','modal')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function distanceab_CreateFcn(hObject, eventdata, handles)
% hObject    handle to distanceab (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function velocityab_Callback(hObject, eventdata, handles)
% hObject    handle to velocityab (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of velocityab as text
%        str2double(get(hObject,'String')) returns contents of velocityab as a double

input = get(hObject,'String');
value = str2double(input);
if isnan(value);
    errordlg('You must enter a numeric value','Bad Input','modal')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function velocityab_CreateFcn(hObject, eventdata, handles)
% hObject    handle to velocityab (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function velocitybc_Callback(hObject, eventdata, handles)
% hObject    handle to velocitybc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of velocitybc as text
%        str2double(get(hObject,'String')) returns contents of velocitybc
%        as a double

input = get(hObject,'String');
value = str2double(input);
if isnan(value);
    errordlg('You must enter a numeric value','Bad Input','modal')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function velocitybc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to velocitybc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function distancebc_Callback(hObject, eventdata, handles)
% hObject    handle to distancebc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of distancebc as text
%        str2double(get(hObject,'String')) returns contents of distancebc as a double

input = get(hObject,'String')
value = str2double(input);
if isnan(value);
    errordlg('You must enter a numeric value','Bad Input','modal')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function distancebc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to distancebc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

% --- Executes on button press in updatebutton.
function updatebutton_Callback(hObject, eventdata, handles)
% hObject    handle to updatebutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

a = get(handles.atoma,'Value');
b = get(handles.atomb,'Value');
c = get(handles.atomc,'Value');
angle = get(handles.angleabc,'Value');
theta = (angle * pi);
xrabi = str2num(get(handles.distanceab,'String'));
xrbci = str2num(get(handles.distancebc,'String'));
vrabi = str2num(get(handles.velocityab,'String'));
vrbci = str2num(get(handles.velocitybc,'String'));
H = str2num(get(handles.hvalue,'String'));
listno = get(handles.graphlist,'Value');
cutoff = str2num(get(handles.cut,'String'));
stepno = str2num(get(handles.steps,'String'));
mep = get(handles.mep,'Value');

handles.current_data = plotlepsgui(a,b,c,theta,xrabi,xrbci,vrabi,vrbci,H,listno,cutoff,stepno,mep);

guidata(hObject, handles);

% --- Executes on selection change in graphlist.
function graphlist_Callback(hObject, eventdata, handles)
% hObject    handle to graphlist (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 graphlist contents as cell array
%        contents{get(hObject,'Value')} returns selected item from graphlist

input = get(hObject,'Value');
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function graphlist_CreateFcn(hObject, eventdata, handles)
% hObject    handle to graphlist (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function angletext_Callback(hObject, eventdata, handles)
% hObject    handle to angletext (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of angletext as text
%        str2double(get(hObject,'String')) returns contents of angletext as a double

% Get the new value for the angleabc text box
NewStrVal = get(hObject, 'String');
NewVal = str2double(NewStrVal);
% Check that the entered value falls within the allowable range
if  isempty(NewVal) || (NewVal<0) || (NewVal>180);
    % Revert to last value, as indicated by angleabc 
    OldVal = get(handles.angleabc,'Value');
    degval = OldVal * 180;
    set(hObject, 'String',degval);
else% Use new angleabc value
    % Set the value of the angleabc to the new value
    rad = NewVal / 180;
    set(handles.angleabc,'Value',rad);
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function angletext_CreateFcn(hObject, eventdata, handles)
% hObject    handle to angletext (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


function hvalue_Callback(hObject, eventdata, handles)
% hObject    handle to hvalue (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of hvalue as text
%        str2double(get(hObject,'String')) returns contents of hvalue as a double

input = get(hObject,'String');
value = str2double(input);
if isnan(value);
    errordlg('You must enter a numeric value','Bad Input','modal')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function hvalue_CreateFcn(hObject, eventdata, handles)
% hObject    handle to hvalue (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


function cut_Callback(hObject, eventdata, handles)
% hObject    handle to cut (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of cut as text
%        str2double(get(hObject,'String')) returns contents of cut as a double
input = get(hObject,'String');
value = str2double(input);
if isnan(value);
    errordlg('You must enter a numeric value','Bad Input','modal')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function cut_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cut (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


function steps_Callback(hObject, eventdata, handles)
% hObject    handle to steps (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of steps as text
%        str2double(get(hObject,'String')) returns contents of steps as a double
input = get(hObject,'String');
value = str2num(input);
if isnan(value);
    errordlg('You must enter a numeric value','Bad Input','modal')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function steps_CreateFcn(hObject, eventdata, handles)
% hObject    handle to steps (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

% --- Executes during object creation, after setting all properties.
function calculation_CreateFcn(hObject, eventdata, handles)
% hObject    handle to steps (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function dynamics_Callback(hObject, eventdata, handles)
if get(handles.hObject,'Value')
    set(handles.mep,'Value',0)
else
    set(handles.mep,'Value',1)
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function dynamics_CreateFcn(hObject, eventdata, handles)
% hObject    handle to steps (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function mep_Callback(hObject, eventdata, handles)
if get(hObject,'Value')
    set(handles.dynamics,'Value',0)
else
    set(handles.dynamics,'Value',1)
end
guidata(hObject,handles);

