From 856bd13046033aa2c6317ea593abdad1faad7117 Mon Sep 17 00:00:00 2001 From: Jeffrey Girard Date: Wed, 23 Oct 2019 12:46:20 -0400 Subject: [PATCH] Add setting to customize axis starting value on mouse+keyboard entry and also validate axis numbers input --- CARMA.prj | 54 ++++++++++++++++++++++++++++++++++++--------- fig_collect_mouse.m | 34 +++++++++++++++++++++++----- fig_collect_vrjoy.m | 12 ++++++++++ fig_launcher.m | 6 ++--- 4 files changed, 87 insertions(+), 19 deletions(-) diff --git a/CARMA.prj b/CARMA.prj index 461e93e..fc5a8b6 100644 --- a/CARMA.prj +++ b/CARMA.prj @@ -1,11 +1,11 @@ - + CARMA - 14.03 - Jeffrey M Girard - me@jmgirard.com + 14.04 + + CARMA: Software for Continuous Affect Rating and Media Annotation Source files, releases, documentation, and support are available through http://carma.jmgirard.com @@ -36,7 +36,12 @@ false false - + Syntax + -? + + Input Arguments + -? print help on how to use the application + input arguments @@ -69,7 +74,6 @@ - ${PROJECT_ROOT}\fig_launcher.m @@ -92,21 +96,51 @@ ${PROJECT_ROOT}\fig_collect_vrjoy.m - C:\Users\jgirard\Documents\CARMA\CARMA\for_testing\splash.png - C:\Users\jgirard\Documents\CARMA\CARMA\for_testing\CARMA.exe - C:\Users\jgirard\Documents\CARMA\CARMA\for_testing\readme.txt + D:\GitHub\CARMA\CARMA\for_testing\readme.txt + D:\GitHub\CARMA\CARMA\for_testing\CARMA.exe + D:\GitHub\CARMA\CARMA\for_testing\splash.png - C:\Program Files\MATLAB\R2018a + D:\MATLAB + + + + + true + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + false diff --git a/fig_collect_mouse.m b/fig_collect_mouse.m index b189dc5..c161535 100644 --- a/fig_collect_mouse.m +++ b/fig_collect_mouse.m @@ -128,10 +128,10 @@ set(handles.text_upper,'String',handles.settings.labUpper); axMin = handles.settings.axMin; axMax = handles.settings.axMax; - axMidpt = axMin + (axMax - axMin)/2; + axStart = handles.settings.axStart; set(handles.slider, ... 'SliderStep',[1/40,1/20], ... - 'Min',axMin,'Max',axMax,'Value',axMidpt); + 'Min',axMin,'Max',axMax,'Value',axStart); % Initialize rating axis axes(handles.axis_rating); set(handles.axis_rating,'XLim',[0,100],'YLim',[0,100]); @@ -282,18 +282,40 @@ function menu_axislab_Callback(hObject,~) function menu_axisnum_Callback(hObject,~) handles = guidata(hObject); settings = handles.settings; - prompt = {'Axis Minimum Value:','Axis Maximum Value:','Number of Axis Steps:'}; - defaultans = {num2str(settings.axMin),num2str(settings.axMax),num2str(settings.axSteps)}; + prompt = {'Axis Minimum Value:','Axis Maximum Value:','Number of Axis Steps:','Axis Starting Value:'}; + defaultans = {num2str(settings.axMin),num2str(settings.axMax),num2str(settings.axSteps),num2str(settings.axStart)}; numbers = inputdlg(prompt,'',1,defaultans); if ~isempty(numbers) settings.axMin = str2double(numbers{1}); settings.axMax = str2double(numbers{2}); settings.axSteps = str2double(numbers{3}); + settings.axStart = str2double(numbers{4}); + if any(isnan([settings.axMin, settings.axMax, settings.axSteps, settings.axStart])) + warndlg('All values must be entered as numbers.', 'Warning'); + return; + end + if settings.axMax <= settings.axMin + warndlg('Axis Maximum Value must be greater than Axis Minimum Value.', 'Warning'); + return; + end + if settings.axMax <= settings.axMin + warndlg('Axis Maximum Value must be greater than Axis Minimum Value.', 'Warning'); + return; + end + if settings.axStart < settings.axMin || settings.axStart > settings.axMax + warndlg('Axis Start must be between then Axis Minimum and Axis Maximum Values.', 'Warning'); + return; + end set(handles.axis_rating, ... 'YLim',[settings.axMin,settings.axMax], ... 'YTick',round(linspace(settings.axMin,settings.axMax,settings.axSteps),2)); set(handles.plot_patch,'YData',[settings.axMin settings.axMin settings.axMax settings.axMax]); - setpref('carma',{'axMin','axMax','axSteps'},{settings.axMin,settings.axMax,settings.axSteps}); + set(handles.slider, ... + 'SliderStep',[1/40,1/20], ... + 'Min',settings.axMin, ... + 'Max',settings.axMax, ... + 'Value',settings.axStart); + setpref('carma',{'axMin','axMax','axSteps','axStart'},{settings.axMin,settings.axMax,settings.axSteps,settings.axStart}); handles.settings = settings; guidata(handles.figure_collect,handles); end @@ -442,7 +464,7 @@ function menu_defaultdir_Callback(hObject,~) function menu_about_Callback(~,~) global version; - msgbox(sprintf('CARMA version %.2f\nJeffrey M Girard (c) 2014-2018\nhttp://carma.jmgirard.com\nGNU General Public License v3',version),'About','Help'); + msgbox(sprintf('CARMA version %.2f\nJeffrey M Girard (c) 2014-2019\nhttp://carma.jmgirard.com\nGNU General Public License v3',version),'About','Help'); end % =============================================================================== diff --git a/fig_collect_vrjoy.m b/fig_collect_vrjoy.m index 967c535..0dcf449 100644 --- a/fig_collect_vrjoy.m +++ b/fig_collect_vrjoy.m @@ -293,6 +293,18 @@ function menu_axisnum_Callback(hObject,~) settings.axMin = str2double(numbers{1}); settings.axMax = str2double(numbers{2}); settings.axSteps = str2double(numbers{3}); + if any(isnan([settings.axMin, settings.axMax, settings.axSteps])) + warndlg('All values must be entered as numbers.', 'Warning'); + return; + end + if settings.axMax <= settings.axMin + warndlg('Axis Maximum Value must be greater than Axis Minimum Value.', 'Warning'); + return; + end + if settings.axMax <= settings.axMin + warndlg('Axis Maximum Value must be greater than Axis Minimum Value.', 'Warning'); + return; + end set(handles.axis_rating, ... 'YLim',[settings.axMin,settings.axMax], ... 'YTick',round(linspace(settings.axMin,settings.axMax,settings.axSteps),2)); diff --git a/fig_launcher.m b/fig_launcher.m index bcd2d28..b78a5cd 100644 --- a/fig_launcher.m +++ b/fig_launcher.m @@ -3,7 +3,7 @@ % License: https://github.com/jmgirard/CARMA/blob/master/license.txt global version; - version = 14.03; + version = 14.04; % Create and center main window defaultBackground = get(0,'defaultUicontrolBackgroundColor'); handles.figure_launcher = figure( ... @@ -60,8 +60,8 @@ pExist = ispref('carma'); if ~pExist addpref('carma', ... - {'labLower','labUpper','axMin','axMax','axSteps','cmapval','cmapstr','defdir','srateval','sratenum','bsizeval','bsizenum','update'}, ... - {'Negative Affect','Positive Affect',-100,100,9,1,'parula','',2,20,3,1.00,'ask'}); + {'labLower','labUpper','axMin','axMax','axSteps','axStart','cmapval','cmapstr','defdir','srateval','sratenum','bsizeval','bsizenum','update'}, ... + {'Negative Affect','Positive Affect',-100,100,9,0,1,'parula','',2,20,3,1.00,'ask'}); end % Check for updates try