www.pudn.com > topgui.zip > topgui.m


function varargout = topgui(varargin) 
%TOPGUI Apply constrains and forces to FEA model. It can be used as an assitant 
%       tool for Ole Sigmund's 99 line topology optimization code. 
% Usage : [fixeddofs F]=topgui(nelx,nely); 
% More infomation :    http://www.geocities.com/chinakkong/research/topgui/ 
%                      http://www.topopt.dtu.dk/cgi-bin/matlab/matlab_counter.cgi 
% 
% ---------------------------------------------------------------------- % 
%                    TopGUI V1.0                                         % 
%                                                                        % 
%  Release date : 2003-11-21                                             % 
%  Written by   : Kang Zhao,Dalian University of Technology,Dalian,China.% 
%  E-mail       : kangzhao@student.dlut.edu.cn                           % 
%  More info    : http://www.geocities.com/chinakkong/research/topgui/      % 
% ---------------------------------------------------------------------- % 
 
% Begin initialization code - DO NOT EDIT 
gui_Singleton = 1; 
gui_State = struct('gui_Name',       mfilename, ... 
                   'gui_Singleton',  gui_Singleton, ... 
                   'gui_OpeningFcn', @topgui_OpeningFcn, ... 
                   'gui_OutputFcn',  @topgui_OutputFcn, ... 
                   'gui_LayoutFcn',  @topgui_LayoutFcn, ...
                   'gui_Callback',   []); 
if nargin & isstr(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 topgui is made visible. 
function topgui_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 topgui (see VARARGIN) 
 
% Choose default command line output for topgui 
 
% To avoid callback executed before axes is ready 
% "topgui_export" below has to be modified to exported .m file name. 
set(hObject,'WindowButtonMotionFcn','topgui(''figure1_WindowButtonMotionFcn'',gcbo,[],guidata(gcbo))',... 
            'WindowButtonUpFcn','topgui(''figure1_WindowButtonUpFcn'',gcbo,[],guidata(gcbo))'); 
         
h_text_email = findobj('tag','text_email'); 
backcolor = get(h_text_email,'BackgroundColor'); 
set(hObject,'Color',backcolor); 
 
% Get input variables 
handles.nelx=varargin{1}; 
handles.nely=varargin{2}; 
 
nelx = handles.nelx; 
nely = handles.nely; 
 
    % Re-set axes properties 
     
    % Get handle of the axes by axes handle in handles 
    h_axes=gca; 
    set(h_axes,'XTick',[1 (5:5:nelx-1) nelx+1]); 
    set(h_axes,'YTick',[1 (5:5:nely-1) nely+1]); 
    set(h_axes,'XLim',[0 nelx+2]); 
    set(h_axes,'YLim',[0 nely+2]); 
     
    % Set limits of x,y,i,j 
    h_lim_x = findobj('tag','text_lim_x'); 
    h_lim_y = findobj('tag','text_lim_y'); 
    h_lim_i = findobj('tag','text_lim_i'); 
    h_lim_j = findobj('tag','text_lim_j'); 
     
    set(h_lim_x,'string',['(' num2str(1) ':' num2str(nelx+1) ')']); 
    set(h_lim_y,'string',['(' num2str(1) ':' num2str(nely+1) ')']); 
    set(h_lim_i,'string',['(' num2str(1) ':' num2str(nelx) ')']); 
    set(h_lim_j,'string',['(' num2str(1) ':' num2str(nely) ')']); 
     
 
    x=(1:nelx+1); 
    y=(1:nely+1); 
     
     
    % =======  Add variables to handles   ======= % 
     
    % Nodes selection 
        handles.h_nodes=zeros(nelx+1,nely+1); % Handles of nodes                
        handles.selection_rect=zeros(1,4); % Select field when picking nodes. 
         
        handles.pt1=zeros(1,2); % [x1 y1] Starting corner of picking rectangle 
        handles.pt3=zeros(1,2); % [x2 y2] Ending corner of picking rectangle 
         
       handles.h_rect=0; % Handle of selection rectangle 
         
       % handles.h_rect=line([x1 x2 x3 x4],[y1 y2 y3 y4]) 
       % 1------4 
       % |      | 
       % 2------3 
        handles.if_picking=0; % in Picking mode and press is down 
         
     
    % Constrains 
        handles.fixeddofs=[]; 
        % patch handles relative to handles.fixeddofs 
        % handles.fixeddofs_patch3=[h_patch1 h_patch1 ... h_patchN] 
        handles.fixeddofs_patch3=[];  
     
    % Forces 
        handles.F=sparse(2*(nely+1)*(nelx+1),1); 
        handles.F_arrow=[]; % arrow handles relative to handles.F 
         
    % ======= Configurate plot ======= % 
    % Unselected nodes 
        handles.nodeMarker_default = ['.']; 
        handles.nodeMarkerSize_default = 8; 
        handles.nodeColor_default = [0 0 1]; 
     
    % Selected nodes 
		handles.nodeMarker_selected = ['o']; 
        handles.nodeMarkerSize_selected = 5; 
        handles.nodeColor_selected = 'm'; 
     
    % Constrain triangle 
        handles.constrain_triangle_height = 0.5; 
        handles.constrain_triangle_width = 0.7; 
        handles.constrain_triangle_FaceColor = 'none'; 
        handles.constrain_triangle_LineWidth = 1.0; 
     
   % Force arrow 
        handles.force_arrow_line_length=0.55; 
        handles.force_arrow_line_color=[1 0 0]; 
        handles.force_arrow_line_width=2.0; 
         
        handles.force_arrow_patch_width=0.3; 
        handles.force_arrow_patch_height=0.3; 
        handles.force_arrow_patch_facecolor='r'; 
        handles.force_arrow_patch_edgecolor='r'; 
     
	% handles.selected_nodes=  
	% [i1 i2 ...in 
	%  j1 j2 ...jn] 
    handles.selected_nodes=[];      
     
    % =======   Plot meshes   ======= % 
    % Horizontal Grid Lines 
    for(j=1:nely+1) 
        x1=x(1); 
        x2=x(nelx+1); 
        y1=y(j); 
        y2=y(j); 
        plot([x1 x2],[y1 y2]); 
        hold on; 
    end 
     
    % Vertical Grid Lines 
    for(i=1:nelx+1) 
        x1=x(i); 
        x2=x(i); 
        y1=y(1); 
        y2=y(nely+1); 
        plot([x1 x2],[y1 y2]); 
        hold on; 
    end 
	 
	% Nodes 
	for i=1:nelx+1 
		for j=1:nely+1 
			handles.h_nodes(i,j)=plot(x(i),y(j)); 
		end	 
	end         
     
    % Set default appearance to nodes 
    set_nodes_appearance(handles.h_nodes,handles,0); 
     
    % Save to handles 
    guidata(hObject,handles); 
        
handles.output = hObject; 
 
% Update handles structure 
guidata(hObject, handles); 
 
% UIWAIT makes topgui wait for user response (see UIRESUME) 
%uiwait(handles.figure1); 
uiwait(hObject); 
 
 
% --- Outputs from this function are returned to the command line. 
function varargout = topgui_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.fixeddofs; 
varargout{2}=handles.F; 
 
 
% Delete TOPGUI 
delete(hObject);

% --- Executes on button press in pushbutton_selNodes_inp.
function pushbutton_selNodes_inp_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_selNodes_inp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA) 
 
% handles.selected_nodes=[2,:];  
% [i1 i2 ...in 
%  j1 j2 ...jn] 
 
 
% Get select type 
h_selNodes_type = findobj('tag','popupmenu_select_type'); 
value = get(h_selNodes_type,'value'); 
 
if value==1 
    handles = guidata(hObject); 
    if_return = checknew(hObject);% if select No in dialog if_return=1, and then quit this function 
    if if_return 
        return; 
    end 
end 
 
% Prompt dialog for input x,y 
prompt = {' x :',' y:'}; 
dlg_title = 'Input index vectors of nodes to be selected (In matlab syntax)'; 
num_lines = 1; 
def       = {'',''}; 
answer    = inputdlg(prompt,dlg_title,num_lines,def); 
 
 
% Validity check for input vector 
valid = 0; 
while ( length(answer) > 0 & valid == 0 ) 
    str_x=answer{1}; 
    str_y=answer{2}; 
     
    if ( length(str_x) > 0 & length(str_y) > 0 ) 
        % Valid input for eval 
        eval(['arr_x=(' str_x ');']); 
        eval(['arr_y=(' str_y ');']);        
        if ( size(arr_x,1) ~= 1 ) % Row vector 
            err_msg='Please input x as a row vector.'; 
        elseif ( size(arr_x,2) == 0 ) % Length>0 
            err_msg='Length of x can not be zero. '; 
        elseif ( size(arr_y,1) ~= 1 ) % Row vector 
            err_msg='Please input y as a row vector.'; 
        elseif ( size(arr_y,2) == 0 ) % Length>0 
            err_msg='Length of y can not be zero. '; 
        elseif ~all( arr_x >= 1 & arr_x <= handles.nelx + 1) % Bound check 
            err_msg=['All elements in x must between 1 and ' num2str(handles.nelx+1)]; 
        elseif ~all( arr_y >= 1 & arr_y <= handles.nely + 1) % Bound check 
            err_msg=['All elements in y must between 1 and ' num2str(handles.nely+1)]; 
        else 
            valid=1; 
        end 
         
        if ~valid 
            % Alert error information 
            h = msgbox(err_msg,'Invalid input!','error','modal'); 
            waitfor(h); % Wait until dialog is deleted 
             
            % Input again 
            prompt = {'x(eg. [1:20 30 40]) :','y(eg. [1:20 30 40]) :'}; 
            dlg_title = 'Input index vectors of nodes to be selected'; 
            num_lines = 1; 
            def       = {str_x,str_y}; % Use last input as default 
            answer    = inputdlg(prompt,dlg_title,num_lines,def); 
        end 
    end 
