Newer
Older
case -1
msgbox( 'Date limits are not correct',...
'Correction module', 'warn', 'modal');
end
end
%% InterpOtherCallback ...............................Interpolation OTher
%----------------------------------------------------------------------
% Callback function run when
%----------------------------------------------------------------------
function InterpPosOtherCallback( src, evnt)
msgbox( 'Method not yet implemented', ...
'Function InterpOtherCallback', ...
'warn',...
'modal' );
end
%% InterpPosCancelCallback ..........................Cancel Interpolation
%----------------------------------------------------------------------
function InterpPosCancelCallback(src, evnt)
% Get tsg application data
% ------------------------
tsg = getappdata( hMainFig, 'tsg_data' );
% Get NO_CONTROL and INTERPOLATED_VALUE codes
% -------------------------------------------

jacques.grelet_ird.fr
committed
NO_CONTROL = tsg.qc.hash.NO_CONTROL.code;
INTERPOLATED_VALUE = tsg.qc.hash.INTERPOLATED_VALUE.code;
if ~isempty( tsg.POSITION_QC )
iINTERP = find( tsg.POSITION_QC == INTERPOLATED_VALUE);
tsg.LATX( iINTERP ) = NaN * ones( size( iINTERP), 1 );
tsg.LONX( iINTERP ) = NaN * ones( size( iINTERP), 1 );
tsg.POSITION_QC = [];
end
% Save tsg application data
% --------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Refresh plots
% -------------
plot_Interpolation( hMainFig, hPlotAxes, 1 );
plot_Interpolation( hMainFig, hPlotAxes, 2 );
plot_Interpolation( hMainFig, hPlotAxes, 3 );
end
%% Cal_OnMenuCallback ..................................... Calibration
%----------------------------------------------------------------------
% Callback function run when
%----------------------------------------------------------------------
function Cal_OnMenuCallback( src, evnt)
% Activate or desactivate uipanels
% --------------------------------
set( hpCalCoef, 'Visible', 'on' );
set( hbgParameter, 'Visible', 'off');
set( hbgQc, 'Visible', 'off');
% Pushbutton
% ----------
set( hQCToggletool, 'enable', 'off' );
set( hClimToggletool, 'enable', 'off', 'state', 'off' );
set( hBottleToggletool, 'enable', 'off' );
set( hInterpToggletool, 'enable', 'off' );
set( hHeaderPushtool, 'enable', 'off' );
set( hPanToggletool, 'state', 'off', 'enable', 'on' );
set( hTimelimitToggletool, 'state', 'off', 'enable', 'off' );
set( hZoomInToggletool, 'state', 'off', 'enable', 'on' );
set( hZoomOutToggletool, 'state', 'off', 'enable', 'on' );
% Get tsg application data
% ------------------------
tsg = getappdata( hMainFig, 'tsg_data' );
% -----------------------------------------
plot_Calibration( hMainFig, hPlotAxes, 1, 'SSPS' );
plot_Calibration( hMainFig, hPlotAxes, 2, 'SSJT' );
plot_Calibration( hMainFig, hPlotAxes, 3, 'SSTP' );

jacques.grelet_ird.fr
committed
% find SLOPE (A) and OFFSET (B) indices in _LINCOEF_CONV array
% ------------------------------------------------------------
A_CNDC = strmatch('SLOPE', tsg.CNDC_LINCOEF_CONV);
B_CNDC = strmatch('OFFSET',tsg.CNDC_LINCOEF_CONV);
A_SSJT = strmatch('SLOPE', tsg.SSJT_LINCOEF_CONV);
B_SSJT = strmatch('OFFSET',tsg.SSJT_LINCOEF_CONV);
A_SSTP = strmatch('SLOPE', tsg.SSTP_LINCOEF_CONV);
B_SSTP = strmatch('OFFSET',tsg.SSTP_LINCOEF_CONV);
% Write the Cal Coef in the Editable uicontrol
% --------------------------------------------

jacques.grelet_ird.fr
committed
set( hetCalCNDCSlope, 'String', num2str(tsg.CNDC_LINCOEF(A_CNDC)));
set( hetCalCNDCOffset, 'String', num2str(tsg.CNDC_LINCOEF(B_CNDC)));

