1 | % By Philip Torr 2002 |
---|
2 | % copyright Microsoft Corp. |
---|
3 | function corn_param_out = torr_c_menu(varargin) |
---|
4 | % TORR_C_MENU Application M-file for torr_c_menu.fig |
---|
5 | % FIG = TORR_C_MENU launch torr_c_menu GUI. |
---|
6 | % TORR_C_MENU('callback_name', ...) invoke the named callback. |
---|
7 | |
---|
8 | % Last Modified by GUIDE v2.0 26-Mar-2002 19:17:03 |
---|
9 | error(nargchk(0,4,nargin)) % function takes only 0 or 2 argument |
---|
10 | if nargin == 2 % LAUNCH GUI |
---|
11 | |
---|
12 | |
---|
13 | fig = openfig(mfilename,'reuse'); |
---|
14 | |
---|
15 | |
---|
16 | |
---|
17 | % Use system color scheme for figure: |
---|
18 | set(fig,'Color',get(0,'defaultUicontrolBackgroundColor')); |
---|
19 | |
---|
20 | % Generate a structure of handles to pass to callbacks, and store it. |
---|
21 | handles = guihandles(fig); |
---|
22 | |
---|
23 | |
---|
24 | |
---|
25 | corn_param = varargin{1}; |
---|
26 | handles.n_corners = corn_param.n_corners; |
---|
27 | handles.corner_sigma = corn_param.corner_sigma; |
---|
28 | handles.corner_width = corn_param.corner_width; |
---|
29 | |
---|
30 | |
---|
31 | set(handles.number_corners_button, 'String', num2str(handles.n_corners)); |
---|
32 | set(handles.sigma_button, 'String', num2str(handles.corner_sigma)); |
---|
33 | set(handles.width_button, 'String', num2str(handles.corner_width)); |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | |
---|
38 | guidata(fig, handles); |
---|
39 | |
---|
40 | % Wait for callbacks to run and window to be dismissed: |
---|
41 | uiwait(fig); |
---|
42 | |
---|
43 | % if nargout > 0 |
---|
44 | % varargout{1} = fig; |
---|
45 | % end |
---|
46 | % |
---|
47 | % |
---|
48 | % |
---|
49 | % UIWAIT might have returned because the window was deleted using |
---|
50 | % the close box - in that case, return 'cancel' as the answer, and |
---|
51 | % don't bother deleting the window! |
---|
52 | if ~ishandle(fig) |
---|
53 | disp('No changes made'); |
---|
54 | corn_param_out(1) = 500; |
---|
55 | corn_param_out(2) = 1; |
---|
56 | corn_param_out(3) = 3; |
---|
57 | else |
---|
58 | % otherwise, we got here because the user pushed one of the two buttons. |
---|
59 | % retrieve the latest copy of the 'handles' struct, and return the answer. |
---|
60 | % Also, we need to delete the window. |
---|
61 | handles = guidata(fig); |
---|
62 | corn_param_out(1) = handles.n_corners; |
---|
63 | corn_param_out(2) = handles.corner_sigma; |
---|
64 | corn_param_out(3) = handles.corner_width; |
---|
65 | delete(fig); |
---|
66 | end |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK |
---|
71 | |
---|
72 | try |
---|
73 | [varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard |
---|
74 | catch |
---|
75 | disp(lasterr); |
---|
76 | end |
---|
77 | |
---|
78 | end |
---|
79 | |
---|
80 | |
---|
81 | %| ABOUT CALLBACKS: |
---|
82 | %| GUIDE automatically appends subfunction prototypes to this file, and |
---|
83 | %| sets objects' callback properties to call them through the FEVAL |
---|
84 | %| switchyard above. This comment describes that mechanism. |
---|
85 | %| |
---|
86 | %| Each callback subfunction declaration has the following form: |
---|
87 | %| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN) |
---|
88 | %| |
---|
89 | %| The subfunction name is composed using the object's Tag and the |
---|
90 | %| callback type separated by '_', e.g. 'slider2_Callback', |
---|
91 | %| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'. |
---|
92 | %| |
---|
93 | %| H is the callback object's handle (obtained using GCBO). |
---|
94 | %| |
---|
95 | %| EVENTDATA is empty, but reserved for future use. |
---|
96 | %| |
---|
97 | %| HANDLES is a structure containing handles of components in GUI using |
---|
98 | %| tags as fieldnames, e.g. handles.figure1, handles.slider2. This |
---|
99 | %| structure is created at GUI startup using GUIHANDLES and stored in |
---|
100 | %| the figure's application data using GUIDATA. A copy of the structure |
---|
101 | %| is passed to each callback. You can store additional information in |
---|
102 | %| this structure at GUI startup, and you can change the structure |
---|
103 | %| during callbacks. Call guidata(h, handles) after changing your |
---|
104 | %| copy to replace the stored original so that subsequent callbacks see |
---|
105 | %| the updates. Type "help guihandles" and "help guidata" for more |
---|
106 | %| information. |
---|
107 | %| |
---|
108 | %| VARARGIN contains any extra arguments you have passed to the |
---|
109 | %| callback. Specify the extra arguments by editing the callback |
---|
110 | %| property in the inspector. By default, GUIDE sets the property to: |
---|
111 | %| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo)) |
---|
112 | %| Add any extra arguments after the last argument, before the final |
---|
113 | %| closing parenthesis. |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | % -------------------------------------------------------------------- |
---|
118 | function varargout = close_button_Callback(h, eventdata, handles, varargin) |
---|
119 | % Stub for Callback of the uicontrol handles.close_button. |
---|
120 | %Stub for Callback of the uicontrol handles.close_button. |
---|
121 | % |
---|
122 | % Obtaining the Figure Handle from Within a Callback. In general, dismissing a modal figure requires the handle |
---|
123 | % of the figure. Since most GUIs hide figure handles to prevent accidental access, the gcbf (get callback figure) |
---|
124 | % command provides the most effective method to get the figure handle from within a callback routine. |
---|
125 | % |
---|
126 | % gcbf returns the handle of the figure containing the object whose callback is executing. This enables you to use |
---|
127 | % gcbf in the callback of the component that will dismiss the dialog. For example, suppose your dialog includes a |
---|
128 | % push button (tagged pushbutton1) that closes the dialog. Its callback could include a call to delete at the end of |
---|
129 | % its callback subfunction. |
---|
130 | |
---|
131 | disp('closing'); |
---|
132 | % corn_param_out.n_corners = handles.n_corners; |
---|
133 | % corn_param_out.corner_sigma = handles.corner_sigma; |
---|
134 | % corn_param_out.corner_width = handles.corner_width; |
---|
135 | |
---|
136 | uiresume(handles.figure1); |
---|
137 | |
---|
138 | |
---|
139 | |
---|
140 | % -------------------------------------------------------------------- |
---|
141 | function varargout = pushbutton2_Callback(h, eventdata, handles, varargin) |
---|
142 | % Stub for Callback of the uicontrol handles.pushbutton2. |
---|
143 | disp('pushbutton2 Callback not implemented yet.') |
---|
144 | |
---|
145 | |
---|
146 | % -------------------------------------------------------------------- |
---|
147 | function varargout = width_button_Callback(h, eventdata, handles, varargin) |
---|
148 | nc = str2num(get(handles.width_button, 'String')); |
---|
149 | minnc = 0; |
---|
150 | maxnc = 20; |
---|
151 | if (isempty(nc) | (nc <= minnc) | (nc >maxnc)) |
---|
152 | nc = handles.corner_width; |
---|
153 | WARNDLG(['out of range' num2str(minnc) '-' num2str(maxnc)],'ooops') |
---|
154 | end; |
---|
155 | handles.corner_width = nc; |
---|
156 | set(handles.width_button, 'String', num2str(handles.corner_width)); |
---|
157 | |
---|
158 | %save data |
---|
159 | guidata(handles.figure1, handles); |
---|
160 | |
---|
161 | % -------------------------------------------------------------------- |
---|
162 | function varargout = sigma_button_Callback(h, eventdata, handles, varargin) |
---|
163 | nc = str2num(get(handles.sigma_button, 'String')); |
---|
164 | minnc = 0; |
---|
165 | maxnc = 20; |
---|
166 | if (isempty(nc) | (nc <= minnc) | (nc >maxnc)) |
---|
167 | nc = handles.corner_sigma; |
---|
168 | WARNDLG(['out of range' num2str(minnc) '-' num2str(maxnc)],'ooops') |
---|
169 | end; |
---|
170 | handles.corner_sigma = nc; |
---|
171 | set(handles.sigma_button, 'String', num2str(handles.corner_sigma)); |
---|
172 | |
---|
173 | %save data |
---|
174 | guidata(handles.figure1, handles); |
---|
175 | |
---|
176 | % -------------------------------------------------------------------- |
---|
177 | function varargout = number_corners_button_Callback(h, eventdata, handles, varargin) |
---|
178 | % Stub for Callback of the uicontrol handles.number_corners_button. |
---|
179 | nc = str2num(get(handles.number_corners_button, 'String')); |
---|
180 | |
---|
181 | minnc = 10; |
---|
182 | maxnc = 10000; |
---|
183 | if (isempty(nc) | (nc < minnc) | (nc >maxnc)) |
---|
184 | nc = handles.n_corners; |
---|
185 | WARNDLG(['out of range' num2str(minnc) '-' num2str(maxnc)],'ooops') |
---|
186 | end; |
---|
187 | handles.n_corners = nc; |
---|
188 | set(handles.number_corners_button, 'String', num2str(handles.n_corners)); |
---|
189 | |
---|
190 | %save data |
---|
191 | guidata(handles.figure1, handles); |
---|
192 | |
---|
193 | % -------------------------------------------------------------------- |
---|
194 | function varargout = edit2_Callback(h, eventdata, handles, varargin) |
---|
195 | % Stub for Callback of the uicontrol handles.edit2. |
---|
196 | disp('edit2 Callback not implemented yet.') |
---|
197 | |
---|
198 | |
---|
199 | % -------------------------------------------------------------------- |
---|
200 | function varargout = edit3_Callback(h, eventdata, handles, varargin) |
---|
201 | % Stub for Callback of the uicontrol handles.edit3. |
---|
202 | disp('edit3 Callback not implemented yet.') |
---|