Newer
Older
%% PopupMenu Select Parameter
% POP_UP filled in with the function "initParameterChoice"
% ---------------------------
function SelectParameter(hObject, eventdata, nplot)
% Callback function run when the ....
% Get application data
% --------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Get the active string of the selected box
% -----------------------------------------
val = get( hObject, 'Value' );
string_list = get( hObject, 'String' );
selected_string = string_list{val};
% Get the default parameter
% -------------------------
tsg.plot.sample = selected_string;
if strcmp( tsg.plot.sample, 'SSJT' )
tsg.plot.sample = 'SSTP';
% Save application data
% --------------------
setappdata( hMainFig, 'tsg_data', tsg);
% Disable the climatology
% -----------------------
plotClim = 0;
if strcmp( get(hClimToggletool, 'state'), 'on' )
set( hClimToggletool, 'state', 'off' );
plotClim = 1;
end
% Disable the climatology
% -----------------------
set( hClimToggletool, 'state', 'off' );
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} );
% Plot the climatology if it was already plotted
% ----------------------------------------------
if plotClim
set( hClimToggletool, 'state', 'on' );
plot_Climatology(hMainFig, hPlotAxes);
%% SelectTime_OnMenuCallback
%---------------------------
function SelectTime_OnMenuCallback(hObject, eventdata)
% Callback function run when the ....
% Desactivate Zoom and Pan functions.
% ----------------------------------
set( hZoomInToggletool, 'state', 'off' );
set( hZoomOutToggletool, 'state', 'off' );
set( hQCToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
% Create a pointer to select the time limits
% ------------------------------------------
selTimePointer = ones(16)+1;
selTimePointer(1,:) = 1; selTimePointer(16,:) = 1;
selTimePointer(:,1) = 1; selTimePointer(:,16) = 1;
selTimePointer(1:4,8:9) = 1; selTimePointer(13:16,8:9) = 1;
selTimePointer(8:9,1:4) = 1; selTimePointer(8:9,13:16) = 1;
selTimePointer(5:12,5:12) = NaN; % Create a transparent region in the center
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
% Activate clic mouse menu on second axes (salinity) for next rbbox
% ----------------------------------------------------------------
set(hMainFig,'WindowButtonDownFcn', @Time_SelectCallback);
% change cursor
% ---------------
set( hMainFig, 'Pointer', 'custom',...
'PointerShapeCData', selTimePointer, 'PointerShapeHotSpot',[9 9]);
% ----------------------------------------------------------------------
% nested function on mouse clic when Select Time toggle tool is selected
% ----------------------------------------------------------------------
function Time_SelectCallback(gcbo, eventdata)
% disable ButtonMotion on main fig during select
% prevent drawing to map
% ----------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', []);
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Selection of the data within the figure
% ---------------------------------------
point1 = get(gca,'CurrentPoint'); % button down detected
finalRect = rbbox; % return figure units
point2 = get(gca,'CurrentPoint'); % button up detected
point1 = point1(1,1:2); % extract x and y
point2 = point2(1,1:2);
p1 = min(point1,point2);
p2 = max(point1,point2); % calculate locations
% get index on selected zone - Only on X axes (time)
% --------------------------------------------------
ind = find(tsg.DAYD >= p1(1,1) & tsg.DAYD <= p2(1,1));
% Write the date in the Editable uicontrol
% ----------------------------------------
set( hetDateMin, 'String', datestr(tsg.DAYD(ind(1)), 31));
set( hetDateMax, 'String', datestr(tsg.DAYD(ind(end)), 31));
% enable ButtonMotion on main fig after select QC area
% ----------------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);
end
end
%% SelectTime_OffMenuCallback
%----------------------------
function SelectTime_OffMenuCallback(hObject, eventdata)
% Desactivate time limit buttons
% ------------------------------
set( hTimelimitToggletool, 'state', 'off');
set( hMainFig, 'WindowButtonDownFcn', []);
set( hMainFig, 'Pointer', 'arrow');
end
%% Clim_OffMenuCallback
%------------------------------------------------------------------------
% Callback function run when the Levitus climatology toolbar is unselected
%------------------------------------------------------------------------
function Clim_OffMenuCallback(hObject, eventdata)
% Get lines handles from tag
% --------------------------
hLines = findobj('-regexp', 'Tag', 'TAG_LINE_CLIMATO_');
% Delete climatology lines on axes
% ---------------------------------
delete(hLines);
%------------------------------------------------------------------------
% Callback function run when the Levitus climatology toolbar is unselected
%------------------------------------------------------------------------
function Clim_OnMenuCallback(hObject, eventdata)
% Test if the TSG and bucket files have been read
% -----------------------------------------------
if strcmp( get(hOpenMenu, 'UserData'), 'on' )
% plot climatology
% ----------------
plot_Climatology(hMainFig, hPlotAxes);
end
end
%% ClimatoSelectMenuCallback
% -------------------------------------------------------------------
% Callback function run when climato submenu is selected
% -------------------------------------------------------------------
function ClimatoSelectMenuCallback(hObject, eventdata, climato, time)
% find all climato submenu and set 'checked' property to 'off'
% ------------------------------------------------------------
hdl = findobj( '-regexp', 'tag', 'TAG_UIMENU_CLIMATO');
set(hdl, 'checked', 'off');
% set current climato submenu checked
% -----------------------------------
set(hObject, 'checked', 'on');
% memorize action on climatology menu for next use
% ------------------------------------------------
s.type = climato;
s.time = time;
set(hClimatoMenu, 'userdata', s);
% check if climatology toggle button is set
% -----------------------------------------
if strcmp(get(hClimToggletool, 'state'), 'on')
% clear last plotted climatology
% ------------------------------
Clim_OffMenuCallback;
% plot and read (eventually) new climatology
% ------------------------------------------
plot_Climatology(hMainFig, hPlotAxes);
end
%% PreferencesMenuCallback
% -------------------------------------------------------------------
% Callback function run when Option/Preference is selected
% -------------------------------------------------------------------
function PreferencesMenuCallback(hObject, eventdata)
oldmapres=tsg.preference.map_resolution;
% call preferences form function
% ------------------------------
if( preferencesForm(hMainFig) )
% if form is validate, update plots only if plot exist
% ----------------------------------------------------
if ~isempty(findobj( '-regexp', 'Tag', ('TAG_PLOT\d_LINE_')))
SelectParameter(pmhPara(1),[],1);
end
% Update the map (if visible) if ship speed QC has been applied
% or map resolution has been changed
% -------------------------------------------------------------
if (strcmp( get(hMapFig,'visible'), 'on') == 1 & ...
gael.alory_legos.obs-mip.fr
committed
tsg.preference.map_resolution ~= oldmapres)
erase_Line( hPlotAxes, 4 );
plot_map( hMainFig, hPlotAxes);
%% HelpMenuCallback
% -------------------------------------------------------------------
% Callback function run when Help/Help is selected
% -------------------------------------------------------------------
function HelpMenuCallback(hObject, eventdata)
msgbox( 'Function Help not yet implemented', 'warn', 'modal');
end
%% AboutMenuCallback
% -------------------------------------------------------------------
% Callback function run when Help/About is selected
% -------------------------------------------------------------------
function AboutMenuCallback(hObject, eventdata)
%splash('Thermo.jpg', 3000);
aboutDialog(hMainFig, DEFAULT_PATH_FILE);
%% HeaderMenuCallback
% -------------------------------------------------------------------
% Callback function run when the headerForm tool bar item is selected
% -------------------------------------------------------------------
function HeaderMenuCallback(hObject, eventdata)
% call header form function
% -------------------------
headerForm(hMainFig);
end
%% PrintFigMenuCallback
% -------------------------------------------------------------------
% Callback function run when the Report tool bar item is selected
% -------------------------------------------------------------------
function PrintFigMenuCallback(hObject, eventdata)
% disable ButtonMotion on main fig during select
% ----------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', []);
% Get the tsg structure
% ---------------------
tsg = getappdata( hMainFig, 'tsg_data');
hPrintFig = figure( 'Name', 'Print','NumberTitle', 'off','Resize', 'on');
hPlot(1) = subplot(3,1,1);
hPlot(2) = subplot(3,1,2);
hPlot(3) = subplot(3,1,3);
title( hPlot(1), tsg.file.name, 'interpreter', 'none');
if strcmp(get(hBottleToggletool,'state'), 'on')
% Default parameter
% -----------------------------------------------------
PARA = getParaCorModule( hMainFig );
plot_Correction( hMainFig, hPlot, PARA );
elseif strcmp(get(hCalToggletool,'state'), 'on')
plot_Calibration( hMainFig, hPlot, 1, 'SSPS' );
plot_Calibration( hMainFig, hPlot, 2, 'SSJT' );
plot_Calibration( hMainFig, hPlot, 3, 'SSTP' );
% elseif strcmp(get(hMapToggletool,'state'), 'on')
% plot_map( hMainFig, hPlot)
elseif strcmp(get(hInterpToggletool,'state'), 'on')
plot_Interpolation( hMainFig, hPlot, 1 );
plot_Interpolation( hMainFig, hPlot, 2 );
plot_Interpolation( hMainFig, hPlot, 3 );
plot_Validation( hMainFig, hPlot, 1, tsg.plot.parameter{1} );
plot_Validation( hMainFig, hPlot, 2, tsg.plot.parameter{2} );
plot_Validation( hMainFig, hPlot, 3, tsg.plot.parameter{3} );
% I = getframe(hPlotAxes(1));
% imwrite(I.cdata, 'myplot.png');
linkaxes([hPlot(1),hPlot(2),hPlot(3)], 'x');
% set(hPlot(i), 'box', 'on','XTickMode','auto');
set(hPlot(i), 'box', 'on','XTickMode','auto');
datetick(hPlot(i),'x','mm/dd','keepticks' );
% enable ButtonMotion on main fig after select QC area
% ----------------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
end
%% ReportMenuCallback
% -------------------------------------------------------------------
% Callback function run when the Report tool bar item is selected
% -------------------------------------------------------------------
function ReportMenuCallback(hObject, eventdata)
% call report function
% --------------------
saveReport(hMainFig);
end
%% SaveMenuCallback
% -------------------------------------------------------------------
% Callback function run when the Save menu item is selected
% -------------------------------------------------------------------
function SaveMenuCallback(hObject, eventdata)
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% fill or append header form
% -------------------------
error = headerForm(hMainFig);
% if user press continue button, ask for netcdf file
% ------------------------------------------------
if error ~= -1
[fileName, pathName, filterindex] = uiputfile('*.nc', ...
'Save file name', strcat(tsg.file.name, '.nc'));
% if user press cancel button, all var are set to zero
% ----------------------------------------------------
if filterindex == 0
return;
end
% Pointer set to watch during reading and plotting
% ------------------------------------------------
set( hMainFig, 'Pointer', 'watch' );
% flushes the event queue and updates the closed uiputfile window
% ---------------------------------------------------------------
drawnow;
% write netcdf file
% -----------------
error = writeTSGDataNetCDF(hMainFig, strcat(pathName, fileName));
% Pointer reset to arrow
% ----------------------
set( hMainFig, 'Pointer', 'arrow' );
% must to be rewriting
% ------------------------------
if error == -1
warning('tsgqc:SaveMenuCallback', ...
'NetCDF writing error: %s %s', pathName, fileName);
return;
end
% update the display
% ------------------
set( hInfoFileText, 'String', strcat(tsg.file.name, tsg.file.ext));
% enable Quality Control mode
% ---------------------------
hdl_pushtool = findobj('Tag', 'QC');
set(hdl_pushtool, 'Enable', 'on');
end
end
% -------------------------------------------------------------------
% Callback function run when the Export menu item is selected
% -------------------------------------------------------------------
function ExportTsgCallback(hObject, eventdata)
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Desactivate MouseMotion 'off'
% ----------------------------
set( hMainFig, 'WindowButtonMotionFcn', []);
% Open standard dialog box for saving files
% -----------------------------------------
[fileName, pathName, filterindex] = uiputfile('*.tsgqc', ...
'Save file name', strcat(tsg.file.name, '.tsgqc'));
% if user press cancel button, all var are set to zero
% ----------------------------------------------------
if filterindex == 0
return;
end
% Pointer set to watch during reading and plotting
% ------------------------------------------------
set( hMainFig, 'Pointer', 'watch' );
% Write a .TSG (ascii) file
% --------------------------
Yves Gouriou
committed
error = writeAsciiTsg(hMainFig, strcat(pathName, fileName));
% Pointer reset to arrow
% ----------------------
set( hMainFig, 'Pointer', 'arrow' );
% enable Quality Control mode
% ---------------------------
hdl_pushtool = findobj('Tag', 'QC');
set(hdl_pushtool, 'Enable', 'on');
% Set MouseMotion 'on'
% --------------------
set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);
% Check for .TSG writing error - must to be rewriting
% Because of the 'return' - These line must be at the end
% --------------------------------------------------------
warning('tsgqc:SaveMenuCallback', ...
'TSG no ouput: %s %s', pathName, fileName);
return;
end
end
%% ExportSampleCallback
% -------------------------------------------------------------------
% Callback function run when the Export menu item is selected
% -------------------------------------------------------------------
function ExportSampleCallback(hObject, eventdata)
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Desactivate MouseMotion 'off'
% ----------------------------
set( hMainFig, 'WindowButtonMotionFcn', []);
% Open standard dialog box for saving files
% -----------------------------------------
gael.alory_legos.obs-mip.fr
committed
[fileName, pathName, filterindex] = uiputfile('*.spl', ...
'Save file name', strcat(tsg.file.name, '.spl'));
% if user press cancel button, all var are set to zero
% ----------------------------------------------------
if filterindex == 0
% Pointer set to watch during reading and plotting
% ------------------------------------------------
set( hMainFig, 'Pointer', 'watch' );
gael.alory_legos.obs-mip.fr
committed
% Write a .SPL (ascii) file
% --------------------------
error = writeAsciiSample(hMainFig, strcat(pathName, fileName));
% Pointer reset to arrow
% ----------------------
set( hMainFig, 'Pointer', 'arrow' );
% enable Quality Control mode
% ---------------------------
hdl_pushtool = findobj('Tag', 'QC');
set(hdl_pushtool, 'Enable', 'on');
% Set MouseMotion 'on'
% --------------------
set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);
% Check for .TSG writing error - must to be rewriting
% Because of the 'return' - These line must be at the end
% --------------------------------------------------------
if error == -1
warning('tsgqc:SaveMenuCallback', ...
'TSG no ouput: %s %s', pathName, fileName);
return;
end
end
%% UndoMenuCallback
% -----------------------------------------------------------------------
% Callback function run when the Edit/Undo menu item is selected (Ctrl+Z)
% -----------------------------------------------------------------------
function UndoMenuCallback(hObject, eventdata)
% Undo module not yet implemented
% -------------------------------
% msgbox('Undo module not yet implemented', 'modal');
%tsg.queue = undo(tsg.queue);
%tsg.SSPS_QC = get(tsg.queue);
% Make the Salinity, temperature and velocity plot
% ------------------------------------------------
plot_SalTempVel( hMainFig, hPlotAxes );
end
%% RedoMenuCallback
% -----------------------------------------------------------------------
% Callback function run when the Edit/Redo menu item is selected (Ctrl+R)
% -----------------------------------------------------------------------
function RedoMenuCallback(hObject, eventdata)
% Redo module not yet implemented
% -------------------------------
msgbox('Redo module not yet implemented', 'modal');
%% KeyPressFcnCallback
% -----------------------------------------------------------------------
% Callback function run when key is pressed
% -----------------------------------------------------------------------
function keyPressFcnCallback(hObject, evnt)

