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

% Last Modified by GUIDE v2.5 17-Sep-2006 17:10:28

% Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @gui3_OpeningFcn, ...
                       'gui_OutputFcn',  @gui3_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 gui3 is made visible.
function gui3_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 gui3 (see VARARGIN)
    % Grafik in aktuelle Axes zeichnen
    [X,Y] = meshgrid(-8:.5:8); 
    R = sqrt(X.^2 + Y.^2) + eps;
    handles.Z = sin(R)./R;
    
    % surf-Zeile auskommentieren, 
    % falls MATLAB das POP-UP-Menu nicht anzeigt
    surf(handles.Z)

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

    % Update handles structure
    guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = gui3_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 popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
    val = get( hObject, 'Value' );
    % Liste der Texte im Pop-up-Menü
    str = get( hObject, 'String' );
    
    % Text zu ausgewähltem Menü-Eintrag
    switch str{val}
        % Eintrag surf wurde ausgewählt -> Darstellung surf 
        case 'surf' 
           surf(handles.Z);
           
        % Eintrag mesh wurde ausgewählt -> Darstellung mesh  
        case 'mesh' 
           mesh(handles.Z);
    end
    
    guidata(hObject,handles)

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


% --------------------------------------------------------------------
function datei_menu_ende_Callback(hObject, eventdata, handles)
% hObject    handle to datei_menu_ende (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
    delete(handles.figure1);

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


% --------------------------------------------------------------------
function ansicht_menu_surf_Callback(hObject, eventdata, handles)
% hObject    handle to ansicht_menu_surf (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
    surf(handles.Z); 
    % Wert ebenfalls im Pop-up-Menü ändern 
    set( handles.popupmenu1, 'Value', 1 );

% --------------------------------------------------------------------
function ansicht_menu_mesh_Callback(hObject, eventdata, handles)
% hObject    handle to ansicht_menu_mesh (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
    mesh(handles.Z); 
    % Wert ebenfalls im Pop-up-Menü ändern 
    set( handles.popupmenu1, 'Value', 2 );

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


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


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


% --------------------------------------------------------------------
function surf_item_Callback(hObject, eventdata, handles)
% hObject    handle to surf_item (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
    surf(handles.Z); 
    % Wert ebenfalls im Pop-up-Menü ändern 
    set( handles.popupmenu1, 'Value', 1 );

% --------------------------------------------------------------------
function mesh_item_Callback(hObject, eventdata, handles)
% hObject    handle to mesh_item (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
    mesh(handles.Z); 
    % Wert ebenfalls im Pop-up-Menü ändern 
    set( handles.popupmenu1, 'Value', 2 );

