VMT

PURPOSE ^

--- THE VELOCITY MAPPING TOOLBOX ---

SYNOPSIS ^

function varargout = VMT(varargin)

DESCRIPTION ^

 --- THE VELOCITY MAPPING TOOLBOX ---
 
 VMT is a Matlab-based software for processing and visualizing ADCP data
 collected along transects in rivers or other bodies of water. VMT allows
 rapid processing, visualization, and analysis of a range of ADCP datasets
 and includes utilities to export ADCP data to files compatible with
 ArcGIS, Tecplot, and Google Earth. The software can be used to explore
 patterns of three-dimensional fluid motion through several methods for
 calculation of secondary flows (e.g. Rhoads and Kenworthy, 1998; Lane et
 al., 2000). The software also includes capabilities for analyzing the
 acoustic backscatter and bathymetric data from the ADCP. A user-friendly
 graphical user interface (GUI) enhances program functionality and
 provides ready access to two- and three- dimensional plotting functions,
 allowing rapid display and interrogation of velocity, backscatter, and
 bathymetry data.
 
 CITATION: 
 Parsons, D. R., Jackson, P. R., Czuba, J. A., Engel, F. L., Rhoads, B.
 L., Oberg, K. A., Best, J. L., Mueller, D. S., Johnson, K. K. and Riley,
 J. D. (2013), Velocity Mapping Toolbox (VMT): a processing and
 visualization suite for moving-vessel ADCP measurements. Earth Surf.
 Process. Landforms. doi: 10.1002/esp.3367

__________________________________________________________________________
 P.R. Jackson, U.S. Geological Survey, Illinois Water Science Center
 (pjackson@usgs.gov)

 Code contributed by D. Parsons, D. Mueller, J. Czuba, and F. Engel.
