From 47b6feed3855fdd6056b53381038d96136b6f764 Mon Sep 17 00:00:00 2001
From: Lewin Probst <info@emirror.de>
Date: Mon, 5 Aug 2019 15:32:01 +0200
Subject: [PATCH] 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
---
 .../applyStatusToAllPointsExceptDeleted.m     |  24 ++++
 .../+pressure/applyStatusToSelectedPoints.m   |  35 +++++
 .../+controller/+edit/+pressure/close.m       |  18 +++
 lib/+artoa/+controller/+edit/+pressure/open.m |  22 ++++
 .../+controller/+edit/+pressure/pickPolygon.m |  57 +++++++++
 lib/+artoa/+controller/+edit/+pressure/plot.m |  72 +++++++++++
 .../applyStatusToAllPointsExceptDeleted.m     |  24 ++++
 .../applyStatusToSelectedPoints.m             |  35 +++++
 .../+controller/+edit/+temperature/close.m    |   3 +-
 .../+edit/+temperature/deleteSelectedPoints.m |  38 ------
 .../+controller/+edit/+temperature/open.m     |   5 +-
 .../+edit/+temperature/pickPolygon.m          |  37 ++----
 .../+controller/+edit/+temperature/plot.m     |  12 +-
 lib/+artoa/+controller/+file/loadInterim.m    |  19 +++
 lib/+artoa/+controller/+file/saveInterim.m    |  16 +++
 lib/+artoa/+controller/copyRfbToWorkspace.m   |   8 +-
 lib/+artoa/+controller/loadRfb.m              |   4 +-
 lib/+artoa/+controller/loadSoundSourceFile.m  |  30 +++++
 lib/+artoa/+controller/updateMenuButtons.m    |  16 +++
 lib/+artoa/+gui/+edit/pressure.m              | 121 ++++++++++++++++++
 lib/+artoa/+gui/+edit/temperature.m           |  50 +++++++-
 lib/+artoa/+gui/main.m                        |  21 ++-
 22 files changed, 588 insertions(+), 79 deletions(-)
 create mode 100644 lib/+artoa/+controller/+edit/+pressure/applyStatusToAllPointsExceptDeleted.m
 create mode 100644 lib/+artoa/+controller/+edit/+pressure/applyStatusToSelectedPoints.m
 create mode 100644 lib/+artoa/+controller/+edit/+pressure/close.m
 create mode 100644 lib/+artoa/+controller/+edit/+pressure/open.m
 create mode 100644 lib/+artoa/+controller/+edit/+pressure/pickPolygon.m
 create mode 100644 lib/+artoa/+controller/+edit/+pressure/plot.m
 create mode 100644 lib/+artoa/+controller/+edit/+temperature/applyStatusToAllPointsExceptDeleted.m
 create mode 100644 lib/+artoa/+controller/+edit/+temperature/applyStatusToSelectedPoints.m
 delete mode 100644 lib/+artoa/+controller/+edit/+temperature/deleteSelectedPoints.m
 create mode 100644 lib/+artoa/+controller/+file/loadInterim.m
 create mode 100644 lib/+artoa/+controller/+file/saveInterim.m
 create mode 100644 lib/+artoa/+controller/loadSoundSourceFile.m
 create mode 100644 lib/+artoa/+controller/updateMenuButtons.m
 create mode 100644 lib/+artoa/+gui/+edit/pressure.m

