IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
uip_block_cascade.m
Go to the documentation of this file.
1 %> @ingroup guigroup
2 %> @file
3 %> @brief Properties Window to create a Cascade Block
4 %> @image html Screenshot-uip_block_cascade.png
5 %> <p><b>Usage</b><br>
6 %> <ol><li>Create all blocks of the cascade sequence <b>before</b> calling this GUI</li>
7 %> <li>The popupmenu shows all blocks present in the workspace. Select among blocks and click on `Add`.</li>
8 %> <li>Click on `OK` when done</li>
9 %> </ol>
10 %>
11 %> @sa block_cascade
12 
13 %> @cond
14 function varargout = uip_block_cascade(varargin)
15 % Begin initialization code - DO NOT EDIT
16 gui_Singleton = 0;
17 gui_State = struct('gui_Name', mfilename, ...
18  'gui_Singleton', gui_Singleton, ...
19  'gui_OpeningFcn', @uip_block_cascade_OpeningFcn, ...
20  'gui_OutputFcn', @uip_block_cascade_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_block_cascade is made visible.
35 function uip_block_cascade_OpeningFcn(hObject, eventdata, handles, varargin)
36 handles.output.flag_ok = 0;
37 handles.blocknames = {};
38 guidata(hObject, handles);
39 gui_set_position(hObject);
40 refresh(handles);
41 
42 % --- Outputs from this function are returned to the command line.
43 function varargout = uip_block_cascade_OutputFcn(hObject, eventdata, handles)
44 try
45  uiwait(handles.figure1);
46  handles = guidata(hObject); % Handles is not a handle(!), so gotta retrieve it again to see changes in .output
47  varargout{1} = handles.output;
48  delete(gcf);
49 catch %#ok<*CTCH>
50  output.flag_ok = 0;
51  output.params = {};
52  varargout{1} = output;
53 end;
54 
55 
56 %############################################
57 function refresh(handles)
58 listbox_load_from_workspace('block', handles.popupmenuBlocks, 0);
59 v = get(handles.listbox, 'Value');
60 if sum(v > length(handles.blocknames)) > 0 && ~isempty(handles.blocknames)
61  set(handles.listbox, 'Value', 1);
62 end;
63 set(handles.listbox, 'String', handles.blocknames);
64 local_show_description(handles);
65 
66 function local_show_description(handles)
67 show_description(handles.listbox, handles.editDescription);
68 %############################################
69 %############################################
70 
71 
72 % --- Executes on button press in pushbuttonOk.
73 function pushbuttonOk_Callback(hObject, eventdata, handles)
74 try
75  handles.output.params = {...
76  'blocks', params2str2(handles.blocknames) ...
77  };
78  handles.output.flag_ok = 1;
79  guidata(hObject, handles);
80  uiresume();
81 catch ME
82  irerrordlg(ME.message, 'Cannot continue');
83 
84 end;
85 
86 % --- Executes on selection change in popupmenuBlocks.
87 function popupmenuBlocks_Callback(hObject, eventdata, handles) %#ok<*INUSD,*DEFNU>
88 
89 % --- Executes during object creation, after setting all properties.
90 function popupmenuBlocks_CreateFcn(hObject, eventdata, handles)
91 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
92  set(hObject,'BackgroundColor','white');
93 end
94 
95 
96 % --- Executes on button press in pushbuttonAdd.
97 function pushbuttonAdd_Callback(hObject, eventdata, handles) %#ok<*INUSL>
98 blockname = listbox_get_selected_1stname(handles.popupmenuBlocks);
99 if ~isempty(blockname)
100  handles.blocknames{end+1} = blockname;
101  guidata(hObject, handles);
102  refresh(handles);
103 end;
104 
105 % --- Executes on selection change in listbox.
106 function listbox_Callback(hObject, eventdata, handles)
107 local_show_description(handles);
108 
109 % --- Executes during object creation, after setting all properties.
110 function listbox_CreateFcn(hObject, eventdata, handles)
111 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
112  set(hObject,'BackgroundColor','white');
113 end
114 
115 % --- Executes on button press in pushbuttonRemove.
116 function pushbuttonRemove_Callback(hObject, eventdata, handles)
117 if ~isempty(get(handles.listbox, 'String'))
118  idxs = get(handles.listbox, 'Value');
119  if ~isempty(idxs)
120  handles.blocknames(idxs) = [];
121  guidata(hObject, handles);
122  refresh(handles);
123  end;
124 end;
125 
126 function editDescription_Callback(hObject, eventdata, handles)
127 
128 % --- Executes during object creation, after setting all properties.
129 function editDescription_CreateFcn(hObject, eventdata, handles)
130 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
131  set(hObject,'BackgroundColor','white');
132 end
133 %> @endcond
Cascade block: final instantializable class.
Definition: block_cascade.m:4
function show_description(in h_list, in h_edit)
function listbox_get_selected_1stname(in h_listbox)
function params2str2(in params)
Base Block class.
Definition: block.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)
function irerrordlg(in errorstring, in dlgname)