jacques.grelet_ird.fr
committed
% MATLAB generates repeated KeyPressFcn events, desactivate callback
% ------------------------------------------------------------------
set(hObject, 'KeyPressFcn', []);

jacques.grelet_ird.fr
committed
% check if key is pressed
% -----------------------
if ~isempty(evnt.Key)

jacques.grelet_ird.fr
committed
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
% test key, shift or control
% --------------------------
switch evnt.Key
case 'shift'
% get current pointer shape
% -------------------------
pointerShape = get(hObject, 'pointer');
% save current cursor shape
% -------------------------
setappdata( hMainFig, 'tsg_pointer', pointerShape);
% set cursor to fullcross or reset to normal arrow
% ------------------------------------------------
set(hObject, 'pointer', 'fullcrosshair');
case 'control'
% Get current position of cusor and return its coordinates in
% axes
% -----------------------------------------------------------
a = get(hPlotAxes(1), 'CurrentPoint');
x = a(2,1);
% Test if cursor is inside data interval
% -------------------------------------
if x > tsg.DAYD(1) && x < tsg.DAYD(end)
% loop over 3 subplot and draw vertical lines
% -------------------------------------------
for iplot = 1:3
axes( hPlotAxes(iplot));
limy = get(hPlotAxes(iplot), 'YLim');
line([x x], limy, 'color', 'k', 'EraseMode', 'xor',...
'tag', 'VERTICAL_TAG_LINE');
end
end
end % end of switch
end
end

