Skip to content
Snippets Groups Projects
initializeArtoa4.m 1.91 KiB
function [] = initializeArtoa4(pForce)
%INITIALIZEARTOA4 Initializes variables required for artoa4 and creates the main window if required.
%

global artoaDataInput artoaWorkspace artoaGui artoaConfig;

%% Parameter check
if ~exist('pForce', 'var')
    pForce = false;
end

%% When the gui exists, focus it
if isfield(artoaGui, 'figures') && isfield(artoaGui.figures, 'main') && ~pForce
    figure(artoaGui.figures.main.Number);
    return
end

%% Initalize required variables
artoaDataInput = struct();
artoaWorkspace = struct();
artoaWorkspace.hideDeletedDataPoints = false;

artoaWorkspace.artoaVersion = ['4' artoa.versioning.getVersionString(true)];

artoaWorkspace.plugins = struct();
artoaWorkspace.plugins.tracking = struct();

if ~pForce
    artoaGui = struct();
    artoaGui.figures = struct();
    artoaGui.main = struct();
    artoaGui.callbacks = struct();
end
artoaGui.trackParameter = struct();
artoaWorkspace.editOffsets = struct();
artoaWorkspace.editOffsets.useOffsets = false;

%% Read ini file if existent
artoa.controller.file.loadArtoaIni();

%% Configure artoa defaults
artoa.controller.addDefaults();

%% Read soundsource file if existent
try
    soundsourceFilepath = artoaConfig.files.soundsourcefile;
    if ~isfile(soundsourceFilepath)
        error([mfilename ': ' soundsourceFilepath ' is not a file. Please check your artoa.ini!']);
    end
    artoaDataInput.soundsources = artoa.load.soundsources(soundsourceFilepath);
catch ex
    error([mfilename ': Reading soundsource file failed with the following message: ' ex.message]);
end

%% Initialize all plugins
artoa.plugins.initialize();

%% Open main gui
artoa.controller.main.open();

%% Move main window to the center of the screen
if ~pForce
    movegui(artoaGui.figures.main, 'center');
end

%% Update the settings defined by ini
if artoa.data.getMember(artoaConfig, {'view', 'hidedeleteddatapoints'}, false)
    artoa.controller.switchHideDeletedPoints();
end
end