view m-toolbox/m/gui/gltpda/g_AddParamCallback.m @ 29:54f14716c721 database-connection-manager

Update Java code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

   function g_AddParamCallback(hObject,varargin)
      
      global params selBlocks paramEnabled
      
      hparamType = get(hObject,'UserData');
      if isa(hparamType,'char') && strcmp(hparamType,'input')
         key = 'input';
         while ~isempty(find(params,key)), key =[key,'x']; end
         params = append(params, param(key,'-->'));
         g_UpdateInports(key,1);
         paramcommand = g_BuildParamCommand(params);
         for kk=1:length(selBlocks)
            set_param(selBlocks(kk),'Description',paramcommand);
         end
       % g_arithmetic(currPanel);
         
      else
         paramTypes = get(hparamType,'String');
         paramType = paramTypes{get(hparamType,'Value')};
         
         switch paramType
            case {'double','double/char'}
               ii = 1; key = ['addPar_name',num2str(ii)];
               while ~isempty(find(params,key))
                  ii = ii+1; key = ['addPar_name',num2str(ii)];
               end
               params = append(params, param(key,1));
            case 'specwin'
               newParam = param('addPar_Win',specwin('Kaiser',1000,200));
               params = append(params, newParam);
               paramTypes(strmatch('specwin',paramTypes,'exact'))=[];
            case 'pzmodel'
               pzObj = pzmodel(1,[pz(10,2),pz(100)],pz(1));
               newParam = param('addPar_pzmodel',pzObj);
               params = append(params, newParam);
               paramTypes(strmatch('pzmodel',paramTypes,'exact'))=[];
            case '-->'
               ii = 1; key = ['addPar_name',num2str(ii)];
               while ~isempty(find(params,key))
                  ii = ii+1; key = ['addPar_name',num2str(ii)];
               end
               params = append(params, param(key,'-->'));
               g_UpdateInports(key,1)
            case 'pz'
               ii = 1; key = ['addPar_pz',num2str(ii)];
               while ~isempty(find(params,key))
                  ii = ii+1; key = ['addPar_pz',num2str(ii)];
               end
               params = append(params, param(key,pz(1)));
            case 'unit'
               ii = 1; key = ['addPar_unit',num2str(ii)];
               while ~isempty(find(params,key))
                  ii = ii+1; key = ['addPar_unit',num2str(ii)];
               end
               params = append(params, param(key,unit()));
         end
         set(findobj(gcf,'Tag','addparamspopup','Style','popupmenu'),'String',paramTypes)
         if nparams(params)==1, paramEnabled = 1;
         else paramEnabled = [paramEnabled,1];
         end
         set(findobj('Tag','apply'),'Enable','on');
         set(findobj('Tag','undo'),'Enable','on');
         
         ltpdagui('Redraw',2)
      end
   end