Commit 1cafc060 authored by Jay Dubb's avatar Jay Dubb
Browse files

v1.30.1

-- Fix not being able to set multiple stims using Add Stims edit box in StimEditGUI. Problem was in StimClass method to add multiple stims.

-- When StimEditGUI is closed and there are unsaved changes, alert user with message box that there are unsaved changes and provide opportunity to save changes before exiting. Also by default have don't ask again checkbox checked. The default behavior when 'don't ask again' is n effect is to exit GUI without saving. In connection to this, added a) new config option to AppSettings "Stim Edit GUI Save Warnings" and b) new option to MenuBox, in addition to 'dontAskAgainOptions', we now simply have 'dontAskAgain' which only provides a single checkbox and the checkbox settings is saved in AppSettings.cfg "Stim Edit GUI Save Warnings".

-- Modify slightly the wording of the warning to user to that they will be modifying an acquisition file directly when saving changes.

-- Add progress bar when StimEditGUI is launched because StimEditGUI is slow to load.
parent 1db799dd
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -23,7 +23,10 @@ files
% Auto Save Acquisition Files # No, Yes
No

% Group Data Loading Warnings
% Group Data Loading Warnings # don't ask again, ask every time
ask every time

% Stim Edit GUI Save Warnings # don't ask again, ask every time
don't ask again

% END
+15 −4
Original line number Diff line number Diff line
@@ -203,13 +203,24 @@ classdef StimClass < FileLoadSaveClass
            
            % Dimensions matter so dimensions must equal
            if ~all(size(obj.data)==size(obj2.data))
                if ~isempty(obj.data) || ~isempty(obj2.data)
                    return;
                end
            end
            
            % Now check contents
            if ~all(obj.data(:)==obj2.data(:))
                return;
            end
            
            if length(obj.dataLabels) ~= length(obj2.dataLabels)
                return;
            end
            for ii = 1:length(obj.dataLabels)
                if ~strcmp(obj.dataLabels{ii}, obj2.dataLabels{ii})
                    return;
                end
            end
            B = true;
        end
        
@@ -364,8 +375,8 @@ classdef StimClass < FileLoadSaveClass
                end 
            else  % If this stim is being added to an empty condition
                for i = 1:length(tPts)
                    obj.data = [tPts(i), duration, amp, more];
                    obj.states = [tPts(i), 1];
                    obj.data(i,:) = [tPts(i), duration, amp, more];
                    obj.states(i,:) = [tPts(i), 1];
                end
            end
        end
+36 −2
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@ function StimEditGUI_OpeningFcn(hObject, eventdata, handles, varargin)
global stimEdit
global maingui

waitmsg = 'Please wait a few seconds while GUI loads ...';
h = waitbar(0, waitmsg); nsteps = 5;  istep = 1;

% Choose default command line output for StimEditGUI
handles.output = hObject;
guidata(hObject, handles);
@@ -139,21 +142,30 @@ else
    set(hObject, 'units','characters');
end

waitbar(istep/nsteps, h, waitmsg); istep = istep+1;

stimEdit.version = get(hObject, 'name');
stimEdit.dataTree = LoadDataTree(stimEdit.groupDirs, stimEdit.format, '', maingui);
if stimEdit.dataTree.IsEmpty()
    close(h);
    return;
end
if isempty(stimEdit.dataTree)
    EnableGuiObjects('off', hObject);
    close(h);
    return;
end
waitbar(istep/nsteps, h, waitmsg); istep = istep+1;

% Make a local copy of dataTree in this GUI 
stimEdit.locDataTree = DataTreeClass(stimEdit.dataTree);

waitbar(istep/nsteps, h, waitmsg); istep = istep+1;

InitCurrElem(stimEdit);

waitbar(istep/nsteps, h, waitmsg); istep = istep+1;

set(get(handles.axes1,'children'), 'ButtonDownFcn', @axes1_ButtonDownFcn);
zoom(hObject,'off');
Display(handles);
@@ -161,6 +173,9 @@ SetTextFilename(handles);
EnableGuiObjects('on', handles);
stimEdit.status=0;

waitbar(1, h, waitmsg);
close(h);


