Skip to content
Snippets Groups Projects
Commit 55689fda authored by leprob001's avatar leprob001
Browse files

Refactoring of track parameter window functions.

parent e3f0f585
No related branches found
No related tags found
No related merge requests found
Showing
with 147 additions and 41 deletions
......@@ -5,15 +5,11 @@ function [] = addSoundsourceCombination(~, ~)
global artoaWorkspace;
%% Get column count
columnCount = size(artoaWorkspace.trackParameter.soundsourceCombinations, 2);
%% Add to the end
artoaWorkspace.trackParameter.soundsourceCombinations(end + 1, :) = cell(1, columnCount);
%% Insert default content
artoaWorkspace.trackParameter.soundsourceCombinations(end + 1, :) = artoa.controller.track.parameter.getDefaultCombinationCell();
%% Update gui
artoa.controller.track.parameter.updateGui();
end
......@@ -5,17 +5,15 @@ function [] = addSoundsourceCombinationAbove(~, ~)
global artoaWorkspace;
%% Get column count
columnCount = size(artoaWorkspace.trackParameter.soundsourceCombinations, 2);
%% Get selection
selectedRow = artoaWorkspace.trackParameter.selectedSoundsourceCombinationRow;
%% Get current data
combinationCell = artoaWorkspace.trackParameter.soundsourceCombinations;
combinations = artoaWorkspace.trackParameter.soundsourceCombinations;
%% Add above the selected
combinationCell(selectedRow + 1:end + 1, :) = combinationCell(selectedRow:end, :);
combinationCell(selectedRow, :) = cell(1, columnCount);
artoaWorkspace.trackParameter.soundsourceCombinations = combinationCell;
combinations(selectedRow + 1:end + 1, :) = combinations(selectedRow:end, :);
combinations(selectedRow, :) = artoa.controller.track.parameter.getDefaultCombinationCell();
artoaWorkspace.trackParameter.soundsourceCombinations = combinations;
%% Update gui
artoa.controller.track.parameter.updateGui();
......
......@@ -3,19 +3,22 @@ function [] = duplicateSoundsourceCombination(~, ~)
% Detailed explanation goes here
global artoaWorkspace;
global artoaWorkspace artoaGui;
%% Get column count
columnCount = size(artoaWorkspace.trackParameter.soundsourceCombinations, 2);
%% Get selection
selectedRow = artoaWorkspace.trackParameter.selectedSoundsourceCombinationRow;
%% Get current data
combinationCell = artoaWorkspace.trackParameter.soundsourceCombinations;
combinationTable = ...
artoa.soundsources.createCombinationsTable( ...
artoaGui.trackParameter.tableSoundSourceCombinations.Data ...
);
%% Add above the selected
combinationCell(selectedRow + 1:end + 1, :) = combinationCell(selectedRow:end, :);
combinationCell(selectedRow, :) = combinationCell(selectedRow + 1, :);
artoaWorkspace.trackParameter.soundsourceCombinations = combinationCell;
combinationTable(selectedRow + 1:end + 1, :) = combinationTable(selectedRow:end, :);
combinationTable(selectedRow, :) = combinationTable(selectedRow + 1, :);
artoaWorkspace.trackParameter.soundsourceCombinations = combinationTable;
%% Update gui
artoa.controller.track.parameter.updateGui();
......
function [emptyCell] = getDefaultCombinationCell()
%GETDEFAULTCOMBINATIONVALUES Summary of this function goes here
% Detailed explanation goes here
global artoaWorkspace;
emptyCell = { ...
floor(min(artoaWorkspace.toaData.toaDate(artoaWorkspace.toaData.status ~= 2))), ...
floor(max(artoaWorkspace.toaData.toaDate(artoaWorkspace.toaData.status ~= 2))), ...
'', ...
'', ...
1464, ...
1464, ...
1464, ...
1464, ...
1464 ...
};
end
......@@ -24,7 +24,7 @@ callbacks.inputGapSize = @artoa.controller.track.parameter.inputGapSize;
callbacks.tableSoundSourceCombinationsSelection = @artoa.controller.track.parameter.tableSoundsourceCombinationsSelection;
callbacks.tableSoundSourceCombinationsEdit = @artoa.controller.track.parameter.tableSoundsourceCombinationsEdit;
callbacks.tableSoundSourceOffsetsEdit = @artoa.controller.track.parameter.tableSoundsourceOffsetsEdit;
callbacks.buttonTrack = '';
callbacks.buttonTrack = @artoa.controller.track.run;
callbacks.buttonQuickTrack = '';
callbacks.buttonAddCombination = @artoa.controller.track.parameter.addSoundsourceCombination;
callbacks.buttonAddCombinationAbove = @artoa.controller.track.parameter.addSoundsourceCombinationAbove;
......@@ -42,15 +42,46 @@ artoa.gui.track.parameter( ...
artoaWorkspace.defaults.soundspeedMethods ...
);
%% Get involved
soundsourceNames = fieldnames(artoaWorkspace.filteredSoundsources);
appliedSoundsources = {};
involvedSoundsources = struct();
for i = 1:length(soundsourceNames)
if artoa.soundsources.hasAppliedToa(soundsourceNames{i}, artoaWorkspace.toaData.soundSource)
extracted = artoa.data.extractSoundsourcesFromStruct( ...
soundsourceNames{i}, ...
artoaWorkspace.filteredSoundsources ...
);
involvedSoundsources.(soundsourceNames{i}) = extracted;
clear extracted;
end
end
%% Setup sound source offsets table
% initialize sound source offsets
artoaGui.trackParameter.tableSoundSourceOffsets.RowName = fieldnames( ...
involvedSoundsources ...
);
%% Create workspace variables
if ~isfield(artoaWorkspace, 'trackParameter')
artoaWorkspace.trackParameter = struct();
% initialize sound source offsets
artoaGui.trackParameter.tableSoundSourceOffsets.RowName = fieldnames( ...
artoaWorkspace.filteredSoundsources ...
% setup sound source combinations
artoaWorkspace.trackParameter.soundsourceCombinations = ...
artoa.soundsources.createCombinationsTable(...
artoa.controller.track.parameter.getDefaultCombinationCell() ...
);
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 ...
);
% initialize settings
availableCallbacks = { ...
'comboboxTrackingMethod', ...
......@@ -61,7 +92,9 @@ if ~isfield(artoaWorkspace, 'trackParameter')
'inputOutputInterpolationInterval', ...
'inputGapSize', ...
'tableSoundSourceOffsetsEdit', ...
'tableSoundSourceCombinationsEdit' ...
'tableSoundSourceCombinationsEdit', ...
'inputFloatOffsetBegin', ...
'inputFloatOffsetEnd' ...
};
for i = 1:length(availableCallbacks)
......
......@@ -6,13 +6,11 @@ function [] = removeSoundsourceCombination(~, ~)
global artoaWorkspace;
%% Get selected row
selectedRow = artoaWorkspace.trackParameter.selectedSoundsourceCombinationRow;
%% Delete from workspace
artoaWorkspace.trackParameter.soundsourceCombinations(selectedRow, :) = [];
%% Update gui
artoa.controller.track.parameter.updateGui();
......
......@@ -2,15 +2,20 @@ function [] = resetSoundsourceCombinations(~, ~)
%RESETSOUNDSOURCECOMBINATIONS Summary of this function goes here
% Detailed explanation goes here
global artoaWorkspace;
if strcmp(questdlg('Reset all combinations?', 'Confirmation', 'Yes', 'Cancel', 'Cancel'), 'Cancel')
return;
end
%% Delete from workspace
artoaWorkspace.trackParameter.soundsourceCombinations(:, :) = [];
artoaWorkspace.trackParameter.soundsourceCombinations = ...
artoa.soundsources.createCombinationsTable( ...
artoa.controller.track.parameter.getDefaultCombinationCell() ...
);
%% Update gui
artoa.controller.track.parameter.updateGui();
end
......@@ -2,10 +2,14 @@ function [] = tableSoundsourceCombinationsEdit(~, ~)
%TABLESOUNDSOURCECOMBINATIONSEDIT Summary of this function goes here
% Detailed explanation goes here
global artoaGui artoaWorkspace;
global artoaWorkspace artoaGui;
%% Save all details
artoaWorkspace.trackParameter.soundsourceCombinations = ...
artoa.soundsources.createCombinationsTable( ...
artoaGui.trackParameter.tableSoundSourceCombinations.Data ...
);
artoaWorkspace.trackParameter.soundsourceCombinations = artoaGui.trackParameter.tableSoundSourceCombinations.Data;
end
......@@ -3,11 +3,13 @@ function [] = tableSoundsourceOffsetsEdit(~, ~)
% Detailed explanation goes here
global artoaWorkspace artoaGui;
artoaWorkspace.trackParameter.soundsourceOffsets = artoaGui.trackParameter.tableSoundSourceOffsets.Data;
global artoaGui artoaWorkspace;
%% Save to workspace
artoaWorkspace.trackParameter.soundsourceOffsets = artoa.soundsources.createOffsetsStruct( ...
artoaGui.trackParameter.tableSoundSourceOffsets.RowName, ...
artoaGui.trackParameter.tableSoundSourceOffsets.Data ...
);
end
......@@ -4,10 +4,17 @@ function [] = updateGui()
global artoaGui artoaWorkspace;
if ~isfield(artoaWorkspace, 'trackParameter')
if ~isfield(artoaWorkspace, 'trackParameter') ...
|| ~isfield(artoaGui.figures, 'trackParameter') ...
|| ~isvalid(artoaGui.figures.trackParameter)
return;
end
% % update soundsources
% artoaGui.trackParameter.tableSoundSourceOffsets.RowName = fieldnames( ...
% artoaWorkspace.filteredSoundsources ...
% );
fields = artoaWorkspace.trackParameter;
fieldNames = fieldnames(fields);
......@@ -29,9 +36,13 @@ for i = 1:length(fieldNames)
case 'gapSize'
artoaGui.trackParameter.inputGapSize.String = currentValue;
case 'soundsourceOffsets'
artoaGui.trackParameter.tableSoundSourceOffsets.Data = currentValue;
artoaGui.trackParameter.tableSoundSourceOffsets.Data = ...
artoa.soundsources.createOffsetsCell( ...
currentValue, ...
artoaGui.trackParameter.tableSoundSourceOffsets.RowName ...
);
case 'soundsourceCombinations'
artoaGui.trackParameter.tableSoundSourceCombinations.Data = currentValue;
artoaGui.trackParameter.tableSoundSourceCombinations.Data = artoa.soundsources.createCombinationsCell(currentValue);
case 'floatOffsetBegin'
artoaGui.trackParameter.inputFloatOffsetBegin.String = currentValue;
case 'floatOffsetEnd'
......@@ -39,10 +50,5 @@ for i = 1:length(fieldNames)
end
end
% update soundsources
artoaGui.trackParameter.tableSoundSourceOffsets.RowName = fieldnames( ...
artoaWorkspace.filteredSoundsources ...
);
end
function [success, message] = validateCombinationsInput(pCombinationsTable)
%VALIDATECOMBINATIONSINPUT Summary of this function goes here
% Detailed explanation goes here
success = false;
message = 'Unknown error';
%% Validate all columns
if any(isnan(pCombinationsTable.combinationBegin))
message = 'The "Begin" column contains an invalid value!';
return;
end
if any(isnan(pCombinationsTable.combinationEnd))
message = 'The "End" column contains an invalid value!';
return;
end
if any(strcmp(pCombinationsTable.soundsources, ''))
message = 'The "Sound Sources" column contains an invalid value!';
return;
end
if any(strcmp(pCombinationsTable.referencePosition, ''))
message = 'The "Reference Position" column contains an invalid value!';
return;
end
if any(isnan(pCombinationsTable.soundspeed1)) ...
|| any(isnan(pCombinationsTable.soundspeed2)) ...
|| any(isnan(pCombinationsTable.soundspeed3)) ...
|| any(isnan(pCombinationsTable.soundspeed4)) ...
|| any(isnan(pCombinationsTable.soundspeed5))
message = 'One of the soundspeeds contains an invalid value!';
return;
end
success = true;
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