📄 display_material_mesh_gui.m
字号:
function [varargout] = display_material_mesh_gui(varargin)% A graphical user interface for plotting the material distributionmOutputArgs = {}; % Variable for storing output when GUI returnshandles = read_data_file; if isempty(handles) return;endcol = [254 253 222]/255;hMainFigure = figure(... % the main GUI figure 'Units','characters',... 'MenuBar','none', ... 'Toolbar','none', ... 'HandleVisibility','callback', ... 'Name', 'Display Material Mesh', ... 'NumberTitle','off', ... 'Position',[5 5 100 8],... 'color', col); cRadioPermittivity = uicontrol('Style', 'radiobutton',... 'Parent', hMainFigure, ... 'String', 'relative permittivity',... 'Value', 1,... 'Units','characters',... 'Position', [1 6 25 1],... 'backgroundcolor', col, ... 'Callback', @fRadioPermittivity); cRadioPermeability = uicontrol('Style', 'radiobutton',... 'Parent', hMainFigure, ... 'String', 'relative permeability',... 'Units','characters',... 'Position', [1 4.5 25 1],... 'backgroundcolor', col, ... 'Callback', @fRadioPermeability); cRadioEconductivity = uicontrol('Style', 'radiobutton',... 'Parent', hMainFigure, ... 'String', 'electric conductivity',... 'Units','characters',... 'Position', [1 3 25 1],... 'backgroundcolor', col, ... 'Callback', @fRadioEconductivity); cRadioMconductivity = uicontrol('Style', 'radiobutton',... 'Parent', hMainFigure, ... 'String', 'magnetic conductivity',... 'Units','characters',... 'Position', [1 1.5 25 1],... 'backgroundcolor', col, ... 'Callback', @fRadioMconductivity); cToggleXYplane = uicontrol('Style', 'toggle',... 'Parent', hMainFigure, ... 'String', 'xy plane',... 'Units','characters',... 'Position', [27 5.2 15 1.6],... 'backgroundcolor', 'g', ... 'value', 1,... 'Callback', @fToggleXYplane); cToggleYZplane = uicontrol('Style', 'toggle',... 'Parent', hMainFigure, ... 'String', 'yz plane',... 'Units','characters',... 'Position', [27 3.3 15 1.6],... 'backgroundcolor', 'g', ... 'value', 1,... 'Callback', @fToggleYZplane); cToggleZXplane = uicontrol('Style', 'toggle',... 'Parent', hMainFigure, ... 'String', 'zx plane',... 'Units','characters',... 'Position', [27 1.5 15 1.6],... 'backgroundcolor', 'g', ... 'value', 1,... 'Callback', @fToggleZXplane); cEditK = uicontrol('Style', 'edit',... 'Parent', hMainFigure, ... 'String', 'xy plane',... 'Units','characters',... 'Position', [50 5.2 15 1.6],... 'backgroundcolor', 'w', ... 'enable','inactive', ... 'Callback', @fEditK); cEditI = uicontrol('Style', 'edit',... 'Parent', hMainFigure, ... 'String', 'yz plane',... 'Units','characters',... 'Position', [50 3.3 15 1.6],... 'backgroundcolor', 'w', ... 'enable','inactive', ... 'Callback', @fEditI); cEditJ = uicontrol('Style', 'edit',... 'Parent', hMainFigure, ... 'String', 'zx plane',... 'Units','characters',... 'Position', [50 1.5 15 1.6],... 'backgroundcolor', 'w', ... 'enable','inactive', ... 'Callback', @fEditJ); cPushKdown = uicontrol('Style', 'pushbutton',... 'Parent', hMainFigure, ... 'String', '<<',... 'Units','characters',... 'Position', [45 5.2 5 1.6],... 'Callback', @fPushKdown); cPushIdown = uicontrol('Style', 'pushbutton',... 'Parent', hMainFigure, ... 'String', '<<',... 'Units','characters',... 'Position', [45 3.3 5 1.6],... 'Callback', @fPushIdown); cPushJdown = uicontrol('Style', 'pushbutton',... 'Parent', hMainFigure, ... 'String', '<<',... 'Units','characters',... 'Position', [45 1.5 5 1.6],... 'Callback', @fPushJdown); cPushKup = uicontrol('Style', 'pushbutton',... 'Parent', hMainFigure, ... 'String', '>>',... 'Units','characters',... 'Position', [65 5.2 5 1.6],... 'Callback', @fPushKup); cPushIup = uicontrol('Style', 'pushbutton',... 'Parent', hMainFigure, ... 'String', '>>',... 'Units','characters',... 'Position', [65 3.3 5 1.6],... 'Callback', @fPushIup); cPushJup = uicontrol('Style', 'pushbutton',... 'Parent', hMainFigure, ... 'String', '>>',... 'Units','characters',... 'Position', [65 1.5 5 1.6],... 'Callback', @fPushJup); cCheckEdge = uicontrol('Style', 'checkbox',... 'Parent', hMainFigure, ... 'String', 'edge',... 'Units','characters',... 'Position', [75 5.2 15 1.6],... 'backgroundcolor', col, ... 'Callback', @fCheckEdge); cCheckAxis = uicontrol('Style', 'checkbox',... 'Parent', hMainFigure, ... 'String', 'axis',... 'Units','characters',... 'Position', [90 5.2 15 1.6],... 'backgroundcolor', col, ... 'Callback', @fCheckAxis); cPushThicknessDown = uicontrol('Style', 'pushbutton',... 'Parent', hMainFigure, ... 'String', '<<',... 'Units','characters',... 'Position', [75 3.3 5 1.6],... 'Callback', @fPushThicknessDown); cPushThicknessUp = uicontrol('Style', 'pushbutton',... 'Parent', hMainFigure, ... 'String', '>>',... 'Units','characters',... 'Position', [80 3.3 5 1.6],... 'Callback', @fPushThicknessUp); cTextThickness = uicontrol('Style', 'text',... 'Parent', hMainFigure, ... 'String', 'thickness',... 'Units','characters',... 'backgroundcolor', col, ... 'Position', [85 3 10 1.6]); cCheckColorbar = uicontrol('Style', 'checkbox',... 'Parent', hMainFigure, ... 'String', 'colorbar',... 'Units','characters',... 'Position', [75 1.5 15 1.6],... 'backgroundcolor', col, ... 'Callback', @fCheckColorbar); set(cEditK, 'string',['k = ' num2str(round((handles.nz+1)/2)) ... ' / ' num2str(handles.nz+1)]);set(cEditI, 'string',['i = ' num2str(round((handles.nx+1)/2)) ... ' / ' num2str(handles.nx+1)]);set(cEditJ, 'string',['j = ' num2str(round((handles.ny+1)/2)) ... ' / ' num2str(handles.ny+1)]);handles.line_thickness_factor = 6;[handles] = initialize_plotting_arrays(handles); [handles] = plot_mesh(handles);view(20,30);mOutputArgs{1} = hMainFigure;if nargout>0 [varargout{1:nargout}] = mOutputArgs{:};endfunction fRadioPermittivity(hObject,eventdata) set(cRadioPermittivity,'value',1); set(cRadioPermeability,'value',0); set(cRadioEconductivity,'value',0); set(cRadioMconductivity,'value',0); set_maxval(handles); [handles] = plot_mesh(handles); endfunction fRadioPermeability(hObject,eventdata) set(cRadioPermittivity,'value',0); set(cRadioPermeability,'value',1); set(cRadioEconductivity,'value',0); set(cRadioMconductivity,'value',0); set_maxval(handles); [handles] = plot_mesh(handles); endfunction fRadioEconductivity(hObject,eventdata) set(cRadioPermittivity,'value',0); set(cRadioPermeability,'value',0); set(cRadioEconductivity,'value',1); set(cRadioMconductivity,'value',0); set_maxval(handles); [handles] = plot_mesh(handles); endfunction fRadioMconductivity(hObject,eventdata) set(cRadioPermittivity,'value',0); set(cRadioPermeability,'value',0); set(cRadioEconductivity,'value',0); set(cRadioMconductivity,'value',1); set_maxval(handles); [handles] = plot_mesh(handles);endfunction fToggleXYplane(hObject,eventdata) val = get(hObject,'value'); if (val == 1) col = 'g'; else col = 'r'; end set(hObject,'backgroundcolor', col); [handles] = plot_mesh(handles);endfunction fToggleYZplane(hObject,eventdata) val = get(hObject,'value'); if (val == 1) col = 'g'; else col = 'r'; end set(hObject,'backgroundcolor', col); [handles] = plot_mesh(handles);endfunction fToggleZXplane(hObject,eventdata) val = get(hObject,'value'); if (val == 1) col = 'g'; else col = 'r'; end set(hObject,'backgroundcolor', col); [handles] = plot_mesh(handles);endfunction fEditK(hObject,eventdata)endfunction fEditI(hObject,eventdata)endfunction fEditJ(hObject,eventdata)endfunction fPushKdown(hObject,eventdata) val = get_index(get(cEditK,'string')); val = val-1; maxval = handles.nz; if get(cRadioPermittivity,'value')==1 || get(cRadioEconductivity,'value')==1 maxval = maxval + 1; end if val<1 val=1; end set(cEditK,'string',['k = ' num2str(val) ' / ' num2str(maxval)]); [handles] = plot_mesh(handles);endfunction fPushIdown(hObject,eventdata) val = get_index(get(cEditI,'string')); val = val-1; maxval = handles.nx; if get(cRadioPermittivity,'value')==1 || get(cRadioEconductivity,'value')==1 maxval = maxval + 1; end if val<1 val=1; end set(cEditI,'string',['i = ' num2str(val) ' / ' num2str(maxval)]); [handles] = plot_mesh(handles);endfunction fPushJdown(hObject,eventdata) val = get_index(get(cEditJ,'string')); val = val-1; maxval = handles.ny; if get(cRadioPermittivity,'value')==1 || get(cRadioEconductivity,'value')==1 maxval = maxval + 1; end if val<1 val=1; end set(cEditJ,'string',['j = ' num2str(val) ' / ' num2str(maxval)]); [handles] = plot_mesh(handles);endfunction fPushKup(hObject,eventdata) val = get_index(get(cEditK,'string')); val = val+1; maxval = handles.nz; if get(cRadioPermittivity,'value')==1 || get(cRadioEconductivity,'value')==1 maxval = maxval + 1; end if val>maxval val=maxval; end set(cEditK,'string',['k = ' num2str(val) ' / ' num2str(maxval)]); [handles] = plot_mesh(handles); endfunction fPushIup(hObject,eventdata) val = get_index(get(cEditI,'string')); val = val+1; maxval = handles.nx; if get(cRadioPermittivity,'value')==1 || get(cRadioEconductivity,'value')==1 maxval = maxval + 1; end if val>maxval val=maxval; end set(cEditI,'string',['i = ' num2str(val) ' / ' num2str(maxval)]); [handles] = plot_mesh(handles);endfunction fPushJup(hObject,eventdata) val = get_index(get(cEditJ,'string')); val = val+1; maxval = handles.ny; if get(cRadioPermittivity,'value')==1 || get(cRadioEconductivity,'value')==1 maxval = maxval + 1; end if val>maxval val=maxval; end set(cEditJ,'string',['j = ' num2str(val) ' / ' num2str(maxval)]); [handles] = plot_mesh(handles);endfunction fCheckEdge(hObject,eventdata) [handles] = plot_mesh(handles);endfunction fCheckAxis(hObject,eventdata) [handles] = plot_mesh(handles);endfunction fPushThicknessDown(hObject,eventdata)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -