diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/m/gui/gltpda/g_LoadMuxParamCallback.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,41 @@
+    function g_LoadMuxParamCallback(varargin)   
+    % This callback is called whenever the user selects a Mux block (or 
+    % Demux). The callback opens the panel to set the only parameter
+    % associated to this type of block: the number of inputs.
+    % The function sets also the dimension of the block accordingly.
+        
+        if strcmp(get(gcbh,'Tag'),'mux'),
+          % Text: 'Number of inputs:'
+            uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','left','Position',[100 panelDimens(4)-60 100 20],'String','Number of inputs:','Visible','on','Style','text');
+          % Edit field:
+            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');
+        elseif strcmp(get(gcbh,'Tag'),'demux'),
+          % Text: 'Number of outputs:'
+            uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','left','Position',[100 panelDimens(4)-60 100 20],'String','Number of outputs:','Visible','on','Style','text');
+          % Edit field:
+            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');
+        end
+
+    %----------------------------------------------------------------------
+    function MuxEditCallback(hObject, varargin)   
+    % This callback is called whenever the user modify the number of inputs
+    % associated to a Mux block (or outputs to a Demux)
+    
+         newValue   = str2double(get(hObject,'String'));
+       % Check it's an integer:
+         newValue = round(newValue);
+         set(hObject,'String',num2str(newValue));
+         for i=1:length(selBlocks)
+             newDimens=get(selBlocks(i),'Position');
+             newDimens(4)=newDimens(2)+25*(newValue+1);
+             if strcmp(get(gcbh,'Tag'),'mux'),
+                 set(selBlocks(i),'Inputs',num2str(newValue));
+             elseif strcmp(get(gcbh,'Tag'),'demux'),
+                 set(selBlocks(i),'Outputs',num2str(newValue));
+             end
+             set(selBlocks(i),'Position',newDimens);
+         end
+    end
+    %----------------------------------------------------------------------
+    
+    end
\ No newline at end of file