jacques.grelet_ird.fr
committed
set( hetCalSSJTSlope, 'String', num2str(tsg.SSJT_LINCOEF(A_SSJT)));
set( hetCalSSJTOffset, 'String', num2str(tsg.SSJT_LINCOEF(B_SSJT)));
set( hetCalSSTPSlope, 'String', num2str(tsg.SSTP_LINCOEF(A_SSTP)));
set( hetCalSSTPOffset, 'String', num2str(tsg.SSTP_LINCOEF(B_SSTP)));
% Intermediate variables
% ----------------------

jacques.grelet_ird.fr
committed
tsg.CNDC_LINCOEF_NEW(A_CNDC) = str2num(get( hetCalCNDCSlope, 'String'));
tsg.CNDC_LINCOEF_NEW(B_CNDC) = str2num(get( hetCalCNDCOffset, 'String'));
tsg.SSJT_LINCOEF_NEW(A_SSJT) = str2num(get( hetCalSSJTSlope, 'String'));
tsg.SSJT_LINCOEF_NEW(B_SSJT) = str2num(get( hetCalSSJTOffset, 'String'));
tsg.SSTP_LINCOEF_NEW(A_SSTP) = str2num(get( hetCalSSTPSlope, 'String'));
tsg.SSTP_LINCOEF_NEW(B_SSTP) = str2num(get( hetCalSSTPOffset, 'String'));
% Save tsg application data
% --------------------------
setappdata( hMainFig, 'tsg_data', tsg );
end
%% Cal_OffMenuCallback ..................................... Calibration
%----------------------------------------------------------------------
% Callback function run when
%----------------------------------------------------------------------
function Cal_OffMenuCallback( src, evnt)
% Activate or desactivate uipanels
% --------------------------------
set( hpCalCoef, 'Visible', 'off' );
set( hbgParameter, 'Visible', 'on');
% Enable Pushbuttons
% ------------------
set( hClimToggletool, 'enable', 'on' );
set( hBottleToggletool, 'enable', 'on' );
set( hInterpToggletool, 'enable', 'on' );
set( hHeaderPushtool, 'enable', 'on' );
set( hQCToggletool, 'state', 'off', 'enable', 'on' );
set( hPanToggletool, 'state', 'off', 'enable', 'on' );
set( hTimelimitToggletool, 'state', 'off', 'enable', 'on' );
set( hZoomInToggletool, 'state', 'off', 'enable', 'on' );
set( hZoomOutToggletool, 'state', 'off', 'enable', 'on' );
% Get tsg application data
% ------------------------
tsg = getappdata( hMainFig, 'tsg_data' );

jacques.grelet_ird.fr
committed
% find SLOPE (A) and OFFSET (B) indices in _LINCOEF_CONV array
% ------------------------------------------------------------
A_CNDC = strmatch('SLOPE', tsg.CNDC_LINCOEF_CONV);
B_CNDC = strmatch('OFFSET',tsg.CNDC_LINCOEF_CONV);
A_SSJT = strmatch('SLOPE', tsg.SSJT_LINCOEF_CONV);
B_SSJT = strmatch('OFFSET',tsg.SSJT_LINCOEF_CONV);
A_SSTP = strmatch('SLOPE', tsg.SSTP_LINCOEF_CONV);
B_SSTP = strmatch('OFFSET',tsg.SSTP_LINCOEF_CONV);
% Save the calibration coefficient
% --------------------------------

jacques.grelet_ird.fr
committed
tsg.CNDC_LINCOEF(A_CNDC) = tsg.CNDC_LINCOEF_NEW(A_CNDC);
tsg.CNDC_LINCOEF(B_CNDC) = tsg.CNDC_LINCOEF_NEW(B_CNDC);
tsg.SSJT_LINCOEF(A_SSJT) = tsg.SSJT_LINCOEF_NEW(A_SSJT);
tsg.SSJT_LINCOEF(B_SSJT) = tsg.SSJT_LINCOEF_NEW(B_SSJT);
tsg.SSTP_LINCOEF(A_SSTP) = tsg.SSTP_LINCOEF_NEW(A_SSTP);
tsg.SSTP_LINCOEF(B_SSTP) = tsg.SSTP_LINCOEF_NEW(B_SSTP);
tsg.CNDC_LINCOEF_NEW = [];
tsg.SSJT_LINCOEF_NEW = [];
tsg.SSTP_LINCOEF_NEW = [];
% Save tsg application data
% --------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% -----------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1, tsg.plot.parameter{1} );
plot_Validation( hMainFig, hPlotAxes, 2, tsg.plot.parameter{2} );
plot_Validation( hMainFig, hPlotAxes, 3, tsg.plot.parameter{3} );
end
%% CalibrateCallback .......................................... Calibration
function CalibrateCallback(src, evnt)
% Get tsg application data
% ------------------------
tsg = getappdata( hMainFig, 'tsg_data' );

