⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 erp_input_diff_ui.m

📁 绝对经典,老外制作的功能强大的matlab实现PLS_TOOBOX
💻 M
📖 第 1 页 / 共 2 页
字号:
%ERP_INPUT_DIFF_UI Choosing condition difference couple
%
%   %Usage: new_couple_lst = erp_input_diff_ui(couple_lst, cond_name);
%   Usage: h01 = erp_input_diff_ui(h0);
%
%   See also RRI_INPUT_CONDITION_UI
%

%   %I (couple_lst) - old couple_lst cell array, or action word call recursively
%   %I (cond_name)  - condition name cell array
%   %O (new_couple_lst) - new couple_lst cell array
%   I (h0) - handle of the wave plotting figure
%   O (h01) - handle of the cond_diff choosing figure
%
%   Modified on 7-MAY-2003 by Jimmy Shen
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%function new_couple_lst = erp_input_diff_ui(varargin)
function h01 = erp_input_diff_ui(varargin)

%   if nargin == 0
%      old_couple_lst = [];
%   end;

   if nargin == 0 | ~ischar(varargin{1})
%      old_couple_lst = varargin{1} + 1;
%      cond_name = [{''} varargin{2}];

   h01 = init(varargin{1});
%      init(old_couple_lst, cond_name);
%      uiwait;				% wait for user finish

%      new_couple_lst = getappdata(gcf,'curr_couple_lst') - 1;

%      [r c] = find(~new_couple_lst);
%      mask = ones(size(new_couple_lst,1),1);
%      mask(r) = 0;
%      new_couple_lst = new_couple_lst(find(mask),:);

%      close(gcf);
      return;
   end;

   %  clear the message line,
   %
   h = findobj(gcf,'Tag','MessageLine');
   set(h,'String','');

   action = upper(varargin{1});

   if strcmp(action,'UPDATE_DIFF'),
      UpdateCouple;
   elseif strcmp(action,'EDIT_DIFF'),
      set(findobj(gcbf,'Tag','MessageLine'),'String', ...
	'Use Add Button to add condition couple');
   elseif strcmp(action,'DELETE_DIFF'),
      DeleteCouple;
   elseif strcmp(action,'ADD_DIFF'),
      AddCouple;
   elseif strcmp(action,'MOVE_SLIDER'),
      MoveSlider;
   elseif strcmp(action,'DELETE_FIG')
      delete_fig;
   elseif strcmp(action,'CANCEL_BUTTON_PRESSED'),
%      old_couple_lst = getappdata(gcf,'old_couple_lst');
%      setappdata(gcf,'curr_couple_lst',old_couple_lst);
%      uiresume;
      close(gcf);
   elseif strcmp(action,'DONE_BUTTON_PRESSED'),
%      uiresume;
      click_ok;
   end;

   return;


%----------------------------------------------------------------------------

%function init(old_couple_lst, cond_name)
function h01 = init(h0)

   old_couple_lst = getappdata(h0,'cond_couple_lst') + 1;
   cond_name = [{''} getappdata(h0,'org_wave_name') getappdata(h0,'mean_wave_name')];

   save_setting_status = 'on';
   input_diff_pos = [];

   try
      load('pls_profile');
   catch
   end

   if ~isempty(input_diff_pos) & strcmp(save_setting_status,'on')

      pos = input_diff_pos;

   else

      w = 0.6;
      h = 0.7;
      x = (1-w)/2;
      y = (1-h)/2;

      pos = [x y w h];

   end

   h01 = figure('Color',[0.8 0.8 0.8], ...
   	'Units','normal', ...
        'Name','Choose Condition Difference Couple', ...
        'MenuBar','none', ...
        'NumberTitle','off', ...
	'deletefcn','erp_input_diff_ui(''DELETE_FIG'');', ...
   	'Position',pos, ...
        'WindowStyle', 'modal', ...
   	'ToolBar','none');
