IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
uip_fcon_mea_pick.m
Go to the documentation of this file.
1 %> @ingroup guigroup
2 %> @file
3 %> @brief Properties window for @ref fcon_mea_pick
4 %> @image html Screenshot-uip_fcon_mea_pick.png
5 %
6 %> <b>Type</b> - see fcon_mea_pick::type
7 %>
8 %>
9 %> @sa fcon_mea_pick
10 
11 %> @cond
12 function varargout = uip_fcon_mea_pick(varargin)
13 % Last Modified by GUIDE v2.5 15-Sep-2011 16:58:45
14 
15 % Begin initialization code - DO NOT EDIT
16 gui_Singleton = 1;
17 gui_State = struct('gui_Name', mfilename, ...
18  'gui_Singleton', gui_Singleton, ...
19  'gui_OpeningFcn', @uip_fcon_mea_pick_OpeningFcn, ...
20  'gui_OutputFcn', @uip_fcon_mea_pick_OutputFcn, ...
21  'gui_LayoutFcn', [] , ...
22  'gui_Callback', []);
23 if nargin && ischar(varargin{1})
24  gui_State.gui_Callback = str2func(varargin{1});
25 end
26 
27 if nargout
28  [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
29 else
30  gui_mainfcn(gui_State, varargin{:});
31 end
32 % End initialization code - DO NOT EDIT
33 
34 % --- Executes just before uip_fcon_mea_pick is made visible.
35 function uip_fcon_mea_pick_OpeningFcn(hObject, eventdata, handles, varargin)
36 if nargin >= 5
37  handles.inputdataset = varargin{2};
38 else
39  handles.inputdataset = [];
40 end;
41 
42 guidata(hObject, handles);
43 gui_set_position(hObject);
44 
45 refresh(handles);
46 handles = guidata(handles.figure1);
47 view1(handles);
48 
49 handles.output.flag_ok = 0;
50 guidata(hObject, handles);
51 gui_set_position(hObject);
52 
53 
54 % --- Outputs from this function are returned to the command clae.
55 function varargout = uip_fcon_mea_pick_OutputFcn(hObject, eventdata, handles)
56 try
57  uiwait(handles.figure1);
58  handles = guidata(hObject);
59  varargout{1} = handles.output;
60  delete(gcf);
61 catch
62  output.flag_ok = 0;
63  output.params = {};
64  varargout{1} = output;
65 end;
66 
67 %############################################
68 
69 %#########
70 function view1(handles)
71 cla(handles.axes2, 'reset');
72 axes(handles.axes2);
73 ds = handles.dataset;
74 hold off;
75 if ~isempty(ds)
76  obsidx = eval(get(handles.edit_obsidx, 'String'));
77  o = fcon_mea_pick();
78  eval(['o = o.setbatch(', params2str(get_params(handles)), ');']);
79  try
80  o.illustrate(ds, obsidx);
81  catch ME
82  irerrordlg(ME.message, 'Error');
83  end;
84 else
85  msgbox('Cannot draw, input not specified!');
86 end;
87 
88 %#########
89 function refresh(handles)
90 if ~isempty(handles.inputdataset)
91  ss = 'input dataset';
92 else
93  ss = 'leave blank';
94 end;
95 listbox_load_from_workspace('irdata', handles.popupmenu_data, 1, ss);
96 assign_dataset(handles);
97 
98 
99 %#########
100 function assign_dataset(handles)
101 
102 sdata = listbox_get_selected_1stname(handles.popupmenu_data);
103 if isempty(sdata)
104  if ~isempty(handles.inputdataset)
105  handles.dataset = handles.inputdataset;
106  else
107  handles.dataset = [];
108  end;
109 else
110  handles.dataset = evalin('base', [sdata, ';']);
111 end;
112 
113 guidata(handles.figure1, handles);
114 
115 
116 %#########
117 function params = get_params(handles)
118 % 'm' and 'a'(maximum and area) types require two elements in the location/range vector
119 idx2 = [2, 3]; % Radio button indexes that require 2 elements in the vector
120 
121 types = 'fma'; % fixed; maximum; area
122 
123 idx_term = get(get(handles.uipanel_term, 'SelectedObject'), 'UserData');
124 type = types(idx_term);
125 
126 v = eval(get(handles.edit_v, 'String'));
127 
128 if any(idx_term == idx2)
129  if numel(v) < 2
130  irerror('Coordinate vector requires two elements!');
131  end;
132 end;
133 
134 params = {...
135 'v', mat2str(v), ...
136 'type', ['''', type, ''''] ...
137 };
138 
139 %############################################
140 %############################################
141 
142 
143 
144 % --- Executes on button press in pushbutton_OK.
145 function pushbutton_OK_Callback(hObject, eventdata, handles)
146 try
147  handles.output.params = get_params(handles);
148  handles.output.flag_ok = 1;
149  guidata(hObject, handles);
150  uiresume();
151 catch ME
152  irerrordlg(ME.message, 'Cannot continue');
153 end;
154 
155 
156 
157 
158 % --- Executes on button press in pushbuttonView.
159 function pushbuttonView_Callback(hObject, eventdata, handles)
160 view1(handles);
161 
162 % --- Executes on selection change in popupmenu_data.
163 function popupmenu_data_Callback(hObject, eventdata, handles)
164 assign_dataset(handles);
165 view1(handles);
166 
167 % --- Executes during object creation, after setting all properties.
168 function popupmenu_data_CreateFcn(hObject, eventdata, handles)
169 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
170  set(hObject,'BackgroundColor','white');
171 end
172 
173 
174 function edit_obsidx_Callback(hObject, eventdata, handles)
175 
176 % --- Executes during object creation, after setting all properties.
177 function edit_obsidx_CreateFcn(hObject, eventdata, handles)
178 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
179  set(hObject,'BackgroundColor','white');
180 end
181 
182 function edit_v_Callback(hObject, eventdata, handles)
183 
184 % --- Executes during object creation, after setting all properties.
185 function edit_v_CreateFcn(hObject, eventdata, handles)
186 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
187  set(hObject,'BackgroundColor','white');
188 end
189 
190 
191 %> @endcond
function irerror(in s)
Dataset class.
Definition: irdata.m:30
function params2str(in params, in flag_o)
function listbox_get_selected_1stname(in h_listbox)
function setbatch(in o, in params)
Picks region area, region peak, or value at fixed x-position.
Definition: fcon_mea_pick.m:2
function listbox_load_from_workspace(in classname, in h_list, in flag_blank, in string_empty, in input)
function gui_set_position(in hObject)
Property type
Definition: fcon_mea_pick.m:13
function irerrordlg(in errorstring, in dlgname)