Skip to content

Commit

Permalink
Replaced "Save Graph" button by "Save Figure" button from uitoolbar. …
Browse files Browse the repository at this point in the history
…Rearranged state buttons in a uipanel and filled a bit of unused space.
  • Loading branch information
ggalibert committed Jul 21, 2017
1 parent 8cb2dc4 commit 8837d2e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 210 deletions.
45 changes: 18 additions & 27 deletions GUI/mainWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,21 @@ function mainWindow(windowTitle, sample_data, states, startState, selectionCallb
'Parent', fig,...
'BorderType', 'none');

% buttons panel
butPanel = uipanel(...
'Parent', sidePanel,...
'BorderType', 'none');

% state buttons
lenStates = length(states);
stateButtons = nan(lenStates, 1);
for k = 1:lenStates
stateButtons(k) = uicontrol(...
'Parent', sidePanel,...
'Parent', butPanel,...
'Style', 'pushbutton',...
'String', states{k});
end

% button to save current graph as an image
graphButton = uicontrol(...
'Parent', sidePanel, ...
'Style', 'pushbutton',...
'String', 'Save Graph');

% variable selection panel - created in createVarPanel
varPanel = uipanel(...
'Parent', sidePanel,...
Expand All @@ -186,8 +185,8 @@ function mainWindow(windowTitle, sample_data, states, startState, selectionCallb
set(fig, 'Units', 'normalized');
set(sidePanel, 'Units', 'normalized');
set(mainPanel, 'Units', 'normalized');
set(butPanel, 'Units', 'normalized');
set(varPanel, 'Units', 'normalized');
set(graphButton, 'Units', 'normalized');
set(sampleMenu, 'Units', 'normalized');
set(graphMenu, 'Units', 'normalized');
set(extraSampleCb, 'Units', 'normalized');
Expand Down Expand Up @@ -216,25 +215,23 @@ function mainWindow(windowTitle, sample_data, states, startState, selectionCallb
set(extraSampleMenu, 'Position', posUi2(fig, 100, 100, 6:10, 1:75, 0));
set(extraSampleCb, 'Position', posUi2(fig, 100, 100, 6:10, 76:100, 0));

% varPanel, graph and stateButtons are positioned relative to sidePanel
% varPanel and butPanel are positioned relative to sidePanel
set(butPanel, 'Position', posUi2(sidePanel, 10, 1, 1:5, 1, 0));
set(varPanel, 'Position', posUi2(sidePanel, 10, 1, 6:10, 1, 0));

% set state buttons position relative to butPanel
n = length(stateButtons);
for k = 1:n
set(stateButtons(k), 'Position', posUi2(sidePanel, 2*(n+1)+1, 1, k, 1, 0));
set(stateButtons(k), 'Position', posUi2(butPanel, n, 1, k, 1, 0));
end

% graph button is tacked on right below state buttons
set(graphButton, 'Position', posUi2(sidePanel, 2*(n+1)+1, 1, n+1, 1, 0));

% set callbacks - variable panel widget
% callbacks are set in createParamPanel
set(sampleMenu, 'Callback', @sampleMenuCallback);
set(graphMenu, 'Callback', @graphMenuCallback);
set(extraSampleCb, 'Callback', @sampleMenuCallback);
set(extraSampleMenu, 'Callback', @sampleMenuCallback);
set(stateButtons, 'Callback', @stateButtonCallback);
set(graphButton, 'Callback', @graphButtonCallback);

set(fig, 'Visible', 'on');
createVarPanel(sample_data{1}, []);
Expand All @@ -243,19 +240,24 @@ function mainWindow(windowTitle, sample_data, states, startState, selectionCallb
tb = findall(fig, 'Type', 'uitoolbar');
buttons = findall(tb);

zoomoutb = findobj(buttons, 'TooltipString', 'Zoom Out');
savefigb = findobj(buttons, 'TooltipString', 'Save Figure');
zoominb = findobj(buttons, 'TooltipString', 'Zoom In');
zoomoutb = findobj(buttons, 'TooltipString', 'Zoom Out');
panb = findobj(buttons, 'TooltipString', 'Pan');
datacursorb = findobj(buttons, 'TooltipString', 'Data Cursor');

buttons(buttons == tb) = [];
buttons(buttons == zoomoutb) = [];
buttons(buttons == savefigb) = [];
buttons(buttons == zoominb) = [];
buttons(buttons == zoomoutb) = [];
buttons(buttons == panb) = [];
buttons(buttons == datacursorb) = [];

delete(buttons);

% reset save figure callback with the FileSaveAs one instead of FileSave
set(savefigb, 'ClickedCallback', 'filemenufcn(gcbf,''FileSaveAs'')');

%set zoom/pan post-callback
%zoom v6 off; % undocumented Matlab to make sure zoom function prior to R14 is not used. Seems to not be supported from R2015a.
hZoom = zoom(fig);
Expand Down Expand Up @@ -424,17 +426,6 @@ function stateButtonCallback(source, ev)
createVarPanel(sam, vars);
end

function graphButtonCallback(source, ev)
%GRAPHBUTTONCALLBACK Called when the user pushes the 'Save Graph' button.
% Prompts the user to save the current graph.

% find all axes objects on the main panel
ax = findobj(mainPanel, 'Type', 'axes');

% save the axes
saveGraph(fig, ax);
end

function varPanelCallback(source, ev)
%PARAMPANELCALLBACK Called when the variable or dimension selection
% changes. Delegates to selectionChange.
Expand Down
183 changes: 0 additions & 183 deletions Util/saveGraph.m

This file was deleted.

0 comments on commit 8837d2e

Please sign in to comment.