3 %> @brief Class Selection Dialog
7 %> <h3>Input parameters (varargin)</h3>
11 %> Structure containing the following fields: flag_ok, params, classname
14 % Begin initialization code - DO NOT EDIT
16 gui_State =
struct(
'gui_Name', mfilename, ...
17 'gui_Singleton', gui_Singleton, ...
18 'gui_OpeningFcn', @blockmenu_OpeningFcn, ...
19 'gui_OutputFcn', @blockmenu_OutputFcn, ...
20 'gui_LayoutFcn', [] , ...
23 % This was the
default what-to-
do with in arguments;
this is the first time I am
using them, so won
't just delete the
25 if nargin && ischar(varargin{1})
26 gui_State.gui_Callback = str2func(varargin{1});
30 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
32 gui_mainfcn(gui_State, varargin{:});
34 % End initialization code - DO NOT EDIT
40 % --- Executes just before blockmenu is made visible.
41 function blockmenu_OpeningFcn(hObject, eventdata, handles, varargin) %#ok<*INUSL>
44 if length(varargin) < 1
45 varargin{1} = 'block';
47 if length(varargin) < 2
51 [rootclassname, dsnames] = varargin{[1, 2]};
54 handles.input.rootclassname = rootclassname;
55 handles.input.dsnames = dsnames;
56 % handles.input.prefix_behaviour = prefix_behaviour;
57 handles.output.flag_ok = 0;
64 flag_ds = ~isempty(dsnames);
66 for i = 1:length(dsnames)
67 datasets(i) = evalin('base
', [dsnames{i} ';
']);
69 inputclass = class(datasets(1));
75 handles.input.datasets = datasets;
76 list = classmap_get_list(rootclassname, inputclass); % descendants of classname that have class(data) as inputclass
78 handles.idx_in = 1:numel(list); % Indexes of list elements to show
79 handles.al = lower(itemlist2cell(list));
80 handles.a = itemlist2cell(list);
82 uicontrol(handles.edit_filter); % Sets focus
84 guidata(hObject, handles);
87 populate_listbox(handles);
89 gui_set_position(hObject);
90 o = eval([rootclassname ';
']);
91 set(hObject, 'Color
', o.color);
92 set(handles.textChoose, 'BackgroundColor
', o.color); % I don't know how to make staticText transparent so far, or inherit parent
's color
93 set(handles.text_filter, 'BackgroundColor
', o.color); % I don't know how to make staticText transparent so far, or inherit parent
's color
96 % % If there is only one option, does an automatic OK button
105 %################################################################
106 %################################################################
108 %#################################
109 function do_ok(handles)
111 if length(get(handles.listboxType, 'String
')) > 0 %#ok<*ISMT>
112 which = handles.idx_in(get(handles.listboxType, 'Value
'));
113 item = handles.list(which);
115 msgbox('Please select a deepest-level option!
');
117 classname = handles.list(which).name;
119 obj = eval([classname, ';
']);
120 result = obj.get_params(handles.input.datasets);
123 handles.output.flag_ok = 1;
124 handles.output.classname = classname;
125 handles.output.params = result.params;
126 guidata(handles.figure1, handles);
138 %#################################
139 function populate_listbox(handles)
140 filter = fel(get(handles.edit_filter, 'String
'));
142 filter = lower(filter);
143 idxs = find(cellfun(@(x) (~isempty(x)), cellfun(@(x) (findstr(filter, x)), handles.al, 'UniformOutput
', 0)));
144 b = zeros(1, numel(handles.a));
145 for i = 1:numel(idxs)
146 if handles.list(idxs(i)).flag_final
148 ob = handles.list(idxs(i));
153 ob = handles.list(ob.parentindex);
158 handles.idx_in = find(b);
160 handles.idx_in = 1:numel(handles.a);
163 set(handles.listboxType, 'Value
', 1);
164 set(handles.listboxType, 'String
', handles.a(handles.idx_in));
165 guidata(handles.figure1, handles);
167 %################################################################
168 %################################################################
174 % --- Outputs from this function are returned to the command line.
175 function varargout = blockmenu_OutputFcn(hObject, eventdata, handles)
177 uiwait(handles.figure1);
178 handles = guidata(hObject); % Handles is not a handle(!), so gotta retrieve it again to see changes in .output
179 varargout{1} = handles.output;
184 varargout{1} = output;
187 % --- Executes on button press in pushbuttonOk.
188 function pushbuttonOk_Callback(hObject, eventdata, handles) %#ok<*DEFNU>
191 % --- Executes on selection change in listboxType.
192 function listboxType_Callback(hObject, eventdata, handles)
193 if strcmp(get(handles.figure1, 'SelectionType
'), 'open
') % This is how you detect a double-click in MATLAB
198 % --- Executes during object creation, after setting all properties.
199 function listboxType_CreateFcn(hObject, eventdata, handles) %#ok<*INUSD>
200 if ispc && isequal(get(hObject,'BackgroundColor
'), get(0,'defaultUicontrolBackgroundColor
'))
201 set(hObject,'BackgroundColor
','white
');
204 % --- Executes on button press in pushbutton_cancel.
205 function pushbutton_cancel_Callback(hObject, eventdata, handles)
210 function edit_filter_Callback(hObject, eventdata, handles)
211 populate_listbox(handles);
213 % --- Executes during object creation, after setting all properties.
214 function edit_filter_CreateFcn(hObject, eventdata, handles)
215 if ispc && isequal(get(hObject,'BackgroundColor
'), get(0,'defaultUicontrolBackgroundColor
'))
216 set(hObject,'BackgroundColor
','white
');
219 function edit_filter_KeyPressFcn(hObject, eventdata, handles)