diff --git a/lib/+artoa/+controller/+edit/+timeOfArrival/pickPoint.m b/lib/+artoa/+controller/+edit/+timeOfArrival/pickPoint.m index d5a559647d8e9ec5c691a27c52a6c4900b1f741e..932ebea90b87e3287d635baf4d5fe7e85d2a7a70 100644 --- a/lib/+artoa/+controller/+edit/+timeOfArrival/pickPoint.m +++ b/lib/+artoa/+controller/+edit/+timeOfArrival/pickPoint.m @@ -8,25 +8,35 @@ global artoaGui artoaWorkspace; artoa.controller.edit.timeOfArrival.dropSelection(); +%% Initialize variable +artoaGui.editTimeOfArrival.userSelection = {}; +artoaWorkspace.editTimeOfArrival.userSelection = []; + %% Select point by mouse [dx, dy, button] = ginput(1); -% find closest match -% calculate distance -distance = sqrt((artoaWorkspace.toaData.toaDate - dx).^2 + (artoaWorkspace.toaData.toa - dy).^2); -[~, index] = min(distance); -x_closest = artoaWorkspace.toaData.toaDate(index); -y_closest = artoaWorkspace.toaData.toa(index); - -if button ~= 1 - return; +while button == 1 + [x_closest, y_closest, index] = findClosestMatch(dx, dy); + + hold on; + artoaGui.editTimeOfArrival.userSelection{end + 1} = scatter(x_closest, y_closest, artoaWorkspace.defaults.pickPointMarkerSize, [0 0 0]); + hold off; + artoaWorkspace.editTimeOfArrival.userSelection = [ ... + artoaWorkspace.editTimeOfArrival.userSelection, ... + index + ]; + [dx, dy, button] = ginput(1); end -hold on; -artoaGui.editTimeOfArrival.userSelection = scatter(x_closest, y_closest, artoaWorkspace.defaults.pickPointMarkerSize, [0 0 0]); -hold off; -artoaWorkspace.editTimeOfArrival.userSelection = index; + function [x_closest, y_closest, index] = findClosestMatch(dx, dy) + % find closest match + % calculate distance + distance = sqrt((artoaWorkspace.toaData.toaDate - dx).^2 + (artoaWorkspace.toaData.toa - dy).^2); + [~, index] = min(distance); + x_closest = artoaWorkspace.toaData.toaDate(index); + y_closest = artoaWorkspace.toaData.toa(index); + end end diff --git a/lib/+artoa/+controller/+edit/clearSelection.m b/lib/+artoa/+controller/+edit/clearSelection.m index 4b8e802b376055f31bd965793de132fa2baa7d66..24cce4bdeb6c717304b52989f5586bf04f530e4e 100644 --- a/lib/+artoa/+controller/+edit/clearSelection.m +++ b/lib/+artoa/+controller/+edit/clearSelection.m @@ -7,7 +7,11 @@ workspaceStruct = pWorkspaceStruct; %% Remove selection from gui if isfield(guiHandle, 'userSelection') - delete(guiHandle.userSelection); + if iscell(guiHandle.userSelection) + cellfun(@delete, guiHandle.userSelection); + else + delete(guiHandle.userSelection); + end guiHandle = rmfield(guiHandle, 'userSelection'); end