Skip to content
Snippets Groups Projects
Commit 12f5c455 authored by leprob001's avatar leprob001
Browse files

Added ability to pick a rectangle based on minimum and maximum date values.

parent 4c188d0e
No related branches found
No related tags found
No related merge requests found
308 309
\ No newline at end of file \ No newline at end of file
function [result] = dropSelection() function [result] = dropSelection(pForce)
%DROPSELECTION Summary of this function goes here %DROPSELECTION Summary of this function goes here
% Detailed explanation goes here % Detailed explanation goes here
global artoaGui artoaWorkspace; global artoaGui artoaWorkspace;
if nargin == 0
pForce = false;
end
result = false; result = false;
if artoa.controller.edit.dataPointsSelected(artoaWorkspace.editTimeOfArrival) if artoa.controller.edit.dataPointsSelected(artoaWorkspace.editTimeOfArrival)
if strcmp(questdlg('Reset current selection?', 'Confirmation', 'Yes', 'Cancel', 'Cancel'), 'Cancel') if ~pForce || strcmp(questdlg('Reset current selection?', 'Confirmation', 'Yes', 'Cancel', 'Cancel'), 'Cancel')
return; return;
end end
% reset the line and all required fields % reset the line and all required fields
......
function [] = pickRectangleByDateRange(src, ~)
%PICKRECTANGLEBYDATERANGE Lets the user pick a rectangle by min and max message date.
global artoaGui artoaWorkspace;
%% Check for any active mode
if ~islogical(artoaGui.editTimeOfArrival.currentInteractionMode)
errordlg('Another interaction mode is currently active. Please finish it first!', 'Interaction mode error!');
return;
end
%% Check if polygon is already selected
if ~artoa.controller.edit.timeOfArrival.dropSelection()
return;
end
%% Initialize variable
artoaGui.editTimeOfArrival.userSelection = {};
artoaWorkspace.editTimeOfArrival.userSelection = false(length(artoaWorkspace.toaData.toa), 1);
%% Initialize polygon
artoaGui.editTimeOfArrival.tmpPolygon = struct();
artoaGui.editTimeOfArrival.tmpPolygon.x = [];
% initialize y for the resulting rectangle
artoaGui.editTimeOfArrival.tmpPolygon.y = [ ...
min(artoaWorkspace.toaData.toa); ...
max(artoaWorkspace.toaData.toa); ...
max(artoaWorkspace.toaData.toa); ...
min(artoaWorkspace.toaData.toa) ...
];
%% Create line that will show the result
artoaGui.editTimeOfArrival.userSelection = line( ...
NaN, NaN, 'Color', [0 0 0], 'LineStyle', '-' ...
);
%% Ask for min and max value
values = {'Minimum message date:', 'Maximum message date:'};
values = inputdlg(values);
values = str2double(values);
% validity check
if any(isnan(values))
% force drop selection
artoa.controller.edit.timeOfArrival.dropSelection(true);
warndlg('One or more input values could not be converted to double. Please try again', 'Input error!');
return;
end
artoaGui.editTimeOfArrival.tmpPolygon.x = [ ...
values(1); ...
values(1); ...
values(2); ...
values(2) ...
];
finishPolygon();
return
%% Helper functions
function finishPolygon()
% close the poligon by adding the first value as the last one
if length(artoaGui.editTimeOfArrival.tmpPolygon.x) > 3 % a polygon can only be closed if there are more than three values
x = [artoaGui.editTimeOfArrival.tmpPolygon.x; artoaGui.editTimeOfArrival.tmpPolygon.x(1)];
y = [artoaGui.editTimeOfArrival.tmpPolygon.y; artoaGui.editTimeOfArrival.tmpPolygon.y(1)];
else
[artoaGui.editTimeOfArrival, artoaWorkspace.editTimeOfArrival] = artoa.controller.edit.clearSelection(artoaGui.editTimeOfArrival, artoaWorkspace.editTimeOfArrival);
return;
end
% update the line
set(artoaGui.editTimeOfArrival.userSelection, 'XData', x, 'YData', y);
% store the selected points in the workspace for editing
artoaWorkspace.editTimeOfArrival.userSelection = inpolygon( ...
artoaWorkspace.toaData.toaDate, ...
artoaWorkspace.toaData.toa, ...
x, ...
y ...
);
end
end
...@@ -115,17 +115,27 @@ artoaGui.editTimeOfArrival.buttonPickPolygon = uicontrol( ... ...@@ -115,17 +115,27 @@ artoaGui.editTimeOfArrival.buttonPickPolygon = uicontrol( ...
'Style', 'PushButton', ... 'Style', 'PushButton', ...
'FontSize', 8, ... 'FontSize', 8, ...
'Units', 'normalized', ... 'Units', 'normalized', ...
'Position', [.156 .7 .69 .2], ... 'Position', [.156 .8 .69 .15], ...
'CallBack', @artoa.controller.edit.timeOfArrival.pickPolygon ... 'CallBack', @artoa.controller.edit.timeOfArrival.pickPolygon ...
); );
artoaGui.editTimeOfArrival.buttonPickRectangleByDateRange = uicontrol( ...
'Parent', artoaGui.editTimeOfArrival.frameControlsSelect, ...
'String', 'Rectangle by date range', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [.156 .6 .69 .15], ...
'CallBack', @artoa.controller.edit.timeOfArrival.pickRectangleByDateRange ...
);
artoaGui.editTimeOfArrival.buttonPickPoint = uicontrol( ... artoaGui.editTimeOfArrival.buttonPickPoint = uicontrol( ...
'Parent', artoaGui.editTimeOfArrival.frameControlsSelect, ... 'Parent', artoaGui.editTimeOfArrival.frameControlsSelect, ...
'String', 'Point(s)', ... 'String', 'Point(s)', ...
'Style', 'PushButton', ... 'Style', 'PushButton', ...
'FontSize', 8, ... 'FontSize', 8, ...
'Units', 'normalized', ... 'Units', 'normalized', ...
'Position', [.156 .4 .69 .2], ... 'Position', [.156 .4 .69 .15], ...
'CallBack', @artoa.controller.edit.timeOfArrival.pickPoint ... 'CallBack', @artoa.controller.edit.timeOfArrival.pickPoint ...
); );
...@@ -135,7 +145,7 @@ artoaGui.editTimeOfArrival.buttonDropSelection = uicontrol( ... ...@@ -135,7 +145,7 @@ artoaGui.editTimeOfArrival.buttonDropSelection = uicontrol( ...
'Style', 'PushButton', ... 'Style', 'PushButton', ...
'FontSize', 8, ... 'FontSize', 8, ...
'Units', 'normalized', ... 'Units', 'normalized', ...
'Position', [.156 .1 .69 .2], ... 'Position', [.156 .1 .69 .15], ...
'CallBack', 'artoa.controller.edit.timeOfArrival.dropSelection();' ... 'CallBack', 'artoa.controller.edit.timeOfArrival.dropSelection();' ...
); );
......
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