Home > functions > job > job_plot_currentmap_dir > job_plot_cmap_setting_dlg_is_requirement_filled.m

job_plot_cmap_setting_dlg_is_requirement_filled

PURPOSE ^

return check result that userinput fill the requirement.

SYNOPSIS ^

function [cond] = job_plot_cmap_setting_dlg_is_requirement_filled(fig)

DESCRIPTION ^

 return check result that userinput fill the requirement.
 [USAGE]
    [cond] = job_plot_cmap_setting_dlg_is_requirement_filled(fig);
 [IN]
    fig : figure handle
 [OUT]
    cond : user input fill the requirement? <<bool>>
           = true  : fill the requirement.
           = false : not fill the requirement.

 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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [cond] = job_plot_cmap_setting_dlg_is_requirement_filled(fig)
0002 % return check result that userinput fill the requirement.
0003 % [USAGE]
0004 %    [cond] = job_plot_cmap_setting_dlg_is_requirement_filled(fig);
0005 % [IN]
0006 %    fig : figure handle
0007 % [OUT]
0008 %    cond : user input fill the requirement? <<bool>>
0009 %           = true  : fill the requirement.
0010 %           = false : not fill the requirement.
0011 %
0012 % Copyright (C) 2011, ATR All Rights Reserved.
0013 % License : New BSD License(see VBMEG_LICENSE.txt)
0014 
0015 %
0016 % --- Previous check
0017 %
0018 cond = false;
0019 if ~ishandle(fig) || isempty(fig)
0020     error('Specified figure is invalid.');
0021 end
0022 
0023 %
0024 % --- Main Procedure
0025 %
0026 private_data = guidata(fig);
0027 if isempty(private_data), return, end
0028 
0029 H = guihandles(fig);
0030 
0031 % which is required? (current or tf) file
0032 if get(H.data_file_current_radiobutton, 'Value')
0033     view_mode = 'current';
0034 elseif get(H.data_file_tf_radiobutton, 'Value')
0035     view_mode = 'tf';
0036 else
0037     error('Specified view mode is unknown.');
0038 end
0039 
0040 % required parameter
0041 mode = private_data.mode;
0042 
0043 % already loaded file
0044 file_on_app = private_data.file_on_app;
0045 
0046 % requirement check
0047 cond = true;
0048 
0049 % case : brain_file is required(always true)
0050 brain_is_required = true;
0051 brain_update = get(H.brain_file_update_checkbox, 'Value');
0052 brain_already_read   = bitget(file_on_app, 1);
0053 brain_file = get(H.brain_file_edit, 'String');
0054 set_error_msg_to_info_msgbox(H.info_edit, 'brain_file', OFF);
0055 if brain_is_required
0056     if brain_update && is_file_exist(brain_file)
0057         % ready to read brain_file(No problem)
0058     elseif brain_already_read && brain_update == false
0059         % brain_file is already read(No problem)
0060     else
0061         % Problem
0062         cond = false;
0063         set_error_msg_to_info_msgbox(H.info_edit, 'brain_file', ON, brain_file);
0064     end
0065 end
0066 
0067 
0068 curr_tf_mode = bitget(mode, 1);
0069 current_is_required = curr_tf_mode && strcmp(view_mode, 'current');
0070 % case : current_file is required.
0071 current_update = get(H.current_file_update_checkbox, 'Value');
0072 current_already_read = bitget(file_on_app, 4);
0073 current_file = get(H.current_file_edit, 'String');
0074 
0075 % case : tf_file is required.
0076 tf_is_required = curr_tf_mode && strcmp(view_mode, 'tf');
0077 tf_update = get(H.tf_file_update_checkbox, 'Value');
0078 tf_already_read = bitget(file_on_app, 5);
0079 tf_file = get(H.tf_file_edit, 'String');
0080 
0081 set_error_msg_to_info_msgbox(H.info_edit, 'current_file', OFF);
0082 set_error_msg_to_info_msgbox(H.info_edit, 'tf_file', OFF);
0083 if current_is_required
0084     if current_update && is_file_exist(current_file)
0085         % ready to read current_file(No problem)
0086     elseif current_already_read && current_update == false
0087         % current_file is already read(No problem)
0088     else
0089         % Problem
0090         cond = false;
0091         set_error_msg_to_info_msgbox(H.info_edit, 'current_file', ON, current_file);
0092     end
0093 elseif tf_is_required
0094     if tf_update && is_file_exist(tf_file)
0095         % ready to read tf_file(No problem)
0096     elseif tf_already_read && tf_update == false
0097         % tf_file is already read(No problem)
0098     else
0099         % Problem
0100         cond = false;
0101         set_error_msg_to_info_msgbox(H.info_edit, 'tf_file', ON, tf_file);
0102     end
0103 end
0104 
0105 % case : area_file is required.
0106 area_is_required = bitget(mode, 2);
0107 area_update = get(H.area_file_update_checkbox, 'Value');
0108 area_already_read = bitget(file_on_app, 2);
0109 area_file = get(H.area_file_edit, 'String');
0110 set_error_msg_to_info_msgbox(H.info_edit, 'area_file', OFF);
0111 if area_is_required
0112     if area_update && is_file_exist(area_file)
0113         % ready to read area_file(No problem)
0114     elseif area_already_read && area_update == false
0115         % area_file is already read(No problem)
0116     else
0117         % Problem
0118         cond = false;
0119         set_error_msg_to_info_msgbox(H.info_edit, 'area_file', ON, area_file);
0120     end
0121 elseif area_update && ~is_file_exist(area_file)
0122     % Problem
0123     cond = false;
0124     set_error_msg_to_info_msgbox(H.info_edit, 'area_file', ON, area_file);
0125 end
0126 
0127 % case : act_file is required.
0128 act_is_required = bitget(mode, 3);
0129 act_update = get(H.act_file_update_checkbox, 'Value');
0130 act_already_read = bitget(file_on_app, 3);
0131 act_file = get(H.act_file_edit, 'String');
0132 set_error_msg_to_info_msgbox(H.info_edit, 'act_file', OFF);
0133 if act_is_required
0134     if act_update && is_file_exist(act_file)
0135         % ready to read act_file(No problem)
0136     elseif act_already_read && act_update == false
0137         % act_file is already read(No problem)
0138     else
0139         % Problem
0140         cond = false;
0141         set_error_msg_to_info_msgbox(H.info_edit, 'act_file', ON, act_file);
0142     end
0143 elseif act_update && ~is_file_exist(act_file)
0144     % Problem
0145     cond = false;
0146     set_error_msg_to_info_msgbox(H.info_edit, 'act_file', ON, act_file);
0147 end
0148 
0149 function ret = is_file_exist(file)
0150 ret = false;
0151 if exist(file, 'file') == 2
0152     ret = true;
0153 end
0154 
0155 function set_error_msg_to_info_msgbox(comp_desc, file_type, on_off, file)
0156 
0157 if ~exist('on_off', 'var'), on_off = ON; end;
0158 
0159 str = get(comp_desc, 'String');
0160 if isempty(str)
0161     str = cell(0);
0162 else
0163     str = cellstr(str);
0164 end
0165 
0166 switch(file_type)
0167     case 'brain_file'
0168         msg = '- Cortical model file';
0169     case 'area_file'
0170         msg = '- Cortical area file';
0171     case 'act_file'
0172         msg = '- Cortical act file';
0173     case 'current_file'
0174         msg = '- Current file';
0175     case 'tf_file'
0176         msg = '- Time frequency file';
0177     otherwise
0178         error('Unknown file_type was specified.');
0179 end
0180 
0181 ix = strmatch(msg, str);
0182 if on_off == ON
0183     % error ON
0184     if isempty(file)
0185         reason = ' is required.';
0186     elseif exist(file, 'file') == 2
0187         reason = ' should be applied.';
0188     else
0189         reason = ' is invalid.';
0190     end
0191     if isempty(ix)
0192         str{end+1} = [msg, reason];
0193     end
0194 else
0195     % error OFF
0196     if ~isempty(ix)
0197         % remove msg
0198         str(ix) = [];
0199     end
0200 end
0201 set(comp_desc, 'String', str);

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