1 function sis_edit(action, varargin)
\r
2 % Sorry, I didn't have enough time to write nice and documented GUI code.
\r
4 % Toolbox for nonlinear filtering.
\r
5 % Copyright (C) 2005 Jakob Rosén <jakob.rosen@gmail.com>
\r
7 % This program is free software; you can redistribute it and/or
\r
8 % modify it under the terms of the GNU General Public License
\r
9 % as published by the Free Software Foundation; either version 2
\r
10 % of the License, or (at your option) any later version.
\r
12 % This program is distributed in the hope that it will be useful,
\r
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 % GNU General Public License for more details.
\r
17 % You should have received a copy of the GNU General Public License
\r
18 % along with this program; if not, write to the Free Software
\r
19 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
22 %myfont='FixedWidth';
\r
24 if strcmp(action,'init');
\r
25 parentfig=varargin{1};
\r
28 callback=varargin{4};
\r
30 resample_functions={@rs_regularized, @rs_simple, @rs_stratified, @rs_systematic};
\r
31 resample_names={'Residual resampling', 'Simple resampling', 'Stratified resampling', 'Systematic resampling'};
\r
32 resample_str=cell2str(resample_names);
\r
34 resampler_str=func2str(obj.resampler);
\r
37 for i=1:length(resample_functions)
\r
38 if strcmp(resampler_str, func2str(resample_functions{i}))
\r
47 % hf=figure('Name','sis object editor','NumberTitle','off','Units','normalized','Position',[0.3 0.5 0.5 0.4]);
\r
48 hf=figure('Name','sis object editor');
\r
52 uicontrol(hf,'Style','Text','String','Number of particles (N):','Units','normalized','Position',[0 p+0.15 0.4 0.05],'HorizontalAlign','Left','Fontname',myfont);
\r
53 uicontrol(hf,'Style','Edit','String',num2str(N),'Units','normalized','Position',[0.45 p+0.15 0.18 0.05],'Callback',['sis_edit(''N_edit'',',num2str(hf),')'],'Tag','N_edit','Fontname',myfont);
\r
55 uicontrol(hf,'Style','Text','String','Resampling function:','Units','normalized','Position',[0.0 p+0.07 0.4 0.05],'HorizontalAlign','Left','Fontname',myfont);
\r
56 uicontrol(hf,'Style','Popup','String',resample_str,'Value',resample_value,'Units','normalized','Position',[0.45 p+0.07 0.4 0.05],'Tag','resampler_select','Fontname',myfont);
\r
58 % uicontrol(hf,'Style','Frame','Units','Characters','Position',[55 0 0.1 5]);
\r
60 uicontrol('Style','Pushbutton','String','Save','Units','normalized','Position',[0.65,p+0.15,0.1,0.05],'Callback',['sis_edit(''save'',',num2str(hf),')'],'Fontname',myfont);
\r
61 uicontrol('Style','Pushbutton','String','Cancel','Units','normalized','Position',[0.75,p+0.15,0.1,0.05],'Callback',['delete(',num2str(hf),')'],'Fontname',myfont);
\r
63 uicontrol(hf,'Style','Text','String','Resampling threshold (Nth):','Units','normalized','Position',[0 p+(-0.01) 0.4 0.05],'HorizontalAlign','Left','Fontname',myfont);
\r
64 uicontrol(hf,'Style','Edit','String',num2str(Nth),'Units','normalized','Position',[0.45 p+(-0.01) 0.18 0.05],'Callback',['sis_edit(''Nth_edit'',',num2str(hf),')'],'Tag','Nth_edit','Fontname',myfont);
\r
65 uicontrol(hf,'Style','Text','String','0 <= Nth <= N','Units','normalized','Position',[0.65 p+(-0.01) 0.2 0.05],'HorizontalAlign','center','Fontname',myfont);
\r
68 handles=guihandles(hf);
\r
70 handles.caller=caller;
\r
71 handles.callback=callback;
\r
72 handles.parentfig=parentfig;
\r
75 handles.resample_functions=resample_functions;
\r
76 guidata(hf,handles);
\r
78 elseif strcmp(action,'save');
\r
81 handles=guidata(hf);
\r
83 caller=handles.caller;
\r
86 resampler_index=get(handles.resampler_select,'value');
\r
88 set(obj,'N',handles.N);
\r
89 set(obj,'resampler',handles.resample_functions{resampler_index});
\r
90 set(obj,'Nth',handles.Nth);
\r
92 parentfig=handles.parentfig;
\r
93 parenthandles=guidata(parentfig);
\r
95 parenthandles.(caller)=obj;
\r
96 guidata(parentfig,parenthandles); % Save data
\r
98 eval(handles.callback);
\r
101 elseif strcmp(action,'N_edit');
\r
103 handles=guidata(hf);
\r
105 N_str=get(handles.N_edit,'String');
\r
107 msgbox('Please enter a value');
\r
111 msgbox('Please enter a POSITIVE value');
\r
114 msgbox('Please enter a positive INTEGER');
\r
120 set(handles.Nth_edit,'String',num2str(N));
\r
124 guidata(hf,handles);
\r
126 elseif strcmp(action,'Nth_edit');
\r
128 handles=guidata(hf);
\r
130 Nth_str=get(handles.Nth_edit,'String');
\r
131 if isempty(Nth_str)
\r
132 msgbox('Please enter a value');
\r
134 Nth=str2num(Nth_str);
\r
136 msgbox('Please enter a POSITIVE value');
\r
138 elseif Nth>handles.N
\r
139 msgbox('Nth must not be greater than N!');
\r
143 set(handles.Nth_edit,'String',num2str(Nth)); % Format!
\r
144 guidata(hf,handles);
\r