Skip to content
Snippets Groups Projects
tsgqc.m 116 KiB
Newer Older
      % Pointer set to watch during reading and plotting
      % ------------------------------------------------
      set( hMainFig, 'Pointer', 'watch' );

      % flushes the event queue and updates the closed uiputfile window
      % ---------------------------------------------------------------
      drawnow;

      % write netcdf file
      % -----------------
      error = writeTSGDataNetCDF(hMainFig, strcat(pathName, fileName));

      % Pointer reset to arrow
      % ----------------------
      set( hMainFig, 'Pointer', 'arrow' );

      % Check for NetCDF writing error 
      % must to be rewriting
      % ------------------------------
      if error == -1
        warning('tsgqc:SaveMenuCallback', ...
                'NetCDF writing error: %s %s', pathName, fileName);
        return;
      end

      % update the display
      % ------------------
      set( hInfoFileText, 'String', strcat(tsg.file.name, tsg.file.ext));
      
      % enable Quality Control mode
      % ---------------------------
      hdl_pushtool = findobj('Tag', 'QC');
      set(hdl_pushtool, 'Enable', 'on');
    end

  end

%% ExportTsgCallback
% -------------------------------------------------------------------
% Callback function run when the Export menu item is selected
% -------------------------------------------------------------------
  function ExportTsgCallback(hObject, eventdata)

    % Retrieve named application data
    % -------------------------------
    tsg = getappdata( hMainFig, 'tsg_data');
    
    % Desactivate MouseMotion 'off'
    % ----------------------------
    set( hMainFig, 'WindowButtonMotionFcn', []);
    % Open standard dialog box for saving files
    % -----------------------------------------
    [fileName, pathName, filterindex] = uiputfile('*.tsgqc', ...
                               'Save file name', strcat(tsg.file.name, '.tsgqc'));

    % if user press cancel button, all var are set to zero
    % ----------------------------------------------------
    if filterindex == 0
      return;
    end

    % Pointer set to watch during reading and plotting
    % ------------------------------------------------
    set( hMainFig, 'Pointer', 'watch' );

    % Write a .TSG (ascii)  file
    % --------------------------
    error = writeAsciiTsg(hMainFig, strcat(pathName, fileName));
    % Pointer reset to arrow
    % ----------------------
    set( hMainFig, 'Pointer', 'arrow' );

    % enable Quality Control mode
    % ---------------------------
    hdl_pushtool = findobj('Tag', 'QC');
    set(hdl_pushtool, 'Enable', 'on');
    
    % Set MouseMotion 'on'
    % --------------------
    set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);

    % Check for .TSG writing error - must to be rewriting
    % Because of the 'return' - These line must be at the end
    % --------------------------------------------------------
    if error == -1
      warning('tsgqc:SaveMenuCallback', ...
        'TSG no ouput: %s %s', pathName, fileName);
      return;
    end

  end
%% ExportSampleCallback
% -------------------------------------------------------------------
% Callback function run when the Export menu item is selected
% -------------------------------------------------------------------
  function ExportSampleCallback(hObject, eventdata)

    % Retrieve named application data
    % -------------------------------
    tsg = getappdata( hMainFig, 'tsg_data');
    
    % Desactivate MouseMotion 'off'
    % ----------------------------
    set( hMainFig, 'WindowButtonMotionFcn', []);

    % Open standard dialog box for saving files
    % -----------------------------------------
    [fileName, pathName, filterindex] = uiputfile('*.spl', ...
                               'Save file name', strcat(tsg.file.name, '.spl'));

    % if user press cancel button, all var are set to zero
    % ----------------------------------------------------
    if filterindex == 0
    % Pointer set to watch during reading and plotting
    % ------------------------------------------------
    set( hMainFig, 'Pointer', 'watch' );

    % Write a .SPL (ascii)  file
    % --------------------------
    error = writeAsciiSample(hMainFig, strcat(pathName, fileName));

    % Pointer reset to arrow
    % ----------------------
    set( hMainFig, 'Pointer', 'arrow' );

    % enable Quality Control mode
    % ---------------------------
    hdl_pushtool = findobj('Tag', 'QC');
    set(hdl_pushtool, 'Enable', 'on');
    
    % Set MouseMotion 'on'
    % --------------------
    set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);

    % Check for .TSG writing error - must to be rewriting
    % Because of the 'return' - These line must be at the end
    % --------------------------------------------------------
    if error == -1
      warning('tsgqc:SaveMenuCallback', ...
        'TSG no ouput: %s %s', pathName, fileName);
      return;
    end

  end

%% UndoMenuCallback
  % -----------------------------------------------------------------------
  % Callback function run when the Edit/Undo menu item is selected (Ctrl+Z)
  % -----------------------------------------------------------------------
  function UndoMenuCallback(hObject, eventdata)  
 
    % Undo module not yet implemented
    % -------------------------------
    % msgbox('Undo module not yet implemented', 'modal');
    
    tsg.queue = undo(tsg.queue);
    tsg.SSPS_QC = get(tsg.queue);
   
    % Make the Salinity, temperature and velocity plot
    % ------------------------------------------------
    plot_SalTempVel( hMainFig, hPlotAxes );

  end

%% RedoMenuCallback
  % -----------------------------------------------------------------------
  % Callback function run when the Edit/Redo menu item is selected (Ctrl+R)
  % -----------------------------------------------------------------------
  function RedoMenuCallback(hObject, eventdata)  
 
    % Redo module not yet implemented
    % -------------------------------
    msgbox('Redo module not yet implemented', 'modal');
    
  end

%% QuitMapCallback
  % -----------------------------------------------------------------
  % Callback function run when the Quit Map Figure item is selected
  % -----------------------------------------------------------------
  function QuitMapCallback(hObject, eventdata)  
   
    % Make the earth map invisible
    % ----------------------------
    set(hMapPanel, 'Visible', 'off' ); 
    set(hMapToggletool, 'state',  'off' );
%% QuitMenuCallback
  % -----------------------------------------------------------------
  % Callback function run when the Quit menu item is selected
  % -----------------------------------------------------------------
  function QuitMenuCallback(hObject, eventdata)  

    % save config mat file in prefdir
    % -------------------------------
    config_file = [prefdir, filesep, tsgqcname, '.mat'];

    % set tsg.levitus empty before save preferences in mat file
    % ---------------------------------------------------------
    tsg.levitus = [];

    % save preference mat file
    % ------------------------
    save( config_file, 'tsg');

    % 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;
             
      end
      
      % quit program
      % ------------
      quitProgram(hMainFig, hMapPanel, DEFAULT_PATH_FILE);
      
    else
      selection = ...
        questdlg(['Quit ' get(hMainFig, 'Name') '?'],...
        ['Quit ' get(hMainFig, 'Name') '?'],...
        'Yes', 'No', 'Yes');
      if strcmp(selection, 'No')
        return;
      else
        quitProgram(hMainFig, hMapPanel, DEFAULT_PATH_FILE);
% ----------------
end