Commit 5800e72a authored by Jay Dubb's avatar Jay Dubb
Browse files

v1.25.12

-- Fix for the stims not being selected correctly closer to the left boundary of the axes found by Christian Arthur.
-- Improve MenuBox positioning relative to parent GUI. Position the StimEditGUI menu options when selecting stims to 'center right' relative to StimEditGUI
-- In StimEditGUI display new condition warning about conditions and colors being reordered only if the new conditions is NOT the last condition when sorted with the group conditions.
parent 461a9b28
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -408,7 +408,7 @@ actionLst{end+1} = 'Cancel';
nActions = length(actionLst);

% Get user's responce to menu question
menu_choice = MenuBox(menuTitleStr, actionLst);
menu_choice = MenuBox(menuTitleStr, actionLst, 'centerright');



@@ -446,7 +446,7 @@ end


% ------------------------------------------------
function status = NewCondWarning()
function status = NewCondWarning(CondNameNew)
global stimEdit

status = 0;
@@ -454,8 +454,16 @@ status = 0;
if stimEdit.newCondWarning
    return;
end

iG = stimEdit.locDataTree.GetCurrElemIndexID();
CondNamesGroup = stimEdit.locDataTree.groups(iG).GetConditions();
CondNamesGroupNew = sort([CondNameNew, CondNamesGroup]);
if strcmp(CondNamesGroupNew{end}, CondNameNew)
    return;
end

msg{1} = sprintf('WARNING: Please note that adding a new condition or renaming an exiting one ');
msg{2} = sprintf('could change the colors of the stimuli and reorder the stim condition color legend ');
msg{2} = sprintf('could change the colors of some stimuli and reorder the stim condition color legend ');
msg{3} = sprintf('in the top right corner of the axes window.');
q = MenuBox([msg{:}], {'Okay', 'Cancel', 'Don''t Warn Again and Proceed'});
if q==3
@@ -493,7 +501,7 @@ while 1
    end
end
CondName = CondNameNew{1};
if NewCondWarning() < 0
if NewCondWarning(CondName) < 0
    CondName = '';
end

+35 −20
Original line number Diff line number Diff line
@@ -74,26 +74,7 @@ set(hf, 'visible','off');
set(hf, 'units','characters');

% Determine optimal position of MenuBox relative to parent GUI
switch(lower(relativePos))
    case 'upperleft'
        posrel = [.2, .6];
    case 'centerleft'
        posrel = [.2, .3];
    case 'lowerleft'
        posrel = [.2, .1];
    case 'upperright'
        posrel = [.8, .6];
    case 'centerright'
        posrel = [.8, .3];
    case 'lowerright'
        posrel = [.8, .1];
    case 'center'
        posrel = [.3, .3];
    otherwise
        posrel = [.3, .3];
end
pX = posParent(1)+posrel(1)*posParent(3);
pY = posParent(2)+posrel(2)*posParent(4);
[pX, pY] = positionRelative(hf, posParent, relativePos);
posBox = [pX, pY, Wfig, Hfig];

if DEBUG
@@ -176,3 +157,37 @@ for ii=1:length(lines)
end


% -------------------------------------------------------------
function [pX, pY] = positionRelative(hf, posParent, relativePos)
lr = .5;
ul = 0;
posFig = get(hf, 'position');

leftSide = posParent(1);
rightSide = posParent(1)+posParent(3);
lowerSide = posParent(2);
upperSide = posParent(2)+posParent(4);

pX = rightSide - .5*posParent(3);
pY = lowerSide + .25*posParent(4);
switch(lower(relativePos))
    case 'upperleft'
        pX = leftSide  - lr*posFig(3);
        pY = upperSide - ul*posFig(4);
    case 'centerleft'
        pX = leftSide  - lr*posFig(3);
        pY = lowerSide + ul*posFig(4);
    case 'lowerleft'
        pX = leftSide  - lr*posFig(3);
        pY = lowerSide + ul*posFig(4);
    case 'upperright'
        pX = rightSide  - lr*posFig(3);
        pY = upperSide - ul*posFig(4);
    case 'centerright'
        pX = rightSide  - lr*posFig(3);
        pY = lowerSide + ul*posFig(4);
    case 'lowerright'
        pX = rightSide  - lr*posFig(3);
        pY = lowerSide + ul*posFig(4);
