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; ...@@ -8,25 +8,35 @@ global artoaGui artoaWorkspace;
artoa.controller.edit.timeOfArrival.dropSelection(); artoa.controller.edit.timeOfArrival.dropSelection();
%% Initialize variable
artoaGui.editTimeOfArrival.userSelection = {};
artoaWorkspace.editTimeOfArrival.userSelection = [];
%% Select point by mouse %% Select point by mouse
[dx, dy, button] = ginput(1); [dx, dy, button] = ginput(1);
% find closest match while button == 1
% calculate distance [x_closest, y_closest, index] = findClosestMatch(dx, dy);
distance = sqrt((artoaWorkspace.toaData.toaDate - dx).^2 + (artoaWorkspace.toaData.toa - dy).^2);
[~, index] = min(distance); hold on;
x_closest = artoaWorkspace.toaData.toaDate(index); artoaGui.editTimeOfArrival.userSelection{end + 1} = scatter(x_closest, y_closest, artoaWorkspace.defaults.pickPointMarkerSize, [0 0 0]);
y_closest = artoaWorkspace.toaData.toa(index); hold off;
artoaWorkspace.editTimeOfArrival.userSelection = [ ...
if button ~= 1 artoaWorkspace.editTimeOfArrival.userSelection, ...
return; index
];
[dx, dy, button] = ginput(1);
end end
hold on; function [x_closest, y_closest, index] = findClosestMatch(dx, dy)
artoaGui.editTimeOfArrival.userSelection = scatter(x_closest, y_closest, artoaWorkspace.defaults.pickPointMarkerSize, [0 0 0]); % find closest match
hold off; % calculate distance
artoaWorkspace.editTimeOfArrival.userSelection = index; 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 end
...@@ -7,7 +7,11 @@ workspaceStruct = pWorkspaceStruct; ...@@ -7,7 +7,11 @@ workspaceStruct = pWorkspaceStruct;
%% Remove selection from gui %% Remove selection from gui
if isfield(guiHandle, 'userSelection') if isfield(guiHandle, 'userSelection')
delete(guiHandle.userSelection); if iscell(guiHandle.userSelection)
cellfun(@delete, guiHandle.userSelection);
else
delete(guiHandle.userSelection);
end
guiHandle = rmfield(guiHandle, 'userSelection'); guiHandle = rmfield(guiHandle, 'userSelection');
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