Skip to content
Snippets Groups Projects
Commit 049d9b15 authored by leprob001's avatar leprob001
Browse files

Added support for multiple point selection.

parent 0367fa0a
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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
......
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