diff --git a/lib/+artoa/+controller/+edit/+pressure/applyStatusToAllPointsExceptDeleted.m b/lib/+artoa/+controller/+edit/+pressure/applyStatusToAllPointsExceptDeleted.m
new file mode 100644
index 0000000..e41a86a
--- /dev/null
+++ b/lib/+artoa/+controller/+edit/+pressure/applyStatusToAllPointsExceptDeleted.m
@@ -0,0 +1,24 @@
+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
+
diff --git a/lib/+artoa/+controller/+edit/+pressure/applyStatusToSelectedPoints.m b/lib/+artoa/+controller/+edit/+pressure/applyStatusToSelectedPoints.m
new file mode 100644
index 0000000..af9b814
--- /dev/null
+++ b/lib/+artoa/+controller/+edit/+pressure/applyStatusToSelectedPoints.m
@@ -0,0 +1,35 @@
+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
+
diff --git a/lib/+artoa/+controller/+edit/+pressure/close.m b/lib/+artoa/+controller/+edit/+pressure/close.m
new file mode 100644
index 0000000..1a1fbc3
--- /dev/null
+++ b/lib/+artoa/+controller/+edit/+pressure/close.m
@@ -0,0 +1,18 @@
+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
+
diff --git a/lib/+artoa/+controller/+edit/+pressure/open.m b/lib/+artoa/+controller/+edit/+pressure/open.m
new file mode 100644
index 0000000..1975833
--- /dev/null
+++ b/lib/+artoa/+controller/+edit/+pressure/open.m
@@ -0,0 +1,22 @@
+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
+
diff --git a/lib/+artoa/+controller/+edit/+pressure/pickPolygon.m b/lib/+artoa/+controller/+edit/+pressure/pickPolygon.m
new file mode 100644
index 0000000..ea3fcfa
--- /dev/null
+++ b/lib/+artoa/+controller/+edit/+pressure/pickPolygon.m
@@ -0,0 +1,57 @@
+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
+
diff --git a/lib/+artoa/+controller/+edit/+pressure/plot.m b/lib/+artoa/+controller/+edit/+pressure/plot.m
new file mode 100644
index 0000000..e95d092
--- /dev/null
+++ b/lib/+artoa/+controller/+edit/+pressure/plot.m
@@ -0,0 +1,72 @@
+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
+
diff --git a/lib/+artoa/+controller/+edit/+temperature/applyStatusToAllPointsExceptDeleted.m b/lib/+artoa/+controller/+edit/+temperature/applyStatusToAllPointsExceptDeleted.m
new file mode 100644
index 0000000..a79323a
--- /dev/null
+++ b/lib/+artoa/+controller/+edit/+temperature/applyStatusToAllPointsExceptDeleted.m
@@ -0,0 +1,24 @@
+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
+
diff --git a/lib/+artoa/+controller/+edit/+temperature/applyStatusToSelectedPoints.m b/lib/+artoa/+controller/+edit/+temperature/applyStatusToSelectedPoints.m
new file mode 100644
index 0000000..cf6ec69
--- /dev/null
+++ b/lib/+artoa/+controller/+edit/+temperature/applyStatusToSelectedPoints.m
@@ -0,0 +1,35 @@
+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
+
diff --git a/lib/+artoa/+controller/+edit/+temperature/close.m b/lib/+artoa/+controller/+edit/+temperature/close.m
index 43be1d5..4758a26 100644
--- a/lib/+artoa/+controller/+edit/+temperature/close.m
+++ b/lib/+artoa/+controller/+edit/+temperature/close.m
@@ -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
 
diff --git a/lib/+artoa/+controller/+edit/+temperature/deleteSelectedPoints.m b/lib/+artoa/+controller/+edit/+temperature/deleteSelectedPoints.m
deleted file mode 100644
index c7af608..0000000
--- a/lib/+artoa/+controller/+edit/+temperature/deleteSelectedPoints.m
+++ /dev/null
@@ -1,38 +0,0 @@
-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
-
diff --git a/lib/+artoa/+controller/+edit/+temperature/open.m b/lib/+artoa/+controller/+edit/+temperature/open.m
index 6a93b0f..d3fcf4b 100644
--- a/lib/+artoa/+controller/+edit/+temperature/open.m
+++ b/lib/+artoa/+controller/+edit/+temperature/open.m
@@ -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
 
diff --git a/lib/+artoa/+controller/+edit/+temperature/pickPolygon.m b/lib/+artoa/+controller/+edit/+temperature/pickPolygon.m
index 6c0de13..16ffa6b 100644
--- a/lib/+artoa/+controller/+edit/+temperature/pickPolygon.m
+++ b/lib/+artoa/+controller/+edit/+temperature/pickPolygon.m
@@ -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
 
