Home > functions > gui > bm_editor > bm_edit_app > bm_edit_app_update_ui_state.m

bm_edit_app_update_ui_state

PURPOSE ^

update application ui status

SYNOPSIS ^

function [obj] = bm_edit_app_update_ui_state(obj)

DESCRIPTION ^

 update application ui status
 [USAGE]
    [obj] = bm_edit_app_update_ui_state(<obj>);
 [IN]
    obj : bm_edit_app object
 [OUT]
    obj : bm_edit_app object

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [obj] = bm_edit_app_update_ui_state(obj)
0002 % update application ui status
0003 % [USAGE]
0004 %    [obj] = bm_edit_app_update_ui_state(<obj>);
0005 % [IN]
0006 %    obj : bm_edit_app object
0007 % [OUT]
0008 %    obj : bm_edit_app object
0009 %
0010 % Copyright (C) 2011, ATR All Rights Reserved.
0011 % License : New BSD License(see VBMEG_LICENSE.txt)
0012 
0013 %
0014 % --- Previous check
0015 %
0016 if ~exist('obj', 'var'), error('obj is a required parameter.'); end
0017 if ~strcmp(obj.class_type, 'bm_edit_app')
0018     error('class type is invalid.');
0019 end
0020 
0021 %
0022 % --- Main Procedure
0023 %
0024 H = guihandles(obj.h);
0025 
0026 % Material for change ui
0027 all_index = bm_manager_get_bm_list_index(obj.bmm);
0028 selected_index = get(H.brain_model_list_listbox, 'value');
0029 Nselected = length(selected_index);
0030 selected_type_is_all_same = false;
0031 selected_model_info = cell(0);
0032 model_type = [];
0033 
0034 if ~isempty(all_index) && Nselected >= 1
0035     selected_model_info = bm_manager_get_model_info(obj.bmm, selected_index);
0036     if Nselected >= 1
0037        model_type = selected_model_info{1}.class_type;
0038     end
0039     % selected model type check
0040     for k=1:Nselected
0041         if strcmp(selected_model_info{k}.class_type, model_type)
0042             selected_type_is_all_same = true;
0043         else
0044             selected_type_is_all_same = false;
0045             break;
0046         end
0047     end
0048 end
0049 
0050 %%%%%%%%%%%%%%%%%%%%%%%%%%
0051 % Import file push status
0052 %%%%%%%%%%%%%%%%%%%%%%%%%%
0053 Import_button_group = [H.brain_file_push;
0054                        H.head_file_push;
0055                        H.curry_file_push;
0056                        H.face_file_push;
0057                        H.mask_file_push;
0058                        H.spm_norm_file_push];
0059 if length(get(H.analyze_file_edit, 'String')) == 0
0060     set(Import_button_group, 'Enable', 'off');
0061 else
0062     set(Import_button_group, 'Enable', 'on');
0063 end
0064 
0065 
0066 %%%%%%%%%%%%%%%%%%%%%%%%%
0067 % 2D / 3D button status
0068 %%%%%%%%%%%%%%%%%%%%%%%%%
0069 % brain model is NOT loaded.
0070 set(H.view2d_push, 'Enable', 'off');
0071 set(H.view3d_push, 'Enable', 'off');
0072 
0073 if ~isempty(all_index)
0074     % 2D is always on
0075     set(H.view2d_push, 'Enable', 'on');
0076     % change 3d button state
0077     if selected_type_is_all_same && strcmp(model_type, 'mask_image_data')
0078         % Disable 3D menu
0079         set(H.view3d_push, 'Enable', 'off');
0080     else
0081         set(H.view3d_push, 'Enable', 'on');
0082     end
0083 end
0084 
0085 %%%%%%%%%%%%%%%%%%%%%%%%%%
0086 % Processing menu status
0087 %%%%%%%%%%%%%%%%%%%%%%%%%%
0088 % Disable menus
0089 set(H.processing_surf_data_menu, 'Enable', 'off');
0090 set(H.processing_mask_data_menu, 'Enable', 'off');
0091 
0092 if ~isempty(all_index)
0093     if selected_type_is_all_same && strcmp(model_type, 'surf_data')
0094         % Enable surf_data menu
0095         set(H.processing_surf_data_menu, 'Enable', 'on');
0096     elseif selected_type_is_all_same && strcmp(model_type, 'mask_image_data')
0097         % Enable mask_data menu
0098         set(H.processing_mask_data_menu, 'Enable', 'on');
0099     end
0100 end
0101 
0102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
0103 % Processing button status
0104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
0105 surf_group = [H.surf_smooth_push;
0106               H.surf_smooth_expand_push;
0107               H.surf_to_filled_mask_push;
0108               H.separate_surf_push;
0109               H.close_surf_push];
0110 mask_group = [H.morphology_operation_push;
0111               H.surf_extract_push];
0112 set(surf_group, 'Enable', 'off');
0113 set(mask_group, 'Enable', 'off');
0114 
0115 if ~isempty(all_index)
0116     if selected_type_is_all_same && strcmp(model_type, 'surf_data')
0117         set(surf_group, 'Enable', 'on');
0118         % vb_surf_to_filled_mask, vb_surf_smooth_expand
0119         % cannot be applied to unclosed surface.
0120         for k=1:length(selected_model_info)
0121             if(selected_model_info{k}.surf_close) == false
0122                 set(H.surf_to_filled_mask_push, 'Enable', 'off');
0123                 set(H.surf_smooth_expand_push, 'Enable', 'off');
0124                 set(H.close_surf_push, 'Enable', 'on');
0125             else
0126                 set(H.close_surf_push, 'Enable', 'off');
0127             end
0128         end
0129     elseif selected_type_is_all_same && strcmp(model_type, 'mask_image_data')
0130         set(mask_group, 'Enable', 'on');
0131     end
0132 end
0133 
0134 
0135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0136 % rename/delete button status
0137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0138 if isempty(all_index)
0139     set(H.rename_push, 'Enable', 'off');
0140     set(H.delete_push, 'Enable', 'off');
0141 else
0142     set(H.rename_push, 'Enable', 'on');
0143     set(H.delete_push, 'Enable', 'on');
0144 end    
0145 
0146 %%%%%%%%%%%%%%%%%%%%%%
0147 % Export menu status
0148 %%%%%%%%%%%%%%%%%%%%%%
0149 if selected_type_is_all_same && strcmp(model_type, 'surf_data')
0150     set(H.export_push, 'Enable', 'on');
0151 else
0152     set(H.export_push, 'Enable', 'off');
0153 end
0154 
0155 % --- After check
0156 %
0157 if nargout ~= 1
0158     error('function caller should receive obj.');
0159 end

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005