Mercurial > hg > ltpda
comparison m-toolbox/m/gui/gltpda/g_LoadMuxParamCallback.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 function g_LoadMuxParamCallback(varargin) | |
2 % This callback is called whenever the user selects a Mux block (or | |
3 % Demux). The callback opens the panel to set the only parameter | |
4 % associated to this type of block: the number of inputs. | |
5 % The function sets also the dimension of the block accordingly. | |
6 | |
7 if strcmp(get(gcbh,'Tag'),'mux'), | |
8 % Text: 'Number of inputs:' | |
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'); | |
10 % Edit field: | |
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'); | |
12 elseif strcmp(get(gcbh,'Tag'),'demux'), | |
13 % Text: 'Number of outputs:' | |
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'); | |
15 % Edit field: | |
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'); | |
17 end | |
18 | |
19 %---------------------------------------------------------------------- | |
20 function MuxEditCallback(hObject, varargin) | |
21 % This callback is called whenever the user modify the number of inputs | |
22 % associated to a Mux block (or outputs to a Demux) | |
23 | |
24 newValue = str2double(get(hObject,'String')); | |
25 % Check it's an integer: | |
26 newValue = round(newValue); | |
27 set(hObject,'String',num2str(newValue)); | |
28 for i=1:length(selBlocks) | |
29 newDimens=get(selBlocks(i),'Position'); | |
30 newDimens(4)=newDimens(2)+25*(newValue+1); | |
31 if strcmp(get(gcbh,'Tag'),'mux'), | |
32 set(selBlocks(i),'Inputs',num2str(newValue)); | |
33 elseif strcmp(get(gcbh,'Tag'),'demux'), | |
34 set(selBlocks(i),'Outputs',num2str(newValue)); | |
35 end | |
36 set(selBlocks(i),'Position',newDimens); | |
37 end | |
38 end | |
39 %---------------------------------------------------------------------- | |
40 | |
41 end |