让这个APP所有输出的字体变大,怎么修改?classdef OrigamiApp < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
GridLayout matlab.ui.container.GridLayout
LeftPanel matlab.ui.container.Panel
RightPanel matlab.ui.container.Panel
UIAxes matlab.ui.control.UIAxes
% Tab group for two origami types
TabGroup matlab.ui.container.TabGroup
StraightTab matlab.ui.container.Tab
CurvedTab matlab.ui.container.Tab
% Straight origami parameters
NverticesEditField matlab.ui.control.NumericEditField
NverticesLabel matlab.ui.control.Label
NfoldsStraightEditField matlab.ui.control.NumericEditField
NfoldsStraightLabel matlab.ui.control.Label
thEditField matlab.ui.control.EditField
thLabel matlab.ui.control.Label
pStraightEditField matlab.ui.control.NumericEditField
pStraightLabel matlab.ui.control.Label
linitialStraightEditField matlab.ui.control.EditField
linitialStraightLabel matlab.ui.control.Label
cscaleStraightEditField matlab.ui.control.NumericEditField
cscaleStraightLabel matlab.ui.control.Label
% Curved origami parameters
NfoldsCurvedEditField matlab.ui.control.NumericEditField
NfoldsCurvedLabel matlab.ui.control.Label
sEditField matlab.ui.control.NumericEditField
sLabel matlab.ui.control.Label
dsEditField matlab.ui.control.NumericEditField
dsLabel matlab.ui.control.Label
klEditField matlab.ui.control.NumericEditField
klLabel matlab.ui.control.Label
krEditField matlab.ui.control.NumericEditField
krLabel matlab.ui.control.Label
phlEditField matlab.ui.control.NumericEditField
phlLabel matlab.ui.control.Label
phrEditField matlab.ui.control.NumericEditField
phrLabel matlab.ui.control.Label
linitialCurvedEditField matlab.ui.control.EditField
linitialCurvedLabel matlab.ui.control.Label
cscaleCurvedEditField matlab.ui.control.NumericEditField
cscaleCurvedLabel matlab.ui.control.Label
pCurvedEditField matlab.ui.control.NumericEditField
pCurvedLabel matlab.ui.control.Label
% Buttons
RunButton matlab.ui.control.Button
SaveButton matlab.ui.control.Button
ClearButton matlab.ui.control.Button
StatusLabel matlab.ui.control.Label
end
properties (Access = private)
allPointsMatrix % Output data
currentFigure % Current figure handle
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: RunButton
function RunButtonPushed(app, event)
try
% Update status
app.StatusLabel.Text = '计算中...';
drawnow;
% Check which tab is selected
currentTab = app.TabGroup.SelectedTab;
if currentTab == app.StraightTab
% Straight origami parameters
N_vertices = app.NverticesEditField.Value;
N_folds = app.NfoldsStraightEditField.Value;
% Parse th (comma-separated values)
th_str = app.thEditField.Value;
th_cell = strsplit(th_str, ',');
th = str2double(th_cell);
if numel(th) < 4
error('扇形角需要4个值,用逗号分隔');
end
% Parse l_initial (comma-separated values)
l_str = app.linitialStraightEditField.Value;
l_cell = strsplit(l_str, ',');
l_initial = str2double(l_cell) * 0.1; % Apply scaling
if numel(l_initial) < 3
error('初始长度需要3个值,用逗号分隔');
end
p = app.pStraightEditField.Value;
c_scale = app.cscaleStraightEditField.Value;
% Validate inputs
if N_vertices < 2
error('顶点数必须大于等于2');
end
if N_folds < 1
error('折痕数必须大于等于1');
end
% Run straight origami calculation
app.allPointsMatrix = app.calculateStraightOrigami(...
N_vertices, N_folds, th, p, l_initial, c_scale);
else
% Curved origami parameters
N_folds = app.NfoldsCurvedEditField.Value;
s = app.sEditField.Value;
ds = app.dsEditField.Value;
kl = app.klEditField.Value;
kr = app.krEditField.Value;
phl = app.phlEditField.Value;
phr = app.phrEditField.Value;
p = app.pCurvedEditField.Value;
c_scale = app.cscaleCurvedEditField.Value;
% Parse l_initial (comma-separated values, middle will be replaced by ds)
l_str = app.linitialCurvedEditField.Value;
l_cell = strsplit(l_str, ',');
if numel(l_cell) < 2
error('初始长度需要2个值,用逗号分隔');
end
l1 = str2double(l_cell{1}) * 0.1;
l2 = str2double(l_cell{2}) * 0.1;
l_initial = [l1, ds*0.1, l2];
% Validate inputs
if N_folds < 1
error('折痕数必须大于等于1');
end
if s <= 0 || ds <= 0
error('弧长必须大于0');
end
if ds > s
error('离散弧长不能大于总弧长');
end
% Run curved origami calculation
app.allPointsMatrix = app.calculateCurvedOrigami(...
N_folds, s, ds, kl, kr, phl, phr, p, l_initial, c_scale);
end
% Update status
app.StatusLabel.Text = '计算完成!';
catch ME
app.StatusLabel.Text = ['错误: ' ME.message];
uialert(app.UIFigure, ME.message, '计算错误');
end
end
% Button pushed function: SaveButton
function SaveButtonPushed(app, event)
if isempty(app.allPointsMatrix)
uialert(app.UIFigure, '请先运行计算', '没有数据');
return;
end
% Open file dialog with multiple file type options
[filename, pathname, filterindex] = uiputfile(...
{'*.mat', 'MAT文件 (*.mat)'; ...
'*.txt', '文本文件 (*.txt)'; ...
'*.csv', 'CSV文件 (*.csv)'}, ...
'保存数据文件');
if filename ~= 0
try
fullpath = fullfile(pathname, filename);
% Save data based on selected file type
switch filterindex
case 1 % .mat file
allPointsMatrix = app.allPointsMatrix;
save(fullpath, 'allPointsMatrix');
app.StatusLabel.Text = ['数据已保存为MAT文件: ' filename];
case 2 % .txt file
% Save as text file with tab delimiter
writematrix(app.allPointsMatrix, fullpath, 'Delimiter', 'tab');
app.StatusLabel.Text = ['数据已保存为文本文件: ' filename];
case 3 % .csv file
% Save as CSV file
writematrix(app.allPointsMatrix, fullpath);
app.StatusLabel.Text = ['数据已保存为CSV文件: ' filename];
end
% Show completion message
uialert(app.UIFigure, ['数据已成功保存到: ' fullpath], '保存成功');
catch ME
app.StatusLabel.Text = ['保存失败: ' ME.message];
uialert(app.UIFigure, ME.message, '保存错误');
end
else
app.StatusLabel.Text = '取消保存操作';
end
end
% Button pushed function: ClearButton
function ClearButtonPushed(app, event)
% Create confirmation dialog
selection = uiconfirm(app.UIFigure, ...
'确定要清空所有数据和图形吗?', ...
'确认清空', ...
'Options', {'确定', '取消'}, ...
'DefaultOption', 2, ...
'CancelOption', 2);
if strcmp(selection, '确定')
try
% Clear the allPointsMatrix
app.allPointsMatrix = [];
% Clear the axes
cla(app.UIAxes);
% Reset axes properties
axis(app.UIAxes, 'on');
grid(app.UIAxes, 'on');
title(app.UIAxes, '');
xlabel(app.UIAxes, '');
ylabel(app.UIAxes, '');
zlabel(app.UIAxes, '');
% Update status
app.StatusLabel.Text = '数据和图形已清空';
% Optional: Clear MATLAB workspace variables
evalin('base', 'clear'); % Clear base workspace
% Show completion message
uialert(app.UIFigure, '数据和图形已成功清空!', '清空完成');
catch ME
app.StatusLabel.Text = ['清空失败: ' ME.message];
uialert(app.UIFigure, ME.message, '清空错误');
end
else
app.StatusLabel.Text = '取消清空操作';
end
end
% Straight origami calculation function
function allPointsMatrix = calculateStraightOrigami(app, N_vertices, N_folds, th, p, l_initial, c_scale)
% Generate sector angles for straight origami
theta_deg = zeros(N_vertices, 4);
theta_deg(:,1) = th(1) * ones(N_vertices,1);
theta_deg(:,2) = th(2) * ones(N_vertices,1);
theta_deg(:,3) = th(3) * ones(N_vertices,1);
theta_deg(:,4) = th(4) * ones(N_vertices,1);
% Convert to radians
theta_rad = deg2rad(theta_deg);
rho_central_rad = deg2rad(p);
% Geometry choice parameter
sigma_geom_choice = -1;
% Calculate initial fold
[P_center_0, P_left_0, P_right_0, actual_N_vertices] = calculate_3d_strip_geometry(...
theta_rad, rho_central_rad, l_initial, c_scale, sigma_geom_choice, N_vertices);
% Call the common visualization and matrix generation
allPointsMatrix = app.processAndVisualizeOrigami(P_center_0, P_left_0, P_right_0, ...
N_vertices, N_folds, p, l_initial, c_scale, theta_deg);
end
% Curved origami calculation function
function allPointsMatrix = calculateCurvedOrigami(app, N_folds, s, ds, kl, kr, phl, phr, p, l_initial, c_scale)
% Calculate number of vertices
N_vertices = round(s/ds) + 1;
% Generate sector angles for curved origami
theta_deg = zeros(N_vertices, 4);
% Convert angles to radians
phl_rad = deg2rad(phl);
phr_rad = deg2rad(phr);
% Calculate radii
rr = 1/abs(kr);
rl = 1/abs(kl);
% Calculate angle increments
dthr = 2 * atan(ds/(2*rr));
dthl = 2 * atan(ds/(2*rl));
% Generate theta values
theta_deg(:,1) = rad2deg(pi/2 + sign(kr)*(dthr/2) + phr_rad) * ones(N_vertices,1);
theta_deg(:,2) = rad2deg(pi/2 + sign(kr)*(dthr/2) - phr_rad) * ones(N_vertices,1);
theta_deg(:,3) = rad2deg(pi/2 - sign(kl)*(dthl/2) + phl_rad) * ones(N_vertices,1);
theta_deg(:,4) = rad2deg(pi/2 - sign(kl)*(dthl/2) - phl_rad) * ones(N_vertices,1);
% Convert to radians
theta_rad = deg2rad(theta_deg);
rho_central_rad = deg2rad(p);
% Geometry choice parameter
sigma_geom_choice = -1;
% Calculate initial fold
[P_center_0, P_left_0, P_right_0, actual_N_vertices] = calculate_3d_strip_geometry(...
theta_rad, rho_central_rad, l_initial, c_scale, sigma_geom_choice, N_vertices);
% Call the common visualization and matrix generation
allPointsMatrix = app.processAndVisualizeOrigami(P_center_0, P_left_0, P_right_0, ...
N_vertices, N_folds, p, l_initial, c_scale, theta_deg);
end
% Common processing and visualization function
function allPointsMatrix = processAndVisualizeOrigami(app, P_center_0, P_left_0, P_right_0, ...
N_vertices, N_folds, p, l_initial, c_scale, theta_deg)
% Multiple fold expansion
P_center_all = cell(N_folds, 1);
P_left_all = cell(N_folds, 1);
P_right_all = cell(N_folds, 1);
% First fold
P_center_all{1} = P_center_0;
P_left_all{1} = P_left_0;
P_right_all{1} = P_right_0;
% Extract angles for calculations
th1 = theta_deg(1,2);
% Generate multiple folds
for fold_idx = 2:N_folds
% Get previous fold as reference
PR_prev_center = P_right_all{fold_idx-1};
PR_prev_left = P_center_all{fold_idx-1};
% Calculate angle parameters for previous fold
PR_th2_ = zeros(1, length(PR_prev_center)-1);
% Calculate th10
a = PR_prev_center(:,1) - PR_prev_center(:,2);
b = PR_prev_left(:,2) - PR_prev_center(:,2);
dot_product = dot(a, b);
norm_a = norm(a);
norm_b = norm(b);
th10 = 180 - acosd(dot_product / (norm_a * norm_b));
for i_ = 1:length(PR_prev_center)-1
A = (PR_prev_center(:,i_+1) - PR_prev_center(:,i_));
B = (PR_prev_left(:,i_) - PR_prev_center(:,i_));
dot_product = dot(A, B);
norm_A = norm(A);
norm_B = norm(B);
cos_theta = dot_product / (norm_A * norm_B);
PR_th2_(i_) = acos(cos_theta);
end
PR_th2 = rad2deg(PR_th2_);
PR_th0 = 180 - PR_th2;
% Generate right boundary for new fold
A = (PR_prev_center(:,2) - PR_prev_center(:,1));
B = (PR_prev_left(:,1) - PR_prev_center(:,1));
PR_normal_Vector = cross(A, B);
if rem(fold_idx,2) == 1
sign_flag = -1;
PR_th1 = th1;
PR_th0(N_vertices) = theta_deg(N_vertices,1);
else
sign_flag = 1;
PR_th1 = th10;
PR_th0(N_vertices) = PR_th0(N_vertices-1);
end
% Rotate normal vector
PR_right_normal_Vector = (RotationofRandL(PR_prev_center(:,1), ...
PR_prev_center(:,1) + PR_normal_Vector, A, deg2rad(sign_flag * p))) - PR_prev_center(:,1)';
% Calculate rotated point
PR_right_ = RotationofRandL(PR_prev_center(:,1), PR_prev_center(:,2), ...
PR_right_normal_Vector/norm(PR_right_normal_Vector), -deg2rad(PR_th1));
% New fold right boundary points
PR_right = zeros(3, N_vertices);
PR_right(:,1) = PR_prev_center(:,1) + l_initial(3) * ...
(PR_right_' - PR_prev_center(:,1)) / norm((PR_right_' - PR_prev_center(:,1)));
% Iteratively calculate remaining points
for i = 2:N_vertices
A = (PR_right(:,i-1) - PR_prev_center(:,i-1));
B = (PR_prev_center(:,i) - PR_prev_center(:,i-1));
PR_normal_Vector = cross(A, B);
PR_right_normal_Vector = PR_normal_Vector / norm(PR_normal_Vector);
PR_right_1 = RotationofRandL(PR_prev_center(:,i), PR_prev_center(:,i-1), ...
PR_right_normal_Vector / norm(PR_right_normal_Vector), deg2rad(PR_th0(i)));
PR_right(:,i) = PR_prev_center(:,i) + l_initial(3) * c_scale^(i-1) * ...
(PR_right_1' - PR_prev_center(:,i)) / norm((PR_right_1' - PR_prev_center(:,i)));
end
% Store new fold data
P_center_all{fold_idx} = PR_prev_center;
P_left_all{fold_idx} = PR_prev_left;
P_right_all{fold_idx} = PR_right;
end
% Visualize in app axes
cla(app.UIAxes);
hold(app.UIAxes, 'on');
axis(app.UIAxes, 'equal');
% Color mapping
colors1 = hsv(N_folds);
colors2 = jet(N_folds);
for fold_idx = 1:N_folds
P_center_curr = P_center_all{fold_idx};
P_left_curr = P_left_all{fold_idx};
P_right_curr = P_right_all{fold_idx};
% Draw coordinate system for first fold
if fold_idx == 1
first_point = P_center_curr(:,1);
% X axis (yellow)
quiver3(app.UIAxes, first_point(1), first_point(2), first_point(3), 0.1, 0, 0, ...
'Color', 'y', 'LineWidth', 2, 'MaxHeadSize', 1.5, 'AutoScale', 'off');
% Y axis (green)
quiver3(app.UIAxes, first_point(1), first_point(2), first_point(3), 0, 0.1, 0, ...
'Color', 'g', 'LineWidth', 2, 'MaxHeadSize', 1.5, 'AutoScale', 'off');
% Z axis (blue)
quiver3(app.UIAxes, first_point(1), first_point(2), first_point(3), 0, 0, 0.1, ...
'Color', 'b', 'LineWidth', 2, 'MaxHeadSize', 1.5, 'AutoScale', 'off');
plot3(app.UIAxes, first_point(1), first_point(2), first_point(3), 'ko', ...
'MarkerSize', 5, 'MarkerFaceColor', 'y');
end
% Draw panels for each fold
for i = 1:N_vertices-1
% Left panel coordinates
x_l = [P_center_curr(1,i) P_center_curr(1,i+1) P_left_curr(1,i+1) P_left_curr(1,i) P_center_curr(1,i)];
y_l = [P_center_curr(2,i) P_center_curr(2,i+1) P_left_curr(2,i+1) P_left_curr(2,i) P_center_curr(2,i)];
z_l = [P_center_curr(3,i) P_center_curr(3,i+1) P_left_curr(3,i+1) P_left_curr(3,i) P_center_curr(3,i)];
% Right panel coordinates
x_r = [P_center_curr(1,i) P_center_curr(1,i+1) P_right_curr(1,i+1) P_right_curr(1,i) P_center_curr(1,i)];
y_r = [P_center_curr(2,i) P_center_curr(2,i+1) P_right_curr(2,i+1) P_right_curr(2,i) P_center_curr(2,i)];
z_r = [P_center_curr(3,i) P_center_curr(3,i+1) P_right_curr(3,i+1) P_right_curr(3,i) P_center_curr(3,i)];
% Fill panels
fill3(app.UIAxes, x_l, y_l, z_l, colors1(fold_idx,:), 'FaceAlpha', 0.7);
fill3(app.UIAxes, x_r, y_r, z_r, colors2(fold_idx,:), 'FaceAlpha', 0.7);
end
end
axis(app.UIAxes, 'off');
view(app.UIAxes, 3);
grid(app.UIAxes, 'on');
title(app.UIAxes, sprintf('折纸机构 (%d 条折痕)', N_folds));
hold(app.UIAxes, 'off');
% Generate allPointsMatrix
totalPoints = N_folds * N_vertices * 3;
allPointsMatrix = zeros(3, totalPoints);
currentIdx = 1;
for foldIdx = 1:N_folds
P_center = P_center_all{foldIdx};
P_left = P_left_all{foldIdx};
PR_right = P_right_all{foldIdx};
allPointsMatrix(:, currentIdx:currentIdx+N_vertices-1) = P_left;
currentIdx = currentIdx + N_vertices;
allPointsMatrix(:, currentIdx:currentIdx+N_vertices-1) = P_center;
currentIdx = currentIdx + N_vertices;
allPointsMatrix(:, currentIdx:currentIdx+N_vertices-1) = PR_right;
currentIdx = currentIdx + N_vertices;
end
allPointsMatrix = allPointsMatrix';
% Remove duplicate points for multiple folds
for i = 2:N_folds
if i == 2
for j = 1:2*N_vertices
allPointsMatrix((i-1)*3*N_vertices, :) = [];
end
else
for j = 1:2*N_vertices
allPointsMatrix((i+1)*N_vertices, :) = [];
end
end
end
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure('Visible', 'off');
app.UIFigure.Position = [100 100 1200 700];
app.UIFigure.Name = '折纸机构运动学建模 App';
% Create GridLayout
app.GridLayout = uigridlayout(app.UIFigure);
app.GridLayout.ColumnWidth = {'1x', '2x'};
app.GridLayout.RowHeight = {'1x'};
% Create LeftPanel
app.LeftPanel = uipanel(app.GridLayout);
app.LeftPanel.Layout.Row = 1;
app.LeftPanel.Layout.Column = 1;
app.LeftPanel.Title = '参数设置';
% Create RightPanel
app.RightPanel = uipanel(app.GridLayout);
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
app.RightPanel.Title = '3D 可视化';
% Create UIAxes
app.UIAxes = uiaxes(app.RightPanel);
app.UIAxes.Position = [10 50 780 600];
% Create TabGroup
app.TabGroup = uitabgroup(app.LeftPanel);
app.TabGroup.Position = [15 100 310 500];
% Create Straight Tab
app.StraightTab = uitab(app.TabGroup);
app.StraightTab.Title = '直纹折纸';
% Create Curved Tab
app.CurvedTab = uitab(app.TabGroup);
app.CurvedTab.Title = '曲纹折纸';
% Create straight origami controls
y_pos = 400;
label_width = 100;
field_width = 100;
% N_vertices for straight
app.NverticesLabel = uilabel(app.StraightTab);
app.NverticesLabel.Position = [20 y_pos label_width 22];
app.NverticesLabel.Text = '顶点数:';
app.NverticesEditField = uieditfield(app.StraightTab, 'numeric');
app.NverticesEditField.Position = [130 y_pos field_width 22];
app.NverticesEditField.Value = 8;
y_pos = y_pos - 40;
% N_folds for straight
app.NfoldsStraightLabel = uilabel(app.StraightTab);
app.NfoldsStraightLabel.Position = [20 y_pos label_width 22];
app.NfoldsStraightLabel.Text = '折痕数:';
app.NfoldsStraightEditField = uieditfield(app.StraightTab, 'numeric');
app.NfoldsStraightEditField.Position = [130 y_pos field_width 22];
app.NfoldsStraightEditField.Value = 3;
y_pos = y_pos - 40;
% th (扇形角) for straight
app.thLabel = uilabel(app.StraightTab);
app.thLabel.Position = [20 y_pos label_width 22];
app.thLabel.Text = '扇形角:';
app.thEditField = uieditfield(app.StraightTab, 'text');
app.thEditField.Position = [130 y_pos field_width 22];
app.thEditField.Value = '90,60,85,120';
app.thLabel.Tooltip = '输入4个角度值,用逗号分隔';
y_pos = y_pos - 40;
% p for straight
app.pStraightLabel = uilabel(app.StraightTab);
app.pStraightLabel.Position = [20 y_pos label_width 22];
app.pStraightLabel.Text = '折叠角:';
app.pStraightEditField = uieditfield(app.StraightTab, 'numeric');
app.pStraightEditField.Position = [130 y_pos field_width 22];
app.pStraightEditField.Value = 0;
y_pos = y_pos - 40;
% l_initial for straight
app.linitialStraightLabel = uilabel(app.StraightTab);
app.linitialStraightLabel.Position = [20 y_pos label_width 22];
app.linitialStraightLabel.Text = '初始长度:';
app.linitialStraightEditField = uieditfield(app.StraightTab, 'text');
app.linitialStraightEditField.Position = [130 y_pos field_width 22];
app.linitialStraightEditField.Value = '1,2,1';
app.linitialStraightLabel.Tooltip = '输入3个长度值,用逗号分隔';
y_pos = y_pos - 40;
% c_scale for straight
app.cscaleStraightLabel = uilabel(app.StraightTab);
app.cscaleStraightLabel.Position = [20 y_pos label_width 22];
app.cscaleStraightLabel.Text = '缩放因子:';
app.cscaleStraightEditField = uieditfield(app.StraightTab, 'numeric');
app.cscaleStraightEditField.Position = [130 y_pos field_width 22];
app.cscaleStraightEditField.Value = 1;
% Create curved origami controls
y_pos = 400;
% N_folds for curved
app.NfoldsCurvedLabel = uilabel(app.CurvedTab);
app.NfoldsCurvedLabel.Position = [20 y_pos label_width 22];
app.NfoldsCurvedLabel.Text = '折痕数:';
app.NfoldsCurvedEditField = uieditfield(app.CurvedTab, 'numeric');
app.NfoldsCurvedEditField.Position = [130 y_pos field_width 22];
app.NfoldsCurvedEditField.Value = 3;
y_pos = y_pos - 40;
% s for curved
app.sLabel = uilabel(app.CurvedTab);
app.sLabel.Position = [20 y_pos label_width 22];
app.sLabel.Text = '总弧长:';
app.sEditField = uieditfield(app.CurvedTab, 'numeric');
app.sEditField.Position = [130 y_pos field_width 22];
app.sEditField.Value = 15;
y_pos = y_pos - 40;
% ds for curved
app.dsLabel = uilabel(app.CurvedTab);
app.dsLabel.Position = [20 y_pos label_width 22];
app.dsLabel.Text = '离散弧长:';
app.dsEditField = uieditfield(app.CurvedTab, 'numeric');
app.dsEditField.Position = [130 y_pos field_width 22];
app.dsEditField.Value = 0.5;
y_pos = y_pos - 40;
% kl for curved
app.klLabel = uilabel(app.CurvedTab);
app.klLabel.Position = [20 y_pos label_width 22];
app.klLabel.Text = '左曲率:';
app.klEditField = uieditfield(app.CurvedTab, 'numeric');
app.klEditField.Position = [130 y_pos field_width 22];
app.klEditField.Value = 0.25;
y_pos = y_pos - 40;
% kr for curved
app.krLabel = uilabel(app.CurvedTab);
app.krLabel.Position = [20 y_pos label_width 22];
app.krLabel.Text = '右曲率:';
app.krEditField = uieditfield(app.CurvedTab, 'numeric');
app.krEditField.Position = [130 y_pos field_width 22];
app.krEditField.Value = -0.25;
y_pos = y_pos - 40;
% phl for curved
app.phlLabel = uilabel(app.CurvedTab);
app.phlLabel.Position = [20 y_pos label_width 22];
app.phlLabel.Text = '左折痕夹角:';
app.phlEditField = uieditfield(app.CurvedTab, 'numeric');
app.phlEditField.Position = [130 y_pos field_width 22];
app.phlEditField.Value = 10;
y_pos = y_pos - 40;
% phr for curved
app.phrLabel = uilabel(app.CurvedTab);
app.phrLabel.Position = [20 y_pos label_width 22];
app.phrLabel.Text = '右折痕夹角:';
app.phrEditField = uieditfield(app.CurvedTab, 'numeric');
app.phrEditField.Position = [130 y_pos field_width 22];
app.phrEditField.Value = 10;
y_pos = y_pos - 40;
% p for curved
app.pCurvedLabel = uilabel(app.CurvedTab);
app.pCurvedLabel.Position = [20 y_pos label_width 22];
app.pCurvedLabel.Text = '折叠角:';
app.pCurvedEditField = uieditfield(app.CurvedTab, 'numeric');
app.pCurvedEditField.Position = [130 y_pos field_width 22];
app.pCurvedEditField.Value = 90;
y_pos = y_pos - 40;
% l_initial for curved
app.linitialCurvedLabel = uilabel(app.CurvedTab);
app.linitialCurvedLabel.Position = [20 y_pos label_width 22];
app.linitialCurvedLabel.Text = '初始长度:';
app.linitialCurvedEditField = uieditfield(app.CurvedTab, 'text');
app.linitialCurvedEditField.Position = [130 y_pos field_width 22];
app.linitialCurvedEditField.Value = '1,1';
app.linitialCurvedLabel.Tooltip = '输入2个长度值,用逗号分隔,中间值固定为离散弧长';
y_pos = y_pos - 40;
% c_scale for curved
app.cscaleCurvedLabel = uilabel(app.CurvedTab);
app.cscaleCurvedLabel.Position = [20 y_pos label_width 22];
app.cscaleCurvedLabel.Text = '缩放因子:';
app.cscaleCurvedEditField = uieditfield(app.CurvedTab, 'numeric');
app.cscaleCurvedEditField.Position = [130 y_pos field_width 22];
app.cscaleCurvedEditField.Value = 1;
% Create buttons at bottom
y_pos = 40;
button_width = 70;
button_spacing = 10;
% Calculate positions for 3 buttons
total_width = 3 * button_width + 2 * button_spacing;
start_x = (310 - total_width) / 2;
app.RunButton = uibutton(app.LeftPanel, 'push');
app.RunButton.Position = [start_x y_pos button_width 30];
app.RunButton.Text = '运行计算';
app.RunButton.ButtonPushedFcn = createCallbackFcn(app, @RunButtonPushed, true);
app.SaveButton = uibutton(app.LeftPanel, 'push');
app.SaveButton.Position = [start_x + button_width + button_spacing y_pos button_width 30];
app.SaveButton.Text = '保存数据';
app.SaveButton.ButtonPushedFcn = createCallbackFcn(app, @SaveButtonPushed, true);
app.ClearButton = uibutton(app.LeftPanel, 'push');
app.ClearButton.Position = [start_x + 2*(button_width + button_spacing) y_pos button_width 30];
app.ClearButton.Text = '清空数据';
app.ClearButton.ButtonPushedFcn = createCallbackFcn(app, @ClearButtonPushed, true);
y_pos = y_pos - 40;
% Status label
app.StatusLabel = uilabel(app.LeftPanel);
app.StatusLabel.Position = [20 y_pos 270 22];
app.StatusLabel.Text = '准备就绪';
% Show the figure after all components are created
app.UIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = OrigamiApp
% Create UIFigure and components
createComponents(app)
% Initialize properties
app.allPointsMatrix = [];
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end