Newer
Older

jacques.grelet_ird.fr
committed
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
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;
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
% 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_history_pointer > 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.Code
% 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 );
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
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;
% 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);
end
% restacks the figure to the top of the screen
% --------------------------------------------
figure( hMainFig);
set(hQCToggletool, 'state', 'on' );
%---------------------------------------------------------------------
% Callback function run when mouse pointer is moving on temperature plot
% draw corresponding measurement position on map
%---------------------------------------------------------------------
function MouseMotion(src, evnt)
% Test if the callback can be activated
% -------------------------------------
if strcmp( get( hMainFig, 'UserData'), 'ButtonMotionOn')
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Get current position of cusor and return its coordinates in
% axes with handle h_axes
% -----------------------------------------------------------
a = get(hPlotAxes(1), 'CurrentPoint');
x = a(2,1);
y = a(2,2);
% Get the Limits of axes 1
% ------------------------
limx = get(hPlotAxes(1), 'XLim');
limy = get(hPlotAxes(1), 'YLim');
% Code to Activate the PAN function when QC mode is active
% A PAN zone is defined in the bottom (10%) of PlotAxes(1)
% 1 - one to desactivate QC when Pan is set to on.
% 2 - one to reactivate QC once the pan has been used.
% ---------------------------------------------------------
% if we are in QC mode
% ---------------------
if strcmp( get(hQCToggletool, 'state' ), 'on' );
% Suppose that Y axes is increasing from the bottom to the top
% ------------------------------------------------------------
limy2 = limy(1) + (limy(2)-limy(1)) * 0.10;
if x > limx(1) && x < limx(2) && y <= limy2 && y >= limy(1)
hPan = pan(hMainFig);
set(hPan,'ActionPreCallback', @preQcPanCallback);
set(hPan,'ActionPostCallback', @postQcPanCallback);
set(hPan,'Enable','on');
else

jacques.grelet_ird.fr
committed
try
pan(hMainFig, 'off');
catch
end
end % end of cursor test location
end % end of QC mode test
% Dynamically display data in uicontrol for valid data
% ----------------------------------------------------
if x > tsg.DAYD(1) && x < tsg.DAYD(end)
% get index of cursor location
% ----------------------------
indCursor = find( tsg.DAYD > x, 1, 'first');
% display informations of cursor location in text uicontrol
% ---------------------------------------------------------
if tsg.preference.positions_format_value == 1
set( hInfoLatText, 'String', dd2dm(tsg.LATX(indCursor), 0) );
set( hInfoLongText, 'String', ...
dd2dm(mod(tsg.LONX(indCursor) + 180, 360) - 180, 1) );
else
set( hInfoLatText, 'String', tsg.LATX(indCursor) );
set( hInfoLongText, 'String', ...
mod(tsg.LONX(indCursor) + 180, 360) - 180 );
end
set( hInfoSSPSText, 'String', tsg.SSPS(indCursor) );
end
if ~isempty(tsg.SSJT)
set( hInfoSSJTText, 'String', tsg.SSJT(indCursor) );
set( hInfoSSTPText, 'String', tsg.SSTP(indCursor) );
% Plot the position on the map if this one is active
% --------------------------------------------------
if strcmp( get(hMapFig, 'Visible'), 'on')
% Select the map axes, we cannot use mline as line with an axes
% in first parameter like: m_line(hPlotAxes(4), ....)
% ------------------------------------------------------------
% Look for a MARKER (Red point) on the ship track
% -----------------------------------------------
h = findobj( hPlotAxes(4), '-regexp','Tag', 'TAG_PLOT4_LINE_MARKER');
if isempty( h ) % if no Marker
if ~isnan( tsg.LONX(indCursor) )
% Plot a Marker (Red point) on the ship track
% -------------------------------------------
hMarker = m_line(mod(tsg.LONX(indCursor(1)) + ...
tsg.lonplus, tsg.lonmod) - tsg.lonplus,...
tsg.LATX(indCursor(1)),...
'Marker', 'o', 'MarkerSize', 5, ...
'Color', 'r', 'MarkerFaceColor', 'r');
% Put a tag on the Marker - This tag allows to get the handle
% of the Marker
% -----------------------------------------------------------
set( hMarker, 'TAG', 'TAG_PLOT4_LINE_MARKER' );
if ~isnan( tsg.LONX(indCursor) )
% Delete the Marker and redraw it
% -------------------------------
delete( h);
tsg.LONX(indCursor), tsg.LATX(indCursor),...
'Marker', 'o', 'MarkerSize', 5, ...
'Color', 'r', 'MarkerFaceColor', 'r');
% Put a tag on the Marker - This tag allows to get the handle
% of the Marker
% -----------------------------------------------------------
set( hMarker, 'TAG', 'TAG_PLOT4_LINE_MARKER' );
end % end of map visible
else
% if cursor is out of valid data, display blank
% ---------------------------------------------
set( hInfoDateText, 'String', '' );
set( hInfoLatText, 'String', '' );
set( hInfoLongText, 'String', '' );
set( hInfoSSPSText, 'String', '' );
set( hInfoSSTPText, 'String', '' );
set( hInfoSSJTText, 'String', '' );