jacques.grelet_ird.fr
committed
% find SLOPE (A) and OFFSET (B) indices in _LINCOEF_CONV array
% ------------------------------------------------------------
A_CNDC = strmatch('SLOPE', tsg.CNDC_LINCOEF_CONV);
B_CNDC = strmatch('OFFSET',tsg.CNDC_LINCOEF_CONV);
A_SSJT = strmatch('SLOPE', tsg.SSJT_LINCOEF_CONV);
B_SSJT = strmatch('OFFSET',tsg.SSJT_LINCOEF_CONV);
A_SSTP = strmatch('SLOPE', tsg.SSTP_LINCOEF_CONV);
B_SSTP = strmatch('OFFSET',tsg.SSTP_LINCOEF_CONV);
% They will be used in the function calibration
% ---------------------------------------------

jacques.grelet_ird.fr
committed
tsg.CNDC_LINCOEF_NEW(A_CNDC) = str2num(get( hetCalCNDCSlope, 'String'));
tsg.CNDC_LINCOEF_NEW(B_CNDC) = str2num(get( hetCalCNDCOffset, 'String'));
tsg.SSJT_LINCOEF_NEW(A_SSJT) = str2num(get( hetCalSSJTSlope, 'String'));
tsg.SSJT_LINCOEF_NEW(B_SSJT) = str2num(get( hetCalSSJTOffset, 'String'));
tsg.SSTP_LINCOEF_NEW(A_SSTP) = str2num(get( hetCalSSTPSlope, 'String'));
tsg.SSTP_LINCOEF_NEW(B_SSTP) = str2num(get( hetCalSSTPOffset, 'String'));
% Save tsg application data
% --------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Calibrate the sensors
% ---------------------
calibration( hMainFig );
% Update the Adjusted variables (SSPS - SSJT) with calibrated records
% -------------------------------------------------------------------
% Refresh plot #1
% ---------------
plot_Calibration( hMainFig, hPlotAxes, 1, 'SSPS' );
plot_Calibration( hMainFig, hPlotAxes, 2, 'SSJT' );
plot_Calibration( hMainFig, hPlotAxes, 3, 'SSTP' );
% As soon as a modification took place the data should be saved
% -------------------------------------------------------------
set( hSaveMenu, 'UserData', 'on' );
end
%% CancelCalibrationCallback .................................. Calibration
function CancelCalibrationCallback(src, evnt)
% Get tsg application data
% ------------------------
tsg = getappdata( hMainFig, 'tsg_data' );
% Emptied the CAL variables
% -------------------------
tsg.CNDC_CAL = [];
tsg.SSPS_CAL = [];
tsg.SSJT_CAL = [];
tsg.SSTP_CAL = [];
% Save tsg application data
% --------------------------
setappdata( hMainFig, 'tsg_data', tsg );

jacques.grelet_ird.fr
committed
% find SLOPE (A) and OFFSET (B) indices in _LINCOEF_CONV array
% ------------------------------------------------------------
A_CNDC = strmatch('SLOPE', tsg.CNDC_LINCOEF_CONV);
B_CNDC = strmatch('OFFSET',tsg.CNDC_LINCOEF_CONV);
A_SSJT = strmatch('SLOPE', tsg.SSJT_LINCOEF_CONV);
B_SSJT = strmatch('OFFSET',tsg.SSJT_LINCOEF_CONV);
A_SSTP = strmatch('SLOPE', tsg.SSTP_LINCOEF_CONV);
B_SSTP = strmatch('OFFSET',tsg.SSTP_LINCOEF_CONV);
% Write the Cal Coef in the Editable uicontrol
% --------------------------------------------

