-
Notifications
You must be signed in to change notification settings - Fork 12
/
VMT.m
5547 lines (4714 loc) · 235 KB
/
VMT.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function varargout = VMT(varargin)
% --- 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
%
% Code contributed by D. Parsons, D. Mueller, J. Czuba, and F. Engel.
%__________________________________________________________________________
% Begin initialization code - DO NOT EDIT
% Adress 2015b java bug #1293244
javax.swing.UIManager.setLookAndFeel('com.sun.java.swing.plaf.windows.WindowsLookAndFeel')
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @VMT_OpeningFcn, ...
'gui_OutputFcn', @VMT_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
% If ERROR, write a txt file with the error dump info
try
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
catch err
errdir = getenv('USERPROFILE');
errLogFileName = fullfile(errdir,...
['VMTerrorLog.txt']);
errWorkspace = fullfile(errdir,...
['VMTerrorWorkspace.mat']);
msgbox({['An unexpected error occurred. Error code: ' err.identifier];...
'';...
'Error details are being written to the following file: ';...
errLogFileName;...
'';...
'Attempting to save current workspace to:';...
errWorkspace},...
'VMT Status: Unexpected Error',...
'error');
handles = varargin{end};
guiprefs = getappdata(handles.figure1,'guiprefs');
guiparams = getappdata(handles.figure1,'guiparams');
i=1;
texterr{i} = 'VMT version:';
i=i+1;
texterr{i} = guiparams.vmt_version{1};
i=i+1;
texterr{i} = guiparams.vmt_version{2};
i=i+1;
texterr{i} = ['Date and time of error: ' datestr(now)];
i=i+1;
texterr{i} = '';
i=i+1;
texterr{i} = 'Attempting to save current workspace to:';
i=i+1;
texterr{i} = [' ' errWorkspace];
i=i+1;
texterr{i} = '';
i=i+1;
texterr{i} = 'Error messages:';
i=i+1;
texterr{i} = err.getReport('extended','hyperlinks','off');
fid = fopen(errLogFileName,'W');
fprintf(fid,'%s\r\n',texterr{:});
fclose(fid);
% Try to save a matfile with guiparams and guiprefs
try
save(errWorkspace,'guiparams','guiprefs','-mat')
catch err
end
rethrow(err)
end
% End initialization code - DO NOT EDIT
%#ok<*DEFNU,*INUSL,*INUSD>
% --- Executes just before VMT is made visible.
function VMT_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to VMT (see VARARGIN)
% Choose default command line output for VMT
handles.output = hObject;
% Build the GUI toolbar:
% ----------------------
handles = buildToolbar(handles);
% Ensure path to utils & docs is available
% ----------------------------------------
if ~isdeployed
utilspath = [pwd filesep 'utils'];
docspath = [pwd filesep 'doc'];
toolspath = [pwd filesep 'tools'];
addpath(utilspath,docspath,toolspath)
end
% Update handles structure
% ------------------------
guidata(hObject, handles);
% Load the GUI preferences:
% -------------------------
load_prefs(handles.figure1)
% Initialize the GUI parameters:
% ------------------------------
guiparams = createGUIparams;
guiparams.vmt_version = {'v4.09'; 'r20181011'};
% Draw the VMT Background
% -----------------
pos = get(handles.figure1,'position');
axes(handles.VMTBackground);
% if ~isdeployed %isempty(dir(fullfile(matlabroot,'toolbox','images')))
X = imread('VMT_Background.png');
imdisp(X,'size',[pos(4) pos(3)]) % Avoids problems with users not having Image Processing TB
% else
% X = imread('VMT_Background.png');
% X = imresize(X, [pos(4) pos(3)]);
% X = uint8(X);
% imshow(X,'Border','tight')
% end
uistack(handles.VMTBackground,'bottom')
% Store the application data:
% ---------------------------
setappdata(handles.figure1,'guiparams',guiparams)
% guiprefs = getappdata(handles.figure1,'guiprefs');
% setappdata(handles.figure1,'guiprefs',guiprefs)
store_prefs(handles.figure1,'runcounter')
% Auto-check for updates
% ----------------------
thres = 20;
runcounter = getpref('VMT','runcounter');
time_to_check = (mod(runcounter,thres)==0);
if time_to_check
menuCheckForUpdates_Callback(hObject, eventdata, handles)
end
% Initialize the GUI:
% -------------------
initGUI(handles)
set_enable(handles,'init')
% Allow VMT GUI to be resized depending on the screen resolution
% set(0,'units','pixels')
% Pix_SS = get(0,'screensize');
% movegui(handles.figure1,'center')
set(handles.figure1,'Resize','on')
% Allow access to the VMT Main GUI info by other sub-GUIs by pushing it to
% the root
setappdata(0 , 'hVMTgui' , gcf);
% UIWAIT makes VMT wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% [EOF] VMT_OpeningFcn
% --- Outputs from this function are returned to the command line.
function varargout = VMT_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% [EOF] VMT_OutputFcn
% --- Executes when figure1 is resized.
function figure1_ResizeFcn(hObject, eventdata, handles)
% Draw the VMT Background
% -----------------
pos = get(handles.figure1,'position');
axes(handles.VMTBackground);
% if ~isdeployed %isempty(dir(fullfile(matlabroot,'toolbox','images')))
X = imread('VMT_Background.png');
imdisp(X,'size',[pos(4) pos(3)]) % Avoids problems with users not having Image Processing TB
% else
% X = imread('VMT_Background.png');
% X = imresize(X, [pos(4) pos(3)]);
% X = uint8(X);
% imshow(X,'Border','tight')
% end
uistack(handles.VMTBackground,'bottom')
% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: delete(hObject) closes the figure
who_called = get(hObject,'tag');
close_button = questdlg(...
'You are about to exit VMT. Any unsaved work will be lost. Are you sure?',...
'Exit VMT?','No');
switch close_button
case 'Yes'
closereq
close all hidden
otherwise
return
end
% [EOF] figure1_CloseRequestFcn
%%%%%%%%%%%%%%%%%%%%%%
% MENU BAR CALLBACKS %
%%%%%%%%%%%%%%%%%%%%%%
% --------------------------------------------------------------------
function menuFile_Callback(hObject, eventdata, handles)
% Empty
% --------------------------------------------------------------------
function menuOpen_Callback(hObject, eventdata, handles)
% Empty
% --------------------------------------------------------------------
function menuOpenASCII_Callback(hObject, eventdata, handles)
loadDataCallback(hObject, eventdata, handles)
% [EOF] menuOpenASCII_Callback
% --------------------------------------------------------------------
function menuOpenSonTekMAT_Callback(hObject, eventdata, handles)
axes(findobj(handles.figure1,'Tag','Plot1Shiptracks')); cla
closeOpenFigures(hObject, eventdata, handles)
% Get the Application data:
% -------------------------
guiparams = getappdata(handles.figure1,'guiparams');
guiprefs = getappdata(handles.figure1,'guiprefs');
% Ask the user to select files:
% -----------------------------
% current_file = fullfile(guiparams.data_folder,guiparams.data_files{1});
% current_file = fullfile(guiprefs.mat_path,guiprefs.mat_file);
if iscell(guiprefs.mat_file)
uifile = fullfile(guiprefs.mat_path,guiprefs.mat_file{1});
else
uifile = fullfile(guiprefs.mat_path,guiprefs.mat_file);
end
[filename,pathname] = ...
uigetfile({'*.mat','MAT-files (*.mat)'}, ...
'Select SonTek RiverSurveyor Live v3.60+ MAT File', ...
uifile, 'MultiSelect','on');
if ischar(pathname) % The user did not hit "Cancel"
guiparams.data_folder = pathname;
if ischar(filename)
filename = {filename};
end
guiparams.data_files = filename;
guiparams.mat_file = '';
setappdata(handles.figure1,'guiparams',guiparams)
% Update the preferences:
% -----------------------
guiprefs = getappdata(handles.figure1,'guiprefs');
guiprefs.ascii_path = pathname;
guiprefs.ascii_file = filename;
setappdata(handles.figure1,'guiprefs',guiprefs)
store_prefs(handles.figure1,'ascii')
% Push messages to Log Window:
% ----------------------------
log_text = {...
'';...
['%--- ' datestr(now) ' ---%'];...
'Current Project Directory:';...
guiparams.data_folder;
'Loading the following files into memory:';...
char(filename)};
statusLogging(handles.LogWindow, log_text)
% Read the file(s)
% ----------------
%A = parseSonTekVMT(fullfile(pathname,filename));
[~,~,savefile,A,z] = ...
VMT_ReadFiles_SonTek(guiparams.data_folder,guiparams.data_files);
guiparams.savefile = savefile;
guiparams.A = A;
guiparams.z = z;
setappdata(handles.figure1,'guiparams',guiparams)
% Process and display ShipTracks
% ------------------------------
shiptracksPlotCallback(hObject, eventdata, handles)
% Update the GUI:
% ---------------
set_enable(handles,'fileloaded')
end
% [EOF] menuOpenSonTekMAT_Callback
% --------------------------------------------------------------------
function menuOpenMAT_Callback(hObject, eventdata, handles)
axes(findobj(handles.figure1,'Tag','Plot1Shiptracks')); cla
closeOpenFigures(hObject, eventdata, handles)
% Get the Application data:
% -------------------------
guiparams = getappdata(handles.figure1,'guiparams');
guiprefs = getappdata(handles.figure1,'guiprefs');
% Ask the user to select files:
% -----------------------------
% current_file = fullfile(guiparams.data_folder,guiparams.data_files{1});
% current_file = fullfile(guiprefs.mat_path,guiprefs.mat_file);
if iscell(guiprefs.mat_file)
uifile = fullfile(guiprefs.mat_path,guiprefs.mat_file{1});
else
uifile = fullfile(guiprefs.mat_path,guiprefs.mat_file);
end
[filename,pathname] = ...
uigetfile({'*.mat','MAT-files (*.mat)'}, ...
'Select MAT File', ...
uifile, 'MultiSelect','on');
if ischar(filename) % Single MAT file loaded
temp_filename = filename;
elseif iscell(filename)
temp_filename = filename{1};
else % Not a valid file
errordlg('The selected file is not a valid ADCP data MAT file.', ...
'Invalid File...')
end
% Load the data:
% --------------
vars = load(fullfile(pathname,temp_filename)); %Use first file to get the HGNS and VGNS
% Make sure the selected file is a valid file:
% --------------------------------------------
varnames = fieldnames(vars);
if isequal(sort(varnames),{'A' 'Map' 'V' 'z'}')
guiparams.mat_path = pathname;
guiparams.mat_file = temp_filename;
guiparams.z = vars.z;
guiparams.A = vars.A;
guiparams.V = vars.V;
% Update the preferences:
% -----------------------
guiprefs = getappdata(handles.figure1,'guiprefs');
guiprefs.mat_path = pathname;
guiprefs.mat_file = temp_filename;
setappdata(handles.figure1,'guiprefs',guiprefs)
store_prefs(handles.figure1,'mat')
% Re-store the Application Data:
% ------------------------------
setappdata(handles.figure1,'guiparams',guiparams)
% Update the GUI:
% ---------------
set(handles.HorizontalGridNodeSpacing,'String',vars.A(1).hgns)
guiparams.horizontal_grid_node_spacing = vars.A(1).hgns;
set_enable(handles,'fileloaded')
else % Not a valid file
errordlg('The selected file is not a valid ADCP data MAT file.', ...
'Invalid File...')
end
% Set the vertical grid node spacing
% ----------------------------------
% For RioGrande probes, use the bin size, else just use the default
% Backwards compatible
if vars.A(1).Sup.wm ~= 3 % RG
set(handles.VerticalGridNodeSpacing,'String',double(vars.A(1).Sup.binSize_cm(1))/100)
guiparams.vertical_grid_node_spacing = double(vars.A(1).Sup.binSize_cm(1))/100;
else % Older file, must be RG
set(handles.VerticalGridNodeSpacing,'String',0.4)
guiparams.vertical_grid_node_spacing = 0.4;
end
% Update the Application Data:
% ------------------------------
set_enable(handles,'fileloaded')
setappdata(handles.figure1,'guiparams',guiparams)
if iscell(filename) % Multiple MAT files loaded
% Set the filenames
% -----------------
guiparams.mat_path = pathname;
guiparams.mat_file = filename;
% Push status to log window
% -------------------------
log_text = {...
'Loading previously processed MAT files.';...
'Directory:'};
log_text = vertcat(log_text, pathname, {'Files:'}, filename');
statusLogging(handles.LogWindow,log_text)
% Update V structure to include current plotting settings
guiparams.V.version = guiparams.vmt_version{1}; V.release = guiparams.vmt_version{2};
guiparams.V.plotSettings.shiptracks.horizontal_grid_node_spacing = guiparams.horizontal_grid_node_spacing;
guiparams.V.plotSettings.shiptracks.vertical_grid_node_spacing = guiparams.vertical_grid_node_spacing;
guiparams.V.plotSettings.planview.depth_range_min = guiparams.depth_range_min;
guiparams.V.plotSettings.planview.depth_range_max = guiparams.depth_range_max;
guiparams.V.plotSettings.planview.vector_scale_plan_view = guiparams.vector_scale_plan_view;
guiparams.V.plotSettings.planview.vector_spacing_plan_view = guiparams.vector_spacing_plan_view;
guiparams.V.plotSettings.planview.smoothing_window_size = guiparams.smoothing_window_size;
guiparams.V.plotSettings.planview.plotref = guiparams.plotref;
guiparams.V.plotSettings.mcs.contour = guiparams.contour;
guiparams.V.plotSettings.mcs.vertical_exaggeration = guiparams.vertical_exaggeration;
guiparams.V.plotSettings.mcs.vector_scale_cross_section = guiparams.vector_scale_cross_section;
guiparams.V.plotSettings.mcs.horizontal_vector_spacing = guiparams.horizontal_vector_spacing;
guiparams.V.plotSettings.mcs.vertical_vector_spacing = guiparams.vertical_vector_spacing;
guiparams.V.plotSettings.mcs.horizontal_smoothing_window = guiparams.horizontal_smoothing_window;
guiparams.V.plotSettings.mcs.vertical_smoothing_window = guiparams.vertical_smoothing_window;
guiparams.V.plotSettings.mcs.plot_secondary_flow_vectors = guiparams.plot_secondary_flow_vectors;
guiparams.V.plotSettings.mcs.secondary_flow_vector_variable = guiparams.secondary_flow_vector_variable;
guiparams.V.plotSettings.mcs.include_vertical_velocity = guiparams.include_vertical_velocity;
% Update the Application Data:
% ------------------------------
setappdata(handles.figure1,'guiparams',guiparams)
set_enable(handles,'multiplematfiles')
% Update the persistent preferences:
% ----------------------------------
guiprefs = getappdata(handles.figure1,'guiprefs');
guiprefs.mat_path = pathname;
guiprefs.mat_file = filename;
setappdata(handles.figure1,'guiprefs',guiprefs)
store_prefs(handles.figure1,'mat')
end
% Process and display ShipTracks if single cross-section loaded
% ------------------------------
if iscell(filename) % Multiple MAT files loaded
ax = findobj(handles.figure1,'Tag','Plot1Shiptracks');
axes(ax)
pos = [xlim; ylim]/2; pos = pos(:,2)';
TextH = text(pos(1),pos(2), 'Multiple Mat-Files Loaded', ...
'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'middle',...
'FontSize',14,...
'FontWeight','bold',...
'EdgeColor',[0 0 0],...
'LineWidth',1.5);
else
shiptracksPlotCallback(hObject, eventdata, handles)
end
% [EOF] menuOpenMAT_Callback
% --------------------------------------------------------------------
function closeOpenFigures(hObject, eventdata, handles)
fig_planview_handle = findobj(0,'name','Plan View Map');
if ~isempty(fig_planview_handle) && ishandle(fig_planview_handle)
delete(fig_planview_handle)
end
fig_contour_handle = findobj(0,'name','Mean Cross Section Contour');
if ~isempty(fig_contour_handle) && ishandle(fig_contour_handle)
delete(fig_contour_handle);
end
% [EOF] closeOpenFigures
% --------------------------------------------------------------------
function menuSave_Callback(hObject, eventdata, handles)
% Empty
% --------------------------------------------------------------------
function menuSaveMAT_Callback(hObject, eventdata, handles)
saveDataCallback(hObject, eventdata, handles)
% [EOF] menuSaveMAT_Callback
% --------------------------------------------------------------------
function menuSaveTecplot_Callback(hObject, eventdata, handles)
SaveTecplotFile_Callback(handles,eventdata,handles)
% [EOF] menuSaveTecplot_Callback
% --------------------------------------------------------------------
function menuSaveKMZFile_Callback(hObject, eventdata, handles)
SaveGoogleEarthFile_Callback(handles,eventdata,handles)
% [EOF] menuSaveKMZFile_Callback
% --------------------------------------------------------------------
function menuExport_Callback(hObject, eventdata, handles)
% Empty
% --------------------------------------------------------------------
function menuFigureExportsettings_Callback(hObject, eventdata, handles)
% Empty
% --------------------------------------------------------------------
function menuPrintFormat_Callback(hObject, eventdata, handles)
% Get the Application Data:
% -------------------------
guiparams = getappdata(handles.figure1,'guiparams');
% Update the Application Data:
% ----------------------------
guiparams.print = true;
guiparams.presentation = false;
% Re-store the Application data:
% ------------------------------
setappdata(handles.figure1,'guiparams',guiparams)
% Update the GUI:
% ---------------
set(handles.menuPrintFormat, 'Checked','on')
set(handles.menuPresentationFormat,'Checked','off')
% [EOF] menuPrintFormat_Callback
% --------------------------------------------------------------------
function menuPresentationFormat_Callback(hObject, eventdata, handles)
% Get the Application Data:
% -------------------------
guiparams = getappdata(handles.figure1,'guiparams');
% Update the Application Data:
% ----------------------------
guiparams.print = false;
guiparams.presentation = true;
% Re-store the Application data:
% ------------------------------
setappdata(handles.figure1,'guiparams',guiparams)
% Update the GUI:
% ---------------
set(handles.menuPrintFormat, 'Checked','off')
set(handles.menuPresentationFormat,'Checked','on')
% [EOF] menuPresentationFormat_Callback
% --------------------------------------------------------------------
function menuGraphicsRenderer_Callback(hObject, eventdata, handles)
% --- Empty ---
% --------------------------------------------------------------------
function menuOpenGL_Callback(hObject, eventdata, handles)
% Get the Application Data:
% -------------------------
guiparams = getappdata(handles.figure1,'guiparams');
guiprefs = getappdata(handles.figure1,'guiprefs');
% Update the Application Data:
% ----------------------------
guiparams.renderer = 'OpenGL';
guiprefs.renderer = 'OpenGL';
% Re-store the Application data:
% ------------------------------
setappdata(handles.figure1,'guiparams',guiparams)
setappdata(handles.figure1,'guiprefs',guiprefs)
store_prefs(handles.figure1,'renderer')
% Update the GUI:
% ---------------
set(handles.menuOpenGL, 'Checked','on')
set(handles.menuPainters, 'Checked','off')
set(handles.menuZbuffer, 'Checked','off')
% Modify the existing figures
% ---------------------------
% Find what plots exist already
hf = findobj('type','figure');
valid_names = {'Plan View Map'; 'Mean Cross Section Contour'};
% Loop through valid figures and adjust
% -------------------------------------
if ~isempty(hf) && any(ishandle(hf))
for i = 1:length(valid_names)
% Focus the figure
hff = findobj('name','Plan View Map');
if ~isempty(hff) && ishandle(hff)
figure(hff)
set(hff,'Renderer',guiparams.renderer)
end
hff = findobj('name','Mean Cross Section Contour');
if ~isempty(hff) && ishandle(hff)
figure(hff)
set(hff,'Renderer',guiparams.renderer)
end
end
end
% [EOF] menuOpenGL_Callback
% --------------------------------------------------------------------
function menuPainters_Callback(hObject, eventdata, handles)
% Get the Application Data:
% -------------------------
guiparams = getappdata(handles.figure1,'guiparams');
guiprefs = getappdata(handles.figure1,'guiprefs');
% Update the Application Data:
% ----------------------------
guiparams.renderer = 'painters';
guiprefs.renderer = 'painters';
% Re-store the Application data:
% ------------------------------
setappdata(handles.figure1,'guiparams',guiparams)
setappdata(handles.figure1,'guiprefs',guiprefs)
store_prefs(handles.figure1,'renderer')
% Update the GUI:
% ---------------
set(handles.menuOpenGL, 'Checked','off')
set(handles.menuPainters, 'Checked','on')
set(handles.menuZbuffer, 'Checked','off')
% Modify the existing figures
% ---------------------------
% Find what plots exist already
hf = findobj('type','figure');
valid_names = {'Plan View Map'; 'Mean Cross Section Contour'};
% Loop through valid figures and adjust
% -------------------------------------
if ~isempty(hf) && any(ishandle(hf))
for i = 1:length(valid_names)
% Focus the figure
hff = findobj('name','Plan View Map');
if ~isempty(hff) && ishandle(hff)
figure(hff)
set(hff,'Renderer',guiparams.renderer)
end
hff = findobj('name','Mean Cross Section Contour');
if ~isempty(hff) && ishandle(hff)
figure(hff)
set(hff,'Renderer',guiparams.renderer)
end
end
end
% [EOF] menuPainters_Callback
% --------------------------------------------------------------------
function menuZbuffer_Callback(hObject, eventdata, handles)
% Get the Application Data:
% -------------------------
guiparams = getappdata(handles.figure1,'guiparams');
guiprefs = getappdata(handles.figure1,'guiprefs');
% Update the Application Data:
% ----------------------------
guiparams.renderer = 'zbuffer';
guiprefs.renderer = 'zbuffer';
% Re-store the Application data:
% ------------------------------
setappdata(handles.figure1,'guiparams',guiparams)
setappdata(handles.figure1,'guiprefs',guiprefs)
store_prefs(handles.figure1,'renderer')
% Update the GUI:
% ---------------
set(handles.menuOpenGL, 'Checked','off')
set(handles.menuPainters, 'Checked','off')
set(handles.menuZbuffer, 'Checked','on')
% Modify the existing figures
% ---------------------------
% Find what plots exist already
hf = findobj('type','figure');
valid_names = {'Plan View Map'; 'Mean Cross Section Contour'};
% Loop through valid figures and adjust
% -------------------------------------
if ~isempty(hf) && any(ishandle(hf))
for i = 1:length(valid_names)
% Focus the figure
hff = findobj('name','Plan View Map');
if ~isempty(hff) && ishandle(hff)
figure(hff)
set(hff,'Renderer',guiparams.renderer)
end
hff = findobj('name','Mean Cross Section Contour');
if ~isempty(hff) && ishandle(hff)
figure(hff)
set(hff,'Renderer',guiparams.renderer)
end
end
end
% [EOF] menuZbuffer_Callback
% --------------------------------------------------------------------
function menuExportFigures_Callback(hObject, eventdata, handles)
% Get the Application data:
% -------------------------
guiparams = getappdata(handles.figure1,'guiparams');
guiprefs = getappdata(handles.figure1,'guiprefs');
% Find what plots exist already
fig_handles = findobj('type','figure');
fig_names = get(fig_handles,'name');
% Remove the VMT GUI as a valid figure in the list
[~, idx] = ismember({get(handles.figure1,'Name'),'VMT_GraphicsControl'}, fig_names);
if ~isempty(idx)
fig_names(idx) = [];
end
if guiparams.presentation
figure_style = 'presentation';
else
figure_style = 'print';
end
[selected_figures] = openFiguresDialog(fig_names,handles.figure1);
if isempty(selected_figures) % User pressed cancel
return
else
for i = 1:length(selected_figures)
VMT_SaveFigs(guiprefs.mat_path,selected_figures(i),figure_style)
end
end
% [EOF] menuExportFigures_Callback
% --------------------------------------------------------------------
function menuBathymetryExportSettings_Callback(hObject, eventdata, handles)
% Get the Application data:
% -------------------------
guiparams = getappdata(handles.figure1,'guiparams');
beam_angle = guiparams.beam_angle;
magnetic_variation = guiparams.magnetic_variation;
wse = guiparams.water_surface_elevation;
output_auxiliary_data = guiparams.output_auxiliary_data;
load_wse_tide_file = guiparams.load_wse_tide_file;
% Open dialog and allow user to select settings
% ---------------------------------------------
[beam_angle,...
magnetic_variation,...
wse,...
output_auxiliary_data,...
load_wse_tide_file] = ...
exportSettingsDialog(beam_angle,magnetic_variation,wse,output_auxiliary_data,load_wse_tide_file,handles.figure1);
% Re-store the Application data:
% ------------------------------
guiparams.beam_angle = beam_angle;
guiparams.magnetic_variation = magnetic_variation;
guiparams.load_wse_tide_file = load_wse_tide_file;
if guiparams.load_wse_tide_file % prompt and load file
infile = fullfile(...
guiparams.multibeambathymetry_path,...
guiparams.multibeambathymetry_file);
[wsedata] = loadTideFile(infile);
guiparams.water_surface_elevation = wsedata;
else
guiparams.water_surface_elevation = wse;
end
guiparams.output_auxiliary_data = output_auxiliary_data;
setappdata(handles.figure1,'guiparams',guiparams)
% [EOF] menuExportSettings_Callback
% --------------------------------------------------------------------
function [wsedata] = loadTideFile(infile)
% wsedata.obstime
% wsedata.elev
% Determine Files to Process
% Ask the user to select files:
% -----------------------------
[zFileName,zPathName] = uigetfile({'*.csv','Comma Separated Values File (*.csv)';'*.*','All files (*.*)'}, ...
'Select the WSE Tide file', ...
infile, ...
'MultiSelect','off');
if ischar(zPathName) % The user did not hit "Cancel"
data = csvread(fullfile(zPathName,zFileName));
wsedata.obstime = datenum(data(:,1:6));
wsedata.elev = data(:,7);
else
wsedata.obstime = [];
wsedata.elev = [];
warndlg('Loading a tide file failed. Please try again.','Warning: No tide file loaded')
end
% [EOF] loadTideFile
% --------------------------------------------------------------------
function menuExportMultibeamBathymetry_Callback(hObject, eventdata, handles)
ExportMultibeamBathymetry_Callback(hObject, eventdata, handles);
% [EOF] menuExportMultibeamBathymetry_Callback
% --------------------------------------------------------------------
function menuSaveANVFile_Callback(hObject, eventdata, handles)
% Get the Application Data:
% -------------------------
guiparams = getappdata(handles.figure1,'guiparams');
guiprefs = getappdata(handles.figure1,'guiprefs');
PVdata = guiparams.iric_anv_planview_data;
iric_path = guiprefs.iric_path;
iric_file = guiprefs.iric_file;
% Is there any planview data?
if isempty(PVdata)
% Nothing to do, warn user
log_text = {'No planview plot data to export. User must Plot Plan View first.'};
warndlg(log_text{:},'Nothing to export')
else
% Save the planview data as output and to an *.anv file with spacing
% and smoothing (for iRiC)
log_text = {'Exporting iRic formated ANV vector file...'};
[iric_file,iric_path] = uiputfile('*.anv','Save *.anv file',...
fullfile(iric_path,iric_file));
if ischar(iric_path) % The user did not hit "Cancel"
outfile = fullfile(iric_path,iric_file);
log_text = vertcat(log_text,{outfile});
ofid = fopen(outfile, 'wt');
outcount = fprintf(ofid,...
'%8.2f %8.2f %5.2f %3.3f %3.3f\n',PVdata.outmat);
fclose(ofid);
else
% Return default iric_path and iric_file
iric_path = guiprefs.iric_path;
iric_file = guiprefs.iric_file;
end
end
% Push messages to Log Window:
% ----------------------------
statusLogging(handles.LogWindow, log_text)
% Store the persistent preferences:
% ---------------------------------
guiprefs.iric_file = iric_file;
guiprefs.iric_path = iric_path;
setappdata(handles.figure1,'guiprefs',guiprefs)
store_prefs(handles.figure1,'iric')
% [EOF] menuSaveANVFile_Callback
% --------------------------------------------------------------------
function menuSaveExcel_Callback(hObject, eventdata, handles)
% Get the Application Data:
% -------------------------
guiparams = getappdata(handles.figure1,'guiparams');
guiprefs = getappdata(handles.figure1,'guiprefs');
excel_path = guiprefs.excel_path;
excel_file = guiprefs.excel_file;
% Push messages to Log Window:
% ----------------------------
log_text = {'Exporting Excel File (reprocessing dataset; this will create new plots)'};
statusLogging(handles.LogWindow, log_text)
% If there are multiple MAT files loaded, go ahead and export just the DAV
% data.
if iscell(guiparams.mat_file)
outputType = 'Multiple';
% Force VMT to reprocess before outputing Excel
planviewPlotCallback(hObject, eventdata, handles)
% Refresh the Application Data:
guiparams = getappdata(handles.figure1,'guiparams');
z = guiparams.z;
A = guiparams.A;
V = guiparams.V;
Map = guiparams.Map;
wse = guiparams.water_surface_elevation;
PVdata = guiparams.iric_anv_planview_data;
dataFiles = guiparams.mat_file;
dataPath = guiparams.mat_path;
[log_text] = VMT_SaveExcelOutput(excel_path,excel_file,outputType,dataPath,dataFiles,V,A,z,Map,wse,PVdata);
% if ischar(excel_path) % The user did not hit "Cancel"
% full_excelfile = fullfile(excel_path,excel_file);
% %log_text = vertcat(log_text,{outfile});
%
% else
% % Return default excel_path and excel_file
% excel_path = guiprefs.excel_path;
% excel_file = guiprefs.excel_file;
% full_excelfile = fullfile(excel_path,excel_file);
% %log_text = vertcat(log_text,{outfile});
% end
else
outputType = 'Single';
% Force VMT to reprocess before outputing Excel
planviewPlotCallback(hObject, eventdata, handles)
crosssectionPlotCallback(hObject, eventdata, handles)
% Refresh the Application Data:
guiparams = getappdata(handles.figure1,'guiparams');
z = guiparams.z;
A = guiparams.A;
V = guiparams.V;
Map = guiparams.Map;
wse = guiparams.water_surface_elevation;
PVdata = guiparams.iric_anv_planview_data; % this is what's in the
% Planview Plot exactly
if isempty(guiparams.data_files{1}) % Loaded MAT file
dataFiles = {guiparams.mat_file};
dataPath = {guiparams.mat_path};
else % ASCII file(s)
dataFiles = guiparams.data_files';
dataPath = {guiparams.ascii_path};
end
[log_text] = VMT_SaveExcelOutput(excel_path,excel_file,outputType,dataPath,dataFiles,V,A,z,Map,wse,PVdata);
end
% Push messages to Log Window:
% ----------------------------
statusLogging(handles.LogWindow, log_text)
% Store the persistent preferences:
% ---------------------------------
guiprefs.excel_file = excel_file;
guiprefs.excel_path = excel_path;
setappdata(handles.figure1,'guiprefs',guiprefs)
store_prefs(handles.figure1,'excel')
% [EOF] menuSaveExcel_Callback
% --------------------------------------------------------------------
function menuExportCustomFlatFile_Callback(hObject, eventdata, handles)
% Call separate GUI
VMT_BuildCustomFlatFile;
% [EOF] menuExportCustomFlatFile_Callback
% --------------------------------------------------------------------
function menuSettings_Callback(hObject, eventdata, handles)
% Empty
% --------------------------------------------------------------------
function menuProcessingSettings_Callback(hObject, eventdata, handles)
% Empty
% --------------------------------------------------------------------
function menuUnitDischargeCorrection_Callback(hObject, eventdata, handles)
% Turn ON or OFF Unit Discharge Correction
% Get the Application Data:
% -------------------------
guiparams = getappdata(handles.figure1,'guiparams');
% Update the GUI & Application Data:
% ----------------------------------
status = get(handles.menuUnitDischargeCorrection,'Checked');
switch status
case 'on' % Turn it off
set(handles.menuUnitDischargeCorrection, 'Checked','off')
guiparams.unit_discharge_correction = false;
case 'off' % Turn it on
set(handles.menuUnitDischargeCorrection, 'Checked','on')
guiparams.unit_discharge_correction = true;
end