11classdef ConditionPanel < handle
2- % UNTITLED Deals with formatting trial conditions UI table
3- % Detailed explanation goes here
4- % TODO Document
2+ % CONDITIONPANEL Deals with formatting trial conditions UI table
3+ % Designed to be an element of the EUI.PARAMEDITOR class that manages
4+ % the UI elements associated with all Conditional parameters.
55 % TODO Add sort by column
66 % TODO Add set condition idx
7- % TODO Use tags for menu items
87
98 properties
9+ % Handle to UI Table that represents trial conditions
1010 ConditionTable
11+ % Minimum UI Panel width allowed. See also EUI.PARAMEDITOR/ONRESIZE
1112 MinWidth = 80
1213% MaxWidth = 140
1314% Margin = 4
15+ % Handle to parent UI container
1416 UIPanel
17+ % Handle to UI container for buttons
1518 ButtonPanel
19+ % Handles to context menu items
1620 ContextMenus
1721 end
1822
1923 properties (Access = protected )
24+ % Handle to EUI.PARAMEDITOR object
2025 ParamEditor
21- Listener
26+ % UIControl button for adding a new trial condition (row) to the table
2227 NewConditionButton
28+ % UIControl button for deleting trial conditions (rows) from the table
2329 DeleteConditionButton
30+ % UIControl button for making conditional parameter (column) global
2431 MakeGlobalButton
32+ % UIControl button for setting multiple table cells at once
2533 SetValuesButton
26- SelectedCells % [row, column;...] of each selected cell
34+ % Indicies of selected table cells as array [row, column;...] of each
35+ % selected cell
36+ SelectedCells
2737 end
2838
2939 methods
3040 function obj = ConditionPanel(f , ParamEditor , varargin )
41+ % FIELDPANEL Panel UI for Conditional parameters
42+ % Input f may be a figure or other UI container object
43+ % ParamEditor is a handle to an eui.ParamEditor object.
44+ %
45+ % See also EUI.PARAMEDITOR, EUI.FIELDPANEL
3146 obj.ParamEditor = ParamEditor ;
3247 obj.UIPanel = uix .VBox(' Parent' , f );
3348% obj.UIPanel.BackgroundColor = 'white';
@@ -108,18 +123,26 @@ function onEdit(obj, src, eventData)
108123 end
109124
110125 function clear(obj )
126+ % CLEAR Clear all table data
127+ % Clears all trial condition data from UI Table
128+ %
129+ % See also EUI.PARAMEDITOR/BUILDUI, EUI.PARAMEDITOR/CLEAR
111130 set(obj .ConditionTable , ' ColumnName' , [], ...
112131 ' Data' , [], ' ColumnEditable' , false );
113132 end
114133
115134 function delete(obj )
135+ % DELETE Deletes the UI container
136+ % Called when this object or its parant ParamEditor is deleted
137+ % See also CLEAR
116138 disp(' delete called' );
117139 delete(obj .UIPanel );
118140 end
119141
120142 function onSelect(obj , ~, eventData )
121- % If at least one cell is selected, ensure buttons and menu items are
122- % enabled, otherwise disable them.
143+ % ONSELECT Callback for when table cells are (de-)selected
144+ % If at least one cell is selected, ensure buttons and menu items
145+ % are enabled, otherwise disable them.
123146 if nargin > 2 ; obj.SelectedCells = eventData .Indices ; end
124147 controls = ...
125148 [obj .MakeGlobalButton , ...
@@ -130,7 +153,12 @@ function onSelect(obj, ~, eventData)
130153 end
131154
132155 function makeGlobal(obj )
133- % FIXME Don't allow only numRepeats to remain
156+ % MAKEGLOBAL Make condition parameter (table column) global
157+ % Find all selected columns are turn into global parameters, using
158+ % the value of the first selected cell as the global parameter
159+ % value.
160+ %
161+ % See also eui.ParamEditor/globaliseParamAtCell
134162 if isempty(obj .SelectedCells )
135163 disp(' nothing selected' )
136164 return
@@ -175,7 +203,19 @@ function deleteSelectedConditions(obj)
175203 obj .fillConditionTable();
176204 end
177205
178- function setSelectedValues(obj ) % Set multiple fields in conditional table
206+ function setSelectedValues(obj )
207+ % SETSELECTEDVALUES Set multiple fields in conditional table at once
208+ % Generates an input dialog for setting multiple trial conditions at
209+ % once. Also allows the use of function handles for more complex
210+ % values.
211+ %
212+ % Examples:
213+ % (1:10:100) % Sets selected rows to [1 11 21 31 41 51 61 71 81 91]
214+ % @(~)randi(100) % Assigned random integer to each selected row
215+ % @(a)a*50 % Multiplies each condition value by 50
216+ % false % Sets all selected rows to false
217+ %
218+ % See also SETNEWVALS, ONEDIT
179219 disp(' updating table cells' );
180220 cols = obj .SelectedCells(: ,2 ); % selected columns
181221 uCol = unique(obj .SelectedCells(: ,2 ));
@@ -233,7 +273,10 @@ function setSelectedValues(obj) % Set multiple fields in conditional table
233273 end
234274
235275 function fillConditionTable(obj )
236- % Build the condition table
276+ % FILLCONDITIONTABLE Build the condition table
277+ % Populates the UI Table with trial specific parameters, where each
278+ % row is a trial condition (that is, a parameter column) and each
279+ % column is a different trial specific parameter
237280 titles = obj .ParamEditor .Parameters .TrialSpecificNames ;
238281 [~ , trialParams ] = obj .ParamEditor .Parameters .assortForExperiment ;
239282 if isempty(titles )
@@ -252,6 +295,10 @@ function fillConditionTable(obj)
252295 end
253296
254297 function newCondition(obj )
298+ % Adds a new trial condition (row) to the ConditionTable
299+ % Adds new row and populates it with sensible 'default' values.
300+ % These are mostly zeros or empty values.
301+ % See also eui.ParamEditor/addEmptyConditionToParam
255302 disp(' adding new condition row' );
256303 PE = obj .ParamEditor ;
257304 cellfun(@PE .addEmptyConditionToParam , ...
0 commit comments