comparison m-toolbox/m/gui/gltpda/g_drawParPanel.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 drawn = g_drawParPanel(varargin)
2
3 global params objName guiFontSize
4
5 if nparams(params)==0, drawn = 0; return;
6 else drawn = 1;
7 end
8
9 % if nargin>0 && strcmp(varargin{1},'cbk'), return; end
10
11 % panelDimens = get(currPanel, 'Position');
12 backColor = [1 1 1];
13
14 try close(findobj('Tag','parampanelFigure')); catch, end;
15 lineSpacing = 22 * guiFontSize/10;
16 setappdata(0,'ltpda_gui_LineSpacing',lineSpacing);
17 currPos = get(0,'PointerLocation');
18 panelFigureSize = [350 10+21*nparams(params)];
19 panelDimens = [currPos(1)-100 currPos(2)-60-panelFigureSize(2) panelFigureSize];
20 currPanel = figure('Position',panelDimens,'Name','Parameters','Tag','parampanelFigure','Resize','off','NumberTitle','off','Toolbar','none','Menubar','none');
21
22 y = nparams(params);
23 for pp=1:y
24 paramkeys{pp} = params.params(pp).key;
25 paramvals{pp} = params.params(pp).val;
26 end
27
28 currParam = -1;
29 for ii = 1:y
30 currParam = currParam + 1;
31 % addedPar = 0;
32 % % Checkbox to enable input setting:
33 % objName{ii,1} = uicontrol('Parent',currPanel,'Units','pixels','Position',[10,panelDimens(4)-lineSpacing*(currParam+1+currGap),14,14],'Value',paramEnabled(ii),'Visible','on','Enable','on','Callback', @g_EnableCallback,'Tag',paramkeys{ii},'UserData',ii,'Style','checkbox');
34 % % Remove Param Button:
35 % try %#ok<ALIGN>
36 % if strcmpi(paramkeys{ii}(1:7),'addPar_')
37 % uicontrol('Parent',currPanel,'Units','pixels','Position',[panelDimens(3)-30 panelDimens(4)-lineSpacing*(currParam+1+currGap) 20 20],'String','-','TooltipString','Remove this parameter','Visible','on','Enable','on','UserData',ii,'Callback', @g_RemParamCallback,'Style','pushbutton');
38 % addedPar = 1;
39 % paramkeys{ii}(1:7) = [];
40 % end
41 % catch, end
42
43 switch class(paramvals{ii})
44
45 % ==========================================================================
46 case {'double'}
47 % ==========================================================================
48 % Key value:
49 objName{ii,2} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'TooltipString','Key (name of the parameter)','Units','pixels','Position',[5 panelDimens(4)-(4+lineSpacing*(currParam+1)) 70 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Style','text');
50 % Val value:
51 data = mat2str(paramvals{ii});
52 objName{ii,3} = uicontrol('Parent',currPanel,'TooltipString','Val (value of the parameter)','Units','pixels','Position',[80 panelDimens(4)-lineSpacing*(currParam+1) 180 guiFontSize*20/10],'String',data,'Fontsize',guiFontSize+1,'Visible','on','Enable','on','UserData',ii,'Callback',@g_editValueCallback,'Style','edit');
53 % objName{ii,4} = uicontrol('UserData',objName{ii,3},'TooltipString','Expand the edit field','Parent',currPanel,'BackgroundColor',[0.7 0.7 0.7],'HorizontalAlignment','left','Position',[405 panelDimens(4)+3-lineSpacing*(currParam+1+currGap) 13 13],'Visible','on','Callback',@g_ExpandEdit,'Style','pushbutton');
54 % Enable parameters from Simulink:
55 objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[270 panelDimens(4)-lineSpacing*(currParam+1) 20 20],'Max',1,'Min',0,'Value',0,'Visible','on','Tag',num2str(ii),'UserData',[],'Callback',@g_fromSimulinkCallback,'Style','checkbox');
56 if strcmp(paramvals{ii},'-->')
57 set(objName{ii,3},'Visible','off');
58 set(objName{ii,4},'Visible','off');
59 set(objName{ii,10},'Value',1);
60 end
61
62 % ==========================================================================
63 case {'char'}
64 % ==========================================================================
65 % Key value:
66 objName{ii,2} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'TooltipString','Key (name of the parameter)','Units','pixels','Position',[5 panelDimens(4)-(4+lineSpacing*(currParam+1)) 70 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Style','text');
67 if strcmpi(paramkeys{ii},'filename')
68 % Browse button:
69 currFilename = paramvals{ii};
70 if isempty(currFilename), currFilename = 'Browse'; end
71 if numel(currFilename)>30, currFilename = ['...',currFilename(end-29:end)]; end
72 objName{ii,3} = uicontrol('Parent',currPanel,'Units','pixels','Position',[80 panelDimens(4)-lineSpacing*(currParam+1) 180 20],'String',currFilename,'Visible','on','Enable','on','Callback',@g_browseCallback,'Style','pushbutton');
73 else
74 % Val value:
75 objName{ii,3} = uicontrol('Parent',currPanel,'Units','pixels','Position',[80 panelDimens(4)-lineSpacing*(currParam+1) 180 20],'String',['''',strrep(paramvals{ii},'''',''''''),''''],'Fontsize',guiFontSize+1,'Visible','on','Enable','on','UserData',ii,'Callback',@g_editValueCallback,'Style','edit');
76 objName{ii,4} = uicontrol('UserData',objName{ii,3},'TooltipString','Expand the edit field','Parent',currPanel,'BackgroundColor',[0.7 0.7 0.7],'HorizontalAlignment','left','Position',[405 panelDimens(4)+3-lineSpacing*(currParam+1) 13 13],'Visible','on','Callback',@g_ExpandEdit,'Style','pushbutton');
77 end
78 objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[270 panelDimens(4)-lineSpacing*(currParam+1) 20 20],'Max',1,'Min',0,'Value',0,'Visible','on','Tag',num2str(ii),'UserData',[],'Callback',@fromSimulinkCallback,'Style','checkbox');
79 if strcmp(paramvals{ii},'-->')
80 set(objName{ii,3},'Visible','off');
81 set(objName{ii,4},'Visible','off');
82 set(objName{ii,10},'Value',1);
83 else
84 set(objName{ii,10},'Visible','off');
85 end
86
87 % % ==========================================================================
88 % case {'unit'}
89 % % ==========================================================================
90 % % Key value:
91 % objName{ii,2} = uicontrol('Parent',currPanel,'Units','pixels','Position',[120 panelDimens(4)-lineSpacing*(currParam+1) 60 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editNameCallback,'Style','edit');
92 % if ~noParamsReq && ~addedPar
93 % set(objName{ii,2},'Style','text','BackgroundColor',backColor,'Position',[50 panelDimens(4)-(4+lineSpacing*(currParam+1)) 120 20]);
94 % end
95 % % Val value:
96 % unitVal = paramvals{ii}.strs; if isempty(unitVal), unitVal = {''}; end
97 % allunits = unit.supportedUnits;
98 % unitsTooltip = 'Supported units: ';
99 % for kk=1:numel(allunits), unitsTooltip = [unitsTooltip,allunits{kk},',']; end
100 % unitsTooltip(end)=[];
101 % objName{ii,3} = uicontrol('Parent',currPanel,'TooltipString',unitsTooltip,'Units','pixels','Position',[200 panelDimens(4)-lineSpacing*(currParam+1) 200 20],'String',['''',unitVal{1},''''],'Fontsize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_unitValCallback,'Style','edit');
102 %
103 % % ==========================================================================
104 % case {'logical'}
105 % % ==========================================================================
106 % % Key value:
107 % objName{ii,2} = uicontrol('Parent',currPanel,'Units','pixels','Position',[120 panelDimens(4)-lineSpacing*(currParam+1) 60 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editNameCallback,'Style','edit');
108 % if ~noParamsReq && ~addedPar
109 % set(objName{ii,2},'Style','text','BackgroundColor',backColor,'Position',[50 panelDimens(4)-(4+lineSpacing*(currParam+1)) 120 20]);
110 % end
111 % % Val value:
112 % objName{ii,3} = uicontrol('Parent',currPanel,'Units','pixels','Position',[200 panelDimens(4)-lineSpacing*(currParam+1) 100 20],'String',{'false','true'},'Value',paramvals{ii}+1,'Fontsize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_logicValCallback,'Style','popupmenu');
113
114 % ==========================================================================
115 case 'specwin'
116 % ==========================================================================
117 selectWind = paramvals{ii}.type;
118 listWindows = ['Kaiser',specwin.getTypes];
119 selectWindValue = strmatch(selectWind,listWindows,'exact');
120 % Window text:
121 objName{ii,2} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[5 panelDimens(4)-lineSpacing*(currParam+1)-3 60 20],'String','Window:','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
122 % Window type popup:
123 objName{ii,3} = uicontrol('Parent',currPanel,'Units','pixels','Position',[80 panelDimens(4)-lineSpacing*(currParam+1) 100 20],'String',listWindows,'TooltipString','Window names','Value',selectWindValue,'Visible','on','Enable','off','Tag',paramkeys{ii},'UserData',ii,'Callback', @g_WindListCallback,'Style','popupmenu');
124 % Length value:
125 currLength = num2str(length(params.params(ii).val.win));
126 objName{ii,4} = uicontrol('Parent',currPanel,'Units','pixels','Position',[190 panelDimens(4)-lineSpacing*(currParam+1) 70 20],'String',num2str(currLength),'TooltipString','Window Length','Visible','on','Enable','off','UserData',ii,'Callback', @g_WindlengthCallback,'Style','edit');
127 if strcmp(selectWind,'Kaiser')
128 % PSL value if Kaiser:
129 currPSL = params.params(ii).val.psll;
130 objName{ii,5} = uicontrol('Parent',currPanel,'Units','pixels','Position',[240 panelDimens(4)-lineSpacing*(currParam+1) 60 20],'String',num2str(currPSL),'TooltipString','Peak Sidelobe','Visible','on','Enable','off','UserData',ii,'Callback',@g_WindPSLCallback,'Style','edit');
131 end
132 % Simulink checkbox:
133 objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[270 panelDimens(4)-lineSpacing*(currParam+1) 20 20],'Max',1,'Min',0,'Value',0,'Visible','on','Tag',num2str(ii),'UserData',paramvals{ii},'Callback',@g_fromSimulinkCallback,'Style','checkbox');
134
135
136
137 % ==========================================================================
138 otherwise % Other types of param?
139 % ==========================================================================
140 % Key value:
141 objName{ii,3} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','Position',[5 panelDimens(4)-5-lineSpacing*(currParam+1) 100 20],'String',paramkeys{ii},'FontSize',guiFontSize+1,'Visible','on','Enable','off','UserData',ii,'Callback',@g_editNameCallback,'Style','text');
142 % Text: input not supported. Please construct by proper block.
143 objName{ii,4} = uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[100 panelDimens(4)-4-lineSpacing*(currParam+1) 150 20],'String','Not supported','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
144 fromSimulink = 0;
145
146 % Simulink checkbox:
147 objName{ii,10} = uicontrol('TooltipString','Retrieve from Simulink','String','','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[270 panelDimens(4)-lineSpacing*(currParam+1) 20 20],'Max',1,'Min',0,'Value',fromSimulink,'Visible','on','Tag',num2str(ii),'UserData',paramvals{ii},'Callback',@g_fromSimulinkCallback,'Style','checkbox');
148
149 % ==============================================================================
150 end % of SWITCH the param type
151
152 end % of cycle among params
153
154
155
156
157 end