1 function danl_edit(obj, hObject, varargin)
\r
2 % NOTE: Model edit windows do not use the "action" input argument,
\r
3 % as all other edit windows do.
\r
4 % This will be fixed as soon as possible. In the meantime, just exclude the first input
\r
5 % argument when programming own model edit windows.
\r
7 % Toolbox for nonlinear filtering.
\r
8 % Copyright (C) 2005 Jakob Rosén <jakob.rosen@gmail.com>
\r
10 % This program is free software; you can redistribute it and/or
\r
11 % modify it under the terms of the GNU General Public License
\r
12 % as published by the Free Software Foundation; either version 2
\r
13 % of the License, or (at your option) any later version.
\r
15 % This program is distributed in the hope that it will be useful,
\r
16 % but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
17 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
18 % GNU General Public License for more details.
\r
20 % You should have received a copy of the GNU General Public License
\r
21 % along with this program; if not, write to the Free Software
\r
22 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
24 % Sorry, I didn't have enough time to write nice GUI code.
\r
26 %myfont='FixedWidth';
\r
29 %hf=figure('Name','DANL Edit','NumberTitle','off','Units','Centimeters','Position',[1 3 15 10],'Units','Normalized','PaperUnits','Centimeters','PaperPosition',[0.25 3 18 12]);
\r
30 hf=figure('Name','DANL Edit');
\r
32 datatypes=pfgui_config('expression_types');
\r
34 object_str='Undefined';
\r
35 object_str2='Undefined (Optional)';
\r
36 for i=1:length(datatypes)
\r
37 object_str=[object_str,'|',eval(['get(',datatypes{i},',''description'')'])];
\r
38 object_str2=[object_str2,'|',eval(['get(',datatypes{i},',''description'')'])];
\r
41 dnames={'f','gw','gu','h','hu'};
\r
46 for i=1:length(dnames);
\r
49 if ~isempty(obj.(currobj));
\r
50 str=get(obj.(currobj),'str');
\r
56 for j=1:length(datatypes)
\r
57 if isa(obj.(currobj),datatypes{j})
\r
63 if strcmp(currobj,'gu')||strcmp(currobj,'hu')
\r
64 popup_str=object_str2; % Optional objects
\r
66 popup_str=object_str;
\r
69 uicontrol(hf,'Style','Text','String',currobj,'Units','normalized','Position',[0.0 postop-space*pos 0.055 0.05],'HorizontalAlign','Left','TooltipString','The actual object','Fontname',myfont);
\r
70 uicontrol(hf,'Style','Edit','String',str,'Units','normalized','Position',[0.04 postop-space*pos 0.38 0.05],'Tag',[currobj,'_edit'],'callback',['danl_action(',num2str(hf),',''edit_data'',''',currobj,''')'],'TooltipString','A string representation of the object','Fontname',myfont);
\r
71 uicontrol(hf,'Style','Pushbutton','String','E','Units','normalized','Position',[0.425 postop-space*pos 0.03 0.05],'callback',['danl_action(',num2str(hf),',''objedit'',''',currobj,''')'],'Tag',[currobj,'_objedit'],'TooltipString','Edit the object','Fontname',myfont);
\r
72 uicontrol(hf,'Style','Popup','String',popup_str,'Value',index+1,'Units','normalized','Position',[0.51 postop-space*pos 0.49 0.05],'callback',['danl_action(',num2str(hf),',''select'',''',currobj,''')'],'Tag',[currobj,'_select'],'TooltipString','Object type','Fontname',myfont);
\r
77 %-------------- rnd stuff
\r
79 rndtypes=pfgui_config('noise_types');
\r
80 rndselect_str='Undefined';
\r
81 for i=1:length(rndtypes)
\r
82 rndselect_str=[rndselect_str,'|',eval(['get(',rndtypes{i},',''description'')'])];
\r
85 rnames={'w','e','p0'};
\r
91 for i=1:length(rnames);
\r
94 if ~isempty(obj.(currobj));
\r
95 str=get(obj.(currobj),'R_str');
\r
101 for j=1:length(rndtypes)
\r
102 if isa(obj.(currobj),rndtypes{j})
\r
108 uicontrol(hf,'Style','Text','String',currobj,'Units','normalized','Position',[0.0 postop-space*pos 0.055 0.05],'HorizontalAlign','Left','TooltipString','The actual object','Fontname',myfont);
\r
109 uicontrol(hf,'Style','Edit','String',str,'Units','normalized','Position',[0.04 postop-space*pos 0.38 0.05],'Tag',[currobj,'_edit'],'callback',['danl_action(',num2str(hf),',''rnd_edit'',''',currobj,''')'],'TooltipString','A string representation of the object','Fontname',myfont);
\r
110 uicontrol(hf,'Style','Pushbutton','String','E','Units','normalized','Position',[0.425 postop-space*pos 0.03 0.05],'callback',['danl_action(',num2str(hf),',''rnd_objedit'',''',currobj,''')'],'Tag',[currobj,'_objedit'],'TooltipString','Edit the object','Fontname',myfont);
\r
111 uicontrol(hf,'Style','Popup','String',rndselect_str,'Value',index+1,'Units','normalized','Position',[0.51 postop-space*pos 0.49 0.05],'callback',['danl_action(',num2str(hf),',''rnd_select'',''',currobj,''')'],'Tag',[currobj,'_select'],'TooltipString','Object type','Fontname',myfont);
\r
121 % Description frame
\r
122 uicontrol(hf,'Style','Frame','Units','normalized','Position',[0.0 0.845-0.04 0.7 0.125+0.04]);
\r
123 uicontrol(hf,'Style','Text','String','x(t+T) = f(x,t) + gu(x,t)*u(t) + gw(x,t)*w(t)','Units','normalized','Position',[0.01 0.9 0.65 0.04],'HorizontalAlign','Left','FontName','FixedWidth');
\r
124 uicontrol(hf,'Style','Text','String',' y(t) = h(x,t) + hu(x,t)*u(t) + e(t)','Units','normalized','Position',[0.01 0.86 0.65 0.04],'HorizontalAlign','Left','FontName','FixedWidth');
\r
125 uicontrol(hf,'Style','Text','String',' x(0) = x0 + p0','Units','normalized','Position',[0.01 0.82 0.65 0.04],'HorizontalAlign','Left','FontName','FixedWidth');
\r
126 uicontrol(hf,'Style','Text','String','Discrete Additive Non-Linear Model','Units','normalized','Position',[0.01 0.95 0.5 0.04],'FontName',myfont);
\r
129 uicontrol(hf,'Style','Text','String','Sample time (T):','Units','normalized','Position',[0.51 0.71 0.39 0.05],'HorizontalAlign','Left','Fontname',myfont);
\r
130 uicontrol(hf,'Style','Edit','String',num2str(T),'Units','normalized','Position',[0.9 0.71 0.1 0.05],'callback',['danl_action(',num2str(hf),',''T_edit'')'],'Tag','T_edit','Fontname',myfont);
\r
131 %uicontrol(hf,'Style','Text','String','seconds','Units','normalized','Position',[0.85 0.71 0.1 0.05],'Fontname',myfont);
\r
135 o1y=-0.02-0.18-0.005;
\r
141 uicontrol(hf,'Style','Frame','Units','normalized','Position',[o1x+0.535 o1y+0.735 0.455 0.255],'callback',['danl_action(',num2str(hf),',''states_edit'')']);
\r
143 uicontrol(hf,'Style','Text','String','Names (xvars):','Units','normalized','Position',[o1x+0.54 o1y+0.855 0.2 0.05],'HorizontalAlign','Left','Fontname',myfont);
\r
144 uicontrol(hf,'Style','Edit','String',cell2cellstr(xvars),'Units','normalized','Position',[o1x+0.75 o1y+0.855 0.2 0.05],'Tag','edit_xvars','callback',['danl_action(',num2str(hf),',''xvars_edit'')'],'Fontname',myfont);
\r
145 uicontrol(hf,'Style','Text','String','x0 vector:','Units','normalized','Position',[o1x+0.54 o1y+0.80 0.2 0.05],'HorizontalAlign','Left','Fontname',myfont);
\r
146 uicontrol(hf,'Style','Edit','String',num2str2(x0),'Units','normalized','Position',[o1x+0.75 o1y+0.80 0.2 0.05],'Tag','edit_x0','callback',['danl_action(',num2str(hf),',''x0_edit'')'],'Fontname',myfont);
\r
147 uicontrol(hf,'Style','Text','String','Generate p0 noise','Units','normalized','Position',[o1x+0.54 o1y+0.74 0.3 0.05],'HorizontalAlign','Left','Fontname',myfont);
\r
148 uicontrol(hf,'Style','Checkbox','Units','normalized','Position',[o1x+0.93 o1y+0.74 0.03 0.05],'Tag','check_p0','Value',1,'Fontname',myfont);
\r
149 uicontrol(hf,'Style','Text','String','States:','Units','normalized','Position',[o1x+0.54 o1y+0.91 0.2 0.05],'HorizontalAlign','Left','Fontname',myfont);
\r
150 uicontrol(hf,'Style','Edit','String',num2str(states),'Units','normalized','Position',[o1x+0.75 o1y+0.91 0.095 0.05],'Tag','edit_states','callback',['danl_action(',num2str(hf),',''statenr_edit'')'],'Fontname',myfont);
\r
151 uicontrol(hf,'Style','Pushbutton','String','Edit','Units','normalized','Position',[o1x+0.85 o1y+0.91 0.1 0.05],'callback',['danl_action(',num2str(hf),',''states_edit'')'],'Fontname',myfont);
\r
157 uicontrol('Style','Pushbutton','String','Save','Units','normalized','Position',[0.8,0.95+blah,0.1,0.05],'Callback',['danl_action(',num2str(hf),',''save'')'],'Fontname',myfont);
\r
158 uicontrol('Style','Pushbutton','String','Cancel','Units','normalized','Position',[0.9,0.95+blah,0.1,0.05],'Callback',['delete(',num2str(hf),')'],'Fontname',myfont);
\r
161 uicontrol(hf,'Style','Frame','Units','normalized','Position',[0.51 0.1+0.48 0.49 0.09]);
\r
162 uicontrol(hf,'Style','Popup','String','f|gu|gw|h|hu|w|e|p0','Value',1,'Units','normalized','Position',[0.52 0.1+0.5 0.1 0.05],'Tag','import_select','TooltipString','Object to import from the workspace','FontName',myfont);
\r
163 uicontrol(hf,'Style','Edit','String','','Units','normalized','Position',[0.63 0.1+0.5 0.25 0.05],'callback',['danl_action(',num2str(hf),',''import_button'')'],'Tag','import_edit','Fontname',myfont);
\r
164 uicontrol(hf,'Style','Pushbutton','String','Import','Units','normalized','Position',[0.89 0.1+0.5 0.1 0.05],'callback',['danl_action(',num2str(hf),',''import_button'')'],'Fontname',myfont);
\r
167 handles=guihandles(hf);
\r
168 handles.parentfig=hObject;
\r
169 handles.caller=varargin{1};
\r
170 handles.callback=varargin{2};
\r
171 handles.datatypes=datatypes;
\r
172 handles.rndtypes=rndtypes;
\r
173 handles.dnames=dnames;
\r
184 handles.xvars=xvars;
\r
186 handles.states=states;
\r
187 guidata(hf,handles);
\r
189 for i=1:length(dnames)
\r
190 danl_update_checkbox(hf,i);
\r