Newer
Older
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
36
37
38
39
40
41
42
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
classdef GUI < handle
properties
% vertical grid
Grid2 = [];
% horizontal grid
Grid1 = [];
%output grid
Grid0 = [];
main_fig = [];
frame = [];
fig = [];
scroll_v = [];
edit_tog = [];
save_pb = [];
pvs_pb = [];
close_pb = [];
save_ext_pb = [];
check_pb = [];
function_name_control = [];
function_name_text = [];
function_inputs_text = [];
function_inputs_control = [];
edit = 1;
initialized = 0;
block_handle = [];
% height of header where buttons and text is
header_height = 100;
% window size
fig_height = 500;
fig_width = 800;
% space inbetween buttons in header
pb_offset = 5;
% width of push buttons in header
pb_width = 80;
% height of push buttons in header
pb_height = 40;
% width of text boxes
text_width = 250;
name_label = [];
input_label = [];
PVS = [];
end
methods
%% GUI
% constructor
% inputs:
% h:double - handle to Tabular block in model
% outputs;
% obj:GUI - object that is created
function obj = GUI(h)
obj.block_handle = h;
end
%% init
% initialize the gui
% inputs:
% obj:GUI - GUI object
% outputs;
% none
function [] = init(obj)
% create the handles for the gui objects
% main figure
obj.fig = figure('units','pixels',...
'position',[0 0 obj.fig_width obj.fig_height],...
'menubar','none',...
'name','GUI_1',...
'numbertitle','off',...
'resize','on',...
'Name',get_param(obj.block_handle,'Name'),...
'CloseRequestFcn',@(src,event)close_fig(obj,src,event),...
'ResizeFcn',@(src,event)resize_fig(obj,src,event));
% edit button
obj.edit_tog = uicontrol('style','toggle',...
'units','pix',...
'string','Edit',...
'HorizontalAlign','left',...
'Parent',obj.fig,...
'Value',obj.edit,...
'callback',@(src,event)edit_tog_call(obj,src,event));
% Save button
obj.save_pb = uicontrol('style','push',...
'units','pix',...
'string','Save',...
'HorizontalAlign','left',...
'Parent',obj.fig,...
'callback',@(src,event)save_call(obj,src,event));
% Close button
obj.close_pb = uicontrol('style','push',...
'units','pix',...
'string','Close',...
'HorizontalAlign','left',...
'Parent',obj.fig,...
'callback',@(src,event)close_fig(obj,src,event));
% Save external button
obj.save_ext_pb = uicontrol('style','push',...
'units','pix',...
'string','Save Ext',...
'HorizontalAlign','left',...
'Parent',obj.fig,...
'callback',@(src,event)save_ext_call(obj,src,event));
% PVS button
obj.pvs_pb = uicontrol('style','push',...
'units','pix',...
'string','PVS',...
'HorizontalAlign','left',...
'Parent',obj.fig,...
'callback',@(src,event)pvs_ext_call(obj,src,event));
% Check button
obj.check_pb = uicontrol('style','push',...
'units','pix',...
'string','Check',...
'HorizontalAlign','left',...
'Parent',obj.fig,...
'callback',@(src,event)check_call(obj,src,event));
% Expression Name Label
obj.name_label = uicontrol('style','text',...
'string','Expression Name',...
'HorizontalAlign','right',...
'BackgroundColor',get(obj.fig,'Color'));
% Expression Name Edit box
obj.function_name_control = uicontrol('style','edit',...
'units','pix',...
'Parent',obj.fig,...
'HorizontalAlign','center',...
'FontWeight','bold',...
'FontSize',12,...
'Max',2.0,...
'BackgroundColor',[1 1 1]);
% input list label
obj.input_label = uicontrol('style','text',...
'string','Inputs',...
'HorizontalAlign','right',...
'BackgroundColor',get(obj.fig,'Color'));
% input list edit box
obj.function_inputs_control = uicontrol('style','edit',...
'units','pix',...
'Parent',obj.fig,...
'HorizontalAlign','center',...
'FontWeight','bold',...
'Max',2.0,...
'FontSize',12,...
'BackgroundColor',[1 1 1]);
% load the function name and inputs
if (~isempty(obj.function_name_text))
set(obj.function_name_control,'String',obj.function_name_text);
end
if (~isempty(obj.function_inputs_text))
set(obj.function_inputs_control,'String',obj.function_inputs_text);
end
obj.PVS = PVS_checker(obj);
obj.set_command_pos;
obj.reset_wh();
obj.draw_allgrids(1);
obj.initialized = 1;
end
%% set_command_pos
% sets the location of all the command buttons, labels and edit
% boxes, places objects at the top of the figure which it
% determines by looking at the height of the figure handle
% inputs:
% obj:GUI - current GUI object
% outputs;
% none
function [] = set_command_pos(obj)
figpos = get(obj.fig,'Position')
% figure out the height of the figure
l_fig_height = figpos(4)
set(obj.edit_tog,'Position',[obj.pb_offset l_fig_height-obj.pb_offset-obj.pb_height obj.pb_width obj.pb_height])
set(obj.save_pb,'Position',[obj.pb_offset*2+obj.pb_width,l_fig_height-obj.pb_offset-obj.pb_height,obj.pb_width,obj.pb_height])
set(obj.close_pb,'Position',[obj.pb_offset*3+obj.pb_width*2,l_fig_height-obj.pb_offset-obj.pb_height,obj.pb_width,obj.pb_height])
set(obj.save_ext_pb,'Position',[obj.pb_offset*4+obj.pb_width*3,l_fig_height-obj.pb_offset-obj.pb_height,obj.pb_width,obj.pb_height])
set(obj.check_pb,'Position',[obj.pb_offset*5+obj.pb_width*4,l_fig_height-obj.pb_offset-obj.pb_height,obj.pb_width,obj.pb_height])
set(obj.pvs_pb,'Position',[obj.pb_offset*6+obj.pb_width*5,l_fig_height-obj.pb_offset-obj.pb_height,obj.pb_width,obj.pb_height])
set(obj.name_label,'Position',[obj.pb_offset l_fig_height-obj.pb_offset*3-obj.pb_height-obj.pb_height obj.pb_width obj.pb_height]);
set(obj.function_name_control,'Position',[obj.pb_offset*2+obj.pb_width l_fig_height-obj.pb_offset*3-obj.pb_height-obj.pb_height obj.text_width obj.pb_height]);
set(obj.input_label,'Position',[obj.pb_offset*2+obj.pb_width+obj.text_width l_fig_height-obj.pb_offset*3-obj.pb_height-obj.pb_height obj.pb_width obj.pb_height]);
Loading
Loading full blame...