-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsl_customization.m
More file actions
35 lines (32 loc) · 975 Bytes
/
sl_customization.m
File metadata and controls
35 lines (32 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
%% Register custom menu function to beginning of Simulink Editor's context menu
function sl_customization(cm)
cm.addCustomMenuFcn('Simulink:PreContextMenu', @getMcMasterTool);
end
%% Define custom menu function
function schemaFcns = getMcMasterTool(callbackInfo)
schemaFcns = {@getAutoLayoutTool};
end
%% Define the second action: Auto Layout
function schema = getAutoLayoutTool(callbackinfo)
schema = sl_action_schema;
schema.label = 'Auto Layout';
schema.userdata = 'autolayout';
schema.callback = @AutoLayoutToolCallback;
end
function AutoLayoutToolCallback(callbackInfo)
try
if strcmp(get_param(bdroot, 'Dirty'), 'on')
AutoLayoutGUI;
else
if isempty(gcos)
AutoLayoutSys(gcs);
else
objs = gcos;
AutoLayout(objs);
end
end
catch ME
getReport(ME)
rethrow(ME)
end
end