0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 function g_LoadMuxParamCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 % This callback is called whenever the user selects a Mux block (or
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % Demux). The callback opens the panel to set the only parameter
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % associated to this type of block: the number of inputs.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % The function sets also the dimension of the block accordingly.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 if strcmp(get(gcbh,'Tag'),'mux'),
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % Text: 'Number of inputs:'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','left','Position',[100 panelDimens(4)-60 100 20],'String','Number of inputs:','Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % Edit field:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 uicontrol('Parent',currPanel,'Units','pixels','HorizontalAlignment','center','Position',[210 panelDimens(4)-57 50 20],'String',get(gcbh,'Inputs'),'Visible','on','Enable','on','Callback',@MuxEditCallback,'Style','edit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 elseif strcmp(get(gcbh,'Tag'),'demux'),
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % Text: 'Number of outputs:'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','left','Position',[100 panelDimens(4)-60 100 20],'String','Number of outputs:','Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % Edit field:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 uicontrol('Parent',currPanel,'Units','pixels','HorizontalAlignment','center','Position',[210 panelDimens(4)-57 50 20],'String',get(gcbh,'Outputs'),'Visible','on','Enable','on','Callback',@MuxEditCallback,'Style','edit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 function MuxEditCallback(hObject, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % This callback is called whenever the user modify the number of inputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 % associated to a Mux block (or outputs to a Demux)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 newValue = str2double(get(hObject,'String'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % Check it's an integer:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 newValue = round(newValue);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 set(hObject,'String',num2str(newValue));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 for i=1:length(selBlocks)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 newDimens=get(selBlocks(i),'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 newDimens(4)=newDimens(2)+25*(newValue+1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 if strcmp(get(gcbh,'Tag'),'mux'),
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 set(selBlocks(i),'Inputs',num2str(newValue));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 elseif strcmp(get(gcbh,'Tag'),'demux'),
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 set(selBlocks(i),'Outputs',num2str(newValue));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 set(selBlocks(i),'Position',newDimens);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 end |