Skip to content
Snippets Groups Projects
Commit c4fa8a1e authored by Yoann Guilhem's avatar Yoann Guilhem
Browse files

New feature in GtVolView: save figure command in context menu.

parent 887e41fe
No related branches found
No related tags found
No related merge requests found
...@@ -667,11 +667,16 @@ classdef GtVolView < GtBaseGuiElem ...@@ -667,11 +667,16 @@ classdef GtVolView < GtBaseGuiElem
set(obj.conf.h_im, 'UIContextMenu', obj.conf.h_context_menu); set(obj.conf.h_im, 'UIContextMenu', obj.conf.h_context_menu);
set(obj.conf.h_overlay, 'UIContextMenu', obj.conf.h_context_menu); set(obj.conf.h_overlay, 'UIContextMenu', obj.conf.h_context_menu);
% Copy pixel info in context menu
cbk = @(src, evt)copy3DPixInfoToClipboard(obj); cbk = @(src, evt)copy3DPixInfoToClipboard(obj);
obj.conf.h_menu_items = {}; obj.conf.h_menu_items = {};
obj.conf.h_menu_items{end+1} = uimenu(obj.conf.h_context_menu, ... obj.conf.h_menu_items{end+1} = uimenu(obj.conf.h_context_menu, ...
'Label', 'Copy pixel 3D info', ... 'Label', 'Copy pixel 3D info', ...
'Callback', cbk); 'Callback', cbk);
% Save figure in context menu
obj.conf.h_menu_items{end+1} = uimenu(obj.conf.h_context_menu, ...
'Label', 'Save figure', ...
'Callback', @(src, evt)saveFigure(obj));
end end
function point = get3DPixelInfo(obj) function point = get3DPixelInfo(obj)
...@@ -917,6 +922,28 @@ classdef GtVolView < GtBaseGuiElem ...@@ -917,6 +922,28 @@ classdef GtVolView < GtBaseGuiElem
end end
drawnow; drawnow;
end end
function saveFigure(obj, fname, ftype)
% GTVOLVIEW/SAVEFIGURE Save the content of axis to a file
cancel = false;
if (~exist('fname', 'var') || isempty(fname) || ...
~exist('ftype', 'var') || isempty(ftype))
[fname, ftype, cancel] = imputfile();
else
if (exist(fname, 'file'))
answer = inputwdefault(['''' fname ''' already exists.\n Do you want to replace it?'], 'n');
if (~strcmp(answer, 'y'))
cancel = true;
end
end
end
if (cancel)
disp('User canceled image saving, so nothing has been written.');
else
im = frame2im(getframe(obj.conf.h_ax));
imwrite(im, fname, ftype);
end
end
end end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment