Download graphical pilot interface simulator (gpis)
Transcript
Edit text box callback:
function wheel_edit_Callback(hObject, eventdata, handles) %hObject refers to edit box
% Obtain value placed in edit box
disp_wheel= str2double(get(handles.wheel_edit,'String'));
% Determine whether disp_wheel iswthin range
If isnumeric(disp_wheel) & ...
disp_wheel >= get(handles.wheel_slider,'Min') & ...
disp_wheel <= get(handles.wheel_slider,'Max')
% Display entered value in edit box
set(hObject,'String', disp_wheel);
% Place value for slider
set(handles.wheel_slider,'Value',disp_wheel);
else
{issue some error message or some adjustment}
Slider callback:
function wheel_slider_Callback(hObject, eventdata, handles)
set(handles.wheel_edit,'String',num2str(get(handles.wheel_slider,'Value')));
They rely on each others property fields to get and set information. The use of the handles
structure passed to each callback function makes this quite easy.
•
Mouse-keyboard recognition:
Each figure created in MATLAB has a particular set of properties associated with it. Of
particular interest for us are the KeyPressFcn and WindowButtonDownFcn fields. These property
fields allow the name of an M-file to be defined. This means that every time a mouse button is
clicked over the figure or a key is pressed when the window is active, MATLAB will execute the
M-file in the KeyPressFcn or WindowButtonDownFcn property, accordingly. For instance, note
the following exerpt from keypress.m (Appendix D):
key = double(get(handles.output,'CurrentCharacter')); % get key pressed
if key = 28 %left arrow
{execute code for left arrow action}
Note that keypress.m relies on CurrentCharacter property to inquire what key was pressed from
the keyboard. The key assignments used by MATLAB are standard ASCII code key assignments.
•
Figure property manipulation for animations:
MATLAB offers many operating options that can be molded to our specific needs. In our
case, we needed to make GPIS efficient at producing animations that were not ‘sluggish’. To
do so, a variety of property fields were changed to achieve the objective. Other than the
options discussed in this text, other options discovered to be useful included the following:
42