diff --git a/lib/+artoa/+controller/+edit/+temperature/plot.m b/lib/+artoa/+controller/+edit/+temperature/plot.m
index e54385b..c978c4c 100644
--- a/lib/+artoa/+controller/+edit/+temperature/plot.m
+++ b/lib/+artoa/+controller/+edit/+temperature/plot.m
@@ -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
diff --git a/lib/+artoa/+controller/+file/loadInterim.m b/lib/+artoa/+controller/+file/loadInterim.m
new file mode 100644
index 0000000..4759005
--- /dev/null
+++ b/lib/+artoa/+controller/+file/loadInterim.m
@@ -0,0 +1,19 @@
+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
+
diff --git a/lib/+artoa/+controller/+file/saveInterim.m b/lib/+artoa/+controller/+file/saveInterim.m
new file mode 100644
index 0000000..361dcfb
--- /dev/null
+++ b/lib/+artoa/+controller/+file/saveInterim.m
@@ -0,0 +1,16 @@
+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
+
diff --git a/lib/+artoa/+controller/copyRfbToWorkspace.m b/lib/+artoa/+controller/copyRfbToWorkspace.m
index dcf13f6..a53b084 100644
--- a/lib/+artoa/+controller/copyRfbToWorkspace.m
+++ b/lib/+artoa/+controller/copyRfbToWorkspace.m
@@ -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( ...
diff --git a/lib/+artoa/+controller/loadRfb.m b/lib/+artoa/+controller/loadRfb.m
index 91736d6..4dd1f80 100644
--- a/lib/+artoa/+controller/loadRfb.m
+++ b/lib/+artoa/+controller/loadRfb.m
@@ -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
 
diff --git a/lib/+artoa/+controller/loadSoundSourceFile.m b/lib/+artoa/+controller/loadSoundSourceFile.m
new file mode 100644
index 0000000..f291317
--- /dev/null
+++ b/lib/+artoa/+controller/loadSoundSourceFile.m
@@ -0,0 +1,30 @@
+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
+
diff --git a/lib/+artoa/+controller/updateMenuButtons.m b/lib/+artoa/+controller/updateMenuButtons.m
new file mode 100644
index 0000000..f99c11c
--- /dev/null
+++ b/lib/+artoa/+controller/updateMenuButtons.m
@@ -0,0 +1,16 @@
+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
+
diff --git a/lib/+artoa/+gui/+edit/pressure.m b/lib/+artoa/+gui/+edit/pressure.m
new file mode 100644
index 0000000..3de7316
--- /dev/null
+++ b/lib/+artoa/+gui/+edit/pressure.m
@@ -0,0 +1,121 @@
+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
+
diff --git a/lib/+artoa/+gui/+edit/temperature.m b/lib/+artoa/+gui/+edit/temperature.m
index f443015..2ad1625 100644
--- a/lib/+artoa/+gui/+edit/temperature.m
+++ b/lib/+artoa/+gui/+edit/temperature.m
@@ -14,6 +14,7 @@ artoaGui.figures.editTemperature = figure( ...
     'Name', windowTitle, ...
     'NumberTitle', 'off' ...
 );
+addToolbarExplorationButtons(artoaGui.figures.editTemperature);
 
 artoaGui.editTemperature = struct();
 
@@ -61,13 +62,58 @@ artoaGui.editTemperature.buttonPick = uicontrol( ...
     'CallBack', 'artoa.controller.edit.temperature.pickPolygon();' ...
 );
 
+artoaGui.editTemperature.buttonApply = uicontrol( ...
+    'String', 'Apply', ...
+    'Style', 'PushButton', ...
+    'FontSize', 8, ...
+    'Units', 'normalized', ...
+    'Position', [(left+buttonMarginLeftRight) .75 (width-2*buttonMarginLeftRight) buttonHeight], ...
+    'CallBack', 'artoa.controller.edit.temperature.applyStatusToSelectedPoints(1);' ...
+);
+
 artoaGui.editTemperature.buttonDelete = uicontrol( ...
     'String', 'Delete', ...
     'Style', 'PushButton', ...
     'FontSize', 8, ...
     'Units', 'normalized', ...
-    'Position', [(left+buttonMarginLeftRight) .75 (width-2*buttonMarginLeftRight) buttonHeight], ...
-    'CallBack', 'artoa.controller.edit.temperature.deleteSelectedPoints();' ...
+    'Position', [(left+buttonMarginLeftRight) .7 (width-2*buttonMarginLeftRight) buttonHeight], ...
+    'CallBack', 'artoa.controller.edit.temperature.applyStatusToSelectedPoints(2);' ...
+);
+
+artoaGui.editTemperature.buttonReset = uicontrol( ...
+    'String', 'Reset', ...
+    'Style', 'PushButton', ...
+    'FontSize', 8, ...
+    'Units', 'normalized', ...
+    'Position', [(left+buttonMarginLeftRight) .65 (width-2*buttonMarginLeftRight) buttonHeight], ...
+    'CallBack', 'artoa.controller.edit.temperature.applyStatusToSelectedPoints(0);' ...
+);
+
+artoaGui.editTemperature.buttonApplyAll = uicontrol( ...
+    'String', 'Apply all', ...
+    'Style', 'PushButton', ...
+    'FontSize', 8, ...
+    'Units', 'normalized', ...
+    'Position', [(left+buttonMarginLeftRight) .5 (width-2*buttonMarginLeftRight) buttonHeight], ...
+    'CallBack', 'artoa.controller.edit.temperature.applyStatusToAllPointsExceptDeleted(1);' ...
+);
+
+artoaGui.editTemperature.buttonResetAll = uicontrol( ...
+    'String', 'Reset all', ...
+    'Style', 'PushButton', ...
+    'FontSize', 8, ...
+    'Units', 'normalized', ...
+    'Position', [(left+buttonMarginLeftRight) .45 (width-2*buttonMarginLeftRight) buttonHeight], ...
+    'CallBack', 'artoa.controller.edit.temperature.applyStatusToAllPointsExceptDeleted(0);' ...
+);
+
+artoaGui.editTemperature.buttonReplot = uicontrol( ...
+    'String', 'Replot', ...
+    'Style', 'PushButton', ...
+    'FontSize', 8, ...
+    'Units', 'normalized', ...
+    'Position', [(left+buttonMarginLeftRight) .2 (width-2*buttonMarginLeftRight) buttonHeight], ...
+    'CallBack', 'artoa.controller.edit.temperature.plot();' ...
 );
 
 
diff --git a/lib/+artoa/+gui/main.m b/lib/+artoa/+gui/main.m
index bd9ec49..d0041c1 100644
--- a/lib/+artoa/+gui/main.m
+++ b/lib/+artoa/+gui/main.m
@@ -32,8 +32,13 @@ uimenu( ...
 );
 uimenu( ...
     loadHandle, ...
-    'Label', 'Interim file', ...%'Callback', 'artoa.controller.loadInterim' ...
-    'Enable', 'off' ...
+    'Label', 'Interim file', ...
+    'Callback', 'artoa.controller.file.loadInterim();' ...
+);
+uimenu( ...
+    loadHandle, ...
+    'Label', 'SoSo file', ...
+    'Callback', 'artoa.controller.loadSoundSourceFile();' ...
 );
 
 % SAVE
@@ -45,6 +50,12 @@ uimenu( ...
     'Enable', 'off' ...
 );
 
+uimenu( ...
+    saveHandle, ...
+    'Label', 'Interim file', ...
+    'Callback', 'artoa.controller.file.saveInterim();' ...
+);
+
 % QUIT
 artoaGui.main.menus.fileQuit = uimenu( ...
     artoaGui.main.menus.file, ...
@@ -71,7 +82,11 @@ artoaGui.main.menus.editTemperature = uimenu( ...
 );
 
 % PRESSURE
-%pressureHandle = uimenu(file, 'Label', 'Pressure', 'Enable', 'off');
+artoaGui.main.menus.editPressure = uimenu( ...
+    artoaGui.main.menus.edit, ...
+    'Label', 'Pressure', ...
+    'Callback', 'artoa.controller.edit.pressure.open();' ...
+);
 
 %% Initialize view menu
 
-- 
GitLab