jacques.grelet_ird.fr
committed
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
%% KeyReleaseFcnCallback
% -----------------------------------------------------------------------
% Callback function run when key is release
% -----------------------------------------------------------------------
function keyReleaseFcnCallback(hObject, evnt)
% check if key is pressed
% -----------------------
if ~isempty(evnt.Key)
% test key, shift or control
% --------------------------
switch evnt.Key
case 'shift'
% get stored cursor shape
% -----------------------
pointerShape = getappdata( hMainFig, 'tsg_pointer');
% if pointer equal to fullcrosshair, oups, error, reset to arrow
% ---------------------------------------------------------------
if strcmp(pointerShape, 'fullcrosshair')
pointerShape = 'arrow';
set(hObject, 'pointer', pointerShape);
end
% set pointer
% -----------
set(hObject, 'pointer', pointerShape);
case 'control'
% find vertical lines and delete them
% -----------------------------------
hdl_lines = findobj( 'Tag', 'VERTICAL_TAG_LINE' );
delete(hdl_lines);
end % end of switch
end % end of if
% Re-activate callback
% --------------------
set(hObject, 'KeyPressFcn', @keyPressFcnCallback);
end
%% QuitMapCallback
% -----------------------------------------------------------------
% Callback function run when the Quit Map Figure item is selected
% -----------------------------------------------------------------
function QuitMapCallback(hObject, eventdata)
% Make the earth map invisible
% ----------------------------
set(hMapToggletool, 'state', 'off' );
% -----------------------------------------------------------------
% Callback function run when the Quit menu item is selected
% -----------------------------------------------------------------
function QuitMenuCallback(hObject, eventdata)
% Get the data from the application GUI
% -------------------------------------
tsg = getappdata(hMainFig, 'tsg_data');
% in case of bad initialisation, the user could close the windows
% ---------------------------------------------------------------
try
% save config mat file in prefdir
% -------------------------------
config_file = [prefdir, filesep, tsgqcname, '.mat'];
% save preference mat file
% ------------------------
if exist('tsg', 'var') && isfield( tsg, 'preference')
preference = tsg.preference;
save( config_file, 'preference');
end
% If the data have been modified and not save, the program
% ask to save the data
% --------------------------------------------------------
if strcmp( get( hSaveMenu, 'UserData' ), 'on')
selection = ...
questdlg('The file has been modified. Do you want to save it ?',...
'Save before Quit?',...
'Yes', 'No', 'Yes');
if strcmp(selection, 'Yes')
% call File/Save Menu Callback before before quit
% -----------------------------------------------
SaveMenuCallback;
% quit program
% ------------
quitProgram(DEFAULT_PATH_FILE, hMainFig, hMapFig);
selection = ...
questdlg(['Quit ' get(hMainFig, 'Name') '?'],...
['Quit ' get(hMainFig, 'Name') '?'],...
'Yes', 'No', 'Yes');
if strcmp(selection, 'No')
return;
else
quitProgram(DEFAULT_PATH_FILE, hMainFig, hMapFig);
end
% catch error during close windows
% --------------------------------
catch
% display message to console and quit program
% -------------------------------------------
fprintf('abnormal program termination during close user request\n');
quitProgram(DEFAULT_PATH_FILE, hMainFig);