end % End while (length(answer)>0 & valid==0) 
 
if ( length(answer)==0 ) % Canceled 
    return; 
end
 
 
% Below:Dialog not canceled and input valid 
 
% Get index array of selected nodes 
len_x=length(arr_x); 
len_y=length(arr_y); 
len=len_x*len_y;                 
nodes_index_array=zeros(2,len); 
k=0; 
for i=1:len_x 
    for j=1:len_y 
        k=k+1; 
        nodes_index_array(1,k)=arr_x(i); 
        nodes_index_array(2,k)=arr_y(j); 
    end 
end 
 
% Select nodes. value: 1-New  2-Add 
select_nodes(nodes_index_array,handles,value);  
 
% End of function pushbutton_selNodes_inp_Callback

% --- Executes on button press in pushbutton_SelNodes_pick.
function pushbutton_SelNodes_pick_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_SelNodes_pick (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA) 
 
handles.if_picking = 1; 
guidata(gcbo,handles); 
 
% Get select type 
h_selNodes_type = findobj('tag','popupmenu_select_type'); 
value = get(h_selNodes_type,'value'); 
 
if value==1 
    handles = guidata(hObject); 
     if_return = checknew(hObject);% if select No in dialog if_return=1, and then quit this function 
    if if_return 
        return; 
    end 
end 
 
nelx=handles.nelx; 
nely=handles.nely; 
 
% Pick by mouse 
set(gcf,'Pointer','crosshair'); 
 
% Get starting corner of selecting rectangle 
waitfor(gcf,'userdata','ButtonDown'); % axes1.WindowButtonDownFcn  -  get handles.if_picking 
handles = guidata(gcbo); % Get updated handles. ( handles.pt1 is got in callback WindowButtonDownFcn)  
 
if ~handles.if_picking % Canceled by right click 
    return; 
end 
 
% Initialize line of rectangle 
xdata=[0 0 0 0 0]; 
ydata=[0 0 0 0 0]; 
handles.h_rect=line('XData', xdata,'YData', ydata,'Visible', 'off','linestyle','--'); 
 
% handles.if_picking=1; 
 
guidata(gcbo,handles); % Save handles 
 
 
% Get end corner of selecting rectangle 
waitfor(gcf,'userdata','ButtonUp'); % 0-Press up and rectangle finished     
handles = guidata(gcbo); % Get updated handles 
 
set(gcf,'userdata',1); 
 
x1=handles.pt1(1); 
y1=handles.pt1(2); 
x3=handles.pt3(1); 
y3=handles.pt3(2); 
 
xmin=ceil(min(x1,x3)); 
xmax=floor(max(x1,x3)); 
ymin=ceil(min(y1,y3)); 
ymax=floor(max(y1,y3)); 
 
% Validity check for selection field 
if ( ~(xmin<=nelx+1 & xmax>=1 & ymin<=nely+1 & ymax>=1 )) 
    errordlg('No nodes selected!'); 
    return; 
end 
 
% Get nodes index array 
len_x=xmax-xmin+1; 
len_y=ymax-ymin+1; 
len=len_x*len_y;                 
nodes_index_array=zeros(2,len); 
k=0; 
for x=xmin:xmax 
    for y=ymin:ymax 
        k=k+1; 
        nodes_index_array(1,k)=x; 
        nodes_index_array(2,k)=y;  
    end	 
end
 
% Select nodes. value: 1-New  2-Add 
select_nodes(nodes_index_array,handles,value);  