jacques.grelet_ird.fr
committed
set( hetCalCNDCSlope, 'String', num2str(tsg.CNDC_LINCOEF(A_CNDC)));
set( hetCalCNDCOffset, 'String', num2str(tsg.CNDC_LINCOEF(B_CNDC)));
set( hetCalSSJTSlope, 'String', num2str(tsg.SSJT_LINCOEF(A_SSJT)));
set( hetCalSSJTOffset, 'String', num2str(tsg.SSJT_LINCOEF(B_SSJT)));
set( hetCalSSTPSlope, 'String', num2str(tsg.SSTP_LINCOEF(A_SSTP)));
set( hetCalSSTPOffset, 'String', num2str(tsg.SSTP_LINCOEF(B_SSTP)));
% Refresh plot #1
% ---------------
plot_Calibration( hMainFig, hPlotAxes, 1, 'SSPS' );
plot_Calibration( hMainFig, hPlotAxes, 2, 'SSJT' );
plot_Calibration( hMainFig, hPlotAxes, 3, 'SSTP' );
% As soon as a modification took place the data should be saved
% -------------------------------------------------------------
set( hSaveMenu, 'UserData', 'on' );
%% ZoomIn_OnMenuCallback
%----------------------------------------------------------------------
% Callback function run when the toolbar zoom in (increase) push button
% is pressed
%----------------------------------------------------------------------
function ZoomIn_OnMenuCallback(src, evnt)
% Desactivate some toggle buttons, hZoomOutToggletool changed state
% must be call before zoom function because the callback set zoom to
% off
% -------------------------------------------------------------------
set( hZoomOutToggletool, 'state', 'off' );
set( hQCToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
set( hTimelimitToggletool, 'state', 'off' );
% returns a zoom mode object for the figure hMainFig handle
% ---------------------------------------------------------
% Set the UI Context Menu to the custom menu
% -----------------------------------------
set(hZoom, 'UIContextMenu', zoom_context_menu)
% Turns off the automatic adaptation of date ticks
% ------------------------------------------------
zoomAdaptiveDateTicks('off');
% turns interactive zooming to in (increase)
% ------------------------------------------
set(hZoom, 'direction', 'in');
% --------------------------------------------------
% hMapZoom = zoom(hMapFig);
% setAllowAxesZoom(hMapZoom, hPlotAxes(4), true);
% set(hMapZoom, 'enable', 'on');
% turns on interactive zooming (same effect than zoom on) but prevent
% side effect on another figure
% -------------------------------------------------------------------
set(hZoom, 'enable', 'on');
% Set this callback to listen to when a zoom operation finishes
% must be call after enable zoom (bug ?)
% -------------------------------------------------------------
set(hZoom, 'ActionPostCallback', @ZoomPan_PostCallback);
% Set map with border and save tsg
% --------------------------------
%tsg.preference.map.border = 0;
setappdata( hMainFig, 'tsg_data', tsg );
end
%% ZoomIn_OffMenuCallback
%----------------------------------------------------------------------
% Callback function run when the toolbar zoom in (increase) push button
% is pressed
%----------------------------------------------------------------------
function ZoomIn_OffMenuCallback(src, evnt)
% disable zoom mode
% -----------------
zoom('off');
end
%% ZoomOut_OnMenuCallback
%------------------------------------------------------------------------
% Callback function run when the toolbar zoom out (descrease) push button
% is pressed
%------------------------------------------------------------------------
function ZoomOut_OnMenuCallback(src, evnt)
% Desactivate Zoom In Toggle toggle button
% -----------------------------------------
set( hZoomInToggletool, 'state', 'off' );
set( hQCToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
set( hTimelimitToggletool, 'state', 'off' );
% returns a zoom mode object for the figure hMainFig handle
% ---------------------------------------------------------
hZoom = zoom(hMainFig);
% Set the UI Context Menu to the custom menu
% -----------------------------------------
set(hZoom, 'UIContextMenu', zoom_context_menu)
% turns interactive zooming out (decrease)
% ----------------------------------------
set(hZoom, 'direction', 'out');
% Disallows a zoom operation on the MAP axes objects
% --------------------------------------------------
% turns on interactive zooming (same effect than zoom on) but prevent
% side effect on another figure
% -------------------------------------------------------------------
set(hZoom, 'enable', 'on');
% Set this callback to listen to when a zoom operation finishes
% -------------------------------------------------------------
set(hZoom, 'ActionPostCallback', @ZoomPan_PostCallback);
end
%% ZoomOut_OffMenuCallback
%------------------------------------------------------------------------
% Callback function run when the toolbar zoom out (descrease) push button
% is pressed
%------------------------------------------------------------------------
function ZoomOut_OffMenuCallback(src, evnt)
% turns interactive zooming off
% -----------------------------
zoom off;
% cursor back to normal, test if it's really necessery
% -----------------------------------------------------
% set(hMainFig, 'Pointer', 'arrow');
% Desactivate Zoom Out Toggle toggle button
% -----------------------------------------
set( hZoomOutToggletool, 'state', 'off' );
% callback function run from context menu from right clic in zoom mode
% --------------------------------------------------------------------
function zoom_reset_callback(src, evnt)
% restore map border to its preference setting for next map plotting
% call by ZoomPan_PostCallback
% ------------------------------------------------------------------
tsg.preference.map.border = ...
str2double(tsg.preference.map.border_string(tsg.preference.map.border_value));
setappdata( hMainFig, 'tsg_data', tsg );
% returns the plot to its initial zoom setting and desactivate zoom
% -----------------------------------------------------------------
hZoom = zoom(hMainFig);
% zoom off doesn't work
set(hZoom, 'enable', 'off');
% Desactivate Zoom In/Out Toggle toggle button
% -----------------------------------------
set( hZoomInToggletool, 'state', 'off' );
set( hZoomOutToggletool, 'state', 'off' );
end
% callback function run from context menu from right clic in zoom mode
% --------------------------------------------------------------------
function zoom_out_callback(src, evnt)
% zoom out by the specified zoom factor 0.5
% ------------------------------------------
zoom(0.5);
end
%----------------------------------------------------------------------
% Callback function run when the pan toggle toolbar is selected
%----------------------------------------------------------------------
function Pan_OnMenuCallback(src, evnt)
% Desactivate some toggle buttons
% -------------------------------
set( hQCToggletool, 'state', 'off' );
set( hTimelimitToggletool, 'state', 'off' );
set( hZoomInToggletool, 'state', 'off' );
set( hZoomOutToggletool, 'state', 'off' );
% Hide the map. Otherwise it slows down the panning
% -------------------------------------------------
% Returns a pan mode object for the figure handle
% -----------------------------------------------
hPan = pan(hMainFig);
% Disallows a pan operation on the MAP axes objects
% --------------------------------------------------
% turns on interactive pan (same effect than pan on) but prevent
% side effect on another figure
% --------------------------------------------------------------
set(hPan, 'enable', 'on');
% Set this callback to listen to when a zoom operation finishes
% must be call after enable zoom (bug ?)
% -------------------------------------------------------------
set(hPan, 'ActionPostCallback', @ZoomPan_PostCallback);
%----------------------------------------------------------------------
% Callback function run when the pan toggle toolbar is released
%----------------------------------------------------------------------
function Pan_OffMenuCallback(src, evnt)
% turns interactive pan off
% -------------------------
pan off;
% cursor back to normal, test if it's really necessery
% -----------------------------------------------------
%set(hMainFig, 'Pointer', 'arrow');
end
%% ZoomPan_PostCallback
%------------------------------------------------------------------------
% Callback function run when zoom or pan action finishes: redraw axes
%------------------------------------------------------------------------
function ZoomPan_PostCallback(src, evnt)
% Set the right limit and interval to the 3 axes
% ----------------------------------------------
for iaxe = 1:3
set(hPlotAxes(iaxe), 'XTickMode', 'auto')
datetick(hPlotAxes(iaxe), 'x', 'keeplimits')
end
% ----------------------------------------
if strcmp( get(hMapFig,'visible'), 'on') == 1
erase_Line( hPlotAxes, 4 );
plot_map( hMainFig, hPlotAxes);
end
Yves Gouriou
committed
%% QCMenuCallback
%----------------------------------------------------------------------
% Callback function run when the Automatic QC menu item is selected
%
% Si vous modiifer ce CallBack verifier les modifications a apporter a
% 1 - preferenceForm.m
% 2 - tsg_preference.m
%----------------------------------------------------------------------
function QCMenuCallback(src, evnt, test)
Yves Gouriou
committed
switch test
case 'Speed'
minSpeedQC(hMainFig)
case 'Flow'
minFlowQC(hMainFig)
case 'Press'
minPressQC(hMainFig)
case 'SSPSmin'
minSSPSQC(hMainFig)
case 'SSPSmax'
maxSSPSQC(hMainFig)
case 'SSJTmin'
minSSJTQC(hMainFig)
case 'SSJTmax'
maxSSJTQC(hMainFig)
Yves Gouriou
committed
case 'SSTPmin'
minSSTPQC(hMainFig)
case 'SSTPmax'
maxSSTPQC(hMainFig)
otherwise
msgbox('QCMenuCallback : erreur', 'QCMenuCallback','error', 'modal');
end
Yves Gouriou
committed
% --------------------------
% refresh QC statistic panel
% --------------------------
display_QC( hMainFig );
Yves Gouriou
committed
% ------------------
% Refresh the plots
%-------------------
% Get the parameter displayed on plot number 1 : figure at the top
% -----------------------------------------------------------------
PARA = getParaCorModule( hMainFig );
Yves Gouriou
committed
% Draw plot 1
% -----------
plot_Validation( hMainFig, hPlotAxes, 1, PARA{1} );
Yves Gouriou
committed
% Update the map if already displayed
% -----------------------------------
if strcmp( get(hMapFig,'visible'), 'on') == 1
erase_Line( hPlotAxes, 4 );
plot_map( hMainFig, hPlotAxes);
end
% enable Undo menu if QC flags applied
% ------------------------------------
if (tsg.qc_history_pointer > 0)
set(findobj('tag','UIMENU_UNDO'),'enable','on');
end
Yves Gouriou
committed
end
%% QC_OnMenuCallback ............................... Quality Control Module
%----------------------------------------------------------------------
% Callback function run when the QC toggle tool is pressed
%----------------------------------------------------------------------
function QC_OnMenuCallback(src, evnt)
% Make the QC code uipanel visible
% --------------------------------
set( hbgQc, 'Visible' ,'on');
set( hDuplicateQcPanel, 'Visible', 'on');
set( hbgParameter, 'Visible', 'off');
% Desactivate toggletools.
% ------------------------
set( hZoomInToggletool, 'state', 'off', 'enable', 'on' );
set( hZoomOutToggletool, 'state', 'off', 'enable', 'on' );
set( hPanToggletool, 'state', 'off' );
set( hTimelimitToggletool, 'state', 'off' );
set( hCalToggletool, 'state', 'off', 'enable', 'off' );
set( hInterpToggletool, 'state', 'off', 'enable', 'off' );
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
PARA = getParaCorModule( hMainFig );
% refresh QC statistic panel
% --------------------------
display_QC( hMainFig );
% Activate right clic context menu on first axes
% ---------------------------------------------------------
set(hPlotAxes(1),'UIContextMenu', hQcCmenu);
% Activate clic mouse menu on first axes for next rbbox
% ----------------------------------------------------------------
set(hPlotAxes(1),'ButtonDownFcn', @QC_SelectCallback);
% change cursor to crosshair aspect
% ---------------------------------
set( hMainFig, 'Pointer', 'crosshair');
% -------------------------------------------------------------
% nested function on mouse clic when QC toggle tool is selected
% -------------------------------------------------------------
function QC_SelectCallback(src, evnt)
% disable zoom by default in QC mode
try
zoom(hMainFig, 'off');
catch
end
% disable ButtonMotion on main fig during select
% prevent drawing to map
% ----------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', []);
% Selection of the data within the figure
% ---------------------------------------
point1 = get(src,'CurrentPoint'); % button down detected
rbbox; % Create rubberband box for area selection
point1 = point1(1,1:2); % extract x and y
point2 = point2(1,1:2);
p1 = min(point1,point2);
p2 = max(point1,point2); % calculate locations
% The following code is only executed if the left mouse button is clicked.
% If the right mouse button is clicked, this code must not be
% executed as the variable 'ind' will be emptied. And this variable
% is used when the context menu (callback 'QC_ContextMenuCallback') is called
% -----------------------------------------------------------------
if ~strcmp( get(gcf, 'SelectionType'), 'alt')
% if evnt.Button == 1 % this works only with Matlab version > R2014
% The QC is applied either on TSG data either on Sample data.
% it depends if the Botte Toggle button has been cliked on
% -----------------------------------------------------------
if strcmp( get(hBottleToggletool, 'state'), 'on')
% get index on selected zone
% --------------------------
if ~isempty(tsg.DAYD_EXT)
ind = find(tsg.DAYD_EXT > p1(1) & tsg.DAYD_EXT < p2(1) & ...
tsg.EXT_DIF > p1(2) & tsg.EXT_DIF < p2(2));
% Keep the information on the indices of the selected zone
% --------------------------------------------------------
tsg.rbboxind = ind .* ones(size(ind));
% Modifiy the QC
% --------------
[tsg.qc.active.Code, tsg.qc.active.Color] = get_active_QC(hMainFig);
tsg.([SAMPLE '_EXT_QC'])(ind) = tsg.qc.active.Code;
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
% Save the modifications
% ----------------------
setappdata( hMainFig, 'tsg_data', tsg);
% plot selected data with selected code
% --------------------------------------
plot_Correction( hMainFig, hPlotAxes, PARA);
end
else
% store last QC in history for undo
% ---------------------------------
if (tsg.qc_history_pointer == 0)
tsg.qc_history_state = int8(zeros(size(tsg.([PARA{1} '_QC']),1),tsg.qc_history_size));
end
if (tsg.qc_history_pointer == tsg.qc_history_size)
tsg.qc_history_state = circshift(tsg.qc_history_state,[0 -1]);

jacques.grelet_ird.fr
committed
else
tsg.qc_history_pointer = tsg.qc_history_pointer + 1;
end
tsg.qc_history_state(:,tsg.qc_history_pointer) = tsg.([PARA{1} '_QC']);
tsg.qc_redo_possible = 0;
% get index on selected zone
% ---------------------------
ind = find(tsg.DAYD > p1(1,1) & tsg.DAYD < p2(1,1) & ...
tsg.(PARA{1}) > p1(1,2) & tsg.(PARA{1}) < p2(1,2));
% Keep the information on the indices of the selected zone
% --------------------------------------------------------
tsg.rbboxind = ind .* ones(size(ind));
% Modify the QC
% --------------
[tsg.qc.active.Code, tsg.qc.active.Color] = get_active_QC(hMainFig);
tsg.([PARA{1} '_QC'])(ind) = tsg.qc.active.Code;
% Save the modifications
% ----------------------
setappdata( hMainFig, 'tsg_data', tsg);
% Draw plot 1 of the validation figure
% ------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1, PARA{1} );
% refresh QC statistic panel
% --------------------------
display_QC( hMainFig );
% Update the map if already displayed
% -----------------------------------
if strcmp( get(hMapFig,'visible'), 'on') == 1
erase_Line( hPlotAxes, 4 );
plot_map( hMainFig, hPlotAxes);
% enable Undo menu if QC flags applied
% ------------------------------------
if (tsg.qc_history_pointer > 0)
set(findobj('tag','UIMENU_UNDO'),'enable','on');
end
% enable Redo menu if QC flags applied
% ------------------------------------
if (tsg.qc_redo_possible > 0)
set(findobj('tag','UIMENU_REDO'),'enable','on');
end

jacques.grelet_ird.fr
committed
end
% As soon as a modification took place the data should be saved
% -------------------------------------------------------------
set( hSaveMenu, 'UserData', 'on' );
% enable ButtonMotion on main fig after select QC area
% ----------------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);

