0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 function pan8nested(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % ========================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % =================== Panel to organize nested loops =====================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % ========================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % $Id: pan8nested.m,v 1.3 2008/11/07 17:59:42 nicola Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 scaleX = getappdata(0, 'ltpda_gui_scalefactor');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 guiFontSize = round(10*scaleX);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 currPanel = varargin{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 panelDimens = get(currPanel, 'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 backColor = get(currPanel, 'BackgroundColor');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 global paramLoop currSys enabledNestedParams
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 currSys = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 alltimers = timerfindall;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 stop(alltimers(2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 set(alltimers(2),'TimerFcn',@ContinuousCheck,'Period',1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 start(alltimers(2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 function buildNestedPanel(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 delete(findobj(gcf,'Parent',currPanel))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 % Check if nested loops execution is enabled or not:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 nestBlock = find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 if isempty(nestBlock)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 nestedStatus = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 nestBlock = {''};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 elseif isempty(get_param(nestBlock{1},'Description'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 set_param(nestBlock{1},'Description','0');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 nestedStatus = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 nestedStatus = str2double(get_param(nestBlock{1},'Description'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 % Enable nested loops:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'TooltipString','Enable or disable the execution of nested loops: when disabled the variables won''t be cleared','Units','normalized','Position',[0.2 0.92 0.2 0.040],'String',' Enable nested loops','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Value',nestedStatus,'Visible','on','Callback',{@enableNested,currPanel,nestBlock{1}},'Style','checkbox');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 % Current system:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Units','normalized','Position',[0.5 0.92 0.125 0.040],'String','Current system:','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 currsystem = bdroot;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 if isempty(currsystem) || isempty(find_system(currsystem,'FindAll','on','Type','Annotation','Tag','ltpda model')), currsystem = 'None'; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Units','normalized','Position',[0.65 0.92 0.25 0.040],'String',currsystem,'FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','UserData','currsystem','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 if isempty(nestBlock{1})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 paramLoop = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 paramnumb = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 enabledNestedParams = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 paramLoop = get_param(nestBlock{1},'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 paramnumb = size(paramLoop,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 enabledNestedParams = get_param(nestBlock{1},'MaskDescription');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 if ~isempty(enabledNestedParams)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 eval(enabledNestedParams);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 enabledNestedParams = ones(1,paramnumb);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 set_param(nestBlock{1},'MaskDescription',['enabledNestedParams = ',mat2str(enabledNestedParams),';'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 for i=1:paramnumb %ie, for every row
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 % Set the proper number to each row:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 paramLoop{i,1}=i;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 % Check that every parameter has a valid order value:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 if isempty(paramLoop{i,2}), paramLoop{i,2}=1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 % Check that every parameter has a name (not empty):
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 if isempty(paramLoop{i,3})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 ii=1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 while ~isempty(findstr(['loop.var',num2str(ii)],[paramLoop{:,3}])), ii=ii+1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 paramLoop{i,3}=['loop.var',num2str(ii)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 % Check that every parameter has a values array (even empty):
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 if isempty(paramLoop{i,6}), paramLoop{i,6}={}; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 % % % % Defining the array with the names/handles of all the elements in the GUI:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 % % % global AllNames
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 % Dimensions of all the objects which can be created inside the Loop Panel:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 AddButtDimension = [20 20]; RemButtDimension = [20 20];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 LeftArrDimension = [20 20]; RightArrDimension = [20 20];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 UpArrDimension = [20 15]; DownArrDimension = [20 15];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 Param2ChangeDimension = [150 20]; IterValDimension = [60 20];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 % Legend (static part of the window):
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[40 panelDimens(4)-80 50 30],'String',{'Add /','Remove'},'FontName','Times New Roman','FontSize',guiFontSize,'Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[110 panelDimens(4)-85 45 30],'String','Position','FontName','Times New Roman','FontSize',guiFontSize,'Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[195 panelDimens(4)-85 110 30],'String','Parameter name','FontName','Times New Roman','FontSize',guiFontSize,'Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[360 panelDimens(4)-85 70 30],'String','Iterations','FontName','Times New Roman','FontSize',guiFontSize,'Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 % =========================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 % This part build the dynamic part of the window:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 % =========================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 if 40*(paramnumb+3)+20 < panelDimens(4), possible2add = 'on';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 else possible2add = 'off';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 for i=1:paramnumb
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 AddButtPosition = [45 panelDimens(4)-40*(i+2)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 RemButtPosition = [67 panelDimens(4)-40*(i+2)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 LeftArrPosition = [105+30*(paramLoop{i,2}-1) panelDimens(4)-40*(i+2)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 UpArrPosition = [125+30*(paramLoop{i,2}-1) panelDimens(4)+8-40*(i+2)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 DownArrPosition = [125+30*(paramLoop{i,2}-1) panelDimens(4)-8-40*(i+2)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 RightArrPosition = [145+30*(paramLoop{i,2}-1) panelDimens(4)-40*(i+2)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 Param2ChangePosition = [180+30*(paramLoop{i,2}-1) panelDimens(4)-40*(i+2)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 IterValPosition = [355+30*(paramLoop{i,2}-1) panelDimens(4)-40*(i+2)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 % Checkbox to enable this param:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 uicontrol('Parent',currPanel,'Value',enabledNestedParams(i),'TooltipString','Enable or disable this parameter only','Units','pixels','BackGroundColor',[1 1 1],'Position',[15 panelDimens(4)-40*(i+2)+2 15 15],'Visible','on','Enable',possible2add,'UserData',i,'Callback',{@EnableNestedParam,currPanel,nestBlock{1}},'Style','checkbox');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 uicontrol('Parent',currPanel,'TooltipString','Add another parameter','Units','pixels','Position',[AddButtPosition,AddButtDimension],'String','+','Visible','on','Enable',possible2add,'UserData',i,'Callback', @AddButtCallback,'Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 uicontrol('Parent',currPanel,'TooltipString','Remove this parameter','Units','pixels','Position',[RemButtPosition,RemButtDimension],'String','-','Visible','on','Enable','on','UserData',i,'Callback', @RemButtCallback,'Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 LeftArrNames{i} = uicontrol('Parent',currPanel,'TooltipString','Move this parameter to the left','Units','pixels','Position',[LeftArrPosition,LeftArrDimension],'String','<','Visible','on','Enable','on','UserData',i,'Callback', @LeftArrCallback,'Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 RightArrNames{i} = uicontrol('Parent',currPanel,'TooltipString','Move this parameter to the right','Units','pixels','Position',[RightArrPosition,RightArrDimension],'String','>','Visible','on','Enable','on','UserData',i,'Callback', @RightArrCallback,'Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 UpArrNames{i} = uicontrol('Parent',currPanel,'TooltipString','Move this parameter up','Units','pixels','Position',[UpArrPosition,DownArrDimension],'String','','Visible','on','Enable','on','UserData',i,'Callback', @UpArrCallback,'Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 DownArrNames{i} = uicontrol('Parent',currPanel,'TooltipString','Move this parameter down','Units','pixels','Position',[DownArrPosition,UpArrDimension],'String','','Visible','on','Enable','on','UserData',i,'Callback', @DownArrCallback,'Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 uicontrol('Parent',currPanel,'Units','pixels','Position',[Param2ChangePosition,Param2ChangeDimension],'String',paramLoop{i,3},'Visible','on','Enable','on','UserData',i,'Callback',@ParamNameChange,'Style','edit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 IterValNames{i} = uicontrol('Parent',currPanel,'TooltipString','The number of iterations associated to this parameter','Units','pixels','Position',[IterValPosition,IterValDimension],'String','-','Visible','on','Enable','on','UserData',i,'Callback',@SetIterations,'Tag',['iterButton',num2str(i)],'Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 if ~isempty(paramLoop{i,4}), set(IterValNames{i},'String',num2str(paramLoop{i,4})); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 if i==1, set(UpArrNames{i},'Enable','off'); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 if i==paramnumb, set(DownArrNames{i},'Enable','off'); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 if paramLoop{i,2}==paramLoop{i,1}, set(RightArrNames{i},'Enable','off');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 else set(RightArrNames{i},'Enable','on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 if paramLoop{i,2}==1, set(LeftArrNames{i},'Enable','off');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 else set(LeftArrNames{i},'Enable','on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 % Last button to add a parameter:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 paramnumb = paramnumb+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 uicontrol('Parent',currPanel,'Units','pixels','Position',[45 panelDimens(4)-40*(paramnumb+2) 20 20],'String','+','Visible','on','Enable',possible2add,'UserData',paramnumb,'Callback', @AddButtCallback,'Tag','lastaddbutton','Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 if ~nestedStatus
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 set([findobj(currPanel,'Style','pushbutton');findobj(currPanel,'Style','edit')],'Enable','off');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 set(findobj(currPanel,'Style','text'),'ForegroundColor',[.8 .8 .8]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 set(findobj(currPanel,'Tag','lastaddbutton'),'enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 % ======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 % ======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 % ============================= FUNCTIONS ==============================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 % ======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 % ======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 function ContinuousCheck(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 % This is the function to execute a continuous check on the status
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 % of the current selection, to verify that a valid LTPDA model is
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 % selected.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 % Clear if nothing's selected
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 if isempty(bdroot) || strcmp(get_param(bdroot,'BlockDiagramType'),'library') || isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 delete(findobj(gcf,'Parent',currPanel))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 currSys = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 paramLoop = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 enabledNestedParams = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 if ~strcmp(gcs,currSys)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 % The selection changed: redraw the panel.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 currSys = gcs;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 enabledNestedParams = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 buildNestedPanel();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 function enableNested(hObject, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 % Callback for the 'Enable nested loops' checkbox.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 currStatus = get(hObject,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 currPanel = varargin{2};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 nestBlock = varargin{3};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 allElements = [findobj(currPanel,'Style','pushbutton');findobj(currPanel,'Style','edit');findobj(currPanel,'Style','checkbox')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 allTexts = findobj(currPanel,'Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 if isempty(nestBlock)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 paramLoop = {1,1,[],[],[],{},[]};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 nestBlock = add_block('ltpda_library/Commonly Used Blocks/Globals',[bdroot '/Nested loops']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 annotation = find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 position = get_param(annotation,'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 set_param(nestBlock,'LinkStatus','inactive','Showname','off','MaskDisplay','disp(''Nested loops'')','Tag','nestedloops','DropShadow','on','Position',[position(1)+20 position(2)-42 position(1)+150 position(2)-27 ])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 set_param(nestBlock,'UserData',paramLoop,'UserDataPersistent','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 switch currStatus
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 case 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 set_param(nestBlock,'Description','1');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 set_param(nestBlock,'UserData',paramLoop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 buildNestedPanel();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 case 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 set_param(nestBlock,'Description','0');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 set(allElements,'Enable','off');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 set(hObject,'Enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 set(findobj(currPanel,'Tag','lastaddbutton'),'enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 set(allTexts,'ForegroundColor',[.8 .8 .8]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 function EnableNestedParam(hObject, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 % Callback for the 'Enable nested param' checkbox, for EVERY PARAM.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 currStatus = get(hObject,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 currPanel = varargin{2};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 nestBlock = varargin{3};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 currParamIndex = get(hObject,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 enabledNestedParams(currParamIndex) = currStatus;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 set_param(nestBlock,'MaskDescription',['enabledNestedParams = ',mat2str(enabledNestedParams),';'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 function AddButtCallback(hObject, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 % Callback function: run when the user click on the Add button: another
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 % parameter is added BELOW the row where user has clicked.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 % Retrieve the index (row) of the clicked button:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 currParamIndex = get(hObject,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 if currParamIndex==1 && isempty(paramLoop)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 paramLoop = {1,1,[],[],[],{},[]};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 nestBlock = add_block('ltpda_library/Commonly Used Blocks/Globals',[bdroot '/Nested loops']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 annotation = find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 position = get_param(annotation,'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 set_param(nestBlock,'LinkStatus','inactive','Showname','off','MaskDisplay','disp(''Nested loops'')','Tag','nestedloops','DropShadow','on','Position',[position(1)+20 position(2)-42 position(1)+150 position(2)-27 ])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 set_param(nestBlock,'Description','1','UserData',paramLoop,'UserDataPersistent','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 enabledNestedParams = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 set_param(nestBlock,'MaskDescription','enabledNestedParams = 1;')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 if currParamIndex > size(paramLoop,1), currParamIndex = size(paramLoop,1); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 paramLoop = [paramLoop(1:currParamIndex,:);cell(1,7);paramLoop(currParamIndex+1:end,:)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 currParamIndex = currParamIndex+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 paramLoop{currParamIndex,1} = currParamIndex;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 paramLoop{currParamIndex,2} = paramLoop{currParamIndex-1,2};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 nestBlock = find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 set_param(nestBlock{1},'Description','1','UserData',paramLoop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 enabledNestedParams = [enabledNestedParams , 1];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 set_param(nestBlock{1},'MaskDescription',['enabledNestedParams = ',mat2str(enabledNestedParams),';'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 buildNestedPanel()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 function RemButtCallback(hObject, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 % Callback function: run when the user click on the Remove button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 % Retrieve the index of the clicked button:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 currParamIndex = get(hObject,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 nestBlock = find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 if currParamIndex==1 && size(paramLoop,1)==1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 clear paramLoop enabledNestedParams
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 delete_block(nestBlock{1})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 xx = size(paramLoop,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 ii = currParamIndex+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287 while ii <= xx && paramLoop{ii,2} > paramLoop{currParamIndex,2}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 paramLoop{ii,2} = paramLoop{ii,2}-1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 ii = ii+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 paramLoop = [paramLoop(1:currParamIndex-1,:);paramLoop(currParamIndex+1:end,:)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 set_param(nestBlock{1},'UserData',paramLoop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 enabledNestedParams(currParamIndex) = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 set_param(nestBlock{1},'MaskDescription',['enabledNestedParams = ',mat2str(enabledNestedParams),';'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 buildNestedPanel()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 function LeftArrCallback(hObject, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 % Callback function: run when the user click on the Left Arrow button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306 % Retrieve the number of the modified parameter:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 currParamIndex = get(hObject,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 xx = size(paramLoop,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 ii = currParamIndex+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 while ii <= xx && paramLoop{ii,2} > paramLoop{currParamIndex,2}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312 paramLoop{ii,2} = paramLoop{ii,2}-1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 ii = ii+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 paramLoop{currParamIndex,2} = paramLoop{currParamIndex,2}-1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 nestBlock = find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318 set_param(nestBlock{1},'UserData',paramLoop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 buildNestedPanel()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325 function RightArrCallback(hObject, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 % Callback function: run when the user click on the Right Arrow button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 % Retrieve the number of the modified parameter:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 currParamIndex = get(hObject,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 % Move to the right the parents parameters:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 ii=currParamIndex;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 if ii>1 && paramLoop{currParamIndex,2}<paramLoop{currParamIndex,1}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 while paramLoop{ii-1,2}==paramLoop{ii,2}-1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 % ie, till when the previous parameters are parents:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 ii=ii-1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 if ii==2, break; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 % ii is the first parent parameter
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 if paramLoop{currParamIndex,2}<=paramLoop{currParamIndex,1}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 for i=ii:currParamIndex, paramLoop{i,2}=paramLoop{i,2}+1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 nestBlock = find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 set_param(nestBlock{1},'UserData',paramLoop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 buildNestedPanel()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 function UpArrCallback(hObject, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 % Callback function: run when the user click on the Up Arrow button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 % Retrieve the number of the modified parameter:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 currParamIndex = get(hObject,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 xx = size(paramLoop,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 % Move to the left the parameters children:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 ii=currParamIndex;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 if ii<xx
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 while paramLoop{ii+1,2}==paramLoop{ii,2}+1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364 % ie, till when the next parameters are children:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 ii=ii+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366 if ii==xx, break; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 % ii is the last children parameter
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 for i=currParamIndex+1:ii, paramLoop{i,2}=paramLoop{i,2}-1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 % We move up the selected row:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 paramLoop([currParamIndex-1,currParamIndex],:) = paramLoop([currParamIndex,currParamIndex-1],:);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374 paramLoop{currParamIndex-1,2} = paramLoop{currParamIndex,2};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375 enabledNestedParams([currParamIndex-1,currParamIndex]) = enabledNestedParams([currParamIndex,currParamIndex-1]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 for i=1:xx, paramLoop{i,1}=i; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 nestBlock = find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379 set_param(nestBlock{1},'UserData',paramLoop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 set_param(nestBlock{1},'MaskDescription',['enabledNestedParams = ',mat2str(enabledNestedParams),';'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381 buildNestedPanel()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387 function DownArrCallback(hObject, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388 % Callback function: run when the user click on the Down Arrow button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390 % Retrieve the number of the modified parameter:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 currParamIndex = get(hObject,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392 xx = size(paramLoop,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394 % Move to the left the parameters children:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395 ii=currParamIndex;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396 if ii<xx
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 while paramLoop{ii+1,2}==paramLoop{ii,2}+1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398 % ie, till when the next parameters are children:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 ii=ii+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400 if ii==xx, break; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 for i=currParamIndex+1:ii, paramLoop{i,2}=paramLoop{i,2}-1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 % We move down the selected row:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406 paramLoop([currParamIndex,currParamIndex+1],:) = paramLoop([currParamIndex+1,currParamIndex],:);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 paramLoop{currParamIndex,2}=paramLoop{currParamIndex+1,2};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408 enabledNestedParams([currParamIndex,currParamIndex+1]) = enabledNestedParams([currParamIndex+1,currParamIndex]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 for i=1:xx, paramLoop{i,1}=i; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 nestBlock = find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 set_param(nestBlock{1},'UserData',paramLoop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413 set_param(nestBlock{1},'MaskDescription',['enabledNestedParams = ',mat2str(enabledNestedParams),';'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 buildNestedPanel()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420 function ParamNameChange(hObject, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421 % Callback function: run when the user changes the name of the variable
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423 % Retrieve the number of the modified parameter:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 currParamIndex = get(hObject,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 newName = get(hObject,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427 oldName = paramLoop{currParamIndex,3};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429 if isempty(newName) || ismember(newName,paramLoop(:,3)), set(hObject,'String',oldName), return; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430 if numel(newName)<6 || ~strcmp(newName(1:5),'loop.'), newName = ['loop.',strrep(newName,'.','')]; set(hObject,'String',newName); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432 paramLoop{currParamIndex,3} = newName;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 nestBlock = find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434 set_param(nestBlock{1},'UserData',paramLoop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441 function SetIterations(hObject,varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443 existingFig = findobj('Name','Set iterations');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444 if ~isempty(existingFig), close(existingFig); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446 % Retrieve the number of the modified parameter:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447 currParamIndex = get(hObject,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 if ~isempty(paramLoop{currParamIndex,5}) % then there are range settings
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 range = paramLoop{currParamIndex,5};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450 min = num2str(range(1)); step = num2str(range(2)); max = num2str(range(3));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451 range = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452 else % there are just direct values settings
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453 min = ''; step = ''; max = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454 range = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457 screenSize = get(0,'ScreenSize');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 backColor = [1 1 1];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459 setIterSize = [570, 280];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460 position = [(screenSize(3)-setIterSize(1))/2 , (screenSize(4)-setIterSize(2))/2 , setIterSize];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461 setIterFig = figure('Position',position,'Name','Set iterations','Tag','setiterations','Resize','off','NumberTitle','off','Toolbar','none','Menubar','none');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462 % Texts
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[30 position(4)-40 80 20],'String','Default:','FontName','Times New Roman','FontSize',guiFontSize+3,'FontWeight','bold','Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[30 position(4)-80 80 20],'String','Iterations:','FontName','Times New Roman','FontSize',guiFontSize+3,'FontWeight','bold','Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465 % Radio buttons:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466 rangeORvalues = uibuttongroup('Parent',setIterFig,'BackgroundColor',backColor,'visible','on','SelectionChangeFcn',@enableRangeOrValues);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467 uicontrol('Parent',rangeORvalues,'BackgroundColor',backColor,'UserData',0,'HorizontalAlignment','center','Position',[150 position(4)-80 100 20],'String','Range:','FontName','Times New Roman','FontSize',guiFontSize+1,'Visible','on','Value',range,'Style','radiobutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 uicontrol('Parent',rangeORvalues,'BackgroundColor',backColor,'UserData',1,'HorizontalAlignment','center','Position',[150 position(4)-110 100 20],'String','Values:','FontName','Times New Roman','FontSize',guiFontSize+1,'Visible','on','Value',~range,'Style','radiobutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470 % Default:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471 defVal = paramLoop{currParamIndex,7};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472 if isempty(defVal), defVal = ''; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[140 position(4)-40 100 20],'String',defVal,'TooltipString','This value will be used whenever this variable isn''t looping, or nested loops are disabled','Enable','on','Tag','defaultvalue','Style','edit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475 % GUI elements for range settings:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476 inputExamples = {'Insert only';...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477 'scalar';...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478 'numbers:'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[270 position(4)-250 80 170],'String',inputExamples,'Visible','on','Tag','range','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[350 position(4)-85 50 20],'String','Min:','Visible','off','Enable','on','Tag','range','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[400 position(4)-80 50 20],'String',min,'Visible','off','Enable','on','Tag','rangemin','Style','edit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[350 position(4)-115 50 20],'String','Step:','Visible','off','Enable','on','Tag','range','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[400 position(4)-110 50 20],'String',step,'Visible','off','Enable','on','Tag','rangestep','Style','edit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[350 position(4)-145 50 20],'String','Max:','Visible','off','Enable','on','Tag','range','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[400 position(4)-140 50 20],'String',max,'Visible','off','Enable','on','Tag','rangemax','Style','edit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486 % Apply button:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487 uicontrol('Parent',setIterFig,'BackgroundColor',[.9 .9 .9],'Units','pixels','Position',[250 15 60 25],'String','Apply >','Visible','off','Enable','on','Callback',@calcIterRange,'UserData',0,'Tag','range','Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','left','Position',[325 17 200 20],'String','---','FontSize',guiFontSize+1,'Visible','off','Tag','rangeIter','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490 % GUI elements for direct values settings:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491 listInput = paramLoop{currParamIndex,6};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492 inputExamples = {'Examples:';...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493 ' 1';...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494 ' 2';...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495 ' ';...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496 ' or:';...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
497 ' ''one''';...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
498 ' ''two''';...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
499 ' ';...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
500 ' or:';...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
501 ' [1:5]';...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
502 ' [10:10:50]'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
503 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','left','Position',[270 position(4)-230 140 170],'String',inputExamples,'Visible','on','Tag','values','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
504 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[360 position(4)-210 150 150],'String',listInput,'Max',10,'FontSize',guiFontSize,'Visible','on','Enable','on','Callback',@valuesListCallback,'Tag','valuesList','UserData',currParamIndex,'Style','edit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
505 % Apply button:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
506 uicontrol('Parent',setIterFig,'BackgroundColor',[.9 .9 .9],'Units','pixels','Position',[250 15 60 25],'String','Apply >','Visible','on','Enable','on','Callback',@calcIterRange,'UserData',1,'Tag','values','Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
507 uicontrol('Parent',setIterFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','left','Position',[325 17 200 20],'String','---','FontSize',guiFontSize+1,'Visible','on','Tag','valuesIter','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
508
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
509 if ~isempty(paramLoop{currParamIndex,6}) % then there are values
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
510 numbIter = numel(paramLoop{currParamIndex,6});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
511 set(findobj(gcf,'tag','valuesIter'),'String',[num2str(numbIter),' iterations'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
512 set(findobj(gcf,'tag','rangeIter'),'String',[num2str(numbIter),' iterations'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
513 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
514
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
515 if range, enableRangeOrValues(-1,0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
516 else enableRangeOrValues(-1,1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
517 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
518
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
519 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
520 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
521
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
522 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
523 function enableRangeOrValues(hObject,varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
524
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
525 if hObject==-1, rangeORvalue = varargin{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
526 else rangeORvalue = get(get(hObject,'SelectedObject'),'userdata');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
527 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
528
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
529 if rangeORvalue % value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
530 set(findobj(gcf,'-regexp','Tag','^range'),'visible','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
531 set(findobj(gcf,'-regexp','Tag','^values'),'visible','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
532 else % range
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
533 set(findobj(gcf,'-regexp','Tag','^range'),'visible','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
534 set(findobj(gcf,'-regexp','Tag','^values'),'visible','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
535 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
536
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
537 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
538 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
539
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
540 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
541 function calcIterRange(hObject,varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
542
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
543 rangeORvalue = get(hObject,'userdata');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
544 defaultVal = findobj(gcf,'Tag','defaultvalue');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
545 if isempty(get(defaultVal,'String'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
546 set(findobj(gcf,'tag','valuesIter'),'String','Please insert a default value')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
547 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
548 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
549
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
550 if rangeORvalue % value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
551 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
552 listField = findobj(gcf,'tag','valuesList');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
553 valuesList = get(listField,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
554 currParamIndex = get(listField,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
555 numbIter = size(valuesList,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
556 paramLoop{currParamIndex,4} = numbIter;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
557 paramLoop{currParamIndex,5} = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
558 paramLoop{currParamIndex,6} = valuesList;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
559 nestBlock = find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
560 set_param(nestBlock{1},'UserData',paramLoop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
561
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
562 set(findobj(gcf,'tag','rangemin'),'String','')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
563 set(findobj(gcf,'tag','rangestep'),'String','')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
564 set(findobj(gcf,'tag','rangemax'),'String','')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
565 set(findobj(gcf,'tag','valuesIter'),'String',[num2str(numbIter),' iterations'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
566 set(findobj('Tag',['iterButton',num2str(currParamIndex)]),'String',num2str(numbIter))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
567 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
568 set(findobj(gcf,'tag','valuesIter'),'String','Error')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
569 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
570 else % range
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
571 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
572 minVal = str2double(get(findobj(gcf,'tag','rangemin'),'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
573 stepVal = str2double(get(findobj(gcf,'tag','rangestep'),'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
574 maxVal = str2double(get(findobj(gcf,'tag','rangemax'),'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
575 valuesList = num2cell([minVal:stepVal:maxVal]'); %#ok<NBRAK>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
576 if ~iscell(valuesList) && isnan(valuesList), error(''); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
577 listField = findobj(gcf,'tag','valuesList');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
578 currParamIndex = get(listField,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
579 numbIter = size(valuesList,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
580 paramLoop{currParamIndex,4} = numbIter;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
581 paramLoop{currParamIndex,5} = [minVal,stepVal,maxVal];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
582 paramLoop{currParamIndex,6} = valuesList;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
583 nestBlock = find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
584 set_param(nestBlock{1},'UserData',paramLoop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
585
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
586 set(findobj(gcf,'tag','valuesList'),'String',valuesList)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
587 set(findobj(gcf,'tag','rangeIter'),'String',[num2str(numbIter),' iterations'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
588 set(findobj('Tag',['iterButton',num2str(currParamIndex)]),'String',num2str(numbIter))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
589 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
590 set(findobj(gcf,'tag','rangeIter'),'String','Error')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
591 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
592 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
593 paramLoop{currParamIndex,7} = get(defaultVal,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
594
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
595 nestBlock = find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
596 set_param(nestBlock{1},'UserData',paramLoop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
597 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
598 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
599
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
600 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
601 function valuesListCallback(hObject, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
602
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
603 valuesList = get(hObject,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
604 currParamIndex = get(hObject,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
605 paramLoop{currParamIndex,6} = valuesList;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
606
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
607 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
608 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
609
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
610 end
|