Skip to content
Snippets Groups Projects
tsgqc.m 132 KiB
Newer Older
% TSGQC: Thermosalinograph (TSG) Quality Control software
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed


%% COPYRIGHT & LICENSE
%  Copyright 2007 - IRD US191, all rights reserved.
%
%  This file is part of tsgqc.
%    TSG-QC is free software; you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation; either version 2 of the License, or
%    (at your option) any later version.
%
%    tsgqc is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with Datagui; if not, write to the Free Software
%    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
%% TIPS
%  To get tsg anywhere during debug:
%  tsg = getappdata( findobj('Tag', 'TAG_TSG-QC_GUI'), 'tsg_data')
%% Define global variables for VERSIONING
% ---------------------------------------
global CHAR_VERSION
global NETCDF_FORMAT_VERSION

% version number, may be used to initialize some files when it change
% 0.90x -> 1.0RCx
% -------------------------------------------------------------------
VERSION = 1.2;  % -> 1.2
CHAR_VERSION = '1.2';

% netcdf file version, see DATA FORMAT TSG document:
% CORTSG_format_gosud_1.5.doc
% --------------------------------------------------
NETCDF_FORMAT_VERSION     = '2.0';
%%  Initialization tasks
%   ********************

% Clear Command Window display, giving up a "clean screen."
% ---------------------------------------------------------
clc;

% Find program directory.
% functions (icons) should be store at a lower level
% add directories to Matlab search path, works on UNIX
% and Windows host
% ---------------------------------------------------
tsgqcname = mfilename;
fulltsgqcname = mfilename('fullpath');

% regular expression expr if it occurs at the end of the input string
% -------------------------------------------------------------------
expr = strcat(tsgqcname, '$');

% get pathname
% ------------
DEFAULT_PATH_FILE =  regexprep(fulltsgqcname, expr, '');

% update Matlab pathdef only for session
% --------------------------------------
p = [pathsep,...
  DEFAULT_PATH_FILE,[ 'tsg_util' pathsep],...
  DEFAULT_PATH_FILE,[ 'tsg_data' pathsep],...
  DEFAULT_PATH_FILE,[ 'tsg_io'   pathsep]
rehash;

% define 'HandleVisibility' property for all objects
% --------------------------------------------------
handleVisibility = 'on';

% % get screen dimensions (pixels)
% % ------------------------------
% set(0,'Units','pixels');
% screenSize = get(0,'ScreenSize');
% 
% % set default font size
% % ---------------------
% if screenSize(3) <= 1024
%   tsg.fontSize = 9;
% else
%   tsg.fontSize = 11;
% end

% Screen limits for the GUI
% -------------------------
set(0,'Units','normalized');
guiLimits = get(0,'ScreenSize');
guiLimits(1) = guiLimits(1) + 0.01;
guiLimits(2) = guiLimits(2) + 0.05;
guiLimits(3) = guiLimits(3) - 0.02;
guiLimits(4) = guiLimits(4) - 0.15;


%% Main TSGQC GUI
% ---------------

% Check if main TSGQC figure exist
% --------------------------------
hMainFig = findobj('Tag', 'TAG_TSG-QC_GUI');

% if TSGQC figure exist and still running, don't create a new instance
% --------------------------------------------------------------------
if ~isempty(hMainFig)

jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
  % display error dialog box and quit
  % ---------------------------------
  errordlg({'An instance of TSGQC is still running !!!', ...
    'Open it from you task bar'}, 'Warning TSGQC');
  return;
% Create and then hide the GUI as it is being constructed.
% --------------------------------------------------------
hMainFig = figure(...
  'Name', 'TSG Validation', ...
  'NumberTitle', 'off', ...
  'Resize', 'on', ...
  'Menubar', 'none', ...
  'Toolbar', 'none', ...
  'UserData', 'ButtonMotionOff', ...
  'WindowButtonMotionFcn', @MouseMotion, ...
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
  'HandleVisibility', handleVisibility,...
  'Visible','on',...
  'Tag','TAG_TSG-QC_GUI',...
  'Units', 'normalized',...
  'Position',guiLimits, ...
  'Color', get( 0, 'DefaultUIControlBackgroundColor' ));
  
%% Check Matlab version for use of KeyPressFcn and KeyReleaseFcn properties
% -------------------------------------------------------------------------
switch ( version('-release') )
  case { '11', '12', '13', '14', '2006a', '2006b' }
    % dont process KeyPressFcn and KeyReleaseFcn events
  otherwise
    
   % show crossline when shitf key is pressed, vertical bar when ctrl key
   % --------------------------------------------------------------------
   set( hMainFig, 'KeyPressFcn',   @keyPressFcnCallback,...
                  'KeyReleaseFcn', @keyReleaseFcnCallback);
end  

%% Initialize tsg structure with tsg_preference function
% -----------------------------------------------------
tsg_preferences(hMainFig, tsgqcname, DEFAULT_PATH_FILE);

% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');

%%  Menu File
%   -----------------------------------------------------------------------
hFileMenu = uimenu(...
  'Parent', hMainFig,...
  'HandleVisibility', handleVisibility,...
  'Label', 'File');
hOpenMenu = uimenu(...
  'Parent', hFileMenu,...
  'Label','Open',...
  'Accelerator','O',...
  'HandleVisibility', handleVisibility,...
  'UserData', 'off',...
  'Callback', @OpenMenuCallback);
hSaveMenu = uimenu(...
  'Parent', hFileMenu,...
  'Label','Save',...
  'Accelerator','S',...
  'Enable', 'off',...
  'UserData', 'off',...
  'HandleVisibility', handleVisibility,...
  'Callback',@SaveMenuCallback);
hExportMenu = uimenu(...
  'Parent', hFileMenu,...
  'Label','Export',...
  'Accelerator','E',...
  'Enable', 'off',...
  'UserData', 'off',...
  'HandleVisibility', handleVisibility);
hExportTSG = uimenu(...
  'Parent', hExportMenu,...
  'Label','Tsg ascii file',...
  'Enable', 'on',...
  'HandleVisibility', handleVisibility,...
  'Callback',@ExportTsgCallback);
Loading
Loading full blame...