function varargout = paramInitial(varargin)
% paramInitial
%   paramInitial opens up a window to enter the model parameters

%   Project: IMPACT
%   Title of Code: paramInitial
%   Relevant additional documentation:
%   Developer: Carlos Gonzalez
%   External Dependencies: NA
%
%   Disclaimer
%   CAUTION: It is strongly recommended that changes to this code
%   should be avoided without first consulting with authors.

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @paramInitial_OpeningFcn, ...
    'gui_OutputFcn',  @paramInitial_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 paramInitial is made visible.
function paramInitial_OpeningFcn(hObject, eventdata, handles, iWecType, filename, filepath, saveFullFile)
% Choose default command line output for paramInitial
handles.output = hObject;

handles.iWecType = iWecType;

handles.h5FilePath = [];
handles.h5FileName = [];

if nargin < 5
    handles.filename =[];
    handles.filepath = [];
    handles.oldModel = []; % loaded wind turbine model
    
    % file for Save&Load button
    % may be different from loaded
    handles.saveFullFile = [];
else
    handles.filename = filename;
    handles.filepath = filepath;
    handles.oldModel = fullfile(filepath, filename);
    
    handles.saveFullFile = saveFullFile;
end

% Update handles structure
guidata(hObject, handles);

addIMPACTIcon(hObject);

if ~isempty(handles.saveFullFile)
    name = get(gcf, 'Name');
    
    if strcmpi(handles.oldModel, handles.saveFullFile)
        set(gcf, 'Name', sprintf('%s - %s (Saved)', name, handles.saveFullFile));
    else
        set(gcf, 'Name', sprintf('%s - %s (Loaded)', name, handles.saveFullFile));        
    end
    
end

if iWecType ==1 || iWecType ==2
    disabledEdits = {'rCogSpar', 'rSparMass',  'rSparIx', 'rSparIy', 'rSparIz', 'rAddedDampingBody2', 'rSparVolume'... % Spar parameters
        'rMooringX', 'rMooringY', 'rMooringZ', ... % Mooring parameters
        'rTetherSpring','rTetherPretension','rTetherLength0'}; % Tether Paramters
    
    for iCont = 1:numel(disabledEdits)
        eval(sprintf('set(handles.edit_%s, ''Enable'', ''off'');', disabledEdits{iCont}));
    end
    set(handles.radiobutton_b2b,'Enable','off');
end

% --- Outputs from this function are returned to the command line.
function varargout = paramInitial_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;


function pushbutton_cancel_Callback(hObject, eventdata, handles)
close(ancestor(hObject,'figure'));

function pushbutton_saveAsLoad_Callback(hObject, eventdata, handles)
saveOrSaveAs(handles);

function edit_rFloaterMass_Callback(hObject, eventdata, handles)


function edit_rFloaterMass_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function edit_rCogFloater_Callback(hObject, eventdata, handles)


function edit_rCogFloater_CreateFcn(hObject, eventdata, handles)

% 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 edit_rFloaterIx_Callback(hObject, eventdata, handles)


function edit_rFloaterIx_CreateFcn(hObject, eventdata, handles)

% 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 edit_rMooringX_Callback(hObject, eventdata, handles)


function edit_rMooringX_CreateFcn(hObject, eventdata, handles)

% 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 edit_rFloaterIy_Callback(hObject, eventdata, handles)


function edit_rFloaterIy_CreateFcn(hObject, eventdata, handles)

% 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 edit_rMooringY_Callback(hObject, eventdata, handles)


function edit_rMooringY_CreateFcn(hObject, eventdata, handles)

% 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 edit_rMooringZ_Callback(hObject, eventdata, handles)


function edit_rMooringZ_CreateFcn(hObject, eventdata, handles)

% 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 edit_Mblade_Callback(hObject, eventdata, handles)


function edit_Mblade_CreateFcn(hObject, eventdata, handles)

% 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 edit_rFloaterIz_Callback(hObject, eventdata, handles)


function edit_rFloaterIz_CreateFcn(hObject, eventdata, handles)

% 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 edit_rDENSITY_Callback(hObject, eventdata, handles)


function edit_rDENSITY_CreateFcn(hObject, eventdata, handles)

% 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 edit_ptoDen_Callback(hObject, eventdata, handles)


function edit_ptoDen_CreateFcn(hObject, eventdata, handles)

% 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 edit_tfPto_Callback(hObject, eventdata, handles)


