diff m-toolbox/m/gui/gltpda/g_fromSimulinkCallback.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_fromSimulinkCallback.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,41 @@
+function g_fromSimulinkCallback(hObject, varargin)
+   
+   global params paramEnabled functionName objName paramSets
+   
+   currParamIndex = str2double(get(hObject,'Tag'));
+   status = get(hObject,'Value'); % 1 activated, 0 deactivated
+   paramval = get(hObject,'UserData');
+   paramKey = params.params(currParamIndex).key;
+   if status %activated
+      for mm=3:9, try set(objName{currParamIndex,mm},'Visible','off'); catch, end; end
+      if ~isempty(paramval)
+         params = pset(params,paramKey,{'-->'});
+      else
+         params = pset(params,paramKey,'-->');
+      end
+      paramEnabled(currParamIndex) = 1;
+      presentBlock = utils.prog.find_in_models(gcb,'SearchDepth',1,'LookUnderMasks','all','Name',lower(paramKey));
+      if ~isempty(presentBlock), set_param(presentBlock{1},'Name',[lower(paramKey),'_fun']); end
+      g_UpdateInports(paramKey,1)
+   else %deactivated
+      for mm=3:9, try set(objName{currParamIndex,mm},'Visible','on'); catch, end; end
+      % Retrieve the original param:
+      [func,currClass] = strtok(get(gcbh,'Tag'));
+      infoObj = eval([currClass,'.getInfo(''',functionName,''')']);
+      if numel(infoObj.sets) > 1
+         currSet   = find(paramSets,'currSet');
+         origParams = infoObj.plists(currSet);
+      else
+         origParams = infoObj.plists;
+      end
+      paramKey = params.params(currParamIndex).key;
+      origPar = find(origParams,paramKey);
+      if isempty(origPar), origPar = 1; end
+      params = pset(params,paramKey,origPar);
+      paramEnabled(currParamIndex) = 0;
+      g_UpdateInports(paramKey,-1)
+   end
+   
+   g_ApplyButtonCallback([],1)
+   
+end