From ffcaaf9b820f07828297d3e2f89934bade4d4b68 Mon Sep 17 00:00:00 2001 From: Lewin Probst <info@emirror.de> Date: Fri, 13 Sep 2019 12:56:56 +0200 Subject: [PATCH] The TOA plot and the sound source panel on the left is now updated on reloading artoa.ini. --- .../createSoundsourceColorsPanel.m | 64 +++++++++++++++++++ .../+controller/+edit/+timeOfArrival/plot.m | 2 + .../plotSoundsourceToaFromGps.m | 1 + lib/+artoa/+controller/+file/loadArtoaIni.m | 2 + lib/+artoa/+gui/+edit/timeOfArrival.m | 39 +---------- 5 files changed, 70 insertions(+), 38 deletions(-) create mode 100644 lib/+artoa/+controller/+edit/+timeOfArrival/createSoundsourceColorsPanel.m diff --git a/lib/+artoa/+controller/+edit/+timeOfArrival/createSoundsourceColorsPanel.m b/lib/+artoa/+controller/+edit/+timeOfArrival/createSoundsourceColorsPanel.m new file mode 100644 index 0000000..a8b97a9 --- /dev/null +++ b/lib/+artoa/+controller/+edit/+timeOfArrival/createSoundsourceColorsPanel.m @@ -0,0 +1,64 @@ +function [] = createSoundsourceColorsPanel() +%CREATESOUNDSOURCECOLORSPANEL Summary of this function goes here +% Detailed explanation goes here + + +global artoaGui artoaWorkspace; + +width = .14; + +artoaGui.editTimeOfArrival.frameControlsSoundSourceColors = uipanel( ... + 'Parent', artoaGui.figures.editTimeOfArrival, ... + 'Title', 'Soundsource colors', ... + 'Units', 'normalized', ... + 'BackgroundColor', 'white', ... + 'Position', [.01 .3 width .6] ... +); + +% add label and color for every sound source that is available +spaceTopAndBottom = .05; +leftItemOffset = 0; +rightItemOffset = 0; + +artoaGui.editTimeOfArrival.labelSoundsourcesColors = struct(); +soundsources = artoaWorkspace.filteredSoundsources; +fnames = fieldnames(soundsources); + +isLeftItem = true; + +for i = 1:length(fnames) + if isLeftItem + offset = leftItemOffset; + marginLeft = 0; + leftItemOffset = leftItemOffset + 0.04; + isLeftItem = false; + else + offset = rightItemOffset; + marginLeft = .5; + rightItemOffset = rightItemOffset + 0.04; + isLeftItem = true; + end + artoaGui.editTimeOfArrival.labelSoundsourcesColors.(fnames{i}) = uicontrol( ... + 'Parent', artoaGui.editTimeOfArrival.frameControlsSoundSourceColors, ... + 'String', '', ... + 'Style', 'text', ... + 'FontSize', 8, ... + 'Units', 'normalized', ... + 'Position', [(marginLeft + .1) (1 - spaceTopAndBottom - offset) .1 .03], ... + 'Background', artoaWorkspace.soundsourceColors(i, :) ... + ); + artoaGui.editTimeOfArrival.labelSoundsourcesColors.([fnames{i} 'c']) = uicontrol( ... + 'Parent', artoaGui.editTimeOfArrival.frameControlsSoundSourceColors, ... + 'String', fnames{i}, ... + 'Style', 'text', ... + 'FontSize', 8, ... + 'Units', 'normalized', ... + 'Position', [(marginLeft + .25) (1 - spaceTopAndBottom - offset) .3 .03], ... + 'Background', [1 1 1], ... + 'HorizontalAlignment', 'left' ... + ); + +end + +end + diff --git a/lib/+artoa/+controller/+edit/+timeOfArrival/plot.m b/lib/+artoa/+controller/+edit/+timeOfArrival/plot.m index 4189a89..a156082 100644 --- a/lib/+artoa/+controller/+edit/+timeOfArrival/plot.m +++ b/lib/+artoa/+controller/+edit/+timeOfArrival/plot.m @@ -34,7 +34,9 @@ if isfield(artoaGui.editTimeOfArrival, 'scatterTimeOfArrival') ... artoaGui.editTimeOfArrival.scatterTimeOfArrival.CData = c; % update applied sound sources artoa.controller.edit.timeOfArrival.plotAppliedSoundsources(); + artoa.controller.edit.timeOfArrival.plotSoundsourceToaFromGps(artoaWorkspace.filteredSoundsources); artoa.controller.edit.timeOfArrival.applyToaAxesToGpsAndSoundsources(); + artoa.controller.edit.timeOfArrival.createSoundsourceColorsPanel(); return end diff --git a/lib/+artoa/+controller/+edit/+timeOfArrival/plotSoundsourceToaFromGps.m b/lib/+artoa/+controller/+edit/+timeOfArrival/plotSoundsourceToaFromGps.m index cd7bd41..394c481 100644 --- a/lib/+artoa/+controller/+edit/+timeOfArrival/plotSoundsourceToaFromGps.m +++ b/lib/+artoa/+controller/+edit/+timeOfArrival/plotSoundsourceToaFromGps.m @@ -16,6 +16,7 @@ hold(artoaGui.editTimeOfArrival.axesToaFromGps, 'on'); yMax = max(artoaGui.editTimeOfArrival.axesScatterTimeOfArrival.YLim); yMin = min(artoaGui.editTimeOfArrival.axesScatterTimeOfArrival.YLim); +%% Create plot fnames = fieldnames(pSoundsources); for o = 1:length(fnames) diff --git a/lib/+artoa/+controller/+file/loadArtoaIni.m b/lib/+artoa/+controller/+file/loadArtoaIni.m index 143d140..d027419 100644 --- a/lib/+artoa/+controller/+file/loadArtoaIni.m +++ b/lib/+artoa/+controller/+file/loadArtoaIni.m @@ -15,6 +15,8 @@ if isempty(artoaDataInput.ini) error([mfilename ': artoa.ini has been found but is empty. Please use a valid artoa.ini!']); end +artoa.controller.edit.timeOfArrival.plot(); + end diff --git a/lib/+artoa/+gui/+edit/timeOfArrival.m b/lib/+artoa/+gui/+edit/timeOfArrival.m index 3272d4b..1bdffd1 100644 --- a/lib/+artoa/+gui/+edit/timeOfArrival.m +++ b/lib/+artoa/+gui/+edit/timeOfArrival.m @@ -151,44 +151,7 @@ artoaGui.editTimeOfArrival.buttonWithdrawAllVisible = uicontrol( ... %% Sound source color legend frame -artoaGui.editTimeOfArrival.frameControlsSoundSourceColors = uipanel( ... - 'Title', 'Soundsource colors', ... - 'Units', 'normalized', ... - 'BackgroundColor', 'white', ... - 'Position', [.01 .2 width .7] ... -); - -% add label and color for every sound source that is available -usedHeight = .8; -spaceTopAndBottom = .05; -offset = 0; - -artoaGui.editTimeOfArrival.labelSoundsourcesColors = struct(); -soundsources = artoaWorkspace.filteredSoundsources; -fnames = fieldnames(soundsources); - -for i = 1:length(fnames) - artoaGui.editTimeOfArrival.labelSoundsourcesColors.(fnames{i}) = uicontrol( ... - 'Parent', artoaGui.editTimeOfArrival.frameControlsSoundSourceColors, ... - 'String', '', ... - 'Style', 'text', ... - 'FontSize', 8, ... - 'Units', 'normalized', ... - 'Position', [.1 (1 - spaceTopAndBottom - offset) .1 .03], ... - 'Background', artoaWorkspace.soundsourceColors(i, :) ... - ); - artoaGui.editTimeOfArrival.labelSoundsourcesColors.([fnames{i} 'c']) = uicontrol( ... - 'Parent', artoaGui.editTimeOfArrival.frameControlsSoundSourceColors, ... - 'String', fnames{i}, ... - 'Style', 'text', ... - 'FontSize', 8, ... - 'Units', 'normalized', ... - 'Position', [.25 (1 - spaceTopAndBottom - offset) .5 .03], ... - 'Background', [1 1 1], ... - 'HorizontalAlignment', 'left' ... - ); - offset = offset + 0.04; -end +artoa.controller.edit.timeOfArrival.createSoundsourceColorsPanel(); %% Colormap slider -- GitLab