Skip to content

Commit d9fc48d

Browse files
committed
Added full documentation
1 parent 335642a commit d9fc48d

File tree

3 files changed

+98
-18
lines changed

3 files changed

+98
-18
lines changed

+eui/ConditionPanel.m

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,48 @@
11
classdef 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, ...

+eui/FieldPanel.m

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
11
classdef FieldPanel < handle
2-
%UNTITLED Deals with formatting global parameter UI elements
3-
% Detailed explanation goes here
2+
%FIELDPANEL Deals with formatting global parameter UI elements
3+
% Designed to be an element of the EUI.PARAMEDITOR class that manages
4+
% the UI elements associated with all Global parameters.
45

56
properties
7+
% Minimum allowable width (in pixels) for each UIControl element
68
MinCtrlWidth = 40
9+
% Maximum allowable width (in pixels) for each UIControl element
710
MaxCtrlWidth = 140
11+
% Space (in pixels) between parent container and parameter fields
812
Margin = 14
13+
% Space (in pixels) between each parameter field row
914
RowSpacing = 1
15+
% Space (in pixels) between each parameter field column
1016
ColSpacing = 3
17+
% Handle to parent UI container
1118
UIPanel
19+
% Handles to context menu option for making a parameter conditional
1220
ContextMenu
1321
end
1422

1523
properties (Access = ?eui.ParamEditor)
24+
% Handle to EUI.PARAMEDITOR object
1625
ParamEditor
26+
% Minimum height (in pixels) of each field row. See ONRESIZE
1727
MinRowHeight
28+
% Listener handle for when parent container is resized
1829
Listener
30+
% Array of UIControl labels
1931
Labels
32+
% Array of UIControl elements. Either 'edit' or 'checkbox' controls
2033
Controls
34+
% Array widths, one for each label in Labels. See ONRESIZE
2135
LabelWidths
2236
end
2337

24-
events
25-
Changed
26-
end
27-
2838
methods
2939
function obj = FieldPanel(f, ParamEditor)
40+
% FIELDPANEL Panel UI for Global parameters
41+
% Input f may be a figure or other UI container object
42+
% ParamEditor is a handle to an eui.ParamEditor object.
43+
%
44+
% See also EUI.PARAMEDITOR, EUI.CONDITIONPANEL
3045
obj.ParamEditor = ParamEditor;
3146
p = uix.Panel('Parent', f, 'BorderType', 'none');
3247
obj.UIPanel = uipanel('Parent', p, 'BorderType', 'none',...
@@ -35,7 +50,14 @@
3550
end
3651

3752
function [label, ctrl] = addField(obj, name, ctrl)
38-
% TODO Maybe use exp.Parameters/ui
53+
% ADDFIELD Adds a new field label and input control
54+
% Adds a label and control element for representing Global
55+
% parameters. The input name should be identical to a parameter
56+
% fieldname. From this the label string title is derived using
57+
% exp.Parameters/title. Callback are added for the context menu and
58+
% for edits
59+
%
60+
% See also ONEDIT, EXP.PARAMETERS/TITLE, EUI.PARAMEDITOR/BUILDUI
3961
if isempty(obj.ContextMenu)
4062
obj.ContextMenu = uicontextmenu;
4163
uimenu(obj.ContextMenu, 'Label', 'Make Conditional', ...
@@ -134,11 +156,20 @@ function makeConditional(obj, name)
134156
end
135157

136158
function delete(obj)
159+
% DELETE Deletes the UI container
160+
% Called when this object or its parant ParamEditor is deleted
161+
% See also CLEAR
137162
disp('delete called');
138163
delete(obj.UIPanel);
139164
end
140165

141166
function onResize(obj, ~, ~)
167+
% ONRESIZE Re-position field UI elements after container resize
168+
% Calculates the positions all field labels and input controls.
169+
% These are organised into rows and columns that maximize use of
170+
% space.
171+
%
172+
% See also EUI.PARAMEDITOR/ONRESIZE
142173
if isempty(obj.Controls)
143174
return
144175
end

+eui/ParamEditor.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ function setRandomized(obj, value)
177177

178178
function addEmptyConditionToParam(obj, name)
179179
% Add a new trial specific condition to the table
180+
% Adds a new trial condition to each trial specific parameter. That
181+
% is, adds a new column to each parameter.
180182
% See also EUI.CONDITIONPANEL/NEWCONDITION
181183
assert(obj.Parameters.isTrialSpecific(name),...
182184
'Tried to add a new condition to global parameter ''%s''', name);

0 commit comments

Comments
 (0)