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

When the sensor to control the flow-meter is connected to ad1, and

present in lbv file, we add the parameter as selected by default
fix #15
parent b40b75ec
No related branches found
No related tags found
No related merge requests found
File deleted
...@@ -50,14 +50,25 @@ YBorder = 1; ...@@ -50,14 +50,25 @@ YBorder = 1;
% Pre-selected parameter % Pre-selected parameter
% ---------------------- % ----------------------
selectedPara = { 'date';'time';'temp';'sal';'cond';'raw';'lat';'lon';'ad1' }; selectedPara = { 'date';'time';'temp';'sal';'cond';'raw';'lat';'lon' };
nSelectedPara = length( selectedPara ); nSelectedPara = length( selectedPara );
% when the sensor to control the flowmeter is connected to ad1, and
% present in lbv file, we add the parameter as selected by default
% -----------------------------------------------------------------
c = strfind( header, 'ad1' );
for i = 1:nHeader
if ~isempty(c{i})
selectedPara = { 'date';'time';'temp';'sal';'cond';'raw';'lat';'lon';'ad1' };
nSelectedPara = length( selectedPara );
end
end
% Get the order number of pre-selected parameter % Get the order number of pre-selected parameter
% ---------------------------------------------- % ----------------------------------------------
for i = 1:nSelectedPara for i = 1:nSelectedPara
x = strfind( header, char(selectedPara(i)) ); x = strfind( header, char(selectedPara(i)) );
% Look for the first not-empty cell % Look for the first not-empty cell
% --------------------------------- % ---------------------------------
for j = 1:nHeader for j = 1:nHeader
...@@ -73,31 +84,31 @@ end ...@@ -73,31 +84,31 @@ end
% ------------------------------------------------------------------- % -------------------------------------------------------------------
figWidth = 2*screenSize(3); figWidth = 2*screenSize(3);
while figWidth > screenSize(3) && fontsize > minFontsize while figWidth > screenSize(3) && fontsize > minFontsize
% Determine the max size of the UIcontrol % Determine the max size of the UIcontrol
% ---------------------------------------- % ----------------------------------------
hf = figure('Visible', 'off', 'Position', screenSize); hf = figure('Visible', 'off', 'Position', screenSize);
for ipar = nHeader : -1 : 1 for ipar = nHeader : -1 : 1
h = uicontrol( 'Parent', hf, 'Style', 'checkbox', 'String', header(ipar), ... h = uicontrol( 'Parent', hf, 'Style', 'checkbox', 'String', header(ipar), ...
'Fontsize', fontsize, 'Units', 'centimeters', 'visible', 'off'); 'Fontsize', fontsize, 'Units', 'centimeters', 'visible', 'off');
% Get the dimension of the string in the Uicontrol % Get the dimension of the string in the Uicontrol
% ------------------------------------------------ % ------------------------------------------------
extent = get(h, 'extent'); extent = get(h, 'extent');
cbWidth(ipar) = extent(3); cbWidth(ipar) = extent(3);
cbHeight(ipar) = extent(4); cbHeight(ipar) = extent(4);
delete( h ) delete( h )
end end
delete( hf ) delete( hf )
% Checkboxes dimension - + 0.5 : size of the checkbox % Checkboxes dimension - + 0.5 : size of the checkbox
% --------------------------------------------------- % ---------------------------------------------------
cbWidth = max(cbWidth) + .5; cbWidth = max(cbWidth) + .5;
cbHeight = max(cbHeight); cbHeight = max(cbHeight);
cbYinterval = .1; cbYinterval = .1;
% Compute figure height using the number of UIcontrol + % Compute figure height using the number of UIcontrol +
% the height of some pushbutton + the border height % the height of some pushbutton + the border height
% ----------------------------------------------------- % -----------------------------------------------------
...@@ -107,15 +118,15 @@ while figWidth > screenSize(3) && fontsize > minFontsize ...@@ -107,15 +118,15 @@ while figWidth > screenSize(3) && fontsize > minFontsize
nbCol = nbCol + 1; nbCol = nbCol + 1;
nbLine = floor( nHeader / nbCol ); nbLine = floor( nHeader / nbCol );
figHeight = (cbYinterval + pbHeight) + ... figHeight = (cbYinterval + pbHeight) + ...
cbHeight*nbLine + cbYinterval*(nbLine+1) + YBorder*2; cbHeight*nbLine + cbYinterval*(nbLine+1) + YBorder*2;
end end
% Compute figure height using the number of UIcontrol + % Compute figure height using the number of UIcontrol +
% the height of some pushbutton % the height of some pushbutton
% --------------------------------------------------- % ---------------------------------------------------
figHeight = (cbYinterval + pbHeight) + ... figHeight = (cbYinterval + pbHeight) + ...
cbHeight*nbLine + cbYinterval*(nbLine+1); cbHeight*nbLine + cbYinterval*(nbLine+1);
% Compute figure width using the number of UIcontrol + % Compute figure width using the number of UIcontrol +
% border width % border width
% --------------------------------------------------- % ---------------------------------------------------
...@@ -148,7 +159,7 @@ hParamFig = figure(... ...@@ -148,7 +159,7 @@ hParamFig = figure(...
'Units', 'centimeters',... 'Units', 'centimeters',...
'Position',[XBorder, YBorder, figWidth, figHeight], ... 'Position',[XBorder, YBorder, figWidth, figHeight], ...
'Color', get(0, 'DefaultUIControlBackgroundColor')); 'Color', get(0, 'DefaultUIControlBackgroundColor'));
% 'WindowStyle', 'modal', ... % 'WindowStyle', 'modal', ...
% Iterate from each element % Iterate from each element
% ------------------------- % -------------------------
...@@ -159,13 +170,13 @@ for i = 1 : nbCol ...@@ -159,13 +170,13 @@ for i = 1 : nbCol
% Set the upper UIcontrol first % Set the upper UIcontrol first
% ----------------------------- % -----------------------------
y_bottom = (pbHeight + cbYinterval) + ... y_bottom = (pbHeight + cbYinterval) + ...
cbHeight*(nbLine-1) + cbYinterval*(nbLine); cbHeight*(nbLine-1) + cbYinterval*(nbLine);
for j = 1 : nbLine for j = 1 : nbLine
if ipar > nHeader if ipar > nHeader
break; break;
end end
% display dynamically uicontrol % display dynamically uicontrol
% ----------------------------- % -----------------------------
ui(ipar) = uicontrol(... ui(ipar) = uicontrol(...
...@@ -178,10 +189,10 @@ for i = 1 : nbCol ...@@ -178,10 +189,10 @@ for i = 1 : nbCol
'HandleVisibility', 'on',... 'HandleVisibility', 'on',...
'Units', 'centimeters', ... 'Units', 'centimeters', ...
'Position', [x_left y_bottom cbWidth cbHeight ]); 'Position', [x_left y_bottom cbWidth cbHeight ]);
y_bottom = y_bottom - cbHeight - cbYinterval; y_bottom = y_bottom - cbHeight - cbYinterval;
ipar = ipar + 1; ipar = ipar + 1;
end end
x_left = x_left + cbWidth; x_left = x_left + cbWidth;
end end
...@@ -223,11 +234,11 @@ uiwait(hParamFig); ...@@ -223,11 +234,11 @@ uiwait(hParamFig);
%% Nested callback %% Nested callback
% ----------------------------------------------------------------------- % -----------------------------------------------------------------------
% Continue action, get uicontrol fields and populate tsg structure % Continue action, get uicontrol fields and populate tsg structure
% ----------------------------------------------------------------------- % -----------------------------------------------------------------------
function continueCallback(obj, event) function continueCallback(obj, event)
% Everything's ok % Everything's ok
% --------------- % ---------------
error = 1; error = 1;
...@@ -237,10 +248,10 @@ uiwait(hParamFig); ...@@ -237,10 +248,10 @@ uiwait(hParamFig);
for i = 1 : nHeader for i = 1 : nHeader
indSelectedHeader(i) = get( ui(i), 'value'); indSelectedHeader(i) = get( ui(i), 'value');
end end
for i = 1 : nSelectedPara for i = 1 : nSelectedPara
x = strfind( header(indSelectedHeader == 1), char(selectedPara(i)) ); x = strfind( header(indSelectedHeader == 1), char(selectedPara(i)) );
% Look for the first not-empty cell % Look for the first not-empty cell
% --------------------------------- % ---------------------------------
n = 0; n = 0;
...@@ -251,30 +262,30 @@ uiwait(hParamFig); ...@@ -251,30 +262,30 @@ uiwait(hParamFig);
end end
switch n switch n
case 0 case 0
% Select automatically COND and RAW % Select automatically COND and RAW
% --------------------------------- % ---------------------------------
if strcmp( char(selectedPara(i)), 'cond' ) || ... if strcmp( char(selectedPara(i)), 'cond' ) || ...
strcmp( char(selectedPara(i)), 'raw' ) strcmp( char(selectedPara(i)), 'raw' )
x = strfind( header, char(selectedPara(i)) ); x = strfind( header, char(selectedPara(i)) );
for j = 1:length(x) for j = 1:length(x)
if ~isempty(x{j}) if ~isempty(x{j})
indSelectedHeader(j) = 1; indSelectedHeader(j) = 1;
set( ui(j), 'value', 1 ); set( ui(j), 'value', 1 );
end end
end end
else else
msgbox( ['Choose a ' char(selectedPara(i))], 'modal' ); msgbox( ['Choose a ' char(selectedPara(i))], 'modal' );
error = -1; error = -1;
break; break;
end end
case 1 case 1
continue continue
...@@ -282,10 +293,10 @@ uiwait(hParamFig); ...@@ -282,10 +293,10 @@ uiwait(hParamFig);
msgbox( ['Choose only ONE ' char(selectedPara(i))], 'modal' ); msgbox( ['Choose only ONE ' char(selectedPara(i))], 'modal' );
error = -1; error = -1;
break; break;
end end
end end
% If everything'ok. Close the GUI % If everything'ok. Close the GUI
% ------------------------------- % -------------------------------
if error == 1 if error == 1
...@@ -297,26 +308,26 @@ uiwait(hParamFig); ...@@ -297,26 +308,26 @@ uiwait(hParamFig);
% close windows (replace call to uiresume(hParamFig)) % close windows (replace call to uiresume(hParamFig))
% ---------------------------------------------------- % ----------------------------------------------------
close(hParamFig); close(hParamFig);
% flushes the event queue and updates the figure window % flushes the event queue and updates the figure window
% ----------------------------------------------------- % -----------------------------------------------------
drawnow; drawnow;
% return % return
end end
end end
% ----------------------------------------------------------------------- % -----------------------------------------------------------------------
% Cancel button, no action % Cancel button, no action
% ----------------------------------------------------------------------- % -----------------------------------------------------------------------
function cancelCallback(obj, event) function cancelCallback(obj, event)
% return error code (no change) % return error code (no change)
% ----------------------------- % -----------------------------
error = -1; error = -1;
% close windows % close windows
% ------------- % -------------
close(hParamFig); close(hParamFig);
...@@ -325,6 +336,6 @@ uiwait(hParamFig); ...@@ -325,6 +336,6 @@ uiwait(hParamFig);
% ----------------------------------------------------- % -----------------------------------------------------
drawnow; drawnow;
% return % return
end end
end end
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