__________________________________________________________________________

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = VMT(varargin)
0002 % --- THE VELOCITY MAPPING TOOLBOX ---
0003 %
0004 % VMT is a Matlab-based software for processing and visualizing ADCP data
0005 % collected along transects in rivers or other bodies of water. VMT allows
0006 % rapid processing, visualization, and analysis of a range of ADCP datasets
0007 % and includes utilities to export ADCP data to files compatible with
0008 % ArcGIS, Tecplot, and Google Earth. The software can be used to explore
0009 % patterns of three-dimensional fluid motion through several methods for
0010 % calculation of secondary flows (e.g. Rhoads and Kenworthy, 1998; Lane et
0011 % al., 2000). The software also includes capabilities for analyzing the
0012 % acoustic backscatter and bathymetric data from the ADCP. A user-friendly
0013 % graphical user interface (GUI) enhances program functionality and
0014 % provides ready access to two- and three- dimensional plotting functions,
0015 % allowing rapid display and interrogation of velocity, backscatter, and
0016 % bathymetry data.
0017 %
0018 % CITATION:
0019 % Parsons, D. R., Jackson, P. R., Czuba, J. A., Engel, F. L., Rhoads, B.
0020 % L., Oberg, K. A., Best, J. L., Mueller, D. S., Johnson, K. K. and Riley,
0021 % J. D. (2013), Velocity Mapping Toolbox (VMT): a processing and
0022 % visualization suite for moving-vessel ADCP measurements. Earth Surf.
0023 % Process. Landforms. doi: 10.1002/esp.3367
0024 %
0025 %__________________________________________________________________________
0026 % P.R. Jackson, U.S. Geological Survey, Illinois Water Science Center
0027 % (pjackson@usgs.gov)
0028 %
0029 % Code contributed by D. Parsons, D. Mueller, J. Czuba, and F. Engel.
0030 %__________________________________________________________________________
0031 
0032 % Begin initialization code - DO NOT EDIT
0033 gui_Singleton = 1;
0034 gui_State = struct('gui_Name',       mfilename, ...
0035     'gui_Singleton',  gui_Singleton, ...
0036     'gui_OpeningFcn', @VMT_OpeningFcn, ...
0037     'gui_OutputFcn',  @VMT_OutputFcn, ...
0038     'gui_LayoutFcn',  [] , ...
0039     'gui_Callback',   []);
0040 if nargin && ischar(varargin{1})
0041     gui_State.gui_Callback = str2func(varargin{1});
0042 end
0043 
0044 % If ERROR, write a txt file with the error dump info
0045 try
0046 if nargout
0047     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0048 else
0049     gui_mainfcn(gui_State, varargin{:});
0050 end
0051 
0052 catch err
0053     if isdeployed
0054         errLogFileName = fullfile(pwd,...
0055             ['errorLog' datestr(now,'yyyymmddHHMMSS') '.txt']);
0056         msgbox({['An unexpected error occurred. Error code: ' err.identifier];...
0057             ['Error details are being written to the following file: '];...
0058             errLogFileName},...
0059             'VMT Status: Unexpected Error',...
0060             'error');
0061         fid = fopen(errLogFileName,'W');
0062         fwrite(fid,err.getReport('extended','hyperlinks','off'));
0063         fclose(fid);
0064         rethrow(err)
0065     else
0066         msgbox(['An unexpected error occurred. Error code: ' err.identifier],...
0067             'VMT Status: Unexpected Error',...
0068             'error');
0069         rethrow(err);
0070     end
0071 end
0072 % End initialization code - DO NOT EDIT
0073 
0074 %#ok<*DEFNU,*INUSL,*INUSD>
0075 
0076 % --- Executes just before VMT is made visible.
0077 function VMT_OpeningFcn(hObject, eventdata, handles, varargin)
0078 % This function has no output args, see OutputFcn.
0079 % hObject    handle to figure
0080 % eventdata  reserved - to be defined in a future version of MATLAB
0081 % handles    structure with handles and user data (see GUIDATA)
0082 % varargin   command line arguments to VMT (see VARARGIN)
0083 
0084 % Choose default command line output for VMT
0085 handles.output = hObject;
0086 
0087 % Build the GUI toolbar:
0088 % ----------------------
0089 handles = buildToolbar(handles);
0090 
0091 % Ensure path to utils & docs is available
0092 % ----------------------------------------
0093 if ~isdeployed
0094     filesep = '\'; % windows
0095     utilspath = [pwd filesep 'utils'];
0096     docspath  = [pwd filesep 'doc'];
0097     toolspath = [pwd filesep 'tools'];
0098     addpath(utilspath,docspath,toolspath)
0099 end
0100 
0101 % Update handles structure
0102 % ------------------------
0103 guidata(hObject, handles);
0104 
0105 % Load the GUI preferences:
0106 % -------------------------
0107 load_prefs(handles.figure1)
0108 
0109 % Initialize the GUI parameters:
0110 % ------------------------------
0111 guiparams = createGUIparams;
0112 guiparams.vmt_version = 'v4.03';
0113 
0114 % Draw the VMT Background
0115 % -----------------
0116 pos = get(handles.figure1,'position');
0117 axes(handles.VMTBackground);
0118 if ~isdeployed %isempty(dir(fullfile(matlabroot,'toolbox','images')))
0119     X = imread('VMT_Background.png');
0120     imdisp(X,'size',[pos(4) pos(3)]) % Avoids problems with users not having Image Processing TB
0121 else
0122     X = imread('VMT_Background.png');
0123     X = imresize(X, [pos(4) pos(3)]);
0124     X = uint8(X);
0125     imshow(X,'Border','tight')
0126 end
0127 uistack(handles.VMTBackground,'bottom')
0128 
0129 % Store the application data:
0130 % ---------------------------
0131 setappdata(handles.figure1,'guiparams',guiparams)
0132 
0133 % Initialize the GUI:
0134 % -------------------
0135 initGUI(handles)
0136 set_enable(handles,'init')
0137 % set(handles.GraphicsExportPanel,'Visible','off')
0138 % set(handles.ProcessingPanel,'Visible','off')
0139 pos = get(handles.figure1,'Position');
0140 % pos(3) = 545;
0141 set(handles.figure1,'Position',pos)
0142 set(handles.figure1,'Resize','on')
0143 
0144 % Allow access to the VMT Main GUI info by other sub-GUIs by pushing it to
0145 % the root
0146 setappdata(0  , 'hVMTgui'    , gcf);
0147 
0148 % UIWAIT makes VMT wait for user response (see UIRESUME)
0149 % uiwait(handles.figure1);
0150 % [EOF] VMT_OpeningFcn
0151 
0152 
0153 % --- Outputs from this function are returned to the command line.
0154 function varargout = VMT_OutputFcn(hObject, eventdata, handles)
0155 % varargout  cell array for returning output args (see VARARGOUT);
0156 % hObject    handle to figure
0157 % eventdata  reserved - to be defined in a future version of MATLAB
0158 % handles    structure with handles and user data (see GUIDATA)
0159 
0160 % Get default command line output from handles structure
0161 varargout{1} = handles.output;
0162 % [EOF] VMT_OutputFcn
0163 
0164 % --- Executes when figure1 is resized.
0165 function figure1_ResizeFcn(hObject, eventdata, handles)
0166 
0167 % Draw the VMT Background
0168 % -----------------
0169 pos = get(handles.figure1,'position');
0170 axes(handles.VMTBackground);
0171 if ~isdeployed %isempty(dir(fullfile(matlabroot,'toolbox','images')))
0172     X = imread('VMT_Background.png');
0173     imdisp(X,'size',[pos(4) pos(3)]) % Avoids problems with users not having Image Processing TB
0174 else
0175     X = imread('VMT_Background.png');
0176     X = imresize(X, [pos(4) pos(3)]);
0177     X = uint8(X);
0178     imshow(X,'Border','tight')
0179 end
0180 uistack(handles.VMTBackground,'bottom')
0181 
0182 % --- Executes when user attempts to close figure1.
0183 function figure1_CloseRequestFcn(hObject, eventdata, handles)
0184 % hObject    handle to figure1 (see GCBO)
0185 % eventdata  reserved - to be defined in a future version of MATLAB
0186 % handles    structure with handles and user data (see GUIDATA)
0187 
0188 % Hint: delete(hObject) closes the figure
0189 close_button = questdlg(...
0190     'You are about to exit VMT. Any unsaved work will be lost. Are you sure?',...
0191     'Exit VMT?','No');
0192 switch close_button
0193     case 'Yes'
0194         delete(hObject)
0195         close all hidden
0196     otherwise
0197         return
0198 end
0199 % [EOF] figure1_CloseRequestFcn
0200 
0201 %%%%%%%%%%%%%%%%%%%%%%
0202 % MENU BAR CALLBACKS %
0203 %%%%%%%%%%%%%%%%%%%%%%
0204 
0205 % --------------------------------------------------------------------
0206 function menuFile_Callback(hObject, eventdata, handles)
0207 % Empty
0208 
0209 % --------------------------------------------------------------------
0210 function menuOpen_Callback(hObject, eventdata, handles)
0211 % Empty
0212 
0213 % --------------------------------------------------------------------
0214 function menuOpenASCII_Callback(hObject, eventdata, handles)
0215 loadDataCallback(hObject, eventdata, handles)
0216 % [EOF] menuOpenASCII_Callback
0217 
0218 % --------------------------------------------------------------------
0219 function menuOpenMAT_Callback(hObject, eventdata, handles)
0220 
0221 % Get the Application data:
0222 % -------------------------
0223 guiparams = getappdata(handles.figure1,'guiparams');
0224 guiprefs = getappdata(handles.figure1,'guiprefs');
0225 
0226 % Ask the user to select files:
0227 % -----------------------------
0228 % current_file = fullfile(guiparams.data_folder,guiparams.data_files{1});
0229 % current_file = fullfile(guiprefs.mat_path,guiprefs.mat_file);
0230 if iscell(guiprefs.mat_file)
0231     uifile = fullfile(guiprefs.mat_path,guiprefs.mat_file{1});
0232 else
0233     uifile = fullfile(guiprefs.mat_path,guiprefs.mat_file);
0234 end
0235 [filename,pathname] = ...
0236     uigetfile({'*.mat','MAT-files (*.mat)'}, ...
0237     'Select MAT File', ...
0238     uifile, 'MultiSelect','on');
0239 
0240 if ischar(filename) % Single MAT file loaded
0241     % Load the data:
0242     % --------------
0243     vars = load(fullfile(pathname,filename));
0244     
0245     % Make sure the selected file is a valid file:
0246     % --------------------------------------------
0247     varnames = fieldnames(vars);
0248     if isequal(sort(varnames),{'A' 'Map' 'V' 'z'}')
0249         guiparams.mat_path = pathname;
0250         guiparams.mat_file = filename;
0251         guiparams.z = vars.z;
0252         guiparams.A = vars.A;
0253         guiparams.V = vars.V;
0254         
0255         % Update the preferences:
0256         % -----------------------
0257         guiprefs = getappdata(handles.figure1,'guiprefs');
0258         guiprefs.mat_path = pathname;
0259         guiprefs.mat_file = filename;
0260         setappdata(handles.figure1,'guiprefs',guiprefs)
0261         store_prefs(handles.figure1,'mat')
0262                      
0263         % Re-store the Application Data:
0264         % ------------------------------
0265         setappdata(handles.figure1,'guiparams',guiparams)
0266         
0267         % Update the GUI:
0268         % ---------------
0269         set_enable(handles,'fileloaded')
0270     else % Not a valid file
0271         errordlg('The selected file is not a valid ADCP data MAT file.', ...
0272             'Invalid File...')
0273     end
0274     
0275 elseif iscell(filename) % Multiple MAT files loaded
0276     % Set the filenames
0277     % -----------------
0278     guiparams.mat_path = pathname;
0279     guiparams.mat_file = filename;
0280     
0281     % Push status to log window
0282     % -------------------------
0283     log_text = {...
0284         'Loading previously processed MAT files.';...
0285         'Directory:'};
0286     log_text = vertcat(log_text, pathname, {'Files:'}, filename');
0287     statusLogging(handles.LogWindow,log_text)
0288     
0289     % Update the Application Data:
0290     % ------------------------------
0291     setappdata(handles.figure1,'guiparams',guiparams)
0292     
0293     % Update the persistent preferences:
0294     % ----------------------------------
0295     guiprefs = getappdata(handles.figure1,'guiprefs');
0296     guiprefs.mat_path = pathname;
0297     guiprefs.mat_file = filename;
0298     setappdata(handles.figure1,'guiprefs',guiprefs)
0299     store_prefs(handles.figure1,'mat')
0300         
0301     % Update the GUI:
0302     % ---------------
0303     set_enable(handles,'multiplematfiles')
0304 end
0305 
0306 % [EOF] menuOpenMAT_Callback
0307 
0308 % --------------------------------------------------------------------
0309 function menuSave_Callback(hObject, eventdata, handles)
0310 % Empty
0311 
0312 % --------------------------------------------------------------------
0313 function menuSaveMAT_Callback(hObject, eventdata, handles)
0314 saveDataCallback(hObject, eventdata, handles)
0315 % [EOF] menuSaveMAT_Callback
0316 
0317 % --------------------------------------------------------------------
0318 function menuSaveTecplot_Callback(hObject, eventdata, handles)
0319 SaveTecplotFile_Callback(handles,eventdata,handles)
0320 % [EOF] menuSaveTecplot_Callback
0321 
0322 % --------------------------------------------------------------------
0323 function menuSaveKMZFile_Callback(hObject, eventdata, handles)
0324 SaveGoogleEarthFile_Callback(handles,eventdata,handles)
0325 % [EOF] menuSaveKMZFile_Callback
0326 
0327 % --------------------------------------------------------------------
0328 function menuExport_Callback(hObject, eventdata, handles)
0329 % Empty
0330 
0331 % --------------------------------------------------------------------
0332 function menuFigureExportsettings_Callback(hObject, eventdata, handles)
0333 % Empty
0334 
0335 % --------------------------------------------------------------------
0336 function menuPrintFormat_Callback(hObject, eventdata, handles)
0337 
0338 % Get the Application Data:
0339 % -------------------------
0340 guiparams = getappdata(handles.figure1,'guiparams');
0341 
0342 % Update the Application Data:
0343 % ----------------------------
0344 guiparams.print        = true;
0345 guiparams.presentation = false;
0346 
0347 % Re-store the Application data:
0348 % ------------------------------
0349 setappdata(handles.figure1,'guiparams',guiparams)
0350 
0351 % Update the GUI:
0352 % ---------------
0353 set(handles.menuPrintFormat,       'Checked','on')
0354 set(handles.menuPresentationFormat,'Checked','off')
0355 
0356 % [EOF] menuPrintFormat_Callback
0357 
0358 
0359 % --------------------------------------------------------------------
0360 function menuPresentationFormat_Callback(hObject, eventdata, handles)
0361 
0362 % Get the Application Data:
0363 % -------------------------
0364 guiparams = getappdata(handles.figure1,'guiparams');
0365 
0366 % Update the Application Data:
0367 % ----------------------------
0368 guiparams.print        = false;
0369 guiparams.presentation = true;
0370 
0371 % Re-store the Application data:
0372 % ------------------------------
0373 setappdata(handles.figure1,'guiparams',guiparams)
0374 
0375 % Update the GUI:
0376 % ---------------
0377 set(handles.menuPrintFormat,       'Checked','off')
0378 set(handles.menuPresentationFormat,'Checked','on')
0379 
0380 % [EOF] menuPresentationFormat_Callback
0381 
0382 % --------------------------------------------------------------------
0383 function menuExportFigures_Callback(hObject, eventdata, handles)
0384 % Get the Application data:
0385 % -------------------------
0386 guiparams = getappdata(handles.figure1,'guiparams');
0387 guiprefs  = getappdata(handles.figure1,'guiprefs');
0388 
0389 % Find what plots exist already
0390 fig_handles = findobj('type','figure');
0391 fig_names   = get(fig_handles,'name');
0392 
0393 % Remove the VMT GUI as a valid figure in the list
0394 [~, idx] = ismember({get(handles.figure1,'Name'),'VMT_GraphicsControl'}, fig_names);
0395 if ~isempty(idx)
0396     fig_names(idx) = [];
0397 end
0398 
0399 if guiparams.presentation
0400     figure_style = 'presentation';
0401 else
0402     figure_style = 'print';
0403 end
0404 
0405 [selected_figures] = openFiguresDialog(fig_names,handles.figure1);
0406 
0407 if isempty(selected_figures) % User pressed cancel
0408     return
0409 else
0410     for i = 1:length(selected_figures)
0411         VMT_SaveFigs(guiprefs.mat_path,selected_figures(i),figure_style)
0412     end
0413 end
0414 
0415 
0416 % [EOF] menuExportFigures_Callback
0417 
0418 % --------------------------------------------------------------------
0419 function menuBathymetryExportSettings_Callback(hObject, eventdata, handles)
0420 % Get the Application data:
0421 % -------------------------
0422 guiparams              = getappdata(handles.figure1,'guiparams');
0423 beam_angle             = guiparams.beam_angle; 
0424 magnetic_variation     = guiparams.magnetic_variation; 
0425 wse                    = guiparams.wse;
0426 output_auxiliary_data = guiparams.output_auxiliary_data; 
0427 
0428 % Open dialog and allow user to select settings
0429 % ---------------------------------------------
0430 [beam_angle,...
0431     magnetic_variation,...
0432     wse,...
0433     output_auxiliary_data] = ...
0434     exportSettingsDialog(beam_angle,magnetic_variation,wse,output_auxiliary_data,handles.figure1);
0435 
0436 % Re-store the Application data:
0437 % ------------------------------
0438 guiparams.beam_angle            = beam_angle;
0439 guiparams.magnetic_variation    = magnetic_variation; 
0440 guiparams.wse                   = wse;
0441 guiparams.output_auxiliary_data = output_auxiliary_data;
0442 setappdata(handles.figure1,'guiparams',guiparams)
0443 
0444 % [EOF] menuExportSettings_Callback
0445 
0446 % --------------------------------------------------------------------
0447 function menuExportMultibeamBathymetry_Callback(hObject, eventdata, handles)
0448 ExportMultibeamBathymetry_Callback(hObject, eventdata, handles);
0449 % [EOF] menuExportMultibeamBathymetry_Callback
0450 
0451 
0452 % --------------------------------------------------------------------
0453 function menuSaveANVFile_Callback(hObject, eventdata, handles)
0454 
0455 % Get the Application Data:
0456 % -------------------------
0457 guiparams = getappdata(handles.figure1,'guiparams');
0458 guiprefs  = getappdata(handles.figure1,'guiprefs');
0459 PVdata    = guiparams.iric_anv_planview_data;
0460 iric_path = guiprefs.iric_path;
0461 iric_file = guiprefs.iric_file;
0462 
0463 % Is there any planview data?
0464 if isempty(PVdata)
0465     % Nothing to do, warn user
0466     log_text = {'No planview plot data to export. User must Plot Plan View first.'};
0467     warndlg(log_text{:},'Nothing to export')
0468 else
0469     % Save the planview data as output and to an *.anv file with spacing
0470     % and smoothing (for iRiC)
0471     log_text = {'Exporting iRic formated ANV vector file...'};
0472     [iric_file,iric_path] = uiputfile('*.anv','Save *.anv file',...
0473         fullfile(iric_path,iric_file));
0474     
0475     if ischar(iric_path) % The user did not hit "Cancel"
0476         outfile = fullfile(iric_path,iric_file);
0477         log_text = vertcat(log_text,{outfile});
0478         ofid   = fopen(outfile, 'wt');
0479         outcount = fprintf(ofid,...
0480             '%8.2f  %8.2f  %5.2f  %3.3f  %3.3f\n',PVdata.outmat);
0481         fclose(ofid);
0482     else
0483         % Return default iric_path and iric_file
0484         iric_path = guiprefs.iric_path;
0485         iric_file = guiprefs.iric_file;
0486     end
0487 end
0488 
0489 % Push messages to Log Window:
0490 % ----------------------------
0491 statusLogging(handles.LogWindow, log_text)
0492 
0493 % Store the persistent preferences:
0494 % ---------------------------------
0495 guiprefs.iric_file = iric_file;
0496 guiprefs.iric_path = iric_path;
0497 setappdata(handles.figure1,'guiprefs',guiprefs)
0498 store_prefs(handles.figure1,'iric')
0499 
0500 % [EOF] menuSaveANVFile_Callback
0501 
0502 % --------------------------------------------------------------------
0503 function menuSaveExcel_Callback(hObject, eventdata, handles)
0504 % Get the Application Data:
0505 % -------------------------
0506 guiparams   = getappdata(handles.figure1,'guiparams');
0507 guiprefs    = getappdata(handles.figure1,'guiprefs');
0508 excel_path  = guiprefs.excel_path;
0509 excel_file  = guiprefs.excel_file;
0510 
0511 % Push messages to Log Window:
0512 % ----------------------------
0513 log_text = {'Exporting Excel File (reprocessing dataset; this will create new plots)'};
0514 statusLogging(handles.LogWindow, log_text)
0515 
0516 % If there are multiple MAT files loaded, go ahead and export just the DAV
0517 % data.
0518 if iscell(guiparams.mat_file)
0519     % Force VMT to reprocess before outputing Excel
0520     planviewPlotCallback(hObject, eventdata, handles)
0521     % Refresh the Application Data:
0522     guiparams   = getappdata(handles.figure1,'guiparams');
0523     z           = guiparams.z;
0524     A           = guiparams.A;
0525     V           = guiparams.V;
0526     Map         = guiparams.Map;
0527     wse         = guiparams.wse;
0528     PVdata      = guiparams.iric_anv_planview_data;
0529     log_text = {'Writing data to Excel file...';...
0530         'Multiple transected loaded. Will export Planview Data Only!'};
0531     [excel_file,excel_path] = uiputfile('*.xlsx','Save *.xlsx file',...
0532         fullfile(excel_path,excel_file));
0533     
0534     if ischar(excel_path) % The user did not hit "Cancel"
0535         outfile = fullfile(excel_path,excel_file);
0536         %log_text = vertcat(log_text,{outfile});
0537         
0538     else
0539         % Return default excel_path and excel_file
0540         excel_path = guiprefs.excel_path;
0541         excel_file = guiprefs.excel_file;
0542         outfile = fullfile(excel_path,excel_file);
0543         %log_text = vertcat(log_text,{outfile});
0544     end
0545     
0546     % Delete the old file if it exists
0547     if exist(outfile, 'file') == 2
0548         log_text = vertcat(log_text,{'Warning: The file';...
0549             ['   ' outfile];...
0550             'already exists. Overwriting file...'});
0551         delete(outfile)
0552     end
0553     
0554     % Save DAV data to an Excel File
0555     hwait = waitbar(0,'Exporting Excel File...');
0556     vmin = num2str(guiparams.depth_range_min);
0557     vmax = num2str(guiparams.depth_range_max);
0558     pvheaders = {...
0559         'UTM_East' 'UTM_North' 'Elev_m'...
0560         ['EastDAV_cm/s, dpth rng ' vmin ' to ' vmax ' m']...
0561         ['NorthDAV_cm/s, dpth rng ' vmin ' to ' vmax ' m']};
0562     PVdata.outmat(4:5,:) = PVdata.outmat(4:5,:).*100; % velocities in cm/s
0563     pvdata = num2cell(PVdata.outmat');
0564     pvout = vertcat(pvheaders,pvdata);
0565     xlswrite(outfile,pvout,'Planview');
0566     waitbar(1,hwait)
0567     delete(hwait)
0568     
0569     % Push messages to Log Window:
0570     % ----------------------------
0571     statusLogging(handles.LogWindow, log_text)
0572 else
0573     
0574     % Force VMT to reprocess before outputing Excel
0575     planviewPlotCallback(hObject, eventdata, handles)
0576     crosssectionPlotCallback(hObject, eventdata, handles)
0577     % Refresh the Application Data:
0578     guiparams   = getappdata(handles.figure1,'guiparams');
0579     z           = guiparams.z;
0580     A           = guiparams.A;
0581     V           = guiparams.V;
0582     Map         = guiparams.Map;
0583     wse         = guiparams.wse;
0584     PVdata      = guiparams.iric_anv_planview_data;
0585     
0586     
0587     log_text = {'Writing data to Excel file...'};
0588     [excel_file,excel_path] = uiputfile('*.xlsx','Save *.xlsx file',...
0589         fullfile(excel_path,excel_file));
0590     
0591     if ischar(excel_path) % The user did not hit "Cancel"
0592         outfile = fullfile(excel_path,excel_file);
0593         %log_text = vertcat(log_text,{outfile});
0594         
0595         % Delete the old file if it exists
0596         if exist(outfile, 'file') == 2
0597             log_text = vertcat(log_text,{'Warning: The file';...
0598                 ['   ' outfile];...
0599                 'already exists. Overwriting file...'});
0600             delete(outfile)
0601         end
0602         
0603         % Push messages to Log Window:
0604         % ----------------------------
0605         statusLogging(handles.LogWindow, log_text)
0606         
0607         % Save MCS Summary to an Excel File
0608         hwait = waitbar(0,'Exporting Excel File...');
0609         xlswrite(outfile,{'Files:'},'VMTSummary','H4'); waitbar(1/5,hwait)
0610         sout = guiparams.data_files';
0611         xlswrite(outfile,sout,'VMTSummary','I4'); waitbar(2/5,hwait)
0612         sout = {...
0613             'VMT: Summary of Mean Cross Section' '' '' '' '' '';...
0614             'VMT ' guiparams.vmt_version '' '' '' '';...
0615             'Date Processed: ' datestr(now) '' '' '' '';...
0616             '' '' '' '' '' '';...
0617             'Mean Cross Section (MCS) Properties' '' '' '' '' '';...
0618             'Horz. Grid Node Spacing (m):' '' '' '' '' guiparams.horizontal_grid_node_spacing;...
0619             'Vert. Grid Node Spacing (m):' '' '' '' '' single(guiparams.A(1).Sup.binSize_cm)/100;...
0620             'Endpoints:' '' '' '' 'UTM_East'    'UTM_North';...
0621             'Left Bank'    '' '' ''    V.xLeftBank V.yLeftBank;...
0622             'Right Bank'    '' '' ''    V.xRightBank V.yRightBank;...
0623             'Total Length in meters' '' '' '' '' V.dl;...
0624             '' '' '' '' '' '';...
0625             'Mean Flow Direction (deg)' '' '' '' '' V.mfd;...
0626             'in geographic coordinates' '' '' '' '' '';...
0627             '' '' '' '' '' '';...
0628             'Slope'    '' '' '' '' V.m;...
0629             'Intercept'    '' '' '' '' V.b;...
0630             'Theta (deg)'    '' '' '' '' V.theta};
0631         xlswrite(outfile,sout,'VMTSummary','A1'); waitbar(3/5,hwait)
0632         
0633         % Save DAV data to an Excel File
0634         vmin = num2str(guiparams.depth_range_min);
0635         vmax = num2str(guiparams.depth_range_max);
0636         pvheaders = {...
0637             'UTM_East' 'UTM_North' 'Elev_m'...
0638             ['EastDAV_cm/s, dpth rng ' vmin ' to ' vmax ' m']...
0639             ['NorthDAV_cm/s, dpth rng ' vmin ' to ' vmax ' m']};
0640         PVdata.outmat(4:5,:) = PVdata.outmat(4:5,:).*100; % velocities in cm/s
0641         pvdata = num2cell(PVdata.outmat');
0642         pvout = vertcat(pvheaders,pvdata);
0643         xlswrite(outfile,pvout,'Planview');
0644         waitbar(4/5,hwait)
0645         
0646         % Save MCS data to an Excel File
0647         mcsheaders = {...
0648             'UTM_East' ...
0649             'UTM_North'...
0650             'Distance from Left Bank, in meters'...
0651             'Elevation, in meters'...
0652             'Bed Elevation, in meters'...
0653             'East Velocity, in cm/s'...
0654             'North Velocity, in cm/s'...
0655             'Vertical Velocity, in cm/s'...
0656             'Velocity Magnitude, in cm/s'...
0657             'Velocity Direction, in degrees (geographic coordinates)'...
0658             'Streamwise Velocity, in cm/s'...
0659             'Transverse Velocity, in cm/s'...
0660             'Primary Velocity (zsd), in cm/s'...
0661             'Secondary Velocity (zsd), in cm/s'...
0662             'Primary Velocity (roz), in cm/s'...
0663             'Secondary Velocity (roz), in cm/s'};
0664         
0665         mcsdata = [...
0666             V.mcsX(:)...
0667             V.mcsY(:)...
0668             V.mcsDist(:)...
0669             (wse - V.mcsDepth(:))...
0670             repmat((wse - V.mcsBed(:)),size(V.mcsX,1),1)...
0671             V.mcsEast(:)...
0672             V.mcsNorth(:)...
0673             V.mcsVert(:)...
0674             V.mcsMag(:)...
0675             V.mcsDir(:)...
0676             V.u(:)...
0677             V.v(:)...
0678             V.vp(:)...
0679             V.vs(:)...
0680             V.Roz.up(:)...
0681             V.Roz.us(:)];
0682         mcsdata(isnan(mcsdata)) = -9999;
0683         
0684         mcsout = vertcat(mcsheaders,num2cell(mcsdata));
0685         xlswrite(outfile,mcsout,'MeanCrossSection');
0686         waitbar(1,hwait)
0687         delete(hwait)
0688         
0689     else
0690         % Return default excel_path and excel_file
0691         excel_path = guiprefs.excel_path;
0692         excel_file = guiprefs.excel_file;
0693         outfile = fullfile(excel_path,excel_file);
0694         log_text = {'User aborted Excel export...'};
0695     end
0696     
0697     
0698     
0699 end
0700 
0701 % Push messages to Log Window:
0702 % ----------------------------
0703 statusLogging(handles.LogWindow, log_text)
0704 
0705 % Store the persistent preferences:
0706 % ---------------------------------
0707 guiprefs.excel_file = excel_file;
0708 guiprefs.excel_path = excel_path;
0709 setappdata(handles.figure1,'guiprefs',guiprefs)
0710 store_prefs(handles.figure1,'excel')
0711 
0712 % [EOF] menuSaveExcel_Callback
0713 
0714 % --------------------------------------------------------------------
0715 function menuParameters_Callback(hObject, eventdata, handles)
0716 % Empty
0717 
0718 % --------------------------------------------------------------------
0719 function menuProcessingParameters_Callback(hObject, eventdata, handles)
0720 % Empty
0721 
0722 % --------------------------------------------------------------------
0723 function menuUnitDischargeCorrection_Callback(hObject, eventdata, handles)
0724 % Turn ON or OFF Unit Discharge Correction
0725 
0726 % Get the Application Data:
0727 % -------------------------
0728 guiparams = getappdata(handles.figure1,'guiparams');
0729 
0730 % Update the GUI & Application Data:
0731 % ----------------------------------
0732 status = get(handles.menuUnitDischargeCorrection,'Checked');
0733 switch status
0734     case 'on' % Turn it off
0735         set(handles.menuUnitDischargeCorrection, 'Checked','off')
0736         guiparams.unit_discharge_correction = false;
0737     case 'off' % Turn it on
0738         set(handles.menuUnitDischargeCorrection, 'Checked','on')
0739         guiparams.unit_discharge_correction = true;
0740 end
0741 
0742 % Re-store the Application data:
0743 % ------------------------------
0744 setappdata(handles.figure1,'guiparams',guiparams)
0745 
0746 
0747 %  [EOF] menuUnitDischargeCorrection_Callback
0748 
0749 % --------------------------------------------------------------------
0750 function menuPlottingParameters_Callback(hObject, eventdata, handles)
0751 % Empty
0752 
0753 % --------------------------------------------------------------------
0754 function menuUnits_Callback(hObject, eventdata, handles)
0755 % Empty
0756 
0757 % --------------------------------------------------------------------
0758 function menuMetric_Callback(hObject, eventdata, handles)
0759 % Set the Plotting Parameter Units to "metric"
0760 
0761 % Get the Application Data:
0762 % -------------------------
0763 guiparams = getappdata(handles.figure1,'guiparams');
0764 
0765 % Update the Application Data:
0766 % ----------------------------
0767 guiparams.english_units = false;
0768 
0769 % Re-store the Application data:
0770 % ------------------------------
0771 setappdata(handles.figure1,'guiparams',guiparams)
0772 
0773 % Update the GUI:
0774 % ---------------
0775 set(handles.menuMetric, 'Checked','on')
0776 set(handles.menuEnglish,'Checked','off')
0777 
0778 % [EOF] menuMetric_Callback
0779 
0780 
0781 % --------------------------------------------------------------------
0782 function menuEnglish_Callback(hObject, eventdata, handles)
0783 % Set the Plotting Parameter Units to "english"
0784 
0785 % Get the Application Data:
0786 % -------------------------
0787 guiparams = getappdata(handles.figure1,'guiparams');
0788 
0789 % Update the Application Data:
0790 % ----------------------------
0791 guiparams.english_units = true;
0792 
0793 % Re-store the Application data:
0794 % ------------------------------
0795 setappdata(handles.figure1,'guiparams',guiparams)
0796 
0797 % Update the GUI:
0798 % ---------------
0799 set(handles.menuMetric, 'Checked','off')
0800 set(handles.menuEnglish,'Checked','on')
0801 
0802 % [EOF] menuEnglish_Callback
0803 
0804 
0805 % --------------------------------------------------------------------
0806 function menuSetCrossSectionEndpoints_Callback(hObject, eventdata, handles)
0807 % Empty
0808 
0809 % --------------------------------------------------------------------
0810 function menuCrossSectionEndpointAutomatic_Callback(hObject, eventdata, handles)
0811 % Set cross-section endpoints automatically
0812 
0813 % Get the Application Data:
0814 % -------------------------
0815 guiparams = getappdata(handles.figure1,'guiparams');
0816 
0817 % Update the Application Data:
0818 % ----------------------------
0819 guiparams.set_cross_section_endpoints = false;
0820 
0821 % Re-store the Application data:
0822 % ------------------------------
0823 setappdata(handles.figure1,'guiparams',guiparams)
0824 
0825 % Update the GUI:
0826 % ---------------
0827 set(handles.menuCrossSectionEndpointAutomatic, 'Checked','on')
0828 set(handles.menuCrossSectionEndpointManual,    'Checked','off')
0829 
0830 % [EOF] menuCrossSectionEndpointAutomatic_Callback
0831 
0832 
0833 % --------------------------------------------------------------------
0834 function menuCrossSectionEndpointManual_Callback(hObject, eventdata, handles)
0835 % Set cross-section endpoints manually
0836 
0837 % Get the Application Data:
0838 % -------------------------
0839 guiparams = getappdata(handles.figure1,'guiparams');
0840 
0841 % Update the Application Data:
0842 % ----------------------------
0843 guiparams.set_cross_section_endpoints = true;
0844 
0845 % Re-store the Application data:
0846 % ------------------------------
0847 setappdata(handles.figure1,'guiparams',guiparams)
0848 
0849 % Update the GUI:
0850 % ---------------
0851 set(handles.menuCrossSectionEndpointAutomatic, 'Checked','off')
0852 set(handles.menuCrossSectionEndpointManual,    'Checked','on')
0853 
0854 % [EOF] menuCrossSectionEndpointManual_Callback
0855 
0856 
0857 
0858 
0859 % --------------------------------------------------------------------
0860 function menuPlotStyle_Callback(hObject, eventdata, handles)
0861 % Empty
0862 
0863 % --------------------------------------------------------------------
0864 function menuStylePrint_Callback(hObject, eventdata, handles)
0865 
0866 % Get the Application Data:
0867 % -------------------------
0868 guiparams = getappdata(handles.figure1,'guiparams');
0869 
0870 % Update the Application Data:
0871 % ----------------------------
0872 guiparams.print        = true;
0873 guiparams.presentation = false;
0874 
0875 % Re-store the Application data:
0876 % ------------------------------
0877 setappdata(handles.figure1,'guiparams',guiparams)
0878 
0879 % Update the GUI:
0880 % ---------------
0881 set(handles.menuStylePrint,        'Checked','on')
0882 set(handles.menuStylePresentation, 'Checked','off')
0883 set(handles.menuPrintFormat,       'Checked','on')
0884 set(handles.menuPresentationFormat,'Checked','off')
0885 
0886 % Modify the existing figures
0887 % ---------------------------
0888 % Find what plots exist already
0889 hf = findobj('type','figure');
0890 valid_names = {'Plan View Map'; 'Mean Cross Section Contour'};
0891 
0892 % Defaults for Print Stlye Figure
0893 BkgdColor   = 'white';
0894 AxColor     = 'black';
0895 FigColor    = 'white'; % [0.3 0.3 0.3]
0896 FntSize     = 14;
0897 
0898 % Loop through valid figures and adjust
0899 % -------------------------------------
0900 if ~isempty(hf) &&  any(ishandle(hf))
0901     
0902     for i = 1:length(valid_names)
0903         switch valid_names{i}
0904             case 'Plan View Map'
0905                 % Focus the figure
0906                 hff = findobj('name','Plan View Map');
0907                 if ~isempty(hff) &&  ishandle(hff)
0908                     figure(hff)
0909                     
0910                     % Make the changes to figure
0911                     set(gcf,'Color',BkgdColor);
0912                     set(gca,'FontSize',FntSize)
0913                     set(get(gca,'Title'),'FontSize',FntSize)
0914                     set(gca,'Color',FigColor)
0915                     set(gca,'XColor',AxColor)
0916                     set(gca,'YColor',AxColor)
0917                     set(gca,'ZColor',AxColor)
0918                     set(findobj(gcf,'tag','Colorbar'),'FontSize',FntSize,'XColor',AxColor,'YColor',AxColor);
0919                     set(get(gca,'Title'),'FontSize',FntSize,'Color',AxColor)
0920                     set(get(gca,'xLabel'),'FontSize',FntSize,'Color',AxColor)
0921                     set(get(gca,'yLabel'),'FontSize',FntSize,'Color',AxColor)
0922                 end
0923             case 'Mean Cross Section Contour'
0924                 % Focus the figure
0925                 hff = findobj('name','Mean Cross Section Contour');
0926                 if ~isempty(hff) &&  ishandle(hff)
0927                     figure(hff)
0928                     
0929                     % Make the changes to figure
0930                     set(gcf,'Color',BkgdColor);
0931                     set(gca,'FontSize',FntSize)
0932                     set(get(gca,'Title'),'FontSize',FntSize)
0933                     set(gca,'Color',FigColor)
0934                     set(gca,'XColor',AxColor)
0935                     set(gca,'YColor',AxColor)
0936                     set(gca,'ZColor',AxColor)
0937                     set(findobj(gcf,'tag','Colorbar'),'FontSize',FntSize,'XColor',AxColor,'YColor',AxColor);
0938                     set(get(gca,'Title'),'FontSize',FntSize,'Color',AxColor)
0939                     set(get(gca,'xLabel'),'FontSize',FntSize,'Color',AxColor)
0940                     set(get(gca,'yLabel'),'FontSize',FntSize,'Color',AxColor)
0941                     set(findobj(gca,'tag','PlotBedElevation')   ,'color'    ,AxColor)
0942                     set(findobj(gca,'tag','ReferenceVectorText'),'color'    ,AxColor)
0943                 end
0944             otherwise
0945         end
0946     end
0947     
0948     
0949 end
0950 
0951 
0952 %[EOF] menuStylePrint_Callback
0953 
0954 
0955 % --------------------------------------------------------------------
0956 function menuStylePresentation_Callback(hObject, eventdata, handles)
0957 % Get the Application Data:
0958 % -------------------------
0959 guiparams = getappdata(handles.figure1,'guiparams');
0960 
0961 % Update the Application Data:
0962 % ----------------------------
0963 guiparams.print        = false;
0964 guiparams.presentation = true;
0965 
0966 % Re-store the Application data:
0967 % ------------------------------
0968 setappdata(handles.figure1,'guiparams',guiparams)
0969 
0970 % Update the GUI:
0971 % ---------------
0972 set(handles.menuStylePrint,        'Checked','off')
0973 set(handles.menuStylePresentation, 'Checked','on')
0974 set(handles.menuPrintFormat,       'Checked','off')
0975 set(handles.menuPresentationFormat,'Checked','on')
0976 
0977 % Modify the existing figures
0978 % ---------------------------
0979 % Find what plots exist already
0980 hf = findobj('type','figure');
0981 valid_names = {'Plan View Map'; 'Mean Cross Section Contour'};
0982 
0983 % Defaults for Presentation Stlye Figure
0984 % --------------------------------------
0985 BkgdColor   = 'black';
0986 AxColor     = 'white';
0987 FigColor    = 'black'; % [0.3 0.3 0.3]
0988 FntSize     = 14;
0989 
0990 % Loop through valid figures and adjust
0991 % -------------------------------------
0992 if ~isempty(hf) &&  any(ishandle(hf))
0993     
0994     for i = 1:length(valid_names)
0995         switch valid_names{i}
0996             case 'Plan View Map'
0997                 % Focus the figure
0998                 hff = findobj('name','Plan View Map');
0999                 if ~isempty(hff) &&  ishandle(hff)
1000                     figure(hff)
1001                     
1002                     % Make the changes to figure
1003                     set(gcf,'Color',BkgdColor);
1004                     set(gca,'FontSize',FntSize)
1005                     set(get(gca,'Title'),'FontSize',FntSize)
1006                     set(gca,'Color',FigColor)
1007                     set(gca,'XColor',AxColor)
1008                     set(gca,'YColor',AxColor)
1009                     set(gca,'ZColor',AxColor)
1010                     set(findobj(gcf,'tag','Colorbar'),'FontSize',FntSize,'XColor',AxColor,'YColor',AxColor);
1011                     set(get(gca,'Title'),'FontSize',FntSize,'Color',AxColor)
1012                     set(get(gca,'xLabel'),'FontSize',FntSize,'Color',AxColor)
1013                     set(get(gca,'yLabel'),'FontSize',FntSize,'Color',AxColor)
1014                 end
1015             case 'Mean Cross Section Contour'
1016                 % Focus the figure
1017                 hff = findobj('name','Mean Cross Section Contour');
1018                 if ~isempty(hff) &&  ishandle(hff)
1019                     figure(hff)
1020                     
1021                     % Make the changes to figure
1022                     set(gcf,'Color',BkgdColor);
1023                     set(gca,'FontSize',FntSize)
1024                     set(get(gca,'Title'),'FontSize',FntSize)
1025                     set(gca,'Color',[0.3 0.3 0.3]) %FigColor)
1026                     set(gca,'XColor',AxColor)
1027                     set(gca,'YColor',AxColor)
1028                     set(gca,'ZColor',AxColor)
1029                     set(findobj(gcf,'tag','Colorbar'),'FontSize',FntSize,'XColor',AxColor,'YColor',AxColor);
1030                     set(get(gca,'Title'),'FontSize',FntSize,'Color',AxColor)
1031                     set(get(gca,'xLabel'),'FontSize',FntSize,'Color',AxColor)
1032                     set(get(gca,'yLabel'),'FontSize',FntSize,'Color',AxColor)
1033                     set(findobj(gca,'tag','PlotBedElevation')   ,'color'    ,AxColor)
1034                     set(findobj(gca,'tag','ReferenceVectorText'),'color'    ,AxColor)
1035                 end
1036             otherwise
1037         end
1038     end
1039     
1040     
1041 end
1042 
1043 % [EOF] menuStylePresentation_Callback
1044 
1045 % --------------------------------------------------------------------
1046 function menuKMZExport_Callback(hObject, eventdata, handles)
1047 
1048 % Get the Application data:
1049 % -------------------------
1050 guiparams = getappdata(handles.figure1,'guiparams');
1051 
1052 % Initialize the answer:
1053 % ----------------------
1054 numstr = {num2str(guiparams.vertical_offset)};
1055 answer = NaN;
1056 while isnan(answer)
1057     answer = inputdlg('Vertical Offset (m)','KMZ Export',1,numstr);
1058     
1059     if isempty(answer) % User hits "Cancel"
1060         return
1061     end
1062     
1063     answer = str2double(answer); % A non-numeric char will be NaN
1064     % A numeric char will be a double
1065 end
1066 
1067 % Re-store the Application data:
1068 % ------------------------------
1069 guiparams.vertical_offset = answer;
1070 setappdata(handles.figure1,'guiparams',guiparams)
1071 
1072 % [EOF] menuKMZExport_Callback
1073 
1074 % --------------------------------------------------------------------
1075 function menuBathymetryParameters_Callback(hObject, eventdata, handles)
1076 % Not implemented
1077 
1078 % --------------------------------------------------------------------
1079 function menuTools_Callback(hObject, eventdata, handles)
1080 % Empty
1081 
1082 % --------------------------------------------------------------------
1083 function menuASCII2GIS_Callback(hObject, eventdata, handles)
1084 ASCII2GIS_GUI
1085 % [EOF] menuASCII2GIS_Callback
1086 
1087 % --------------------------------------------------------------------
1088 function menuASCII2KML_Callback(hObject, eventdata, handles)
1089 
1090 % Get the Application preferences:
1091 % --------------------------------
1092 guiprefs  = getappdata(handles.figure1,'guiprefs');
1093 
1094 inpath = guiprefs.kmz_path;
1095 if iscell(guiprefs.kmz_file)
1096     infile = guiprefs.kmz_file{1};
1097 else
1098     infile = guiprefs.kmz_file;
1099 end
1100 [log_text,outpath,outfile] = ASCII2KML(inpath,infile);
1101 
1102 guiprefs.kmz_path = outpath;
1103 guiprefs.kmz_file = outfile;
1104 
1105 % Update persistent preferences
1106 % -----------------------------
1107 setappdata(handles.figure1,'guiprefs',guiprefs)
1108 
1109 % [EOF] menuASCII2KML_Callback
1110 
1111 % --------------------------------------------------------------------
1112 function menuHelp_Callback(hObject, eventdata, handles)
1113 % Empty
1114 
1115 % --------------------------------------------------------------------
1116 function menuUsersGuide_Callback(hObject, eventdata, handles)
1117 try
1118     web('http://code.google.com/p/velocity-mapping-tool/wiki/UserGuide?tm=6')
1119 catch err %#ok<NASGU>
1120     if isdeployed
1121         errLogFileName = fullfile(pwd,...
1122             ['errorLog' datestr(now,'yyyymmddHHMMSS') '.txt']);
1123         msgbox({['An unexpected error occurred. Error code: ' err.identifier];...
1124             ['Error details are being written to the following file: '];...
1125             errLogFileName},...
1126             'VMT Status: Unexpected Error',...
1127             'error');
1128         fid = fopen(errLogFileName,'W');
1129         fwrite(fid,err.getReport('extended','hyperlinks','off'));
1130         fclose(fid);
1131         rethrow(err)
1132     else
1133         msgbox(['An unexpected error occurred. Error code: ' err.identifier],...
1134             'VMT Status: Unexpected Error',...
1135             'error');
1136         rethrow(err);
1137     end
1138 end
1139 % [EOF] menuASCII2KML_Callback
1140 
1141 % --------------------------------------------------------------------
1142 function menuFunctionLibrary_Callback(hObject, eventdata, handles)
1143 % Get the Application data:
1144 % -------------------------
1145 % guiparams = getappdata(handles.figure1,'guiparams'); %#ok<NASGU>
1146 
1147 try
1148     % Construct a URL to a local file which can be interpreted by any
1149     % web-browser
1150     rootpath = strrep(pwd,filesep,'/');
1151     webaddress = ['file:///' rootpath '/doc/index.html'];
1152     system(['start ' webaddress]);
1153 %     [stat,h,url] = web(webaddress) % Produced with m2html (FEX)
1154 catch err 
1155     if isdeployed
1156         errLogFileName = fullfile(pwd,...
1157             ['errorLog' datestr(now,'yyyymmddHHMMSS') '.txt']);
1158         msgbox({['An unexpected error occurred. Error code: ' err.identifier];...
1159             ['Error details are being written to the following file: '];...
1160             errLogFileName},...
1161             'VMT Status: Unexpected Error',...
1162             'error');
1163         fid = fopen(errLogFileName,'W');
1164         fwrite(fid,err.getReport('extended','hyperlinks','off'));
1165         fclose(fid);
1166         rethrow(err)
1167     else
1168         msgbox(['An unexpected error occurred. Error code: ' err.identifier],...
1169             'VMT Status: Unexpected Error',...
1170             'error');
1171         rethrow(err);
1172     end
1173 end
1174 
1175 % [EOF] menuFunctionLibrary_Callback
1176 
1177 % --------------------------------------------------------------------
1178 function menuCheckForUpdates_Callback(hObject, eventdata, handles)
1179 
1180 % Get the Application data:
1181 % -------------------------
1182 guiparams = getappdata(handles.figure1,'guiparams');
1183 
1184 % Check version tag against the web, and display a message
1185 try
1186     current_vmt_version = urlread('http://hydroacoustics.usgs.gov/movingboat/VMT/VMT_version.txt');
1187     %     current_vmt_version = urlread('http://hydroacoustics.usgs.gov/movingboat/VMT/VMT_version.txt');
1188 catch err %#ok<NASGU>
1189     if isdeployed
1190         errLogFileName = fullfile(pwd,...
1191             ['errorLog' datestr(now,'yyyymmddHHMMSS') '.txt']);
1192         msgbox({['An unexpected error occurred. Error code: ' err.identifier];...
1193             ['Error details are being written to the following file: '];...
1194             errLogFileName},...
1195             'VMT Status: Unexpected Error',...
1196             'error');
1197         fid = fopen(errLogFileName,'W');
1198         fwrite(fid,err.getReport('extended','hyperlinks','off'));
1199         fclose(fid);
1200         rethrow(err)
1201     else
1202         msgbox(['An unexpected error occurred. Error code: ' err.identifier],...
1203             'VMT Status: Unexpected Error',...
1204             'error');
1205         rethrow(err);
1206     end
1207 end
1208 
1209 if strcmpi(guiparams.vmt_version,current_vmt_version)
1210     h = msgbox('VMT is currently up to date, no updates available.','Check for updates'); %#ok<NASGU>
1211 else
1212     h = msgbox('VMT is out of date. Please visit the VMT homepage.','Check for updates'); %#ok<NASGU>
1213 end
1214 % [EOF] menuCheckForUpdates_Callback
1215 
1216 % --------------------------------------------------------------------
1217 function menuAbout_Callback(hObject, eventdata, handles)
1218 
1219 % Get the Application data:
1220 % -------------------------
1221 guiparams = getappdata(handles.figure1,'guiparams');
1222 messagestr = ...
1223     {'The Velocity Mapping Toolbox';...
1224     ['   Version: ' guiparams.vmt_version];...
1225     '';...
1226     '';...
1227     'With collaborations from:';...
1228     '   U.S. Geological Survey';...
1229     '   University of Illinois';...
1230     '   University of Hull';...
1231     '';...
1232     '';...
1233     'Citation: ';...
1234     '   Parsons, D. R., Jackson, P. R., Czuba, J. A., Engel, F. L.,';...
1235     '   Rhoads, B. L., Oberg, K. A., Best, J. L., Mueller, D. S.,';...
1236     '   Johnson, K. K. and Riley, J. D. (2013), Velocity Mapping';...
1237     '   Toolbox (VMT): a processing and visualization suite for';...
1238     '   moving-vessel ADCP measurements. Earth Surf. Process.';...
1239     '   Landforms.doi: 10.1002/esp.3367'};
1240 h = msgbox(messagestr,'About VMT'); %#ok<NASGU>
1241 % [EOF] menuAbout_Callback
1242 
1243 
1244 
1245 
1246 %%%%%%%%%%%%%%%%%%%%%
1247 % TOOLBAR CALLBACKS %
1248 %%%%%%%%%%%%%%%%%%%%%
1249 
1250 % --------------------------------------------------------------------
1251 function loadDataCallback(hObject, eventdata, handles)
1252 % Read Files into Data Structure using tfile.
1253 
1254 % Get the Application data:
1255 % -------------------------
1256 guiparams = getappdata(handles.figure1,'guiparams');
1257 guiprefs = getappdata(handles.figure1,'guiprefs');
1258 
1259 % Ask the user to select files:
1260 % -----------------------------
1261 current_file = fullfile(guiprefs.ascii_path,guiprefs.ascii_file{1});
1262 [filename,pathname] = uigetfile({'*_ASC.TXT','ASCII (*_ASC.TXT)'}, ...
1263     'Select the ASCII Output Files', ...
1264     current_file, ...
1265     'MultiSelect','on');
1266 
1267 if ischar(pathname) % The user did not hit "Cancel"
1268     guiparams.data_folder = pathname;
1269     if ischar(filename)
1270         filename = {filename};
1271     end
1272     guiparams.data_files = filename;
1273     guiparams.mat_file = '';
1274     
1275     setappdata(handles.figure1,'guiparams',guiparams)
1276     
1277    
1278     
1279     % Update the preferences:
1280     % -----------------------
1281     guiprefs = getappdata(handles.figure1,'guiprefs');
1282     guiprefs.ascii_path = pathname;
1283     guiprefs.ascii_file = filename;
1284     setappdata(handles.figure1,'guiprefs',guiprefs)
1285     store_prefs(handles.figure1,'ascii')
1286     
1287     % Push messages to Log Window:
1288     % ----------------------------
1289     log_text = {...
1290         '';...
1291         ['%--- ' datestr(now) ' ---%'];...
1292         'Current Project Directory:';...
1293         guiparams.data_folder;
1294         'Loading the following files into memory:';...
1295         char(filename)};
1296     statusLogging(handles.LogWindow, log_text)
1297     
1298     % Read the file(s)
1299     % ----------------
1300     [~,~,savefile,A,z] = ...
1301         VMT_ReadFiles(guiparams.data_folder,guiparams.data_files);
1302     guiparams.savefile = savefile;
1303     guiparams.A        = A;
1304     guiparams.z        = z;
1305     setappdata(handles.figure1,'guiparams',guiparams)
1306 %
1307 %     % Preprocess the data:
1308 %     % --------------------
1309 %     A = VMT_PreProcess(z,A);
1310 %
1311 %     % Push messages to Log Window:
1312 %     % ----------------------------
1313 %     log_text = {...
1314 %         '   Preprocessing complete.';...
1315 %         '   Begin Data Processing...'};
1316 %     statusLogging(handles.LogWindow, log_text)
1317 %
1318 %     A(1).hgns = guiparams.horizontal_grid_node_spacing;
1319 %     A(1).wse  = guiparams.wse;  %Set the WSE to entered value
1320 %     [A,V,processing_log_text] = VMT_ProcessTransects(z,A,...
1321 %         guiparams.set_cross_section_endpoints,...
1322 %         guiparams.unit_discharge_correction);
1323 %
1324 %     % Push messages to Log Window:
1325 %     % ----------------------------
1326 %     statusLogging(handles.LogWindow, processing_log_text)
1327 %
1328 %     % Store the data:
1329 %     % ---------------
1330 %     guiparams.z = z;
1331 %     guiparams.A = A;
1332 %     guiparams.V = V;
1333 %     setappdata(handles.figure1,'guiparams',guiparams)
1334     
1335       
1336     % Update the GUI:
1337     % ---------------
1338     set_enable(handles,'fileloaded')
1339 end
1340 % [EOF] loadDataCallback
1341 
1342 
1343 
1344 % --------------------------------------------------------------------
1345 function saveDataCallback(hObject, eventdata, handles)
1346 % SaveMATFile_Callback(handles.SaveMATFile,eventdata,handles)
1347 
1348 % Get the Application data:
1349 % -------------------------
1350 guiparams = getappdata(handles.figure1,'guiparams');
1351 z   = guiparams.z;   %#ok<NASGU>
1352 A   = guiparams.A;   %#ok<NASGU>
1353 V   = guiparams.V;   %#ok<NASGU>
1354 Map = guiparams.Map; %#ok<NASGU>
1355 
1356 [the_file,the_path] = ...
1357     uiputfile({'*.mat','MAT-Files (*.mat)'}, ...
1358     'Save MAT-File', ...
1359     fullfile(guiparams.mat_path,guiparams.savefile));
1360 
1361 % Save the processed data to a MAT file:
1362 % --------------------------------------
1363 if ischar(the_file)
1364     guiparams.mat_path = the_path;
1365     guiparams.mat_file = the_file;
1366     guiparams.savefile = the_file;
1367     
1368     % Re-store the Application data:
1369     % ------------------------------
1370     setappdata(handles.figure1,'guiparams',guiparams)
1371     
1372     % Update the preferences:
1373     % -----------------------
1374     guiprefs = getappdata(handles.figure1,'guiprefs');
1375     guiprefs.mat_path = the_path;
1376     guiprefs.mat_file = the_file;
1377     setappdata(handles.figure1,'guiprefs',guiprefs)
1378     store_prefs(handles.figure1,'mat')
1379     
1380     [pathstr,filename,extension] = fileparts([guiparams.mat_path guiparams.savefile]);
1381     savefile = fullfile(pathstr,[filename extension]);
1382     %h = msgbox(['Saving processed data in MAT File ''' filename extension ''''], ...
1383     %    'Saving Processed Data File...'); %#ok<NASGU>
1384     log_text = {...
1385         'Saving Processed Data File...';...
1386         savefile};
1387     statusLogging(handles.LogWindow,log_text)
1388     save(savefile,'A','V','z','Map')
1389 end
1390 
1391 % [EOF] saveDataCallback
1392 
1393 
1394 % --------------------------------------------------------------------
1395 function saveBathymetryCallback(hObject, eventdata, handles)
1396 
1397 % Get the Application data:
1398 % -------------------------
1399 guiparams = getappdata(handles.figure1,'guiparams');
1400 z   = guiparams.z;
1401 A   = guiparams.A;
1402 % V   = guiparams.V;   %#ok<NASGU>
1403 % Map = guiparams.Map; %#ok<NASGU>
1404 
1405 % Compute multibeam bathymetry:
1406 % -----------------------------
1407 msgbox('Processing Bathymetry...Please Be Patient','VMT Status','help','replace')
1408 %A = VMT_MBBathy(z,A,savefile,handles.beam_angle,handles.MagneticVariation,handles.WSE);
1409 VMT_MBBathy(z,A,savefile, ...
1410     guiparams.beam_angle, ...
1411     guiparams.magnetic_variation, ...
1412     guiparams.wse, ...
1413     guiparams.output_auxiliary_data);
1414 
1415 msgbox('Bathymetry Output Complete','VMT Status','help','replace')
1416 
1417 % [EOF] saveBathymetryCallback
1418 
1419 % --------------------------------------------------------------------
1420 function plottingParametersCallback(hObject, eventdata, handles)
1421 
1422 % Get the Application data:
1423 % -------------------------
1424 guiparams = getappdata(handles.figure1,'guiparams');
1425 
1426 [guiparams.english_units,guiparams.set_cross_section_endpoints,...
1427     guiparams.presentation,guiparams.print] = ...
1428     plotParametersDialog(guiparams.english_units, ...
1429     guiparams.set_cross_section_endpoints,...
1430     guiparams.presentation,guiparams.print,...
1431     handles.figure1);
1432 
1433 % Update the GUI:
1434 % ---------------
1435 if guiparams.english_units
1436     set(handles.menuMetric, 'Checked','off')
1437     set(handles.menuEnglish,'Checked','on')
1438 else
1439     set(handles.menuMetric, 'Checked','on')
1440     set(handles.menuEnglish,'Checked','off')
1441 end
1442 
1443 if guiparams.set_cross_section_endpoints
1444     set(handles.menuCrossSectionEndpointAutomatic,'Checked','off')
1445     set(handles.menuCrossSectionEndpointManual,   'Checked','on')
1446 else
1447     set(handles.menuCrossSectionEndpointAutomatic,'Checked','on')
1448     set(handles.menuCrossSectionEndpointManual,   'Checked','off')
1449 end
1450 
1451 if guiparams.presentation
1452     menuStylePresentation_Callback(hObject, eventdata, handles)
1453 %     set(handles.menuStylePrint,           'Checked','off')
1454 %     set(handles.menuStylePresentation,    'Checked','on')
1455 %     set(handles.menuPrintFormat,          'Checked','off')
1456 %     set(handles.menuPresentationFormat,   'Checked','on')
1457 else
1458     menuStylePrint_Callback(hObject, eventdata, handles)
1459 %     set(handles.menuStylePrint,           'Checked','on')
1460 %     set(handles.menuStylePresentation,    'Checked','off')
1461 %     set(handles.menuPrintFormat,          'Checked','on')
1462 %     set(handles.menuPresentationFormat,   'Checked','off')
1463 end
1464 
1465 % Re-store the Application data:
1466 % ------------------------------
1467 setappdata(handles.figure1,'guiparams',guiparams)
1468 
1469 % [EOF] plottingParametersCallback
1470 
1471 
1472 % --------------------------------------------------------------------
1473 function processingParametersCallback(hObject, eventdata, handles)
1474 
1475 % Get the Application data:
1476 % -------------------------
1477 guiparams = getappdata(handles.figure1,'guiparams');
1478 z   = guiparams.z;   %#ok<NASGU>
1479 A   = guiparams.A;   %#ok<NASGU>
1480 V   = guiparams.V;   %#ok<NASGU>
1481 Map = guiparams.Map; %#ok<NASGU>
1482 
1483 % [EOF] processingParametersCallback
1484 
1485 
1486 % --------------------------------------------------------------------
1487 function shiptracksPlotCallback(hObject, eventdata, handles)
1488 % Plot 1
1489 
1490 % Get the Application data:
1491 % -------------------------
1492 guiparams = getappdata(handles.figure1,'guiparams');
1493 z = guiparams.z;
1494 A = guiparams.A;
1495 V = guiparams.V; %#ok<NASGU>
1496 % Map = guiparams.Map;
1497 setends = guiparams.set_cross_section_endpoints;
1498 
1499 % Preprocess the data:
1500 % --------------------
1501 A = VMT_PreProcess(z,A);
1502 
1503 % Push messages to Log Window:
1504 % ----------------------------
1505 log_text = {...
1506     '   Preprocessing complete.';...
1507     '   Begin Data Processing...'};
1508 statusLogging(handles.LogWindow, log_text)
1509 
1510 % Process the transects:
1511 % ----------------------
1512 A(1).hgns = guiparams.horizontal_grid_node_spacing;
1513 A(1).wse  = guiparams.wse;  %Set the WSE to entered value
1514 [A,V,processing_log_text] = VMT_ProcessTransects(z,A,...
1515     guiparams.set_cross_section_endpoints,guiparams.unit_discharge_correction);
1516 
1517 % Compute the smoothed variables
1518 % ------------------------------
1519 % This is required so that the V struc is complete at any point during
1520 % runtime.
1521 V = VMT_SmoothVar(V, ...
1522     ...guiparams.contour, ...
1523     guiparams.horizontal_smoothing_window, ...
1524     guiparams.vertical_smoothing_window);
1525 
1526 % Push messages to Log Window:
1527 % ----------------------------
1528 statusLogging(handles.LogWindow, processing_log_text)
1529 
1530 % Store the data:
1531 % ---------------
1532 guiparams.z = z;
1533 guiparams.A = A;
1534 guiparams.V = V;
1535 setappdata(handles.figure1,'guiparams',guiparams)
1536 
1537 % Push messages to Log Window:
1538 % ----------------------------
1539 log_text = {'Plotting Shiptracks (reprocessing)'};
1540 statusLogging(handles.LogWindow, log_text)
1541 
1542 % Create or replot the Shiptracks
1543 % -------------------------------
1544 % Grab the axes to the plot
1545 % axes(handles.Plot1Shiptracks);
1546 VMT_PlotShiptracks(A,V,z,setends,handles.Plot1Shiptracks); % PLOT 1
1547 
1548 %%%%%%%%%%%%%%%%%%%%%%%%%
1549 % New plot display window
1550 % h = VMT_CreatePlotDisplay('shiptracks');
1551 % h = figure(1); clf
1552 %%%%%%%%%%%%%%%%%%%%%%%%%
1553 
1554 % [EOF] shiptracksPlotCallback
1555 
1556 
1557 % --------------------------------------------------------------------
1558 function planviewPlotCallback(hObject, eventdata, handles)
1559 % Plot 2
1560 
1561 % Get the Application data:
1562 % -------------------------
1563 guiparams = getappdata(handles.figure1,'guiparams');
1564 guiprefs  = getappdata(handles.figure1,'guiprefs');
1565 
1566 if iscell(guiparams.mat_file) % Multiple MAT files loaded
1567     % Push messages to Log Window:
1568     % ----------------------------
1569     log_text = {'Plotting Multiple Transects (Planview)'};
1570     statusLogging(handles.LogWindow, log_text)
1571     
1572        
1573     % Push plotting parameters to log window:
1574     % ---------------------------------------
1575     log_text = {...
1576         'Plan View Plotting Parameters';...
1577         sprintf('   Depth range %3.1f to %3.1f m',guiparams.depth_range_min, guiparams.depth_range_max);...
1578         sprintf('   Vector scale: %d',guiparams.vector_scale_plan_view);...
1579         sprintf('   Vector spacing: %d',guiparams.vector_spacing_plan_view);...
1580         sprintf('   Smoothing window size: %d',guiparams.smoothing_window_size);...
1581         };
1582     statusLogging(handles.LogWindow, log_text)
1583     
1584     % Plot the data:
1585     % --------------
1586     z = [];
1587     A = [];
1588     V = [];
1589     Map = [];
1590     depth_range = [guiparams.depth_range_min guiparams.depth_range_max];
1591     [PVdata,~,log_text] = VMT_PlotPlanViewQuivers(z,A,V,Map, ...
1592         depth_range, ...
1593         guiparams.vector_scale_plan_view, ...
1594         guiparams.vector_spacing_plan_view, ...
1595         guiparams.smoothing_window_size, ...
1596         guiparams.display_shoreline, ...
1597         guiparams.english_units, ...
1598         guiparams.mat_file, ...
1599         guiparams.mat_path); % PLOT2
1600     statusLogging(handles.LogWindow, log_text)
1601     
1602     % Plot a Shoreline Map:
1603     % ---------------------
1604     if guiparams.display_shoreline
1605         [guiprefs.shoreline_file,guiprefs.shoreline_path] = uigetfile(...
1606             {'*.txt;*.csv','All Text Files'; '*.*','All Files'},...
1607             'Select Map Text File',...
1608             fullfile(guiprefs.shoreline_path,guiprefs.shoreline_file));
1609         if ischar(guiprefs.shoreline_file) % User did not hit cancel
1610             mapdata = dlmread(fullfile(guiprefs.shoreline_path,guiprefs.shoreline_file));
1611             Map.UTMe   = mapdata(:,1);
1612             Map.UTMn   = mapdata(:,2);
1613             Map.infile = fullfile(guiprefs.shoreline_path,guiprefs.shoreline_file);
1614             %Map.UTMzone = zone;
1615         else
1616             Map = [];
1617         end
1618         VMT_PlotShoreline(Map)
1619         log_text = {...
1620             '   Loading map file.';...
1621             '   Plotting shoreline.'...
1622             };
1623         statusLogging(handles.LogWindow, log_text)
1624     else
1625         Map = [];
1626     end
1627     
1628 else
1629     z = guiparams.z;
1630     A = guiparams.A;
1631     % V = guiparams.V;
1632     Map = guiparams.Map;
1633     
1634     % Push messages to Log Window:
1635     % ----------------------------
1636     log_text = {'Plotting Depth Averaged Vectors (reprocessing)'};
1637     statusLogging(handles.LogWindow, log_text)
1638     
1639         
1640     % Preprocess the data:
1641     % --------------------
1642     A = VMT_PreProcess(z,A);
1643     
1644     % Process the transects:
1645     % ----------------------
1646     A(1).hgns = guiparams.horizontal_grid_node_spacing;
1647     A(1).wse  = guiparams.wse;  %Set the WSE to entered value
1648     [A,V,processing_log_text] = VMT_ProcessTransects(z,A,...
1649         guiparams.set_cross_section_endpoints,guiparams.unit_discharge_correction);
1650     
1651     % Compute the smoothed variables
1652     % ------------------------------
1653     % This is required so that the V struc is complete at any point during
1654     % runtime.
1655     V = VMT_SmoothVar(V, ...
1656         ...guiparams.contour, ...
1657         guiparams.horizontal_smoothing_window, ...
1658         guiparams.vertical_smoothing_window);
1659     
1660     % Push messages to Log Window:
1661     % ----------------------------
1662     statusLogging(handles.LogWindow, processing_log_text)
1663     
1664     % Plot the cross section:
1665     % -----------------------
1666     log_text = {...
1667         'Plan View Plotting Parameters';...
1668         sprintf('   Depth range %3.1f to %3.1f m',guiparams.depth_range_min, guiparams.depth_range_max);...
1669         sprintf('   Vector scale: %d',guiparams.vector_scale_plan_view);...
1670         sprintf('   Vector spacing: %d',guiparams.vector_spacing_plan_view);...
1671         sprintf('   Smoothing window size: %d',guiparams.smoothing_window_size);...
1672         };
1673     statusLogging(handles.LogWindow, log_text)
1674     
1675     % Plot the data:
1676     % --------------
1677     %msgbox('Plotting Plan View','VMT Status','help','replace');
1678     depth_range = [guiparams.depth_range_min guiparams.depth_range_max];
1679     
1680     
1681     [PVdata,~,log_text] = VMT_PlotPlanViewQuivers(z,A,V,Map, ...
1682         depth_range, ...
1683         guiparams.vector_scale_plan_view, ...
1684         guiparams.vector_spacing_plan_view, ...
1685         guiparams.smoothing_window_size, ...
1686         guiparams.display_shoreline, ...
1687         guiparams.english_units, ...
1688         guiparams.mat_file, ...
1689         guiparams.mat_path); % PLOT2
1690     statusLogging(handles.LogWindow, log_text)
1691     
1692     % Plot a Shoreline Map:
1693     % ---------------------
1694     if guiparams.display_shoreline
1695         [guiprefs.shoreline_file,guiprefs.shoreline_path] = uigetfile(...
1696             {'*.txt;*.csv','All Text Files'; '*.*','All Files'},...
1697             'Select Map Text File',...
1698             fullfile(guiprefs.shoreline_path,guiprefs.shoreline_file));
1699         if ischar(guiprefs.shoreline_file) % User did not hit cancel
1700             mapdata = dlmread(fullfile(guiprefs.shoreline_path,guiprefs.shoreline_file));
1701             Map.UTMe   = mapdata(:,1);
1702             Map.UTMn   = mapdata(:,2);
1703             Map.infile = fullfile(guiprefs.shoreline_path,guiprefs.shoreline_file);
1704             %Map.UTMzone = zone;
1705         else
1706             Map = [];
1707         end
1708         VMT_PlotShoreline(Map)
1709         log_text = {...
1710             '   Loading map file.';...
1711             '   Plotting shoreline.'...
1712             };
1713         statusLogging(handles.LogWindow, log_text)
1714     else
1715         Map = [];
1716     end
1717     
1718 end
1719 
1720 if guiparams.add_background
1721     [guiprefs,log_text] = VMT_OverlayDOQQ(guiprefs);
1722     statusLogging(handles.LogWindow, log_text)
1723 end
1724 
1725 % Update guiparams
1726 % ----------------
1727 guiparams.z   = z;
1728 guiparams.A   = A;
1729 guiparams.V   = V;
1730 guiparams.Map = Map;
1731 guiparams.iric_anv_planview_data = PVdata;
1732 setappdata(handles.figure1,'guiparams',guiparams);
1733 
1734 % Update preferences
1735 % ------------------
1736 setappdata(handles.figure1,'guiprefs',guiprefs)
1737 store_prefs(handles.figure1,'shoreline')
1738 store_prefs(handles.figure1,'aerial')
1739 
1740 % Force plot to be formated properly
1741 % ----------------------------------
1742 if guiparams.presentation
1743     menuStylePresentation_Callback(hObject, eventdata, handles)
1744 else
1745     menuStylePrint_Callback(hObject, eventdata, handles)
1746 end
1747 
1748 % Start the Graphics Control Gui
1749 % ------------------------------
1750 VMT_GraphicsControl
1751 
1752 % [EOF] planviewPlotCallback
1753 
1754 
1755 % --------------------------------------------------------------------
1756 function crosssectionPlotCallback(hObject, eventdata, handles)
1757 % Plot 3
1758 
1759 % Get the Application data:
1760 % -------------------------
1761 guiparams = getappdata(handles.figure1,'guiparams');
1762 z = guiparams.z;
1763 A = guiparams.A;
1764 % V = guiparams.V;
1765 % Map = guiparams.Map;
1766 
1767 % Preprocess the data:
1768 % --------------------
1769 A = VMT_PreProcess(z,A);
1770 
1771 % Push messages to Log Window:
1772 % ----------------------------
1773 log_text = {'Plotting Cross Section (reprocessing)'};
1774 statusLogging(handles.LogWindow, log_text)
1775 
1776 % Process the transects:
1777 % ----------------------
1778 A(1).hgns = guiparams.horizontal_grid_node_spacing;
1779 A(1).wse  = guiparams.wse;  %Set the WSE to entered value
1780 [A,V,processing_log_text] = VMT_ProcessTransects(z,A,...
1781     guiparams.set_cross_section_endpoints,guiparams.unit_discharge_correction);
1782 
1783 % Push messages to Log Window:
1784 % ----------------------------
1785 statusLogging(handles.LogWindow, processing_log_text)
1786 
1787 % Plot the cross section:
1788 % -----------------------
1789 log_text = {...
1790     'Cross Section Plotting Parameters';...
1791     sprintf('   Contour variable: %s'          ,guiparams.contours(guiparams.idx_contour).string);...
1792     sprintf('   Vertical exaggeration: %d'     ,guiparams.vertical_exaggeration);...
1793     sprintf('   Vector scale: %3.1f'           ,guiparams.vector_scale_cross_section);...
1794     sprintf('   Horizontal vector spacing: %d' ,guiparams.horizontal_vector_spacing);...
1795     sprintf('   Vertical vector spacing: %d'   ,guiparams.vertical_vector_spacing);...
1796     sprintf('   Horizontal smooting window: %d',guiparams.horizontal_smoothing_window);...
1797     sprintf('   Vertical smoothing window: %d' ,guiparams.vertical_smoothing_window);...
1798     };
1799 if guiparams.plot_secondary_flow_vectors
1800     log_text = vertcat(log_text, {...
1801         sprintf('   Vector variable: %s',guiparams.secondary_flows(guiparams.idx_secondary_flow_vector_variable).string);...
1802         sprintf('   Inc. vertical component?: %d',guiparams.include_vertical_velocity)...
1803         });
1804 end
1805 % Push messages to Log Window:
1806 % ----------------------------
1807 statusLogging(handles.LogWindow, log_text)
1808 
1809 if guiparams.plot_secondary_flow_vectors
1810     %msgbox('Plotting Cross Section','VMT Status','help','replace')
1811 %     V = VMT_SmoothVar(V, ...
1812 %         ...guiparams.contour, ...
1813 %         guiparams.horizontal_smoothing_window, ...
1814 %         guiparams.vertical_smoothing_window);
1815     V = VMT_SmoothVar(V, ...
1816         ...guiparams.secondary_flow_vector_variable, ...
1817         guiparams.horizontal_smoothing_window, ...
1818         guiparams.vertical_smoothing_window);
1819     [~,A,V,plot_cont_log_text] = VMT_PlotXSContQuiver(z,A,V, ...
1820         guiparams.contour, ...
1821         guiparams.vector_scale_cross_section, ...
1822         guiparams.vertical_exaggeration, ...
1823         guiparams.horizontal_vector_spacing, ...
1824         guiparams.vertical_vector_spacing, ...
1825         guiparams.secondary_flow_vector_variable, ...
1826         guiparams.include_vertical_velocity, ...
1827         guiparams.english_units); %#ok<ASGLU> % PLOT3
1828     
1829 elseif ~guiparams.plot_secondary_flow_vectors
1830     V = VMT_SmoothVar(V, ...
1831         ...guiparams.contour, ...
1832         guiparams.horizontal_smoothing_window, ...
1833         guiparams.vertical_smoothing_window);
1834     
1835     [~,A,V,zmin,zmax,plot_cont_log_text] = VMT_PlotXSCont(z,A,V, ...
1836         guiparams.contour, ...
1837         guiparams.vertical_exaggeration, ...
1838         guiparams.english_units);  %#ok<ASGLU>
1839     
1840     guiparams.zmin = zmin;
1841     guiparams.zmax = zmax;
1842     setappdata(handles.figure1,'guiparams',guiparams)
1843 end
1844 
1845 % Force plot to be formated properly
1846 % ----------------------------------
1847 if guiparams.presentation
1848     menuStylePresentation_Callback(hObject, eventdata, handles)
1849 else
1850     menuStylePrint_Callback(hObject, eventdata, handles)
1851 end
1852 
1853 % Re-store the Application data:
1854 % ------------------------------
1855 guiparams.V = V;
1856 setappdata(handles.figure1,'guiparams',guiparams)
1857 
1858 % Start the Graphics Control Gui
1859 % ------------------------------
1860 VMT_GraphicsControl
1861 
1862 % Push messages to Log Window:
1863 % ----------------------------
1864 statusLogging(handles.LogWindow, plot_cont_log_text)
1865 % msgbox('Plotting Complete','VMT Status','help','replace')
1866 
1867 % [EOF] crosssectionPlotCallback
1868 
1869 
1870 %%%%%%%%%%%%%%%%%%%%%%%%%
1871 % DATA EXPORT CALLBACKS %
1872 %%%%%%%%%%%%%%%%%%%%%%%%%
1873 
1874 % --------------------------------------------------------------------
1875 function SaveMATFile_Callback(hObject, eventdata, handles)
1876 % saveDataCallback(hObject, eventdata, handles)
1877 
1878 % Get the Application data:
1879 % -------------------------
1880 guiparams = getappdata(handles.figure1,'guiparams');
1881 z   = guiparams.z;   %#ok<NASGU>
1882 A   = guiparams.A;   %#ok<NASGU>
1883 V   = guiparams.V;   %#ok<NASGU>
1884 Map = guiparams.Map; %#ok<NASGU>
1885 
1886 [the_file,the_path] = ...
1887     uiputfile({'*.mat','MAT-Files (*.mat)'}, ...
1888     'Save MAT-File', ...
1889     fullfile(guiparams.mat_path,guiparams.savefile));
1890 
1891 % Save the processed data to a MAT file:
1892 % --------------------------------------
1893 if ischar(the_file)
1894     guiparams.mat_path = the_path;
1895     guiparams.mat_file = the_file;
1896     guiparams.savefile = the_file;
1897     
1898     % Re-store the Application data:
1899     % ------------------------------
1900     setappdata(handles.figure1,'guiparams',guiparams)
1901     
1902     % Update the preferences:
1903     % -----------------------
1904     guiprefs = getappdata(handles.figure1,'guiprefs');
1905     guiprefs.mat_path = the_path;
1906     guiprefs.mat_file = the_file;
1907     setappdata(handles.figure1,'guiprefs',guiprefs)
1908     store_prefs(handles.figure1,'mat')
1909     
1910     [~,filename,extension] = fileparts(guiparams.savefile);
1911     savefile = [filename extension];
1912     h = msgbox(['Saving processed data in MAT File ''' savefile ''''], ...
1913         'Saving Processed Data File...'); %#ok<NASGU>
1914     disp('Saving Processed Data File...')
1915     disp(savefile)
1916     save(savefile,'A','V','z','Map')
1917 end
1918 
1919 % [EOF] SaveMATFile_Callback
1920 
1921 
1922 % --------------------------------------------------------------------
1923 function SaveTecplotFile_Callback(hObject, eventdata, handles)
1924 
1925 % Get the Application data:
1926 % -------------------------
1927 guiparams = getappdata(handles.figure1,'guiparams');
1928 % z   = guiparams.z;
1929 % A   = guiparams.A;
1930 V   = guiparams.V;
1931 % Map = guiparams.Map;
1932 
1933 [the_file,the_path] = ...
1934     uiputfile({'*.dat','Tecplot Files (*.dat)'}, ...
1935     'Save Tecplot File', ...
1936     fullfile(guiparams.tecplot_path,guiparams.tecplot_file));
1937 
1938 % Output the data (no smoothing) to Tecplot:
1939 % ------------------------------------------
1940 if ischar(the_file)
1941     guiparams.tecplot_path = the_path;
1942     guiparams.tecplot_file = the_file;
1943     
1944     % Re-store the Application data:
1945     % ------------------------------
1946     setappdata(handles.figure1,'guiparams',guiparams)
1947     
1948     % Update the preferences:
1949     % -----------------------
1950     guiprefs = getappdata(handles.figure1,'guiprefs');
1951     guiprefs.tecplot_path = the_path;
1952     guiprefs.tecplot_file = the_file;
1953     setappdata(handles.figure1,'guiprefs',guiprefs)
1954     store_prefs(handles.figure1,'tecplot')
1955     
1956     % Push to log window
1957     % ------------------
1958     log_text = {...
1959         'Exporting Data to Tecplot (*.dat) File...';...
1960         'Directory:';...
1961         the_path;...
1962         ['Filename: ' the_file]};
1963     statusLogging(handles.LogWindow,log_text)
1964         
1965     if isempty(V)
1966         A = guiparams.A;
1967         A(1).hgns = guiparams.horizontal_grid_node_spacing;
1968         A(1).wse  = guiparams.wse;  %Set the WSE to entered value
1969         [~,V,processing_log_text] = VMT_ProcessTransects(z,A,...
1970             guiparams.set_cross_section_endpoints,...
1971             guiparams.unit_discharge_correction);
1972     end
1973     VMT_BuildTecplotFile(V,fullfile(guiparams.tecplot_path,guiparams.tecplot_file));
1974     
1975     % Push to log window
1976     % ------------------
1977     log_text = {'Exporting XS Bathy Data to Tecplot (*.dat) File...'};
1978     statusLogging(handles.LogWindow,log_text)
1979     
1980     VMT_BuildTecplotFile_XSBathy(V,fullfile(guiparams.tecplot_path,guiparams.tecplot_file));
1981     
1982     % Push to log window
1983     % ------------------
1984     log_text = {'Tecplot Export Complete'};
1985     statusLogging(handles.LogWindow,log_text)
1986    
1987 end
1988 
1989 % [EOF] SaveTechplotFile_Callback
1990 
1991 
1992 % --------------------------------------------------------------------
1993 function SaveGoogleEarthFile_Callback(hObject, eventdata, handles)
1994 
1995 % Get the Application data:
1996 % -------------------------
1997 guiparams = getappdata(handles.figure1,'guiparams');
1998 % z   = guiparams.z;
1999 A   = guiparams.A;
2000 V   = guiparams.V;
2001 Map = guiparams.Map; %#ok<NASGU>
2002 
2003 [the_file,the_path] = ...
2004     uiputfile({'*.kmz','Google Earth Files (*.kmz)'}, ...
2005     'Save Google Earth File', ...
2006     fullfile(guiparams.kmz_path,guiparams.kmz_file));
2007 
2008 % Save the processed data to a Google Earth (KMZ) file:
2009 % -----------------------------------------------------
2010 if ischar(the_file)
2011     guiparams.kmz_path = the_path;
2012     guiparams.kmz_file = the_file;
2013     
2014     % Re-store the Application data:
2015     % ------------------------------
2016     setappdata(handles.figure1,'guiparams',guiparams)
2017     
2018     % Update the preferences:
2019     % -----------------------
2020     guiprefs = getappdata(handles.figure1,'guiprefs');
2021     guiprefs.kmz_path = the_path;
2022     guiprefs.kmz_file = the_file;
2023     setappdata(handles.figure1,'guiprefs',guiprefs)
2024     store_prefs(handles.figure1,'kmz')
2025     
2026     %     if guiparams.display_shoreline
2027     %         VMT_Shoreline2GE_3D(A,Map, ...
2028     %                             guiparams.vertical_exaggeration, ...
2029     %                             guiparams.vertical_offset);
2030     %     end
2031     if isempty(V)
2032         A = guiparams.A;
2033         A(1).hgns = guiparams.horizontal_grid_node_spacing;
2034         A(1).wse  = guiparams.wse;  %Set the WSE to entered value
2035         [~,V,processing_log_text] = VMT_ProcessTransects(z,A,...
2036             guiparams.set_cross_section_endpoints,...
2037             guiparams.unit_discharge_correction);
2038     end
2039     VMT_MeanXS2GE_3D(A,V,[], ...
2040         fullfile(guiparams.kmz_path,guiparams.kmz_file), ...
2041         guiparams.vertical_exaggeration, ...
2042         guiparams.vertical_offset);
2043 end
2044 
2045 % [EOF] SaveGoogleEarthFile_Callback
2046 
2047 
2048 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2049 % DATA EXPORT/BATHYMETRY CALLBACKS %
2050 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2051 
2052 % --------------------------------------------------------------------
2053 function ExportMultibeamBathymetry_Callback(hObject, eventdata, handles)
2054 
2055 % Get the Application data:
2056 % -------------------------
2057 guiparams = getappdata(handles.figure1,'guiparams');
2058 guiprefs  = getappdata(handles.figure1,'guiprefs');
2059 z = guiparams.z;
2060 A = guiparams.A;
2061 V = guiparams.V; %#ok<NASGU>
2062 % Map = guiparams.Map;
2063 setends = guiparams.set_cross_section_endpoints;
2064 
2065 [the_file,the_path] = ...
2066     uiputfile({'*.csv','Multibeam Bathymetry Files (*.csv)'}, ...
2067     'Export Multibeam Bathymetry', ...
2068     fullfile(guiprefs.multibeambathymetry_path, ...
2069     guiprefs.multibeambathymetry_file));
2070 
2071 if ischar(the_file)
2072     guiparams.multibeambathymetry_path = the_path;
2073     guiparams.multibeambathymetry_file = the_file;
2074     
2075     % Re-store the Application data:
2076     % ------------------------------
2077     setappdata(handles.figure1,'guiparams',guiparams)
2078     
2079     % Update the preferences:
2080     % -----------------------
2081     guiprefs = getappdata(handles.figure1,'guiprefs');
2082     guiprefs.multibeambathymetry_path = the_path;
2083     guiprefs.multibeambathymetry_file = the_file;
2084     setappdata(handles.figure1,'guiprefs',guiprefs)
2085     store_prefs(handles.figure1,'multibeambathymetry')
2086     
2087     if guiparams.output_auxiliary_data
2088     end
2089     
2090     %msgbox('Processing Bathymetry...Please Be Patient','VMT Status','help','replace')
2091     
2092     savefile = fullfile(guiparams.multibeambathymetry_path, ...
2093         guiparams.multibeambathymetry_file);
2094     
2095     log_text = {'Multibeam bathymetry file saved to:';...
2096         ['   ' savefile]};
2097     statusLogging(handles.LogWindow,log_text)
2098     
2099     % Process the transects:
2100     % ----------------------
2101     A(1).hgns = guiparams.horizontal_grid_node_spacing;
2102     A(1).wse  = guiparams.wse;  %Set the WSE to entered value
2103     [A,V,processing_log_text] = VMT_ProcessTransects(z,A,...
2104         guiparams.set_cross_section_endpoints,guiparams.unit_discharge_correction);
2105     
2106     % Compute the smoothed variables
2107     % ------------------------------
2108     % This is required so that the V struc is complete at any point during
2109     % runtime.
2110     V = VMT_SmoothVar(V, ...
2111         ...guiparams.contour, ...
2112         guiparams.horizontal_smoothing_window, ...
2113         guiparams.vertical_smoothing_window);
2114     
2115     % Push messages to Log Window:
2116     % ----------------------------
2117     statusLogging(handles.LogWindow, processing_log_text)
2118 
2119     
2120     VMT_MBBathy(guiparams.z, ...
2121         guiparams.A, ...
2122         savefile, ...
2123         guiparams.beam_angle, ...
2124         guiparams.magnetic_variation, ...
2125         guiparams.wse, ...
2126         guiparams.output_auxiliary_data);
2127     
2128     %msgbox('Bathymetry Output Complete','VMT Status','help','replace')
2129     
2130 end
2131 
2132 % [EOF] ExportMultibeamBathymetry_Callback
2133 
2134 
2135 % --------------------------------------------------------------------
2136 function BeamAngle_Callback(hObject, eventdata, handles)
2137 % Get the beam angle
2138 
2139 % Get the Application data:
2140 % -------------------------
2141 guiparams = getappdata(handles.figure1,'guiparams');
2142 
2143 % Get the new entry and make sure it is valid (numeric, positive):
2144 % ----------------------------------------------------------------
2145 new_beam_angle = str2double(get(hObject,'String'));
2146 is_a_number = ~isnan(new_beam_angle);
2147 is_positive = new_beam_angle>=0;
2148 
2149 % Modify the Application data:
2150 % ----------------------------
2151 if is_a_number && is_positive
2152     guiparams.beam_angle = new_beam_angle;
2153     
2154     % Re-store the Application data:
2155     % ------------------------------
2156     setappdata(handles.figure1,'guiparams',guiparams)
2157     
2158 else % Reject the (incorrect) input
2159     set(hObject,'String',guiparams.beam_angle)
2160 end
2161 
2162 % [EOF] BeamAngle_Callback
2163 
2164 
2165 % --------------------------------------------------------------------
2166 function MagneticVariation_Callback(hObject, eventdata, handles)
2167 % Get the Magnetic Variation
2168 
2169 % Get the Application data:
2170 % -------------------------
2171 guiparams = getappdata(handles.figure1,'guiparams');
2172 
2173 % Get the new entry and make sure it is valid (numeric, positive):
2174 % ----------------------------------------------------------------
2175 new_magnetic_variation = str2double(get(hObject,'String'));
2176 is_a_number = ~isnan(new_magnetic_variation);
2177 is_positive = new_magnetic_variation>=0;
2178 
2179 % Modify the Application data:
2180 % ----------------------------
2181 if is_a_number && is_positive
2182     guiparams.magnetic_variation = new_magnetic_variation;
2183     
2184     % Re-store the Application data:
2185     % ------------------------------
2186     setappdata(handles.figure1,'guiparams',guiparams)
2187     
2188 else % Reject the (incorrect) input
2189     set(hObject,'String',guiparams.magnetic_variation)
2190 end
2191 
2192 % [EOF] MagneticVariation_Callback
2193 
2194 
2195 % --------------------------------------------------------------------
2196 function WSE_Callback(hObject, eventdata, handles)
2197 
2198 % Get the Application data:
2199 % -------------------------
2200 guiparams = getappdata(handles.figure1,'guiparams');
2201 
2202 % Get the new entry and make sure it is valid (numeric, positive):
2203 % ----------------------------------------------------------------
2204 new_wse = str2double(get(hObject,'String'));
2205 is_a_number = ~isnan(new_wse);
2206 is_positive = new_wse>=0;
2207 
2208 % Modify the Application data:
2209 % ----------------------------
2210 if is_a_number && is_positive
2211     guiparams.wse = new_wse;
2212     
2213     % Re-store the Application data:
2214     % ------------------------------
2215     setappdata(handles.figure1,'guiparams',guiparams)
2216     
2217 else % Reject the (incorrect) input
2218     set(hObject,'String',guiparams.wse)
2219 end
2220 
2221 % [EOF] WSE_Callback
2222 
2223 
2224 % --------------------------------------------------------------------
2225 function OutputAuxiliaryData_Callback(hObject, eventdata, handles)
2226 % Bathymetry Auxiliary Data
2227 
2228 % Get the Application data:
2229 % -------------------------
2230 guiparams = getappdata(handles.figure1,'guiparams');
2231 
2232 % Modify the Application data:
2233 % ----------------------------
2234 guiparams.output_auxiliary_data = logical(get(hObject,'Value')); % boolean
2235 
2236 % Re-store the Application data:
2237 % ------------------------------
2238 setappdata(handles.figure1,'guiparams',guiparams)
2239 
2240 % [EOF] OutputAuxiliaryData_Callback
2241 
2242 
2243 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2244 % PLOTTING/PLAN VIEW PLOT CALLBACKS %
2245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2246 
2247 % --------------------------------------------------------------------
2248 function DepthRangeMin_Callback(hObject, eventdata, handles)
2249 
2250 % Get the Application data:
2251 % -------------------------
2252 guiparams = getappdata(handles.figure1,'guiparams');
2253 
2254 % Get the new entry and make sure it is valid (numeric, positive):
2255 % ----------------------------------------------------------------
2256 new_depth_range_min = str2double(get(hObject,'String'));
2257 is_a_number = ~isnan(new_depth_range_min);
2258 is_positive = new_depth_range_min>=0;
2259 
2260 % Modify the Application data:
2261 % ----------------------------
2262 if is_a_number && is_positive
2263     guiparams.depth_range_min = new_depth_range_min;
2264     
2265     % Re-store the Application data:
2266     % ------------------------------
2267     setappdata(handles.figure1,'guiparams',guiparams)
2268     
2269 else % Reject the (incorrect) input
2270     set(hObject,'String',guiparams.depth_range_min)
2271 end
2272 
2273 % [EOF] DepthRangeMin_Callback
2274 
2275 
2276 % --------------------------------------------------------------------
2277 function DepthRangeMax_Callback(hObject, eventdata, handles)
2278 
2279 % Get the Application data:
2280 % -------------------------
2281 guiparams = getappdata(handles.figure1,'guiparams');
2282 
2283 % Get the new entry and make sure it is valid (numeric, positive):
2284 % ----------------------------------------------------------------
2285 new_depth_range_max = str2double(get(hObject,'String'));
2286 is_a_number = ~isnan(new_depth_range_max);
2287 is_positive = new_depth_range_max>=0;
2288 
2289 % Modify the Application data:
2290 % ----------------------------
2291 if is_a_number && is_positive
2292     guiparams.depth_range_max = new_depth_range_max;
2293     
2294     % Re-store the Application data:
2295     % ------------------------------
2296     setappdata(handles.figure1,'guiparams',guiparams)
2297     
2298 else % Reject the (incorrect) input
2299     set(hObject,'String',guiparams.depth_range_max)
2300 end
2301 
2302 % [EOF] DepthMax_Callback
2303 
2304 
2305 % --------------------------------------------------------------------
2306 function VectorScalePlanView_Callback(hObject, eventdata, handles)
2307 % Set quiver scale (contour)
2308 
2309 % Get the Application data:
2310 % -------------------------
2311 guiparams = getappdata(handles.figure1,'guiparams');
2312 
2313 % Get the new entry and make sure it is valid (numeric, positive):
2314 % ----------------------------------------------------------------
2315 new_vector_scale_plan_view = str2double(get(hObject,'String'));
2316 is_a_number = ~isnan(new_vector_scale_plan_view);
2317 is_positive = new_vector_scale_plan_view>=0;
2318 
2319 % Modify the Application data:
2320 % ----------------------------
2321 if is_a_number && is_positive
2322     guiparams.vector_scale_plan_view = round(new_vector_scale_plan_view);
2323     
2324     % Re-store the Application data:
2325     % ------------------------------
2326     setappdata(handles.figure1,'guiparams',guiparams)
2327     
2328 else % Reject the (incorrect) input
2329     set(hObject,'String',guiparams.vector_scale_plan_view)
2330 end
2331 
2332 % [EOF] VectorScalePlanView_Callback
2333 
2334 
2335 % --------------------------------------------------------------------
2336 function VectorSpacingPlanview_Callback(hObject, eventdata, handles)
2337 % Set quiver spacing (contour, horizontal)
2338 
2339 % Get the Application data:
2340 % -------------------------
2341 guiparams = getappdata(handles.figure1,'guiparams');
2342 
2343 % Get the new entry and make sure it is valid (numeric, positive):
2344 % ----------------------------------------------------------------
2345 new_vector_spacing_plan_view = str2double(get(hObject,'String'));
2346 is_a_number = ~isnan(new_vector_spacing_plan_view);
2347 is_positive = new_vector_spacing_plan_view>=0;
2348 
2349 % Modify the Application data:
2350 % ----------------------------
2351 if is_a_number && is_positive
2352     guiparams.vector_spacing_plan_view = round(new_vector_spacing_plan_view);
2353     
2354     % Re-store the Application data:
2355     % ------------------------------
2356     setappdata(handles.figure1,'guiparams',guiparams)
2357     
2358 else % Reject the (incorrect) input
2359     set(hObject,'String',guiparams.vector_spacing_plan_view)
2360 end
2361 
2362 % [EOF] VectorSpacingPlanview_Callback
2363 
2364 
2365 % --------------------------------------------------------------------
2366 function SmoothingWindowSize_Callback(hObject, eventdata, handles)
2367 % Plan View smoothing window size
2368 
2369 % Get the Application data:
2370 % -------------------------
2371 guiparams = getappdata(handles.figure1,'guiparams');
2372 
2373 % Get the new entry and make sure it is valid (numeric, positive):
2374 % ----------------------------------------------------------------
2375 new_smoothing_window_size = str2double(get(hObject,'String'));
2376 is_a_number = ~isnan(new_smoothing_window_size);
2377 is_positive = new_smoothing_window_size>=0;
2378 
2379 % Modify the Application data:
2380 % ----------------------------
2381 if is_a_number && is_positive
2382     guiparams.smoothing_window_size = round(new_smoothing_window_size);
2383     
2384     % Re-store the Application data:
2385     % ------------------------------
2386     setappdata(handles.figure1,'guiparams',guiparams)
2387     
2388 else % Reject the (incorrect) input
2389     set(hObject,'String',guiparams.smoothing_window_size)
2390 end
2391 
2392 % [EOF] SmoothingWindowSize_Callback
2393 
2394 
2395 % --------------------------------------------------------------------
2396 function DisplayShoreline_Callback(hObject, eventdata, handles)
2397 
2398 % Get the Application data:
2399 % -------------------------
2400 guiparams = getappdata(handles.figure1,'guiparams');
2401 
2402 % Modify the Application data:
2403 % ----------------------------
2404 guiparams.display_shoreline = logical(get(hObject,'Value')); % boolean
2405 
2406 % Re-store the Application data:
2407 % ------------------------------
2408 setappdata(handles.figure1,'guiparams',guiparams)
2409 
2410 % [EOF] DisplayShoreline_Callback
2411 
2412 
2413 % --------------------------------------------------------------------
2414 function AddBackground_Callback(hObject, eventdata, handles)
2415 
2416 % Get the Application data:
2417 % -------------------------
2418 guiparams = getappdata(handles.figure1,'guiparams');
2419 
2420 % Modify the Application data:
2421 % ----------------------------
2422 guiparams.add_background = logical(get(hObject,'Value')); % boolean
2423 
2424 % Re-store the Application data:
2425 % ------------------------------
2426 setappdata(handles.figure1,'guiparams',guiparams)
2427 
2428 % [EOF] AddBackground_Callback
2429 
2430 
2431 % --------------------------------------------------------------------
2432 function PlotPlanView_Callback(hObject, eventdata, handles)
2433 planviewPlotCallback(hObject, eventdata, handles)
2434 % [EOF] PlotPlanView_Callback
2435 
2436 
2437 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2438 % PLOTTING/SHIP TRACKS PLOT CALLBACKS %
2439 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2440 
2441 % --------------------------------------------------------------------
2442 function HorizontalGridNodeSpacing_Callback(hObject, eventdata, handles)
2443 % Set the horizontal grid node spacing
2444 
2445 % Get the Application data:
2446 % -------------------------
2447 guiparams = getappdata(handles.figure1,'guiparams');
2448 
2449 % Get the new entry and make sure it is valid (numeric, positive):
2450 % ----------------------------------------------------------------
2451 new_horizontal_grid_node_spacing = str2double(get(hObject,'String'));
2452 is_a_number = ~isnan(new_horizontal_grid_node_spacing);
2453 is_positive = new_horizontal_grid_node_spacing>=0;
2454 
2455 % Modify the Application data:
2456 % ----------------------------
2457 if is_a_number && is_positive
2458     guiparams.horizontal_grid_node_spacing = round(new_horizontal_grid_node_spacing);
2459     
2460     % Re-store the Application data:
2461     % ------------------------------
2462     setappdata(handles.figure1,'guiparams',guiparams)
2463     
2464 else % Reject the (incorrect) input
2465     set(hObject,'String',guiparams.horizontal_grid_node_spacing)
2466 end
2467 
2468 % [EOF] HorizontalGridNodeSpacing_Callback
2469 
2470 
2471 % --------------------------------------------------------------------
2472 function SetCrossSectionEndpoints_Callback(hObject, eventdata, handles)
2473 % Set the cross section endpoints manually
2474 
2475 % Get the Application data:
2476 % -------------------------
2477 guiparams = getappdata(handles.figure1,'guiparams');
2478 
2479 % Modify the Application data:
2480 % ----------------------------
2481 guiparams.set_cross_section_endpoints = logical(get(hObject,'Value')); % boolean
2482 
2483 % Re-store the Application data:
2484 % ------------------------------
2485 setappdata(handles.figure1,'guiparams',guiparams)
2486 
2487 % [EOF] SetCrossSectionEndpoints_Callback
2488 
2489 
2490 % --------------------------------------------------------------------
2491 function PlotShiptracks_Callback(hObject, eventdata, handles)
2492 shiptracksPlotCallback(hObject, eventdata, handles)
2493 % [EOF] PlotShiptracks_Callback
2494 
2495 
2496 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2497 % PLOTTING/CROSS SECTION PLOT CALLBACKS %
2498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2499 
2500 % --------------------------------------------------------------------
2501 function Contour_Callback(hObject, eventdata, handles)
2502 
2503 % Get the Application data:
2504 % -------------------------
2505 guiparams = getappdata(handles.figure1,'guiparams');
2506 
2507 % Modify the Application data:
2508 % ----------------------------
2509 idx_variable = get(hObject,'Value');
2510 guiparams.idx_contour = idx_variable;
2511 guiparams.contour = guiparams.contours(idx_variable).variable;
2512 
2513 % Re-store the Application data:
2514 % ------------------------------
2515 setappdata(handles.figure1,'guiparams',guiparams)
2516 
2517 % [EOF] Contour_Callback
2518 
2519 
2520 % --------------------------------------------------------------------
2521 function VerticalExaggeration_Callback(hObject, eventdata, handles)
2522 % Set vertical exaggeration
2523 
2524 % Get the Application data:
2525 % -------------------------
2526 guiparams = getappdata(handles.figure1,'guiparams');
2527 
2528 % Modify the Application data:
2529 % ----------------------------
2530 guiparams.vertical_exaggeration = str2double(get(hObject,'String'));
2531 
2532 % Re-store the Application data:
2533 % ------------------------------
2534 setappdata(handles.figure1,'guiparams',guiparams)
2535 
2536 % Update the GUI:
2537 % ---------------
2538 % updateGUI(handles,guiparams)
2539 
2540 % [EOF] VerticalExaggeration_Callback
2541 
2542 
2543 % --------------------------------------------------------------------
2544 function VectorScaleCrossSection_Callback(hObject, eventdata, handles)
2545 
2546 % Get the Application data:
2547 % -------------------------
2548 guiparams = getappdata(handles.figure1,'guiparams');
2549 
2550 % Modify the Application data:
2551 % ----------------------------
2552 guiparams.vector_scale_cross_section = str2double(get(hObject,'String'));
2553 
2554 % Re-store the Application data:
2555 % ------------------------------
2556 setappdata(handles.figure1,'guiparams',guiparams)
2557 
2558 % Update the GUI:
2559 % ---------------
2560 % updateGUI(handles,guiparams)
2561 
2562 % [EOF] VectorScaleCrossSection_Callback
2563 
2564 
2565 % --------------------------------------------------------------------
2566 function HorizontalVectorSpacing_Callback(hObject, eventdata, handles)
2567 
2568 % Get the Application data:
2569 % -------------------------
2570 guiparams = getappdata(handles.figure1,'guiparams');
2571 
2572 % Modify the Application data:
2573 % ----------------------------
2574 guiparams.horizontal_vector_spacing = str2double(get(hObject,'String'));
2575 
2576 % Re-store the Application data:
2577 % ------------------------------
2578 setappdata(handles.figure1,'guiparams',guiparams)
2579 
2580 % Update the GUI:
2581 % ---------------
2582 % updateGUI(handles,guiparams)
2583 
2584 % [EOF] HorizontalVectorSpacing_Callback
2585 
2586 
2587 % --------------------------------------------------------------------
2588 function VerticalVectorSpacing_Callback(hObject, eventdata, handles)
2589 % Get the vertical quiver spacing for contour plots
2590 
2591 % Get the Application data:
2592 % -------------------------
2593 guiparams = getappdata(handles.figure1,'guiparams');
2594 
2595 % Modify the Application data:
2596 % ----------------------------
2597 guiparams.vertical_vector_spacing = str2double(get(hObject,'String'));
2598 
2599 % Re-store the Application data:
2600 % ------------------------------
2601 setappdata(handles.figure1,'guiparams',guiparams)
2602 
2603 % Update the GUI:
2604 % ---------------
2605 % updateGUI(handles,guiparams)
2606 
2607 % [EOF] VerticalVectorSpacing_Callback
2608 
2609 
2610 % --------------------------------------------------------------------
2611 function HorizontalSmoothingWindow_Callback(hObject, eventdata, handles)
2612 % Horizontal Smoothing
2613 
2614 % Get the Application data:
2615 % -------------------------
2616 guiparams = getappdata(handles.figure1,'guiparams');
2617 
2618 % Modify the Application data:
2619 % ----------------------------
2620 guiparams.horizontal_smoothing_window = str2double(get(hObject,'String'));
2621 
2622 % Re-store the Application data:
2623 % ------------------------------
2624 setappdata(handles.figure1,'guiparams',guiparams)
2625 
2626 % Update the GUI:
2627 % ---------------
2628 % updateGUI(handles,guiparams)
2629 
2630 % [EOF] HorizontalSmoothingWindow_Callback
2631 
2632 
2633 % --------------------------------------------------------------------
2634 function VerticalSmoothingWindow_Callback(hObject, eventdata, handles)
2635 % Vertical Smoothing
2636 
2637 % Get the Application data:
2638 % -------------------------
2639 guiparams = getappdata(handles.figure1,'guiparams');
2640 
2641 % Modify the Application data:
2642 % ----------------------------
2643 guiparams.vertical_smoothing_window = str2double(get(hObject,'String'));
2644 
2645 % Re-store the Application data:
2646 % ------------------------------
2647 setappdata(handles.figure1,'guiparams',guiparams)
2648 
2649 % Update the GUI:
2650 % ---------------
2651 % updateGUI(handles,guiparams)
2652 
2653 % [EOF] VerticalSmoothingWindow_Callback
2654 
2655 
2656 % --------------------------------------------------------------------
2657 function PlotSecondaryFlowVectors_Callback(hObject, eventdata, handles)
2658 
2659 % Get the Application data:
2660 % -------------------------
2661 guiparams = getappdata(handles.figure1,'guiparams');
2662 
2663 % Modify the Application data:
2664 % ----------------------------
2665 guiparams.plot_secondary_flow_vectors = logical(get(hObject,'Value')); % boolean
2666 
2667 % Re-store the Application data:
2668 % ------------------------------
2669 setappdata(handles.figure1,'guiparams',guiparams)
2670 
2671 % [EOF] PlotSecondaryFlowVectors_Callback
2672 
2673 
2674 % --------------------------------------------------------------------
2675 function SecondaryFlowVectorVariable_Callback(hObject, eventdata, handles)
2676 
2677 % Get the Application data:
2678 % -------------------------
2679 guiparams = getappdata(handles.figure1,'guiparams');
2680 
2681 % Modify the Application data:
2682 % ----------------------------
2683 idx_variable = get(hObject,'Value');
2684 guiparams.idx_secondary_flow_vector_variable = idx_variable;
2685 guiparams.secondary_flow_vector_variable = guiparams.secondary_flows(idx_variable).variable;
2686 
2687 % Re-store the Application data:
2688 % ------------------------------
2689 setappdata(handles.figure1,'guiparams',guiparams)
2690 
2691 % [EOF] SecondaryFlowVectorVariable_Callback
2692 
2693 
2694 % --------------------------------------------------------------------
2695 function IncludeVerticalVelocity_Callback(hObject, eventdata, handles)
2696 
2697 % Get the Application data:
2698 % -------------------------
2699 guiparams = getappdata(handles.figure1,'guiparams');
2700 
2701 % Modify the Application data:
2702 % ----------------------------
2703 guiparams.include_vertical_velocity = logical(get(hObject,'Value')); % boolean
2704 
2705 % Re-store the Application data:
2706 % ------------------------------
2707 setappdata(handles.figure1,'guiparams',guiparams)
2708 
2709 % [EOF] IncludeVerticalVelocity_Callback
2710 
2711 
2712 % --------------------------------------------------------------------
2713 function PlotCrossSection_Callback(hObject, eventdata, handles)
2714 crosssectionPlotCallback(hObject, eventdata, handles)
2715 % [EOF] PlotCrossSection_Callback
2716 
2717 
2718 % --------------------------------------------------------------------
2719 function ClearLog_Callback(hObject, eventdata, handles)
2720 set(handles.LogWindow,'string','')
2721 % [EOF] ClearLog_Callback
2722 
2723 % --------------------------------------------------------------------
2724 function SaveLog_Callback(hObject, eventdata, handles)
2725 
2726 % Get the Application data:
2727 % -------------------------
2728 guiparams = getappdata(handles.figure1,'guiparams');
2729 guiprefs  = getappdata(handles.figure1,'guiprefs');
2730 % z   = guiparams.z;   %#ok<NASGU>
2731 % A   = guiparams.A;   %#ok<NASGU>
2732 % V   = guiparams.V;   %#ok<NASGU>
2733 % Map = guiparams.Map; %#ok<NASGU>
2734 
2735 [the_file,the_path] = ...
2736     uiputfile({'*.txt','TXT-Files (*.txt)'}, ...
2737     'Choose where to save the log file', ...
2738     fullfile(guiprefs.log_path,guiprefs.log_file));
2739 
2740 % Save the log to a TXT file:
2741 % ---------------------------
2742 if ischar(the_file)
2743     guiparams.log_path = the_path;
2744     guiparams.log_file = the_file;
2745     %guiparams.savefile = the_file;
2746     
2747     % Re-store the Application data:
2748     % ------------------------------
2749     setappdata(handles.figure1,'guiparams',guiparams)
2750     
2751     % Update the preferences:
2752     % -----------------------
2753     guiprefs = getappdata(handles.figure1,'guiprefs');
2754     guiprefs.log_path = the_path;
2755     guiprefs.log_file = the_file;
2756     setappdata(handles.figure1,'guiprefs',guiprefs)
2757     store_prefs(handles.figure1,'log')
2758     
2759     [~,filename,extension] = fileparts(the_file);
2760     savefile = [the_path filename extension];
2761     h = msgbox(['Saving log to: ''' savefile ''''], ...
2762         'Saving Log File...'); %#ok<NASGU>
2763     
2764     logfile = get(handles.LogWindow,'string');
2765     [nrows,~]= size(logfile);
2766     fid = fopen(savefile, 'w');
2767     for row=1:nrows
2768         fprintf(fid, '%s \n', logfile{row,:});
2769     end
2770     fclose(fid);
2771 end
2772 % [EOF] SaveLog_Callback
2773 
2774 %%%%%%%%%%%%%%%%
2775 % SUBFUNCTIONS %
2776 %%%%%%%%%%%%%%%%
2777 
2778 % --------------------------------------------------------------------
2779 function handles = buildToolbar(handles)
2780 
2781 icons = getIcons;
2782 ht = uitoolbar('Parent',handles.figure1);
2783 
2784 % Load data
2785 % icon = imread('C:\Users\pfricker\Desktop\icons\file_open.png');
2786 % icon = double(icon)/(2^16-1);
2787 % icon(icon==0) = NaN;
2788 handles.toolbarLoadData = ...
2789     uipushtool('Parent',       ht, ...
2790     'CData',        icons(1).data, ...
2791     'TooltipString','Open ASCII File');
2792 
2793 % Save data
2794 % icon = imread('C:\Users\pfricker\Desktop\icons\file_save.png');
2795 % icon = double(icon)/(2^16-1);
2796 % icon(icon==0) = NaN;
2797 handles.toolbarSaveMatFile = ...
2798     uipushtool('Parent',       ht, ...
2799     'CData',        icons(2).data, ...
2800     'TooltipString','Save MAT File', ...
2801     'Separator',    'on');
2802 
2803 
2804 % Save bathymetry
2805 %icon = ones(16,16,3);
2806 handles.toolbarSaveBathymetry = ...
2807     uipushtool('Parent',       ht, ...
2808     'CData',        icons(5).data, ...
2809     'TooltipString','Export Bathymetry');
2810 
2811 % Save figures
2812 % icon = ones(16,16,3);
2813 handles.toolbarSaveFigures = ...
2814     uipushtool('Parent',       ht, ...
2815     'CData',        icons(6).data, ...
2816     'TooltipString','Export Figures');
2817 
2818 % Save Excel File
2819 % icon = ones(16,16,3);
2820 handles.toolbarSaveExcel = ...
2821     uipushtool('Parent',       ht, ...
2822     'CData',        icons(7).data, ...
2823     'TooltipString','Export Excel File');
2824 
2825 
2826 % Plotting parameters
2827 % [icon,map] = imread('C:\Users\pfricker\Desktop\icons\PlotGeneralElement.gif');
2828 % icon = ind2rgb(icon,map);
2829 handles.toolbarPlottingParameters = ...
2830     uipushtool('Parent',       ht, ...
2831     'CData',        icons(3).data, ...
2832     'TooltipString','Plotting Parameters', ...
2833     'Separator',    'on');
2834 
2835 % Processing parameters
2836 % [icon,map] = imread('C:\Users\pfricker\Desktop\icons\ParameterIcon.gif');
2837 % icon = ind2rgb(icon,map);
2838 handles.toolbarProcessingParameters = ...
2839     uipushtool('Parent',       ht, ...
2840     'CData',        icons(4).data, ...
2841     'TooltipString','Processing Parameters');
2842 
2843 % % Plot 1: Shiptracks
2844 % handles.shiptracksPlot = ...
2845 %     uipushtool('Parent',       ht, ...
2846 %                'CData',        icon, ...
2847 %                'TooltipString','Shiptracks plot', ...
2848 %                'Separator',    'on');
2849 %
2850 % % Plot 2: Plan view
2851 % handles.planviewPlot = ...
2852 %     uipushtool('Parent',       ht, ...
2853 %                'CData',        icon, ...
2854 %                'TooltipString','Plan view plot');
2855 %
2856 % % Plot 3: Cross section
2857 % handles.crosssectionPlot = ...
2858 %     uipushtool('Parent',       ht, ...
2859 %                'CData',        icon, ...
2860 %                'TooltipString','Cross section plot');
2861 
2862 set(handles.toolbarLoadData,            'ClickedCallback',{@loadDataCallback,handles})
2863 set(handles.toolbarSaveMatFile,         'ClickedCallback',{@saveDataCallback,handles})
2864 set(handles.toolbarSaveBathymetry,      'ClickedCallback',{@ExportMultibeamBathymetry_Callback,handles})
2865 set(handles.toolbarSaveFigures,         'ClickedCallback',{@menuExportFigures_Callback,handles})
2866 set(handles.toolbarSaveExcel,           'ClickedCallback',{@menuSaveExcel_Callback,handles})
2867 set(handles.toolbarPlottingParameters,  'ClickedCallback',{@plottingParametersCallback,handles})
2868 set(handles.toolbarProcessingParameters,'ClickedCallback',{@processingParametersCallback,handles})
2869 % set(handles.shiptracksPlot,      'ClickedCallback',{@shiptracksPlotCallback,handles})
2870 % set(handles.planviewPlot,        'ClickedCallback',{@planviewPlotCallback,handles})
2871 % set(handles.crosssectionPlot,    'ClickedCallback',{@crosssectionPlotCallback,handles})
2872 
2873 % [EOF] buildtoolbar
2874 
2875 
2876 % --------------------------------------------------------------------
2877 function load_prefs(hfigure)
2878 % Load the GUI preferences.  Also, initialize preferences if they don't
2879 % already exist.
2880 
2881 % Preferences:
2882 % 'ascii'                Path and filenames of current ASCII files
2883 % 'mat'                  Path and filename of current MAT file
2884 % 'tecplot'              Path and filename of last Tecplot file
2885 % 'kmz'                  Path and filename of last KMZ file
2886 % 'multibeambathymetry'  Path and filename of last Multibeam Bathymetry file
2887 % 'log'                  Path and filename of last Log file
2888 % 'iric'                 Path and filename of last iRic ANV file
2889 % 'excel'                Path and filename of last Excel file
2890 % 'aerial'               Path and filename of last Aerial file
2891 % 'shoreline'            Path and filename of last Shoreline file
2892 
2893 % Originals
2894 % prefs = {'ascii2gispath' 'ascii2kmlpath' 'asciipath'   'doqqpath' ...
2895 %          'endspath'      'logpath'       'matpath'     'savedpath' ...
2896 %          'shorepath'     'stapath'       'ysidatapath' 'ysidatapath'};
2897 
2898 % ASCII
2899 if ispref('VMT','ascii')
2900     ascii = getpref('VMT','ascii');
2901     if exist(ascii.path,'dir')
2902         guiprefs.ascii_path = ascii.path;
2903     else
2904         guiprefs.ascii_path = pwd;
2905     end
2906     does_exist = false(1,length(ascii.file));
2907     for k = 1:length(ascii.file) % Check each file one-by-one
2908         does_exist(k) = exist(fullfile(ascii.path,ascii.file{k}),'file');
2909     end
2910     if any(does_exist)
2911         guiprefs.ascii_file = ascii.file(does_exist);
2912     else
2913         guiprefs.ascii_file = {''};
2914     end
2915 else % Initialize ASCII
2916     guiprefs.ascii_path = pwd;
2917     guiprefs.ascii_file = {''};
2918     
2919     ascii.path = pwd;
2920     ascii.file = {''};
2921     setpref('VMT','ascii',ascii)
2922 end
2923 
2924 % MAT
2925 if ispref('VMT','mat')
2926     mat = getpref('VMT','mat');
2927     if exist(mat.path,'dir')
2928         guiprefs.mat_path = mat.path;
2929     else
2930         guiprefs.mat_path = pwd;
2931     end
2932     
2933     if iscell(mat.file)
2934         if exist(fullfile(mat.path,mat.file{1}),'file')
2935             guiprefs.mat_file = mat.file;
2936         else
2937             guiprefs.mat_file = '';
2938         end
2939     else
2940         if exist(fullfile(mat.path,mat.file),'file')
2941             guiprefs.mat_file = mat.file;
2942         else
2943             guiprefs.mat_file = '';
2944         end
2945     end
2946 else % Initialize MAT
2947     guiprefs.mat_path = pwd;
2948     guiprefs.mat_file = '';
2949     
2950     mat.path = pwd;
2951     mat.file = '';
2952     setpref('VMT','mat',mat)
2953 end
2954 
2955 % TECPLOT
2956 if ispref('VMT','tecplot')
2957     tecplot = getpref('VMT','tecplot');
2958     if exist(tecplot.path,'dir')
2959         guiprefs.tecplot_path = tecplot.path;
2960     else
2961         guiprefs.tecplot_path = pwd;
2962     end
2963     if exist(fullfile(tecplot.path,tecplot.file),'file')
2964         guiprefs.tecplot_file = tecplot.file;
2965     else
2966         guiprefs.tecplot_file = '';
2967     end
2968 else % Initialize TECPLOT
2969     guiprefs.tecplot_path = pwd;
2970     guiprefs.tecplot_file = '';
2971     
2972     tecplot.path = pwd;
2973     tecplot.file = '';
2974     setpref('VMT','tecplot',tecplot)
2975 end
2976 
2977 % KMZ
2978 if ispref('VMT','kmz')
2979     kmz = getpref('VMT','kmz');
2980     if exist(kmz.path,'dir')
2981         guiprefs.kmz_path = kmz.path;
2982     else
2983         guiprefs.kmz_path = pwd;
2984     end
2985     if exist(fullfile(kmz.path,kmz.file),'file')
2986         guiprefs.kmz_file = kmz.file;
2987     else
2988         guiprefs.kmz_file = '';
2989     end
2990 else % Initialize KMZ
2991     guiprefs.kmz_path = pwd;
2992     guiprefs.kmz_file = '';
2993     
2994     kmz.path = pwd;
2995     kmz.file = '';
2996     setpref('VMT','kmz',kmz)
2997 end
2998 
2999 % MULTIBEAM BATHYMETRY
3000 if ispref('VMT','multibeambathymetry')
3001     multibeambathymetry = getpref('VMT','multibeambathymetry');
3002     if exist(multibeambathymetry.path,'dir')
3003         guiprefs.multibeambathymetry_path = multibeambathymetry.path;
3004     else
3005         guiprefs.multibeambathymetry_path = pwd;
3006     end
3007     if exist(fullfile(multibeambathymetry.path,multibeambathymetry.file),'file')
3008         guiprefs.multibeambathymetry_file = multibeambathymetry.file;
3009     else
3010         guiprefs.multibeambathymetry_file = '';
3011     end
3012 else % Initialize MULTIBEAM BATHYMETRY
3013     guiprefs.multibeambathymetry_path = pwd;
3014     guiprefs.multibeambathymetry_file = '';
3015     
3016     multibeambathymetry.path = pwd;
3017     multibeambathymetry.file = '';
3018     setpref('VMT','multibeambathymetry',multibeambathymetry)
3019 end
3020 
3021 % Log
3022 if ispref('VMT','log')
3023     log = getpref('VMT','log');
3024     if exist(log.path,'dir')
3025         guiprefs.log_path = log.path;
3026     else
3027         guiprefs.log_path = pwd;
3028     end
3029     if exist(fullfile(log.path,log.file),'file')
3030         guiprefs.log_file = log.file;
3031     else
3032         guiprefs.log_file = '';
3033     end
3034 else % Initialize Log
3035     guiprefs.log_path = pwd;
3036     guiprefs.log_file = '';
3037     
3038     log.path = pwd;
3039     log.file = '';
3040     setpref('VMT','log',log)
3041 end
3042 
3043 % iRic
3044 if ispref('VMT','iric')
3045     iric = getpref('VMT','iric');
3046     if exist(iric.path,'dir')
3047         guiprefs.iric_path = iric.path;
3048     else
3049         guiprefs.iric_path = pwd;
3050     end
3051     if exist(fullfile(iric.path,iric.file),'file')
3052         guiprefs.iric_file = iric.file;
3053     else
3054         guiprefs.iric_file = '';
3055     end
3056 else % Initialize Log
3057     guiprefs.iric_path = pwd;
3058     guiprefs.iric_file = '';
3059     
3060     iric.path = pwd;
3061     iric.file = '';
3062     setpref('VMT','iric',iric)
3063 end
3064 
3065 % excel
3066 if ispref('VMT','excel')
3067     excel = getpref('VMT','excel');
3068     if exist(excel.path,'dir')
3069         guiprefs.excel_path = excel.path;
3070     else
3071         guiprefs.excel_path = pwd;
3072     end
3073     if exist(fullfile(excel.path,excel.file),'file')
3074         guiprefs.excel_file = excel.file;
3075     else
3076         guiprefs.excel_file = '';
3077     end
3078 else % Initialize pref
3079     guiprefs.excel_path = pwd;
3080     guiprefs.excel_file = '';
3081     
3082     excel.path = pwd;
3083     excel.file = '';
3084     setpref('VMT','excel',excel)
3085 end
3086 
3087 % aerial
3088 if ispref('VMT','aerial')
3089     aerial = getpref('VMT','aerial');
3090     if exist(aerial.path,'dir')
3091         guiprefs.aerial_path = aerial.path;
3092     else
3093         guiprefs.aerial_path = pwd;
3094     end
3095     does_exist = false(1,length(aerial.file));
3096     if iscell(aerial.file)
3097     for k = 1:numel(aerial.file) % Check each file one-by-one
3098         does_exist(k) = exist(fullfile(aerial.path,aerial.file{k}),'file');
3099     end
3100     else
3101         does_exist = exist(fullfile(aerial.path,aerial.file),'file');
3102     end
3103     if any(does_exist)
3104         guiprefs.aerial_file = aerial.file;
3105     else
3106         guiprefs.aerial_file = {''};
3107     end
3108 else % Initialize aerial
3109     guiprefs.aerial_path = pwd;
3110     guiprefs.aerial_file = {''};
3111     
3112     aerial.path = pwd;
3113     aerial.file = {''};
3114     setpref('VMT','aerial',aerial)
3115 end
3116 
3117 % shoreline
3118 if ispref('VMT','shoreline')
3119     shoreline = getpref('VMT','shoreline');
3120     if exist(shoreline.path,'dir')
3121         guiprefs.shoreline_path = shoreline.path;
3122     else
3123         guiprefs.shoreline_path = pwd;
3124     end
3125     
3126     if iscell(shoreline.file)
3127         if exist(fullfile(shoreline.path,shoreline.file{1}),'file')
3128             guiprefs.shoreline_file = shoreline.file;
3129         else
3130             guiprefs.shoreline_file = '';
3131         end
3132     else
3133         if exist(fullfile(shoreline.path,shoreline.file),'file')
3134             guiprefs.shoreline_file = shoreline.file;
3135         else
3136             guiprefs.shoreline_file = '';
3137         end
3138     end
3139 else % Initialize shoreline
3140     guiprefs.shoreline_path = pwd;
3141     guiprefs.shoreline_file = '';
3142     
3143     shoreline.path = pwd;
3144     shoreline.file = '';
3145     setpref('VMT','shoreline',shoreline)
3146 end
3147 % guiprefs.presentation = true;
3148 % guiprefs.print        = false;
3149 
3150 % for k = 1:length(prefs)
3151 %     newpref = '';
3152 %     if ispref('VMT',prefs{k})
3153 %         stored_newpref = getpref('VMT',prefs{k});
3154 %         if exist(stored_newpref,'dir')
3155 %             newpref = stored_newpref;
3156 %         else
3157 %             setpref('VMT',prefs{k},newpref)
3158 %         end
3159 %     end
3160 %     guiprefs.(prefs{k}) = newpref;
3161 % end
3162 
3163 setappdata(hfigure,'guiprefs',guiprefs)
3164 
3165 % [EOF] load_prefs
3166 
3167 
3168 % --------------------------------------------------------------------
3169 function store_prefs(hfigure,pref)
3170 % Store preferences in the Application data and in the persistent
3171 % preferences data.
3172 
3173 % Preferences:
3174 % 'ascii'                Path and filenames of current ASCII files
3175 % 'mat'                  Path and filename of current MAT file
3176 % 'tecplot'              Path and filename of last Tecplot file
3177 % 'kmz'                  Path and filename of last KMZ file
3178 % 'multibeambathymetry'  Path and filename of last Multibeam Bathymetry file
3179 % 'log'                  Path and filename of last Log file
3180 % 'iric'                 Path and filename of last iRic ANV file
3181 % 'excel'                Path and filename of last Excel file
3182 % 'aerial'               Path and filename of last Aerial file
3183 % 'shoreline'            Path and filename of last Shoreline file
3184 
3185 guiprefs = getappdata(hfigure,'guiprefs');
3186 
3187 switch pref
3188     case 'ascii'
3189         ascii.path = guiprefs.ascii_path;
3190         ascii.file = guiprefs.ascii_file;
3191         setpref('VMT','ascii',ascii)
3192     case 'mat'
3193         mat.path = guiprefs.mat_path;
3194         mat.file = guiprefs.mat_file;
3195         setpref('VMT','mat',mat)
3196     case 'tecplot'
3197         tecplot.path = guiprefs.tecplot_path;
3198         tecplot.file = guiprefs.tecplot_file;
3199         setpref('VMT','tecplot',tecplot)
3200     case 'kmz'
3201         kmz.path = guiprefs.kmz_path;
3202         kmz.file = guiprefs.kmz_file;
3203         setpref('VMT','kmz',kmz)
3204     case 'multibeambathymetry'
3205         multibeambathymetry.path = guiprefs.multibeambathymetry_path;
3206         multibeambathymetry.file = guiprefs.multibeambathymetry_file;
3207         setpref('VMT','multibeambathymetry',multibeambathymetry)
3208     case 'log'
3209         log.path = guiprefs.log_path;
3210         log.file = guiprefs.log_file;
3211         setpref('VMT','log',log)
3212     case 'iric'
3213         iric.path = guiprefs.iric_path;
3214         iric.file = guiprefs.iric_file;
3215         setpref('VMT','iric',iric)
3216     case 'excel'
3217         excel.path = guiprefs.excel_path;
3218         excel.file = guiprefs.excel_file;
3219         setpref('VMT','excel',excel)
3220     case 'aerial'
3221         aerial.path = guiprefs.aerial_path;
3222         aerial.file = guiprefs.aerial_file;
3223         setpref('VMT','aerial',aerial)
3224     case 'shoreline'
3225         shoreline.path = guiprefs.shoreline_path;
3226         shoreline.file = guiprefs.shoreline_file;
3227         setpref('VMT','shoreline',shoreline)
3228     otherwise
3229 end
3230 
3231 % if ismember(pref,prefs)
3232 %     setpref('VMT',pref,value)
3233 %
3234 %     guiprefs = getappdata(hfigure,'guiprefs');
3235 %     guiprefs.(pref) = value;
3236 %     setappdata(hfigure,'guiprefs',guiprefs)
3237 % end
3238 
3239 % [EOF] store_prefs
3240 
3241 
3242 % --------------------------------------------------------------------
3243 function initGUI(handles)
3244 % Initialize the UI controls in the GUI.
3245 
3246 guiparams = getappdata(handles.figure1,'guiparams');
3247 
3248 % Set the name and version
3249 set(handles.figure1,'Name',['Velocity Mapping Toolbox (VMT) ' guiparams.vmt_version], ...
3250     'DockControls','off')
3251 %set(handles.VMTversion,             'String',guiparams.vmt_version)
3252 
3253 % Set the PLOT 1 axis labels
3254 axes(handles.Plot1Shiptracks);
3255 set(handles.Plot1Shiptracks,'DataAspectRatio',[1 1 1],'PlotBoxAspectRatio',[1 1 1])
3256 xlabel('UTM Easting (m)')
3257 ylabel('UTM Northing (m)')
3258 box on
3259 grid on
3260 % ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM
3261 
3262 %%%%%%%%%%%%
3263 % MENU BAR %
3264 %%%%%%%%%%%%
3265 if guiparams.english_units
3266     set(handles.menuMetric, 'Checked','off')
3267     set(handles.menuEnglish,'Checked','on')
3268 else
3269     set(handles.menuMetric, 'Checked','on')
3270     set(handles.menuEnglish,'Checked','off')
3271 end
3272 
3273 if guiparams.set_cross_section_endpoints
3274     set(handles.menuCrossSectionEndpointAutomatic,'Checked','off')
3275     set(handles.menuCrossSectionEndpointManual,   'Checked','on')
3276 else
3277     set(handles.menuCrossSectionEndpointAutomatic,'Checked','on')
3278     set(handles.menuCrossSectionEndpointManual,   'Checked','off')
3279 end
3280 
3281 
3282 if guiparams.print
3283     set(handles.menuPrintFormat,       'Checked','on')
3284     set(handles.menuPresentationFormat,'Checked','off')
3285     set(handles.menuStylePrint,        'Checked','on')
3286     set(handles.menuStylePresentation, 'Checked','off')
3287 elseif guiparams.presentation
3288     set(handles.menuPrintFormat,       'Checked','off')
3289     set(handles.menuPresentationFormat,'Checked','on')
3290     set(handles.menuStylePrint,        'Checked','off')
3291     set(handles.menuStylePresentation, 'Checked','on')
3292 else
3293 end
3294 
3295 
3296 %%%%%%%%%%%%%%%
3297 % DATA EXPORT %
3298 %%%%%%%%%%%%%%%
3299 % BathymetryPanel
3300 % set(handles.BeamAngle,                  'String',guiparams.beam_angle)
3301 % set(handles.MagneticVariation,          'String',guiparams.magnetic_variation)
3302 % set(handles.WSE,                        'String',guiparams.wse)
3303 % set(handles.OutputAuxiliaryData,        'Value', guiparams.output_auxiliary_data)
3304 
3305 %%%%%%%%%%%%%%%%%%%%%%
3306 % PLOTTING/PLAN VIEW %
3307 %%%%%%%%%%%%%%%%%%%%%%
3308 % PlanViewPanel
3309 set(handles.DepthRangeMin,              'String',guiparams.depth_range_min)
3310 set(handles.DepthRangeMax,              'String',guiparams.depth_range_max)
3311 set(handles.VectorScalePlanView,        'String',guiparams.vector_scale_plan_view)
3312 set(handles.VectorSpacingPlanview,      'String',guiparams.vector_spacing_plan_view)
3313 set(handles.SmoothingWindowSize,        'String',guiparams.smoothing_window_size)
3314 set(handles.DisplayShoreline,           'Value', guiparams.display_shoreline)
3315 set(handles.AddBackground,              'Value', guiparams.add_background)
3316 
3317 %%%%%%%%%%%%%%%%%%%%%%%%
3318 % PLOTTING/SHIP TRACKS %
3319 %%%%%%%%%%%%%%%%%%%%%%%%
3320 % ShiptracksPanel
3321 set(handles.HorizontalGridNodeSpacing,  'String',guiparams.horizontal_grid_node_spacing)
3322 %set(handles.SetCrossSectionEndpoints,   'Value', guiparams.set_cross_section_endpoints)
3323 
3324 %%%%%%%%%%%%%%%%%%%%%%%%%%%
3325 % PLOTTING/CROSS SECTIONS %
3326 %%%%%%%%%%%%%%%%%%%%%%%%%%%
3327 % CrossSectionsPanel
3328 set(handles.Contour,                    'String',{guiparams.contours.string}, ...
3329     'Value', guiparams.idx_contour)
3330 set(handles.VerticalExaggeration,       'String',guiparams.vertical_exaggeration)
3331 set(handles.VectorScaleCrossSection,    'String',guiparams.vector_scale_cross_section)
3332 set(handles.HorizontalVectorSpacing,    'String',guiparams.horizontal_vector_spacing)
3333 set(handles.VerticalVectorSpacing,      'String',guiparams.vertical_vector_spacing)
3334 set(handles.HorizontalSmoothingWindow,  'String',guiparams.horizontal_smoothing_window)
3335 set(handles.VerticalSmoothingWindow,    'String',guiparams.vertical_smoothing_window)
3336 set(handles.PlotSecondaryFlowVectors,   'Value', guiparams.plot_secondary_flow_vectors)
3337 set(handles.SecondaryFlowVectorVariable,'String',{guiparams.secondary_flows.string}, ...
3338     'Value', guiparams.idx_secondary_flow_vector_variable)
3339 set(handles.IncludeVerticalVelocity,    'Value', guiparams.include_vertical_velocity)
3340 
3341 % set(handles.EnglishUnits,               'Value',guiparams.english_units)
3342 
3343 % [EOF] initGUI
3344 
3345 
3346 % --------------------------------------------------------------------
3347 function set_enable(handles,enable_state)
3348 
3349 guiparams = getappdata(handles.figure1,'guiparams');
3350 
3351 switch enable_state
3352     case 'init'
3353         set([handles.menuFile
3354             handles.menuOpen
3355             handles.menuOpenASCII
3356             handles.menuOpenMAT
3357             ],'Enable','on')
3358         
3359         set([handles.toolbarLoadData
3360             ],'Enable','on')
3361         set([handles.toolbarSaveMatFile
3362             handles.toolbarSaveBathymetry
3363             handles.toolbarSaveFigures
3364             handles.toolbarSaveExcel
3365             handles.toolbarPlottingParameters
3366             handles.toolbarProcessingParameters
3367             ],'Enable','off')
3368         
3369         set([handles.DepthRangeMin
3370             handles.DepthRangeMax
3371             handles.VectorScalePlanView
3372             handles.VectorSpacingPlanview
3373             handles.SmoothingWindowSize
3374             handles.DisplayShoreline
3375             handles.AddBackground
3376             handles.PlotPlanView
3377             ],'Enable','off')
3378         
3379         set([handles.HorizontalGridNodeSpacing
3380             handles.PlotShiptracks
3381             ],'Enable','off')
3382         
3383         set([handles.Contour
3384             handles.VerticalExaggeration
3385             handles.VectorScaleCrossSection
3386             handles.HorizontalVectorSpacing
3387             handles.VerticalVectorSpacing
3388             handles.HorizontalSmoothingWindow
3389             handles.VerticalSmoothingWindow
3390             handles.PlotSecondaryFlowVectors
3391             handles.SecondaryFlowVectorVariable
3392             handles.IncludeVerticalVelocity
3393             handles.PlotCrossSection
3394             ],'Enable','off')
3395         
3396     case 'fileloaded'
3397         set([handles.menuFile
3398             handles.menuOpen
3399             handles.menuOpenASCII
3400             handles.menuOpenMAT
3401             handles.menuSaveMAT
3402             handles.menuSaveTecplot
3403             handles.menuSaveKMZFile
3404             handles.menuParameters
3405             handles.menuPlottingParameters
3406             handles.menuMetric
3407             handles.menuEnglish
3408             handles.menuBathymetryExportSettings
3409             handles.menuExportMultibeamBathymetry
3410             handles.menuKMZExport
3411             ],'Enable','on')
3412         
3413         set([handles.toolbarLoadData
3414             handles.toolbarSaveMatFile
3415             handles.toolbarSaveBathymetry
3416             handles.toolbarSaveExcel
3417             handles.toolbarSaveFigures
3418             handles.toolbarPlottingParameters
3419             ],'Enable','on')
3420         set([handles.toolbarProcessingParameters
3421             ],'Enable','off')
3422         
3423            
3424         set([handles.DepthRangeMin
3425             handles.DepthRangeMax
3426             handles.VectorScalePlanView
3427             handles.VectorSpacingPlanview
3428             handles.SmoothingWindowSize
3429             handles.DisplayShoreline
3430             handles.PlotPlanView
3431             ],'Enable','on')
3432         if guiparams.has_mapping_toolbox
3433             set(handles.AddBackground,'Enable','on')
3434         else
3435             set(handles.AddBackground,'Enable','off')
3436         end
3437         
3438         set([handles.HorizontalGridNodeSpacing
3439             handles.PlotShiptracks
3440             ],'Enable','on')
3441         
3442         set([handles.Contour
3443             handles.VerticalExaggeration
3444             handles.VectorScaleCrossSection
3445             handles.HorizontalVectorSpacing
3446             handles.VerticalVectorSpacing
3447             handles.HorizontalSmoothingWindow
3448             handles.VerticalSmoothingWindow
3449             handles.PlotSecondaryFlowVectors
3450             handles.SecondaryFlowVectorVariable
3451             handles.IncludeVerticalVelocity
3452             handles.PlotCrossSection
3453             ],'Enable','on')
3454     case 'multiplematfiles'
3455         set([handles.menuFile
3456             handles.menuOpen
3457             handles.menuOpenASCII
3458             handles.menuOpenMAT
3459             handles.menuParameters
3460             handles.menuPlottingParameters
3461             handles.menuMetric
3462             handles.menuEnglish
3463             ],'Enable','on')
3464         set([handles.menuSaveMAT
3465             handles.menuBathymetryExportSettings
3466             handles.menuExportMultibeamBathymetry
3467             handles.menuKMZExport
3468             handles.menuSaveKMZFile
3469             handles.menuSaveTecplot
3470             ],'Enable','off')
3471         
3472         set([handles.toolbarLoadData
3473             handles.toolbarSaveFigures
3474             handles.toolbarPlottingParameters
3475             handles.toolbarSaveExcel
3476             ],'Enable','on')
3477         set([handles.toolbarProcessingParameters
3478             handles.toolbarSaveMatFile
3479             handles.toolbarSaveBathymetry
3480             ],'Enable','off')
3481         
3482         set([handles.DepthRangeMin
3483             handles.DepthRangeMax
3484             handles.VectorScalePlanView
3485             handles.VectorSpacingPlanview
3486             handles.SmoothingWindowSize
3487             handles.DisplayShoreline
3488             handles.PlotPlanView
3489             ],'Enable','on')
3490         if guiparams.has_mapping_toolbox
3491             set(handles.AddBackground,'Enable','on')
3492         else
3493             set(handles.AddBackground,'Enable','off')
3494         end
3495         
3496         set([handles.HorizontalGridNodeSpacing
3497             handles.PlotShiptracks
3498             ],'Enable','off')
3499         
3500         set([handles.Contour
3501             handles.VerticalExaggeration
3502             handles.VectorScaleCrossSection
3503             handles.HorizontalVectorSpacing
3504             handles.VerticalVectorSpacing
3505             handles.HorizontalSmoothingWindow
3506             handles.VerticalSmoothingWindow
3507             handles.PlotSecondaryFlowVectors
3508             handles.SecondaryFlowVectorVariable
3509             handles.IncludeVerticalVelocity
3510             handles.PlotCrossSection
3511             ],'Enable','off')
3512     otherwise
3513 end
3514 
3515 % [EOF] set_enable
3516 
3517 %% Compute the longitudinal dispersion coefficient
3518 
3519 %% --- Executes on button press in zerosecq_chkbox.
3520 %function zerosecq_chkbox_Callback(hObject, eventdata, handles)
3521 % hObject    handle to zerosecq_chkbox (see GCBO)
3522 % eventdata  reserved - to be defined in a future version of MATLAB
3523 % handles    structure with handles and user data (see GUIDATA)
3524 
3525 % Hint: get(hObject,'Value') returns toggle state of zerosecq_chkbox
3526 
3527 
3528 % --------------------------------------------------------------------
3529 function [english_units,set_cross_section_endpoints,plot_presentation_style,plot_print_style] = ...
3530     plotParametersDialog(english_units,set_cross_section_endpoints,plot_presentation_style,plot_print_style,hf)
3531 
3532 w = 500;
3533 h = 110;
3534 dx = 10;
3535 dy = 35;
3536 the_color = get(0,'factoryUipanelBackgroundColor');
3537 handles.Figure = figure('Name', 'Plotting Parameters', ...
3538     'Color',the_color, ...
3539     'NumberTitle','off', ...
3540     'HandleVisibility','callback', ...
3541     'WindowStyle','modal', ...
3542     'MenuBar','none', ...
3543     'ToolBar','none', ...
3544     'Units','pixels', ...
3545     'Position',[0 0 w h], ...
3546     'Resize','off', ...
3547     'Visible','off');
3548 dialog_params.english_units               = english_units;
3549 dialog_params.set_cross_section_endpoints = set_cross_section_endpoints;
3550 dialog_params.presentation                = plot_presentation_style; %presentation;
3551 dialog_params.print                       = plot_print_style; %print;
3552 setappdata(handles.Figure,'dialog_params',dialog_params)
3553 setappdata(handles.Figure,'original_dialog_params',dialog_params)
3554 
3555 % Build the graphics:
3556 % -------------------
3557 handles.UnitsPanel = uipanel('Parent',handles.Figure, ...
3558     'Title', 'Units', ...
3559     'Units','pixels', ...
3560     'Position',[dx dy (w-3*dx)/3 h-dx-dy+10]);
3561 handles.UnitsMetric = uicontrol('Style','checkbox', ...
3562     'Parent',handles.UnitsPanel, ...
3563     'String','Metric', ...
3564     'Units','pixels', ...
3565     'Position',[15 35 100 22]);
3566 handles.UnitsEnglish = uicontrol('Style','checkbox', ...
3567     'Parent',handles.UnitsPanel, ...
3568     'String','English', ...
3569     'Units','pixels', ...
3570     'Position',[15 10 100 22]);
3571 
3572 handles.EndpointsPanel = uipanel('Parent',handles.Figure, ...
3573     'Title', 'Cross-Section Endpoints', ...
3574     'Units','pixels', ...
3575     'Position',[(w+dx)/3 dy (w-3*dx)/3 h-dx-dy+10]);
3576 handles.EndpointsAutomatic = uicontrol('Style','checkbox', ...
3577     'Parent',handles.EndpointsPanel, ...
3578     'String','Automatic', ...
3579     'Units','pixels', ...
3580     'Position',[15 35 100 22]);
3581 handles.EndpointsManual = uicontrol('Style','checkbox', ...
3582     'Parent',handles.EndpointsPanel, ...
3583     'String','Set Manually', ...
3584     'Units','pixels', ...
3585     'Position',[15 10 100 22]);
3586 
3587 handles.StylePanel = uipanel('Parent',handles.Figure, ...
3588     'Title', 'Plot Style', ...
3589     'Units','pixels', ...
3590     'Position',[w-w/3 dy (w-3*dx)/3 h-dx-dy+10]);
3591 handles.StylePresentation = uicontrol('Style','checkbox', ...
3592     'Parent',handles.StylePanel, ...
3593     'String','Presentation', ...
3594     'Units','pixels', ...
3595     'Position',[15 35 100 22]);
3596 handles.StylePrint = uicontrol('Style','checkbox', ...
3597     'Parent',handles.StylePanel, ...
3598     'String','Print', ...
3599     'Units','pixels', ...
3600     'Position',[15 10 100 22]);
3601 
3602 handles.OK = uicontrol('Style',   'pushbutton', ...
3603     'Parent',  handles.Figure, ...
3604     'String',  'OK', ...
3605     'Units',   'pixels', ...
3606     'Position',[w/2-80-dx/4 6 80 22]);
3607 handles.Cancel = uicontrol('Style',   'pushbutton', ...
3608     'Parent',  handles.Figure, ...
3609     'String',  'Cancel', ...
3610     'Units',   'pixels', ...
3611     'Position',[w/2+dx/4 6 80 22]);
3612 
3613 % Update the UI controls:
3614 % -----------------------
3615 if dialog_params.english_units
3616     set(handles.UnitsMetric, 'Value',0)
3617     set(handles.UnitsEnglish,'Value',1)
3618 else
3619     set(handles.UnitsMetric, 'Value',1)
3620     set(handles.UnitsEnglish,'Value',0)
3621 end
3622 if dialog_params.set_cross_section_endpoints
3623     set(handles.EndpointsAutomatic,'Value',0)
3624     set(handles.EndpointsManual,   'Value',1)
3625 else
3626     set(handles.EndpointsAutomatic,'Value',1)
3627     set(handles.EndpointsManual,   'Value',0)
3628 end
3629 if dialog_params.presentation
3630     set(handles.StylePresentation, 'Value',1)
3631     set(handles.StylePrint,        'Value',0)
3632 else
3633     set(handles.StylePresentation, 'Value',0)
3634     set(handles.StylePrint,        'Value',1)
3635 end
3636 
3637 % Set the callbacks:
3638 % ------------------
3639 set(handles.Figure,            'CloseRequestFcn',{@dialogCloseReq, handles.OK})
3640 set(handles.UnitsMetric,       'Callback',       {@dialogUnits,    handles,'metric'})
3641 set(handles.UnitsEnglish,      'Callback',       {@dialogUnits,    handles,'english'})
3642 set(handles.EndpointsAutomatic,'Callback',       {@dialogEnpoints, handles,'auto'})
3643 set(handles.EndpointsManual,   'Callback',       {@dialogEnpoints, handles,'manual'})
3644 set(handles.StylePresentation, 'Callback',       {@dialogPlotStyle,handles,'presentation'})
3645 set(handles.StylePrint,        'Callback',       {@dialogPlotStyle,handles,'print'})
3646 set(handles.OK,                'Callback',       {@dialogOK,       handles.OK})
3647 set(handles.Cancel,            'Callback',       {@dialogCancel,   handles})
3648 
3649 % Position the dialog and make it visible:
3650 % ----------------------------------------
3651 fpos = get(hf,'Position');
3652 dpos = [(fpos(1) + fpos(3)/2 -w/2) (fpos(2) + fpos(4)/2)];
3653 movegui(handles.Figure,dpos)
3654 set(handles.Figure,'Visible','on')
3655 
3656 % Hold the dialog open:
3657 % ---------------------
3658 waitfor(handles.OK)
3659 
3660 % Return the outputs and close the dialog:
3661 % ----------------------------------------
3662 dialog_params = getappdata(handles.Figure,'dialog_params');
3663 english_units = dialog_params.english_units;
3664 set_cross_section_endpoints = dialog_params.set_cross_section_endpoints;
3665 plot_presentation_style =  dialog_params.presentation;
3666 plot_print_style =  dialog_params.print;
3667 
3668 delete(handles.Figure)
3669 
3670 % [EOF] plotParametersDialog
3671 
3672 
3673 % --------------------------------------------------------------------
3674 function dialogUnits(hObject,eventdata,handles,the_units)
3675 
3676 dialog_params = getappdata(handles.Figure,'dialog_params');
3677 switch the_units
3678     case 'metric'
3679         dialog_params.english_units = false;
3680         
3681         set(handles.UnitsMetric, 'Value',1)
3682         set(handles.UnitsEnglish,'Value',0)
3683     case 'english'
3684         dialog_params.english_units = true;
3685         
3686         set(handles.UnitsMetric, 'Value',0)
3687         set(handles.UnitsEnglish,'Value',1)
3688     otherwise
3689 end
3690 setappdata(handles.Figure,'dialog_params',dialog_params)
3691 
3692 % [EOF] dialogUnits
3693 
3694 % --------------------------------------------------------------------
3695 function dialogEnpoints(hObject,eventdata,handles,the_endpoints)
3696 
3697 dialog_params = getappdata(handles.Figure,'dialog_params');
3698 switch the_endpoints
3699     case 'auto'
3700         dialog_params.set_cross_section_endpoints = false;
3701         
3702         set(handles.EndpointsAutomatic,'Value',1)
3703         set(handles.EndpointsManual,   'Value',0)
3704     case 'manual'
3705         dialog_params.set_cross_section_endpoints = true;
3706         
3707         set(handles.EndpointsAutomatic,'Value',0)
3708         set(handles.EndpointsManual,   'Value',1)
3709     otherwise
3710 end
3711 setappdata(handles.Figure,'dialog_params',dialog_params)
3712 
3713 % [EOF] dialogEnpoints
3714 
3715 function dialogPlotStyle(hObject,eventdata,handles,the_style)
3716 
3717 dialog_params = getappdata(handles.Figure,'dialog_params');
3718 switch the_style
3719     case 'presentation'
3720         dialog_params.presentation  = true;
3721         dialog_params.print         = false;
3722         
3723         set(handles.StylePresentation,'Value',1)
3724         set(handles.StylePrint,       'Value',0)
3725     case 'print'
3726         dialog_params.presentation  = false;
3727         dialog_params.print         = true;
3728         
3729         set(handles.StylePresentation,'Value',0)
3730         set(handles.StylePrint,       'Value',1)
3731     otherwise
3732 end
3733 setappdata(handles.Figure,'dialog_params',dialog_params)
3734 
3735 % [EOF] dialogEnpoints
3736 
3737 % --------------------------------------------------------------------
3738 function dialogOK(hObject,eventdata,h_OK)
3739 
3740 delete(h_OK)
3741 
3742 % [EOF] dialogOK
3743 
3744 % --------------------------------------------------------------------
3745 function dialogCancel(hObject,eventdata,handles)
3746 % Return the original inputs
3747 dialog_params = getappdata(handles.Figure,'original_dialog_params');
3748 setappdata(handles.Figure,'dialog_params',dialog_params)
3749 delete(handles.OK)
3750 
3751 % [EOF] dialogCancel
3752 
3753 % --------------------------------------------------------------------
3754 function dialogCloseReq(hObject,eventdata,h_OK)
3755 
3756 delete(h_OK)
3757 
3758 % [EOF] dialogCloseReq
3759 
3760 function [beam_angle,magnetic_variation,wse,output_auxiliary_data] = exportSettingsDialog(beam_angle,magnetic_variation,wse,output_auxiliary_data,hf)
3761 w = 230;
3762 h = 200;
3763 dx = 10;
3764 dy = 35;
3765 the_color = get(0,'factoryUipanelBackgroundColor');
3766 handles.Figure = figure('Name', 'Export Settings', ...
3767     'Color',the_color, ...
3768     'NumberTitle','off', ...
3769     'HandleVisibility','callback', ...
3770     'WindowStyle','modal', ...
3771     'MenuBar','none', ...
3772     'ToolBar','none', ...
3773     'Units','pixels', ...
3774     'Position',[0 0 w h], ...
3775     'Resize','off', ...
3776     'Visible','off');
3777 dialog_params.beam_angle             = beam_angle;
3778 dialog_params.magnetic_variation     = magnetic_variation;
3779 dialog_params.wse                    = wse;
3780 dialog_params.output_auxiliary_data = output_auxiliary_data;
3781 setappdata(handles.Figure,'dialog_params',dialog_params)
3782 setappdata(handles.Figure,'original_dialog_params',dialog_params)
3783 
3784 % Build the graphics:
3785 % -------------------
3786 ph = 150;
3787 handles.BathymetryPanel = uipanel('Parent',handles.Figure, ...
3788     'Title', 'Bathymetry', ...
3789     'Units','pixels', ...
3790     'Position',[dx dy (w-2*dx) h-dx-dy+10]);
3791 handles.BeamAngleText = uicontrol('Style','text', ...
3792     'Parent',handles.BathymetryPanel, ...
3793     'String','Beam Angle (deg)', ...
3794     ...'Value',beam_angle,...
3795     'HorizontalAlignment','right',...
3796     'Units','pixels', ...
3797     'Position',[dx+5 h-ph+60-4 100 22]);
3798 handles.BeamAngle = uicontrol('Style','edit', ...
3799     'Parent',handles.BathymetryPanel, ...
3800     ...'String','Beam Angle (deg)', ...
3801     'String',beam_angle,...
3802     'BackgroundColor','w',...
3803     'Units','pixels', ...
3804     'Position',[w-dx-80 h-ph+60 50 22]);
3805 handles.MagneticVariationText = uicontrol('Style','text', ...
3806     'Parent',handles.BathymetryPanel, ...
3807     'String','Magnetic Variation', ...
3808     ...'Value',beam_angle,...
3809     'HorizontalAlignment','right',...
3810     'Units','pixels', ...
3811     'Position',[dx+5 h-ph+30-4 100 22]);
3812 handles.MagneticVariation = uicontrol('Style','edit', ...
3813     'Parent',handles.BathymetryPanel, ...
3814     ...'String','Magnetic Variation', ...
3815     'String',magnetic_variation,...
3816     'BackgroundColor','w',...
3817     'Units','pixels', ...
3818     'Position',[w-dx-80 h-ph+30 50 22]);
3819 handles.WSEText = uicontrol('Style','text', ...
3820     'Parent',handles.BathymetryPanel, ...
3821     'String','WSE (m)', ...
3822     ...'Value',beam_angle,...
3823     'HorizontalAlignment','right',...
3824     'Units','pixels', ...
3825     'Position',[dx+5 h-ph-4 100 22]);
3826 handles.WSE = uicontrol('Style','edit', ...
3827     'Parent',handles.BathymetryPanel, ...
3828     ...'String','Magnetic Variation', ...
3829     'String',wse,...
3830     'BackgroundColor','w',...
3831     'Units','pixels', ...
3832     'Position',[w-dx-80 h-ph 50 22]);
3833 handles.OutputauxiliaryData = uicontrol('Style','checkbox', ...
3834     'Parent',handles.BathymetryPanel, ...
3835     'String','Output auxiliary Data', ...
3836     'Units','pixels', ...
3837     'Position',[dx+5 20 w-2*dx-30 22]);
3838 handles.OK = uicontrol('Style',   'pushbutton', ...
3839     'Parent',  handles.Figure, ...
3840     'String',  'OK', ...
3841     'Units',   'pixels', ...
3842     'Position',[w/2-80-dx/4 6 80 22]);
3843 handles.Cancel = uicontrol('Style',   'pushbutton', ...
3844     'Parent',  handles.Figure, ...
3845     'String',  'Cancel', ...
3846     'Units',   'pixels', ...
3847     'Position',[w/2+dx/4 6 80 22]);
3848 
3849 % Update the UI controls:
3850 % -----------------------
3851 set(handles.BeamAngle,                'String',dialog_params.beam_angle)
3852 set(handles.MagneticVariation,        'String',dialog_params.magnetic_variation)
3853 set(handles.WSE,                      'String',dialog_params.wse)
3854 set(handles.OutputauxiliaryData,     'Value', double(dialog_params.output_auxiliary_data))
3855 
3856 % Set the callbacks:
3857 % ------------------
3858 set(handles.Figure,                      'CloseRequestFcn',{@dialogCloseReq,handles.OK})
3859 set(handles.BeamAngle,                   'Callback',       {@dialogExportSettings,handles})
3860 set(handles.MagneticVariation,           'Callback',       {@dialogExportSettings,handles})
3861 set(handles.WSE,                         'Callback',       {@dialogExportSettings,handles})
3862 set(handles.OutputauxiliaryData,        'Callback',       {@dialogExportSettings,handles})
3863 set(handles.OK,                          'Callback',       {@dialogOK,      handles.OK})
3864 set(handles.Cancel,                      'Callback',       {@dialogCancel,  handles})
3865 
3866 % Position the dialog and make it visible:
3867 % ----------------------------------------
3868 fpos = get(hf,'Position');
3869 dpos = [(fpos(1) + fpos(3)/2 -w/2) (fpos(2) + fpos(4)/2)];
3870 movegui(handles.Figure,dpos)
3871 set(handles.Figure,'Visible','on')
3872 
3873 % Hold the dialog open:
3874 % ---------------------
3875 waitfor(handles.OK)
3876 
3877 % Return the outputs and close the dialog:
3878 % ----------------------------------------
3879 dialog_params           = getappdata(handles.Figure,'dialog_params');
3880 beam_angle              = dialog_params.beam_angle;
3881 magnetic_variation      = dialog_params.magnetic_variation;
3882 wse                     = dialog_params.wse;
3883 output_auxiliary_data  = logical(dialog_params.output_auxiliary_data);
3884 
3885 delete(handles.Figure)
3886 
3887 % [EOF] exportSettingsDialog
3888 
3889 % --------------------------------------------------------------------
3890 function dialogExportSettings(hObject,eventdata,handles)
3891 
3892 % Grab the current data
3893 dialog_params = getappdata(handles.Figure,'dialog_params');
3894 
3895 % Set it according to the dialog box values
3896 dialog_params.beam_angle                = get(handles.BeamAngle,'String');
3897 dialog_params.magnetic_variation        = get(handles.MagneticVariation,'String');
3898 dialog_params.wse                       = get(handles.WSE,'String');
3899 dialog_params.output_auxiliary_data    = get(handles.OutputauxiliaryData,'Value');
3900 
3901 % Re-store the application data
3902 setappdata(handles.Figure,'dialog_params',dialog_params)
3903 
3904 % [EOF] dialogExportSettings
3905 
3906 function [selected_figures] = openFiguresDialog(figure_names,hf)
3907 
3908 w = 230;
3909 h = 200;
3910 dx = 10;
3911 dy = 35;
3912 the_color = get(0,'factoryUipanelBackgroundColor');
3913 handles.Figure = figure('Name', 'Select open figures to export', ...
3914     'Color',the_color, ...
3915     'NumberTitle','off', ...
3916     'HandleVisibility','callback', ...
3917     'WindowStyle','modal', ...
3918     'MenuBar','none', ...
3919     'ToolBar','none', ...
3920     'Units','pixels', ...
3921     'Position',[0 0 w h], ...
3922     'Resize','off', ...
3923     'Visible','off');
3924 dialog_params.figure_names               = figure_names;
3925 dialog_params.selected_figures           = '';
3926 setappdata(handles.Figure,'dialog_params',dialog_params)
3927 setappdata(handles.Figure,'original_dialog_params',dialog_params)
3928 
3929 % Build the graphics:
3930 % -------------------
3931 handles.ListboxPanel = uipanel('Parent',handles.Figure, ...
3932     'Title', 'Figures', ...
3933     'Units','pixels', ...
3934     'Position',[dx dy (w-2*dx) h-dx-dy+10]);
3935 handles.Figures = uicontrol('Style','listbox', ...
3936     'Parent',handles.ListboxPanel, ...
3937     'BackGroundColor','white',...
3938     'String',figure_names, ...
3939     'Min', 0,...
3940     'Max', 2,...
3941     'Units','pixels', ...
3942     'Position',[15 35 (w-5*dx) 100]);
3943 
3944 
3945 handles.OK = uicontrol('Style',   'pushbutton', ...
3946     'Parent',  handles.Figure, ...
3947     'String',  'OK', ...
3948     'Units',   'pixels', ...
3949     'Position',[w/2-80-dx/4 6 80 22]);
3950 handles.Cancel = uicontrol('Style',   'pushbutton', ...
3951     'Parent',  handles.Figure, ...
3952     'String',  'Cancel', ...
3953     'Units',   'pixels', ...
3954     'Position',[w/2+dx/4 6 80 22]);
3955 
3956 % Update the UI controls:
3957 % -----------------------
3958 
3959 
3960 % Set the callbacks:
3961 % ------------------
3962 set(handles.Figure,            'CloseRequestFcn',{@dialogCloseReq,handles.OK})
3963 set(handles.Figures,           'Callback',       {@dialogSelectFigures    handles})
3964 set(handles.OK,                'Callback',       {@dialogOK,       handles.OK})
3965 set(handles.Cancel,            'Callback',       {@dialogCancel,   handles})
3966 
3967 % Position the dialog and make it visible:
3968 % ----------------------------------------
3969 fpos = get(hf,'Position');
3970 dpos = [(fpos(1) + fpos(3)/2 -w/2) (fpos(2) + fpos(4)/2)];
3971 movegui(handles.Figure,dpos)
3972 set(handles.Figure,'Visible','on')
3973 
3974 % Hold the dialog open:
3975 % ---------------------
3976 waitfor(handles.OK)
3977 
3978 % Return the outputs and close the dialog:
3979 % ----------------------------------------
3980 dialog_params = getappdata(handles.Figure,'dialog_params');
3981 selected_figures = dialog_params.selected_figures;
3982 
3983 delete(handles.Figure)
3984 
3985 % [EOF] openFiguresDialog
3986 
3987 % --------------------------------------------------------------------
3988 function dialogSelectFigures(hObject,eventdata,handles)
3989 
3990 dialog_params = getappdata(handles.Figure,'dialog_params');
3991 
3992 idx_selected = get(handles.Figures,'Value');
3993 fig_names    = get(handles.Figures,'String');
3994 selected     = fig_names(idx_selected);
3995 dialog_params.selected_figures = selected;
3996 
3997 setappdata(handles.Figure,'dialog_params',dialog_params)
3998 
3999 
4000 
4001 % --------------------------------------------------------------------
4002 function icons = getIcons
4003 
4004 % Load data
4005 idx = 1;
4006 icons(idx).data(:,:,1) = ...
4007     [NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN
4008     NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   129   120   135   188   NaN   NaN   NaN
4009     NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN    96   189   NaN   NaN   130   NaN    95   NaN
4010     NaN   NaN   206   206   206   206   NaN   NaN   NaN   NaN   NaN   NaN   NaN    84    79   NaN
4011     NaN   206   255   255   255   255   198   197   NaN   NaN   NaN   NaN    83    79    76   NaN
4012     198   255   255   255   255   255   255   198   198   198   198   198   198   212   212   NaN
4013     198   255   255   255   255   255   255   255   255   255   255   255   198   157   197   NaN
4014     198   255   226   198   198   198   198   198   198   198   198   198   198   198   177   NaN
4015     198   255   198   218   255   255   255   255   255   255   255   255   255   255   161   NaN
4016     198   253   198   247   255   255   255   255   255   255   255   255   255   251   155   NaN
4017     198   226   201   255   255   255   255   255   255   255   255   255   231   206   165   NaN
4018     198   207   215   255   255   255   255   255   255   255   255   255   239   198   159   NaN
4019     198   198   240   255   255   255   255   255   255   255   255   255   222   157   159   NaN
4020     198   199   255   255   255   255   255   255   255   255   255   255   191   165   159   NaN
4021     NaN   165   165   165   165   165   165   165   165   165   165   165   165   159   159   NaN
4022     NaN   NaN   159   159   159   159   159   159   159   159   159   159   159   159   NaN   NaN]/255;
4023 
4024 icons(idx).data(:,:,2) = ...
4025     [NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN
4026     NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   145   137   149   195   NaN   NaN   NaN
4027     NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   116   196   NaN   NaN   145   NaN   116   NaN
4028     NaN   NaN   162   162   162   162   NaN   NaN   NaN   NaN   NaN   NaN   NaN   107   105   NaN
4029     NaN   162   255   255   255   255   154   197   NaN   NaN   NaN   NaN   106   104   103   NaN
4030     154   255   255   255   255   255   255   154   154   154   154   154   154   208   208   NaN
4031     154   243   243   243   243   243   243   255   255   255   255   255   154   123   197   NaN
4032     154   235   193   154   154   154   154   154   154   154   154   154   154   154   137   NaN
4033     154   215   154   191   255   255   251   255   255   255   255   255   231   255   126   NaN
4034     154   213   154   240   255   255   255   255   255   255   255   255   199   249   123   NaN
4035     154   179   160   255   247   247   247   247   247   247   247   247   190   188   115   NaN
4036     154   162   184   255   235   235   235   235   235   235   235   231   186   154   169   NaN
4037     154   154   228   255   227   227   227   227   227   227   227   223   178   123   169   NaN
4038     154   156   255   215   215   215   215   215   215   215   215   215   153   115   169   NaN
4039     NaN   115   115   115   115   115   115   115   115   115   115   115   115   169   169   NaN
4040     NaN   NaN   169   169   169   169   169   169   169   169   169   169   169   169   NaN   NaN]/255;
4041 
4042 icons(idx).data(:,:,3) = ...
4043     [NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN
4044     NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   166   161   170   202   NaN   NaN   NaN
4045     NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   149   205   NaN   NaN   166   NaN   148   NaN
4046     NaN   NaN    34    34    34    34   NaN   NaN   NaN   NaN   NaN   NaN   NaN   141   144   NaN
4047     NaN    34   255   255   255   255    25   197   NaN   NaN   NaN   NaN   142   145   147   NaN
4048     25   255   156   156   156   156   255    25    25    25    25    25    25   200   200   NaN
4049     25   156   140   140   140   140   140   255   255   255   255   255    25    26   197   NaN
4050     25   132    80    25    25    25    25    25    25    25    25    25    25    25    25   NaN
4051     25   132    25   108   255   255   247   255   255   255   255   255   132   255    25   NaN
4052     25   112    25   137   156   156   156   156   156   156   156   156    91   150    25   NaN
4053     25    67    33   165   148   148   148   148   148   148   148   148    83    92    13   NaN
4054     25    38    64   156   132   132   132   132   132   132   132   132    67    25   176   NaN
4055     25    26   122   156   124   124   124   124   124   124   124   124    67    26   176   NaN
4056     25    28   156   108   108   108   108   108   108   108   108   108    41    13   176   NaN
4057     NaN    13    13    13    13    13    13    13    13    13    13    13    13   176   176   NaN
4058     NaN   NaN   176   176   176   176   176   176   176   176   176   176   176   176   NaN   NaN]/255;
4059 
4060 % Save data
4061 idx = idx+1;
4062 icons(idx).data(:,:,1) = ...
4063     [NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN
4064     NaN    0.6902    0.6902    0.6902    0.6902    0.6902    0.6274    0.6274    0.5647    0.5647    0.5647    0.5019    0.5019    0.4392    0.2510       NaN
4065     NaN    0.6902    0.7529    0.5647    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    0.9412    0.3137    0.3765    0.2510    0.4670
4066     NaN    0.6902    0.7529    0.5647    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    0.9412    0.9412    0.2510    0.1882    0.2510    0.4670
4067     NaN    0.6274    0.7529    0.5019    1.0000    1.0000    1.0000    1.0000    1.0000    0.9412    0.9412    0.8784    0.1882    0.5019    0.2510    0.4670
4068     NaN    0.6274    0.7529    0.4392    1.0000    1.0000    1.0000    1.0000    0.9412    0.9412    0.8784    0.8157    0.1882    0.4392    0.2510    0.4670
4069     NaN    0.6274    0.7529    0.4392    1.0000    1.0000    1.0000    0.9412    0.9412    0.8784    0.8157    0.7529    0.1255    0.3765    0.2510    0.4670
4070     NaN    0.5647    0.7529    0.3765    1.0000    1.0000    0.9412    0.9412    0.8784    0.8157    0.7529    0.7529    0.0627    0.3765    0.2510    0.4670
4071     NaN    0.5647    0.7529    0.6902    0.3765    0.3137    0.3137    0.2510    0.1882    0.1882    0.1255    0.0627    0.3765    0.3137    0.2510    0.4670
4072     NaN    0.5019    0.6902    0.6902    0.6274    0.5647    0.5019    0.5019    0.5019    0.4392    0.4392    0.3765    0.3137    0.3137    0.2510    0.4670
4073     NaN    0.5019    0.6902    0.6274    0.5647    0.3137    0.3137    0.3137    0.3137    0.3137    0.3765    0.3137    0.3137    0.2510    0.2510    0.4670
4074     NaN    0.4392    0.6274    0.5647    0.5019    0.3137       NaN    0.1882    0.8157    0.8157    0.3765    0.2510    0.2510    0.2510    0.2510    0.4670
4075     NaN    0.4392    0.6274    0.5019    0.5019    0.3137    0.1882    0.4392    0.8784    0.8784    0.4392    0.1882    0.2510    0.1882    0.2510    0.4670
4076     NaN    0.4392    0.5647    0.5019    0.1255    0.1255    0.6902    0.6902    0.7529    0.7529    0.3137    0.1882    0.1882    0.1882    0.2510    0.4670
4077     NaN    0.7333    0.2510    0.2510    0.2510    0.2510    0.2510    0.2510    0.2510    0.2510    0.2510    0.2510    0.2510    0.2510    0.2510    0.4670
4078     NaN       NaN    0.4670    0.4670    0.4670    0.4670    0.4670    0.4670    0.4670    0.4670    0.4670    0.4670    0.4670    0.4670    0.4670    0.4670];
4079 
4080 icons(idx).data(:,:,2) = ...
4081     [NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN
4082     NaN    0.7216    0.7216    0.6902    0.6902    0.6588    0.6274    0.5961    0.5647    0.5647    0.5333    0.5019    0.4706    0.4706    0.2196       NaN
4083     NaN    0.6902    0.7529    0.5647    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    0.9725    0.3451    0.3451    0.2196    0.5378
4084     NaN    0.6902    0.7529    0.5333    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    0.9725    0.9412    0.3137    0.1882    0.2196    0.5378
4085     NaN    0.6588    0.7529    0.5019    1.0000    1.0000    1.0000    1.0000    1.0000    0.9725    0.9412    0.9098    0.3137    0.4706    0.2196    0.5378
4086     NaN    0.6274    0.7529    0.4706    1.0000    1.0000    1.0000    1.0000    0.9725    0.9412    0.9098    0.8470    0.2824    0.4392    0.2196    0.5378
4087     NaN    0.5961    0.7529    0.4392    1.0000    1.0000    1.0000    0.9725    0.9412    0.9098    0.8470    0.8157    0.2510    0.4078    0.2196    0.5378
4088     NaN    0.5647    0.7529    0.4078    1.0000    1.0000    0.9725    0.9412    0.9098    0.8470    0.8157    0.7843    0.2196    0.3765    0.2196    0.5378
4089     NaN    0.5333    0.7216    0.7216    0.3765    0.3765    0.3451    0.3137    0.3137    0.2824    0.2510    0.2196    0.3765    0.3451    0.2196    0.5378
4090     NaN    0.5019    0.6902    0.6902    0.6274    0.5647    0.5333    0.5019    0.4706    0.4392    0.4078    0.3765    0.3451    0.3137    0.2196    0.5378
4091     NaN    0.4706    0.6588    0.6274    0.5647    0.3451    0.3451    0.3451    0.3451    0.3765    0.4078    0.3451    0.3137    0.2824    0.2196    0.5378
4092     NaN    0.4706    0.6274    0.5647    0.5333    0.3451       NaN    0.2510    0.8470    0.8784    0.4706    0.2824    0.2824    0.2510    0.2196    0.5378
4093     NaN    0.4392    0.5961    0.5333    0.5019    0.3451    0.2510    0.4706    0.8784    0.9098    0.5019    0.2510    0.2510    0.2510    0.2196    0.5378
4094     NaN    0.4078    0.5647    0.5019    0.2824    0.1882    0.7216    0.7216    0.7529    0.7843    0.3137    0.2510    0.2510    0.2196    0.2196    0.5378
4095     NaN    0.7176    0.2196    0.2196    0.2196    0.2196    0.2196    0.2196    0.2196    0.2196    0.2196    0.2196    0.2196    0.2196    0.2196    0.5378
4096     NaN       NaN    0.5378    0.5378    0.5378    0.5378    0.5378    0.5378    0.5378    0.5378    0.5378    0.5378    0.5378    0.5378    0.5378    0.5378];
4097 
4098 icons(idx).data(:,:,3) = ...
4099     [NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN       NaN
4100     NaN    0.9412    0.9412    0.9412    0.9412    0.9412    0.9412    0.8784    0.8784    0.8784    0.8784    0.8784    0.8157    0.8157    0.4392       NaN
4101     NaN    0.9412    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    0.7529    0.6902    0.4392    0.5997
4102     NaN    0.9412    1.0000    0.9412    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    0.9412    0.7529    0.3765    0.4392    0.5997
4103     NaN    0.9412    1.0000    0.8784    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    0.9412    0.9412    0.6902    0.8784    0.4392    0.5997
4104     NaN    0.9412    1.0000    0.8784    1.0000    1.0000    1.0000    1.0000    1.0000    0.9412    0.9412    0.9412    0.6902    0.8157    0.4392    0.5997
4105     NaN    0.8784    1.0000    0.8157    1.0000    1.0000    1.0000    1.0000    0.9412    0.9412    0.9412    0.8784    0.6274    0.8157    0.4392    0.5997
4106     NaN    0.8784    1.0000    0.8157    1.0000    1.0000    1.0000    0.9412    0.9412    0.9412    0.8784    0.8784    0.6274    0.7529    0.4392    0.5997
4107     NaN    0.8784    1.0000    1.0000    0.8157    0.7529    0.7529    0.7529    0.6902    0.6902    0.6274    0.6274    0.7529    0.7529    0.4392    0.5997
4108     NaN    0.8784    1.0000    1.0000    1.0000    0.9412    0.9412    0.8784    0.8784    0.8157    0.8157    0.7529    0.7529    0.6902    0.4392    0.5997
4109     NaN    0.8157    1.0000    1.0000    0.9412    0.4392    0.4392    0.4392    0.4392    0.4392    0.5019    0.7529    0.6902    0.6902    0.4392    0.5997
4110     NaN    0.8157    1.0000    0.9412    0.9412    0.4392       NaN    0.2510    0.9412    0.9412    0.5019    0.6902    0.6902    0.6274    0.4392    0.5997
4111     NaN    0.8157    1.0000    0.9412    0.8784    0.4392    0.2510    0.5647    0.9412    0.9412    0.5647    0.6274    0.6274    0.6274    0.4392    0.5997
4112     NaN    0.8157    0.9412    0.8784    0.6902    0.2510    0.7529    0.7529    0.8157    0.8157    0.3137    0.6274    0.6274    0.6274    0.4392    0.5997
4113     NaN    0.8275    0.4392    0.4392    0.4392    0.4392    0.4392    0.4392    0.4392    0.4392    0.4392    0.4392    0.4392    0.4392    0.4392    0.5997
4114     NaN       NaN    0.5997    0.5997    0.5997    0.5997    0.5997    0.5997    0.5997    0.5997    0.5997    0.5997    0.5997    0.5997    0.5997    0.5997];
4115 
4116 % Plotting parameters
4117 idx = idx+1;
4118 icons(idx).data(:,:,1) = ...
4119     [  0     0     0     0     0     0     0     0     0     0     0     0     0     0     0   255
4120     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4121     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   165
4122     0   255   203    79   213   255   255   255   255   255   254   160   109   247     0   165
4123     0   254    71   224    79   255   255   255   255   255   211   101   165   123     0   165
4124     0   191   123   255   123   203   255   255   255   255   101   224   254    79     0   165
4125     0   101   239   255   224   109   255   255   255   247    79   254   254   123    36   165
4126     0   123   254   255   255    79   247   255   255   165   165   255   255   224     0   165
4127     0   255   255   255   254   160   173   255   255    87   239   255   255   255     0   165
4128     0   255   255   255   255   224   101   255   239    87   255   255   255   255     0   165
4129     0   255   255   255   255   255   101   224   123   191   255   255   255   255     0   165
4130     0   255   255   255   255   254   224    54   101   255   255   255   255   255     0   165
4131     0   255   255   255   255   255   255   247   255   255   255   255   255   255     0   165
4132     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   165
4133     0     0     0     1     0     0     0     0     0     0     0     0     0     0     0   165
4134     255   165   165   165   172   165   165   165   165   165   165   165   165   165   165   165]/255;
4135 
4136 icons(idx).data(:,:,2) = ...
4137     [  0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
4138     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0     0
4139     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   165
4140     0   255   203    79   213   255   255   255   255   255   254   160   109   247     0   165
4141     0   254    71   224    79   255   255   255   255   255   211   101   165   123     0   165
4142     0   191   123   255   123   203   255   255   255   255   101   224   254    79     0   165
4143     0   101   239   255   224   109   255   255   255   247    79   254   254   123     0   165
4144     0   123   254   255   255    79   247   255   255   165   165   255   255   224     0   165
4145     0   255   255   255   254   160   173   255   255    87   239   255   255   255     0   165
4146     0   255   255   255   255   224   101   255   239    87   255   255   255   255     0   165
4147     0   255   255   255   255   255   101   224   123   191   255   255   255   255     0   165
4148     0   255   255   255   255   254   224    54   101   255   255   255   255   255     0   165
4149     0   255   255   255   255   255   255   247   255   255   255   255   255   255     0   165
4150     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   165
4151     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0   165
4152     0   165   165   165   153   165   165   165   165   165   165   165   165   165   165   165]/255;
4153 
4154 icons(idx).data(:,:,3) = ...
4155     [  0     0     0     0     0     0     0     0     0     0     0     0     0     0     0   255
4156     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4157     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   145
4158     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   145
4159     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   145
4160     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   145
4161     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   145
4162     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   145
4163     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   145
4164     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   145
4165     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   145
4166     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   145
4167     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   145
4168     0   255   255   255   255   255   255   255   255   255   255   255   255   255     0   145
4169     0    24    39     0     0     0     0     0     0     0     0     0     0     0     0   145
4170     255   145   145   145   134   145   145   145   145   145   145   145   145   145   145   145]/255;
4171 
4172 % Processing parameters
4173 idx = idx+1;
4174 icons(idx).data(:,:,1) = ...
4175     [255   255   255   255   255   255   255   255   255   255   255   255   255   255   255   255
4176     255     0     0     0   255   255   255   255   255   255   255   255     0     0     0   255
4177     255     0   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4178     255     0   255   255   107   255   255   107   255   255   255   107   255   255     0   255
4179     255     0   255   255   107   255   255   107   255   255   107   255   107   255     0   255
4180     255     0   255   255   107   255   255   107   255   255   255   107   255   255     0   255
4181     255     0   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4182     255     0   255   255   107   255   255   107   255   255   255   107   255   255     0   255
4183     255     0   255   255   107   255   107   255   107   255   255   107   255   255     0   255
4184     255     0   255   255   107   255   255   107   255   255   255   107   255   255     0   255
4185     255     0   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4186     255     0   255   255   107   255   255   107   255   255   255   107   255   255     0   255
4187     255     0   255   107   255   107   255   107   255   255   107   255   107   255     0   255
4188     255     0   255   255   107   255   255   107   255   255   255   107   255   255     0   255
4189     255     0   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4190     255     0     0     0   255   255   255   255   255   255   255   255     0     0     0   255]/255;
4191 
4192 icons(idx).data(:,:,2) = ...
4193     [255   255   255   255   255   255   255   255   255   255   255   255   255   255   255   255
4194     255     0     0     0   255   255   255   255   255   255   255   255     0     0     0   255
4195     255     0   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4196     255     0   255   255    99   255   255    99   255   255   255    99   255   255     0   255
4197     255     0   255   255    99   255   255    99   255   255    99   255    99   255     0   255
4198     255     0   255   255    99   255   255    99   255   255   255    99   255   255     0   255
4199     255     0   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4200     255     0   255   255    99   255   255    99   255   255   255    99   255   255     0   255
4201     255     0   255   255    99   255    99   255    99   255   255    99   255   255     0   255
4202     255     0   255   255    99   255   255    99   255   255   255    99   255   255     0   255
4203     255     0   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4204     255     0   255   255    99   255   255    99   255   255   255    99   255   255     0   255
4205     255     0   255    99   255    99   255    99   255   255    99   255    99   255     0   255
4206     255     0   255   255    99   255   255    99   255   255   255    99   255   255     0   255
4207     255     0   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4208     255     0     0     0   255   255   255   255   255   255   255   255     0     0     0   255]/255;
4209 
4210 icons(idx).data(:,:,3) = ...
4211     [255   255   255   255   255   255   255   255   255   255   255   255   255   255   255   255
4212     255     0     0     0   255   255   255   255   255   255   255   255     0     0     0   255
4213     255     0   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4214     255     0   255   255    99   255   255    99   255   255   255    99   255   255     0   255
4215     255     0   255   255    99   255   255    99   255   255    99   255    99   255     0   255
4216     255     0   255   255    99   255   255    99   255   255   255    99   255   255     0   255
4217     255     0   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4218     255     0   255   255    99   255   255    99   255   255   255    99   255   255     0   255
4219     255     0   255   255    99   255    99   255    99   255   255    99   255   255     0   255
4220     255     0   255   255    99   255   255    99   255   255   255    99   255   255     0   255
4221     255     0   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4222     255     0   255   255    99   255   255    99   255   255   255    99   255   255     0   255
4223     255     0   255    99   255    99   255    99   255   255    99   255    99   255     0   255
4224     255     0   255   255    99   255   255    99   255   255   255    99   255   255     0   255
4225     255     0   255   255   255   255   255   255   255   255   255   255   255   255     0   255
4226     255     0     0     0   255   255   255   255   255   255   255   255     0     0     0   255]/255;
4227 
4228 % Export bathymetry dialog
4229 idx = idx+1;
4230 icons(idx).data(:,:,1) = ...
4231     [226    226    226    226    226    226    226    197    220    226    226    226    226    226    226    226
4232     226    226    226    226    226    227    241    144    158    241    228    228    229    228    229    226
4233     226    243    243    243    237    237    246    164    119    242    232    225    226    218    243    206
4234     179    152    153    166    148    148    177    179    63    185    141    146    154    151    179    189
4235     167    4    134    175    151    164    161    198    122    255    212    233    215    199    140    185
4236     134    50    209    241    255    255    133    118    15    20    28    94    4    0    0    89
4237     136    0    0    0    0    0    0    0    0    0    0    0    0    21    56    140
4238     208    255    226    233    255    242    215    232    251    237    226    233    207    222    156    139
4239     172    159    152    153    166    145    178    147    169    164    161    163    154    153    128    135
4240     160    164    148    139    171    150    165    154    165    185    166    173    190    190    148    162
4241     214    233    211    203    217    212    217    238    202    236    213    222    230    224    184    184
4242     219    206    174    190    219    204    201    218    183    224    219    222    217    202    176    182
4243     210    182    183    214    225    220    203    229    175    217    220    220    222    212    184    185
4244     197    175    207    224    223    220    205    231    170    221    220    220    222    217    191    187
4245     186    193    223    224    220    201    203    228    171    224    218    220    222    215    190    187
4246     189    211    220    216    204    201    214    213    187    213    216    220    220    212    193    189
4247     ]/255;
4248 icons(idx).data(:,:,2) = ...
4249     [233    233    233    233    233    233    233    204    227    233    233    233    233    233    233    233
4250     233    233    233    233    233    234    247    152    167    247    235    234    235    234    236    233
4251     233    242    242    240    236    237    247    170    131    243    234    231    234    224    245    212
4252     208    193    199    209    196    196    211    197    100    211    194    196    200    199    202    196
4253     205    19    179    199    183    197    182    179    162    255    217    246    234    231    191    199
4254     167    47    229    240    255    252    139    154    87    86    99    139    79    46    23    121
4255     175    30    47    29    28    19    5    41    33    39    54    55    65    83    81    185
4256     236    255    249    253    255    251    240    255    235    255    247    252    233    245    204    190
4257     208    200    195    196    204    192    214    202    144    215    201    201    195    195    177    186
4258     200    201    189    183    206    192    204    210    111    231    209    214    222    223    199    209
4259     245    255    251    247    254    254    252    255    156    255    254    255    255    254    235    232
4260     249    244    227    237    247    244    242    255    132    239    254    250    247    244    228    231
4261     245    231    231    246    253    249    243    255    119    223    255    251    250    245    229    232
4262     239    227    244    251    251    248    244    255    110    217    255    250    251    246    233    233
4263     233    237    250    252    249    242    246    255    115    209    255    250    251    246    232    232
4264     234    245    249    247    242    242    246    231    154    192    246    249    249    245    234    233
4265     ]/255;
4266 icons(idx).data(:,:,3) = ...
4267     [233    233    233    233    233    233    233    204    227    233    233    233    233    233    233    233
4268     233    233    233    233    233    234    247    152    167    247    235    234    235    234    236    233
4269     233    242    242    240    236    237    247    170    131    243    234    231    234    224    245    212
4270     208    193    199    209    196    196    211    197    100    211    194    196    200    199    202    196
4271     205    19    179    199    183    197    182    179    162    255    217    246    234    231    191    199
4272     167    47    229    240    255    252    139    154    87    86    99    139    79    46    23    121
4273     175    30    47    29    28    19    5    41    33    39    54    55    65    83    81    185
4274     236    255    249    253    255    251    240    255    235    255    247    252    233    245    204    190
4275     208    200    195    196    204    192    214    202    144    215    201    201    195    195    177    186
4276     200    201    189    183    206    192    204    210    111    231    209    214    222    223    199    209
4277     245    255    251    247    254    254    252    255    156    255    254    255    255    254    235    232
4278     249    244    227    237    247    244    242    255    132    239    254    250    247    244    228    231
4279     245    231    231    246    253    249    243    255    119    223    255    251    250    245    229    232
4280     239    227    244    251    251    248    244    255    110    217    255    250    251    246    233    233
4281     233    237    250    252    249    242    246    255    115    209    255    250    251    246    232    232
4282     234    245    249    247    242    242    246    231    154    192    246    249    249    245    234    233
4283     ]/255;
4284 
4285 % Export Figures Dialog
4286 idx = idx + 1;
4287 icons(idx).data(:,:,1) = ...
4288     [NaN    NaN    10    23    23    23    23    23    23    23    21    3    NaN    NaN    NaN    NaN
4289     NaN    NaN    67    255    255    255    255    255    255    255    201    141    NaN    NaN    NaN    NaN
4290     NaN    NaN    43    255    241    240    241    246    252    255    186    220    151    NaN    NaN    NaN
4291     NaN    NaN    42    255    238    237    237    236    238    254    210    178    214    38    NaN    NaN
4292     NaN    NaN    43    255    241    241    241    241    240    244    252    255    255    79    NaN    NaN
4293     NaN    NaN    47    255    232    232    225    224    224    223    220    238    255    69    NaN    NaN
4294     NaN    NaN    55    233    114    225    230    223    221    221    215    237    255    67    NaN    NaN
4295     4    NaN    37    181    168    126    193    214    205    200    203    242    255    67    NaN    NaN
4296     41    164    134    153    144    139    131    209    238    223    242    240    255    67    NaN    NaN
4297     41    118    91    91    122    125    120    106    170    241    245    241    255    67    NaN    NaN
4298     41    113    91    89    97    108    99    89    117    205    190    230    255    67    NaN    NaN
4299     41    124    94    88    78    74    81    179    255    252    244    241    255    67    NaN    NaN
4300     13    34    76    187    88    92    222    255    255    250    250    250    255    73    NaN    NaN
4301     NaN    NaN    69    236    121    227    255    243    238    238    238    238    255    82    NaN    NaN
4302     NaN    NaN    NaN    0    0    0    0    0    0    0    0    0    0    0    NaN    NaN]/255;
4303 
4304 
4305 icons(idx).data(:,:,2) = ...
4306     [NaN    NaN    10    24    24    24    24    24    24    24    22    4    NaN    NaN    NaN    NaN
4307     NaN    NaN    69    255    255    255    255    255    255    255    204    144    NaN    NaN    NaN    NaN
4308     NaN    NaN    45    255    241    240    241    246    252    255    189    222    155    NaN    NaN    NaN
4309     NaN    NaN    43    255    238    237    237    236    238    254    210    179    215    39    NaN    NaN
4310     NaN    NaN    44    255    241    241    241    241    240    244    252    255    255    80    NaN    NaN
4311     NaN    NaN    49    255    231    230    225    224    224    223    220    238    255    70    NaN    NaN
4312     NaN    NaN    56    227    136    214    227    223    221    221    215    237    255    68    NaN    NaN
4313     4    NaN    19    157    243    154    181    210    204    200    203    242    255    67    NaN    NaN
4314     51    255    231    225    219    217    172    197    232    222    242    240    255    67    NaN    NaN
4315     52    227    184    183    195    201    204    172    169    239    245    241    255    67    NaN    NaN
4316     51    218    177    177    180    187    187    177    130    202    190    230    255    67    NaN    NaN
4317     51    237    195    183    172    170    152    175    255    251    244    241    255    67    NaN    NaN
4318     15    38    72    173    183    149    211    255    255    250    250    250    255    73    NaN    NaN
4319     NaN    NaN    65    226    174    214    252    242    238    238    238    238    255    84    NaN    NaN
4320     NaN    NaN    NaN    0    0    0    0    0    0    0    0    0    0    0    NaN    NaN]/255;
4321 
4322 
4323 icons(idx).data(:,:,3) = ...
4324     [NaN    NaN    9    23    23    23    23    23    23    23    21    3    NaN    NaN    NaN    NaN
4325     NaN    NaN    66    255    255    255    255    255    255    255    196    139    NaN    NaN    NaN    NaN
4326     NaN    NaN    42    255    239    238    238    244    252    255    186    216    148    NaN    NaN    NaN
4327     NaN    NaN    41    255    236    235    235    234    237    251    210    176    212    36    NaN    NaN
4328     NaN    NaN    42    255    239    239    239    239    238    241    252    255    255    78    NaN    NaN
4329     NaN    NaN    46    255    233    232    224    223    223    223    219    235    255    67    NaN    NaN
4330     NaN    NaN    53    240    101    232    230    221    219    218    213    235    255    65    NaN    NaN
4331     5    NaN    60    212    94    107    205    215    203    198    201    240    255    66    NaN    NaN
4332     34    56    40    80    70    62    94    222    241    221    240    238    255    66    NaN    NaN
4333     35    10    2    0    51    55    36    46    176    240    243    239    255    66    NaN    NaN
4334     35    11    9    7    16    34    12    6    110    204    188    228    255    66    NaN    NaN
4335     35    14    0    0    0    0    14    187    255    251    242    239    255    66    NaN    NaN
4336     12    37    84    206    0    41    234    255    255    248    248    248    255    72    NaN    NaN
4337     NaN    NaN    69    249    79    239    255    240    236    236    236    236    255    80    NaN    NaN
4338     NaN    NaN    NaN    0    0    0    0    0    0    0    0    0    0    0    NaN    NaN]/255;
4339 
4340 % Export Excel File
4341 idx = idx + 1;
4342 icons(idx).data(:,:,1) = ...
4343     [NaN    NaN    NaN    NaN    NaN    NaN  106  252  255  255  255  255  255  255  255  255
4344    38  136  109  101   96   77   95  134  106   99   93   87   90   66  255  255
4345    52  197  232  217  210  202  191  178  170  164  160  159  155   15  255  255
4346    51  181  255  255  255  255  255  255  255  255  255  255  253    9  255  255
4347    49  174  245  153  156  175  255  255  181  153  149  205  245    0  255  255
4348    47  168  199  122  149  100  155  183   99   99   15  117  245    0  255  241
4349    45  158  255  146  146  141   87   68  120   34   86  255  238    0  252  232
4350    42  144  255  255  158  158  143   74   68  117  255  255  230    0  255  255
4351    40  134  255  255  169   15  150  111   68   81  105  167  236    0  230  217
4352    37  131  255  158   99  106   10  143  117   50   51  165  252    0  255  254
4353    35  122  208    0   22   32    8   17  110   20    0   13  212    0  255  245
4354    33  115  255  255  255  255  255  250  146  113  119  106  217    0  236  217
4355    31  109  255  254  252  251  250  255  255  255  255  255  241    0  255  251
4356    29  116  190  168  164  157  145  133  126  121  117  118  112    0  215  205
4357    20   63   47   38   36   20   38   83   64   51   52   55   64   20  255  241
4358     NaN    NaN    NaN    NaN    NaN    NaN   96  249  252  228  237  251  249  203  241  246]/255;
4359 
4360 icons(idx).data(:,:,2) = ...
4361     [NaN    NaN    NaN    NaN    NaN    NaN  114  252  255  255  255  255  255  255  255  255
4362    49  180  152  145  140  118  140  173  150  139  132  126  126  106  255  255
4363    67  249  252  242  237  231  221  207  201  196  194  193  193   75  255  255
4364    66  232  255  255  255  255  255  255  255  255  255  255  255   68  255  255
4365    64  226  251  197  191  200  255  255  194  170  168  214  253   61  255  255
4366    62  220  224  183  207  173  189  202  167  175  116  172  253   58  255  246
4367    60  211  255  190  196  203  166  131  187  134  148  255  249   54  254  240
4368    57  199  255  255  198  203  202  158  132  168  255  255  245   47  255  255
4369    54  190  255  255  200  110  199  185  155  147  160  203  251   44  240  230
4370    52  187  255  204  187  194  121  204  189  139   99  179  255   39  255  254
4371    49  180  230   42   49   53   36   64  182   98   65   70  228   36  255  248
4372    47  171  255  255  255  255  255  255  186  115  124  114  235   34  243  229
4373    45  166  255  255  254  254  255  255  255  255  255  255  255   33  255  252
4374    43  176  222  206  204  200  190  180  174  171  169  169  169   32  229  220
4375    30  101   81   74   69   54   72  116   96   84   84   84   94   55  255  245
4376     NaN    NaN    NaN    NaN    NaN    NaN  105  251  253  237  242  252  251  218  246  249]/255;
4377 
4378 icons(idx).data(:,:,3) = ...
4379     [ NaN    NaN    NaN    NaN    NaN    NaN  125  253  255  255  255  255  255  255  255  255
4380    34  118   92   84   79   56   83  111   88   79   73   69   74   45  255  255
4381    46  180  228  207  203  195  182  169  159  155  149  149  145    0  255  255
4382    45  163  255  255  255  255  255  255  255  255  255  255  254    0  255  255
4383    42  156  248  152  155  176  255  255  181  154  147  206  245    0  255  255
4384    40  150  202  117  136   87  154  181   90   84    8  120  243    0  255  252
4385    38  138  255  145  137  131   81   65  106   27   86  255  238    0  255  250
4386    35  122  255  255  159  152  137   75   62  121  255  255  229    0  255  255
4387    33  113  255  255  171   13  145  111   67   76   84  159  234    0  255  247
4388    30  109  255  160   89   97   10  136  111   36   33  159  251    0  255  255
4389    28   99  211    0   12   23    2   11  101    0    0   13  209    0  255  253
4390    26   92  255  255  255  255  255  250  146  111  117  104  213    0  255  245
4391    23   89  255  255  255  255  255  255  255  255  255  255  241    0  255  254
4392    22   93  180  156  151  141  129  114  105   98   93   93   83    0  255  239
4393    15   43   26   17   15    0   25   63   45   39   38   39   44    9  255  252
4394     NaN    NaN    NaN    NaN    NaN    NaN  117  253  255  249  251  255  254  239  252  254]/255;
4395 
4396 % [EOF] getIcons
4397 
4398 function guiparams = createGUIparams
4399 % Creates the guiparams structure with specified defaults.
4400 
4401 % Organized by GUI panels
4402 %%%%%%%%%%%%%%%%%%%
4403 % SHIPTRACKS PLOT %
4404 %%%%%%%%%%%%%%%%%%%
4405 guiparams.horizontal_grid_node_spacing       = 1.0;
4406 
4407 %%%%%%%%%%%%%%%%%%%%%%
4408 % CROSS SECTION PLOT %
4409 %%%%%%%%%%%%%%%%%%%%%%
4410 guiparams.contours                           = ''; % Set below
4411 guiparams.contour                            = ''; % Set below
4412 guiparams.idx_contour                        = 1;
4413 guiparams.vertical_exaggeration              = 10;
4414 guiparams.vector_scale_cross_section         = 0.2;
4415 guiparams.horizontal_vector_spacing          = 1;
4416 guiparams.vertical_vector_spacing            = 1;
4417 guiparams.horizontal_smoothing_window        = 1;
4418 guiparams.vertical_smoothing_window          = 1;
4419 guiparams.plot_secondary_flow_vectors        = true;
4420 guiparams.secondary_flows                    = ''; % Set below
4421 guiparams.secondary_flow_vector_variable     = ''; % Set below
4422 guiparams.idx_secondary_flow_vector_variable = 1;
4423 guiparams.include_vertical_velocity          = true;
4424 
4425 %%%%%%%%%%%%%%%%%%
4426 % PLAN VIEW PLOT %
4427 %%%%%%%%%%%%%%%%%%
4428 guiparams.depth_range_min                    = 0;
4429 guiparams.depth_range_max                    = inf;
4430 guiparams.vector_scale_plan_view             = 1;
4431 guiparams.vector_spacing_plan_view           = 1;
4432 guiparams.smoothing_window_size              = 1;
4433 guiparams.display_shoreline                  = false;
4434 guiparams.add_background                     = false;
4435 
4436 %%%%%%%%%%%%%%%
4437 % DATA EXPORT %
4438 %%%%%%%%%%%%%%%
4439 guiparams.beam_angle                         = 20.0;
4440 guiparams.magnetic_variation                 = 0.0;
4441 guiparams.wse                                = 0.0;
4442 guiparams.output_auxiliary_data              = false;
4443 
4444 %%%%%%%%%%%%%%%%%%%%%
4445 % Contour variables %
4446 %%%%%%%%%%%%%%%%%%%%%
4447 idx = 1;
4448 guiparams.contours(idx).string   = 'Streamwise Velocity (u)';
4449 guiparams.contours(idx).variable = 'streamwise';
4450 idx = idx + 1;
4451 guiparams.contours(idx).string   = 'Transverse Velocity (v)';
4452 guiparams.contours(idx).variable = 'transverse';
4453 idx = idx + 1;
4454 guiparams.contours(idx).string   = 'Vertical Velocity (w)';
4455 guiparams.contours(idx).variable = 'vertical';
4456 idx = idx + 1;
4457 guiparams.contours(idx).string   = 'Velocity Magnitude';
4458 guiparams.contours(idx).variable = 'mag';
4459 idx = idx + 1;
4460 guiparams.contours(idx).string   = 'East Velocity (E)';
4461 guiparams.contours(idx).variable = 'east';
4462 idx = idx + 1;
4463 guiparams.contours(idx).string   = 'North Velocity (N)';
4464 guiparams.contours(idx).variable = 'north';
4465 idx = idx + 1;
4466 guiparams.contours(idx).string   = 'Primary Velocity (zsd)';
4467 guiparams.contours(idx).variable = 'primary_zsd';
4468 idx = idx + 1;
4469 guiparams.contours(idx).string   = 'Secondary Velocity (zsd)';
4470 guiparams.contours(idx).variable = 'secondary_zsd';
4471 idx = idx + 1;
4472 guiparams.contours(idx).string   = 'Primary Velocity (Roz)';
4473 guiparams.contours(idx).variable = 'primary_roz';
4474 idx = idx + 1;
4475 guiparams.contours(idx).string   = 'Secondary Velocity (Roz)';
4476 guiparams.contours(idx).variable = 'secondary_roz';
4477 idx = idx + 1;
4478 guiparams.contours(idx).string   = 'Prim. Vel. (Roz, Downstream Comp.)';
4479 guiparams.contours(idx).variable = 'primary_roz_x';
4480 idx = idx + 1;
4481 guiparams.contours(idx).string   = 'Prim. Vel. (Roz, Cross-Stream Comp.)';
4482 guiparams.contours(idx).variable = 'primary_roz_y';
4483 idx = idx + 1;
4484 guiparams.contours(idx).string   = 'Sec. Vel. (Roz, Downstream Comp.)';
4485 guiparams.contours(idx).variable = 'secondary_roz_x';
4486 idx = idx + 1;
4487 guiparams.contours(idx).string   = 'Sec. Vel. (Roz, Cross-Stream Comp.)';
4488 guiparams.contours(idx).variable = 'secondary_roz_y';
4489 idx = idx + 1;
4490 guiparams.contours(idx).string   = 'Backscatter';
4491 guiparams.contours(idx).variable = 'backscatter';
4492 idx = idx + 1;
4493 guiparams.contours(idx).string   = 'Flow Direction (deg.)';
4494 guiparams.contours(idx).variable = 'flowangle';
4495 
4496 guiparams.contour = guiparams.contours(guiparams.idx_contour).variable;
4497 
4498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4499 % Secondary Flow Vector Variables %
4500 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4501 idx = 1;
4502 guiparams.secondary_flows(idx).string   = 'Transverse';
4503 guiparams.secondary_flows(idx).variable = 'transverse';
4504 idx = idx + 1;
4505 guiparams.secondary_flows(idx).string   = 'Secondary (zsd)';
4506 guiparams.secondary_flows(idx).variable = 'secondary_zsd';
4507 idx = idx + 1;
4508 guiparams.secondary_flows(idx).string   = 'Secondary (Roz)';
4509 guiparams.secondary_flows(idx).variable = 'secondary_roz';
4510 idx = idx + 1;
4511 guiparams.secondary_flows(idx).string   = 'Secondary (Roz, Cross-Stream Comp)';
4512 guiparams.secondary_flows(idx).variable = 'secondary_roz_y';
4513 idx = idx + 1;
4514 guiparams.secondary_flows(idx).string   = 'Primary (Roz, Cross-Stream Comp)';
4515 guiparams.secondary_flows(idx).variable  = 'primary_roz_y';
4516 
4517 guiparams.secondary_flow_vector_variable = ...
4518     guiparams.secondary_flows(guiparams.idx_secondary_flow_vector_variable).variable;
4519 
4520 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4521 % INTERNAL SETTINGS & DEFAULTS %
4522 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4523 % Menu bar options
4524 guiparams.presentation                       = true;
4525 guiparams.print                              = false;
4526 guiparams.set_cross_section_endpoints        = false;
4527 guiparams.unit_discharge_correction          = false;
4528 guiparams.english_units                      = false;
4529 guiparams.vertical_offset                    = 0;
4530 % guiparams.plot_ship_tracks                   = false;
4531 % guiparams.plot_planview                      = false;
4532 % guiparams.plot_cross_section                 = false;
4533 
4534 % File location defaults
4535 guiparams.ascii_path                        = pwd;
4536 guiparams.ascii_file                        = '';
4537 guiparams.mat_path                          = pwd;
4538 guiparams.mat_file                          = '';
4539 guiparams.tecplot_path                      = pwd;
4540 guiparams.tecplot_file                      = '';
4541 guiparams.kmz_path                          = pwd;
4542 guiparams.kmz_file                          = '';
4543 guiparams.multibeambathymetry_path          = pwd;
4544 guiparams.multibeambathymetry_file          = '';
4545 guiparams.log_path                          = pwd;
4546 guiparams.log_file                          = '';
4547 % Avoids problems of not finding the MCR root when running as a standalone
4548 % application
4549 if isdeployed 
4550     guiparams.has_mapping_toolbox           = true;
4551 else
4552     guiparams.has_mapping_toolbox               = ...
4553         ~isempty(dir(fullfile(matlabroot,'toolbox','map')));
4554 end
4555 
4556 %%%%%%%%%%%%%%%%%%%%%%%%%%
4557 % IN MEMORY DATA STORAGE %
4558 %%%%%%%%%%%%%%%%%%%%%%%%%%
4559 guiparams.z                      = [];
4560 guiparams.A                      = [];
4561 guiparams.V                      = [];
4562 guiparams.Map                    = [];
4563 guiparams.savefile               = [];
4564 guiparams.iric_anv_planview_data = [];
4565 % guiparams.zmin = []; % Don't need to store these?
4566 % guiparams.zmax = [];
4567 % guiprefs = getappdata(handles.figure1,'guiprefs');
4568 guiparams.data_folder = '';
4569 guiparams.data_files  = {''};
4570 
4571 % [EOF] createGUIparams
4572 
4573 % [EOF] VMT

Generated on Wed 14-Aug-2013 08:31:52 by m2html © 2005