jacques.grelet_ird.fr
committed
end
%% QC_OffMenuCallback .............................. Quality Control Module
%----------------------------------------------------------------------
% Callback function run when the QC toggle tool is released
%----------------------------------------------------------------------
function QC_OffMenuCallback(src, evnt)
% Desactive right clic menu on first axes (salinity)
% ---------------------------------------------------
set(hPlotAxes(1),'UIContextMenu', []);
% Desactive clic mouse menu (zoom) on first axes (salinity)
% ----------------------------------------------------------
set(hPlotAxes(1),'ButtonDownFcn', []);
% Uipanel visible or not
% -----------------------
set( hbgQc, 'Visible', 'off' );
set( hDuplicateQcPanel, 'Visible', 'off');
if strcmp( get(hBottleToggletool, 'state'), 'off' )
set( hCalToggletool, 'state', 'off', 'enable', 'on' );
set( hInterpToggletool, 'state', 'off', 'enable', 'on' );
end
% uibuttongroup uipanel used to choose a parameter is set to
% on only if the Correction screen (bottle toggletool) is off
% -----------------------------------------------------------
if strcmp( get( hBottleToggletool, 'state'), 'off')
set( hbgParameter, 'Visible', 'on');
end
% set POSITION_QC from LATX_QC or LONX_QC after validation
% give same value for LATX_QC and LONX_QC
% ---------------------------------------------------------
tsg.POSITION_QC = max(tsg.LATX_QC,tsg.LONX_QC );
tsg.LATX_QC = tsg.POSITION_QC;
tsg.LONX_QC = tsg.POSITION_QC;
% Save the modifications
% ----------------------
setappdata( hMainFig, 'tsg_data', tsg);
% cursor back to normal
% ---------------------
set(hMainFig,'Pointer','arrow');
%% QC_ContextMenuCallback context menu selected ........................ Quality Control Module
%-----------------------------------------------------------
% Context menu used to attribute a QC to a previously selected
% TSG time series
%-----------------------------------------------------------
function QC_ContextMenuCallback(src, evnt, key)
% Retrieve Default Quality Code and Color
% ---------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Get the parameter (SSPS, SSJT or SSTP)
% --------------------------------------
PARA = getParaCorModule( hMainFig );
% get key and some values in hashtable
% ------------------------------------

