Skip to content

Commit

Permalink
Bugfix: Pan/zoom issues in TS and spectrum figures
Browse files Browse the repository at this point in the history
  • Loading branch information
ftadel committed Sep 19, 2020
1 parent 9500920 commit 5fc1b60
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion doc/license.html
Expand Up @@ -5,7 +5,7 @@
<body alink="#fff000" link="#fff000" vlink="#fff000">
<h4><span style="font-family: Arial Black; color: #ffffff;"><strong>THERE IS NO UNDO BUTTON - SET UP A BACKUP OF YOUR DATABASE</strong></span></h4>
<HR>
<!-- LICENCE_START -->Version: 3.200918 (18-Sep-2020)<br>
<!-- LICENCE_START -->Version: 3.200919 (19-Sep-2020)<br>
<span style="font-style: italic;">COPYRIGHT &copy; 2000-2020
USC &amp; McGill University.<br>
</span>
Expand Down
2 changes: 1 addition & 1 deletion doc/version.txt
@@ -1,2 +1,2 @@
% Brainstorm
% v. 3.200918 (18-Sep-2020)
% v. 3.200919 (19-Sep-2020)
9 changes: 7 additions & 2 deletions toolbox/gui/figure_spectrum.m
Expand Up @@ -239,9 +239,11 @@ function FigureMouseDownCallback(hFig, ev)
% CTRL+Mouse, or Mouse right
case 'alt'
clickAction = 'gzoom';
set(hFig, 'Pointer', 'top');
% SHIFT+Mouse
case 'extend'
clickAction = 'pan';
set(hFig, 'Pointer', 'fleur');
% DOUBLE CLICK
case 'open'
ResetView(hFig);
Expand Down Expand Up @@ -328,6 +330,9 @@ function FigureMouseUpCallback(hFig, event)
% Reset figure mouse fields
setappdata(hFig, 'clickAction', '');
setappdata(hFig, 'hasMoved', 0);
% Restore mouse pointer
set(hFig, 'Pointer', 'arrow');
drawnow;
% Get axes handles
hAxes = getappdata(hFig, 'clickSource');
if isempty(hAxes) || ~ishandle(hAxes)
Expand Down Expand Up @@ -531,7 +536,7 @@ function ZoomSelection(hFig)
end
% Set axes bounds to selection
hAxesList = findobj(hFig, '-depth', 1, 'Tag', 'AxesGraph');
set(hAxesList, 'XLim', [GraphSelection(1), GraphSelection(2)]);
set(hAxesList, 'XLim', [min(GraphSelection), max(GraphSelection)]);
% Draw new time selection
setappdata(hFig, 'GraphSelection', []);
DrawSelection(hFig);
Expand Down Expand Up @@ -1370,7 +1375,7 @@ function UpdateFigurePlot(hFig, isForced)
% Get automatic YLim
if ~isempty(Fmax) && (Fmax(1) ~= Fmax(2))
% Use the first local maximum: ignores the huge range of high frequencies
if any(strcmpi(TfInfo.Function, {'power', 'magnitude'})) && all(TF(:)>=0)
if any(strcmpi(TfInfo.Function, {'power', 'magnitude'})) && strcmpi(TsInfo.YScale, 'linear') && all(TF(:)>=0)
TFmax = max(TF,[],1);
iStart = find(diff(TFmax)>0,1);
if ~isempty(iStart)
Expand Down
29 changes: 24 additions & 5 deletions toolbox/gui/figure_timeseries.m
Expand Up @@ -897,7 +897,7 @@ function ZoomSelection(hFig)
end
% Set axes bounds to selection
hAxesList = findobj(hFig, '-depth', 1, 'Tag', 'AxesGraph');
set(hAxesList, 'XLim', [GraphSelection(1), GraphSelection(2)]);
set(hAxesList, 'XLim', [min(GraphSelection), max(GraphSelection)]);
% Delete selection
SetTimeSelectionLinked(hFig, []);
end
Expand Down Expand Up @@ -946,8 +946,15 @@ function FigureScroll(hFig, ScrollCount, target)
%% ===== FIGURE ZOOM: LINKED =====
% Apply the same zoom operations to similar figures
function FigureZoomLinked(hFig, direction, Factor)
% Get figure type
FigureId = getappdata(hFig, 'FigureId');
% Get all the time-series figures
hAllFigs = bst_figures('GetFiguresByType', {'DataTimeSeries', 'ResultsTimeSeries'});
switch (FigureId.Type)
case {'DataTimeSeries', 'ResultsTimeSeries'}
hAllFigs = bst_figures('GetFiguresByType', {'DataTimeSeries', 'ResultsTimeSeries'});
case 'Spectrum'
hAllFigs = bst_figures('GetFiguresByType', 'Spectrum');
end
% Place the input figure in first
hAllFigs(hAllFigs == hFig) = [];
hAllFigs = [hFig, hAllFigs];
Expand Down Expand Up @@ -1070,6 +1077,11 @@ function FigureZoom(hFig, direction, Factor, center)

%% ===== FIGURE PAN =====
function FigurePan(hFig, motion)
% Flip Y motion for flipped axis
TsInfo = getappdata(hFig, 'TsInfo');
if ~isempty(TsInfo) && isfield(TsInfo, 'FlipYAxis') && isequal(TsInfo.FlipYAxis, 1)
motion(2) = -motion(2);
end
% Get list of axes in this figure
hAxes = findobj(hFig, '-depth', 1, 'Tag', 'AxesGraph');
% Displacement in X
Expand Down Expand Up @@ -1995,17 +2007,24 @@ function SetProperty(hFig, propName, propVal)
else
propGraph = 'on';
end
% Get axes handles
hAxes = findobj(hFig, '-depth', 1, 'Tag', 'AxesGraph');
% Update figure
switch propName
case 'ShowXGrid'
hAxes = findobj(hFig, '-depth', 1, 'Tag', 'AxesGraph');
set(hAxes, 'XGrid', propGraph);
set(hAxes, 'XMinorGrid', propGraph);
case 'ShowYGrid'
hAxes = findobj(hFig, '-depth', 1, 'Tag', 'AxesGraph');
set(hAxes, 'YGrid', propGraph);
set(hAxes, 'YMinorGrid', propGraph);
case {'ShowZeroLines', 'FlipYAxis', 'ShowEventsMode'}
case 'FlipYAxis'
ResetViewLinked(hFig);
YLimInit = getappdata(hAxes, 'YLimInit');
if (length(YLimInit) == 2)
setappdata(hAxes, 'YLimInit', [YLimInit(2), YLimInit(1)]);
end
bst_figures('ReloadFigures', hFig, 0);
case {'ShowZeroLines', 'ShowEventsMode'}
bst_figures('ReloadFigures', hFig, 0);
otherwise
error('Invalid property name.');
Expand Down

0 comments on commit 5fc1b60

Please sign in to comment.