GUI设计图
matlab2015b实现
function varargout = DeleteBlockNameFunction(varargin)
% DELETEBLOCKNAMEFUNCTION MATLAB code for DeleteBlockNameFunction.fig
% DELETEBLOCKNAMEFUNCTION, by itself, creates a new DELETEBLOCKNAMEFUNCTION or raises the existing
% singleton*.
%
% H = DELETEBLOCKNAMEFUNCTION returns the handle to a new DELETEBLOCKNAMEFUNCTION or the handle to
% the existing singleton*.
%
% DELETEBLOCKNAMEFUNCTION('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DELETEBLOCKNAMEFUNCTION.M with the given input arguments.
%
% DELETEBLOCKNAMEFUNCTION('Property','Value',...) creates a new DELETEBLOCKNAMEFUNCTION or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before DeleteBlockNameFunction_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to DeleteBlockNameFunction_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
% Edit the above text to modify the response to help DeleteBlockNameFunction
% Last Modified by GUIDE v2.5 10-May-2021 14:01:28
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @DeleteBlockNameFunction_OpeningFcn, ...
'gui_OutputFcn', @DeleteBlockNameFunction_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 DeleteBlockNameFunction is made visible.
function DeleteBlockNameFunction_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 DeleteBlockNameFunction (see VARARGIN)
% Choose default command line output for DeleteBlockNameFunction
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes DeleteBlockNameFunction wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = DeleteBlockNameFunction_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;
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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
function color_input_Callback(hObject, eventdata, handles)
% hObject handle to color_input (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 color_input as text
% str2double(get(hObject,'String')) returns contents of color_input as a double
% --- Executes during object creation, after setting all properties.
function color_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to color_input (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 pushbutton_explain.
function pushbutton_explain_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_explain (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
helpdlg('请按照说明输入', 'Help');
function showname_input_Callback(hObject, eventdata, handles)
% hObject handle to showname_input (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 showname_input as text
% str2double(get(hObject,'String')) returns contents of showname_input as a double
% --- Executes during object creation, after setting all properties.
function showname_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to showname_input (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 selection change in popupmenu_type.
function popupmenu_type_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu_type (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_type contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu_type
% --- Executes during object creation, after setting all properties.
function popupmenu_type_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu_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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton.
function pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
color = get(handles.color_input,'string');
showname = get(handles.showname_input,'string');
blockname_Val = get(handles.popupmenu_type, 'Value');
blockname_Str = get(handles.popupmenu_type, 'string');
%c=blockname_Str{blockname_Val}
switch blockname_Str{blockname_Val}
case 'DataTypeConversion'
LookUpBlockType = find_system(gcb,'FindAll','on','SearchDepth',2,'Blocktype','DataTypeConversion')
%用于将搜索深度限制在指定级别的选项,指定为以逗号分隔的对组,由 'SearchDepth' 和正整数字符向量或字符串标量组成。
%例如,指定 '0' 会仅搜索加载的系统,指定 '1' 会搜索顶层系统的模块和子系统,指定 '2' 会搜索顶层系统及其子级,等等。默认值为搜索所有级别
case 'Constant'
LookUpBlockType = find_system(gcb,'FindAll','on','SearchDepth',2,'Blocktype','Constant')
case 'Switch'
LookUpBlockType = find_system(gcb,'FindAll','on','SearchDepth',1,'Blocktype','Switch')
case 'Gain'
LookUpBlockType = find_system(gcb,'FindAll','on','SearchDepth',1,'Blocktype','Gain')
case 'Goto'
LookUpBlockType = find_system(gcb,'FindAll','on','SearchDepth',1,'Blocktype','Goto')
case 'From'
LookUpBlockType = find_system(gcb,'FindAll','on','SearchDepth',1,'Blocktype','From')
case 'SubSystem'
LookUpBlockType = find_system(gcb,'FindAll','on','SearchDepth',1,'Blocktype','SubSystem') %不可以用
% LookUpBlockType = find_system(gcs,'FindAll','On','BlockType','Subsystem')
case 'Selector'
LookUpBlockType = find_system(gcb,'FindAll','on','SearchDepth',1,'Blocktype','Selector')
case 'EnablePort'
LookUpBlockType = find_system(gcb,'FindAll','on','SearchDepth',2,'Blocktype','EnablePort')
case 'TriggerPort'
LookUpBlockType = find_system(gcb,'FindAll','on','SearchDepth',2,'Blocktype','TriggerPort')
case 'Terminator'
LookUpBlockType = find_system(gcb,'FindAll','on','SearchDepth',2,'Blocktype','Terminator')
otherwise
%msgbox('Error!!','Error');
errordlg('文件错误','未找到名字');
end
if isempty(LookUpBlockType)
return;
end
for i=1:length(LookUpBlockType)
if(strcmp(showname, 'Off'))
set(LookUpBlockType,'ShowName','Off') %On, %ShowBlockName
end
if(strcmp(showname, 'On'))
set(LookUpBlockType,'ShowName','On') %On, %ShowBlockName
end
if(strcmp(color, 'YES'))
set(LookUpBlockType,'ForegroundColor','Black');
set(LookUpBlockType,'BackgroundColor','White');
end
end
function edit_inputSameDT_Callback(hObject, eventdata, handles)
% hObject handle to edit_inputSameDT (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 edit_inputSameDT as text
% str2double(get(hObject,'String')) returns contents of edit_inputSameDT as a double
% --- Executes during object creation, after setting all properties.
function edit_inputSameDT_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_inputSameDT (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 pushbutton_inputSameDT.
function pushbutton_inputSameDT_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_inputSameDT (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%%InputSameDT== Requre all data port inputs to have the same data type
inputSameDT = get(handles.edit_inputSameDT,'string');
LookUpBlockType = find_system(gcb,'FindAll','on','SearchDepth',1,'Blocktype','Switch');
if(strcmp(inputSameDT, 'On'))
set(LookUpBlockType,'InputSameDT','On');
end
if(strcmp(inputSameDT, 'Off'))
set(LookUpBlockType,'InputSameDT','Off');
end