%	'DoubleBuffer', 'on', ...
%	'Renderer', 'OpenGL', ...

   x = 0.06;
   y = 0.9;
   w = 1;
   h = 0.06;

   pos = [x y w h];

   c = uicontrol('Parent',h01, ...
   	'Style','text', ...
   	'Units','normal', ...
   	'BackgroundColor',[0.8 0.8 0.8], ...
   	'FontUnits','normal', ...
   	'FontSize',0.6, ...
	'FontName', 'FixedWidth', ...
   	'FontAngle','italic', ...
   	'FontWeight','bold', ...
   	'HorizontalAlignment','left', ...
   	'ListboxTop',0, ...
   	'Position',pos, ...
   	'String','Choose Condition Difference Couple: ');

   x = 0.03;
   y = 0.83;
   w = 0.07;

   pos = [x y w h];

   c_h1 = uicontrol('Parent',h01, ...		% couple idx
   	'Style','text', ...
   	'Units','normal', ...
   	'BackgroundColor',[0.8 0.8 0.8], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
   	'HorizontalAlignment','right', ...
   	'ListboxTop',0, ...
   	'Position',pos, ...
   	'String','1.');

   x = x+w+0.01;
   w = 0.29;

   pos = [x y w h];

   c_h2 = uicontrol('Parent',h01, ...		% condition 1 name
   	'Style','popupmenu', ...
   	'Units','normal', ...
   	'BackgroundColor',[1 1 1], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
   	'HorizontalAlignment','left', ...
   	'ListboxTop',0, ...
   	'Position',pos, ...
   	'String',cond_name);

   x = x+w+0.01;
   w = 0.03;

   pos = [x y w h];

   c_h3 = uicontrol('Parent',h01, ...		% minus sign
   	'Style','text', ...
   	'Units','normal', ...
   	'BackgroundColor',[0.8 0.8 0.8], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
   	'HorizontalAlignment','center', ...
   	'ListboxTop',0, ...
   	'Position',pos, ...
   	'String','-');

   x = x+w+0.01;
   w = 0.29;

   pos = [x y w h];

   c_h4 = uicontrol('Parent',h01, ...		% condition 2 name
   	'Style','popupmenu', ...
   	'Units','normal', ...
   	'BackgroundColor',[1 1 1], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
   	'HorizontalAlignment','left', ...
   	'ListboxTop',0, ...
   	'Position',pos, ...
   	'String',cond_name);

   x = x+w+0.01;
   w = 0.12;

   pos = [x y w h];

   c_h5 = uicontrol('Parent',h01, ...		% add / delete button
   	'Units','normal', ...
   	'Position',pos, ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
   	'ListboxTop',0, ...
   	'String','Add');

   x = x+w+0.02;
   w = 0.04;

   pos = [x y w h];

   h1 = uicontrol('Parent',h01, ...		% scroll bar
	'Style', 'slider', ...
   	'Units','normal', ...
   	'Min',1, ...
   	'Max',20, ...
   	'Value',20, ...
   	'Position',pos, ...
   	'Callback','erp_input_diff_ui(''MOVE_SLIDER'');', ...
   	'Tag','CondSlider');

   x = 0.11;
   y = 0.08;
   w = 0.2;

   pos = [x y w h];

   h1 = uicontrol('Parent',h01, ...			% DONE
        'Units','normal', ...
        'Callback','', ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
        'ListboxTop',0, ...
        'Position',pos, ...
        'String','OK', ...
   	'Callback','erp_input_diff_ui(''DONE_BUTTON_PRESSED'');', ...
        'Tag','DONEButton');

   x = 0.67;

   pos = [x y w h];

   h1 = uicontrol('Parent',h01, ...			% CANCEL
        'Units','normal', ...
        'Callback','', ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
        'ListboxTop',0, ...
        'Position',pos, ...
        'String','Cancel', ...
   	'Callback','erp_input_diff_ui(''CANCEL_BUTTON_PRESSED'');', ...
        'Tag','CANCELButton');

   x = 0.01;
   y = 0;
   w = 1;

   pos = [x y w h];

   h1 = uicontrol('Parent',h01, ...			% Message Line
        'Style','text', ...
        'Units','normal', ...
        'BackgroundColor',[0.8 0.8 0.8], ...
        'ForegroundColor',[0.8 0.0 0.0], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
        'HorizontalAlignment','left', ...
        'Position',pos, ...
        'String','', ...
        'Tag','MessageLine');

   couple1_hdls = [c_h1,c_h2,c_h3,c_h4,c_h5];		% save handles for row
   setappdata(h01,'couple_hlist',couple1_hdls);

   couple_template = copyobj(couple1_hdls,h01);
   set(couple_template,'visible','off');

   setappdata(h01,'old_couple_lst',old_couple_lst);
   setappdata(h01,'curr_couple_lst',old_couple_lst);
   setappdata(h01,'couple_template',couple_template);

   cond_h = 0.06;
   setappdata(h01,'ConditionHeight', cond_h);

   lower_h = 0.01;      % vert. space for Number of rows etc.
   setappdata(h01,'lower_h',lower_h);

   setappdata(h01,'top_couple_idx',1);

   SetupCoupleRows;
   SetupSlider;
   CreateAddRow;
   DisplayCouple;
   UpdateSlider;

   return;						% init