% --- Executes during object creation, after setting all properties.
function popupmenu_select_type_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu_select_type (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

% --- Executes during object creation, after setting all properties.
function popupmenu_constrain_type_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu_constrain_type (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on button press in pushbutton_constrain_apply.
function pushbutton_constrain_apply_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_constrain_apply (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA) 
 
% Get constrain type 
 
if ~if_nodes_selected(handles) 
    return; 
end 
 
h_constrain_type = findobj('tag','popupmenu_constrain_type'); 
value = get( h_constrain_type,'value'); 
 
switch value 
    case 1 % Ux 
        dofs = [0 1]; 
    case 2 % Uy 
        dofs = [1 0]; 
    case 3 % UxUy 
        dofs = [0 0]; 
    otherwise 
        dofs = [0 0]; 
end 
 
% Update handles.fixeddofs and handles.fixeddofs_patch3  
%   and redraw constrain triangles 
handles = apply_constrains(handles.selected_nodes, dofs, handles); 
 
% Save updated handles 
guidata(hObject,handles);


% --- Executes on button press in pushbutton_constrain_clear.
function pushbutton_constrain_clear_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_constrain_clear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA) 
 
if ~if_nodes_selected(handles) 
    return; 
end 
 
button = questdlg('Are you sure to cancel the specified constrains on the selected nodes?','Confirm selection','Yes','No','No'); 
if strcmp(button,'No') 
    return; 
end 
 
index_selected_nodes=IJ2index(handles.selected_nodes,handles); 
 
h_constrain_type = findobj('tag','popupmenu_constrain_type'); 
value = get(h_constrain_type,'value'); % 1-Ux 2-Uy 3-UxUy 
 
switch value 
    case 1 % Ux 
        dofs_free=2*index_selected_nodes-1; 
    case 2 % Uy 
        dofs_free=2*index_selected_nodes; 
    case 3 % UxUy 
        dofs_free=[2*index_selected_nodes-1 2*index_selected_nodes]; 
    otherwise 
        dofs_free=[2*index_selected_nodes-1 2*index_selected_nodes]; 
end 
 
n = length( handles.fixeddofs ); 
 
% To save uncanceled dofs 
fixeddofs_temp=[];  
fixeddofs_patch3_temp=[]; 
 
for i=1:n 
    result = find( dofs_free == handles.fixeddofs(i)); 
    if length( result ) == 0 % Not canceled 
        fixeddofs_temp=[fixeddofs_temp handles.fixeddofs(i)]; 
        fixeddofs_patch3_temp=[fixeddofs_patch3_temp handles.fixeddofs_patch3(i)]; 
    else % Constrain Canceled 
        delete(handles.fixeddofs_patch3(i)); 
    end 
end 
 
handles.fixeddofs=fixeddofs_temp; 
handles.fixeddofs_patch3=fixeddofs_patch3_temp; 
 
% Update constrain number 
num_dofs = length( handles.fixeddofs ); 
num_uy = length( find( mod( handles.fixeddofs,2 )==0 ) ); % number of Uy constrains 
num_ux = num_dofs - num_uy; % number of Ux constrains 
 
 
% Update constrain number 
h_num_constrained_ux=findobj('tag','text_num_constrained_ux'); 
h_num_constrained_uy=findobj('tag','text_num_constrained_uy'); 
 
set(h_num_constrained_ux,'string',num2str(num_ux)); 
set(h_num_constrained_uy,'string',num2str(num_uy)); 
 
 
guidata(gcbo,handles); 



% --- Executes during object creation, after setting all properties.
function popupmenu_force_type_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu_force_type (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on button press in pushbutton_force_apply.
function pushbutton_force_apply_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_force_apply (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA) 
 
if ~if_nodes_selected(handles) 
    return; 
end 
 
% Get force type 
h_force_type = findobj('tag','popupmenu_force_type'); 
value = get( h_force_type,'value'); 
 
dlgTitle='Input magnitude of force'; 
switch value 
    case 1 % Fx 
        dof=1; 
        prompt={'Fx:'}; 
    case 2 % Fy 
        dof=2; 
        prompt={'Fy:'}; 
    otherwise 
        return; 
end 
 
str_mag=inputdlg(prompt,dlgTitle); %magnitude of force 
if length(str_mag)==0 % canceled 
   return; 
end 
force=str2num(str_mag{1}); 
 
% Update handles.F and handles.F_arrow 
%   and redraw force arrows 
handles = apply_forces(handles.selected_nodes, dof, force, handles ); 
 
% Save updated handles 
guidata(hObject,handles);


% --- Executes on button press in pushbutton_force_clear.
function pushbutton_force_clear_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_force_clear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA) 
 
if ~if_nodes_selected(handles) 
    return; 
end 
 
button = questdlg('Are you sure to cancel the specified forces on the selected nodes?','Confirm selection','Yes','No','No'); 
if strcmp(button,'No') 
    return; 
end 
 
index_selected_nodes=IJ2index(handles.selected_nodes,handles); 
 
% Get force type 
h_force_type = findobj('tag','popupmenu_force_type'); 
value = get( h_force_type,'value'); 
 
switch value 
    case 1 % Fx 
        dofs_free=2*index_selected_nodes-1; 
    case 2 % Fy 
        dofs_free=2*index_selected_nodes; 
    otherwise 
        dofs_free=[2*index_selected_nodes-1 2*index_selected_nodes]; 
end 
 
i_nonzeros = find(handles.F); 
n = length( i_nonzeros ); 
 
% To save uncanceled forces 
F_arrow_temp=[]; 
 
for i=1:n 
    dof = i_nonzeros(i); 
    result = find( dofs_free == dof); 
    if length( result ) == 0 % Not canceled 
        F_arrow_temp=[F_arrow_temp handles.F_arrow(:,i)]; 
    else % Force Canceled 
        handles.F(dof) = 0.0; 
        delete(handles.F_arrow(:,i)); 
    end 
end 
handles.F_arrow=F_arrow_temp; 
 
 
 
i_nonzeros = find(handles.F); 
n = length( i_nonzeros ); 
num_fy = length( find( mod ( i_nonzeros, 2 ) == 0 ) ); 
num_fx = n - num_fy;  
 
% Update force number 
h_num_force_fx=findobj('tag','text_num_force_fx'); 
h_num_force_fy=findobj('tag','text_num_force_fy'); 
 
set(h_num_force_fx,'string',num2str(num_fx)); 
set(h_num_force_fy,'string',num2str(num_fy)); 
 
 
guidata(gcbo,handles); 



% --- Executes on button press in checkbox_save_files.
function checkbox_save_files_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox_save_files (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 checkbox_save_files
 
h_edit=findobj('tag','edit_save_path'); 
h_browse=findobj('tag','pushbutton_browse'); 
 
value=get(hObject,'Value'); 
if value % Checked 
    set(h_edit,'enable','on');     
    set(h_browse,'enable','on'); 
else 
    set(h_edit,'string',''); 
    set(h_edit,'enable','off');     
    set(h_browse,'enable','off'); 
end

% --- Executes on button press in pushbutton_OK.
function pushbutton_OK_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_OK (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA) 
disp('Starting optimization ...'); 
uiresume; 
     
% --- Set appearance of nodes 
function set_nodes_appearance(h_nodes,handles,iflag) 
% iflag: 0 - default apprarance 
%        1 - selected appearance 
 
switch iflag 
    case 0 % unselected mode 
        set(h_nodes,'Marker',handles.nodeMarker_default); 
        set(h_nodes,'MarkerSize',handles.nodeMarkerSize_default); 
        set(h_nodes,'Color',handles.nodeColor_default); 
    case 1 % selected mode 
        set(h_nodes,'Marker',handles.nodeMarker_selected); 
        set(h_nodes,'MarkerSize',handles.nodeMarkerSize_selected); 
        set(h_nodes,'Color',handles.nodeColor_selected); 
    otherwise % set default to unselected mode 
        set(h_nodes,'Marker',handles.nodeMarker_default); 
        set(h_nodes,'MarkerSize',handles.nodeMarkerSize_default); 
        set(h_nodes,'Color',handles.nodeColor_default); 
end 
     
% --- Select nodes 
function select_nodes(nodes_index_array,handles,i_select_type) 
% nodes_index_array=[x1 x2 ... xn 
%                   y1 y2 ...yn ] 
% handles : topgui handles 
% i_select_type :  1 - New      2 - Add 
 
if ~size(nodes_index_array,2)>0 
    return; 
end 
 
switch i_select_type 
    case 1 % New 
        if (size(handles.selected_nodes,2)>0) 
            ii=handles.selected_nodes(1,:); 
            jj=handles.selected_nodes(2,:); 
             
            % Set previous selected nodes appearance to unselected mode 
            set_nodes_appearance(handles.h_nodes(ii,jj),handles,0);  
             
            % Clear selected nodes 
            handles.selected_nodes=[];              
        end 
         
        % Save newly selected nodes index(sorted and no repetites) 
        handles.selected_nodes=[unique(nodes_index_array','rows')]';  
         
        ii=handles.selected_nodes(1,:); 
        jj=handles.selected_nodes(2,:); 
         
        % Set nodes appearance to selected mode 
        set_nodes_appearance(handles.h_nodes(ii,jj),handles,1);  
    case 2 % Add 
        ii=nodes_index_array(1,:); 
        jj=nodes_index_array(2,:); 
         
        % Add newly selected nodes index(sorted and no repetites) 
        handles.selected_nodes=[unique([handles.selected_nodes nodes_index_array]','rows')]';   
         
        % Set newly selected nodes appearance to selected mode         
        set_nodes_appearance(handles.h_nodes(ii,jj),handles,1);  
    otherwise         
end     
 
% Update num of selected nodes 
num=size( handles.selected_nodes,2 ); 
str_num=num2str(num); 
h_text_num_nodes_selected=findobj('tag','text_num_nodes_selected'); 
set(h_text_num_nodes_selected,'string',str_num); 
 
% Save updated handles 
    guidata(gcf,handles); 
     
% --- Check/alert for a new selection 
function if_return = checknew(hObject); 
 
if_return = 0; 
handles = guidata(hObject); 
 
% Alert for clearing previous selection 
if(size(handles.selected_nodes,2)>0)  
    button = questdlg('Are you sure to cancel the previous selection and start a new selestion?','Confirm selection','Yes','No','No'); 
    if strcmp(button,'No') 
        if_return = 1; 
        return; 
    else % Unselect previously selected nodes 
        % Set previously selected nodes to unselected mode 
        ii=handles.selected_nodes(1,:); 
        jj=handles.selected_nodes(2,:); 
        set_nodes_appearance(handles.h_nodes(ii,jj),handles,0); 
         
        % Clear handls.selected_nodes 
        handles.selected_nodes=[]; 
         
        % Update num of selected nodes 
        h_text_num_nodes_selected=findobj('tag','text_num_nodes_selected'); 
        set(h_text_num_nodes_selected,'string','0'); 
         
        guidata(hObject,handles); 
    end 
end 
 
% --- apply_constrains 
function handles = apply_constrains(nodes_index_array, dofs, handles) 
% node_index_array=[x1 x2 ... xn   
%                   y1 y2 ... yn] 
% dof = [0 1]-Ux     [1 0]-Uy    [0 0]-UxUy 
 
% handles.fixeddofs=[u1 v1 u2 v2 ...]; 
 
% handles.fixeddofs_patch3=[ h_patch1 h_patch2 ... h_patchN] 
 
index_selected_nodes=IJ2index(nodes_index_array, handles); 
 
% Update fixed dofs 
if(all(dofs==[0 1])) % Ux fixed 
    dofs_fixed=2*index_selected_nodes-1; 
    handles.fixeddofs=unique([handles.fixeddofs dofs_fixed]); % unique also sorts it in asc 
elseif(all(dofs==[1 0])) 
    dofs_fixed=2*index_selected_nodes; 
    handles.fixeddofs=unique([handles.fixeddofs dofs_fixed]); % unique also sorts it in asc 
elseif(all(dofs==[0 0])) 
    dofs_fixed=[2*index_selected_nodes-1 2*index_selected_nodes]; 
    handles.fixeddofs=unique([handles.fixeddofs dofs_fixed]); % unique also sorts it in asc 
end 
 
% Redraw constrain symbols 
if(length(handles.fixeddofs)>0) 
    delete(handles.fixeddofs_patch3); % delete old patchs 
end 
handles.fixeddofs_patch3=[]; % initial patchs 
 
num_dofs=length(handles.fixeddofs); 
num_ux=0; % number of Ux constrains 
num_uy=0; % number of Uy constrains 
for i=1:num_dofs 
    index_dof=handles.fixeddofs(i); 
    if(mod(index_dof,2)==1) % Ux 
        idof=1; 
        num_ux=num_ux+1; 
        inode=(index_dof+1)/2; 
    else % Uy 
        idof=2; 
        num_uy=num_uy+1; 
        inode=index_dof/2; 
    end 
    y=mod(inode,handles.nely+1); 
    x=(inode-y)/(handles.nely+1)+1; 
    if y==0 
        y=handles.nely+1; 
        x=x-1; 
    end 
    handles.fixeddofs_patch3=[handles.fixeddofs_patch3 patch3(x,y,idof,handles)]; 
end 
 
% Update constrain number 
h_num_constrained_ux=findobj('tag','text_num_constrained_ux'); 
h_num_constrained_uy=findobj('tag','text_num_constrained_uy'); 
 
set(h_num_constrained_ux,'string',num2str(num_ux)); 
set(h_num_constrained_uy,'string',num2str(num_uy)); 
     
% Save handles 
guidata(gcbo,handles); 
 
% End of function apply_constrains 
 
% --- Get node index in FEA by (i,j) 
function index=IJ2index(nodes_index_array, handles) 
% nodes_index_array=[x1 x2 ... xn   
%                    y1 y2 ... yn] 
 
index=zeros(1,size(nodes_index_array,2)); 
 
I=nodes_index_array(1,:); 
J=nodes_index_array(2,:); 
 
index=sort((handles.nely+1)*(I-1)+J); 
 
 
% ******************* Rri_patch ******************** % 
function h=patch3(x,y,dof,handles) 
% Draw Constrain triangle 
% [x y] - Coordinates of constrained node 
% dof - 1=Ux fixed  2=Uy fixed 
 
height=handles.constrain_triangle_height; %底边上的高 
len_base=handles.constrain_triangle_width; %底边长 
switch dof 
    case 1 % Ux fixed 
        x1=x-height; 
        x2=x-height; 
        y1=y-0.5*len_base; 
        y2=y+0.5*len_base; 
    case 2 % Uy fixed 
        x1=x-0.5*len_base; 
        x2=x+0.5*len_base; 
        y1=y+height; 
        y2=y+height; 
end 
 
h=patch([x x1 x2],[y y1 y2],'r'); 
set(h,'Facecolor',handles.constrain_triangle_FaceColor); % patch's face is transparent 
set(h,'linewidth',handles.constrain_triangle_LineWidth); % line width of patch edge 
 
function handles = apply_forces(nodes_index_array, dof, force, handles); 
% node_index_array=[x1 x2 ... xn   
%                   y1 y2 ... yn] 
index_selected_nodes = IJ2index(nodes_index_array, handles); 
switch dof 
    case 1 % Fx 
        dofs_force=2*index_selected_nodes-1; 
    case 2 % Fy 
        dofs_force=2*index_selected_nodes; 
    otherwise 
        return; 
end 
 
% Update F 
handles.F(dofs_force)=handles.F(dofs_force) + force; 
 
% Redraw forces 
  % delete old arrows 
  delete(handles.F_arrow);     
   
  % initialize handle array 
  handles.F_arrow=[];  
   
  index_dofs=find(handles.F~=0); % non-zero element in sparse handles.F 
  n=length(index_dofs); 
   
  num_fx = 0; 
  num_fy = 0; 
  for i=1:n 
      idof=index_dofs(i); 
      force=handles.F(idof); 
      if(mod(idof,2)==0) % Fy 
          num_fy=num_fy+1; 
          inode=idof/2; 
          if(force<0) 
              dof=-2; 
          else 
              dof=+2; 
          end 
      else % Fx 
          num_fx=num_fx+1; 
          inode=(idof+1)/2; 
          if(force<0) 
              dof=-1; 
          else 
              dof=+1; 
          end 
      end 
       
      y=mod(inode,handles.nely+1); 
      x=(inode-y)/(handles.nely+1)+1; 
      if y==0 
            y=handles.nely+1; 
            x=x-1; 
      end 
       
      [h_line,h_arrow] = drawF(x,y,dof,handles); 
      handles.F_arrow=[handles.F_arrow [h_line h_arrow]']; 
       
  end % end loop for all non-zero elements in handles.F 
   
% Update force number 
h_num_force_fx=findobj('tag','text_num_force_fx'); 
h_num_force_fy=findobj('tag','text_num_force_fy'); 
 
set(h_num_force_fx,'string',num2str(num_fx)); 
set(h_num_force_fy,'string',num2str(num_fy)); 
   
% Save handles 
guidata(gcbo,handles); 
   
% --- DrawF 
function [h_line,h_patch]=drawF(x,y,dof,handles) 
% Draw Forces 以节点[x y]为起点 作箭头(arrow=line+patch) 
% [x y] - Coordinates of Node 
% dof :  1=Fx>0  -1=Fx<0   2=Fy>0 -2=Fy<0 
%% 用带箭头的直线连接两点 起点(x1,y1)-->终点(x2,y2) 
 
len = handles.force_arrow_line_length; % line 的长度 
 
width_arrow = handles.force_arrow_patch_width; %箭头底边宽度 
height_arrow = handles.force_arrow_patch_height; %箭头长度 
 
x1=x; 
y1=y; 
 
switch dof 
    case -1 % Fx<0 
        x2=x1-len; 
        y2=y1; 
         
        p1_x=x2-height_arrow; 
        p1_y=y2; 
         
        p2_x=x2; 
        p3_x=x2; 
         
        p2_y=y2-0.5*width_arrow; 
        p3_y=y2+0.5*width_arrow; 
         
    case +1 % Fx>0 
        x2=x1+len; 
        y2=y1; 
         
        p1_x=x2+height_arrow; 
        p1_y=y2; 
         
        p2_x=x2; 
        p3_x=x2; 
         
        p2_y=y2-0.5*width_arrow; 
        p3_y=y2+0.5*width_arrow; 
    case -2 % Fy<0 
        x2=x1; 
        y2=y1-len; 
         
        p1_x=x2; 
        p1_y=y2-height_arrow; 
         
        p2_y=y2; 
        p3_y=y2; 
         
        p2_x=x2-0.5*width_arrow; 
        p3_x=x2+0.5*width_arrow; 
         
    case 2 % Fy 
        x2=x1; 
        y2=y1+len; 
         
        p1_x=x2; 
        p1_y=y2+height_arrow; 
         
        p2_y=y2; 
        p3_y=y2; 
         
        p2_x=x2-0.5*width_arrow; 
        p3_x=x2+0.5*width_arrow; 
end 
 
h_line=line([x1 x2],[y1 y2]); 
set(h_line,'color',handles.force_arrow_line_color); 
set(h_line,'LineWidth',handles.force_arrow_line_width); 
 
h_patch=patch([p1_x p2_x p3_x],[p1_y p2_y p3_y],handles.force_arrow_patch_facecolor); 
set(h_patch,'EdgeColor',handles.force_arrow_patch_edgecolor);


% --- Executes on mouse motion over figure - except title and menu.
function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA) 
 
handles = guidata(gcbo); 
 
h_figure=hObject; 
h_axes=gca; 
 
 
units_figure = get(h_figure,'units'); 
units_axes   = get(h_axes,'units'); 
 
if_units_consistent = 1; 
 
if ~strcmp(units_figure,units_axes) 
    if_units_consistent=0; 
    set(h_axes,'units',units_figure); % To be sure that units of figure and axes are consistent 
end 
 
% Check if cusor on axes 
pos_axes=get(gca,'position'); % [left bottom width height] 
pos_cursor=get(hObject,'currentpoint'); % [left bottom] 
 
 
% If on homepage, change cursor to hand 
%     h_homepage=findobj('tag','text_homepage'); 
%     pos_homepage=get(h_homepage,'position'); 
%     if_cursor_on_homepage = ( pos_cursor(1) > pos_homepage(1) & pos_cursor(1) < pos_homepage(1) + pos_homepage(3) &  ... 
%      pos_cursor(2) > pos_homepage(2) & pos_cursor(2) < pos_homepage(2) + pos_homepage(4) ); 
%     pos_cursor 
%     [pos_cursor(1)>pos_homepage(1) pos_cursor(1)pos_homepage(2) pos_cursor(2) pos_axes(1) + pos_axes(3) |  ... 
    pos_cursor(2) < pos_axes(2) | pos_cursor(2) > pos_axes(2) + pos_axes(4) ) 
    return; 
  end 
 
% Recover units of axes,if original units of figure and axes are not consistent. 
if ~if_units_consistent 
    set(h_axes,'units',units_axes);  
end 
 
% Below : Cursor on axes 
 
[x,y]=gpos(gca); 
 
i_node=round(x); 
i_node=max(1,i_node); 
i_node=min(handles.nelx+1,i_node); 
 
j_node=round(y); 
j_node=max(1,j_node); 
j_node=min(handles.nely+1,j_node); 
 
i_elem=floor(x); 
i_elem=max(1,i_elem); 
i_elem=min(handles.nelx,i_elem); 
 
j_elem=floor(y); 
j_elem=max(1,j_elem); 
j_elem=min(handles.nely,j_elem); 
 
% Update current position 
% Current node 
h_node_x=findobj('tag','text_node_x'); 
h_node_y=findobj('tag','text_node_y'); 
 
set(h_node_x,'string',num2str(i_node)); 
set(h_node_y,'string',num2str(j_node)); 
 
%  Current element 
h_elem_i=findobj('tag','text_elem_i'); 
h_elem_j=findobj('tag','text_elem_j'); 
 
set(h_elem_i,'string',num2str(i_elem)); 
set(h_elem_j,'string',num2str(j_elem)); 
 
% If in picking mode 
if handles.if_picking      
    x1=handles.pt1(1); 
    y1=handles.pt1(2); 
     
    x3=x; 
    y3=y;     
     
    handles.pt3(1)=x3; 
    handles.pt3(2)=y3; 
     
    xdata=[x1 x1 x3 x3 x1]; 
    ydata=[y1 y3 y3 y1 y1]; 
     
    if handles.h_rect>0     
        set(handles.h_rect,'XData',xdata,'YData',ydata,'Visible','on'); 
    end 
end 
 
guidata(gcbo,handles); 
 
 
function [x,y]=gpos(h_axes) 
%GPOS Get current position of cusor and return its coordinates in axes with handle h_axes 
% h_axes - handle of specified axes 
% [x,y]  - cursor coordinates in axes h_aexs 
 
h_figure=gcf; 
 
units_figure = get(h_figure,'units'); 
units_axes   = get(h_axes,'units'); 
 
if_units_consistent = 1; 
 
if ~strcmp(units_figure,units_axes) 
    if_units_consistent=0; 
    set(h_axes,'units',units_figure); % To be sure that units of figure and axes are consistent 
end 
 
% Position of origin in figure [left bottom] 
pos_axes_unitfig    = get(h_axes,'position'); 
width_axes_unitfig  = pos_axes_unitfig(3); 
height_axes_unitfig = pos_axes_unitfig(4); 
 
xDir_axes=get(h_axes,'XDir'); 
yDir_axes=get(h_axes,'YDir'); 
 
% Cursor position in figure 
pos_cursor_unitfig = get( h_figure, 'currentpoint'); % [left bottom] 
 
if strcmp(xDir_axes,'normal') 
    left_origin_unitfig = pos_axes_unitfig(1); 
    x_cursor2origin_unitfig = pos_cursor_unitfig(1) - left_origin_unitfig; 
else 
    left_origin = pos_axes_unitfig(1) + width_axes_unitfig; 
    x_cursor2origin_unitfig = -( pos_cursor_unitfig(1) - left_origin_unitfig ); 
end 
 
if strcmp(yDir_axes,'normal') 
    bottom_origin_unitfig     = pos_axes_unitfig(2); 
    y_cursor2origin_unitfig = pos_cursor_unitfig(2) - bottom_origin_unitfig; 
else 
    bottom_origin_unitfig = pos_axes_unitfig(2) + height_axes_unitfig; 
    y_cursor2origin_unitfig = -( pos_cursor_unitfig(2) - bottom_origin_unitfig ); 
end 
 
xlim_axes=get(h_axes,'XLim'); 
width_axes_unitaxes=xlim_axes(2)-xlim_axes(1); 
 
ylim_axes=get(h_axes,'YLim'); 
height_axes_unitaxes=ylim_axes(2)-ylim_axes(1); 
 
x = xlim_axes(1) + x_cursor2origin_unitfig / width_axes_unitfig * width_axes_unitaxes; 
y = ylim_axes(1) + y_cursor2origin_unitfig / height_axes_unitfig * height_axes_unitaxes; 
 
% Recover units of axes,if original units of figure and axes are not consistent. 
if ~if_units_consistent 
    set(h_axes,'units',units_axes);  
end


% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function figure1_WindowButtonUpFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA) 
handles = guidata(gcbo); 
if handles.if_picking
	handles.if_picking=0; 
    if handles.h_rect>0 
        delete(handles.h_rect); 
    end     
     
    handles.h_rect=0;     
    set(gcf,'Pointer','arrow'); 
    set(gcf,'userdata','ButtonUp'); 
	guidata(gcbo,handles); 
end

% % --- Executes on mouse press over axes background.
% function axes1_ButtonDownFcn(hObject, eventdata, handles)
% % hObject    handle to axes1 (see GCBO)
% % eventdata  reserved - to be defined in a future version of MATLAB
% % handles    structure with handles and user data (see GUIDATA) 
%  
% if handles.if_picking
% 	[x,y]=gpos(gca); 
%     handles.pt1=[x,y]; 
% 	set(gcf,'userdata','ButtonDown'); 
% 	guidata(gcbo,handles); 
% end 
     
% --- check if any nodes are selected when apply/cancel constrains or forces 
function if_nodes = if_nodes_selected( handles ) 
if_nodes = 1; 
if ( length( handles.selected_nodes ) == 0 ) 
    if_nodes = 0; 
    h = msgbox('No nodes selected!','Error!','error','modal'); 
    waitfor(h); % Wait until dialog is deleted 
end

% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function figure1_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA) 
if handles.if_picking    
    str_sel_type = get(gcf,'SelectionType');     
    if strcmp(str_sel_type , 'normal')         
        [x,y]=gpos(gca); 
        handles.pt1=[x,y]; 
        set(gcf,'userdata','ButtonDown');;         
    elseif strcmp(str_sel_type , 'alt') % Right click and quit the piking mode 
        handles.if_picking = 0; 
        set( gcf, 'Pointer', 'arrow'); 
    end 
end 
guidata(gcbo,handles);


% --- Executes on button press in pushbutton_homepage.
function pushbutton_homepage_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_homepage (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

web http://www.geocities.com/chinakkong/research/topgui/ -browser
 
 
% --- Creates and returns a handle to the GUI figure.  
function h1 = topgui_LayoutFcn(policy) 
% policy - create a new figure or use a singleton. 'new' or 'reuse'. 
 
persistent hsingleton; 
if strcmpi(policy, 'reuse') & ishandle(hsingleton) 
    h1 = hsingleton; 
    return; 
end 
 
h1 = figure(... 
'Units','normalized',... 
'PaperUnits','normalized',... 
'Color',[0 0.501960784313725 0.752941176470588],... 
'Colormap',[0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0],... 
'IntegerHandle','off',... 
'InvertHardcopy',get(0,'defaultfigureInvertHardcopy'),... 
'MenuBar','none',... 
'Name','TopGUI V1.0',... 
'NumberTitle','off',... 
'PaperPosition',[0.0119243429653489 0.0842781102631165 0.381578974891164 0.20226746463148],... 
'PaperSize',[1 1],... 
'PaperType',get(0,'defaultfigurePaperType'),... 
'Position',[0.048828125 0.0846354166666667 0.88671875 0.838541666666667],... 
'Renderer',get(0,'defaultfigureRenderer'),... 
'RendererMode','manual',... 
'WindowButtonDownFcn','topgui(''figure1_WindowButtonDownFcn'',gcbo,[],guidata(gcbo))',... 
'HandleVisibility','callback',... 
'Interruptible','off',... 
'Tag','figure1',... 
'UserData',zeros(1,0)); 
 
setappdata(h1, 'GUIDEOptions', struct(... 
'active_h', 1.650060e+002, ... 
'taginfo', struct(... 
'figure', 2, ... 
'axes', 2, ... 
'text', 52, ... 
'pushbutton', 11, ... 
'togglebutton', 4, ... 
'popupmenu', 4, ... 
'frame', 8, ... 
'checkbox', 2, ... 
'edit', 2), ... 
'override', 0, ... 
'release', 13, ... 
'resize', 'none', ... 
'accessibility', 'callback', ... 
'mfile', 1, ... 
'callbacks', 1, ... 
'singleton', 1, ... 
'syscolorfig', 1, ... 
'lastSavedFile', 'D:\program\matlab\work\vtop\gui.m')); 
 
 
h2 = axes(... 
'Parent',h1,... 
'CameraPosition',[0.5 0.5 9.16025403784439],... 
'CameraPositionMode',get(0,'defaultaxesCameraPositionMode'),... 
'Color',get(0,'defaultaxesColor'),... 
'ColorOrder',get(0,'defaultaxesColorOrder'),... 
'NextPlot','add',... 
'Position',[0.0253303964757709 0.279503105590062 0.814977973568283 0.687888198757764],... 
'XColor',get(0,'defaultaxesXColor'),... 
'XAxisLocation','top',... 
'YColor',get(0,'defaultaxesYColor'),... 
'YDir','reverse',... 
'ZColor',get(0,'defaultaxesZColor'),... 
'Tag','axes1'); 
 
 
h3 = get(h2,'title'); 
 
set(h3,... 
'Parent',h2,... 
'Color',[0 0 0],... 
'HorizontalAlignment','center',... 
'Position',[0.499324324324324 -0.0620767494356658 1.00005459937205],... 
'VerticalAlignment','bottom',... 
'HandleVisibility','off'); 
 
h4 = get(h2,'xlabel'); 
 
set(h4,... 
'Parent',h2,... 
'Color',[0 0 0],... 
'HorizontalAlignment','center',... 
'Position',[0.499324324324324 -0.0485327313769752 1.00005459937205],... 
'VerticalAlignment','bottom',... 
'HandleVisibility','off'); 
 
h5 = get(h2,'ylabel'); 
 
set(h5,... 
'Parent',h2,... 
'Color',[0 0 0],... 
'HorizontalAlignment','center',... 
'Position',[-0.0385135135135135 0.502257336343115 1.00005459937205],... 
'Rotation',90,... 
'VerticalAlignment','bottom',... 
'HandleVisibility','off'); 
 
h6 = get(h2,'zlabel'); 
 
set(h6,... 
'Parent',h2,... 
'Color',[0 0 0],... 
'HorizontalAlignment','right',... 
'Position',[-0.0317567567567568 -0.0440180586907448 1.00005459937205],... 
'HandleVisibility','off',... 
'Visible','off'); 
 
h7 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.0867208672086721,... 
'ListboxTop',0,... 
'Position',[0.00770925110132159 0.0698757763975155 0.302863436123348 0.177018633540373],... 
'String',{ '' },... 
'Style','frame',... 
'Tag','frame2'); 
 
 
h8 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0 0.627450980392157],... 
'FontSize',0.55,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'ListboxTop',0,... 
'Position',[0.0198237885462555 0.226708074534161 0.131057268722467 0.0326086956521739],... 
'String','Selecting Nodes',... 
'Style','text',... 
'Tag','text1'); 
 
 
h9 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.250980392156863 0.250980392156863],... 
'Callback','topgui(''pushbutton_selNodes_inp_Callback'',gcbo,[],guidata(gcbo))',... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[0.752941176470588 0.752941176470588 0.752941176470588],... 
'ListboxTop',0,... 
'Max',3,... 
'Position',[0.168502202643172 0.0978260869565217 0.0594713656387665 0.0372670807453416],... 
'String','Input',... 
'TooltipString','Input nodes index in Matlab vector format.',... 
'Tag','pushbutton_selNodes_inp'); 
 
 
h10 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0.501960784313725 0 0.250980392156863],... 
'Callback','topgui(''pushbutton_SelNodes_pick_Callback'',gcbo,[],guidata(gcbo))',... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[0.752941176470588 0.752941176470588 0.752941176470588],... 
'ListboxTop',0,... 
'Position',[0.241189427312775 0.0978260869565217 0.0594713656387665 0.0372670807453416],... 
'String','Pick',... 
'TooltipString','Pick nodes by mouse in GUI.',... 
'Tag','pushbutton_SelNodes_pick'); 
 
 
h11 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[1 1 1],... 
'FontSize',0.592592592592593,... 
'ListboxTop',0,... 
'Position',[0.168502202643172 0.156832298136646 0.0759911894273128 0.0357142857142857],... 
'String',{ 'New' 'Add' },... 
'Style','popupmenu',... 
'TooltipString','New - starting a new selection.  Add - Adding nodes to previous selection.',... 
'Value',1,... 
'CreateFcn','topgui(''popupmenu_select_type_CreateFcn'',gcbo,[],guidata(gcbo))',... 
'Tag','popupmenu_select_type'); 
 
 
h12 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'ListboxTop',0,... 
'Position',[0.843612334801763 0.708074534161491 0.14647577092511 0.236024844720497],... 
'String',{ '' },... 
'Style','frame',... 
'Tag','frame3'); 
 
 
h13 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0 0.627450980392157],... 
'CData',zeros(1,0),... 
'FontSize',0.6,... 
'FontWeight','bold',... 
'ForegroundColor',[0.501960784313725 1 0],... 
'ListboxTop',0,... 
'Position',[0.866740088105728 0.933229813664596 0.105726872246696 0.0279503105590062],... 
'String','Current position',... 
'Style','text',... 
'Tag','text8',... 
'UserData',zeros(1,0)); 
 
 
h14 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'ListboxTop',0,... 
'Position',[0.844713656387665 0.321428571428571 0.143171806167401 0.341614906832298],... 
'String',{ '' },... 
'Style','frame',... 
'Tag','frame4'); 
 
 
h15 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0 0.627450980392157],... 
'CData',zeros(1,0),... 
'FontSize',0.7,... 
'FontWeight','bold',... 
'ForegroundColor',[0.501960784313725 1 0],... 
'ListboxTop',0,... 
'Position',[0.857929515418502 0.650621118012422 0.0991189427312775 0.0279503105590062],... 
'String','Summary',... 
'Style','text',... 
'Tag','text9',... 
'UserData',zeros(1,0)); 
 
 
h16 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'HorizontalAlignment','left',... 
'ListboxTop',0,... 
'Position',[0.852422907488987 0.897515527950311 0.0506607929515419 0.0326086956521739],... 
'String','Node :',... 
'Style','text',... 
'Tag','text10'); 
 
 
h17 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.6,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'ListboxTop',0,... 
'Position',[0.851321585903084 0.87111801242236 0.0374449339207049 0.0279503105590062],... 
'String','x = ',... 
'Style','text',... 
'Tag','text11'); 
 
 
h18 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.6,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'ListboxTop',0,... 
'Position',[0.851321585903084 0.843167701863354 0.0374449339207049 0.0279503105590062],... 
'String','y = ',... 
'Style','text',... 
'Tag','text12'); 
 
 
h19 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.6,... 
'ForegroundColor',[1 1 0],... 
'ListboxTop',0,... 
'Position',[0.879955947136565 0.87111801242236 0.0330396475770925 0.0279503105590062],... 
'String','1',... 
'Style','text',... 
'Interruptible','off',... 
'Tag','text_node_x'); 
 
 
h20 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.507936507936508,... 
'ForegroundColor',[1 1 1],... 
'HorizontalAlignment','left',... 
'ListboxTop',0,... 
'Position',[0.920704845814978 0.869565217391304 0.0605726872246696 0.0326086956521739],... 
'String','(1:nelx+1)',... 
'Style','text',... 
'Tag','text_lim_x'); 
 
 
h21 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.6,... 
'ForegroundColor',[1 1 0],... 
'ListboxTop',0,... 
'Position',[0.879955947136565 0.840062111801242 0.0319383259911894 0.0279503105590062],... 
'String','1',... 
'Style','text',... 
'Interruptible','off',... 
'Tag','text_node_y'); 
 
 
h22 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.627450980392157,... 
'ForegroundColor',[1 1 1],... 
'HorizontalAlignment','left',... 
'ListboxTop',0,... 
'Position',[0.920704845814978 0.841614906832298 0.0594713656387665 0.0263975155279503],... 
'String','(1:nely+1)',... 
'Style','text',... 
'Tag','text_lim_y'); 
 
 
h23 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'HorizontalAlignment','left',... 
'ListboxTop',0,... 
'Position',[0.852422907488987 0.793478260869565 0.0859030837004405 0.0372670807453416],... 
'String','Element :',... 
'Style','text',... 
'Tag','text17'); 
 
 
h24 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.6,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'ListboxTop',0,... 
'Position',[0.855726872246696 0.763975155279503 0.0341409691629956 0.0326086956521739],... 
'String','i = ',... 
'Style','text',... 
'Tag','text18'); 
 
 
h25 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.6,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'ListboxTop',0,... 
'Position',[0.8568281938326 0.722049689440994 0.0330396475770925 0.0357142857142857],... 
'String','j = ',... 
'Style','text',... 
'Tag','text20'); 
 
 
h26 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.6,... 
'ForegroundColor',[1 1 0],... 
'ListboxTop',0,... 
'Position',[0.879955947136564 0.763975155279503 0.0319383259911894 0.0279503105590062],... 
'String','1',... 
'Style','text',... 
'Interruptible','off',... 
'Tag','text_elem_i'); 
 
 
h27 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.6,... 
'ForegroundColor',[1 1 0],... 
'ListboxTop',0,... 
'Position',[0.879955947136564 0.728260869565217 0.0319383259911894 0.0279503105590062],... 
'String','1',... 
'Style','text',... 
'Interruptible','off',... 
'Tag','text_elem_j'); 
 
 
h28 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'CData',zeros(1,0),... 
'FontSize',0.711111111111111,... 
'ForegroundColor',[1 1 1],... 
'HorizontalAlignment','left',... 
'ListboxTop',0,... 
'Position',[0.920704845814978 0.770186335403727 0.0605726872246696 0.0232919254658385],... 
'String','(1:nelx)',... 
'Style','text',... 
'Tag','text_lim_i',... 
'UserData',zeros(1,0)); 
 
 
h29 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.507936507936508,... 
'ForegroundColor',[1 1 1],... 
'HorizontalAlignment','left',... 
'ListboxTop',0,... 
'Position',[0.920704845814978 0.720496894409938 0.0572687224669604 0.0326086956521739],... 
'String','(1:nely)',... 
'Style','text',... 
'Tag','text_lim_j'); 
 
 
h30 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.4,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'HorizontalAlignment','left',... 
'ListboxTop',0,... 
'Position',[0.851321585903084 0.597826086956522 0.121145374449339 0.0450310559006211],... 
'String','Selected  nodes :',... 
'Style','text',... 
'Tag','text26'); 
 
 
h31 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.627450980392157,... 
'ForegroundColor',[1 1 0],... 
'ListboxTop',0,... 
'Position',[0.895374449339208 0.577639751552795 0.0352422907488987 0.0279503105590062],... 
'String','0',... 
'Style','text',... 
'Tag','text_num_nodes_selected'); 
 
 
h32 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.56140350877193,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'HorizontalAlignment','left',... 
'ListboxTop',0,... 
'Position',[0.851321585903084 0.529503105590062 0.133259911894273 0.0326086956521739],... 
'String','Constrained dofs :',... 
'Style','text',... 
'Tag','text29'); 
 
 
h33 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.711111111111111,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'ListboxTop',0,... 
'Position',[0.874449339207049 0.506211180124224 0.051762114537445 0.0232919254658385],... 
'String','Ux :',... 
'Style','text',... 
'Tag','text30'); 
 
 
h34 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.7,... 
'ForegroundColor',[1 1 0],... 
'ListboxTop',0,... 
'Position',[0.919603524229075 0.501552795031056 0.0594713656387665 0.0232919254658385],... 
'String','0',... 
'Style','text',... 
'Tag','text_num_constrained_ux'); 
 
 
h35 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.711111111111111,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'ListboxTop',0,... 
'Position',[0.874449339207049 0.462732919254658 0.051762114537445 0.0232919254658385],... 
'String','Uy :',... 
'Style','text',... 
'Tag','text32'); 
 
 
h36 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'CData',zeros(1,0),... 
'FontSize',0.7,... 
'ForegroundColor',[1 1 0],... 
'ListboxTop',0,... 
'Position',[0.920704845814978 0.462732919254658 0.0594713656387665 0.0232919254658385],... 
'String','0',... 
'Style','text',... 
'Tag','text_num_constrained_uy',... 
'UserData',zeros(1,0)); 
 
 
h37 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.56140350877193,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'HorizontalAlignment','left',... 
'ListboxTop',0,... 
'Position',[0.851321585903084 0.409937888198758 0.118942731277533 0.0326086956521739],... 
'String','Forces of dofs:',... 
'Style','text',... 
'Tag','text35'); 
 
 
h38 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.711111111111111,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'ListboxTop',0,... 
'Position',[0.875550660792952 0.386645962732919 0.051762114537445 0.0232919254658385],... 
'String','Fx :',... 
'Style','text',... 
'Tag','text36'); 
 
 
h39 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.711111111111111,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'ListboxTop',0,... 
'Position',[0.875550660792952 0.352484472049689 0.051762114537445 0.0232919254658385],... 
'String','Fy :',... 
'Style','text',... 
'Tag','text37'); 
 
 
h40 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.666666666666667,... 
'ForegroundColor',[1 1 0],... 
'ListboxTop',0,... 
'Position',[0.919603524229075 0.386645962732919 0.0594713656387665 0.0232919254658385],... 
'String','0',... 
'Style','text',... 
'Tag','text_num_force_fx'); 
 
 
h41 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.666666666666667,... 
'ForegroundColor',[1 1 0],... 
'ListboxTop',0,... 
'Position',[0.919603524229075 0.349378881987578 0.0594713656387665 0.0232919254658385],... 
'String','0',... 
'Style','text',... 
'Tag','text_num_force_fy'); 
 
 
h42 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0.501960784313725 0 0.250980392156863],... 
'Callback','topgui(''pushbutton_OK_Callback'',gcbo,[],guidata(gcbo))',... 
'FontSize',0.55,... 
'FontWeight','bold',... 
'ForegroundColor',[0.752941176470588 0.752941176470588 0.752941176470588],... 
'ListboxTop',0,... 
'Position',[0.878854625550661 0.0900621118012422 0.106828193832599 0.0496894409937888],... 
'String','Finish >>',... 
'TooltipString','Finish input and start optimization.',... 
'Tag','pushbutton_OK'); 
 
 
h43 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'CData',zeros(1,0),... 
'FontSize',0.6,... 
'FontWeight','bold',... 
'ForegroundColor',[0 1 0.250980392156863],... 
'HorizontalAlignment','right',... 
'ListboxTop',0,... 
'Position',[0.0374449339207049 0.156832298136646 0.123348017621145 0.0326086956521739],... 
'String','Selection type :',... 
'Style','text',... 
'TooltipString','New - starting a new selection.  Add - Adding nodes to previous selection.',... 
'Tag','text43',... 
'UserData',zeros(1,0)); 
 
 
h44 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'CData',zeros(1,0),... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[0.501960784313725 1 0],... 
'HorizontalAlignment','right',... 
'ListboxTop',0,... 
'Position',[0.013215859030837 0.093167701863354 0.147577092511013 0.0403726708074534],... 
'String','Selecting method :',... 
'Style','text',... 
'TooltipString','Input - Input nodes index in Matlab vector format..  Pick - PIck nodes by mouse in GUI..',... 
'Tag','text44',... 
'UserData',zeros(1,0)); 
 
 
h45 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.0867208672086721,... 
'ListboxTop',0,... 
'Position',[0.325991189427313 0.0714285714285714 0.257709251101322 0.175465838509317],... 
'String',{ '' },... 
'Style','frame',... 
'Tag','frame6'); 
 
 
h46 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0 0.627450980392157],... 
'FontSize',0.55,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'ListboxTop',0,... 
'Position',[0.33920704845815 0.229813664596273 0.158590308370044 0.0326086956521739],... 
'String','Apply/Clear Constrains ',... 
'Style','text',... 
'Tag','text3'); 
 
 
h47 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[1 1 1],... 
'FontSize',0.56140350877193,... 
'ListboxTop',0,... 
'Position',[0.436123348017621 0.158385093167702 0.0770925110132159 0.0372670807453416],... 
'String',{ 'Ux' 'Uy' 'Ux,Uy' },... 
'Style','popupmenu',... 
'Value',1,... 
'CreateFcn','topgui(''popupmenu_constrain_type_CreateFcn'',gcbo,[],guidata(gcbo))',... 
'Tag','popupmenu_constrain_type'); 
 
 
h48 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0.501960784313725 0 0.250980392156863],... 
'Callback','topgui(''pushbutton_constrain_apply_Callback'',gcbo,[],guidata(gcbo))',... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[0.752941176470588 0.752941176470588 0.752941176470588],... 
'ListboxTop',0,... 
'Position',[0.436123348017621 0.093167701863354 0.0594713656387665 0.0372670807453416],... 
'String','Apply',... 
'TooltipString','Apply specified constrains on selected nodes.',... 
'Tag','pushbutton_constrain_apply'); 
 
 
h49 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0.501960784313725 0 0.250980392156863],... 
'Callback','topgui(''pushbutton_constrain_clear_Callback'',gcbo,[],guidata(gcbo))',... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[0.752941176470588 0.752941176470588 0.752941176470588],... 
'ListboxTop',0,... 
'Position',[0.511013215859031 0.093167701863354 0.0594713656387665 0.0372670807453416],... 
'String','Clear',... 
'TooltipString','Clear the specified constrains on selected ndoes.',... 
'Tag','pushbutton_constrain_clear'); 
 
 
h50 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'CData',zeros(1,0),... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[0.501960784313725 1 0],... 
'HorizontalAlignment','right',... 
'ListboxTop',0,... 
'Position',[0.361233480176212 0.150621118012422 0.0616740088105727 0.0434782608695652],... 
'String','Dof :',... 
'Style','text',... 
'Tag','text45',... 
'UserData',zeros(1,0)); 
 
 
h51 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'CData',zeros(1,0),... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[0.501960784313725 1 0],... 
'HorizontalAlignment','right',... 
'ListboxTop',0,... 
'Position',[0.333700440528635 0.0869565217391304 0.0892070484581498 0.0403726708074534],... 
'String','Operation :',... 
'Style','text',... 
'Tag','text46',... 
'UserData',zeros(1,0)); 
 
 
h52 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'FontSize',0.0927536231884058,... 
'ListboxTop',0,... 
'Position',[0.598017621145374 0.0698757763975155 0.262114537444934 0.177018633540373],... 
'String',{ '' },... 
'Style','frame',... 
'Tag','frame7'); 
 
 
h53 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[1 1 1],... 
'FontSize',0.6,... 
'ListboxTop',0,... 
'Position',[0.70704845814978 0.166149068322981 0.0759911894273128 0.0357142857142857],... 
'String',{ 'Fx' 'Fy' },... 
'Style','popupmenu',... 
'Value',1,... 
'CreateFcn','topgui(''popupmenu_force_type_CreateFcn'',gcbo,[],guidata(gcbo))',... 
'Tag','popupmenu_force_type'); 
 
 
h54 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0.501960784313725 0 0.250980392156863],... 
'Callback','topgui(''pushbutton_force_apply_Callback'',gcbo,[],guidata(gcbo))',... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[0.752941176470588 0.752941176470588 0.752941176470588],... 
'ListboxTop',0,... 
'Position',[0.708149779735683 0.0978260869565217 0.0550660792951542 0.0357142857142857],... 
'String','Apply',... 
'TooltipString','Apply specified forces on selected nodes.',... 
'Tag','pushbutton_force_apply'); 
 
 
h55 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0.501960784313725 0 0.250980392156863],... 
'Callback','topgui(''pushbutton_force_clear_Callback'',gcbo,[],guidata(gcbo))',... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[0.752941176470588 0.752941176470588 0.752941176470588],... 
'ListboxTop',0,... 
'Position',[0.784140969162996 0.0978260869565217 0.0550660792951542 0.0357142857142857],... 
'String','Clear',... 
'TooltipString','Clear specified forces on selected nodes.',... 
'Tag','pushbutton_force_clear'); 
 
 
h56 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0 0.627450980392157],... 
'FontSize',0.55,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 1],... 
'ListboxTop',0,... 
'Position',[0.611233480176211 0.231366459627329 0.143171806167401 0.0326086956521739],... 
'String','Apply/Clear Forces ',... 
'Style','text',... 
'Tag','text5'); 
 
 
h57 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'CData',zeros(1,0),... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[0.501960784313725 1 0],... 
'HorizontalAlignment','right',... 
'ListboxTop',0,... 
'Position',[0.650881057268722 0.153726708074534 0.0440528634361234 0.0434782608695652],... 
'String','Dof :',... 
'Style','text',... 
'Tag','text47',... 
'UserData',zeros(1,0)); 
 
 
h58 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'CData',zeros(1,0),... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[0.501960784313725 1 0],... 
'HorizontalAlignment','right',... 
'ListboxTop',0,... 
'Position',[0.609030837004405 0.0947204968944099 0.0859030837004405 0.0372670807453416],... 
'String','Operation :',... 
'Style','text',... 
'Tag','text48',... 
'UserData',zeros(1,0)); 
 
 
h59 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0 0.501960784313725 0.752941176470588],... 
'CData',zeros(1,0),... 
'FontSize',0.55,... 
'ListboxTop',0,... 
'Position',[0.259911894273128 0.0124223602484472 0.412995594713657 0.0326086956521739],... 
'String','Written by Kang Zhao.  E-mail : kangzhao @ student.dlut.edu.cn',... 
'Style','text',... 
'ButtonDownFcn','topgui(''text_email_ButtonDownFcn'',gcbo,[],guidata(gcbo))',... 
'Tag','text_email',... 
'UserData',zeros(1,0)); 
 
 
h60 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0.250980392156863 0 0.501960784313725],... 
'CData',zeros(1,0),... 
'FontSize',0.6,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 0],... 
'ListboxTop',0,... 
'Position',[0.00660792951541851 0.0093167701863354 0.143171806167401 0.0357142857142857],... 
'String','TopGUI   V 1.0 ',... 
'Style','text',... 
'TooltipString','More info : http://www.geocities.com/chinakkong/research/topgui',... 
'Tag','text_version',... 
'UserData',zeros(1,0)); 
 
 
h61 = uicontrol(... 
'Parent',h1,... 
'Units','normalized',... 
'FontUnits','normalized',... 
'BackgroundColor',[0.501960784313725 0 0.501960784313725],... 
'Callback','topgui(''pushbutton_homepage_Callback'',gcbo,[],guidata(gcbo))',... 
'FontSize',0.5,... 
'FontWeight','bold',... 
'ForegroundColor',[1 1 0],... 
'ListboxTop',0,... 
'Position',[0.763215859030837 0.0077639751552795 0.232378854625551 0.0403726708074534],... 
'String','More info about TopGUI ...',... 
'Tag','pushbutton_homepage'); 
 
 
 