jacques.grelet_ird.fr
committed
code = tsg.qc.hash.(key).code;
color = tsg.qc.hash.(key).color;
% set active code and color from selected context menu
% ----------------------------------------------------
tsg.qc.active.Code = code;
tsg.qc.active.Color = color;
% Modify and plot the last selected tsg data
% ------------------------------------------
if isfield(tsg, 'rbboxind') && ~isempty( tsg.rbboxind )
if strcmp( get(hBottleToggletool, 'state'), 'on')
tsg.([SAMPLE '_EXT_QC'])(tsg.rbboxind) = tsg.qc.active.Code;
% in the application data
% ----------------------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Draw the 3 plots of the Correction figure
% -----------------------------------------
plot_Correction( hMainFig, hPlotAxes, PARA );
else
% store last QC in history for undo
% ---------------------------------
if (tsg.qc_history_pointer == 0)
tsg.qc_history_state = int8(zeros(size(tsg.([PARA{1} '_QC']),1),tsg.qc_history_size));
end
if (tsg.qc_history_pointer == tsg.qc_history_size)
tsg.qc_history_state = circshift(tsg.qc_history_state,[0 -1]);
else
tsg.qc_history_pointer = tsg.qc_history_pointer + 1;
end
tsg.qc_history_state(:,tsg.qc_history_pointer) = tsg.([PARA{1} '_QC']);
tsg.qc_redo_possible = 0;

