-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.m
More file actions
336 lines (301 loc) · 11.6 KB
/
main.m
File metadata and controls
336 lines (301 loc) · 11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
close all;
clear;
clc
addpath(genpath('.')); % 添加子文件路径以查找回调函数
%% 启动设置
%% 初次登陆教程??
%% 窗体设置
% 窗口设置
h_fig = figure('Name','空气动力学激波参数计算系统',...
'MenuBar','None',...
'NumberTitle','off',...
'ToolBar','None',...
'Units','normalized',...
'Position',[0.05 0.05 0.64 0.85]);
% 静态文本底布 为了后续编辑公式显示
ax_text = axes('Parent',h_fig,...
'Units','normalized',...
'Position',[0, 0, 1, 1],...
'Visible','off');
setappdata(h_fig,'ax_text',ax_text);
%% 创建菜单项
% + 文件
% - 退出
% + 编辑
% - 保存图片
% - 导出数据
% - 批量计算
% + 帮助
% - 帮助
% - 关于
% 文件
h_menu_file = uimenu(h_fig,'label','文件');
h_file_submenu1 = uimenu(h_menu_file,'label','退出',...
'callback',{@callback_quit,h_fig},...
'Accelerator','W');
h_file_submenu2 = uimenu(h_menu_file,'label','模板生成',...
'callback',{@callback_download,h_fig});
% 编辑
h_menu_edit = uimenu(h_fig,'label','编辑');
h_edit_submenu1 = uimenu(h_menu_edit,'label','保存图片',...
'callback',{@callback_saveFig,h_fig},...
'Accelerator','F');
h_edit_submenu2 = uimenu(h_menu_edit,'label','导出数据',...
'callback',{@callback_saveData,h_fig},...
'Accelerator','D');
h_edit_submenu3 = uimenu(h_menu_edit,'label','批量计算',...
'callback',{@callback_calData,h_fig},...
'Accelerator','B');
% 帮助
h_menu_help = uimenu(h_fig,'label','帮助');
h_help_submenu1 = uimenu(h_menu_help,'label','帮助',...
'callback',{@callback_help,h_fig},...
'Accelerator','H');
h_help_submenu2 = uimenu(h_menu_help,'label','关于',...
'callback',{@callback_info,h_fig},...
'Accelerator','I');
%% 创建名称title
h_text_title = uicontrol(h_fig,'style','text',...
'unit','normalized',...
'position',[0.35,0.93,0.35,0.05],...
'horizontal','center',...
'FontName','隶书',...
'FontSize',17,...
'string','空气动力学激波参数计算系统');
%% 创建图窗
% 初始白布
ax_fig = axes('Parent',h_fig,...
'Units','normalized',...
'Position',[0.06, 0.08, 0.6, 0.75],...
'XTick',[],...
'YTick',[],...
'Box','On');
setappdata(h_fig,'ax_fig',ax_fig);
% 临时计算数据
ax_temp = axes('Parent',h_fig,...
'Units','normalized',...
'Position',[0.06, 0.08, 0.6, 0.75],...
'XTick',[],...
'YTick',[],...
'Visible','off',...
'Box','On');
setappdata(h_fig,'ax_temp',ax_temp);
% 初始化正斜激波绘图窗口
initObliFig;
initNormFig(h_fig);
%% 用户数据暂存记录
data.FigHandleName = {'fig_ma2','fig_r2r1','fig_p2p1','fig_t2t1',...
'fig_obliq_beta','fig_obliq_ma2','fig_obliq_r2r1','fig_obliq_p2p1','fig_obliq_t2t1'}; % 设置图像句柄名称
data.NormalFigIndex = [1, 0, 0, 0]; % 设置正激波初始图像显示关系
data.ObliqueFigIndex = [1, 0, 0, 0, 0]; % 设置斜激波初始图像显示关系
data.NormalGraphExist = 0; % 记录尚未画图
data.ObliqueGraphExist = 0; % 记录尚未画图
data.isPreObliFig = 0; % 记录查值画图
data.MarkPoint = [0,0]; % 记录被选中标记点坐标
data.ObliQiang = []; % 斜激波强解数据
data.Ma2beta = []; % Ma2Beta双解数据
data.NormRecordData = []; % 正激波 ma1 ma2 beta r2r1 p2p1 t2t1
data.ObliRecordData = []; % 斜激波 ma1 ma2 beta r2r1 p2p1 t2t1 theta
guidata(h_fig,data);
%% 创建输入栏(Ma1,Ma2,theta<根据正负激波显示或隐藏>)
% Ma1
h_text_ma1 = uicontrol(h_fig,'style','text',...
'unit','normalized',...
'position',[0.68,0.75,0.07,0.04],...
'horizontal','center',...
'FontSize',15,...
'string','Ma1');
h_edit_ma1 = uicontrol(h_fig,'style','edit',...
'unit','normalized',...
'position',[0.68,0.7,0.07,0.04],...
'horizontal','left',...
'FontSize',10,...
'string','5',...
'callback',{@callback_ma1,h_fig});
setappdata(h_fig,'edit_ma1',h_edit_ma1);
% theta
h_text_theta = uicontrol(h_fig,'style','text',...
'Visible','off',...
'unit','normalized',...
'position',[0.76,0.75,0.07,0.04],...
'horizontal','center',...
'FontSize',15,...
'string','θ(deg)');
setappdata(h_fig,'text_theta',h_text_theta);
h_edit_theta = uicontrol(h_fig,'style','edit',...
'Visible','off',...
'unit','normalized',...
'position',[0.76,0.7,0.07,0.04],...
'horizontal','left',...
'FontSize',10,...
'callback',{@callback_theta,h_fig});
setappdata(h_fig,'edit_theta',h_edit_theta);
% Ma2
h_text_ma2 = uicontrol(h_fig,'style','text',...
'unit','normalized',...
'position',[0.84,0.75,0.07,0.04],...
'horizontal','center',...
'FontSize',15,...
'string','Ma2');
h_edit_ma2 = uicontrol(h_fig,'style','edit',...
'unit','normalized',...
'position',[0.84,0.7,0.07,0.04],...
'horizontal','left',...
'string','0.41523',...
'FontSize',10,...
'callback',{@callback_ma2,h_fig});
setappdata(h_fig,'edit_ma2',h_edit_ma2);
%% 创建下拉菜单
pum = uicontrol('Style','popupmenu',...
'Parent',h_fig,...
'String',{'正激波','斜激波'},...
'FontSize',10,...
'Units','normalized',...
'Position',[0.7, 0.65, 0.18, 0.2],...
'Callback',{@callback_menu,h_fig});
setappdata(h_fig,'pum',pum);
%% 创建数值显示
% p2/p1
h_result_p2p1 = uicontrol(h_fig,'style','text',...
'unit','normalized',...
'position',[0.82,0.58,0.1,0.04],...
'horizontal','center',...
'FontSize',15,...
'string','29');
text_result_p2p1 = text('unit','normalized',...
'position',[0.72,0.6],...
'horizontal','center',...
'Interpreter','latex',...
'Parent',ax_text,...
'FontSize',15,...
'string','$$\frac{p_2}{p_1}$$');
setappdata(h_fig,'res_p2p1',h_result_p2p1);
% rho2/rho1
h_result_r2r1 = uicontrol(h_fig,'style','text',...
'unit','normalized',...
'position',[0.82,0.48,0.1,0.04],...
'horizontal','center',...
'FontSize',15,...
'string','5');
text_result_r2r1 = text('unit','normalized',...
'position',[0.72,0.5],...
'horizontal','center',...
'Interpreter','latex',...
'Parent',ax_text,...
'FontSize',15,...
'string','$$\frac{\rho_2}{\rho_1}$$');
setappdata(h_fig,'res_r2r1',h_result_r2r1);
% T2/T1
h_result_T2T1 = uicontrol(h_fig,'style','text',...
'unit','normalized',...
'position',[0.82,0.38,0.1,0.04],...
'horizontal','center',...
'FontSize',15,...
'string','5.8');
text_result_T2T1 = text('unit','normalized',...
'position',[0.72,0.4],...
'horizontal','center',...
'Interpreter','latex',...
'Parent',ax_text,...
'FontSize',15,...
'string','$\frac{T_2}{T_1}$');
setappdata(h_fig,'res_T2T1',h_result_T2T1);
% beta 用于正激波
h_result_beta = uicontrol(h_fig,'style','text',...
'unit','normalized',...
'position',[0.82,0.28,0.1,0.04],...
'horizontal','center',...
'FontSize',15,...
'string','90');
text_result_beta = text('unit','normalized',...
'position',[0.72,0.3],...
'horizontal','center',...
'Interpreter','latex',...
'Parent',ax_text,...
'FontSize',15,...
'string','$\beta$(deg)');
setappdata(h_fig,'res_beta',h_result_beta);
% beta 用于斜激波
h_edit_beta = uicontrol(h_fig,'style','edit',...
'unit','normalized',...
'position',[0.82,0.28,0.1,0.04],...
'horizontal','center',...
'string',' ',...
'FontSize',15,...
'Visible','off',...
'callback',{@callback_beta,h_fig});
setappdata(h_fig,'edit_beta',h_edit_beta);
%% 创建斜激波强弱解按钮
bg = uibuttongroup('Parent',h_fig,...
'Visible','off',...
'unit','normalized',...
'Position',[0.92,0.27,0.08,0.06],...
'SelectionChangedFcn',@callback_bg);
setappdata(h_fig,'bg',bg);
% 在按键组创建两个选项
ruo = uicontrol(bg,'Style','radiobutton',...
'unit','normalized',...
'String',' 弱解',...
'FontSize',10,...
'Position',[0.18,0.45,1,0.5],...
'HandleVisibility','off');
qiang = uicontrol(bg,'Style','radiobutton',...
'unit','normalized',...
'String',' 强解',...
'FontSize',10,...
'Position',[0.18,0.02,1,0.5],...
'HandleVisibility','off');
%% 创建Ma2-beta双解按钮
bg_beta = uibuttongroup('Parent',h_fig,...
'Visible','off',...
'unit','normalized',...
'Position',[0.92,0.27,0.08,0.06],...
'SelectionChangedFcn',@callback_bgBeta);
setappdata(h_fig,'bg_beta',bg_beta);
% 在按键组创建两个选项
ruo = uicontrol(bg_beta,'Style','radiobutton',...
'unit','normalized',...
'String',' 结果1',...
'FontSize',10,...
'Position',[0.18,0.45,1,0.5],...
'HandleVisibility','off');
qiang = uicontrol(bg_beta,'Style','radiobutton',...
'unit','normalized',...
'String',' 结果2',...
'FontSize',10,...
'Position',[0.18,0.02,1,0.5],...
'HandleVisibility','off');
%% 创建按钮
btn1 = uicontrol('Style','pushbutton',...
'Parent',h_fig,...
'String','绘制图像',...
'FontSize',13,...
'Units','normalized',...
'Position',[0.7,0.07,0.1,0.05],...
'Callback',{@callback_btn1,h_fig});
setappdata(h_fig,'btn1',btn1)
btn2 = uicontrol('Style','pushbutton',...
'Parent',h_fig,...
'String','记录数据',...
'FontSize',13,...
'Units','normalized',...
'Position',[0.83,0.07,0.1,0.05],...
'Callback',{@callback_btn2,h_fig});
setappdata(h_fig,'btn2',btn2)
btn3 = uicontrol('Style','pushbutton',...
'Parent',h_fig,...
'String','清空',...
'FontSize',10,...
'Units','normalized',...
'position',[0.93,0.7,0.05,0.04],...
'Callback',{@callback_btn3,h_fig});
setappdata(h_fig,'btn3',btn3)
%% 设置键盘响应
set(h_fig,'windowKeyPressFcn',@(~,evnt)callback_keypress(evnt,h_fig));
%% 设置窗口关闭提示
set(h_fig,'CloseRequestFcn',{@callback_quit,h_fig});
%% 设置鼠标相应
set(h_fig,'WindowButtonMotionFcn',{@callback_motion,h_fig}); % 设置鼠标形状
set(h_fig,'WindowButtonDownFcn',{@callback_buttondown,h_fig}); % 设置鼠标Shift+左键(或滚轮键)
%% 辅助函数
% PATH: Function -> callbackFunc -> ...