%----------------------------------------------------------------------------
function SetupCoupleRows()

   couple_hdls = getappdata(gcf,'couple_hlist');
   cond_h = getappdata(gcf,'ConditionHeight');
   lower_h = getappdata(gcf,'lower_h');

   bottom_pos = get(findobj(gcf,'Tag','DONEButton'),'Position');
   top_pos = get(couple_hdls(1,2),'Position');

   rows = floor(( top_pos(2) - bottom_pos(2) - lower_h ) / cond_h);

   % A row of vertical positions, at which the 13 4-controls will be located.
   v_pos = top_pos(2) - [0:rows-1]*cond_h;

   couple_template = getappdata(gcf,'couple_template');
   edit_cbf = 'erp_input_diff_ui(''UPDATE_DIFF'');';
   delete_cbf = 'erp_input_diff_ui(''DELETE_DIFF'');';

   nr = size(couple_hdls,1);		% nr = 1 for the initial
   if (rows < nr)			% too many rows
      for i=rows+1:nr,
          delete(couple_hdls(i,:));
      end;
      couple_hdls = couple_hdls(1:rows,:);
   else					% add new rows to 'rows' amount
      for i=nr+1:rows,
         new_c_hdls = copyobj(couple_template,gcf);
         couple_hdls = [couple_hdls; new_c_hdls'];
      end;
   end

   v = 'off';
   for i=1:rows
      % take out the handle list created above, and use it in the following 'label,edit,delete'.
      % those handles are valid, since they are all obtained from function copyobj() above.
      new_c_hdls = couple_hdls(i,:);

      % init label
      pos = get(new_c_hdls(1),'Position'); pos(2) = v_pos(i)-0.01;
      set(new_c_hdls(1),'String','','Position',pos,'Visible',v,'UserData',i);

      % init each edit box setup, insert callback property while doing setup
      pos = get(new_c_hdls(2),'Position'); pos(2) = v_pos(i);
      set(new_c_hdls(2), 'Position',pos, 'Visible',v, ...
                        'UserData',[i,1],'Callback',edit_cbf);

      % init each edit box setup, insert callback property while doing setup
      pos = get(new_c_hdls(3),'Position'); pos(2) = v_pos(i);
      set(new_c_hdls(3), 'Position',pos, 'Visible',v, ...
                        'UserData',i);

      % init each edit box setup, insert callback property while doing setup
      pos = get(new_c_hdls(4),'Position'); pos(2) = v_pos(i);
      set(new_c_hdls(4), 'Position',pos, 'Visible',v, ...
                        'UserData',[i,2],'Callback',edit_cbf);

      % init each delete button setup, insert callback property while doing setup
      pos = get(new_c_hdls(5),'Position'); pos(2) = v_pos(i);
      set(new_c_hdls(5),'String','Delete','Position',pos,'Visible',v, ...
                        'UserData',i,'Callback',delete_cbf);

   end

   setappdata(gcf,'couple_hlist',couple_hdls);
   setappdata(gcf,'NumRows',rows);

   return;					% SetupCoupleRows


%----------------------------------------------------------------------------
function DisplayCouple()

   curr_couple_lst = getappdata(gcf,'curr_couple_lst');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -