Skip to content
Snippets Groups Projects
Commit 27e966f6 authored by leprob001's avatar leprob001
Browse files

Updated offsets table. (Unstable version)

/ Float offsets are now integrated into the table
/ Options to either use manual or calculated offset (last one not done yet)
/ Added begin and end offset for soundsources to enable input of drift (drift not implemented yet)
/ Updated GUI of track parameter
parent 72df8e30
No related branches found
No related tags found
No related merge requests found
Showing
with 115 additions and 163 deletions
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
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
......@@ -25,14 +25,11 @@ callbacks.tableSoundSourceCombinationsSelection = @artoa.controller.track.parame
callbacks.tableSoundSourceCombinationsEdit = @artoa.controller.track.parameter.tableSoundsourceCombinationsEdit;
callbacks.tableSoundSourceOffsetsEdit = @artoa.controller.track.parameter.tableSoundsourceOffsetsEdit;
callbacks.buttonTrack = @artoa.controller.track.run;
callbacks.buttonQuickTrack = '';
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( ...
......@@ -42,16 +39,6 @@ artoa.gui.track.parameter( ...
artoaWorkspace.defaults.soundspeedMethods ...
);
%% Get sources with applied toa
soundsourcesWithAppliedToa = artoa.controller.getSoundsourcesWithAppliedToa();
%% Setup sound source offsets table
% initialize sound source offsets
artoaGui.trackParameter.tableSoundSourceOffsets.RowName = fieldnames( ...
soundsourcesWithAppliedToa ...
);
%% Create workspace variables
if ~isfield(artoaWorkspace, 'trackParameter')
artoaWorkspace.trackParameter = struct();
......@@ -64,11 +51,8 @@ if ~isfield(artoaWorkspace, 'trackParameter')
artoaGui.trackParameter.tableSoundSourceCombinations.Data = artoa.controller.track.parameter.getDefaultCombinationCell();
% initialize sound source offsets
artoaGui.trackParameter.tableSoundSourceOffsets.Data(1:length(artoaGui.trackParameter.tableSoundSourceOffsets.RowName), 1) = {0};
artoaWorkspace.trackParameter.soundsourceOffsets = artoa.soundsources.createOffsetsStruct( ...
artoaGui.trackParameter.tableSoundSourceOffsets.RowName, ...
artoaGui.trackParameter.tableSoundSourceOffsets.Data ...
);
artoaWorkspace.trackParameter.soundsourceOffsets = ...
artoa.offsets.generateOffsetTable(artoa.controller.getSoundsourcesWithAppliedToa());
% initialize settings
availableCallbacks = { ...
......@@ -78,11 +62,8 @@ if ~isfield(artoaWorkspace, 'trackParameter')
'comboboxSoundspeedMethod', ...
'checkboxPlotResiduals', ...
'inputOutputInterpolationInterval', ...
'inputGapSize', ...
'tableSoundSourceOffsetsEdit', ...
'tableSoundSourceCombinationsEdit', ...
'inputFloatOffsetBegin', ...
'inputFloatOffsetEnd' ...
'inputGapSize', ...'tableSoundSourceOffsetsEdit', ...
'tableSoundSourceCombinationsEdit' ...
};
for i = 1:length(availableCallbacks)
......
......@@ -6,10 +6,7 @@ function [] = tableSoundsourceOffsetsEdit(~, ~)
global artoaGui artoaWorkspace;
%% Save to workspace
artoaWorkspace.trackParameter.soundsourceOffsets = artoa.soundsources.createOffsetsStruct( ...
artoaGui.trackParameter.tableSoundSourceOffsets.RowName, ...
artoaGui.trackParameter.tableSoundSourceOffsets.Data ...
);
artoaWorkspace.trackParameter.soundsourceOffsets(:, :) = artoaGui.trackParameter.tableSoundSourceOffsets.Data;
end
......@@ -36,17 +36,13 @@ for i = 1:length(fieldNames)
case 'gapSize'
artoaGui.trackParameter.inputGapSize.String = currentValue;
case 'soundsourceOffsets'
artoaGui.trackParameter.tableSoundSourceOffsets.Data = ...
artoa.soundsources.createOffsetsCell( ...
currentValue, ...
artoaGui.trackParameter.tableSoundSourceOffsets.RowName ...
);
artoaGui.trackParameter.tableSoundSourceOffsets.Data = table2cell( ...
currentValue ...
);
artoaGui.trackParameter.tableSoundSourceOffsets.RowName = currentValue.Properties.RowNames;
artoaGui.trackParameter.tableSoundSourceOffsets.ColumnName = currentValue.Properties.VariableNames;
case 'soundsourceCombinations'
artoaGui.trackParameter.tableSoundSourceCombinations.Data = artoa.soundsources.createCombinationsCell(currentValue);
case 'floatOffsetBegin'
artoaGui.trackParameter.inputFloatOffsetBegin.String = currentValue;
case 'floatOffsetEnd'
artoaGui.trackParameter.inputFloatOffsetEnd.String = currentValue;
end
end
......
......@@ -40,8 +40,8 @@ uniqueToaDates = unique(pToaData.toaDate);
%% Add float drift to TOA
pToaData = artoa.data.addFloatDrift( ...
pToaData, ...
pTrackingParameter.floatOffsetBegin, ...
pTrackingParameter.floatOffsetEnd ...
pTrackingParameter.soundsourceOffsets{'Float', 'Begin'}, ...
pTrackingParameter.soundsourceOffsets{'Float', 'End'} ...
);
%% Initialize return variables
......@@ -113,8 +113,8 @@ for i = 1:length(involvedSoundsources)
% subtract offset (corrective value) of sound source
soundsourceOffsetCorrectiveValue = ...
pTrackingParameter.soundsourceOffsets.(currentSoundsource.sourcename);
currentToa = currentToa - soundsourceOffsetCorrectiveValue(1);
pTrackingParameter.soundsourceOffsets{currentSoundsource.sourcename, 'Begin'};
currentToa = currentToa - soundsourceOffsetCorrectiveValue;
% interpolate toa data
[ ...
......
......@@ -25,9 +25,7 @@ availableCallbacks = { ...
'buttonAddCombinationAbove', ...
'buttonDuplicateCombination', ...
'buttonRemoveCombination', ...
'buttonResetAllCombinations', ...
'inputFloatOffsetBegin', ...
'inputFloatOffsetEnd' ...
'buttonResetAllCombinations' ...
};
for i = 1:length(availableCallbacks) % check if a callback is undefined
......@@ -203,20 +201,14 @@ clear columns;
%% Sound source offset table
columns = { ...
'Offset'
};
artoaGui.trackParameter.tableSoundSourceOffsets = uitable( ...
artoaGui.figures.trackParameter, ...
'Units', 'normalized', ...
'Position', [left, 0.1, width, 0.27], ...
'Data', cell(1, length(columns)), ...
'ColumnName', columns, ...
'Position', [left, 0.1, width * 2, 0.27], ...
'ColumnEditable', true, ...
'CellSelectionCallback', pCallbacks.tableSoundSourceOffsetsSelection,... %@(app,event) disp(num2str(event.Indices)) ...
'CellEditCallback', pCallbacks.tableSoundSourceOffsetsEdit ...
);
clear columns;
%% Track buttons frame
......@@ -237,7 +229,6 @@ artoaGui.trackParameter.buttonTrack = uicontrol( ...
'CallBack', pCallbacks.buttonTrack ...
);
%% Combination buttons frame
artoaGui.trackParameter.frameCombinationButtons = uipanel( ...
......@@ -298,54 +289,5 @@ artoaGui.trackParameter.buttonResetAllCombinations = uicontrol( ...
'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
function [offsetsTable] = addSoundsource(pOffsetsTable, pSoundsource)
%ADDROW Summary of this function goes here
% Detailed explanation goes here
%% Initialize return variable
offsetsTable = pOffsetsTable;
%% Check if soundsource already exists
if any(strcmp(pSoundsource.sourcename, pOffsetsTable.Properties.RowNames))
return;
end
%% Add variable
offsetsTable(end + 1, :) = artoa.offsets.getDefaultRowValues();
offsetsTable.Properties.RowNames{end} = pSoundsource.sourcename;
%% Sort rows
offsetsTable = sortrows(offsetsTable, 'RowNames');
end
function [offsetTable] = generateOffsetTable(pSoundsources)
%GETDEFAULTOFFSETTABLE Summary of this function goes here
% Detailed explanation goes here
%% Initialize return variable
offsetTable = cell2table( ...
artoa.offsets.getDefaultRowValues(), ...
'VariableNames', artoa.offsets.getDefaultVariableNames() ...
);
%% Setup rows
offsetTable.Properties.RowNames(1) = {'Float'};
if nargin ~= 1
return;
end
if iscell(pSoundsources)
for i = 1:length(pSoundsources)
offsetTable(i + 1, :) = artoa.offsets.getDefaultRowValues();
offsetTable.Properties.RowNames(i + 1) = {pSoundsources{i}.sourcename};
end
end
if isstruct(pSoundsources)
fnames = fieldnames(pSoundsources);
for i = 1:length(fnames)
offsetTable(i + 1, :) = artoa.offsets.getDefaultRowValues();
offsetTable.Properties.RowNames(i + 1) = {pSoundsources.(fnames{i}).sourcename};
end
end
end
function [defaultRow] = getDefaultRowValues()
%GETDEFAULTROW Summary of this function goes here
% Detailed explanation goes here
defaultOffset = 0;
defaultUseOffset = false;
defaultRow = {defaultOffset, defaultUseOffset, defaultOffset, defaultUseOffset};
end
function [defaultVariableNames] = getDefaultVariableNames()
%GETDEFAULTVARIABLENAMES Summary of this function goes here
% Detailed explanation goes here
defaultVariableNames = { ...
'Begin', ...
'UseBegin', ...
'End', ...
'UseEnd' ...
};
end
function [offsetsTable] = removeSoundsource(pOffsetsTable, pSoundsourceName)
%ADDROW Summary of this function goes here
% Detailed explanation goes here
%% Initialize return variable
offsetsTable = pOffsetsTable;
%% Check if soundsource exists
if ~any(strcmp(pSoundsourceName, pOffsetsTable.Properties.RowNames))
return;
end
%% Remove from table
offsetsTable(pSoundsourceName, :) = [];
%% Sort rows
offsetsTable = sortrows(offsetsTable, 'RowNames');
end
function [offsetsCell] = createOffsetsCell(pOffsetsStruct, pTableRowNames)
%CREATEOFFSETSCELL Summary of this function goes here
% Detailed explanation goes here
%% Initialize return variable
offsetsCell = cell(length(pTableRowNames), 1);
%% Create cell
for i = 1:length(pTableRowNames)
currentRowName = pTableRowNames{i};
if artoa.data.hasMember(pOffsetsStruct, {currentRowName})
value = pOffsetsStruct.(currentRowName);
else
value = 0;
end
offsetsCell{i} = value;
end
end
function [offsetStruct] = createOffsetsStruct(pOffsetTableRowNames, pOffsetTableData)
%CREATEOFFSETSSTRUCT Summary of this function goes here
% Detailed explanation goes here
%% Initialize return variable
offsetStruct = struct();
%% Convert to struct
rowNames = pOffsetTableRowNames;
for i = 1:length(rowNames)
offsetStruct.(rowNames{i}) = pOffsetTableData{i, 1};
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment