function disp_fig(k,kk,mode,action),
% disp_fig is the Matlab script for implementation of the disp_fig function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% $Id: disp_fig.m,v 1.5 2003/11/30 22:28:27 pierrot Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Matlab script for implementation of machine vision display function
% * ....
% *.....
% Copyright (C) 2003 WISIRC
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Authors: Sebastien PIERROT
% date: 15/10/2003
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% $Log: disp_fig.m,v $
% Revision 1.5 2003/11/30 22:28:27 pierrot
% Environment and mass filter settings as well corresponding figures are available
%
% Revision 1.4 2003/11/26 12:05:45 pierrot
% File source menu is implemented as a open file menu. You can load another picture whenever for processing
%
% Revision 1.3 2003/11/03 14:38:37 pierrot
% all gui menus are available as well the simulink acquisition test and make it parent of all other figures.
%
% Revision 1.2 2003/10/24 17:41:12 pierrot
% multi sources are available (video, pictures,...) and the figure that custum process/display is working properly
%
% Revision 1.1 2003/10/20 15:38:27 pierrot
% Gui Version 1.4
%
% Revision 1.3 2003/10/15 14:09:55 pierrot
% header modification for m2htlm function processing
%
% Revision 1.2 2003/10/14 23:15:53 pierrot
% header added to file
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global grab_Set set_Set disp_Set process source_Set
%******************************************************************
%******************************************************************
%******************************************************************
%******************************************************************
switch k,
case 'default_set',
% set default settings for machine vision procession
set_Set.wb = process.def_set.wb;
set_Set.seg = process.def_set.seg;
set_Set.env = process.def_set.env;
%Set source (file or grabber) image
source_Set.grab = 'file';
source_Set.mode = 'load';
case 'setting_to_file',
%******************************************************************
%Set the processus to display
% and define process settings
switch kk,
case 'open',
[fname,pname] = uigetfile('*.mat','Select the data file');
if isstr(fname) & isstr(pname),
s= load([pname fname]);
set_Set= s.set_Set;
end;
case 'save',
[fname,pname] = uiputfile('*.mat','Save the dat file');
if isstr(fname) & isstr(pname),
save([pname fname]);
end
end;
case 'set_disp_process',
% Set user or default settings up to the process to execute
% Setting off the process or
switch kk,
case 'Frame',
hfig = findobj('type','figure','tag','Pre_Process');
if isempty(hfig),
disp_Set.proc.Frame = 'on';
%process.set.Acquisition = 'on'
disp_Set.number = disp_Set.number + 1;
end;
case 'Pre_Process',
hfig = findobj('type','figure','tag','Pre_Process');
if isempty(hfig),
disp_Set.proc.Pre_Process = 'on';
process.set.Pre_Process = 'on';
%process.set.Acquisition = 'on'
disp_Set.number = disp_Set.number + 1;
end;
case 'WB',
hfig = findobj('type','figure','tag','WB');
if isempty(hfig),
disp_Set.proc.WB = 'on';
process.set.WB = 'on';
%process.set.Acquisition = 'on'
disp_Set.number = disp_Set.number + 1;
end;
switch mode
case 'default'
set_Set.wb = process.def_set.wb;
case 'user',
prompt = {'Nb Pixels for white rf.','dT between each WB process (seconds)'};
title = 'White Balancing Setting...';
lines= 1;
def = {num2str(process.def_set.wb.np_WB),num2str(process.def_set.wb.dt_WB)};
answer = inputdlg(prompt,title,lines,def);
if ~isempty(answer)
result = str2double(answer);
if length(result(2)) == 0 | result(2) == 0 ,
set_Set.wb.dt_WB = process.def_set.wb.dt_WB;
else
set_Set.wb.dt_WB = result(2);
end;
if length(result(1)) == 0 | result(1) == 0,
set_Set.wb.np_WB = process.def_set.wb.np_WB;
else
set_Set.wb.np_WB = result(1);
end;
end;
end;
set_Set.wb.t_WB = timerfind('Tag','WB');
if ~isempty(set_Set.wb.t_WB),
stop(set_Set.wb.t_WB);
else
set_Set.wb.t_WB= timer('Tag','WB',...
'TimerFcn','WB_Process_Fct(process.image)',...
'Period', set_Set.wb.dt_WB);
set(set_Set.wb.t_WB,'ExecutionMode', 'FixedRate');
end;
start(set_Set.wb.t_WB);
case 'Environment'
if isempty(set_Set.env.dim_H)
set_Set.env = process.def_set.env;
end;
if isempty(set_Set.seg.h_Col_H)
set_Set.seg = process.def_set.seg;
end;
hfig = findobj('type','figure','tag','Environment');
if isempty(hfig),
hfig= hgload('Figures\Disp_Env_Settings.fig');
end;
case 'ColCal'
hfig = findobj('type','figure','tag','ColCal');
if isempty(hfig)
process.set.Reconizing = 'on';
disp_Set.proc.ColCal = 'on';
disp_Set.number = disp_Set.number + 1;
end;%
switch mode,
case 'default',
set_Set.seg = process.def_set.seg;
case 'user'
switch action