Mercurial > hg > ltpda
diff m-toolbox/m/gui/gltpda/g_editValueCallback.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_editValueCallback.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,69 @@ +function g_editValueCallback(hObject, varargin) + + global params paramEnabled + + expandedEdit = 0; + if numel(get(hObject,'UserData'))>1 + hObject = get(hObject,'UserData'); + orighObject = hObject(2); + hObject = hObject(1); + expandedEdit = 1; + else + orighObject = hObject; + end + currParamIndex = get(hObject,'UserData'); + newValue = get(hObject,'String'); + + if isempty(newValue), set(orighObject,'String',num2str(params.params(currParamIndex).val)); return; end + if strcmp(newValue(1),''''), + paramType = 'char'; + newValue(1) = []; newValue(end) = []; + for j = numel(newValue)-1:-1:2 + if strcmp(newValue(j),'''') && (~strcmp(newValue(j-1),'''') && ~strcmp(newValue(j+1),'''')) + newValue = [newValue(1:j),'''',newValue(j+1:end)]; + end + end + elseif ~strcmp(newValue(1),'{'), + paramType = 'double'; + else + paramType = 'double'; + end + + switch paramType + case 'double' + try + newValue = evalin('base',newValue); + if isnumeric(newValue) + set(orighObject,'String',mat2str(newValue)) + else + params = pset(params,params.params(currParamIndex).key,newValue); + paramcommand = BuildParamCommand(params); + for kk=1:length(selBlocks) + set_param(selBlocks(kk),'Description',paramcommand); + end + AnnotationUpdate(params); + buildplistFigureParam([],[],get(findobj('Tag','paramsPage'),'UserData')) + return + end + catch + oldValue = params.params(currParamIndex).val; + if ~isa(oldValue,'char'), mat2str(oldValue); end + set(orighObject,'String',oldValue) + return + end + case 'char' + params = pset(params,params.params(currParamIndex).key,newValue); + end + + if expandedEdit, paramEnabled(currParamIndex) = 1; end + params = pset(params,params.params(currParamIndex).key,newValue); + + if isempty(findobj('Tag','parampanelFigure')) + set(findobj('Tag','apply'),'Enable','on'); + set(findobj('Tag','undo'),'Enable','on'); + else + paramEnabled(currParamIndex) = 1; + g_ApplyButtonCallback(); + end + +end \ No newline at end of file