⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui_set_parameters.m

📁 利用电磁场的源激发方法来计算光子晶体波导例如光子晶体光纤
💻 M
字号:
function varargout = gui_set_parameters(varargin)
% GUI_SET_PARAMETERS M-file for gui_set_parameters.fig
%      GUI_SET_PARAMETERS, by itself, creates a new GUI_SET_PARAMETERS or raises the existing
%      singleton*.
%
%      H = GUI_SET_PARAMETERS returns the handle to a new GUI_SET_PARAMETERS or the handle to
%      the existing singleton*.
%
%      GUI_SET_PARAMETERS('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI_SET_PARAMETERS.M with the given input arguments.
%
%      GUI_SET_PARAMETERS('Property','Value',...) creates a new GUI_SET_PARAMETERS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before gui_set_parameters_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to gui_set_parameters_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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help gui_set_parameters

% Last Modified by GUIDE v2.5 07-Jun-2006 10:04:58

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @gui_set_parameters_OpeningFcn, ...
    'gui_OutputFcn',  @gui_set_parameters_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 gui_set_parameters is made visible.
function gui_set_parameters_OpeningFcn(hObject, eventdata, handles, varargin)
global Testing2Sources
% 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 gui_set_parameters (see VARARGIN)

% Choose default command line output for gui_set_parameters
handles.oGd = varargin{2};
Testing2Sources = 1.3;
defalphaOut = 1;
defalphaIn = 0.4;
defPerVein = 25;
oGd = handles.oGd;
axes(handles.axes1)
draw_geom(oGd)
if ~isfield(oGd,'nSources')
    handles.oGd.nSources = (oGd.nSd-1)*defPerVein;
end
set(handles.uiNSources, 'string', num2str(round(handles.oGd.nSources)))

if ~isfield(oGd,'nTestingPoints')
    handles.oGd.nTestingPoints = round((oGd.nSd-1)*30*Testing2Sources);
end
set(handles.uiNTesting, 'string', num2str(round(handles.oGd.nTestingPoints)))

if ~isfield(oGd, 'alphaOut')
    handles.oGd.alphaOut = defalphaOut;
end
set(handles.uiOutDist, 'string', num2str(handles.oGd.alphaOut))

if ~isfield(oGd, 'alphaIn')
    handles.oGd.alphaIn = defalphaIn;
end
set(handles.uiInDist, 'string', num2str(handles.oGd.alphaIn))
if length(varargin) == 4
    handles.pos = varargin{4};
    show_pos(handles.oGd, handles.pos)
end

handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes gui_set_parameters wait for user response (see UIRESUME)
uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = gui_set_parameters_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;
delete(handles.figure1);


function uiNSources_Callback(hObject, eventdata, handles)
% hObject    handle to uiNSources (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 uiNSources as text
%        str2double(get(hObject,'String')) returns contents of uiNSources as a double
val = round(str2double(get(hObject,'String')));
if isnan(val) | (val <= 1) 
    set(hObject, 'string', num2str(handles.oGd.nSources));
    return
end
handles.oGd.nSources = val;
set(hObject, 'string', num2str(handles.oGd.nSources));
guidata(hObject, handles)



% --- Executes during object creation, after setting all properties.
function uiNSources_CreateFcn(hObject, eventdata, handles)
% hObject    handle to uiNSources (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function uiNTesting_Callback(hObject, eventdata, handles)
% hObject    handle to uiNTesting (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 uiNTesting as text
%        str2double(get(hObject,'String')) returns contents of uiNTesting as a double
val = round(str2double(get(hObject,'String')));
if isnan(val) | (val <= 1) 
    set(hObject, 'string', num2str(handles.oGd.nTestingPoints));
    return
end
handles.oGd.nTestingPoints = val;
set(hObject, 'string', num2str(handles.oGd.nTestingPoints));
guidata(hObject, handles)

% --- Executes during object creation, after setting all properties.
function uiNTesting_CreateFcn(hObject, eventdata, handles)
% hObject    handle to uiNTesting (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function uiInDist_Callback(hObject, eventdata, handles)
% hObject    handle to uiInDist (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 uiInDist as text
%        str2double(get(hObject,'String')) returns contents of uiInDist as a double
val = str2double(get(hObject,'String'));
if isnan(val) | (val <= 0)
    set(hObject, 'string', num2str(handles.oGd.alphaIn));
    return
end
handles.oGd.alphaIn = val;
guidata(hObject, handles)


% --- Executes during object creation, after setting all properties.
function uiInDist_CreateFcn(hObject, eventdata, handles)
% hObject    handle to uiInDist (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (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 edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on button press in uiDistribute.
function uiDistribute_Callback(hObject, eventdata, handles)
% hObject    handle to uiDistribute (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if handles.oGd.nSources > handles.oGd.nTestingPoints
    h = errordlg('The No. of sources must not exceed the No. of testing points.', ...
        'SMTgui');
    return
end
h = msgbox('Calculating location of sources and testing points...', 'SMTgui', 'help');
handles.pos = distribute(handles.oGd);
axes(handles.axes1)
show_pos(handles.oGd, handles.pos);
delete(h);
guidata(hObject, handles);

% --- Executes on button press in uiOk.
function uiOk_Callback(hObject, eventdata, handles)
% hObject    handle to uiOk (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if handles.oGd.nSources > handles.oGd.nTestingPoints
    h = errordlg('The No. of sources must not exceed the No. of testing points.', ...
        'SMTgui');
    return
end
if ~isfield(handles, 'pos')
    h = errordlg('Please press ''Distribute...'' first.', 'Error');
    return
end
handles.status = 0;
guidata(hObject, handles);
handles.output = guidata(gcbo);
guidata(hObject, handles);

% Use UIRESUME instead of delete because the OutputFcn needs
% to get the updated handles structure.
uiresume(handles.figure1);


% --- Executes on button press in uiCancel.
function uiCancel_Callback(hObject, eventdata, handles)
% hObject    handle to uiCancel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.status = -1;
guidata(hObject, handles);
handles.output = guidata(gcbo);
guidata(hObject, handles);

% Use UIRESUME instead of delete because the OutputFcn needs
% to get the updated handles structure.
uiresume(handles.figure1);





function uiOutDist_Callback(hObject, eventdata, handles)
% hObject    handle to uiOutDist (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 uiOutDist as text
%        str2double(get(hObject,'String')) returns contents of uiOutDist as a double
val = str2double(get(hObject,'String'));
if isnan(val) | (val <= 0) 
    set(hObject, 'string', num2str(handles.oGd.alphaOut));
    return
end
handles.oGd.alphaOut = val;
guidata(hObject, handles)




% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(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)

uiCancel_Callback(handles.uiCancel, eventdata, handles)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -