User`s guide
10 Examples of GUIDE GUIs
set(hgrotate,'Matrix',makehgtform(' zrotate',az));
drawnow % Refresh the screen
Light the Globe and Shift the Light Source
A light object illuminates the globe, initially from the left. Two sliders
control the light’s position, which you can manipulate whether the globe is
standing still or r o tat in g. The light is a child of the axes, so is not affected by
either of the
hgtransforms. The call to light uses no parameters other than
its altitude and an azimuth:
hlight = camlight(0,0);
After creating the light, the axes1_CreateFcn adds some handles and data
that other callbacks need to the
handles structure:
handles.light = hlight;
handles.tform = hgrotate;
handles.hmesh = hmesh;
handles.azimuth = 0.;
handles.cmap = cmap;
guidata(gcf,handles);
The call to gui data caches the data added to handles.
Moving either of the sliders sets both the elevation and the az imuth of the
light source, although each slider changes only one. The code in the callback
for varying the elevation of the light is
function sunelslider_Call back(hObject, eventdata, handles)
hlight = handles.light; % Get handle to light object
sunaz = get(handles.sunazslider,'value'); % Get current light azimuth
sunel = get(hObject,'value'); % Varies from -72.8 -> 72 .8 deg
lightangle(hlight,sunaz,sunel) % Set the new light angle
The callbac k for th e l ig h t azimuth slider wor ks similarly, query in g th e
elevation slider’s setting to keep that value from being changed in the call to
lightangle.
10-28