jacques.grelet_ird.fr
committed
set(findobj('tag','UIMENU_REDO'),'enable','off');
% Modify the QC
% --------------
tsg.([PARA{1} '_QC'])(tsg.rbboxind) = tsg.qc.active.Code;
% Save tsg.SSPS_QC in the application data before use
% inside plot_Validation
% ---------------------------------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Draw plot 1 of the validation figure
% ------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1, PARA{1} );
% Re-draw the map
% -------------------------------------------------------------
if strcmp( get(hMapFig, 'visible'), 'on') == 1
erase_Line( hPlotAxes, 4 );
plot_map( hMainFig, hPlotAxes);
end
% Update the radio button corresponding to the selected
% QC context menu (rbg : RadioButtonGroup)
% -----------------------------------------------------
radioTag = ['TAG_QC_RADIO_' char(key)]; % Build the TAG of the CODE
hbgChildren = get(hbgQc,'Children'); % Get the handles of the rbg
hbgTagCell = get(hbgChildren, 'tag'); % get the TAG of the rbg
ind = strcmp(radioTag, hbgTagCell); % Compare the TAG
hRadioButton = hbgChildren( ind == 1 ); % Get the handle of the button
set(hbgQc, 'SelectedObject', hRadioButton); % Make this button active
% refresh QC statistic panel
% ---------------------------
display_QC( hMainFig);
%setappdata( hMainFig, 'tsg_data', tsg );
end
%% Radiobutton Quality Control ..................... Quality Control Module
% ---------------------------------------------------------------
% Callback to select CODE and COLOR QC from the RadioButton Group
% ---------------------------------------------------------------
function radioButtonQc(source, evnt)
% Retrieve Default Quality Code and Color
% ---------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Retrieve the key from the active RadioButton
% --------------------------------------------
rbTag = get(evnt.NewValue,'Tag');
% store his handle to uibuttongroup userdata
% ------------------------------------------
set(hbgQc,'Userdata', evnt.NewValue);
% set active code and color from selected context menu
% ----------------------------------------------------

jacques.grelet_ird.fr
committed
tsg.qc.active.Code = tsg.qc.hash.(key).code;
tsg.qc.active.Color = tsg.qc.hash.(key).color;

jacques.grelet_ird.fr
committed
% save tsg struct
% ----------------
end
%% preQcPanCallback .................................Quality Control Module
% ---------------------------------------------------------------
% Callback function ... to be completed
% ---------------------------------------------------------------
end
%% postQcPanCallback ............................... Quality Control Module
% ---------------------------------------------------------------
% Callback function ... to be completed
% ---------------------------------------------------------------
% Set the right limit and interval to the 3 axes
% ----------------------------------------------
for iaxe = 1:3
set(hPlotAxes(iaxe),'XTickMode','auto')
datetick(hPlotAxes(iaxe),'x','keeplimits')
end
% Re-draw the map once the pan is off - only valide in QC mode
% -------------------------------------------------------------
if strcmp( get(hMapFig, 'visible'), 'on') == 1
erase_Line( hPlotAxes, 4 );
plot_map( hMainFig, hPlotAxes);