From dc87e3d2825af77cffa4b1726a4fae23196d89c3 Mon Sep 17 00:00:00 2001 From: Lewin Probst <info@emirror.de> Date: Sun, 22 Sep 2019 20:17:28 +0200 Subject: [PATCH] Improved track parameter window and added state management. --- .../+parameter/addSoundsourceCombination.m | 19 ++++ .../addSoundsourceCombinationAbove.m | 25 ++++++ .../duplicateSoundsourceCombination.m | 25 ++++++ .../+track/+parameter/inputFloatOffsetBegin.m | 13 +++ .../+track/+parameter/inputFloatOffsetEnd.m | 13 +++ .../+track/+parameter/inputGapSize.m | 2 +- .../inputOutputInterpolationInterval.m | 2 +- .../+controller/+track/+parameter/open.m | 17 ++-- .../+parameter/removeSoundsourceCombination.m | 21 +++++ .../+parameter/resetSoundsourceCombinations.m | 16 ++++ .../tableSoundsourceCombinationsEdit.m | 11 +++ .../tableSoundsourceCombinationsSelection.m | 20 +++++ .../+controller/+track/+parameter/updateGui.m | 6 ++ lib/+artoa/+gui/+track/parameter.m | 90 +++++++++++++++++-- 14 files changed, 264 insertions(+), 16 deletions(-) create mode 100644 lib/+artoa/+controller/+track/+parameter/addSoundsourceCombination.m create mode 100644 lib/+artoa/+controller/+track/+parameter/addSoundsourceCombinationAbove.m create mode 100644 lib/+artoa/+controller/+track/+parameter/duplicateSoundsourceCombination.m create mode 100644 lib/+artoa/+controller/+track/+parameter/inputFloatOffsetBegin.m create mode 100644 lib/+artoa/+controller/+track/+parameter/inputFloatOffsetEnd.m create mode 100644 lib/+artoa/+controller/+track/+parameter/removeSoundsourceCombination.m create mode 100644 lib/+artoa/+controller/+track/+parameter/resetSoundsourceCombinations.m create mode 100644 lib/+artoa/+controller/+track/+parameter/tableSoundsourceCombinationsEdit.m create mode 100644 lib/+artoa/+controller/+track/+parameter/tableSoundsourceCombinationsSelection.m diff --git a/lib/+artoa/+controller/+track/+parameter/addSoundsourceCombination.m b/lib/+artoa/+controller/+track/+parameter/addSoundsourceCombination.m new file mode 100644 index 0000000..c40f9f1 --- /dev/null +++ b/lib/+artoa/+controller/+track/+parameter/addSoundsourceCombination.m @@ -0,0 +1,19 @@ +function [] = addSoundsourceCombination(~, ~) +%ADDSOUNDSOURCECOMBINATION Summary of this function goes here +% Detailed explanation goes here + + +global artoaWorkspace; + +%% Get column count +columnCount = size(artoaWorkspace.trackParameter.soundsourceCombinations, 2); + +%% Add to the end +artoaWorkspace.trackParameter.soundsourceCombinations(end + 1, :) = cell(1, columnCount); + +%% Update gui +artoa.controller.track.parameter.updateGui(); + + +end + diff --git a/lib/+artoa/+controller/+track/+parameter/addSoundsourceCombinationAbove.m b/lib/+artoa/+controller/+track/+parameter/addSoundsourceCombinationAbove.m new file mode 100644 index 0000000..d7cbf26 --- /dev/null +++ b/lib/+artoa/+controller/+track/+parameter/addSoundsourceCombinationAbove.m @@ -0,0 +1,25 @@ +function [] = addSoundsourceCombinationAbove(~, ~) +%ADDSOUNDSOURCECOMBINATIONABOVE Summary of this function goes here +% Detailed explanation goes here + + +global artoaWorkspace; + +%% Get column count +columnCount = size(artoaWorkspace.trackParameter.soundsourceCombinations, 2); +%% Get selection +selectedRow = artoaWorkspace.trackParameter.selectedSoundsourceCombinationRow; +%% Get current data +combinationCell = artoaWorkspace.trackParameter.soundsourceCombinations; + +%% Add above the selected +combinationCell(selectedRow + 1:end + 1, :) = combinationCell(selectedRow:end, :); +combinationCell(selectedRow, :) = cell(1, columnCount); +artoaWorkspace.trackParameter.soundsourceCombinations = combinationCell; + +%% Update gui +artoa.controller.track.parameter.updateGui(); + + +end + diff --git a/lib/+artoa/+controller/+track/+parameter/duplicateSoundsourceCombination.m b/lib/+artoa/+controller/+track/+parameter/duplicateSoundsourceCombination.m new file mode 100644 index 0000000..9ca9b2e --- /dev/null +++ b/lib/+artoa/+controller/+track/+parameter/duplicateSoundsourceCombination.m @@ -0,0 +1,25 @@ +function [] = duplicateSoundsourceCombination(~, ~) +%DUPLICATESOUNDSOURCECOMBINATION Summary of this function goes here +% Detailed explanation goes here + + +global artoaWorkspace; + +%% Get column count +columnCount = size(artoaWorkspace.trackParameter.soundsourceCombinations, 2); +%% Get selection +selectedRow = artoaWorkspace.trackParameter.selectedSoundsourceCombinationRow; +%% Get current data +combinationCell = artoaWorkspace.trackParameter.soundsourceCombinations; + +%% Add above the selected +combinationCell(selectedRow + 1:end + 1, :) = combinationCell(selectedRow:end, :); +combinationCell(selectedRow, :) = combinationCell(selectedRow + 1, :); +artoaWorkspace.trackParameter.soundsourceCombinations = combinationCell; + +%% Update gui +artoa.controller.track.parameter.updateGui(); + + +end + diff --git a/lib/+artoa/+controller/+track/+parameter/inputFloatOffsetBegin.m b/lib/+artoa/+controller/+track/+parameter/inputFloatOffsetBegin.m new file mode 100644 index 0000000..a17d691 --- /dev/null +++ b/lib/+artoa/+controller/+track/+parameter/inputFloatOffsetBegin.m @@ -0,0 +1,13 @@ +function [newValue] = inputFloatOffsetBegin(~, ~) +%INPUTFLOATOFFSETBEGIN Summary of this function goes here +% Detailed explanation goes here + +global artoaGui artoaWorkspace; + +newValue = artoaGui.trackParameter.inputFloatOffsetBegin.String; + +artoaWorkspace.trackParameter.floatOffsetBegin = str2double(newValue); + + +end + diff --git a/lib/+artoa/+controller/+track/+parameter/inputFloatOffsetEnd.m b/lib/+artoa/+controller/+track/+parameter/inputFloatOffsetEnd.m new file mode 100644 index 0000000..029cfa0 --- /dev/null +++ b/lib/+artoa/+controller/+track/+parameter/inputFloatOffsetEnd.m @@ -0,0 +1,13 @@ +function [newValue] = inputFloatOffsetEnd(~, ~) +%INPUTFLOATOFFSETBEGIN Summary of this function goes here +% Detailed explanation goes here + +global artoaGui artoaWorkspace; + +newValue = artoaGui.trackParameter.inputFloatOffsetEnd.String; + +artoaWorkspace.trackParameter.floatOffsetEnd = str2double(newValue); + + +end + diff --git a/lib/+artoa/+controller/+track/+parameter/inputGapSize.m b/lib/+artoa/+controller/+track/+parameter/inputGapSize.m index 6da9161..091e70f 100644 --- a/lib/+artoa/+controller/+track/+parameter/inputGapSize.m +++ b/lib/+artoa/+controller/+track/+parameter/inputGapSize.m @@ -6,7 +6,7 @@ global artoaGui artoaWorkspace; newValue = artoaGui.trackParameter.inputGapSize.String; -artoaWorkspace.trackParameter.inputGapSize = newValue; +artoaWorkspace.trackParameter.gapSize = str2double(newValue); end diff --git a/lib/+artoa/+controller/+track/+parameter/inputOutputInterpolationInterval.m b/lib/+artoa/+controller/+track/+parameter/inputOutputInterpolationInterval.m index d2a53e9..72a4447 100644 --- a/lib/+artoa/+controller/+track/+parameter/inputOutputInterpolationInterval.m +++ b/lib/+artoa/+controller/+track/+parameter/inputOutputInterpolationInterval.m @@ -6,7 +6,7 @@ global artoaGui artoaWorkspace; newValue = artoaGui.trackParameter.inputOutputInterpolationInterval.String; -artoaWorkspace.trackParameter.outputInterpolationInterval = newValue; +artoaWorkspace.trackParameter.interpolationInterval = str2double(newValue); end diff --git a/lib/+artoa/+controller/+track/+parameter/open.m b/lib/+artoa/+controller/+track/+parameter/open.m index 6f81839..ec617ea 100644 --- a/lib/+artoa/+controller/+track/+parameter/open.m +++ b/lib/+artoa/+controller/+track/+parameter/open.m @@ -21,14 +21,18 @@ callbacks.comboboxSoundspeedMethod = @artoa.controller.track.parameter.comboboxS callbacks.checkboxPlotResiduals = @artoa.controller.track.parameter.checkboxPlotResiduals; callbacks.inputOutputInterpolationInterval = @artoa.controller.track.parameter.inputOutputInterpolationInterval; callbacks.inputGapSize = @artoa.controller.track.parameter.inputGapSize; -callbacks.tableSoundSourceCombinationsSelection = ''; -callbacks.tableSoundSourceCombinationsEdit = ''; +callbacks.tableSoundSourceCombinationsSelection = @artoa.controller.track.parameter.tableSoundsourceCombinationsSelection; +callbacks.tableSoundSourceCombinationsEdit = @artoa.controller.track.parameter.tableSoundsourceCombinationsEdit; callbacks.tableSoundSourceOffsetsEdit = @artoa.controller.track.parameter.tableSoundsourceOffsetsEdit; callbacks.buttonTrack = ''; callbacks.buttonQuickTrack = ''; -callbacks.buttonAddCombination = ''; -callbacks.buttonRemoveCombination = ''; -callbacks.buttonResetAllCombinations = ''; +callbacks.buttonAddCombination = @artoa.controller.track.parameter.addSoundsourceCombination; +callbacks.buttonAddCombinationAbove = @artoa.controller.track.parameter.addSoundsourceCombinationAbove; +callbacks.buttonDuplicateCombination = @artoa.controller.track.parameter.duplicateSoundsourceCombination; +callbacks.buttonRemoveCombination = @artoa.controller.track.parameter.removeSoundsourceCombination; +callbacks.buttonResetAllCombinations = @artoa.controller.track.parameter.resetSoundsourceCombinations; +callbacks.inputFloatOffsetBegin = @artoa.controller.track.parameter.inputFloatOffsetBegin; +callbacks.inputFloatOffsetEnd = @artoa.controller.track.parameter.inputFloatOffsetEnd; %% Open the gui artoa.gui.track.parameter( ... @@ -56,7 +60,8 @@ if ~isfield(artoaWorkspace, 'trackParameter') 'checkboxPlotResiduals', ... 'inputOutputInterpolationInterval', ... 'inputGapSize', ... - 'tableSoundSourceOffsetsEdit' ... + 'tableSoundSourceOffsetsEdit', ... + 'tableSoundSourceCombinationsEdit' ... }; for i = 1:length(availableCallbacks) diff --git a/lib/+artoa/+controller/+track/+parameter/removeSoundsourceCombination.m b/lib/+artoa/+controller/+track/+parameter/removeSoundsourceCombination.m new file mode 100644 index 0000000..d27f54f --- /dev/null +++ b/lib/+artoa/+controller/+track/+parameter/removeSoundsourceCombination.m @@ -0,0 +1,21 @@ +function [] = removeSoundsourceCombination(~, ~) +%REMOVESOUNDSOURCECOMBINATION Summary of this function goes here +% Detailed explanation goes here + + +global artoaWorkspace; + +%% Get selected row + +selectedRow = artoaWorkspace.trackParameter.selectedSoundsourceCombinationRow; + +%% Delete from workspace +artoaWorkspace.trackParameter.soundsourceCombinations(selectedRow, :) = []; + + +%% Update gui +artoa.controller.track.parameter.updateGui(); + + +end + diff --git a/lib/+artoa/+controller/+track/+parameter/resetSoundsourceCombinations.m b/lib/+artoa/+controller/+track/+parameter/resetSoundsourceCombinations.m new file mode 100644 index 0000000..fa80e26 --- /dev/null +++ b/lib/+artoa/+controller/+track/+parameter/resetSoundsourceCombinations.m @@ -0,0 +1,16 @@ +function [] = resetSoundsourceCombinations(~, ~) +%RESETSOUNDSOURCECOMBINATIONS Summary of this function goes here +% Detailed explanation goes here + + +global artoaWorkspace; + +%% Delete from workspace +artoaWorkspace.trackParameter.soundsourceCombinations(:, :) = []; + +%% Update gui +artoa.controller.track.parameter.updateGui(); + + +end + diff --git a/lib/+artoa/+controller/+track/+parameter/tableSoundsourceCombinationsEdit.m b/lib/+artoa/+controller/+track/+parameter/tableSoundsourceCombinationsEdit.m new file mode 100644 index 0000000..f3d1bc7 --- /dev/null +++ b/lib/+artoa/+controller/+track/+parameter/tableSoundsourceCombinationsEdit.m @@ -0,0 +1,11 @@ +function [] = tableSoundsourceCombinationsEdit(~, ~) +%TABLESOUNDSOURCECOMBINATIONSEDIT Summary of this function goes here +% Detailed explanation goes here + + +global artoaWorkspace artoaGui; + +artoaWorkspace.trackParameter.soundsourceCombinations = artoaGui.trackParameter.tableSoundSourceCombinations.Data; + +end + diff --git a/lib/+artoa/+controller/+track/+parameter/tableSoundsourceCombinationsSelection.m b/lib/+artoa/+controller/+track/+parameter/tableSoundsourceCombinationsSelection.m new file mode 100644 index 0000000..68e3232 --- /dev/null +++ b/lib/+artoa/+controller/+track/+parameter/tableSoundsourceCombinationsSelection.m @@ -0,0 +1,20 @@ +function [outputArg1,outputArg2] = tableSoundsourceCombinationsSelection(~, event) +%TABLESOUNDSOURCECOMBINATIONSSELECTION Summary of this function goes here +% Detailed explanation goes here + +global artoaWorkspace; + +%% Update the selected cell +try + artoaWorkspace.trackParameter.selectedSoundsourceCombinationRow = event.Indices(1); + artoaWorkspace.trackParameter.selectedSoundsourceCombinationColumn = event.Indices(2); +catch + artoaWorkspace.trackParameter.selectedSoundsourceCombinationRow = ... + size(artoaWorkspace.trackParameter.soundsourceCombinations, 1); + artoaWorkspace.trackParameter.selectedSoundsourceCombinationColumn = ... + size(artoaWorkspace.trackParameter.soundsourceCombinations, 2); +end + + +end + diff --git a/lib/+artoa/+controller/+track/+parameter/updateGui.m b/lib/+artoa/+controller/+track/+parameter/updateGui.m index 3f86a76..a3babdf 100644 --- a/lib/+artoa/+controller/+track/+parameter/updateGui.m +++ b/lib/+artoa/+controller/+track/+parameter/updateGui.m @@ -30,6 +30,12 @@ for i = 1:length(fieldNames) artoaGui.trackParameter.inputGapSize.String = currentValue; case 'soundsourceOffsets' artoaGui.trackParameter.tableSoundSourceOffsets.Data = currentValue; + case 'soundsourceCombinations' + artoaGui.trackParameter.tableSoundSourceCombinations.Data = currentValue; + case 'floatOffsetBegin' + artoaGui.trackParameter.inputFloatOffsetBegin.String = currentValue; + case 'floatOffsetEnd' + artoaGui.trackParameter.inputFloatOffsetEnd.String = currentValue; end end diff --git a/lib/+artoa/+gui/+track/parameter.m b/lib/+artoa/+gui/+track/parameter.m index 4d2a9f3..364f27f 100644 --- a/lib/+artoa/+gui/+track/parameter.m +++ b/lib/+artoa/+gui/+track/parameter.m @@ -23,8 +23,12 @@ availableCallbacks = { ... 'buttonTrack', ... 'buttonQuickTrack', ... 'buttonAddCombination', ... + 'buttonAddCombinationAbove', ... + 'buttonDuplicateCombination', ... 'buttonRemoveCombination', ... - 'buttonResetAllCombinations' ... + 'buttonResetAllCombinations', ... + 'inputFloatOffsetBegin', ... + 'inputFloatOffsetEnd' ... }; for i = 1:length(availableCallbacks) % check if a callback is undefined @@ -206,7 +210,7 @@ columns = { ... artoaGui.trackParameter.tableSoundSourceOffsets = uitable( ... artoaGui.figures.trackParameter, ... 'Units', 'normalized', ... - 'Position', [left, 0.1, 0.75*width, 0.27], ... + 'Position', [left, 0.1, width, 0.27], ... 'Data', cell(1, length(columns)), ... 'ColumnName', columns, ... 'ColumnEditable', true, ... @@ -255,33 +259,103 @@ artoaGui.trackParameter.frameCombinationButtons = uipanel( ... artoaGui.trackParameter.buttonAddCombination = uicontrol( ... 'Parent', artoaGui.trackParameter.frameCombinationButtons, ... - 'String', 'Add Combination', ... + 'String', 'Add', ... 'Style', 'PushButton', ... 'FontSize', 8, ... 'Units', 'normalized', ... - 'Position', [left .8 (1-2*left) .5*buttonHeight], ... + '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 ... +); + +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 Combination', ... + 'String', 'Remove selected', ... 'Style', 'PushButton', ... 'FontSize', 8, ... 'Units', 'normalized', ... - 'Position', [left .6 (1-2*left) .5*buttonHeight], ... + 'Position', [left .35 (1-2*left) .4*buttonHeight], ... 'CallBack', pCallbacks.buttonRemoveCombination ... ); artoaGui.trackParameter.buttonResetAllCombinations = uicontrol( ... 'Parent', artoaGui.trackParameter.frameCombinationButtons, ... - 'String', 'Reset Combinations', ... + 'String', 'Reset All', ... 'Style', 'PushButton', ... 'FontSize', 8, ... 'Units', 'normalized', ... - 'Position', [left .1 (1-2*left) .5*buttonHeight], ... + 'Position', [left .1 (1-2*left) .4*buttonHeight], ... 'CallBack', pCallbacks.buttonResetAllCombinations ... ); +%% Float offset frame + +artoaGui.trackParameter.frameFloatOffsets = uipanel( ... + 'Title', 'Float offsets', ... + 'Units', 'normalized', ... + 'BackgroundColor', 'white', ... + 'Position', [(2*left + width) .1 width .27] ... +); + +artoaGui.trackParameter.textFloatOffsetBegin = uicontrol( ... + 'Parent', artoaGui.trackParameter.frameFloatOffsets, ... + 'String', 'Begin [s]', ... + 'Style', 'text', ... + 'FontSize', 8, ... + 'Units', 'normalized', ... + 'Position', [left .6 .3 .2], ... + 'CallBack', '' ... +); + +artoaGui.trackParameter.inputFloatOffsetBegin = uicontrol( ... + 'Parent', artoaGui.trackParameter.frameFloatOffsets, ... + 'String', '0', ... + 'Style', 'edit', ... + 'FontSize', 8, ... + 'Units', 'normalized', ... + 'Position', [(.5-left) .6 .3 .2], ... + 'CallBack', pCallbacks.inputFloatOffsetBegin ... +); + +artoaGui.trackParameter.textFloatOffsetEnd = uicontrol( ... + 'Parent', artoaGui.trackParameter.frameFloatOffsets, ... + 'String', 'End [s]', ... + 'Style', 'text', ... + 'FontSize', 8, ... + 'Units', 'normalized', ... + 'Position', [left .2 .3 .2], ... + 'CallBack', '' ... +); + +artoaGui.trackParameter.inputFloatOffsetEnd = uicontrol( ... + 'Parent', artoaGui.trackParameter.frameFloatOffsets, ... + 'String', '0', ... + 'Style', 'edit', ... + 'FontSize', 8, ... + 'Units', 'normalized', ... + 'Position', [(.5-left) .2 .3 .2], ... + 'CallBack', pCallbacks.inputFloatOffsetEnd ... +); + end -- GitLab