📄 toolkit.m
字号:
function varargout = toolkit(varargin)% TOOLKIT M-file for toolkit.fig% TOOLKIT, by itself, creates a new TOOLKIT or raises the existing% singleton*.%% H = TOOLKIT returns the handle to a new TOOLKIT or the handle to% the existing singleton*.%% TOOLKIT('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in TOOLKIT.M with the given input arguments.%% TOOLKIT('Property','Value',...) creates a new TOOLKIT or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before toolkit_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to toolkit_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% L. Chen and C. Zhang% Last Modified by GUIDE v2.5 13-Oct-2006 23:36:15% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @toolkit_OpeningFcn, ... 'gui_OutputFcn', @toolkit_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before toolkit is made visible.function toolkit_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to toolkit (see VARARGIN)if length(varargin)<2, return; endhandles.node = varargin{1};handles.elem = varargin{2};handles.plotwindow = 1; % default valuehandles.isNewindow = 0; % draw in the original solu/mesh window% Choose default command line output for toolkithandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes toolkit wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = toolkit_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout{1} = handles.output;% --- Executes on button press in cleanmesh.function cleanmesh_Callback(hObject, eventdata, handles)% hObject handle to cleanmesh (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)if (handles.isNewindow == 0) figure(1); subplot(1,2,2); % in old windowelse handles.plotwindow = figure; % in a new windowend% Update handles structureguidata(hObject, handles);hold off; showmesh(handles.node, handles.elem); hold on;title('Current mesh', 'FontSize', 14);% --- Executes on button press in plotelem.function plotelem_Callback(hObject, eventdata, handles)% hObject handle to plotelem (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)if (handles.isNewindow == 0) figure(1); subplot(1,2,2); % in old windowelse figure(handles.plotwindow);endplotelem(handles.node, handles.elem);title('Element indices', 'FontSize', 16);% --- Executes on button press in findnode.function findnode_Callback(hObject, eventdata, handles)% hObject handle to findnode (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)index = str2double(get(handles.Input_box,'String'));if (index <= 0 || index > max(size(handles.node))), return; endif (handles.isNewindow == 0) figure(1); subplot(1,2,2); % in old windowelse figure(handles.plotwindow);endfindnode(handles.node, index);% --- Executes on button press in findelem.function findelem_Callback(hObject, eventdata, handles)% hObject handle to findelem (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)index = str2double(get(handles.Input_box,'String'));if (index <= 0 || index > max(size(handles.elem))), return; endif (handles.isNewindow == 0) figure(1); subplot(1,2,2); % in old windowelse figure(handles.plotwindow);endfindelem(handles.node, handles.elem, index);% --- Executes on button press in findedge.function findedge_Callback(hObject, eventdata, handles)% hObject handle to findedge (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)index = str2double(get(handles.Input_box,'String'));edge = [handles.elem(:,[1,2]); handles.elem(:,[1,3]); handles.elem(:,[2,3])];edge = unique(sort(edge,2),'rows');if (index <= 0 || index > max(size(edge))), return; endif (handles.isNewindow == 0) figure(1); subplot(1,2,2); % in old windowelse figure(handles.plotwindow);endfindedge(handles.node, edge, index);function Input_box_Callback(hObject, eventdata, handles)% hObject handle to Input_box (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of Input_box as text% str2double(get(hObject,'String')) returns contents of Input_box as a double% --- Executes during object creation, after setting all properties.function Input_box_CreateFcn(hObject, eventdata, handles)% hObject handle to Input_box (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end% --- Executes on button press in plotnode.function plotnode_Callback(hObject, eventdata, handles)% hObject handle to plotnode (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)if (handles.isNewindow == 0) figure(1); subplot(1,2,2); % in old windowelse figure(handles.plotwindow);endplotnode(handles.node); title('Node indices', 'FontSize', 14);% --- Executes on button press in plotedge.function plotedge_Callback(hObject, eventdata, handles)% hObject handle to plotedge (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)edge = [handles.elem(:,[1,2]); handles.elem(:,[1,3]); handles.elem(:,[2,3])];edge = unique(sort(edge,2),'rows');if (handles.isNewindow == 0) figure(1); subplot(1,2,2); % in old windowelse figure(handles.plotwindow);endplotedge(handles.node, edge); title('Element indices', 'FontSize', 14);% --- Executes on button press in windowselect.function windowselect_Callback(hObject, eventdata, handles)% hObject handle to windowselect (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of windowselecthandles.isNewindow = get(hObject,'Value');guidata(hObject, handles);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -