Newer
Older

jacques.grelet_ird.fr
committed
% check if key is pressed
% -----------------------
if ~isempty(evnt.Key)

jacques.grelet_ird.fr
committed
% test key, shift or control
% --------------------------
switch evnt.Key

jacques.grelet_ird.fr
committed
case 'shift'

jacques.grelet_ird.fr
committed
% get stored cursor shape
% -----------------------
pointerShape = getappdata( hMainFig, 'tsg_pointer');

jacques.grelet_ird.fr
committed
% if pointer equal to fullcrosshair, oups, error, reset to arrow
% ---------------------------------------------------------------
if strcmp(pointerShape, 'fullcrosshair')
pointerShape = 'arrow';

jacques.grelet_ird.fr
committed
end

jacques.grelet_ird.fr
committed
% set pointer
% -----------
case 'alt'

jacques.grelet_ird.fr
committed
% find vertical lines and delete them
% -----------------------------------
hdl_lines = findobj( 'Tag', 'VERTICAL_TAG_LINE' );
delete(hdl_lines);

jacques.grelet_ird.fr
committed
end % end of switch

jacques.grelet_ird.fr
committed
end % end of if
% Re-activate callback
% --------------------

jacques.grelet_ird.fr
committed
end
%% QuitMapCallback
% -----------------------------------------------------------------
% Callback function run when the Quit Map Figure item is selected
% -----------------------------------------------------------------
function QuitMapCallback(src, evnt)
% Make the earth map invisible
% ----------------------------
set(hMapToggletool, 'state', 'off' );
% -----------------------------------------------------------------
% Callback function run when the Quit menu item is selected
% -----------------------------------------------------------------
function QuitMenuCallback(src, evnt)
% Get the data from the application GUI
% -------------------------------------
tsg = getappdata(hMainFig, 'tsg_data');
% in case of bad initialisation, the user could close the windows
% ---------------------------------------------------------------
try
% save config mat file in prefdir
% -------------------------------
config_file = [prefdir, filesep, tsgqcname, '.mat'];
% save preference mat file
% ------------------------
if exist('tsg', 'var') && isfield( tsg, 'preference')
preference = tsg.preference;
save( config_file, 'preference');
end
% If the data have been modified and not save, the program
% ask to save the data
% --------------------------------------------------------
if strcmp( get( hSaveMenu, 'UserData' ), 'on')
selection = ...
questdlg('The file has been modified. Do you want to save it ?',...
'Save before Quit?',...
'Yes', 'No', 'Yes');
if strcmp(selection, 'Yes')
% call File/Save Menu Callback before before quit
% -----------------------------------------------
SaveMenuCallback;
% quit program
% ------------
quitProgram(DEFAULT_PATH_FILE, hMainFig, hMapFig);
selection = ...
questdlg(['Quit ' get(hMainFig, 'Name') '?'],...
['Quit ' get(hMainFig, 'Name') '?'],...
'Yes', 'No', 'Yes');
if strcmp(selection, 'No')
return;
else
quitProgram(DEFAULT_PATH_FILE, hMainFig, hMapFig);
end
% catch error during close windows
% --------------------------------
catch
% display message to console and quit program
% -------------------------------------------
fprintf('abnormal program termination during close user request\n');
quitProgram(DEFAULT_PATH_FILE, hMainFig);

jacques.grelet_ird.fr
committed
end % end of QuitMenuCallback
function quitProgram(DEFAULT_PATH_FILE, varargin)
% close all windows
% -----------------
for ii=1:size(varargin,2)
delete(varargin{ii});
end
% reset userdata property of root Matalab object (0) for next use
% ---------------------------------------------------------------
set(0, 'userdata', []);
% reset Matlab search path to default
% addpath isn't mandatory and failed with compiled applications
% --------------------------------------------------------------
if (~isdeployed)
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_util'] );
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_data'] );
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_io'] );
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_map'] );
end
% Refresh file system caches
% --------------------------
rehash;
% clear base workspace just before quit, this is the only method
% to clear NetCDF variables assign to base workspace with assignin
% ----------------------------------------------------------------
evalin('base','clear all');
end % end of quitProgram
end % end of tsgqc