Skip to content

Commit

Permalink
Merge pull request #147 from AlbertoCuadra/develop
Browse files Browse the repository at this point in the history
Add: new functionalities
  • Loading branch information
AlbertoCuadra committed Feb 9, 2022
2 parents 2ae0362 + c76ff4c commit 5b75940
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Combustion_Toolbox.m
@@ -1,5 +1,5 @@
% -------------------------------------------------------------------------
% COMBUSTION TOOLBOX @v0.5.1
% COMBUSTION TOOLBOX @v0.5.2
% A MATLAB-GUI based open-source tool for solving gaseous combustion problems.
%
% Type of problems:
Expand Down
2 changes: 1 addition & 1 deletion GUI/Functions/gui_ReactantsValueChanged.m
Expand Up @@ -90,7 +90,7 @@ function gui_ReactantsValueChanged(obj, event)
app.PD.N_Fuel = [0.5, 0.5];
otherwise % SET NEW SPECIES
try
species = gui_seeker_species(obj, event);
species = gui_seeker_value(obj, event, app.S.LS_DB);
catch
message = {'Species not found.'};
uialert(obj.UIFigure, message, 'Warning', 'Icon', 'warning');
Expand Down
24 changes: 0 additions & 24 deletions GUI/Functions/gui_seeker_species.m

This file was deleted.

22 changes: 22 additions & 0 deletions GUI/Functions/gui_seeker_value.m
@@ -0,0 +1,22 @@
function value = gui_seeker_value(obj, event, ListValues)
% Return the value that match with the value introduced in the finder
try
seekValue = event.Value;
index = 0;
seekIndex = false;
while ~seekIndex
index = index + 1;
seekIndex = startsWith(ListValues{index}, seekValue, 'IgnoreCase', false);
end
if index
value = ListValues{index}; % Value found in ListValues
else
value = []; % Value not found in ListValues
end
catch ME
errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ...
ME.stack(1).name, ME.stack(1).line, ME.message);
fprintf('%s\n', errorMessage);
uiwait(warndlg(errorMessage));
end
end
39 changes: 39 additions & 0 deletions GUI/Functions/gui_value2list.m
@@ -0,0 +1,39 @@
function LS = gui_value2list(obj, value, LS, action)
% Add/remove (action) selected value to LS
if ~isempty(value)
switch lower(action)
case 'add'
LS = add_value(value, LS);
case 'remove'
LS = remove_value(value, LS);
end
end
end

% SUB-PASS FUNCTIONS
function LS = add_value(value, LS)
% Add value to LS

% Check if the value is already included in the list
n_pass = [];
for n = length(value):-1:1
if ~any(strcmp(LS, value{n}))
n_pass = [n_pass, n];
end
end
LS = [LS, value(n_pass)];
end

function LS = remove_value(value, LS)
% Remove value from LS

% Remove the species from the list
N = length(LS);
n_pass = true(1, N);
for n = N:-1:1
if any(strcmp(value, LS{n}))
n_pass(n) = false;
end
end
LS = LS(n_pass);
end
Binary file modified GUI/combustion_toolbox_app.mlapp
Binary file not shown.
Binary file modified Installer/Combustion Toolbox.mlappinstall
Binary file not shown.

0 comments on commit 5b75940

Please sign in to comment.