function varargout = Tool_v7(varargin)
%TOOL_V7 M-file for Tool_v7.fig
%      TOOL_V7, by itself, creates a new TOOL_V7 or raises the existing
%      singleton*.
%
%      H = TOOL_V7 returns the handle to a new TOOL_V7 or the handle to
%      the existing singleton*.
%
%      TOOL_V7('Property','Value',...) creates a new TOOL_V7 using the
%      given property value pairs. Unrecognized properties are passed via
%      varargin to Tool_v7_OpeningFcn.  This calling syntax produces a
%      warning when there is an existing singleton*.
%
%      TOOL_V7('CALLBACK') and TOOL_V7('CALLBACK',hObject,...) call the
%      local function named CALLBACK in TOOL_V7.M with the given input
%      arguments.
%
%      *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 Tool_v7

% Last Modified by GUIDE v2.5 12-Mar-2012 12:44:06

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Tool_v7_OpeningFcn, ...
                   'gui_OutputFcn',  @Tool_v7_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 Tool_v7 is made visible.
function Tool_v7_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   unrecognized PropertyName/PropertyValue pairs from the
%            command line (see VARARGIN)

% Choose default command line output for Tool_v7
handles.output = hObject;
% Kennparameter und dazugehörige POP-UP-Auswahl


     handles.KP_Auswahl ={'Max. Beschleunigung';...
                         'Regelungsdauer';
                         '';
                        }
                    
     set(handles.KP_Auswahl_1,'String',handles.KP_Auswahl,'Value',3); 
     set(handles.KP_Auswahl_2,'String',handles.KP_Auswahl,'Value',3);
         
% Nicht Editierbarkeit der Einheitenfelder
     set(handles.Einheit_1,'Enable','inactive');
     set(handles.Einheit_2,'Enable','inactive');
     
% Nicht Editierbarkeit der Wertefelder am Anfang
     set(handles.Wert1,'Enable','off');
     set(handles.Wert2,'Enable','off');
     
% Laden der Manöver im Pop-Up
        
    handles.Manoeverinhalt = {'' ; ... 
    '1';'2';     
             };
    set(handles.Manoever,'String',handles.Manoeverinhalt);    
   
guidata(hObject, handles);


% UIWAIT makes Kennparametertool_v2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


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


% --- Outputs from this function are returned to the command line.
function varargout = Tool_v7_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 KP_Auswahl_1.
function KP_Auswahl_1_Callback(hObject, eventdata, handles)
str_2=get(handles.KP_Auswahl_2,'String');
ausgabe_2=str_2{get(handles.KP_Auswahl_2,'value')};
str_1=get(handles.KP_Auswahl_1,'String');
ausgabe_1=str_1{get(handles.KP_Auswahl_1,'value')};
if (strcmp(ausgabe_1,''))
    clear handles.Wert1;
    set(handles.Wert1,'Enable','off');
elseif (strcmp(ausgabe_1,ausgabe_2))
    clear handles.Wert1;
    set(handles.Wert1,'Enable','off');
    errordlg('Der Kennparameter wird schon verwendet !', 'Error')
else
    set(handles.Wert1,'Enable','on');
end

switch get(handles.KP_Auswahl_1,'Value')
    case 1
       Einheit='m/s^2';
    case 2
       Einheit='s';
    case 3
       Einheit='  ';
end
set(handles.Einheit_1,'String',{Einheit});

guidata(hObject,handles)


% hObject    handle to KP_Auswahl_1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

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


