Skip to content
Snippets Groups Projects
Commit f6073c6e authored by jacques.grelet_ird.fr's avatar jacques.grelet_ird.fr
Browse files

Ajour de la fonction QuitProgram pour fermer proprement l'application.

Ajout de la propriété CloseRequestFcn dans la définition de la figure.
Ajout dynamique dans le path matlab de sous répertoires tsg_util et tsg_data.
Utilisation de filesep pour assurer la portabilité Unix/Windows
Prise en charge distincte de la lecture des fichiers txt, xml et NetCDF.
Correction d'un bug en cas de mauvaise ouverture d'un fichier.
parent a0b126fd
No related branches found
No related tags found
No related merge requests found
......@@ -7,13 +7,20 @@ function tsgqc_GUI
% ********************
clc
% Determine the directory where the program is store.
% Find program directory.
% functions (icons) should be store at a lower level
% MAKE the path working on UNIX machine
% add directories to Matlab search path, works on UNIX
% and Windows host
% ---------------------------------------------------
tsgqcname = mfilename;
fulltsgqcname = mfilename('fullpath');
DEFAULT_PATH_FILE = strrep(fulltsgqcname, tsgqcname, '') ;
p = [pathsep,...
DEFAULT_PATH_FILE,[filesep 'tsg_util' pathsep],...
DEFAULT_PATH_FILE,[filesep 'tsg_data' pathsep]
];
addpath( p, '-END' );
rehash;
% Screen limits for the GUI
% -------------------------
......@@ -34,6 +41,7 @@ function tsgqc_GUI
'Toolbar', 'none', ...
'Tag', 'ButtonMotionOff', ...
'WindowButtonMotionFcn', @MouseMotion, ...
'CloseRequestFcn', @QuitProgram,...
'HandleVisibility','callback',...
'Visible','on',...
'Units', 'normalized',...
......@@ -76,7 +84,7 @@ function tsgqc_GUI
'Parent',hToolbar,...
'TooltipString','Save file',...
'CData',iconRead( ...
[DEFAULT_PATH_FILE 'tsg_icon\savedoc.mat']),...
[DEFAULT_PATH_FILE 'tsg_icon' filesep 'savedoc.mat']),...
'HandleVisibility','callback', ...
'ClickedCallback', @SaveMenuCallback);
hZoomPushtool = uipushtool(... % Open toolbar button
......@@ -100,7 +108,7 @@ function tsgqc_GUI
'Separator', 'on', ...
'Tag', 'off', ...
'CData',iconRead(...
[DEFAULT_PATH_FILE 'tsg_icon\qcicon.mat']),...
[DEFAULT_PATH_FILE 'tsg_icon' filesep 'qcicon.mat']),...
'HandleVisibility','callback', ...
'ClickedCallback', @QCMenuCallback);
hMapPushtool = uipushtool(... % Open toolbar button
......@@ -109,7 +117,7 @@ function tsgqc_GUI
'Separator', 'on', ...
'Tag', 'off', ...
'CData',iconRead(...
[DEFAULT_PATH_FILE 'tsg_icon\mapicon.mat']),...
[DEFAULT_PATH_FILE 'tsg_icon' filesep 'mapicon.mat']),...
'HandleVisibility','callback', ...
'ClickedCallback', @MapMenuCallback);
hClimPushtool = uipushtool(... % Open toolbar button
......@@ -118,7 +126,7 @@ function tsgqc_GUI
'Separator', 'on', ...
'Tag', 'off', ...
'CData',iconRead(...
[DEFAULT_PATH_FILE 'tsg_icon\climicon.mat']),...
[DEFAULT_PATH_FILE 'tsg_icon' filesep 'climicon.mat']),...
'HandleVisibility','callback', ...
'ClickedCallback', @ClimMenuCallback);
hBottlePushtool = uipushtool(... % Open toolbar button
......@@ -127,7 +135,7 @@ function tsgqc_GUI
'Separator', 'on', ...
'Tag', 'off', ...
'CData',iconRead(...
[DEFAULT_PATH_FILE 'tsg_icon\bottleicon.mat']),...
[DEFAULT_PATH_FILE 'tsg_icon' filesep 'bottleicon.mat']),...
'HandleVisibility','callback', ...
'ClickedCallback', @BottleMenuCallback);
......@@ -238,16 +246,27 @@ function tsgqc_GUI
% ATTENTION : function OpenMenuCallback(hObject, eventdata)
% This has to be made general for UNIX and WINDOWS system
% ---------------------------------------------------------
[filename, pathname] = uigetfile( ...
[DEFAULT_PATH_FILE '*.*'], 'Pick an NetCdf file');
[filename, pathname, filterIndex] = uigetfile( ...
{'*.txt';'*.xml';'*.nc'}, 'Pick a file');
if ~isequal(filename, 0)
% Read the data
% -------------
error = tsg_readTsgData( hMainFig, filename );
switch filterIndex
case 1
error = tsg_readTsgDataTxt( hMainFig, filename );
case 2
error = tsg_readTsgDataXML( hMainFig, filename );
case 3
error = tsg_readTsgDataNetCDF( hMainFig, filename );
otherwise
return;
end
if error
if error ~= -1
% The file has been open and read
% -------------------------------
......@@ -726,6 +745,8 @@ function tsgqc_GUI
function QuitMenuCallback(hObject, eventdata)
% Callback function run when the Quit menu item is selected
% If the data have been modified and not save, the program
% propose to save the data
% --------------------------------------------------------
......@@ -737,7 +758,7 @@ function tsgqc_GUI
if strcmp(selection, 'Yes')
return;
else
delete(hMainFig);
QuitProgram;
end
else
selection = ...
......@@ -747,10 +768,21 @@ function tsgqc_GUI
if strcmp(selection, 'No')
return;
else
delete(hMainFig);
QuitProgram;
end
end
end
end
% ----------------------------------------------------------------
function QuitProgram(hObject, eventdata)
delete(hMainFig);
% reset Matlab search path to default
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_util'] );
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_data'] );
rehash;
end
end
\ No newline at end of file
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