function edit_tfPto_CreateFcn(hObject, eventdata, handles)

% 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 edit_rTetherSpring_Callback(hObject, eventdata, handles)


function edit_rTetherSpring_CreateFcn(hObject, eventdata, handles)

% 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 edit_rTetherPretension_Callback(hObject, eventdata, handles)


function edit_rTetherPretension_CreateFcn(hObject, eventdata, handles)

% 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 edit_rTetherLength0_Callback(hObject, eventdata, handles)


function edit_rTetherLength0_CreateFcn(hObject, eventdata, handles)

% 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 pushbutton_h5File_Callback(hObject, eventdata, handles)
cd1 = cd;
if ~isempty(handles.h5FilePath) && exist(handles.h5FilePath,'file')
    cd(handles.h5FilePath);
end

[ filename, filepath ] = uigetfile({ '*.h5' },...
    'Select the BEM file');
cd(cd1);

if filename~=0
    handles.h5FilePath = filepath;
    handles.h5FileName = filename;
    guidata(hObject, handles);
    set( handles.text_h5File, { 'String', 'toolTipString' }, { filename, filepath } );
end


function pushbutton_saveLoad_Callback(hObject, eventdata, handles)

if isempty(handles.filename)
    % The file is a new one
    saveOrSaveAs(handles);
else
    [path, file, ext]  = fileparts(handles.saveFullFile);
    saveOrSaveAs(handles, [file, ext], path, handles.saveFullFile);
end




function saveOrSaveAs(handles, filename, pathname, saveFullFile)
% used to save or save as

% if there is only one input, save as mode is to be used
% if there are three inputs, save mode is to be used


% if ~isempty(handles.oldModel)
%     pf = fopen(handles.oldModel,'r');
%     if pf==-1
%        errordlgMLS(sprintf('Cannot open %s', handles.oldModel));
%        return;
%     end
%     while 1
%         tline = fgetl(pf);
%         if ~ischar(tline)
%             break
%         end
%         try
%             eval(tline);
%         catch
%             errordlgMLS(sprintf('Error occurred when reading %s', handles.oldModel));
%             return
%         end
%     end
%     fclose(pf);
% end

%% Floater parameters
rFloaterMass = get( handles.edit_rFloaterMass, 'String' ); 
rCogFloater= get( handles.edit_rCogFloater, 'String' ); 

rFloaterIx = get( handles.edit_rFloaterIx, 'String' ); 
rFloaterIy = get( handles.edit_rFloaterIy, 'String' ); 
rFloaterIz = get( handles.edit_rFloaterIz, 'String' ); 
rFloaterDispVolume = get( handles.edit_rFloaterVolume, 'String' ); 
rAddedDampingBody1 =get( handles.edit_rAddedDampingBody1, 'String' ); 

if handles.iWecType==3 || handles.iWecType==4
    %% Spar parameters
    rSparMass = get( handles.edit_rSparMass, 'String' );
    rCogSpar= get( handles.edit_rCogSpar, 'String' );
    
    rSparIx = get( handles.edit_rSparIx, 'String' );
    rSparIy = get( handles.edit_rSparIy, 'String' );
    rSparIz = get( handles.edit_rSparIz, 'String' );
    rSparDispVolume = get( handles.edit_rSparVolume, 'String' );
    rAddedDampingBody2 =get( handles.edit_rAddedDampingBody2, 'String' );
    
    
    %% Mooring
    rMooringX = get( handles.edit_rMooringX, 'String' );
    rMooringY = get( handles.edit_rMooringY, 'String' );
    rMooringZ = get( handles.edit_rMooringZ, 'String' );
end

%% Aerodynamics parameters
rDENSITY = get( handles.edit_rDENSITY, 'String' ); % water density
if handles.iWecType==3 || handles.iWecType==4
    iBodyToBodyInteraction = get(handles.radiobutton_b2b,'Value');
end

%% Pitch Actuator parameters
tfPto = get( handles.edit_tfPto, 'String' ); % numerator for pitch actuator

%% Operational parameters
if handles.iWecType==3 || handles.iWecType==4
    rTetherSpring = get( handles.edit_rTetherSpring, 'String' ); % Cut out wind speed
    rTetherPretension = get( handles.edit_rTetherPretension, 'String' ); % Nominal generator torque [Nm]
    rTetherLength0 = get( handles.edit_rTetherLength0, 'String' ); % Minimum pitch angle [deg]
end



