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

Added editPressure figure, Extended controller functions, Added Interim file support.

New features:
  + It is now possible to load and save an Interim file.
  + There are now 5 options to edit the temperature and pressure status
    from the edit temperature and pressure windows.

Changes to the existing features:

+gui/+edit/temperature.m:
  + Added toolbar to be able to zoom and pan
  + Added buttons to apply, delete, reset, apply all and reset all data
    points that have been selected using the pick button.

+gui/main.m:
  + Added menu entries for loading sound source and interim files
  + Added menu entry for saving Interim files
  + Added menu entry to be able to open the editPressure window

+gui/+edit/pressure.m:
  + Added definition of the editPressure window

+controller/copyRfbToWorkspace.m:
  / Removed status variable from workspace, it has been replaced by
    statusTemperature and statusPressure
parent d2a38530
No related branches found
No related tags found
No related merge requests found
Showing
with 522 additions and 74 deletions
function [] = applyStatusToAllPointsExceptDeleted(pStatus)
%APPLYSTATUSTOALLPOINTSEXCEPTDELETED Selects all points that are not deleted.
% Applies status 1 to all points that are not deleted.
%
% Parameters:
% pStatusCode (int) The status code that will be applied to the
% selected data.
global artoaWorkspace;
%% Set selection
artoaWorkspace.editPressure.selectedPoints = (artoaWorkspace.statusPressure ~= 2);
%% Set status
artoaWorkspace.statusPressure(artoaWorkspace.editPressure.selectedPoints) = pStatus;
%% Update gui
artoa.controller.edit.pressure.plot();
%% Remove the selected points from workspace
artoaWorkspace.editPressure = rmfield(artoaWorkspace.editPressure, 'selectedPoints');
end
function [] = applyStatusToSelectedPoints(pStatusCode)
%APPLYSTATUSTOSELECTEDPOINTS Applies the given status code to the workspace variables.
% Applies the given status to the workspace variable.
% If pUpdateGui is set to false, the polygon variables are not being
% cleaned up.
%
% Parameters:
% pStatusCode (int) The status code that will be applied to the
% selected data.
%
global artoaWorkspace artoaGui;
%% Check if selection exists
if ~isfield(artoaWorkspace.editPressure, 'selectedPoints') ...
|| isempty(artoaWorkspace.editPressure.selectedPoints)
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;
%% Update gui
artoa.controller.edit.pressure.plot();
delete(artoaGui.editPressure.selectedPolygon);
artoaGui.editPressure = rmfield(artoaGui.editPressure, 'selectedPolygon');
%% Remove the polygon field from workspace
artoaWorkspace.editPressure = rmfield(artoaWorkspace.editPressure, 'selectedPoints');
end
function [ ] = close()
%CLOSEREQ Cleans up all variables that are used by the editPressure GUI.
% Changes to the data is not being modified.
global artoaGui artoaWorkspace;
%% Close the figure
delete(artoaGui.figures.editPressure);
%% Clean up variables
artoaGui = rmfield(artoaGui, 'editPressure');
artoaGui.figures = rmfield(artoaGui.figures, 'editPressure');
artoaWorkspace = rmfield(artoaWorkspace, 'editPressure');
end
function [] = open()
%OPENEDITTEMPERATURE Initializes the pressure editing gui.
% Detailed explanation goes here
global artoaGui artoaWorkspace;
%% Check if the gui is already opened
if isfield(artoaGui.figures, 'editPressure')
figure(artoaGui.figures.editPressure);
return
end
%% Open the gui
artoa.gui.edit.pressure();
%% Create workspace variables
artoaWorkspace.editPressure = struct();
end
function [] = pickPolygon()
%PICKPOLYGON Lets the user pick a polygon in the plot.
% During selection, a line is being plotted that shows the selected
% points by the user.
% The polygon can be stopped by using the right mouse button. If
% finished, the selected points are being calculated and stored in the
% artoaWorkspace variable.
global artoaGui artoaWorkspace;
%% Select polygon by mouse
x = [];
y = [];
% draw the line that will be extended on every click
artoaGui.editPressure.selectedPolygon = line( ...
NaN, NaN, 'Color', [1 1 1], 'LineStyle', '-' ...
);
[dx, dy, button] = ginput(1);
while button == 1
% get boundaries
bound = artoaGui.figures.editPressure.CurrentAxes.XLim;
dx = artoa.data.adjustToBoundaries(dx, bound(1), bound(2));
bound = artoaGui.figures.editPressure.CurrentAxes.YLim;
dy = artoa.data.adjustToBoundaries(dy, bound(1), bound(2));
% add values to array
x = [x; dx];
y = [y; dy];
if length(x) == 1
continue;
end
% update the line
set(artoaGui.editPressure.selectedPolygon, 'XData', x, 'YData', y);
[dx, dy, button] = ginput(1);
end
% close the poligon by adding the first value as the last one
if length(x) > 3 % a polygon can only be closed if there are more than two values
x = [x; x(1)];
y = [y; y(1)];
end
% update the line
set(artoaGui.editPressure.selectedPolygon, 'XData', x, 'YData', y);
% store the selected points in the workspace for editing
artoaWorkspace.editPressure.selectedPoints = inpolygon( ...
artoaWorkspace.rafosDate, ...
artoaWorkspace.pressure, ...
x, ...
y ...
);
end
function [] = plot()
%PLOT Plots or updates the temperature points.
% If the plot already exists and is valid, the points only get updated.
% Otherwise the plot will be initialized
%
global artoaGui artoaWorkspace;
hold on
%% Get all required values
% create color vector
c = repmat([1 1 0], length(artoaWorkspace.rafosDate), 1);
c(artoaWorkspace.statusPressure == 1, :) = ...
repmat([1 1 1], length(c(artoaWorkspace.statusPressure == 1, 1)), 1);
c(artoaWorkspace.statusPressure == 2, :) = ...
repmat([1 0 0], length(c(artoaWorkspace.statusPressure == 2, 1)), 1);
if artoaWorkspace.showAllDataPoints
x = artoaWorkspace.rafosDate;
y = artoaWorkspace.pressure;
else
x = artoaWorkspace.rafosDate(artoaWorkspace.statusPressure ~= 2);
y = artoaWorkspace.pressure(artoaWorkspace.statusPressure ~= 2);
c = c(artoaWorkspace.statusPressure ~= 2, :);
end
%% If the plot exists, just update the values
if isfield(artoaGui.editPressure, 'scatterPressure') ...
&& isvalid(artoaGui.editPressure.scatterPressure)
artoaGui.editPressure.scatterPressure.XData = x;
artoaGui.editPressure.scatterPressure.YData = y;
artoaGui.editPressure.scatterPressure.CData = c;
return
end
% get all points that are not deleted
artoaGui.editPressure.scatterPressure = scatter( ...
x, ...
y, ...
[], ...
c, ... %'.', 'MarkerSize', 10 ...
'filled' ...
);
grid on;
% set background color
set(gca, 'Color', [.3 .3 .3], 'XColor', 'blue', 'YColor', 'blue');
% set plot title
titleVal = [ ...
'Project: ' artoaWorkspace.float.projectname ...
' FloatId: ' num2str(artoaWorkspace.float.floatname) ...
' Cycle: ' num2str(artoaWorkspace.float.cycle(1)) ...
' - Pressure' ...
];
titleHandle = title(titleVal, 'FontSize', 10);
set(titleHandle, 'Color', 'blue');
% set x and y label
xlabel('Message Date', 'FontSize', 10);
ylabel('Pressure [dBar]', 'FontSize', 10);
hold off
end
function [] = applyStatusToAllPointsExceptDeleted(pStatus)
%APPLYSTATUSTOALLPOINTSEXCEPTDELETED Selects all points that are not deleted.
% Applies status 1 to all points that are not deleted.
%
% Parameters:
% pStatusCode (int) The status code that will be applied to the
% selected data.
global artoaWorkspace;
%% Set selection
artoaWorkspace.editTemperature.selectedPoints = (artoaWorkspace.statusTemperature ~= 2);
%% Set status
artoaWorkspace.statusTemperature(artoaWorkspace.editTemperature.selectedPoints) = pStatus;
%% Update gui
artoa.controller.edit.temperature.plot();
%% Remove the selected points from workspace
artoaWorkspace.editTemperature = rmfield(artoaWorkspace.editTemperature, 'selectedPoints');
end
function [] = applyStatusToSelectedPoints(pStatusCode)
%APPLYSTATUSTOSELECTEDPOINTS Applies the given status code to the workspace variables.
% Applies the given status to the workspace variable.
% If pUpdateGui is set to false, the polygon variables are not being
% cleaned up.
%
% Parameters:
% pStatusCode (int) The status code that will be applied to the
% selected data.
%
global artoaWorkspace artoaGui;
%% Check if selection exists
if ~isfield(artoaWorkspace.editTemperature, 'selectedPoints') ...
|| isempty(artoaWorkspace.editTemperature.selectedPoints)
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;
%% Update gui
artoa.controller.edit.temperature.plot();
delete(artoaGui.editTemperature.selectedPolygon);
artoaGui.editTemperature = rmfield(artoaGui.editTemperature, 'selectedPolygon');
%% Remove the polygon field from workspace
artoaWorkspace.editTemperature = rmfield(artoaWorkspace.editTemperature, 'selectedPoints');
end
......@@ -2,7 +2,7 @@ function [ ] = close()
%CLOSEREQ Cleans up all variables that are used by the editTemperature GUI.
% Changes to the data is not being modified.
global artoaGui;
global artoaGui artoaWorkspace;
%% Close the figure
......@@ -12,6 +12,7 @@ delete(artoaGui.figures.editTemperature);
artoaGui = rmfield(artoaGui, 'editTemperature');
artoaGui.figures = rmfield(artoaGui.figures, 'editTemperature');
artoaWorkspace = rmfield(artoaWorkspace, 'editTemperature');
end
function [] = deleteSelectedPoints()
%DELETESELECTEDPOINTS Summary of this function goes here
% Detailed explanation goes here
global artoaWorkspace;
%% Check if selection exists
if ~isfield(artoaWorkspace, 'selectedPolygon') || ~isvalid(artoaWorkspace.selectedPolygon)
return;
end
%% Get polygon data
selectedPolygonX = artoaWorkspace.selectedPolygon.XData;
selectedPolygonY = artoaWorkspace.selectedPolygon.YData;
if isempty(selectedPolygonX) || isempty(selectedPolygonY)
return;
end
%% Find indices of selected points in temperature array
selectedPoints = inpolygon( ...
artoaWorkspace.rafosDate, ...
artoaWorkspace.temperature, ...
selectedPolygonX, ...
selectedPolygonY ...
);
%% Mark data as deleted
artoaWorkspace.status(selectedPoints) = 2;
%% Update gui
artoa.controller.edit.temperature.plot();
end
......@@ -2,7 +2,7 @@ function [] = open()
%OPENEDITTEMPERATURE Initializes the temperature editing gui.
% Detailed explanation goes here
global artoaGui;
global artoaGui artoaWorkspace;
%% Check if the gui is already opened
......@@ -15,5 +15,8 @@ end
%% Open the gui
artoa.gui.edit.temperature();
%% Create workspace variables
artoaWorkspace.editTemperature = struct();
end
......@@ -2,29 +2,18 @@ function [] = pickPolygon()
%PICKPOLYGON Lets the user pick a polygon in the plot.
% During selection, a line is being plotted that shows the selected
% points by the user.
% The polygon can be stopped by using the right mouse button. If
% finished, the selected points are being calculated and stored in the
% artoaWorkspace variable.
global artoaGui artoaWorkspace;
%% Save current state of window button down
windowButtonDownFunction = get( ...
artoaGui.figures.editTemperature, ...
'WindowButtonDownFcn' ...
);
%% Disable current window button down
set( ...
artoaGui.figures.editTemperature, ...
'WindowButtonDownFcn', ...
'' ...
);
%% Select polygon by mouse
x = [];
y = [];
% draw the line that will be extended on every click
artoaWorkspace.selectedPolygon = line( ...
artoaGui.editTemperature.selectedPolygon = line( ...
NaN, NaN, 'Color', [1 1 1], 'LineStyle', '-' ...
);
......@@ -42,7 +31,7 @@ while button == 1
continue;
end
% update the line
set(artoaWorkspace.selectedPolygon, 'XData', x, 'YData', y);
set(artoaGui.editTemperature.selectedPolygon, 'XData', x, 'YData', y);
[dx, dy, button] = ginput(1);
end
......@@ -52,15 +41,17 @@ if length(x) > 3 % a polygon can only be closed if there are more than two value
y = [y; y(1)];
end
% update the line
set(artoaWorkspace.selectedPolygon, 'XData', x, 'YData', y);
set(artoaGui.editTemperature.selectedPolygon, 'XData', x, 'YData', y);
% store the selected points in the workspace for editing
artoaWorkspace.editTemperature.selectedPoints = inpolygon( ...
artoaWorkspace.rafosDate, ...
artoaWorkspace.temperature, ...
x, ...
y ...
);
%% Restore window button down
set( ...
artoaGui.figures.editTemperature, ...
'WindowButtonDownFcn', ...
windowButtonDownFunction ...
);
end
......@@ -11,16 +11,18 @@ hold on
%% Get all required values
% create color vector
c = repmat([1 1 0], length(artoaWorkspace.rafosDate), 1);
c(artoaWorkspace.status == 1, :) = repmat([1 1 1], length(c(artoaWorkspace.status == 1, 1)), 1);
c(artoaWorkspace.status == 2, :) = repmat([1 0 0], length(c(artoaWorkspace.status == 2, 1)), 1);
c(artoaWorkspace.statusTemperature == 1, :) = ...
repmat([1 1 1], length(c(artoaWorkspace.statusTemperature == 1, 1)), 1);
c(artoaWorkspace.statusTemperature == 2, :) = ...
repmat([1 0 0], length(c(artoaWorkspace.statusTemperature == 2, 1)), 1);
if artoaWorkspace.showAllDataPoints
x = artoaWorkspace.rafosDate;
y = artoaWorkspace.temperature;
else
x = artoaWorkspace.rafosDate(artoaWorkspace.status ~= 2);
y = artoaWorkspace.temperature(artoaWorkspace.status ~= 2);
c = c(artoaWorkspace.status ~= 2, :);
x = artoaWorkspace.rafosDate(artoaWorkspace.statusTemperature ~= 2);
y = artoaWorkspace.temperature(artoaWorkspace.statusTemperature ~= 2);
c = c(artoaWorkspace.statusTemperature ~= 2, :);
end
%% If the plot exists, just update the values
......
function [] = loadInterim()
%LOADINTERIM Loads the current state of ARTOA4 from the file specified by dialog.
%
%% Ask for filename
filename = uigetfile('*.itm');
if (filename == 0)
return
end
%% Load mat file
load(filename, '-mat');
%% Update menu buttons
artoa.controller.updateMenuButtons();
end
function [] = saveInterim()
%SAVEINTERIM Saves the current state of ARTOA4 to the file specified by dialog.
%
global artoaWorkspace artoaDataInput artoaDataOutput;
%% Ask for filename
filename = uiputfile('*.itm');
if (filename ~= 0)
save(filename, 'artoaWorkspace', 'artoaDataInput', 'artoaDataOutput');
end
end
......@@ -19,14 +19,16 @@ artoaWorkspace.temperature = artoaDataInput.rfb.DATA(:, artoaDataInput.rfb.VARIA
artoaWorkspace.pressure = artoaDataInput.rfb.DATA(:, artoaDataInput.rfb.VARIABLE_LIST.pressure);
% STATUS
artoaWorkspace.status = zeros(size(artoaDataInput.rfb.DATA, 1), 1);
artoaWorkspace.statusTemperature = zeros(size(artoaDataInput.rfb.DATA, 1), 1);
artoaWorkspace.statusPressure = zeros(size(artoaDataInput.rfb.DATA, 1), 1);
% EXCLUDE LINES CONTAINING 9999
temperatureToExclude = artoaDataInput.rfb.DATA(:, artoaDataInput.rfb.VARIABLE_LIST.temperature) == 9999;
pressureToExclude = artoaDataInput.rfb.DATA(:, artoaDataInput.rfb.VARIABLE_LIST.pressure) == 9999;
pointsToExclude = or(temperatureToExclude, pressureToExclude);
artoaWorkspace.status(pointsToExclude) = 2;
%pointsToExclude = or(temperatureToExclude, pressureToExclude);
artoaWorkspace.statusTemperature(temperatureToExclude) = 2;
artoaWorkspace.statusPressure(pressureToExclude) = 2;
% RAFOS DATE
artoaWorkspace.rafosDate = artoa.convert.dmy2rd( ...
......
......@@ -22,9 +22,7 @@ artoaDataInput.rfb = artoa.load.rfb(filepath);
artoa.controller.copyRfbToWorkspace();
%% Update menu buttons
if ~islogical(artoaDataInput.rfb)
artoaGui.main.menus.edit.Enable = 'on';
end
artoa.controller.updateMenuButtons();
end
function [] = loadSoundSourceFile()
%LOADSOUNDSOURCEFILE Creates a file selection dialog and reads the file into memory.
global artoaGui artoaDataInput;
%% Initialize variables
artoaDataInput.soundsources = false;
%% Create file dialog and filename
[file, path] = uigetfile('*.soso');
filepath = fullfile(path, file);
%% Check if file exists
if ~isfile(filepath)
error([mfilename ': Selected file ' filepath ' is not a file! Please try again!']);
end
%% Load file into memory
artoaDataInput.soundsources = artoa.load.soundsources(filepath);
%% Update workspace
%artoa.controller.copyRfbToWorkspace();
%% Update menu buttons
if ~islogical(artoaDataInput.soundsources)
artoaGui.main.menus.edit.Enable = 'on';
end
end
function [] = updateMenuButtons()
%ENABLEMENUBUTTONS Summary of this function goes here
% Detailed explanation goes here
global artoaGui artoaDataInput;
%% Update menu buttons
if isfield(artoaDataInput, 'rfb') && ~islogical(artoaDataInput.rfb)
artoaGui.main.menus.edit.Enable = 'on';
else
artoaGui.main.menus.edit.Enable = 'off';
end
end
function [] = pressure()
%TEMPERATURE Defines the ARTOA4 edit pressure window.
global artoaGui artoaWorkspace;
%% Initialize required variables
windowTitle = [ 'ARTOA4 - Float ' num2str(artoaWorkspace.float.floatname) ' - Pressure' ];
%% Initialize temperature gui
artoaGui.figures.editPressure = figure( ...
'Name', windowTitle, ...
'NumberTitle', 'off' ...
);
addToolbarExplorationButtons(artoaGui.figures.editPressure);
artoaGui.editPressure = struct();
set( ...
artoaGui.figures.editPressure, ...
'CloseRequestFcn', ...
'artoa.controller.edit.pressure.close();' ...
);
%% Generate Plot
artoa.controller.edit.pressure.plot();
set(gca, 'Position', [0.13 0.11 0.706 0.815]);
%% Generate Controls
left = .85;
width = .14;
buttonHeight = .05;
buttonMarginLeftRight = .005;
artoaGui.editPressure.frameControls = uicontrol( ...
'Style', 'Frame', ...
'Units', 'normalized', ...
'BackgroundColor', 'white', ...
'Position', [left .11 width .815] ...
);
artoaGui.editPressure.frameHeadline = uicontrol( ...
'Style', 'Text', ...
'Units', 'normalized', ...
'FontSize', 8, ...
'BackgroundColor', 'white', ...
'Position', [(left+buttonMarginLeftRight) .85 (width-2*buttonMarginLeftRight) buttonHeight], ...
'String', 'Data' ...
);
artoaGui.editPressure.buttonPick = uicontrol( ...
'String', 'Pick', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(left+buttonMarginLeftRight) .8 (width-2*buttonMarginLeftRight) buttonHeight], ...
'CallBack', 'artoa.controller.edit.pressure.pickPolygon();' ...
);
artoaGui.editPressure.buttonApply = uicontrol( ...
'String', 'Apply', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(left+buttonMarginLeftRight) .75 (width-2*buttonMarginLeftRight) buttonHeight], ...
'CallBack', 'artoa.controller.edit.pressure.applyStatusToSelectedPoints(1);' ...
);
artoaGui.editPressure.buttonDelete = uicontrol( ...
'String', 'Delete', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(left+buttonMarginLeftRight) .7 (width-2*buttonMarginLeftRight) buttonHeight], ...
'CallBack', 'artoa.controller.edit.pressure.applyStatusToSelectedPoints(2);' ...
);
artoaGui.editPressure.buttonReset = uicontrol( ...
'String', 'Reset', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(left+buttonMarginLeftRight) .65 (width-2*buttonMarginLeftRight) buttonHeight], ...
'CallBack', 'artoa.controller.edit.pressure.applyStatusToSelectedPoints(0);' ...
);
artoaGui.editPressure.buttonApplyAll = uicontrol( ...
'String', 'Apply all', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(left+buttonMarginLeftRight) .5 (width-2*buttonMarginLeftRight) buttonHeight], ...
'CallBack', 'artoa.controller.edit.pressure.applyStatusToAllPointsExceptDeleted(1);' ...
);
artoaGui.editPressure.buttonResetAll = uicontrol( ...
'String', 'Reset all', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(left+buttonMarginLeftRight) .45 (width-2*buttonMarginLeftRight) buttonHeight], ...
'CallBack', 'artoa.controller.edit.pressure.applyStatusToAllPointsExceptDeleted(0);' ...
);
artoaGui.editPressure.buttonReplot = uicontrol( ...
'String', 'Replot', ...
'Style', 'PushButton', ...
'FontSize', 8, ...
'Units', 'normalized', ...
'Position', [(left+buttonMarginLeftRight) .2 (width-2*buttonMarginLeftRight) buttonHeight], ...
'CallBack', 'artoa.controller.edit.pressure.plot();' ...
);
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