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

Updated the edit windows to match the requirements of issue #11.

parent 646e0806
No related branches found
No related tags found
No related merge requests found
Showing
with 301 additions and 50 deletions
function [] = applyStatusToAllPoints(pStatus)
%APPLYSTATUSTOALLPOINTS Applies the given status to all points.
% Applies given status to all points.
%
% Parameters:
% pStatusCode (int) The status code that will be applied to the
% selected data.
global artoaWorkspace artoaGui;
%% Set status
artoaWorkspace.statusPressure(:) = pStatus;
%% Update gui
artoa.controller.edit.updateAvailablePlots();
artoa.controller.updateMenuButtons();
[artoaGui.editPressure, artoaWorkspace.editPressure] = ...
artoa.controller.edit.clearSelection(artoaGui.editPressure, artoaWorkspace.editPressure);
end
function [] = applyStatusToAllVisible(pStatusCode)
%APPLYSTATUSTOALLVISIBLE Applies the given status code to the visible points.
% Applies the given status to the workspace variable.
%
% Parameters:
% pStatusCode (int) The status code that will be applied to the
% selected data.
%
global artoaWorkspace artoaGui;
%% Get all visible points
x_boundary = artoaGui.figures.editPressure.CurrentAxes.XLim;
y_boundary = artoaGui.figures.editPressure.CurrentAxes.YLim;
selection = inpolygon( ...
artoaWorkspace.rafosDate, ...
artoaWorkspace.pressure, ...
[x_boundary(1) x_boundary(2) x_boundary(2) x_boundary(1) x_boundary(1)], ...
[y_boundary(1) y_boundary(1) y_boundary(2) y_boundary(2) y_boundary(1)] ...
);
%% Set status
artoaWorkspace.statusPressure(selection) = pStatusCode;
%% Update gui
artoa.controller.edit.updateAvailablePlots();
artoa.controller.updateMenuButtons();
end
......@@ -14,14 +14,14 @@ global artoaWorkspace artoaGui;
%% Check if selection exists
if ~isfield(artoaWorkspace.editPressure, 'selectedPoints') ...
|| isempty(artoaWorkspace.editPressure.selectedPoints)
if ~isfield(artoaWorkspace.editPressure, 'userSelection') ...
|| isempty(artoaWorkspace.editPressure.userSelection)
warndlg('You need to select data by using the "Pick" button first!', 'No data selected');
return;
end
%% Set status
artoaWorkspace.statusPressure(artoaWorkspace.editPressure.selectedPoints) = pStatusCode;
artoaWorkspace.statusPressure(artoaWorkspace.editPressure.userSelection) = pStatusCode;
%% Update gui
artoa.controller.edit.updateAvailablePlots();
......
function [] = dropSelection()
%DROPSELECTION Summary of this function goes here
% Detailed explanation goes here
global artoaGui artoaWorkspace;
if artoa.controller.edit.dataPointsSelected(artoaWorkspace.editPressure)
if strcmp(questdlg('Reset current selection?', 'Confirmation', 'Yes', 'Cancel', 'Cancel'), 'Cancel')
return;
end
% reset the line and all required fields
[artoaGui.editPressure, artoaWorkspace.editPressure] = artoa.controller.edit.clearSelection(artoaGui.editPressure, artoaWorkspace.editPressure);
end
end
function [] = pickPoint()
%PICKPOINT Lets the user pick a point in the plot.
% Selection can be aborted by using the right mouse button.
global artoaGui artoaWorkspace;
%% Check if polygon is already selected
artoa.controller.edit.pressure.dropSelection();
%% Select point by mouse
[dx, dy, button] = ginput(1);
% find closest match
% calculate distance
distance = sqrt((artoaWorkspace.rafosDate - dx).^2 + (artoaWorkspace.pressure - dy).^2);
[~, index] = min(distance);
x_closest = artoaWorkspace.rafosDate(index);
y_closest = artoaWorkspace.pressure(index);
if button ~= 1
return;
end
hold on;
artoaGui.editPressure.userSelection = scatter(x_closest, y_closest, 50, [1 1 1]);
hold off;
artoaWorkspace.editPressure.userSelection = index;
end
......@@ -8,22 +8,16 @@ function [] = pickPolygon()
global artoaGui artoaWorkspace;
%% Check if polygon is already selected
%% Check if selection is already selected
if artoa.controller.edit.dataPointsSelected(artoaWorkspace.editPressure)
if strcmp(questdlg('Reset current line and pick a new one?', 'Confirmation', 'Yes', 'Cancel', 'Cancel'), 'Cancel')
return;
end
% reset the line and all required fields
[artoaGui.editPressure, artoaWorkspace.editPressure] = artoa.controller.edit.clearSelection(artoaGui.editPressure, artoaWorkspace.editPressure);
end
artoa.controller.edit.pressure.dropSelection();
%% Select polygon by mouse
x = [];
y = [];
% draw the line that will be extended on every click
artoaGui.editPressure.selectedPolygon = line( ...
artoaGui.editPressure.userSelection = line( ...
NaN, NaN, 'Color', [1 1 1], 'LineStyle', '-' ...
);
......@@ -41,7 +35,7 @@ while button == 1
continue;
end
% update the line
set(artoaGui.editPressure.selectedPolygon, 'XData', x, 'YData', y);
set(artoaGui.editPressure.userSelection, 'XData', x, 'YData', y);
[dx, dy, button] = ginput(1);
end
......@@ -54,10 +48,10 @@ else
return;
end
% update the line
set(artoaGui.editPressure.selectedPolygon, 'XData', x, 'YData', y);
set(artoaGui.editPressure.userSelection, 'XData', x, 'YData', y);
% store the selected points in the workspace for editing
artoaWorkspace.editPressure.selectedPoints = inpolygon( ...
artoaWorkspace.editPressure.userSelection = inpolygon( ...
artoaWorkspace.rafosDate, ...
artoaWorkspace.pressure, ...
x, ...
......
function [] = applyStatusToAllPoints(pStatus)
%APPLYSTATUSTOALLPOINTS Applies the given status to all points.
% Applies given status to all points.
%
% Parameters:
% pStatusCode (int) The status code that will be applied to the
% selected data.
global artoaWorkspace artoaGui;
%% Set status
artoaWorkspace.statusTemperature(:) = pStatus;
%% Update gui
artoa.controller.edit.updateAvailablePlots();
artoa.controller.updateMenuButtons();
[artoaGui.editTemperature, artoaWorkspace.editTemperature] = ...
artoa.controller.edit.clearSelection(artoaGui.editTemperature, artoaWorkspace.editTemperature);
end
function [] = applyStatusToAllVisible(pStatusCode)
%APPLYSTATUSTOALLVISIBLE Applies the given status code to the visible points.
% Applies the given status to the workspace variable.
%
% Parameters:
% pStatusCode (int) The status code that will be applied to the
% selected data.
%
global artoaWorkspace artoaGui;
%% Get all visible points
x_boundary = artoaGui.figures.editTemperature.CurrentAxes.XLim;
y_boundary = artoaGui.figures.editTemperature.CurrentAxes.YLim;
selection = inpolygon( ...
artoaWorkspace.rafosDate, ...
artoaWorkspace.temperature, ...
[x_boundary(1) x_boundary(2) x_boundary(2) x_boundary(1) x_boundary(1)], ...
[y_boundary(1) y_boundary(1) y_boundary(2) y_boundary(2) y_boundary(1)] ...
);
%% Set status
artoaWorkspace.statusTemperature(selection) = pStatusCode;
%% Update gui
artoa.controller.edit.updateAvailablePlots();
artoa.controller.updateMenuButtons();
end
......@@ -14,14 +14,14 @@ global artoaWorkspace artoaGui;
%% Check if selection exists
if ~isfield(artoaWorkspace.editTemperature, 'selectedPoints') ...
|| isempty(artoaWorkspace.editTemperature.selectedPoints)
if ~isfield(artoaWorkspace.editTemperature, 'userSelection') ...
|| isempty(artoaWorkspace.editTemperature.userSelection)
warndlg('You need to select data by using the "Pick" button first!', 'No data selected');
return;
end
%% Set status
artoaWorkspace.statusTemperature(artoaWorkspace.editTemperature.selectedPoints) = pStatusCode;
artoaWorkspace.statusTemperature(artoaWorkspace.editTemperature.userSelection) = pStatusCode;
%% Update gui
artoa.controller.edit.updateAvailablePlots();
......
function [] = dropSelection()
%DROPSELECTION Summary of this function goes here
% Detailed explanation goes here
global artoaGui artoaWorkspace;
if artoa.controller.edit.dataPointsSelected(artoaWorkspace.editTemperature)
if strcmp(questdlg('Reset current selection?', 'Confirmation', 'Yes', 'Cancel', 'Cancel'), 'Cancel')
return;
end
% reset the line and all required fields
[artoaGui.editTemperature, artoaWorkspace.editTemperature] = artoa.controller.edit.clearSelection(artoaGui.editTemperature, artoaWorkspace.editTemperature);
end
end
function [] = pickPoint()
%PICKPOINT Lets the user pick a point in the plot.
% Selection can be aborted by using the right mouse button.
global artoaGui artoaWorkspace;
%% Check if polygon is already selected
artoa.controller.edit.temperature.dropSelection();
%% Select point by mouse
[dx, dy, button] = ginput(1);
% find closest match
% calculate distance
distance = sqrt((artoaWorkspace.rafosDate - dx).^2 + (artoaWorkspace.temperature - dy).^2);
[~, index] = min(distance);
x_closest = artoaWorkspace.rafosDate(index);
y_closest = artoaWorkspace.temperature(index);
if button ~= 1
return;
end
hold on;
artoaGui.editTemperature.userSelection = scatter(x_closest, y_closest, 50, [1 1 1]);
hold off;
artoaWorkspace.editTemperature.userSelection = index;
end
......@@ -23,7 +23,7 @@ x = [];
y = [];
% draw the line that will be extended on every click
artoaGui.editTemperature.selectedPolygon = line( ...
artoaGui.editTemperature.userSelection = line( ...
NaN, NaN, 'Color', [1 1 1], 'LineStyle', '-' ...
);
......@@ -41,7 +41,7 @@ while button == 1
continue;
end
% update the line
set(artoaGui.editTemperature.selectedPolygon, 'XData', x, 'YData', y);
set(artoaGui.editTemperature.userSelection, 'XData', x, 'YData', y);
[dx, dy, button] = ginput(1);
end
......@@ -54,10 +54,10 @@ else
return;
end
% update the line
set(artoaGui.editTemperature.selectedPolygon, 'XData', x, 'YData', y);
set(artoaGui.editTemperature.userSelection, 'XData', x, 'YData', y);
% store the selected points in the workspace for editing
artoaWorkspace.editTemperature.selectedPoints = inpolygon( ...
artoaWorkspace.editTemperature.userSelection = inpolygon( ...
artoaWorkspace.rafosDate, ...
artoaWorkspace.temperature, ...
x, ...
......
......@@ -34,7 +34,7 @@ end
% update sound source of selected points
artoaWorkspace.toaData.soundSource( ...
artoaWorkspace.editTimeOfArrival.selectedPoints ...
artoaWorkspace.editTimeOfArrival.userSelection ...
) = soundsources(index);
......
function [] = dropSelection()
%DROPSELECTION Summary of this function goes here
% Detailed explanation goes here
global artoaGui artoaWorkspace;
if artoa.controller.edit.dataPointsSelected(artoaWorkspace.editTimeOfArrival)
if strcmp(questdlg('Reset current selection?', 'Confirmation', 'Yes', 'Cancel', 'Cancel'), 'Cancel')
return;
end
% reset the line and all required fields
[artoaGui.editTimeOfArrival, artoaWorkspace.editTimeOfArrival] = artoa.controller.edit.clearSelection(artoaGui.editTimeOfArrival, artoaWorkspace.editTimeOfArrival);
end
end
function [] = pickPoint()
%PICKPOINT Lets the user pick a point in the plot.
% Selection can be aborted by using the right mouse button.
global artoaGui artoaWorkspace;
%% Check if polygon is already selected
artoa.controller.edit.timeOfArrival.dropSelection();
%% 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;
end
hold on;
artoaGui.editTimeOfArrival.userSelection = scatter(x_closest, y_closest, 50, [1 1 1]);
hold off;
artoaWorkspace.editTimeOfArrival.userSelection = index;
end
......@@ -10,20 +10,14 @@ global artoaGui artoaWorkspace;
%% Check if polygon is already selected
if artoa.controller.edit.dataPointsSelected(artoaWorkspace.editTimeOfArrival)
if strcmp(questdlg('Reset current line and pick a new one?', 'Confirmation', 'Yes', 'Cancel', 'Cancel'), 'Cancel')
return;
end
% reset the line and all required fields
[artoaGui.editTimeOfArrival, artoaWorkspace.editTimeOfArrival] = artoa.controller.edit.clearSelection(artoaGui.editTimeOfArrival, artoaWorkspace.editTimeOfArrival);
end
artoa.controller.edit.timeOfArrival.dropSelection();
%% Select polygon by mouse
x = [];
y = [];
% draw the line that will be extended on every click
artoaGui.editTimeOfArrival.selectedPolygon = line( ...
artoaGui.editTimeOfArrival.userSelection = line( ...
NaN, NaN, 'Color', [1 1 1], 'LineStyle', '-' ...
);
......@@ -41,7 +35,7 @@ while button == 1
continue;
end
% update the line
set(artoaGui.editTimeOfArrival.selectedPolygon, 'XData', x, 'YData', y);
set(artoaGui.editTimeOfArrival.userSelection, 'XData', x, 'YData', y);
[dx, dy, button] = ginput(1);
end
......@@ -54,10 +48,10 @@ else
return;
end
% update the line
set(artoaGui.editTimeOfArrival.selectedPolygon, 'XData', x, 'YData', y);
set(artoaGui.editTimeOfArrival.userSelection, 'XData', x, 'YData', y);
% store the selected points in the workspace for editing
artoaWorkspace.editTimeOfArrival.selectedPoints = inpolygon( ...
artoaWorkspace.editTimeOfArrival.userSelection = inpolygon( ...
artoaWorkspace.toaData.toaDate, ...
artoaWorkspace.toaData.toa, ...
x, ...
......
......@@ -91,7 +91,7 @@ set(titleHandle, 'Color', 'blue');
% set x and y label
xlabel(artoaGui.figures.editTimeOfArrival.CurrentAxes, 'Message Date', 'FontSize', 10);
ylabel(artoaGui.figures.editTimeOfArrival.CurrentAxes, 'Time of arrival', 'FontSize', 10);
ylabel(artoaGui.figures.editTimeOfArrival.CurrentAxes, 'Time of arrival rel. to window start time', 'FontSize', 10);
hold off;
......
function [] = resetShiftToa()
%SHIFTTOA Summary of this function goes here
% Detailed explanation goes here
global artoaGui artoaWorkspace artoaDataInput;
%% Ask for reset
if strcmp(questdlg('Reset shift?', 'Confirmation', 'Yes', 'Cancel', 'Cancel'), 'Cancel')
return;
end
artoaWorkspace.toaData.toa = artoaDataInput.toaData.toa;
[artoaGui.editTimeOfArrival, artoaWorkspace.editTimeOfArrival] = ...
artoa.controller.edit.clearSelection(artoaGui.editTimeOfArrival, artoaWorkspace.editTimeOfArrival);
artoa.controller.edit.updateAvailablePlots();
end
function [] = shiftToaSelection()
function [] = shiftToa()
%SHIFTTOA Summary of this function goes here
% Detailed explanation goes here
global artoaGui artoaWorkspace;
%% Select polygon
if ~artoa.controller.edit.dataPointsSelected(artoaWorkspace.editTimeOfArrival)
warndlg('You need to select data by using the "Pick" button first!', 'No data selected');
return;
end
%% Ask for shift value
answer = inputdlg({'Enter shift value:'}, 'Shift TOAs', [1 35], {'0'});
......
......@@ -5,15 +5,15 @@ function [guiHandle, workspaceStruct] = clearSelection(pGuiHandle, pWorkspaceStr
guiHandle = pGuiHandle;
workspaceStruct = pWorkspaceStruct;
%% Remove polygon from gui
if isfield(guiHandle, 'selectedPolygon')
delete(guiHandle.selectedPolygon);
guiHandle = rmfield(guiHandle, 'selectedPolygon');
%% Remove selection from gui
if isfield(guiHandle, 'userSelection')
delete(guiHandle.userSelection);
guiHandle = rmfield(guiHandle, 'userSelection');
end
%% Remove the polygon field from workspace
if (isfield(workspaceStruct, 'selectedPoints'))
workspaceStruct = rmfield(workspaceStruct, 'selectedPoints');
%% Remove the selection field from workspace
if (isfield(workspaceStruct, 'userSelection'))
workspaceStruct = rmfield(workspaceStruct, '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