%%
if nargin < 2
    %% get the filename and pathname for 'save as'
    [filename, pathname] = uiputfile( ...
        {'*.m'; '*.*'}, ...
        'Save as');
    saveFullFile = fullfile(pathname, filename);
end
%% save the parameter file
% If 'Cancel' was selected then return
if filename == 0
    return
end

hParam = ancestor( handles.edit_rFloaterMass, 'figure'); % parameter figure

% Construct the full path and save as *.m file
fullFile = fullfile(pathname,filename);
% copyfile(tempFile, fullFile, 'f');

%%
tempFile = regexprep(fullFile, '\.m', '.tmp');
% create the file in the path
pf = fopen(tempFile, 'w+');
if pf==-1
    errordlgMLS(sprintf('%s cannot be created. ', fullFile));
    return;
end

try
    % the first line of the parameter file
    fprintf( pf, '%%%% IMPACT model file\n\n' );

    % toolbox release
    fprintf( pf, '%% Release\n');
    fprintf( pf, 'rRelease = 1.0;\n\n');
    
    fprintf( pf, '%% WEC type\n');
    fprintf( pf, 'iWecType = %d;\n\n',handles.iWecType);

    %% Constants
    fprintf( pf, '%% Gravity\nrGRAVITY = 9.81;\n\n' );

    fprintf( pf, '%% Water density\nrDENSITY = %s;\n\n',rDENSITY );

    fprintf( pf, '%% Floater\n\n');
    fprintf( pf, '%% Centre of gravity (from mean sea surface)\n' );
    fprintf( pf, 'rCogFloater = %s;\n', rCogFloater);
    
    fprintf( pf, '%% Body masses and Volume\n' );
    fprintf( pf, 'rFloaterMass = %s;\n', rFloaterMass);
    fprintf( pf, 'rFloaterVolume = %s;\n\n', rFloaterDispVolume);
    
    fprintf( pf, '%% Moment of Inertia\n' );  
    fprintf( pf, 'rFloaterIx = %s;\n', rFloaterIx); 
    fprintf( pf, 'rFloaterIy = %s;\n', rFloaterIy); 
    fprintf( pf, 'rFloaterIz = %s;\n', rFloaterIz);     
    fprintf( pf, 'arFloaterInertia = [%s 0 0;0 %s 0;0 0 %s];\n\n', rFloaterIx,rFloaterIy,rFloaterIz);
    
    fprintf( pf, '%% Additional damping\n');
    fprintf( pf, 'rAddedDampingBody1 = %s;\n', rAddedDampingBody1);
    
    if handles.iWecType==3 || handles.iWecType==4
        
        fprintf( pf, '%% Spar\n\n');
        fprintf( pf, '%% Centre of gravity (from mean sea surface)\n' );
        fprintf( pf, 'rCogSpar = %s;\n\n', rCogSpar);
        
        fprintf( pf, '%% Body masses and Volume\n' );
        fprintf( pf, 'rSparMass = %s;\n\n', rSparMass);
        fprintf( pf, 'rSparVolume = %s;\n\n', rSparDispVolume);
        
        fprintf( pf, '%% Moment of Inertia\n' );
        % Spar
        fprintf( pf, 'rSparIx = %s;\n', rSparIx);
        fprintf( pf, 'rSparIy = %s;\n', rSparIy);
        fprintf( pf, 'rSparIz = %s;\n', rSparIz);
        
        fprintf( pf, 'arSparInertia = [%s 0 0;0 %s 0;0 0 %s];\n\n', rSparIx,rSparIy,rSparIz);
        
        fprintf( pf, '%% Additional damping\n');
        fprintf( pf, 'rAddedDampingBody2 = %s;\n\n', rAddedDampingBody2);
        
        fprintf( pf, 'rTetherSpring = %s;\n', rTetherSpring);
        fprintf( pf, 'rTetherPretension = %s;\n', rTetherPretension);
        fprintf( pf, 'rTetherLength0 = %s;\n\n', rTetherLength0);
        
        
        fprintf( pf, '%% Mooring\n' );
        fprintf( pf, 'rMooringX = %s;\n', rMooringX);
        fprintf( pf, 'rMooringY = %s;\n', rMooringY);
        fprintf( pf, 'rMooringZ = %s;\n\n', rMooringZ);
    end
    

    %% PTO paramters
    fprintf( pf, '%% Pto\n' );
    fprintf( pf, 's = tf(''s'');\n' );
    fprintf( pf, 'tfPto = %s;\n\n', tfPto);

    %% Hydrodynamics parameters 
    fprintf( pf, '%% Hydrodyanmics parameters\n' );
    if handles.iWecType==3 || handles.iWecType==4
        fprintf( pf, 'iBodyToBodyInteraction = %1.0f;\n\n', iBodyToBodyInteraction);
    end

    % BEM File
    fprintf( pf, '%% BEM .H5 file\n' );
    fprintf( pf, 'stH5File = ''%s'';\n', fullfile(handles.h5FilePath,handles.h5FileName));
    
    fclose(pf);