% --- Executes during object creation, after setting all properties.
function KP_Auswahl_1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to KP_Auswahl_1 (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 Manoever.
function Manoever_Callback(hObject, eventdata, handles)

% hObject    handle to Manoever (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

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


% --- Executes during object creation, after setting all properties.
function Manoever_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Manoever (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 Wert1_Callback(hObject, eventdata, handles)
Wert_1 = str2double(get(hObject,'String'));
% Wenn keine korrekte Eingabe erfolgt ist
if isnan(Wert_1)
    Wert_1 = NaN;
    set(hObject,'String',Wert_1);
    errordlg('Die Eingabe muss eine Zahl sein !', 'Error')
end

handles.Wert1 = Wert_1;
str_2=get(handles.KP_Auswahl_1,'String');
ausgabe=str_2{get(handles.KP_Auswahl_1,'value')};

if (strcmp(ausgabe,'Max. Beschleunigung'))
    set(handles.Aus_Besch,'String',Wert_1);
elseif (strcmp(ausgabe,'Regelungsdauer'))
     set(handles.Aus_Dauer,'String',Wert_1);
end

if (strcmp(ausgabe,''));
     set(handles.Wert1,'String',NaN);
end
guidata(hObject,handles)
% hObject    handle to Wert1 (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 Wert1 as text
%        str2double(get(hObject,'String')) returns contents of Wert1 as a double


% --- Executes during object creation, after setting all properties.
function Wert1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Wert1 (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 Einheit_1_Callback(hObject, eventdata, handles)


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


% --- Executes during object creation, after setting all properties.
function Einheit_1_CreateFcn(hObject, eventdata, handles)

% hObject    handle to Einheit_1 (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 Aus_Besch_Callback(hObject, eventdata, handles)


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


% --- Executes during object creation, after setting all properties.
function Aus_Besch_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Aus_Besch (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 KP_Auswahl_2.
function KP_Auswahl_2_Callback(hObject, eventdata, handles)
str_2=get(handles.KP_Auswahl_2,'String');
ausgabe_2=str_2{get(handles.KP_Auswahl_2,'value')};
str_1=get(handles.KP_Auswahl_1,'String');
ausgabe_1=str_1{get(handles.KP_Auswahl_1,'value')};

if    (strcmp(ausgabe_2,''))
       set(handles.Wert2,'Enable','off');
elseif(strcmp(ausgabe_1,ausgabe_2))
       set(handles.Wert2,'Enable','off');
       errordlg('Der Kennparameter wird schon verwendet !', 'Error')
else
    set(handles.Wert2,'Enable','on');
end

switch get(handles.KP_Auswahl_2,'Value')
    case 1
       Einheit='m/s^2';
    case 2
       Einheit='s';
    case 3
       Einheit='  ';
end

set(handles.Einheit_2,'String',{Einheit});


guidata(hObject,handles)
% hObject    handle to KP_Auswahl_2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

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


% --- Executes during object creation, after setting all properties.
function KP_Auswahl_2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to KP_Auswahl_2 (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 Wert2_Callback(hObject, eventdata, handles)
Wert_2 = str2double(get(hObject,'String'));
if isnan(Wert_2)
    Wert_2 = NaN;
    set(hObject,'String',Wert_2);
    errordlg('Die Eingabe muss eine Zahl sein !', 'Error')
end

handles.Wert2 = Wert_2;
str=get(handles.KP_Auswahl_2,'String');
ausgabe=str{get(handles.KP_Auswahl_2,'value')};

if (strcmp(ausgabe,'Max. Beschleunigung'))
    set(handles.Aus_Besch,'String',Wert_2);
elseif (strcmp(ausgabe,'Regelungsdauer'))
     set(handles.Aus_Dauer,'String',Wert_2);    
end
guidata(hObject,handles)
% hObject    handle to Wert2 (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 Wert2 as text
%        str2double(get(hObject,'String')) returns contents of Wert2 as a double


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


% --- Executes during object creation, after setting all properties.
function Einheit_2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Einheit_2 (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 Aus_Dauer_Callback(hObject, eventdata, handles)
set(handles.Aus_Dauer,'String',Wert_2);
% hObject    handle to Aus_Dauer (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 Aus_Dauer as text
%        str2double(get(hObject,'String')) returns contents of Aus_Dauer as a double


% --- Executes during object creation, after setting all properties.
function Aus_Dauer_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Aus_Dauer (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
