Newer
Older
function [ ] = main(pCallbacks, pTrackingMethods, pInterpolationMethods, pSoundspeedMethods)
%MAIN Contains the definition of main ARTOA4 gui.
global artoaGui;
%% Initialize callbacks
availableCallbacks = { ...
'CloseRequestFcn', ...
'WindowButtonDownFcn', ...
'loadRfb', ...
'loadInterim', ...
'loadSoundsourceFile', ...
'saveInterim', ...
'saveOptimumTables', ...
'loadArtoaIni', ...
'quit', ...
'openEditTemperature', ...
'openEditPressure', ...
'openEditTimeOfArrival', ...
'openEditOffsets', ...
'openTrackParameter', ...
'openTrackTrajectoryOutput', ...
'switchHideDeletedDataPoints', ...
'comboboxTrackingMethod', ... % FIRST ITEM TRACK PARAMETER CALLBACKS
'checkboxDopplerCorrection', ...
'comboboxInterpolationMethod', ...
'comboboxSoundspeedMethod', ...
'checkboxPlotResiduals', ...
'inputOutputInterpolationInterval', ...
'inputGapSize', ...
'tableSoundSourceCombinationsSelection', ...
'tableSoundSourceCombinationsEdit', ...
'buttonTrack', ...
'buttonAddCombination', ...
'buttonAddCombinationAbove', ...
'buttonDuplicateCombination', ...
'buttonRemoveCombination', ...
'buttonResetAllCombinations', ...
'tableSoundsourceOffsetsSelect', ... % FIRST ITEM OF OFFSETS
'tableSoundsourceOffsetsEdit', ...
'tableSoundspeedEdit', ...
'buttonCalculateOffsets', ...
'checkboxUseOffsets', ...
'buttonCopyFromOptimum', ...
'buttonCopyFromMeasured', ...
'buttonEmpiricalToNan', ...
'buttonUndoLastCopy' ...
};
for i = 1:length(availableCallbacks) % check if a callback is undefined
if ~isfield(pCallbacks, availableCallbacks{i})
pCallbacks.(availableCallbacks{i}) = @(~, ~) false;
end
end
%% Initialize main window
artoaGui.figures.main = figure( ...
'Name', 'ARTOA 4', ...
'NumberTitle', 'off', ...
'Color', 'white', ...
'MenuBar', 'none', ...
'WindowKeyPressFcn', @artoa.controller.main.shortcuts ...
%% Geometry variables
heightWindow = 60; % [characters]
widthWindow = 129; % [characters]
heightShortcutHintPanel = .1;
heightFrame = .4;
widthFrame = .95;
spacer = .025;
%% Set window height
artoaGui.figures.main.Position(3) = widthWindow;
artoaGui.figures.main.Position(4) = heightWindow;
%% Set extraordinary callbacks
set(artoaGui.figures.main, 'CloseRequestFcn', pCallbacks.CloseRequestFcn);
set(artoaGui.figures.main, 'WindowButtonDownFcn', pCallbacks.WindowButtonDownFcn);
%% Initialize file menu
artoaGui.main.menus = struct();
artoaGui.main.menus.file = uimenu(artoaGui.figures.main, 'Label', 'File');
% LOAD
loadHandle = uimenu(artoaGui.main.menus.file, 'Label', 'Load');
uimenu( ...
loadHandle, ...
'Label', 'ARGOS file', ...%'Callback', 'artoa.controller.loadArgos' ...
'Enable', 'off' ...
);
uimenu( ...
loadHandle, ...
'Label', 'RFB file', ...
'Callback', pCallbacks.loadRfb ...
);
uimenu( ...
loadHandle, ...
leprob001
committed
'Label', 'Interim file', ...
'Callback', pCallbacks.loadInterim ...
leprob001
committed
);
uimenu( ...
loadHandle, ...
'Label', 'SoSo file', ...
'Callback', pCallbacks.loadSoundsourceFile ...
artoaGui.main.menus.fileSave = uimenu( ...
artoaGui.main.menus.file, ...
'Label', 'Save', ...
'Enable', 'off' ...
);
artoaGui.main.menus.fileSave, ...
'Label', 'RFC file', ...
'Callback', pCallbacks.saveRfc ...
leprob001
committed
uimenu( ...
artoaGui.main.menus.fileSave, ...
leprob001
committed
'Label', 'Interim file', ...
'Callback', pCallbacks.saveInterim ...
leprob001
committed
);
uimenu( ...
artoaGui.main.menus.fileSave, ...
'Label', 'Optimum tables', ...
'Callback', pCallbacks.saveOptimumTables ...
);
artoaGui.main.menus.fileReloadArtoaIni = uimenu( ...
artoaGui.main.menus.file, ...
'Label', 'Reload artoa.ini', ...
'Callback', pCallbacks.loadArtoaIni ...
% QUIT
artoaGui.main.menus.fileQuit = uimenu( ...
artoaGui.main.menus.file, ...
'Label', 'Quit', ...
'Callback', pCallbacks.quit ...
);
%% Initialize edit menu
artoaGui.main.menus.edit = uimenu( ...
artoaGui.figures.main, ...
'Label', 'Edit', ...
'Enable', 'off' ...
);
% TEMPERATURE
artoaGui.main.menus.editTemperature = uimenu( ...
artoaGui.main.menus.edit, ...
'Label', 'Temperature', ...
'Callback', pCallbacks.openEditTemperature ...
);
% PRESSURE
leprob001
committed
artoaGui.main.menus.editPressure = uimenu( ...
artoaGui.main.menus.edit, ...
'Label', 'Pressure', ...
'Callback', pCallbacks.openEditPressure ...
leprob001
committed
);
% TIME OF ARRIVAL
artoaGui.main.menus.editTimeOfArrival = uimenu( ...
artoaGui.main.menus.edit, ...
'Label', 'Time of arrival', ...
'Callback', pCallbacks.openEditTimeOfArrival, ...
%% Initialize track menu
artoaGui.main.menus.track = uimenu( ...
artoaGui.figures.main, ...
'Label', 'Track', ...
'Enable', 'off' ...
);
% TRAJECTORY OUTPUT
artoaGui.main.menus.trajectoryOutput = uimenu( ...
artoaGui.main.menus.track, ...
'Label', 'Trajectory output', ...
'Callback', pCallbacks.openTrackTrajectoryOutput ...
%% Initialize view menu
artoaGui.main.menus.view = uimenu( ...
artoaGui.figures.main, ...
'Label', 'View', ...
'Enable', 'on' ...
);
artoaGui.main.menus.viewHideDeletedDataPoints = uimenu( ...
artoaGui.main.menus.view, ...
'Label', 'Hide deleted data points', ...
'Callback', pCallbacks.switchHideDeletedDataPoints ...
%% Initialize shortcut hints
shortcutHints = { ...
't', 'Open Edit temperature window';
'p', 'Open Edit pressure window';
'e', 'Open Edit time of arrival window';
'f', 'Open Edit offsets window';
'i', 'Open track parameter window';
'o', 'Open trajectory output window';
};
artoaGui.main.shortcutHints = uitable();
artoaGui.main.shortcutHints.Data = shortcutHints;
artoaGui.main.shortcutHints.Enable = 'off';
artoaGui.main.shortcutHints.ColumnName = {'Key', 'Action'};
artoaGui.main.shortcutHints.RowName = '';
artoaGui.main.shortcutHints.Units = 'normalized';
artoaGui.main.shortcutHints.Position = [spacer (1 - heightShortcutHintPanel - spacer) widthFrame heightShortcutHintPanel];
%% Version info
gitInfo = getGitInfo();
artoaGui.main.textVersionInfo = uicontrol( ...
'Parent', artoaGui.figures.main, ...
'String', artoa.controller.main.getVersionString(), ...
'Style', 'text', ...
'FontSize', 10, ...
'Units', 'characters', ...
'Background', [1 1 1], ...
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
'Position', [(widthWindow - 20) 1 20 1] ...
);
%% Track parameter
artoaGui.trackParameter.frameTrackingParameter = uipanel( ...
'Parent', artoaGui.figures.main, ...
'Title', 'Tracking Parameter', ...
'Units', 'normalized', ...
'BackgroundColor', 'white', ...
'Position', [ ...
spacer ...
(1 - spacer - heightFrame) ...
widthFrame ...
heightFrame ...
] ...
);
% default geometry values for track parameter
left = .025;
width = .20;
buttonHeight = .3;
% Tracking method frame
artoaGui.trackParameter.frameTrackingMethod = uipanel( ...
'Parent', artoaGui.trackParameter.frameTrackingParameter, ...
'Title', 'Tracking Method', ...
'Units', 'normalized', ...
'BackgroundColor', 'white', ...
'Position', [left .75 width .20] ...
);
artoaGui.trackParameter.comboboxTrackingMethod = uicontrol( ...
'Parent', artoaGui.trackParameter.frameTrackingMethod, ...
'String', pTrackingMethods, ...
'Style', 'popupmenu', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .5 .9 .4], ...
'CallBack', pCallbacks.comboboxTrackingMethod ...
);
artoaGui.trackParameter.checkboxDopplerCorrection = uicontrol( ...
'Parent', artoaGui.trackParameter.frameTrackingMethod, ...
'String', 'Apply Doppler Correction', ...
'Style', 'checkbox', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .1 .9 .3], ...
'Value', 1, ...
'CallBack', pCallbacks.checkboxDopplerCorrection ...
);
% Interpolation method frame
artoaGui.trackParameter.frameInterpolationMethod = uipanel( ...
'Parent', artoaGui.trackParameter.frameTrackingParameter, ...
'Title', 'Input Interpolation Method', ...
'Units', 'normalized', ...
'BackgroundColor', 'white', ...
'Position', [(2*left + width) .75 width .20] ...
);
artoaGui.trackParameter.comboboxInterpolationMethod = uicontrol( ...
'Parent', artoaGui.trackParameter.frameInterpolationMethod, ...
'String', pInterpolationMethods, ...
'Style', 'popupmenu', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .5 .9 .4], ...
'CallBack', pCallbacks.comboboxInterpolationMethod ...
);
artoaGui.trackParameter.textGapSize = uicontrol( ...
'Parent', artoaGui.trackParameter.frameInterpolationMethod, ...
'String', 'Gap Size [days]', ...
'Style', 'text', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .1 .5 .3], ...
'CallBack', '' ...
);
artoaGui.trackParameter.inputGapSize = uicontrol( ...
'Parent', artoaGui.trackParameter.frameInterpolationMethod, ...
'String', '10', ...
'Style', 'edit', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(.7-left) .1 .3 .3], ...
'CallBack', pCallbacks.inputGapSize ...
);
% Soundspeed method frame
artoaGui.trackParameter.frameSoundspeedMethod = uipanel( ...
'Parent', artoaGui.trackParameter.frameTrackingParameter, ...
'Title', 'Sound Speed Method', ...
'Units', 'normalized', ...
'BackgroundColor', 'white', ...
'Position', [(3*left + 2*width) .75 width .20] ...
);
artoaGui.trackParameter.comboboxSoundspeedMethod = uicontrol( ...
'Parent', artoaGui.trackParameter.frameSoundspeedMethod, ...
'String', pSoundspeedMethods, ...
'Style', 'popupmenu', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .5 .9 .4], ...
'CallBack', pCallbacks.comboboxSoundspeedMethod ...
);
artoaGui.trackParameter.checkboxPlotResiduals = uicontrol( ...
'Parent', artoaGui.trackParameter.frameSoundspeedMethod, ...
'String', 'Plot Residuals', ...
'Enable', 'off', ...
'Style', 'checkbox', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .1 .9 .3], ...
'CallBack', pCallbacks.checkboxPlotResiduals ...
);
% Output interpolation interval
artoaGui.trackParameter.textOutputInterpolationInterval = uicontrol( ...
'Parent', artoaGui.trackParameter.frameTrackingParameter, ...
'String', 'Output Interpolation Interval [h]', ...
'Style', 'text', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(4*left + 3*width) .75 (.5*width) .20], ...
'CallBack', '' ...
);
artoaGui.trackParameter.inputOutputInterpolationInterval = uicontrol( ...
'Parent', artoaGui.trackParameter.frameTrackingParameter, ...
'String', '24', ...
'Style', 'edit', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(5*left + 3*width) .775 (.25*width) .05], ...
'CallBack', pCallbacks.inputOutputInterpolationInterval ...
);
% Sound source combination table
columns = { ...
'Begin', ...
'End', ...
'Sound Sources', ...
'Reference Position', ...
'Sound Speed', 'Sound Speed', 'Sound Speed' ...
};
artoaGui.trackParameter.tableSoundSourceCombinations = uitable( ...
artoaGui.trackParameter.frameTrackingParameter, ...
'Units', 'normalized', ...
'Position', [left, 0.05, (5*left + 3.25*width), 0.65], ...
'Data', cell(1, length(columns)), ...
'ColumnName', columns, ...
'ColumnEditable', true, ...
'CellSelectionCallback', pCallbacks.tableSoundSourceCombinationsSelection,... %@(app,event) disp(num2str(event.Indices)) ...
'CellEditCallback', pCallbacks.tableSoundSourceCombinationsEdit ...
);
clear columns;
% Track buttons frame
artoaGui.trackParameter.frameTrackButtons = uipanel( ...
'Parent', artoaGui.trackParameter.frameTrackingParameter, ...
'Title', 'Tracking controls', ...
'Units', 'normalized', ...
'BackgroundColor', 'white', ...
'Position', [(1-left-.75*width) .58 .75*width .20] ...
);
artoaGui.trackParameter.buttonTrack = uicontrol( ...
'Parent', artoaGui.trackParameter.frameTrackButtons, ...
'String', 'Track', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .3 (1-2*left) buttonHeight], ...
'CallBack', pCallbacks.buttonTrack ...
);
% Combination buttons frame
artoaGui.trackParameter.frameCombinationButtons = uipanel( ...
'Parent', artoaGui.trackParameter.frameTrackingParameter, ...
'Title', 'Combination controls', ...
'Units', 'normalized', ...
'BackgroundColor', 'white', ...
'Position', [(1-left-.75*width) .13 .75*width .40] ...
);
artoaGui.trackParameter.buttonAddCombination = uicontrol( ...
'Parent', artoaGui.trackParameter.frameCombinationButtons, ...
'String', 'Add', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .8 (1-2*left) .4*buttonHeight], ...
'CallBack', pCallbacks.buttonAddCombination ...
);
artoaGui.trackParameter.buttonAddAboveCombination = uicontrol( ...
'Parent', artoaGui.trackParameter.frameCombinationButtons, ...
'String', 'Add above selected', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .65 (1-2*left) .4*buttonHeight], ...
'CallBack', pCallbacks.buttonAddCombinationAbove ...
);
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
artoaGui.trackParameter.buttonDuplicateCombination = uicontrol( ...
'Parent', artoaGui.trackParameter.frameCombinationButtons, ...
'String', 'Duplicate selected', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .5 (1-2*left) .4*buttonHeight], ...
'CallBack', pCallbacks.buttonDuplicateCombination ...
);
artoaGui.trackParameter.buttonRemoveCombination = uicontrol( ...
'Parent', artoaGui.trackParameter.frameCombinationButtons, ...
'String', 'Remove selected', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .35 (1-2*left) .4*buttonHeight], ...
'CallBack', pCallbacks.buttonRemoveCombination ...
);
artoaGui.trackParameter.buttonResetAllCombinations = uicontrol( ...
'Parent', artoaGui.trackParameter.frameCombinationButtons, ...
'String', 'Reset All', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .1 (1-2*left) .4*buttonHeight], ...
'CallBack', pCallbacks.buttonResetAllCombinations ...
);
clear left width buttonHeight;
%% Offset table
artoaGui.editOffsets.frameOffsets = uipanel( ...
'Parent', artoaGui.figures.main, ...
'Title', 'Offsets', ...
'Units', 'normalized', ...
'BackgroundColor', 'white', ...
'Position', [ ...
spacer ...
(1 - 2 * spacer - 2 * heightFrame) ...
widthFrame ...
heightFrame ...
] ...
);
% setup geometry variables
left = 0.03;
fullwidth = 1 - (2 * left);
% Initialize offset table
artoaGui.editOffsets.tableSoundsourceOffsets = uitable( ...
artoaGui.editOffsets.frameOffsets, ...
'Units', 'normalized', ...
'Position', [left, 0.45, fullwidth, 0.525], ...
'ColumnEditable', true, ...
'CellSelectionCallback', pCallbacks.tableSoundsourceOffsetsSelect, ...
'CellEditCallback', pCallbacks.tableSoundsourceOffsetsEdit ...
);
% Initialize soundspeed table
artoaGui.editOffsets.tableSoundspeed = uitable( ...
artoaGui.editOffsets.frameOffsets, ...
'Units', 'normalized', ...
'Position', [left, 0.35, fullwidth, 0.1], ...
'ColumnEditable', true, ...'CellSelectionCallback', pCallbacks.tableSoundsourceOffsetsSelect, ...
'CellEditCallback', pCallbacks.tableSoundspeedEdit ...
);
% Optimum offsets frame
artoaGui.editOffsets.frameOptimumOffsets = uipanel( ...
'Parent', artoaGui.editOffsets.frameOffsets, ...
'Title', 'Offset controls', ...
'Units', 'normalized', ...
'BackgroundColor', 'white', ...
'Position', [left .025 fullwidth .3] ...
);
% Setup calculate offsets button
artoaGui.editOffsets.buttonCalculateOffsets = uicontrol( ...
'Parent', artoaGui.editOffsets.frameOptimumOffsets, ...
'String', 'Calculate offsets', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .25 fullwidth/2 .2], ...
'CallBack', pCallbacks.buttonCalculateOffsets ...
);
artoaGui.editOffsets.checkboxUseOffsets = uicontrol( ...
'Parent', artoaGui.editOffsets.frameOptimumOffsets, ...
'String', 'Use offsets', ...
'Style', 'checkbox', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [left .75 fullwidth/2 .2], ...
'CallBack', pCallbacks.checkboxUseOffsets ...
);
artoaGui.editOffsets.buttonCopyFromMeasured = uicontrol( ...
'Parent', artoaGui.editOffsets.frameOptimumOffsets, ...
'String', 'Copy Measured to Empirical', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(1.5*left + fullwidth/2) .725 fullwidth/2 .2], ...
'CallBack', pCallbacks.buttonCopyFromMeasured ...
);
artoaGui.editOffsets.buttonCopyFromOptimum = uicontrol( ...
'Parent', artoaGui.editOffsets.frameOptimumOffsets, ...
'String', 'Copy Optimum to Empirical', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(1.5*left + fullwidth/2) .5 fullwidth/2 .2], ...
'CallBack', pCallbacks.buttonCopyFromOptimum ...
);
artoaGui.editOffsets.buttonEmpiricalToNan = uicontrol( ...
'Parent', artoaGui.editOffsets.frameOptimumOffsets, ...
'String', 'Empirical to NaN', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(1.5*left + fullwidth/2) .275 fullwidth/2 .2], ...
'CallBack', pCallbacks.buttonEmpiricalToNan ...
);
artoaGui.editOffsets.buttonUndoLastCopy = uicontrol( ...
'Parent', artoaGui.editOffsets.frameOptimumOffsets, ...
'String', 'Undo last copy', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(1.5*left + fullwidth/2) .05 fullwidth/2 .2], ...
'CallBack', pCallbacks.buttonUndoLastCopy ...
);