Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 42 additions & 22 deletions Functions/Plugins/ParameterGUI/BpodParameterGUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,50 +102,53 @@
else
BpodSystem.GUIData.ParameterGUI.LastParamValues{ParamNum} = ThisParam;
end
ThisParamStyle = 'edit'; % Just initial assumption
ThisParamCB = '';
if isfield(Meta, ThisParamName)
if isstruct(Meta.(ThisParamName))
ValidField = false;
if isfield(Meta.(ThisParamName), 'Style')
ThisParamStyle = Meta.(ThisParamName).Style;
if isfield(Meta.(ThisParamName), 'String')
ThisParamString = Meta.(ThisParamName).String;
else
ThisParamString = '';
end
else
error(['Style not specified for parameter ' ThisParamName '.'])
ValidField = true;
end
if isfield(Meta.(ThisParamName), 'Callback')
ThisParamCB = Meta.(ThisParamName).Callback;
ValidField = true;
end
if ~ValidField
error(['Style or Callback not specified for parameter ' ThisParamName '.'])
end
else
error(['GUIMeta entry for ' ThisParamName ' must be a struct.'])
end
else
ThisParamStyle = 'edit';
ThisParamValue = NaN;
end
BpodSystem.GUIHandles.ParameterGUI.Labels(ParamNum) = uicontrol(htab,'Style', 'text', 'String', ThisParamName, 'Position', [HPos+5 VPos+InPanelPos 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center');
switch lower(ThisParamStyle)
case 'edit'
BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 1;
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'edit', 'String', num2str(ThisParam), 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center');
case 'edittext'
BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 8;
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'edit', 'String', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center');
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'edit', 'String', num2str(ThisParam), 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB);
case 'text'
BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 2;
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'text', 'String', num2str(ThisParam), 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center');
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'text', 'String', num2str(ThisParam), 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB);
case 'checkbox'
BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 3;
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'checkbox', 'Value', ThisParam, 'String', ' (check to activate)', 'Position', [HPos+220 VPos+InPanelPos+4 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center');
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'checkbox', 'Value', ThisParam, 'String', ' (check to activate)', 'Position', [HPos+220 VPos+InPanelPos+4 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB);
case 'popupmenu'
BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 4;
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'popupmenu', 'String', ThisParamString, 'Value', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center');
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'popupmenu', 'String', ThisParamString, 'Value', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB);
case 'togglebutton' % INCOMPLETE
BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 5;
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'togglebutton', 'String', ThisParamString, 'Value', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center');
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'togglebutton', 'String', ThisParamString, 'Value', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB);
case 'pushbutton'
BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 6;
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'pushbutton', 'String', ThisParamString,...
'Value', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12,...
'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',Meta.OdorSettings.Callback);
'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB);
case 'table'
BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 7;
columnNames = fieldnames(Params.(ThisParamName));
Expand All @@ -167,8 +170,18 @@
ThisPanelHeight = ThisPanelHeight + (htable.Position(4)-25);
BpodSystem.GUIHandles.ParameterGUI.Panels.(ThisTabPanelNames{p}).Position(4) = ThisPanelHeight;
BpodSystem.GUIData.ParameterGUI.LastParamValues{ParamNum} = htable.Data;
case 'edittext'
BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 8;
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'edit', 'String', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB);
case 'slider'
BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 9;
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'slider', 'String', ThisParam,...
'Value', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12,...
'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center', 'min', 0, 'max', 1,...
'Callback',ThisParamCB);

otherwise
error('Invalid parameter style specified. Valid parameters are: ''edit'', ''text'', ''checkbox'', ''popupmenu'', ''togglebutton'', ''pushbutton''');
error('Invalid parameter style specified. Valid parameters are: ''edit'', ''text'', ''checkbox'', ''popupmenu'', ''togglebutton'', ''pushbutton'', ''slider''');
end
InPanelPos = InPanelPos + 35;
ParamNum = ParamNum + 1;
Expand Down Expand Up @@ -216,13 +229,6 @@
elseif Params.GUI.(ThisParamName) ~= ThisParamLastValue
set(ThisParamHandle, 'String', num2str(GUIParam));
end
case 8 % Edit Text
GUIParam = get(ThisParamHandle, 'String');
if ~strcmpi(GUIParam, ThisParamLastValue)
Params.GUI.(ThisParamName) = GUIParam;
elseif ~strcmpi(Params.GUI.(ThisParamName), ThisParamLastValue)
set(ThisParamHandle, 'String', GUIParam);
end
case 2 % Text
GUIParam = Params.GUI.(ThisParamName);
Text = GUIParam;
Expand Down Expand Up @@ -265,6 +271,20 @@
elseif any(argData(:) ~= ThisParamLastValue(:)) % Change originated in TaskParameters propagates to the GUI
ThisParamHandle.Data = argData;
end
case 8 % Edit Text
GUIParam = get(ThisParamHandle, 'String');
if ~strcmpi(GUIParam, ThisParamLastValue)
Params.GUI.(ThisParamName) = GUIParam;
elseif ~strcmpi(Params.GUI.(ThisParamName), ThisParamLastValue)
set(ThisParamHandle, 'String', GUIParam);
end
case 9 % Slider
GUIParam = get(ThisParamHandle, 'Value');
if GUIParam ~= ThisParamLastValue
Params.GUI.(ThisParamName) = GUIParam;
elseif Params.GUI.(ThisParamName) ~= ThisParamLastValue
set(ThisParamHandle, 'Value', GUIParam);
end
end
BpodSystem.GUIData.ParameterGUI.LastParamValues{p} = GUIParam;
end
Expand Down