function varargout = Main_window(varargin)
% MAIN_WINDOW M-file for Main_window.fig
%      MAIN_WINDOW, by itself, creates a new MAIN_WINDOW or raises the existing
%      singleton*.
%
%      H = MAIN_WINDOW returns the handle to a new MAIN_WINDOW or the handle to
%      the existing singleton*.
%
%      MAIN_WINDOW('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MAIN_WINDOW.M with the given input arguments.
%
%      MAIN_WINDOW('Property','Value',...) creates a new MAIN_WINDOW or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Main_window_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Main_window_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 Main_window

% Last Modified by GUIDE v2.5 24-May-2013 03:53:44

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Main_window_OpeningFcn, ...
                   'gui_OutputFcn',  @Main_window_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 Main_window is made visible.
function Main_window_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 Main_window (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Main_window wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% ======================================================
% po spusteni
nacti(hObject, eventdata, handles);


% --- Outputs from this function are returned to the command line.
function varargout = Main_window_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 button press in ZobrazButt.
function ZobrazButt_Callback(hObject, eventdata, handles)
% hObject    handle to ZobrazButt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
nacti(hObject, eventdata, handles);
Rez_spoje();


function PLD_Callback(hObject, eventdata, handles)
% hObject    handle to PLD (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 PLD as text
%        str2double(get(hObject,'String')) returns contents of PLD as a double


% --- Executes during object creation, after setting all properties.
function PLD_CreateFcn(hObject, eventdata, handles)
% hObject    handle to PLD (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function nacti(hObject, eventdata, handles) 
%nacteni z okna pro ovladani
PLD=str2double(get(handles.PLD,'String'));
alfaLD=str2double(get(handles.alfaLD,'String'));
alfaTXA=str2double(get(handles.alfaTXA,'String'));
alfaWT=str2double(get(handles.alfaWT,'String'));
alfaAL=str2double(get(handles.alfaAL,'String'));
Dekv=str2double(get(handles.Dekv,'String'));
fiT=str2double(get(handles.fiT,'String'));
DRXA=str2double(get(handles.DRXA,'String'));
alfaWR=str2double(get(handles.alfaWR,'String'));
alfaRXA=str2double(get(handles.alfaRXA,'String'));
alfaIF=str2double(get(handles.alfaIF,'String'));
alfaPD=str2double(get(handles.alfaPD,'String'));
alfa1cast=str2double(get(handles.alfa1cast,'String'));
SNR0=str2double(get(handles.SNR0,'String'));
NEP=str2double(get(handles.NEP,'String'));
delta=str2double(get(handles.delta,'String'));
lok_str=get(handles.lokalita,'String');
lok_val=get(handles.lokalita,'Value');
Cn2_str=get(handles.Cn2_text,'String');
Cn2_val=get(handles.Cn2_text,'Value');
lambda=str2double(get(handles.lambda,'String'))*10^(-9);

switch Cn2_str{Cn2_val};
    case 'Klidná' 
        Cn2 = 10^(-16);
    case 'Střední' 
        Cn2 = 10^(-14);
    case 'Velmi silná' 
        Cn2 = 10^(-12);
end

assignin('base','PLD',PLD);
assignin('base','alfaLD',alfaLD);
assignin('base','alfaTXA',alfaTXA);
assignin('base','alfaWT',alfaWT);
assignin('base','alfaAL',alfaAL);
assignin('base','Dekv',Dekv);
assignin('base','fiT',fiT);
assignin('base','DRXA',DRXA);
assignin('base','alfaWR',alfaWR);
assignin('base','alfaRXA',alfaRXA);
assignin('base','alfaIF',alfaIF);
assignin('base','alfaPD',alfaPD);
assignin('base','alfa1cast',alfa1cast);
assignin('base','SNR0',SNR0);
assignin('base','NEP',NEP);
assignin('base','delta',delta);
assignin('base','lok_str',lok_str);
assignin('base','lok_val',lok_val);
assignin('base','Cn2',Cn2);
assignin('base','lambda',lambda);


function alfaLD_Callback(hObject, eventdata, handles)
% hObject    handle to alfaLD (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 alfaLD as text
%        str2double(get(hObject,'String')) returns contents of alfaLD as a double


% --- Executes during object creation, after setting all properties.
function alfaLD_CreateFcn(hObject, eventdata, handles)
% hObject    handle to alfaLD (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function alfaTXA_Callback(hObject, eventdata, handles)
% hObject    handle to alfaTXA (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 alfaTXA as text
%        str2double(get(hObject,'String')) returns contents of alfaTXA as a double


% --- Executes during object creation, after setting all properties.
function alfaTXA_CreateFcn(hObject, eventdata, handles)
% hObject    handle to alfaTXA (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function alfaWT_Callback(hObject, eventdata, handles)
% hObject    handle to alfaWT (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 alfaWT as text
%        str2double(get(hObject,'String')) returns contents of alfaWT as a double


% --- Executes during object creation, after setting all properties.
function alfaWT_CreateFcn(hObject, eventdata, handles)
% hObject    handle to alfaWT (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function alfaAL_Callback(hObject, eventdata, handles)
% hObject    handle to alfaAL (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 alfaAL as text
%        str2double(get(hObject,'String')) returns contents of alfaAL as a double


% --- Executes during object creation, after setting all properties.
function alfaAL_CreateFcn(hObject, eventdata, handles)
% hObject    handle to alfaAL (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function Dekv_Callback(hObject, eventdata, handles)
% hObject    handle to Dekv (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 Dekv as text
%        str2double(get(hObject,'String')) returns contents of Dekv as a double


% --- Executes during object creation, after setting all properties.
function Dekv_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Dekv (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function fiT_Callback(hObject, eventdata, handles)
% hObject    handle to fiT (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 fiT as text
%        str2double(get(hObject,'String')) returns contents of fiT as a double


% --- Executes during object creation, after setting all properties.
function fiT_CreateFcn(hObject, eventdata, handles)
% hObject    handle to fiT (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function DRXA_Callback(hObject, eventdata, handles)
% hObject    handle to DRXA (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 DRXA as text
%        str2double(get(hObject,'String')) returns contents of DRXA as a double


% --- Executes during object creation, after setting all properties.
function DRXA_CreateFcn(hObject, eventdata, handles)
% hObject    handle to DRXA (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function alfaWR_Callback(hObject, eventdata, handles)
% hObject    handle to alfaWR (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 alfaWR as text
%        str2double(get(hObject,'String')) returns contents of alfaWR as a double


% --- Executes during object creation, after setting all properties.
function alfaWR_CreateFcn(hObject, eventdata, handles)
% hObject    handle to alfaWR (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function alfaRXA_Callback(hObject, eventdata, handles)
% hObject    handle to alfaRXA (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 alfaRXA as text
%        str2double(get(hObject,'String')) returns contents of alfaRXA as a double


% --- Executes during object creation, after setting all properties.
function alfaRXA_CreateFcn(hObject, eventdata, handles)
% hObject    handle to alfaRXA (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function alfaIF_Callback(hObject, eventdata, handles)
% hObject    handle to alfaIF (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 alfaIF as text
%        str2double(get(hObject,'String')) returns contents of alfaIF as a double


% --- Executes during object creation, after setting all properties.
function alfaIF_CreateFcn(hObject, eventdata, handles)
% hObject    handle to alfaIF (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function alfaPD_Callback(hObject, eventdata, handles)
% hObject    handle to alfaPD (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 alfaPD as text
%        str2double(get(hObject,'String')) returns contents of alfaPD as a double


% --- Executes during object creation, after setting all properties.
function alfaPD_CreateFcn(hObject, eventdata, handles)
% hObject    handle to alfaPD (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function alfa1cast_Callback(hObject, eventdata, handles)
% hObject    handle to alfa1cast (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 alfa1cast as text
%        str2double(get(hObject,'String')) returns contents of alfa1cast as a double


% --- Executes during object creation, after setting all properties.
function alfa1cast_CreateFcn(hObject, eventdata, handles)
% hObject    handle to alfa1cast (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function alfa1turb_Callback(hObject, eventdata, handles)
% hObject    handle to alfa1turb (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 alfa1turb as text
%        str2double(get(hObject,'String')) returns contents of alfa1turb as a double


% --- Executes during object creation, after setting all properties.
function alfa1turb_CreateFcn(hObject, eventdata, handles)
% hObject    handle to alfa1turb (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function SNR0_Callback(hObject, eventdata, handles)
% hObject    handle to SNR0 (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 SNR0 as text
%        str2double(get(hObject,'String')) returns contents of SNR0 as a double


% --- Executes during object creation, after setting all properties.
function SNR0_CreateFcn(hObject, eventdata, handles)
% hObject    handle to SNR0 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function NEP_Callback(hObject, eventdata, handles)
% hObject    handle to NEP (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 NEP as text
%        str2double(get(hObject,'String')) returns contents of NEP as a double


% --- Executes during object creation, after setting all properties.
function NEP_CreateFcn(hObject, eventdata, handles)
% hObject    handle to NEP (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function delta_Callback(hObject, eventdata, handles)
% hObject    handle to delta (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 delta as text
%        str2double(get(hObject,'String')) returns contents of delta as a double


% --- Executes during object creation, after setting all properties.
function delta_CreateFcn(hObject, eventdata, handles)
% hObject    handle to delta (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in lokalita.
function lokalita_Callback(hObject, eventdata, handles)
% hObject    handle to lokalita (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 lokalita contents as cell array
%        contents{get(hObject,'Value')} returns selected item from lokalita


% --- Executes during object creation, after setting all properties.
function lokalita_CreateFcn(hObject, eventdata, handles)
% hObject    handle to lokalita (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in Cn2_text.
function Cn2_text_Callback(hObject, eventdata, handles)
% hObject    handle to Cn2_text (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 Cn2_text contents as cell array
%        contents{get(hObject,'Value')} returns selected item from Cn2_text


% --- Executes during object creation, after setting all properties.
function Cn2_text_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Cn2_text (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function lambda_Callback(hObject, eventdata, handles)
% hObject    handle to lambda (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 lambda as text
%        str2double(get(hObject,'String')) returns contents of lambda as a double


% --- Executes during object creation, after setting all properties.
function lambda_CreateFcn(hObject, eventdata, handles)
% hObject    handle to lambda (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function L12_Callback(hObject, eventdata, handles)
% hObject    handle to L12 (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 L12 as text
%        str2double(get(hObject,'String')) returns contents of L12 as a double


% --- Executes during object creation, after setting all properties.
function L12_CreateFcn(hObject, eventdata, handles)
% hObject    handle to L12 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
