Skip to content

Commit

Permalink
Make sure auto zoom on graph(s) other than current one takes into acc…
Browse files Browse the repository at this point in the history
…ount extra sample data if extra sample is selected.
  • Loading branch information
ggalibert committed Jul 21, 2017
1 parent 1d6fbdc commit 2a4be73
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
13 changes: 11 additions & 2 deletions GUI/mainWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ function zoomPostCallback(source, ev)
% change in the Y range of displayed data
if ~isempty(graphs1D)
sam = getSelectedData();
extraSam = getExtraSelectedData();

hTickBoxes = get(varPanel, 'UserData');

Expand All @@ -501,15 +502,23 @@ function zoomPostCallback(source, ev)
userData = get(graphs1D(i), 'UserData');

hData = userData{1};
xData = get(hData, 'XData');
yData = get(hData, 'YData');
xData = get(hData(1), 'XData');
yData = get(hData(1), 'YData');

iTickBox = userData{2}; % index into currently ticked boxes
iAllTickedBox = find(cell2mat(get(hTickBoxes, 'Value')) == 1);

varName = get(hTickBoxes(iAllTickedBox(iTickBox)), 'String');
iVar = getVar(sam.variables, varName);
flags = sam.variables{iVar}.flags;
if get(extraSampleCb, 'value')
iExtraVar = getVar(extraSam.variables, varName);
if iExtraVar
flags = [flags; extraSam.variables{iExtraVar}.flags];
xData = [xData, get(hData(2), 'XData')];
yData = [yData, get(hData(2), 'YData')];
end
end
iGood = ismember(flags, okFlags);

xData(~iGood) = [];
Expand Down
4 changes: 2 additions & 2 deletions Graph/TimeSeries/highlightTimeSeriesGeneric.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
if ~isstruct(variable), error('variable must be a struct'); end
if ~ischar(type), error('type must be a string'); end

xdata = get(data, 'XData');
ydata = get(data, 'YData');
xdata = get(data(1), 'XData'); % data(1) retrieves the first graphic handle only in case extra sample is selected
ydata = get(data(1), 'YData');

if iscell(xdata)
xdata = cell2mat(xdata)';
Expand Down
16 changes: 11 additions & 5 deletions Graph/graphTimeSeries.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

graphs = [];
lines = [];

if isempty(vars)
return;
end
Expand All @@ -82,13 +82,19 @@
% get rid of variables that we should ignore
sample_data.variables = sample_data.variables(vars);
lenVar = length(sample_data.variables);

if ~isempty(extra_sample_data)
nInst = 2;
else
nInst = 1;
end

if verLessThan('matlab','8.1') %R2013a
graphs = nan(lenVar, 1);
lines = nan(lenVar, 1);
lines = nan(lenVar, nInst);
else
graphs = gobjects(lenVar, 1);
lines = gobjects(lenVar, 1);
lines = gobjects(lenVar, nInst);
end

iTimeDim = getVar(sample_data.dimensions, 'TIME');
Expand Down Expand Up @@ -203,10 +209,10 @@
(extra_sample_data.variables{iExtraVar}.flags == rawFlag);
extra_sample_data.variables{iExtraVar}.data(~iGoodExtra) = NaN;
end
plotFunc(graphs(k), extra_sample_data, iExtraVar, 'k', xTickProp); % extra instrument is always plotted in black
[lines(k,2), ~] = plotFunc(graphs(k), extra_sample_data, iExtraVar, 'k', xTickProp); % extra instrument is always plotted in black
end
% we plot the current instrument last so that it appears on top
[lines(k,:), labels] = plotFunc(graphs(k), sample_data, k, 'b', xTickProp); % current instrument is always plotted in blue
[lines(k,1), labels] = plotFunc(graphs(k), sample_data, k, 'b', xTickProp); % current instrument is always plotted in blue

if ~isempty(labels)
% set x labels and ticks
Expand Down

0 comments on commit 2a4be73

Please sign in to comment.