image thumbnail

Simple Plot, Zoom and FFT GUI

by

 

03 Dec 2007 (Updated )

GUI to select a Simulink output file or workspace variable, m-file outputs or oscilloscope data. Zo

QuestionDialog_v01(varargin)
function varargout = QuestionDialog_v01(varargin)
%=====================================================================
% QUESTIONDIALOG_V01 M-file for QuestionDialog_v01.fig
%=====================================================================
% GUI reduced from GUI HELP example - MODAL
%
%      QUESTIONDIALOG_V01( )  
%  
%     QuestionDialog_v01(  )  
%
% Last Modified by GUIDE v2.5 13-Nov-2007 19:58:51
%=====================================================================
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @QuestionDialog_v01_OpeningFcn, ...
                   'gui_OutputFcn',  @QuestionDialog_v01_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 QuestionDialog_v01 is made visible.
function QuestionDialog_v01_OpeningFcn(hObject,...
                  eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% varargin   command line arguments to QuestionDialog_v01 (see VARARGIN)

% Choose default command line output for QuestionDialog_v01
handles.output = 'NO';

% Update handles structure
guidata(hObject, handles);

%=====================================================================
% Handle dialog figure title and text
 %====================================================================
 set(hObject, 'Name', varargin{2});                                     %  figure title
 set(handles.text1, 'String', varargin{4});                          % message sting
 OldUnits = get(hObject, 'Units');
set(hObject, 'Units', 'pixels');
set(hObject, 'Position', [650 460 320 174]);                         % set position
set(hObject, 'Units', OldUnits);

%=====================================================================
% Show a question icon from dialogicons.mat - variables questIconData
% and questIconMap
%=====================================================================
load dialogicons.mat
 
IconData=questIconData;
questIconMap(256,:) = get(handles.figure1, 'Color');
IconCMap=questIconMap;
Img=image(IconData, 'Parent', handles.axes1);
set(handles.figure1, 'Colormap', IconCMap);
set(handles.axes1, 'Visible', 'off', 'YDir'   , 'reverse'  ,  'XLim'   ,...
                              get(Img,'XData'),  'YLim'   , get(Img,'YData'));
                          
%=====================================================================
 % Make the GUI modal
set(handles.figure1,'WindowStyle','modal')
%=====================================================================

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

%=====================================================================
% --- Outputs from this function are returned to the command line.
%=====================================================================
function varargout = QuestionDialog_v01_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
varargout{1} = handles.output; 
% Get default command line output from handles structure
delete(handles.figure1);                                          % The figure can be deleted now
 
%=====================================================================
% --- Executes on button press YES
%=====================================================================
function YESbutton_Callback(hObject, eventdata, handles)
% hObject    handle to YESbutton (see GCBO)
handles.output = get(hObject,'String');
guidata(hObject, handles);        % Update handles structure
% Use UIRESUME instead of delete because the OutputFcn needs 
uiresume(handles.figure1);        
                                                        % ... to get the updated handles structure.
%=====================================================================
% --- Executes on button press NO
%=====================================================================
function NObutton_Callback(hObject, eventdata, handles)
handles.output = get(hObject,'String');
guidata(hObject, handles);        % Update handles structure 
% Use UIRESUME instead of delete because the OutputFcn needs 
uiresume(handles.figure1);                                            
                                                                                                  
%=====================================================================
% --- Executes when user attempts to close figure1.
%=====================================================================
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
if isequal(get(handles.figure1, 'waitstatus'), 'waiting')   % The GUI is still in  
    uiresume(handles.figure1);                                % ...UIWAIT, us UIRESUME     
else
   delete(handles.figure1);                                       % The GUI is no longer waiting,
end                                                                              % ... just close it

%=====================================================================
% --- Executes on key press over figure with no controls selected.
%=====================================================================
function figure1_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% Check for "enter" or "escape"
if isequal(get(hObject,'CurrentKey'),'escape')  % User said ABORT by hitting 
     handles.output = 'NO';                                     %  .... escape
    guidata(hObject, handles);                               % Update handles structure                                            
    uiresume(handles.figure1);
end    
if isequal(get(hObject,'CurrentKey'),'return')
    uiresume(handles.figure1);
end    

Contact us