end
+24 −12
Original line number Diff line number Diff line
@@ -4,10 +4,11 @@ p1 = get(gca,'CurrentPoint'); % button down detected
finalRect = rbbox;                   % return figure units
p2 = abs(get(gca,'CurrentPoint'));

% dispSelectedPts(p1, p2, finalRect);
fprintf('Initial ...\n');
dispSelectedPts(p1, p2, finalRect);

[err, p1, p2] = errorCheck(p1, p2, finalRect);
if err<1
if err<0
    dispSelectedPts(p1,p2,finalRect);
    return;
end
@@ -23,7 +24,9 @@ while all(p1==p2)
    p2 = get(gca,'CurrentPoint');
end

fprintf('Modified ...\n');
dispSelectedPts(p1, p2, finalRect);
fprintf('\n');



@@ -53,7 +56,13 @@ axesSize_userUnits = xlim(2) - xlim(1);

scalingFactor = axesSize_userUnits / axesSize_guiUnits;

rectSize_finalRect    = scalingFactor * finalRect(3);
offset = 0;
if finalRect(1)<p(1)
    offset = abs(finalRect(1) - p(1));
    p2(:) = xlim(1);
end
rectSize_finalRect    = scalingFactor * (finalRect(3) - offset);
% rectSize_finalRect    = scalingFactor * finalRect(3);
rectSize_CurrentPoint = p2(1) - p1(1);

if all(p1==0) & all(p2==0)
@@ -62,14 +71,21 @@ if all(p1==0) & all(p2==0)
    return
end

if p1(1) <= p2(1)
    p2 = p1 + rectSize_finalRect;

if all(p1(1)==p2(1)) & p1(1)==p1(2)
    farSidePosX = (scalingFactor*abs(finalRect(1)-p(1)) + scalingFactor*finalRect(3));
    nearSidePosX = scalingFactor*abs(finalRect(1)-p(1));
    if abs(p1(1) - farSidePosX) < 1
        p1(:,1) = p2(1) - rectSize_finalRect;
    elseif abs(p1(1) - nearSidePosX) < 1
        p2(:,1) = p1(1) + rectSize_finalRect;
    end 
elseif p1(1) <= p2(1)
    p2(:,1) = p1(1) + rectSize_finalRect;
else
    p1 = p2 + rectSize_finalRect;
    p1(:,1) = p2(1) + rectSize_finalRect;
end


fprintf('\n');
fprintf('Selection rectangle from finalRect    :  %0.1f\n', rectSize_finalRect);
fprintf('Selection rectangle from CurrentPoint :  %0.1f\n', rectSize_CurrentPoint );

@@ -85,16 +101,12 @@ set(gca, 'units',u);
p = get(gca, 'position');
xlim = get(gca, 'xlim');

fprintf('\n');

fprintf('axes size:  [%0.2f, %0.2f, %0.2f, %0.2f]\n', p(1), p(2), p(3), p(4));
fprintf('axes xlim:  [%0.2f, %0.2f]\n', xlim(1), xlim(2));
fprintf('finalRect: [%0.2f, %0.2f, %0.2f, %0.2f]\n', finalRect(1), finalRect(2), finalRect(3), finalRect(4));
fprintf('p1:        [%0.2f, %0.2f]\n', p1(1), p1(2));
fprintf('p2:        [%0.2f, %0.2f]\n', p2(1), p2(2));

fprintf('\n');

set(gca, 'units',u0);


+1 −1
Original line number Diff line number Diff line
@@ -2,5 +2,5 @@ function vrnnum = getVernum()

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