annotate m-toolbox/m/gui/gltpda/pan2param.m @ 11:9174aadb93a5 database-connection-manager

Add LTPDA Repository utility functions into utils.repository
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
1 function pan2param(varargin)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
2 % This is the GUI m-file able to read the list of parameters to be set for
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
3 % the function/block currently selected and to build the window with the
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
4 % parameters panel accordingly.
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
5 %
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
6 % $Id: pan2param.m,v 1.64 2009/02/01 17:20:04 nicola Exp $
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
7
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
8 global oldparams params paramEnabled oldparamEnabled paramSets currPanel
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
9 global LTPDAinvar selBlocks objName noParamsReq functionName guiFontSize %#ok<NUSED>
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
10
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
11 %%
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
12
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
13 currPanel = varargin{1};
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
14 panelDimens = get(currPanel, 'Position');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
15 backColor = get(currPanel, 'BackgroundColor');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
16 selBlocks = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
17 set(gcf,'NextPlot','new');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
18 GUIprefs = getappdata(0, 'GUIpreferences');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
19 if ~isfield(GUIprefs,'CAD'), GUIprefs.CAD = 0; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
20 if ~isfield(GUIprefs,'Copied'), GUIprefs.Copied = 0; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
21 if ~isfield(GUIprefs,'Detach'), GUIprefs.Detach = 0; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
22 setappdata(0, 'GUIpreferences',GUIprefs);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
23
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
24 guiFontSize = getappdata(0, 'ltpda_gui_fontsize');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
25 if isempty(guiFontSize), guiFontSize = 10; setappdata(0, 'ltpda_gui_fontsize',10); end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
26 set(gcf,'NextPlot','new')
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
27 alltimers = timerfindall;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
28 stop(alltimers(1));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
29 set(alltimers(1),'TimerFcn',@g_ContinuousParamCheck,'Period',0.3);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
30 start(alltimers(1));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
31
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
32
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
33 %%
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
34 %----------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
35 function buildplistFigureParam(varargin)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
36 %----------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
37 panelDimens = get(currPanel, 'Position');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
38 lineSpacing = 25 * guiFontSize/10;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
39 setappdata(0,'ltpda_gui_LineSpacing',lineSpacing);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
40 if ~isempty(findobj(gcf,'Tag','apply'))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
41 notredrawn = 0; undoStatus = get(findobj(gcf,'Tag','undo'),'enable');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
42 % deletes only the dynamical part of the panel:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
43 for i = 1:numel(objName), try delete(objName{i}); catch, end; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
44 delete(findobj('Parent',currPanel,'TooltipString','Remove this parameter'))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
45 else
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
46 notredrawn = 1; undoStatus = 'off';
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
47 % deletes all, to redraw the entire panel:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
48 delete(findobj(gcf,'Parent',currPanel));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
49 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
50 objName = [];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
51 close(findobj('Tag','expandedEditField'))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
52 if notredrawn % Executes the STATIC part too only if it's not just an update of the panel
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
53
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
54 % =========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
55 % =========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
56 % ========================== Build STATIC panel ===========================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
57 % =========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
58 % =========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
59
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
60 % -------------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
61 % Retrieve the parameters:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
62 % -------------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
63 if isempty(oldparams) && isempty(params) % the user has just selected another block
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
64 paramcommand = get_param(gcbh,'Description');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
65 noParamsReq=0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
66 if isempty(paramcommand)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
67 paramcommand = g_RetrievePlist();
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
68 selBlocks = utils.prog.gcbsh;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
69 for kk=1:length(selBlocks)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
70 set_param(selBlocks(kk),'Description',paramcommand);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
71 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
72 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
73 eval(paramcommand)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
74 if ~isempty(oldparams), params = oldparams; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
75 oldparamEnabled = paramEnabled;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
76 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
77
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
78 if ~exist('paramEnabled','var') && isempty(find(params,'Sets')) && noParamsReq==0
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
79 paramEnabled = zeros(1,nparams(params));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
80 oldparamEnabled = paramEnabled;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
81 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
82 childpath = find_system(gcbh,'LookUnderMasks','all','BlockType','M-S-Function');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
83 setappdata(0,'ltpda_currFunctionName',get_param(childpath,'Tag'));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
84
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
85 y = nparams(params);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
86
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
87 if y==0 && ~exist('paramSets','var') && noParamsReq==0
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
88 paramcommand=[paramcommand,'noParamsReq=1;'];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
89 selBlocks = utils.prog.gcbsh;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
90 for kk=1:length(selBlocks), set_param(selBlocks(kk),'Description',paramcommand); end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
91 buildplistFigureParam([],[],get(findobj('Tag','paramsPage'),'UserData'))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
92 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
93
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
94 % -------------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
95 % Fixed buttons:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
96 % -------------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
97 % Help Button
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
98 uicontrol('Parent',currPanel,'Units','pixels','HorizontalAlignment','center','Position',[20 10 45 guiFontSize*16/10],'FontAngle','italic','FontSize',guiFontSize,'String','?','TooltipString','Open the Help associated to this function','Visible','on','Callback',@g_HelpButtonCallback,'Style','pushbutton');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
99 % Reset Parameters Button
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
100 uicontrol('Parent',currPanel,'Units','pixels','HorizontalAlignment','center','Position',[75 10 75 guiFontSize*16/10],'FontAngle','italic','FontSize',guiFontSize,'String','Reset','TooltipString','Reset the parameters for this block','Visible','on','Callback',@g_ResetButtonCallback,'Style','pushbutton');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
101 % 'Set name' checkbox:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
102 setName = get(gcbh,'UserData');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
103 if isempty(setName), setName = 0; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
104 uicontrol('Parent',currPanel,'Units','pixels','BackgroundColor',backColor,'HorizontalAlignment','left','Position',[170 10 140 guiFontSize*16/10],'FontAngle','italic','FontSize',guiFontSize-2,'String','Set name','TooltipString','Set the signal name equal to the block name','Visible','on','Callback',@g_SetNameCallback,'Value',setName,'Style','checkbox');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
105 % Keep local result
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
106 probe = get_param(gcbh,'MaskHelp');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
107 if ~isempty(probe) && isa(probe,'char') && strcmp(probe,'probe'), keepRes = 1; else keepRes = 0; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
108 uicontrol('Parent',currPanel,'Units','pixels','BackgroundColor',backColor,'HorizontalAlignment','left','Position',[250 10 220 guiFontSize*16/10],'FontAngle','italic','FontSize',guiFontSize-2,'String','Keep local result','TooltipString','Do not delete the result of this block at the end of the analysis calculation','Visible','on','Callback',@g_KeepResultCallback,'Value',keepRes,'Style','checkbox');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
109 % Number of data inputs:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
110 uicontrol('Parent',currPanel,'TooltipString','Set the number of input expected by this block','BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','right','Position',[370 5 70 guiFontSize*20/10],'String','Inputs: ','FontAngle','italic','FontSize',guiFontSize-2,'Visible','on','Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
111 paramFromSimulink = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
112 for ii=1:y
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
113 paramkeys{ii} = params.params(ii).key;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
114 paramvals{ii} = params.params(ii).val;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
115 if isa(paramvals{ii},'char') && numel(paramvals{ii})>2 && strcmp(paramvals{ii},'-->'), paramFromSimulink = paramFromSimulink + 1; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
116 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
117 inports = find_system(gcb,'SearchDepth',1,'LookUnderMasks','all','BlockType','Inport');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
118 uicontrol('Parent',currPanel,'TooltipString','Set the number of input expected by this block','BackgroundColor',backColor,'Units','pixels','Position',[450 8 40 guiFontSize*20/10],'String',num2str(numel(inports)-paramFromSimulink),'FontSize',guiFontSize,'Visible','on','Enable','on','UserData',numel(inports)-paramFromSimulink,'Callback',@g_numberDataInput,'Tag','numbDataInputs','Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
119
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
120 % The function has different sets of parameters:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
121 if exist('paramSets','var') && ~isempty(paramSets)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
122 sets = find(paramSets,'sets');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
123 currSet = find(paramSets,'currSet');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
124 % Sets popup menu:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
125 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[40 panelDimens(4)-30 250 20],'String',sets,'Value',currSet,'Visible','on','UserData',sets,'Callback',@g_SetsUpdate,'Style','popup');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
126 panelDimens(4) = panelDimens(4)-20;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
127 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
128
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
129 % -------------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
130 % Button to add user-defined params:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
131 % -------------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
132 paramTypes = {'double/char','specwin','pzmodel','-->'};
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
133 for kk=1:y, paramTypes(strmatch(class(params.params(kk).val),paramTypes,'exact'))=[]; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
134 paramTypes = [paramTypes(1:end-1),{'pz','unit'},paramTypes(end)];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
135 % ParamType popup
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
136 hparamType = uicontrol('Parent',currPanel,'Tag','addparamspopup','TooltipString','Add a user-defined parameter','BackgroundColor',backColor,'Units','pixels','Position',[20 40 100 20],'String',paramTypes,'Value',1,'Visible','on','Enable','on','Style','popupmenu');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
137 % Add params button
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
138 uicontrol('Parent',currPanel,'TooltipString','Add a user-defined parameter','Units','pixels','Position',[130 40 20 20],'String','+','Visible','on','Enable','on','Callback', @g_AddParamCallback,'UserData',hparamType,'Style','pushbutton');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
139
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
140 % -------------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
141 % Buttons to apply or undo:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
142 % -------------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
143 % Apply button
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
144 uicontrol('Parent',currPanel,'Units','pixels','Position',[panelDimens(3)-70 40 60 guiFontSize*20/10],'HorizontalAlignment','right','FontSize',guiFontSize,'String','Apply','Visible','on','Enable','off','Callback', @g_ApplyButtonCallback,'DeleteFcn',{@g_ApplyButtonCallback,0},'UserData',hparamType,'Tag','apply','Style','pushbutton');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
145 % Undo button
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
146 uicontrol('Parent',currPanel,'Units','pixels','Position',[panelDimens(3)-70 10 60 guiFontSize*20/10],'HorizontalAlignment','right','FontSize',guiFontSize,'String','Undo','Visible','on','Enable',undoStatus,'Callback', @g_UndoButtonCallback,'UserData',hparamType,'Tag','undo','Style','pushbutton');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
147
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
148
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
149 paramPagePosition = panelDimens + [3 65+guiFontSize*16/10 -6 -(80+guiFontSize*16/10)];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
150
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
151 else % The part above was executed only if it's not an update of the panel
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
152 y = nparams(params);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
153 for pp=1:y
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
154 paramkeys{pp} = params.params(pp).key;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
155 paramvals{pp} = params.params(pp).val;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
156 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
157 if exist('paramSets','var') && ~isempty(paramSets), panelDimens(4) = panelDimens(4)-20; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
158 paramPagePosition = panelDimens + [3 65+guiFontSize*16/10 -6 -(80+guiFontSize*16/10)];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
159 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
160
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
161
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
162 if nargin>2 && isa(varargin{3},'cell'), varargin{3} = varargin{3}{1}; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
163 if nargin<3, currPage = 1; else currPage = varargin{3}; if isa(currPage,'cell'), currPage = currPage{1}; end; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
164 uipanel('Parent',currPanel,'BackgroundColor',backColor,'FontSize',7,'Units','pixels','Position',paramPagePosition,'Tag','paramsPage','UserData',currPage);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
165
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
166 GUIprefs = getappdata(0, 'GUIpreferences');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
167 % Check if the parameters panel has to be drawn detached:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
168 if GUIprefs.Detach
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
169 drawn = g_drawParPanel();
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
170 if drawn, return; end;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
171 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
172
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
173
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
174
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
175 % =========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
176 % =========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
177 % ========================= Build DYNAMIC panel ===========================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
178 % =========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
179 % =========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
180
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
181 totalGaps = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
182 paramThisPage = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
183 lastParamGap = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
184 paramPages = [];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
185 for ii=1:y
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
186 paramThisPage = paramThisPage+1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
187 % -------------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
188 % Cycle to verify whether gaps (= extra lines for complex params, such as
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
189 % pzmodels) are necessary or not:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
190 switch class(paramvals{ii})
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
191 case 'pzmodel'
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
192 if numel(paramvals{ii}.poles)>1 || numel(paramvals{ii}.zeros)>1
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
193 totalGaps = totalGaps+1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
194 lastParamGap = 1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
195 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
196 case 'pz'
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
197 if numel(paramvals{ii})>1
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
198 totalGaps = totalGaps+1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
199 lastParamGap = 1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
200 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
201 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
202 % -------------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
203 % Check if it's necessary to draw multiple parameters pages:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
204 if (paramThisPage+totalGaps)*lineSpacing > paramPagePosition(4)-20
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
205 paramPages = [paramPages , paramThisPage-1];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
206 if ii==y, paramPages = [paramPages,1]; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
207 paramThisPage = 1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
208 totalGaps = lastParamGap;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
209 lastParamGap = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
210 elseif ii==y
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
211 paramPages = [paramPages , paramThisPage];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
212 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
213 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
214
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
215 currGap = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
216 % The vector 'paramPages' contains how many params are contained into every page.
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
217 if numel(paramPages) > 1
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
218 set(findobj('Tag','paramsPage'),'Title',['Page number ', num2str(currPage)] );
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
219 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Tag','gotoparamspage','HorizontalAlignment','left','Position',[200 39 100 20],'String','Go to page: ','FontName','Times New Roman','FontSize',guiFontSize+2,'FontWeight','bold','Visible','on','Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
220 for ii = 0:numel(paramPages)-1
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
221 uicontrol('Parent',currPanel,'Tag','gotoparamspage','Units','pixels','Position',[300+ii*(30) 40 20 20],'String',num2str(ii+1),'Visible','on','Enable','on','Callback', {@buildplistFigureParam,ii+1},'Style','pushbutton');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
222 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
223 elseif numel(paramPages) == 1
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
224 delete(findobj('Tag','gotoparamspage'))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
225 elseif isempty(paramPages)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
226 paramPages = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
227 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
228 firstParam = 1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
229 if nargin>1
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
230 if varargin{3}>numel(paramPages), varargin{3} = numel(paramPages); end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
231 for ii = 1:varargin{3}-1
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
232 firstParam = firstParam + paramPages(ii);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
233 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
234 lastParam = firstParam + paramPages(varargin{3})-1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
235 else
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
236 lastParam = paramPages(1);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
237 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
238 currParam = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
239
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
240 for ii = firstParam:lastParam
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
241 currParam = currParam + 1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
242 addedPar = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
243 % Checkbox to enable input setting:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
244 objName{ii,1} = uicontrol('Parent',currPanel,'Units','pixels','Position',[10,panelDimens(4)-lineSpacing*(currParam+1+currGap),14,14],'Value',paramEnabled(ii),'Visible','on','Enable','on','Callback', @g_EnableCallback,'Tag',paramkeys{ii},'UserData',ii,'Style','checkbox');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
245 % Remove Param Button:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
246 try %#ok<ALIGN>
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
247 if strcmpi(paramkeys{ii}(1:7),'addPar_')
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
248 uicontrol('Parent',currPanel,'Units','pixels','Position',[panelDimens(3)-30 panelDimens(4)-lineSpacing*(currParam+1+currGap) 20 20],'String','-','TooltipString','Remove this parameter','Visible','on','Enable','on','UserData',ii,'Callback', @g_RemParamCallback,'Style','pushbutton');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
249 addedPar = 1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
250 paramkeys{ii}(1:7) = [];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
251 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
252 catch, end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
253
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
254 switch class(paramvals{ii})
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
255
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
256 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
257 case {'double'}
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
258 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
259 % Key value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
260 objName{ii,2} = uicontrol('Parent',currPanel,'TooltipString','Key (name of the parameter)','Units','pixels','Position',[50 panelDimens(4)-lineSpacing*(currParam+1+currGap) 120 guiFontSize*20/10],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editNameCallback,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
261 if ~noParamsReq && ~addedPar
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
262 set(objName{ii,2},'Style','text','BackgroundColor',backColor,'Position',[50 panelDimens(4)-(4+lineSpacing*(currParam+1+currGap)) 120 20]);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
263 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
264 % Val value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
265 data = mat2str(paramvals{ii});
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
266 objName{ii,3} = uicontrol('Parent',currPanel,'TooltipString','Val (value of the parameter)','Units','pixels','Position',[200 panelDimens(4)-lineSpacing*(currParam+1+currGap) 200 guiFontSize*20/10],'String',data,'Fontsize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editValueCallback,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
267 objName{ii,4} = uicontrol('UserData',objName{ii,3},'TooltipString','Expand the edit field','Parent',currPanel,'BackgroundColor',[0.7 0.7 0.7],'HorizontalAlignment','left','Position',[405 panelDimens(4)+3-lineSpacing*(currParam+1+currGap) 13 13],'Visible','on','Callback',@g_ExpandEdit,'Style','pushbutton');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
268 % Enable parameters from Simulink:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
269 objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','From Simulink','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[450 panelDimens(4)-lineSpacing*(currParam+1+currGap) 120 20],'Max',1,'Min',0,'Value',0,'Visible','on','Tag',num2str(ii),'UserData',[],'Callback',@g_fromSimulinkCallback,'Style','checkbox');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
270 if strcmp(paramvals{ii},'-->')
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
271 set(objName{ii,3},'Visible','off');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
272 set(objName{ii,4},'Visible','off');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
273 set(objName{ii,10},'Value',1);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
274 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
275
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
276 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
277 case {'char'}
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
278 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
279 % Key value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
280 objName{ii,2} = uicontrol('Parent',currPanel,'Units','pixels','Position',[120 panelDimens(4)-lineSpacing*(currParam+1+currGap) 60 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editNameCallback,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
281 if ~noParamsReq && ~addedPar
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
282 set(objName{ii,2},'Style','text','BackgroundColor',backColor,'Position',[50 panelDimens(4)-(4+lineSpacing*(currParam+1+currGap)) 120 20]);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
283 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
284 if strcmpi(paramkeys{ii},'filename')
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
285 % Browse button:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
286 currFilename = paramvals{ii};
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
287 if isempty(currFilename), currFilename = 'Browse'; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
288 if numel(currFilename)>30, currFilename = ['...',currFilename(end-29:end)]; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
289 objName{ii,3} = uicontrol('Parent',currPanel,'Units','pixels','Position',[200 panelDimens(4)-lineSpacing*(currParam+1+currGap) 300 20],'String',currFilename,'Visible','on','Enable','off','Callback',@g_browseCallback,'Style','pushbutton');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
290 else
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
291 % Val value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
292 objName{ii,3} = uicontrol('Parent',currPanel,'Units','pixels','Position',[200 panelDimens(4)-lineSpacing*(currParam+1+currGap) 200 20],'String',['''',strrep(paramvals{ii},'''',''''''),''''],'Fontsize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editValueCallback,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
293 objName{ii,4} = uicontrol('UserData',objName{ii,3},'TooltipString','Expand the edit field','Parent',currPanel,'BackgroundColor',[0.7 0.7 0.7],'HorizontalAlignment','left','Position',[405 panelDimens(4)+3-lineSpacing*(currParam+1+currGap) 13 13],'Visible','on','Callback',@g_ExpandEdit,'Style','pushbutton');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
294 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
295 objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','From Simulink','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[450 panelDimens(4)-lineSpacing*(currParam+1+currGap) 120 20],'Max',1,'Min',0,'Value',0,'Visible','on','Tag',num2str(ii),'UserData',[],'Callback',@fromSimulinkCallback,'Style','checkbox');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
296 if strcmp(paramvals{ii},'-->')
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
297 set(objName{ii,3},'Visible','off');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
298 set(objName{ii,4},'Visible','off');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
299 set(objName{ii,10},'Value',1);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
300 else
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
301 set(objName{ii,10},'Visible','off');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
302 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
303
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
304 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
305 case {'unit'}
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
306 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
307 % Key value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
308 objName{ii,2} = uicontrol('Parent',currPanel,'Units','pixels','Position',[120 panelDimens(4)-lineSpacing*(currParam+1+currGap) 60 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editNameCallback,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
309 if ~noParamsReq && ~addedPar
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
310 set(objName{ii,2},'Style','text','BackgroundColor',backColor,'Position',[50 panelDimens(4)-(4+lineSpacing*(currParam+1+currGap)) 120 20]);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
311 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
312 % Val value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
313 unitVal = paramvals{ii}.strs; if isempty(unitVal), unitVal = {''}; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
314 allunits = unit.supportedUnits;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
315 unitsTooltip = 'Supported units: ';
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
316 for kk=1:numel(allunits), unitsTooltip = [unitsTooltip,allunits{kk},',']; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
317 unitsTooltip(end)=[];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
318 objName{ii,3} = uicontrol('Parent',currPanel,'TooltipString',unitsTooltip,'Units','pixels','Position',[200 panelDimens(4)-lineSpacing*(currParam+1+currGap) 200 20],'String',['''',unitVal{1},''''],'Fontsize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_unitValCallback,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
319
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
320 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
321 case {'logical'}
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
322 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
323 % Key value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
324 objName{ii,2} = uicontrol('Parent',currPanel,'Units','pixels','Position',[120 panelDimens(4)-lineSpacing*(currParam+1+currGap) 60 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editNameCallback,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
325 if ~noParamsReq && ~addedPar
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
326 set(objName{ii,2},'Style','text','BackgroundColor',backColor,'Position',[50 panelDimens(4)-(4+lineSpacing*(currParam+1+currGap)) 120 20]);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
327 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
328 % Val value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
329 objName{ii,3} = uicontrol('Parent',currPanel,'Units','pixels','Position',[200 panelDimens(4)-lineSpacing*(currParam+1+currGap) 100 20],'String',{'false','true'},'Value',paramvals{ii}+1,'Fontsize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_logicValCallback,'Style','popupmenu');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
330
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
331 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
332 case 'specwin'
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
333 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
334 selectWind = paramvals{ii}.type;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
335 listWindows = ['Kaiser',specwin.getTypes];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
336 selectWindValue = strmatch(selectWind,listWindows,'exact');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
337 % Window text:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
338 objName{ii,2} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[40 panelDimens(4)-lineSpacing*(currParam+1+currGap)-5 60 20],'String','Window:','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
339 % Window type popup:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
340 objName{ii,3} = uicontrol('Parent',currPanel,'Units','pixels','Position',[105 panelDimens(4)-lineSpacing*(currParam+1+currGap)-2 90 20],'String',listWindows,'TooltipString','Window names','Value',selectWindValue,'Visible','on','Enable','off','Tag',paramkeys{ii},'UserData',ii,'Callback', @g_WindListCallback,'Style','popupmenu');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
341 % Length value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
342 currLength = num2str(length(params.params(ii).val.win));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
343 objName{ii,4} = uicontrol('Parent',currPanel,'Units','pixels','Position',[200 panelDimens(4)-lineSpacing*(currParam+1+currGap)-2 70 20],'String',num2str(currLength),'TooltipString','Window Length','Visible','on','Enable','off','UserData',ii,'Callback', @g_WindlengthCallback,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
344 if strcmp(selectWind,'Kaiser')
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
345 % PSL value if Kaiser:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
346 currPSL = params.params(ii).val.psll;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
347 objName{ii,5} = uicontrol('Parent',currPanel,'Units','pixels','Position',[275 panelDimens(4)-lineSpacing*(currParam+1+currGap)-2 60 20],'String',num2str(currPSL),'TooltipString','Peak Sidelobe','Visible','on','Enable','off','UserData',ii,'Callback',@g_WindPSLCallback,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
348 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
349 % Simulink checkbox:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
350 objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','From Simulink','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[450 panelDimens(4)-lineSpacing*(currParam+1+currGap) 120 20],'Max',1,'Min',0,'Value',0,'Visible','on','Tag',num2str(ii),'UserData',paramvals{ii},'Callback',@g_fromSimulinkCallback,'Style','checkbox');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
351
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
352 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
353 case 'pzmodel'
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
354 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
355 % Simulink checkbox:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
356 objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','From Simulink','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[500 panelDimens(4)-lineSpacing*(currParam+1+currGap) 120 20],'Max',1,'Min',0,'Value',0,'Visible','on','Tag',num2str(ii),'UserData',paramvals{ii},'Callback',@g_fromSimulinkCallback,'Style','checkbox');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
357
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
358 clear pzObj currPoles poleFreqs poleQs poleFQs currZeros zeroFreqs zeroQs zeroFQs
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
359 pzObj = params.params(ii).val;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
360 currPoles = pzObj.poles;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
361 currZeros = pzObj.zeros;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
362 % Load button:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
363 objName{ii,3} = uicontrol('Parent',currPanel,'HorizontalAlignment','left','Position',[50 panelDimens(4)-(3+lineSpacing*(currParam+1+currGap)) 50 20],'String','Load','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','UserData',ii,'Callback',@g_pzmodelLoad,'enable','off','Style','pushbutton');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
364 % Gain text:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
365 objName{ii,4} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[120 panelDimens(4)-lineSpacing*(currParam+1+currGap)-5 40 20*guiFontSize/10],'String','Gain:','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
366 % Gain value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
367 currGain = pzObj.gain;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
368 objName{ii,5} = uicontrol('Parent',currPanel,'Units','pixels','Position',[155 panelDimens(4)-(2+lineSpacing*(currParam+1+currGap)) 60 20],'String',num2str(currGain),'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_pzmodelGainEdit,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
369 % Poles text:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
370 objName{ii,6} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[240 panelDimens(4)-lineSpacing*(currParam+1+currGap)-5 40 20],'String','Poles:','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
371 % Zeros text:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
372 objName{ii,7} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[355 panelDimens(4)-lineSpacing*(currParam+1+currGap)-5 40 20],'String','Zeros:','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
373 % Poles value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
374 for kk=1:numel(currPoles)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
375 poleFreqs(kk,1) = currPoles(kk).f;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
376 poleQs(kk,1) = currPoles(kk).q;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
377 if ~isnan(poleQs(kk,1))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
378 poleFQs{kk,1}=strcat(num2str(poleFreqs(kk,1)),',',num2str(poleQs(kk,1)));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
379 else
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
380 poleFQs{kk,1}=num2str(poleFreqs(kk,1));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
381 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
382 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
383 if numel(currPoles)>1 || numel(currZeros)>1
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
384 currGap=currGap+1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
385 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
386 if isempty(currPoles)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
387 poleFQs = '';
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
388 else
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
389 poleFQs=char(poleFQs);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
390 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
391 objName{ii,8} = uicontrol('Parent',currPanel,'Units','pixels','Position',[280 panelDimens(4)-(2+lineSpacing*(currParam+1+currGap))-(lineSpacing-30)*(max(numel(currPoles),numel(currZeros))>1) 60 (20+(max(numel(currPoles),numel(currZeros))>1)*lineSpacing)*guiFontSize/10],'Max',2,'String',poleFQs,'FontSize',guiFontSize+1,'TooltipString','Insert ''freq'' or ''freq,q'' on multiple lines','Visible','on','Enable','off','UserData',ii,'Callback',{@g_pzmodelPZEdit,1},'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
392 % Zeros value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
393 for kk=1:numel(currZeros)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
394 zeroFreqs(kk,1) = currZeros(kk).f;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
395 zeroQs(kk,1) = currZeros(kk).q;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
396 if ~isnan(zeroQs(kk,1))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
397 zeroFQs{kk,1}=strcat(num2str(zeroFreqs(kk,1)),',',num2str(zeroQs(kk,1)));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
398 else
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
399 zeroFQs{kk,1}=num2str(zeroFreqs(kk,1));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
400 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
401 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
402 if isempty(currZeros)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
403 zeroFQs = '';
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
404 else
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
405 zeroFQs = char(zeroFQs);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
406 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
407 objName{ii,9} = uicontrol('Parent',currPanel,'Units','pixels','Position',[395 panelDimens(4)-(2+lineSpacing*(currParam+1+currGap))-(lineSpacing-30)*(max(numel(currPoles),numel(currZeros))>1) 60 (20+(max(numel(currPoles),numel(currZeros))>1)*lineSpacing)*guiFontSize/10],'Max',2,'String',zeroFQs,'FontSize',guiFontSize+1,'TooltipString','Insert ''freq'' or ''freq,q'' on multiple lines','Visible','on','Enable','off','UserData',ii,'Callback',{@g_pzmodelPZEdit,0},'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
408
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
409 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
410 case 'pz'
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
411 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
412 % Simulink checkbox:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
413 objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','From Simulink','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[500 panelDimens(4)-lineSpacing*(currParam+1+currGap) 120 20],'Max',1,'Min',0,'Value',0,'Visible','on','Tag',num2str(ii),'UserData',paramvals{ii},'Callback',@g_fromSimulinkCallback,'Style','checkbox');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
414
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
415 currPoles = params.params(ii).val;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
416 clear poleFreqs poleQs poleFQs
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
417 for kk=1:numel(currPoles)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
418 poleFreqs(kk,1) = currPoles(kk).f;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
419 poleQs(kk,1) = currPoles(kk).q;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
420 if isnan(poleQs(kk,1))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
421 poleFQs{kk,1}=num2str(poleFreqs(kk,1));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
422 else
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
423 poleFQs{kk,1}=strcat(num2str(poleFreqs(kk,1)),',',num2str(poleQs(kk,1)));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
424 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
425
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
426 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
427 poleFQs=char(poleFQs);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
428 % Poles text:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
429 objName{ii,2} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[50 panelDimens(4)-(4+lineSpacing*(currParam+1+currGap)) 120 20],'String','PZ','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Enable','off','Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
430 if numel(currPoles)>1, currGap=currGap+1; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
431 % Poles value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
432 objName{ii,3} = uicontrol('Parent',currPanel,'Units','pixels','Position',[250 panelDimens(4)-(2+lineSpacing*(currParam+1+currGap))-(lineSpacing-30)*(numel(currPoles)>1) 100 (20+(numel(currPoles)>1)*lineSpacing)*guiFontSize/10],'String',poleFQs,'Max',2,'FontSize',guiFontSize,'TooltipString','Insert ''freq'' or ''freq,q''','Visible','on','Enable','on','UserData',ii,'Callback',@g_poleEdit,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
433
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
434 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
435 case 'cell'
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
436 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
437 if isa(paramvals{ii}{1},'char') && strcmp(paramvals{ii}{1},'-->')
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
438 % Key value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
439 objName{ii,2} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','Position',[50 panelDimens(4)-5-lineSpacing*(currParam+1+currGap) 120 20],'String',paramkeys{ii},'Visible','on','Enable','on','UserData',ii,'Callback',@g_editNameCallback,'Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
440 % Text: from Simulink environment:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
441 objName{ii,3} = uicontrol('TooltipString','Retrieve from Simulink','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[230 panelDimens(4)-6-lineSpacing*(currParam+1+currGap) 200 20],'String','From Simulink environment','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
442 fromSimulink = 1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
443 else
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
444 % Key value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
445 objName{ii,2} = uicontrol('Parent',currPanel,'Units','pixels','Position',[120 panelDimens(4)-lineSpacing*(currParam+1+currGap) 60 20],'String',paramkeys{ii},'Visible','on','Enable','off','UserData',ii,'Callback',@g_editNameCallback,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
446 if ~noParamsReq && ~addedPar
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
447 set(objName{ii,2},'Style','text','BackgroundColor',backColor,'Position',[50 panelDimens(4)-5-lineSpacing*(currParam+1+currGap) 120 20]);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
448 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
449 % Val value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
450 data = utils.prog.cell2str(paramvals{ii});
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
451 objName{ii,3} = uicontrol('Parent',currPanel,'Units','pixels','Position',[250 panelDimens(4)-lineSpacing*(currParam+1+currGap) 130 20],'String',data,'Visible','on','Enable','on','UserData',ii,'Callback',@g_editValueCallback,'Style','edit');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
452 fromSimulink = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
453 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
454
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
455 % Simulink checkbox:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
456 objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','From Simulink','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[500 panelDimens(4)-lineSpacing*(currParam+1+currGap) 120 20],'Max',1,'Min',0,'Value',fromSimulink,'Visible','on','Tag',num2str(ii),'UserData',paramvals{ii},'Callback',@g_fromSimulinkCallback,'Style','checkbox');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
457
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
458
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
459 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
460 otherwise % Other types of param?
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
461 % ==========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
462 % Key value:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
463 objName{ii,3} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','Position',[50 panelDimens(4)-5-lineSpacing*(currParam+1+currGap) 120 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editNameCallback,'Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
464 % Text: input not supported. Please construct by proper block.
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
465 objName{ii,4} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[250 panelDimens(4)-4-lineSpacing*(currParam+1+currGap) 200 20],'String','Unsupported yet','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
466 fromSimulink = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
467
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
468 % Simulink checkbox:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
469 objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','From Simulink','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[450 panelDimens(4)-lineSpacing*(currParam+1+currGap) 120 20],'Max',1,'Min',0,'Value',fromSimulink,'Visible','on','Tag',num2str(ii),'UserData',paramvals{ii},'Callback',@g_fromSimulinkCallback,'Style','checkbox');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
470
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
471 % ==============================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
472 end % of SWITCH the param type
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
473 % Cycle to activate enabled params:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
474 if paramEnabled(ii) || noParamsReq==1
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
475 [xx,yy] = size(objName);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
476 jj=2;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
477 while jj<=yy && ~isempty(objName{ii,jj})
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
478 try set(objName{ii,jj},'Enable','on'); set(objName{ii,jj},'ForegroundColor',[0 0 0]); catch, end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
479 jj=jj+1;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
480 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
481 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
482
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
483 end % of cycle among params
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
484
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
485 end % of buildplistFigureParam function
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
486 %----------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
487
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
488 %% ========================= Selection Check ==============================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
489 % =========================================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
490 %----------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
491 function g_ContinuousParamCheck(varargin)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
492 % This is the function to execute a continuous check on the status
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
493 % of the current selection (system and block).
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
494
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
495 currSelection = utils.prog.gcbsh;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
496 % set(findobj('Tag','LTPDAGUI'),'Name',[strtok(get(findobj('Tag','LTPDAGUI'),'Name'),' - '),' - ',bdroot]);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
497 if isnan(selBlocks), buildplistFigureParam([],[],get(findobj('Tag','paramsPage'),'UserData')); end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
498
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
499 % Clear the figure if nothing is and was selected OR nothing is and something was selected OR is selected a library
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
500 if (isempty(selBlocks) && isempty(currSelection)) || (~isempty(selBlocks) && isempty(currSelection)) || strcmp(get_param(bdroot,'BlockDiagramType'),'library')
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
501 delete(findobj(gcf,'Parent',currPanel))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
502 try close(findobj('Tag','parampanelFigure')); catch, end;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
503 selBlocks = [];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
504 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[0 (panelDimens(4)+30)/2 panelDimens(3) 30],'String','Nothing currently selected','Visible','on','Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
505 return
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
506 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
507
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
508 % Check that it's selected a ltpda simulink analysis diagram:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
509 if ~isempty(bdroot) && ~isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
510
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
511 if ((numel(selBlocks)==1 && selBlocks~=gcbh) || length(selBlocks)~=length(currSelection)) || selBlocks(1)~=currSelection(1) && ~isempty(currSelection)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
512 delete(findobj(gcf,'Parent',currPanel))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
513 try close(findobj('Tag','parampanelFigure')); catch, end;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
514 GUIprefs = getappdata(0, 'GUIpreferences');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
515 if GUIprefs.CAD
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
516 if GUIprefs.Copied
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
517 if length(currSelection)<1, return; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
518 currSelection = g_copyfcnCallback(selBlocks,currSelection);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
519 GUIprefs.Copied = 0;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
520 setappdata(0, 'GUIpreferences',GUIprefs)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
521 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
522 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
523 for i=1:length(currSelection)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
524 set_param(currSelection(i),'LinkStatus','inactive');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
525 currentTags{i}=get_param(currSelection(i),'Tag');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
526 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
527
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
528 if strcmp(currentTags{1},'')
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
529 delete(findobj(gcf,'Parent',currPanel))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
530 selBlocks = currSelection;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
531 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[0 (panelDimens(4)+30)/2 panelDimens(3) 30],'String','Not a valid LTPDA block','Visible','on','Style','text');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
532 return
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
533 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
534
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
535 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
536 if numel(currSelection)>1 % then the user has selected multiple blocks
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
537 % Check for consistency: all methods? same class?
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
538 for i=1:numel(currentTags)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
539 if ~strcmp(currentTags{i},currentTags{1})
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
540 g_ErrorSelectionInconsistent(currPanel);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
541 selBlocks = currSelection;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
542 return;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
543 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
544 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
545 % Check for consistency: same method?:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
546 for i=1:numel(currSelection)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
547 childpath = find_system(currSelection(i),'LookUnderMasks','all','BlockType','M-S-Function');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
548 functionname{i}=get_param(childpath,'Tag');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
549 if ~strcmp(functionname{i},functionname{1}) % different functions, inconsistent selection
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
550 g_ErrorSelectionInconsistent(currPanel);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
551 selBlocks = currSelection;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
552 return;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
553 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
554 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
555 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
556 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
557
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
558 delete(findobj(gcf,'Parent',currPanel))
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
559 selBlocks = currSelection;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
560 oldparams = []; params = []; paramEnabled = []; oldparamEnabled = []; functionName = ''; paramSets = [];
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
561
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
562 % Get the new functionName:
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
563 childpath = find_system(gcbh,'LookUnderMasks','all','BlockType','M-S-Function');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
564 functionName = get_param(childpath,'Tag');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
565 if isempty(functionName)
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
566 description = get_param(gcbh,'Description');
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
567 funcname = findstr('functionName=',description);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
568 if funcname
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
569 i = funcname+14;
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
570 while ~strcmp(description(i),';'), i=i+1; end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
571 functionName = description(funcname+14:i-2);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
572 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
573 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
574 funcType = strtok(get(gcbh,'Tag'));
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
575 if isempty(functionName) && strcmp(funcType,'method')
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
576 functionName = g_setmethod();
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
577 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
578
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
579 switch funcType
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
580 % =========================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
581 case {'function','freepl','method'}
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
582 buildplistFigureParam()
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
583 % =========================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
584 case 'arithmetic'
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
585 g_arithmetic(currPanel);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
586 % =========================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
587 case 'input'
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
588 g_LoadInputParamCallback(currPanel);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
589 % =========================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
590 case {'mux','demux'}
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
591 g_LoadMuxParamCallback();
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
592 % =========================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
593 case 'from'
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
594 g_LoadFromBlockCallback(currPanel);
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
595 % =========================================================
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
596 end % of switch
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
597
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
598 end % end of blocks selection
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
599 end % end of system selection check
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
600
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
601 end
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
602 %----------------------------------------------------------------------
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
603
f0afece42f48 Import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
604 end