www.pudn.com > AFEM@matlab.rar > toolkit.m, change:2006-10-20,size:8166b


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 EDIT
gui_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});
end

if 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; end

handles.node = varargin{1};
handles.elem = varargin{2};
handles.plotwindow = 1; % default value
handles.isNewindow = 0; % draw in the original solu/mesh window

% Choose default command line output for toolkit
handles.output = hObject;

% Update handles structure
guidata(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 structure
varargout{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 window
else 
    handles.plotwindow = figure; % in a new window
end
% Update handles structure
guidata(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 window
else 
    figure(handles.plotwindow);
end

plotelem(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; end

if (handles.isNewindow == 0)
    figure(1); subplot(1,2,2); % in old window
else 
    figure(handles.plotwindow);
end

findnode(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; end

if (handles.isNewindow == 0)
    figure(1); subplot(1,2,2); % in old window
else 
    figure(handles.plotwindow);
end

findelem(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; end

if (handles.isNewindow == 0)
    figure(1); subplot(1,2,2); % in old window
else 
    figure(handles.plotwindow);
end

findedge(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 window
else 
    figure(handles.plotwindow);
end

plotnode(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 window
else 
    figure(handles.plotwindow);
end

plotedge(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 windowselect
handles.isNewindow = get(hObject,'Value');

guidata(hObject, handles);