From 85fd6870e95f3cb07b4292e1cf090ecea97a3ab1 Mon Sep 17 00:00:00 2001 From: Jacques Grelet <jacques.grelet@ird.fr> Date: Mon, 28 Jan 2013 11:29:08 +0000 Subject: [PATCH] add progress bar on .tsgqc file reading use repmat instead of for loop to define format add GOSUD version in menu help/about --- tsg_io/readAsciiTsg.m | 44 +++++++++++++++++++++++++++++++++++------- tsg_util/aboutDialog.m | 4 +++- tsgqc.m | 4 ++-- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/tsg_io/readAsciiTsg.m b/tsg_io/readAsciiTsg.m index 69ec00f..de3d134 100644 --- a/tsg_io/readAsciiTsg.m +++ b/tsg_io/readAsciiTsg.m @@ -14,6 +14,21 @@ function [error] = readAsciiTsg( hMainFig, filename ) % % $Id$ +% use waitbar per default +% ---------------------- +wbool = true; + +% update waitbar title with Tex mode disable +% ------------------------------------------ +if wbool + %set(0,'DefaulttextInterpreter','none') + msg = sprintf('Loading file %s. Please wait...', filename); + wb = waitbar(0, msg); + hchild = get(wb,'children'); + htitle = get(hchild,'title'); + set(htitle,'Interpreter','None'); +end + % Get the data from the application GUI % ------------------------------------- tsg = getappdata( hMainFig, 'tsg_data'); @@ -96,15 +111,12 @@ while ~OK end end -% Builld the format depending on the header parameters +% Build the format depending on the header parameters % 1 - Decimate the HEADER - The 7th first parameters are always % %HEADER YEAR MNTH DAYX hh mm ss % 2 - The 6 Date and time parametes are read in %d % ------------------------------------------------------------- -format = '%d %d %d %d %d %d'; -for i = 7 : nHeader - format = [format ' %f']; -end +format = strcat('%d %d %d %d %d %d', repmat(' %f', 1, nHeader - 6)); % Read the data in a cell % ----------------------- @@ -114,6 +126,18 @@ cellData = textscan( fid, format ); % --------------------------- s = cell2struct(cellData, header, 2); +% get the number of line read +% ---------------------------- +nlines = length(s.YEAR); + +% moves the waitbar cursor +% ------------------------ +for i=1 : nlines + if wbool && (mod(i, 100) == 0) + waitbar( i/nlines, wb); + end +end + clear cellData % Date (y m d h m s) in the first 6 elements in data @@ -142,7 +166,7 @@ for i = 7 : nHeader else tsg.(char(header(i))) = s.(char(header(i))); end - + end % populate tsg.file structure @@ -168,7 +192,7 @@ if (file_ini_id ~= -1) % display information on command window % -------------------------------------- - fprintf('\n...reading %s : ', file_ini); + fprintf('\n...reading %s : %s lines', file_ini, nlines - 1); % Save the data in the application GUI % ------------------------------------ @@ -197,6 +221,12 @@ fclose( fid ); % ------------------------------------ t = toc; fprintf('...done (%6.2f sec).\n\n',t); +% Close waitbar +% ------------- +if wbool + close(wb) +end + % Everything OK % ------------- error = 1; diff --git a/tsg_util/aboutDialog.m b/tsg_util/aboutDialog.m index 10772ba..d0a2e5c 100644 --- a/tsg_util/aboutDialog.m +++ b/tsg_util/aboutDialog.m @@ -65,13 +65,15 @@ hRightPanel = uipanel( ... 'ButtonDownFcn', @quitAboutCallback); % display info in botom panel +msg = sprintf( 'TSGQC Version : %s - GOSUD format: %s', ... + tsg.preference.char_version, tsg.FORMAT_VERSION) uicontrol('Parent', hBottomPanel, ... 'Style','text',... 'FontSize', 14, ... 'Units','normalized',... 'Position',[.1 .1 .9 .5],... 'FontWeight','bold',... - 'String',strcat('TSGQC Version : ', ' ', tsg.preference.char_version),... + 'String', msg,... 'HorizontalAlignment','center'); % display info in right panel diff --git a/tsgqc.m b/tsgqc.m index 23a2592..7359f61 100644 --- a/tsgqc.m +++ b/tsgqc.m @@ -37,8 +37,8 @@ global GOSUD_FORMAT_VERSION % version number, may be used to initialize some files when it change % 0.90x -> 1.0RCx % ------------------------------------------------------------------- -VERSION = 1.3; % -> 1.3 -CHAR_VERSION = '1.3'; +VERSION = 1.301; % -> 1.3 +CHAR_VERSION = '1.301'; % netcdf file version, see DATA FORMAT TSG document: % CORTSG_format_gosud.doc -- GitLab