mri_updateparent - General GUI data handing for MRI Toolbox Useage: [mri] = mri_updateparent(UserData,focus) 'UserData' is obtained from get(gcbf,'UserData'), where all the necessary parameters and stored for each GUI, including the handles of any GUI parent. 'focus' is a boolean option that switches whether the parent is the current figure (1, default) or not (0). This function returns the mri struct to both the matlab workspace and any direct parent of the GUI calling this function.
0001 function [mri] = mri_updateparent(UserData,focus) 0002 0003 % mri_updateparent - General GUI data handing for MRI Toolbox 0004 % 0005 % Useage: [mri] = mri_updateparent(UserData,focus) 0006 % 0007 % 'UserData' is obtained from get(gcbf,'UserData'), where all 0008 % the necessary parameters and stored for each GUI, including 0009 % the handles of any GUI parent. 0010 % 0011 % 'focus' is a boolean option that switches whether the 0012 % parent is the current figure (1, default) or not (0). 0013 % 0014 % This function returns the mri struct to both the matlab 0015 % workspace and any direct parent of the GUI calling 0016 % this function. 0017 % 0018 0019 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $ 0020 0021 % Licence: GNU GPL, no express or implied warranties 0022 % History: 04/2002, Darren.Weber@flinders.edu.au 0023 % - extracted from individual gui* functions 0024 % 0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0026 0027 if ~exist('focus','var'), focus = 1; end 0028 0029 if isfield(UserData,'parent'), 0030 if isfield(UserData.parent,'gui'), 0031 % Get the userdata from the parent 0032 parent = get(UserData.parent.gui,'UserData'); 0033 if isfield(parent,'mri') & isfield(UserData,'mri'), 0034 % Update the parent mri structure 0035 parent.mri = UserData.mri; 0036 set(UserData.parent.gui,'UserData',parent); 0037 % Make the parent the current figure 0038 end 0039 if focus, 0040 figure(UserData.parent.gui); end 0041 end 0042 end 0043 0044 if isfield(UserData,'mri'), 0045 if ~isempty(UserData.mri), 0046 mri = UserData.mri; 0047 end 0048 end 0049 0050 return