% --------------------------------------------------------------------
function pushbuttonExit_Callback(hObject, eventdata, handles)
@@ -661,10 +676,11 @@ end
% Check auto-save config parameter
if ~strcmpi(stimEdit.config.autoSaveAcqFiles, 'Yes')
    % Ask user if they want to save, before changing contents of acquisition file
    msg{1} = sprintf('PLEASE NOTE:  Your stim edits will be saved directly to the acquisition file %s if you select ''Yes''.  ', stimEdit.dataTreeHandle.currElem.name);
    if stimEdit.dataTreeHandle.currElem.IsRun()
        msg = sprintf('Are you sure you want to save stimulus edits directly in the acquisition file %s?', stimEdit.dataTreeHandle.currElem.name);
        msg{2} = sprintf('Are you sure you want to modify the original acquisition file? ');
    else
        msg = sprintf('Are you sure you want to save stimulus edits directly in acquisition files in %s?', stimEdit.dataTreeHandle.currElem.name);
        msg{2} = sprintf('Are you sure you want to modify the original acquisition files? ');
    end
    q = MenuBox(msg, {'Yes','No','Don''t ask again'});
    if q==2
@@ -704,6 +720,24 @@ global stimEdit
if isempty(stimEdit)
    return;
end
cfg = ConfigFileClass();
if strcmp(cfg.GetValue('Stim Edit GUI Save Warnings'), sprintf('don''t ask again'))
    return;
end

if stimEdit.dataTreeHandle.currElem.AcquiredDataModified()
    q = MenuBox('There are unsaved changes to stims or conditions in the current element. Do you want to save your edits?', ...
        {'Yes','No'}, [], [], 'dontAskAgain');
    
    if q(2)==1 
        cfg.SetValue('Stim Edit GUI Save Warnings', sprintf('don''t ask again'));
        cfg.Save();
    end
    if q(1)==2
        % Exit GUI without saving changes
        return
    end
end
Save()


+31 −7
Original line number Diff line number Diff line
function selection = MenuBox(msg, bttns, relativePos, textLineWidth, options)

%
% SYNTAX:
%
%   selection = MenuBox(msg, bttns)
%   selection = MenuBox(msg, bttns, relativePos)
%   selection = MenuBox(msg, bttns, relativePos, textLineWidth)
%   selection = MenuBox(msg, bttns, relativePos, textLineWidth, options)
%
% EXAMPLES:
%
%   q = MenuBox('Please select option',{'option1','option2','option3'});
%   q = MenuBox('Please select option',{'option1','option2','option3'}, 'lowerleft');
%   q = MenuBox('Please select option',{'option1','option2','option3'}, 'upperright',80);
%   q = MenuBox('Please select option',{'option1','option2','option3'},[],[],sprintf('dontAskAgain'));
%   q = MenuBox('Please select option',{'option1','option2','option3'},'centerright',[],sprintf('dontAskAgainOptions'));
%   q = MenuBox('Please select option',{'option1','option2','option3'},[],75,sprintf('dontAskAgain'));
%

global bttnIds
bttnIds = 0;

@@ -281,12 +300,17 @@ end
function checkboxes = getCheckboxes(options)

checkboxes = {};
if ~optionExists(options, 'dontAskAgainOptions')
if ~optionExists(options, 'dontAskAgainOptions') && ~optionExists(options, 'dontAskAgain')
    return;
end
if optionExists(options, 'dontAskAgainOptions')
    checkboxes = { ...
        sprintf('don''t ask again');  ...
        sprintf('ask every time'); ...
        % sprintf('ask once at start of next session'); ...
        };
else
    checkboxes = { ...
        sprintf('don''t ask again');  ...
        };
end
+1 −1
Original line number Diff line number Diff line
@@ -2,5 +2,5 @@ function vrnnum = getVernum()

vrnnum{1} = '1';   % Major version #
vrnnum{2} = '30';  % Major sub-version #
vrnnum{3} = '0';   % Minor version #
vrnnum{3} = '1';   % Minor version #
vrnnum{4} = '0';   % Minor sub-version # or patch #: 'p1', 'p2', etc