comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 function g_editValueCallback(hObject, varargin)
2
3 global params paramEnabled
4
5 expandedEdit = 0;
6 if numel(get(hObject,'UserData'))>1
7 hObject = get(hObject,'UserData');
8 orighObject = hObject(2);
9 hObject = hObject(1);
10 expandedEdit = 1;
11 else
12 orighObject = hObject;
13 end
14 currParamIndex = get(hObject,'UserData');
15 newValue = get(hObject,'String');
16
17 if isempty(newValue), set(orighObject,'String',num2str(params.params(currParamIndex).val)); return; end
18 if strcmp(newValue(1),''''),
19 paramType = 'char';
20 newValue(1) = []; newValue(end) = [];
21 for j = numel(newValue)-1:-1:2
22 if strcmp(newValue(j),'''') && (~strcmp(newValue(j-1),'''') && ~strcmp(newValue(j+1),''''))
23 newValue = [newValue(1:j),'''',newValue(j+1:end)];
24 end
25 end
26 elseif ~strcmp(newValue(1),'{'),
27 paramType = 'double';
28 else
29 paramType = 'double';
30 end
31
32 switch paramType
33 case 'double'
34 try
35 newValue = evalin('base',newValue);
36 if isnumeric(newValue)
37 set(orighObject,'String',mat2str(newValue))
38 else
39 params = pset(params,params.params(currParamIndex).key,newValue);
40 paramcommand = BuildParamCommand(params);
41 for kk=1:length(selBlocks)
42 set_param(selBlocks(kk),'Description',paramcommand);
43 end
44 AnnotationUpdate(params);
45 buildplistFigureParam([],[],get(findobj('Tag','paramsPage'),'UserData'))
46 return
47 end
48 catch
49 oldValue = params.params(currParamIndex).val;
50 if ~isa(oldValue,'char'), mat2str(oldValue); end
51 set(orighObject,'String',oldValue)
52 return
53 end
54 case 'char'
55 params = pset(params,params.params(currParamIndex).key,newValue);
56 end
57
58 if expandedEdit, paramEnabled(currParamIndex) = 1; end
59 params = pset(params,params.params(currParamIndex).key,newValue);
60
61 if isempty(findobj('Tag','parampanelFigure'))
62 set(findobj('Tag','apply'),'Enable','on');
63 set(findobj('Tag','undo'),'Enable','on');
64 else
65 paramEnabled(currParamIndex) = 1;
66 g_ApplyButtonCallback();
67 end
68
69 end