-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcallbackButtonDeleteSelection.m
39 lines (29 loc) · 1.21 KB
/
callbackButtonDeleteSelection.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function callbackButtonDeleteSelection(obj, evt, ...
ternHandles, specHandles, ECHandles)
%CALLBACKBUTTONDELETESELECTION executes the callback for the "Delete
%selection" button, used to delete a user-selected point on the ternary
%plot
set(ternHandles.buttonDelete, 'Callback', []);
figTern = ternHandles.fTernDiagram;
ternInfo = figTern.UserData;
pointInfo = ternInfo.pointInfo;
figure(figTern);
[xSelect, ySelect] = ginput(1);
indexPoint = findNearestPoint(xSelect, ySelect, ...
ternInfo.numSelected, pointInfo(:, 1), pointInfo(:, 2));
% find index of other point
if mod(indexPoint, 2) == 0
indexPartner = indexPoint - 1;
else
indexPartner = indexPoint + 1;
end
ternInfo.numSelected = ternInfo.numSelected - 2;
ternInfo.pointInfo = removerows(ternInfo.pointInfo, ...
[indexPoint, indexPartner]);
ternInfo.savedPoly = removerows(ternInfo.pointInfo, ...
[indexPoint, indexPartner]);
figTern.UserData = ternInfo;
plotTernData(ternHandles, specHandles, ECHandles);
set(ternHandles.buttonDelete, 'Callback', ...
{@callbackButtonDeleteSelection, ternHandles, specHandles, ECHandles});
end