catch
    fclose(pf);
    delete(tempFile);
    errordlgMLS(sprintf('Error occurred when creating %s. ', fullFile));
    return;
end

hFigure = findobj( 'tag', 'controller_design' );
handles = guidata(hFigure);

% if ~exist(fullFile,'file')
%     copyfile(tempFile, fullFile, 'f');
%     delete(fullFile); 
% end

copyfile(tempFile, fullFile, 'f');
delete(tempFile); 

[handles, iSuccess] = loadMFile(handles, filename, pathname, saveFullFile);

if iSuccess
    close(hParam); % close the parameter setting figure
end




function edit_ptoDelay_Callback(hObject, eventdata, handles)


function edit_ptoDelay_CreateFcn(hObject, eventdata, handles)

% 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 key press with focus on MLS_paramSetting and no controls selected.
function MLS_paramSetting_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to MLS_paramSetting (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 pushbutton_load.
function pushbutton_load_Callback(hObject, eventdata, handles)

path = fullfile(matlabroot,'toolbox','IMPACT', 'temp');
AllFile = dir(fullfile(path, 'tempModel*.m'));
name = sprintf('tempModel%d.m', numel(AllFile)+1);

handles.filename = name;
handles.filepath = path;
guidata(hObject, handles);
saveOrSaveAs(handles, handles.filename, handles.filepath, handles.saveFullFile);



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


% --- Executes during object creation, after setting all properties.
function edit_rFloaterVolume_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rFloaterVolume (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 edit_rSparMass_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rSparMass (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 edit_rSparMass as text
%        str2double(get(hObject,'String')) returns contents of edit_rSparMass as a double


% --- Executes during object creation, after setting all properties.
function edit_rSparMass_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rSparMass (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 edit_rCogSpar_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rCogSpar (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 edit_rCogSpar as text
%        str2double(get(hObject,'String')) returns contents of edit_rCogSpar as a double


% --- Executes during object creation, after setting all properties.
function edit_rCogSpar_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rCogSpar (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 edit_rSparIx_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rSparIx (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 edit_rSparIx as text
%        str2double(get(hObject,'String')) returns contents of edit_rSparIx as a double


% --- Executes during object creation, after setting all properties.
function edit_rSparIx_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rSparIx (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 edit_rSparIy_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rSparIy (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 edit_rSparIy as text
%        str2double(get(hObject,'String')) returns contents of edit_rSparIy as a double


% --- Executes during object creation, after setting all properties.
function edit_rSparIy_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rSparIy (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 edit_rSparIz_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rSparIz (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 edit_rSparIz as text
%        str2double(get(hObject,'String')) returns contents of edit_rSparIz as a double


% --- Executes during object creation, after setting all properties.
function edit_rSparIz_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rSparIz (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 edit_rSparVolume_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rSparVolume (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 edit_rSparVolume as text
%        str2double(get(hObject,'String')) returns contents of edit_rSparVolume as a double


% --- Executes during object creation, after setting all properties.
function edit_rSparVolume_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rSparVolume (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 edit_rAddedDampingBody1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rAddedDampingBody1 (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 edit_rAddedDampingBody1 as text
%        str2double(get(hObject,'String')) returns contents of edit_rAddedDampingBody1 as a double


% --- Executes during object creation, after setting all properties.
function edit_rAddedDampingBody1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rAddedDampingBody1 (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 edit_rAddedDampingBody2_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rAddedDampingBody2 (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 edit_rAddedDampingBody2 as text
%        str2double(get(hObject,'String')) returns contents of edit_rAddedDampingBody2 as a double


% --- Executes during object creation, after setting all properties.
function edit_rAddedDampingBody2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_rAddedDampingBody2 (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 button press in radiobutton_b2b.
function radiobutton_b2b_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton_b2b (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton_b2b
