Newer
Older
function TTdiag(varargin)
orig_gcbh = gcbh;
Action = varargin{1};
if 1 ~= nargin
DAStudio.warning('improper function use')
end
switch Action,
case 'Open',
blockHandleTTTopMask = orig_gcbh;
LocalOpenBlockFcn(blockHandleTTTopMask);
case 'Close',
blockHandleTTTopMask = orig_gcbh;
LocalCloseBlockFcn(blockHandleTTTopMask);
case 'Copy',
blockHandleTTTopMask = orig_gcbh;
LocalCopyBlockFcn(blockHandleTTTopMask);
otherwise,
DAStudio.error('Simulink:dialog:UnknownAction',Action);
end
end
function LocalCopyBlockFcn(blockHandleTTTopMask)
gui = get(blockHandleTTTopMask,'UserData')
if(~isempty(gui))
gui_new = gui.clone(blockHandleTTTopMask);
% gui_new = copy(gui,blockHandleTTTopMask)
% gui_new.function_name_text = get_param(blockHandleTTTopMask,'Name');
% gui_new.fig = [];
% gui_new.block_handle = blockHandleTTTopMask;
% TEMPORARY SOLUTION
set_param(blockHandleTTTopMask,'UserData',gui_new)
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
end
end
function LocalOpenBlockFcn(blockHandleTTTopMask)
modelHandle = bdroot(blockHandleTTTopMask);
gui = get_param(blockHandleTTTopMask,'UserData');
if ~isempty(gui)
gui.block_handle = blockHandleTTTopMask;
if ishghandle(gui.fig)
set(gui.fig,'Visible','on')
figure(gui.fig)
%gui.init();
% gui.reset_wh();
% gui.draw_allgrids();
else
gui.init();
end
% set_param(gui.fig,'Visible','on')
else
if strcmp(get_param(modelHandle,'Lock'), 'on') || ...
strcmp(get_param(blockHandleTTTopMask,'LinkStatus'),'implicit')
errordlg(...
DAStudio.message('can not open Model Locked'),...
'Error', 'modal')
return
end
Grid2 = Grid(2,[]);
Grid1 = Grid(1,[]);
rGrid = RGrid(Grid1,Grid2);
Grid1.set_rGrid(rGrid);
Grid2.set_rGrid(rGrid);
Grid2.new_Cell;
Grid1.new_Cell;
gui = GUI(blockHandleTTTopMask);
%gui.init();
gui.set_grid(Grid2,Grid1,rGrid);
gui.init();
%gui.reset_wh();
%gui.draw_allgrids();
set(Grid2.delete_cell_pb,'Enable','off');
set(Grid1.delete_cell_pb,'Enable','off');
set_param(blockHandleTTTopMask,'UserData',gui);
set_param(blockHandleTTTopMask, 'UserDataPersistent', 'on');
end
end
function LocalCloseRequestBlockFcn(blockHandleTTTopMask)
modelHandle = bdroot(blockHandleTTTopMask);
gui = get_param(blockHandleTTTopMask,'UserData')
set_param(gui.fig,'Visible','off')
end
% Make a copy of a handle object.
function new = copy(this,h)
% Instantiate new object of the same class.
new = feval(class(this),h);
% Copy all non-hidden properties.
p = properties(this);
for i = 1:length(p)
new.(p{i}) = this.(p{i});
end
end