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