hsingleton = h1; 


% --- Handles default GUIDE GUI creation and callback dispatch
function varargout = gui_mainfcn(gui_State, varargin) 

 
%   GUI_MAINFCN provides these command line APIs for dealing with GUIs 
% 
%      TOPGUI, by itself, creates a new TOPGUI or raises the existing 
%      singleton*. 
% 
%      H = TOPGUI returns the handle to a new TOPGUI or the handle to 
%      the existing singleton*. 
% 
%      TOPGUI('CALLBACK',hObject,eventData,handles,...) calls the local 
%      function named CALLBACK in TOPGUI.M with the given input arguments. 
% 
%      TOPGUI('Property','Value',...) creates a new TOPGUI or raises the 
%      existing singleton*.  Starting from the left, property value pairs are 
%      applied to the GUI before untitled_OpeningFunction gets called.  An 
%      unrecognized property name or invalid value makes property application 
%      stop.  All inputs are passed to untitled_OpeningFcn via varargin. 
% 
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one 
%      instance to run (singleton)". 
 
%   Copyright 1984-2002 The MathWorks, Inc. 
%   $Revision: 1.4 $ $Date: 2002/05/31 21:44:31 $ 
 
gui_StateFields =  {'gui_Name' 
                    'gui_Singleton' 
                    'gui_OpeningFcn' 
                    'gui_OutputFcn' 
                    'gui_LayoutFcn' 
                    'gui_Callback'}; 
