IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
ask_dataset.m
Go to the documentation of this file.
1 %> @ingroup guigroup
2 %> @file
3 %> @brief Browses datasets present in workspace for GUI user to choose one.
4 %>
5 %> This is used in: uip_blbl_extract_cv.m
6 %>
7 %> @image html Screenshot-ask_dataset.png
8 %>
9 %> @c varargin inputs:
10 %> @arg internal Please pass first parameter as "[]" (empty vector)
11 %> @arg flag_empty=0 Whether can return empty or not
12 %> @arg caption='Dataset of input'
13 function varargout = ask_dataset(varargin)
14 % Last Modified by GUIDE v2.5 05-Mar-2011 16:14:34
15 
16 % Begin initialization code - DO NOT EDIT
17 gui_Singleton = 1;
18 gui_State = struct('gui_Name', mfilename, ...
19  'gui_Singleton', gui_Singleton, ...
20  'gui_OpeningFcn', @ask_dataset_OpeningFcn, ...
21  'gui_OutputFcn', @ask_dataset_OutputFcn, ...
22  'gui_LayoutFcn', [] , ...
23  'gui_Callback', []);
24 if nargin && ischar(varargin{1})
25  gui_State.gui_Callback = str2func(varargin{1});
26 end
27 
28 if nargout
29  [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
30 else
31  gui_mainfcn(gui_State, varargin{:});
32 end
33 % End initialization code - DO NOT EDIT
34 
35 %> @cond
36 % --- Executes just before ask_dataset is made visible.
37 function ask_dataset_OpeningFcn(hObject, eventdata, handles, varargin)
38 if nargin > 4 && ~isempty(varargin{2})
39  set(handles.text_caption, 'String', varargin{2});
40 end;
41 
42 if nargin > 5
43  handles.input.flag_empty = varargin{3};
44 else
45  handles.input.flag_empty = 0;
46 end;
47 
48 handles.output.flag_ok = 0;
49 guidata(hObject, handles);
50 gui_set_position(hObject);
51 refresh(handles);
52 
53 % --- Outputs from this function are returned to the command clae.
54 function varargout = ask_dataset_OutputFcn(hObject, eventdata, handles)
55 try
56  uiwait(handles.figure1);
57  handles = guidata(hObject);
58  varargout{1} = handles.output;
59  delete(gcf);
60 catch
61  output.flag_ok = 0;
62  output.params = {};
63  varargout{1} = output;
64 end;
65 
66 
67 %############################################
68 
69 %#########
70 function refresh(handles)
71 listbox_load_from_workspace('irdata', handles.popupmenuData, handles.input.flag_empty);
72 
73 %############################################
74 
75 % --- Executes on button press in pushbuttonOK.
76 function pushbuttonOK_Callback(hObject, eventdata, handles)
77 try
78  sdata = listbox_get_selected_1stname(handles.popupmenuData);
79  if isempty(sdata)
80  if handles.input.flag_empty
81  sdata = '[]';
82  else
83  irerror('Input dataset not specified!');
84  end;
85  end;
86 
87  handles.output.params = {...
88  'data', sdata ...
89  };
90  handles.output.flag_ok = 1;
91  guidata(hObject, handles);
92  uiresume();
93 catch ME
94  irerrordlg(ME.message, 'Cannot continue');
95 
96 end;
97 
98 
99 % --- Executes on selection change in popupmenuData.
100 function popupmenuData_Callback(hObject, eventdata, handles)
101 
102 % --- Executes during object creation, after setting all properties.
103 function popupmenuData_CreateFcn(hObject, eventdata, handles)
104 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
105  set(hObject,'BackgroundColor','white');
106 end
107 %> @endcond
function irerror(in s)
Dataset class.
Definition: irdata.m:30
function listbox_get_selected_1stname(in h_listbox)
function listbox_load_from_workspace(in classname, in h_list, in flag_blank, in string_empty, in input)
function gui_set_position(in hObject)
Analysis Session (AS) base class.
Definition: as.m:6
function irerrordlg(in errorstring, in dlgname)
function ask_dataset(in varargin)