add row btn

This commit is contained in:
xinxiao
2026-03-22 10:35:25 +08:00
parent 44cfe7c1e3
commit b2d1787972
3 changed files with 606 additions and 262 deletions
+76
View File
@@ -173,6 +173,67 @@ classdef EDFMAppController < handle
obj.configurePlotControls(actionId);
end
function onTableSelectionChanged(obj, tableName, indices)
if ~isprop(obj.App, tableName)
return;
end
if isempty(indices)
obj.App.(tableName).UserData = [];
else
obj.App.(tableName).UserData = indices(1, 1);
end
end
function addTableRow(obj, tableName)
if ~isprop(obj.App, tableName)
return;
end
data = obj.App.(tableName).Data;
newRow = obj.getDefaultRowForTable(tableName);
if isempty(data)
data = newRow;
else
if isnumeric(data)
data = num2cell(data);
end
data(end + 1, :) = newRow;
end
obj.App.(tableName).Data = data;
obj.App.(tableName).UserData = size(data, 1);
end
function deleteSelectedTableRow(obj, tableName)
if ~isprop(obj.App, tableName)
return;
end
data = obj.App.(tableName).Data;
if isempty(data)
return;
end
selectedRow = [];
if isprop(obj.App.(tableName), 'UserData')
selectedRow = obj.App.(tableName).UserData;
end
if isempty(selectedRow) || ~isscalar(selectedRow) || selectedRow < 1
uialert(obj.App.UIFigure, ...
sprintf('Please select a row in %s first.', tableName), ...
'Delete Row');
return;
end
if selectedRow > size(data, 1)
return;
end
data(selectedRow, :) = [];
obj.App.(tableName).Data = data;
obj.App.(tableName).UserData = [];
end
function runCasePlot(obj, actionId)
if isempty(fieldnames(obj.Results))
uialert(obj.App.UIFigure, 'Run or import results before plotting.', 'Plot');
@@ -1053,6 +1114,21 @@ classdef EDFMAppController < handle
value = rawValue;
end
function row = getDefaultRowForTable(~, tableName)
switch tableName
case 'Well1Table'
row = {'', 1, '[1 1 1]', 0.178/2, 0, 1};
case 'Well2Table'
row = {'', 0, '[]', 0.178/2, 0, 4};
case 'FractureWellLocationTable'
row = {0, 0, 0};
case 'ScheduleTable'
row = {'w1', 'open', 'inj', 'const_pwf', 40, 40, '', '', '', ''};
otherwise
row = {''};
end
end
function value = parseTableCell(~, rawValue)
if isnumeric(rawValue) || islogical(rawValue)
value = rawValue;