gui_Mfile = ''; 
for i=1:length(gui_StateFields) 
    if ~isfield(gui_State, gui_StateFields{i}) 
        error('Could not find field %s in the gui_State struct in GUI M-file %s', gui_StateFields{i}, gui_Mfile);         
    elseif isequal(gui_StateFields{i}, 'gui_Name') 
        gui_Mfile = [getfield(gui_State, gui_StateFields{i}), '.m']; 
    end 
end 
 
numargin = length(varargin); 
 
if numargin == 0 
    % TOPGUI 
    % create the GUI 
    gui_Create = 1; 
elseif numargin > 3 & ischar(varargin{1}) & ishandle(varargin{2}) 
    % TOPGUI('CALLBACK',hObject,eventData,handles,...) 
    gui_Create = 0; 
else 
    % TOPGUI(...) 
    % create the GUI and hand varargin to the openingfcn 
    gui_Create = 1; 
end 
 
if gui_Create == 0 
    varargin{1} = gui_State.gui_Callback; 
    if nargout 
        [varargout{1:nargout}] = feval(varargin{:}); 
    else 
        feval(varargin{:}); 
    end 
else 
    if gui_State.gui_Singleton 
        gui_SingletonOpt = 'reuse'; 
    else 
        gui_SingletonOpt = 'new'; 
    end 
     
    % Open fig file with stored settings.  Note: This executes all component 
    % specific CreateFunctions with an empty HANDLES structure. 
     
    % Do feval on layout code in m-file if it exists 
    if ~isempty(gui_State.gui_LayoutFcn) 
        gui_hFigure = feval(gui_State.gui_LayoutFcn, gui_SingletonOpt); 
    else 
        gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt);             
        % If the figure has InGUIInitialization it was not completely created 
        % on the last pass.  Delete this handle and try again. 
        if isappdata(gui_hFigure, 'InGUIInitialization') 
            delete(gui_hFigure); 
            gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt);             
        end 
    end 
     
    % Set flag to indicate starting GUI initialization 
    setappdata(gui_hFigure,'InGUIInitialization',1); 
 
    % Fetch GUIDE Application options 
    gui_Options = getappdata(gui_hFigure,'GUIDEOptions'); 
     
    if ~isappdata(gui_hFigure,'GUIOnScreen') 
        % Adjust background color 
        if gui_Options.syscolorfig  
            set(gui_hFigure,'Color', get(0,'DefaultUicontrolBackgroundColor')); 
        end 
 
        % Generate HANDLES structure and store with GUIDATA 
        guidata(gui_hFigure, guihandles(gui_hFigure)); 
    end 
     
    % If user specified 'Visible','off' in p/v pairs, don't make the figure 
    % visible. 
    gui_MakeVisible = 1; 
    for ind=1:2:length(varargin) 
        if length(varargin) == ind 
            break; 
        end 
        len1 = min(length('visible'),length(varargin{ind})); 
        len2 = min(length('off'),length(varargin{ind+1})); 
        if ischar(varargin{ind}) & ischar(varargin{ind+1}) & ... 
                strncmpi(varargin{ind},'visible',len1) & len2 > 1 
            if strncmpi(varargin{ind+1},'off',len2) 
                gui_MakeVisible = 0; 
            elseif strncmpi(varargin{ind+1},'on',len2) 
                gui_MakeVisible = 1; 
            end 
        end 
    end 
     
    % Check for figure param value pairs 
    for index=1:2:length(varargin) 
        if length(varargin) == index 
            break; 
        end 
        try, set(gui_hFigure, varargin{index}, varargin{index+1}), catch, break, end 
    end 
 
    % If handle visibility is set to 'callback', turn it on until finished 
    % with OpeningFcn 
    gui_HandleVisibility = get(gui_hFigure,'HandleVisibility'); 
    if strcmp(gui_HandleVisibility, 'callback') 
        set(gui_hFigure,'HandleVisibility', 'on'); 
    end 
     
    feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:}); 
     
    if ishandle(gui_hFigure) 
        % Update handle visibility 
        set(gui_hFigure,'HandleVisibility', gui_HandleVisibility); 
         
        % Make figure visible 
        if gui_MakeVisible 
            set(gui_hFigure, 'Visible', 'on') 
            if gui_Options.singleton  
                setappdata(gui_hFigure,'GUIOnScreen', 1); 
            end 
        end 
 
        % Done with GUI initialization 
        rmappdata(gui_hFigure,'InGUIInitialization'); 
    end 
     
    % If handle visibility is set to 'callback', turn it on until finished with 
    % OutputFcn 
    if ishandle(gui_hFigure) 
        gui_HandleVisibility = get(gui_hFigure,'HandleVisibility'); 
        if strcmp(gui_HandleVisibility, 'callback') 
            set(gui_hFigure,'HandleVisibility', 'on'); 
        end 
        gui_Handles = guidata(gui_hFigure); 
    else 
        gui_Handles = []; 
    end 
     
    if nargout 
        [varargout{1:nargout}] = feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles); 
    else 
        feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles); 
    end 
     
    if ishandle(gui_hFigure) 
        set(gui_hFigure,'HandleVisibility', gui_HandleVisibility); 
    end 
end     
 
function gui_hFigure = local_openfig(name, singleton) 
if nargin('openfig') == 3  
    gui_hFigure = openfig(name, singleton, 'auto'); 
else 
    % OPENFIG did not accept 3rd input argument until R13, 
    % toggle default figure visible to prevent the figure 
    % from showing up too soon. 
    gui_OldDefaultVisible = get(0,'defaultFigureVisible'); 
    set(0,'defaultFigureVisible','off'); 
    gui_hFigure = openfig(name, singleton); 
    set(0,'defaultFigureVisible',gui_OldDefaultVisible); 
end