function lightdm(action, lights)
% LIGHTDM Displays light bulbs over a surface to show lighting

%    Yama Habibzai
%   Copyright (c) 1984-98 by The MathWorks, Inc. All Rights Reserved
%    $Revision: 1.5 $
%    $Date: 1997/11/21 19:39:34 $

if nargin < 1
  action = 'init';
  lights = 1;
end

switch action
case 'init'
  % var for uicontrol
  
  Xleft = .85;
  btnwidth = .1;
  btnhighth = .05;
  Ybottom = .05;
  spacing = .07;
  
  plane(lights);
  
  %%% The uicontrols 
  
  frm = uicontrol('Style', 'frame',...
      'Units', 'Normalized', 'BackGroundColor', [.5 .5 .5],...
      'Position', [Xleft-.02 Ybottom-.02 btnwidth+.04 2*btnhighth+.06]);
  
  closehn = uicontrol('Style', 'push',...
      'String', 'Close',...
      'Units', 'Normalized',...
      'callback', 'close(gcbf)',...
      'Position',[Xleft Ybottom btnwidth btnhighth]);
  
  
  infohdn = uicontrol('Style', 'push',...
      'String', 'Info',...
      'Units', 'Normalized',...
      'callback', 'lightdm(''info'')',...
      'Position',[Xleft Ybottom+spacing btnwidth btnhighth]);
  
  %%% The pop-up menu
  
  poplist = {'One light',
  'Two lights',
  'Three lights',
  'Four lights'};
  
  pop = uicontrol('Style', 'popupmenu',...
      'Units', 'Normalized',...
      'String', poplist,...
      'Position', [.05 .9 .2 .05],...
      'Fontsize', 12,...
      'HorizontalAlignment', 'center',...
      'Value', lights,...
      'BackgroundColor', [1 1 1],...
      'callback','lightdm(''Localshow'')');
  set(gcf, 'color', [0 0 0]);
  
case 'draw',
  
  plane(lights);
case 'info',
  
  ttl = 'Lighting Example'; 
  infostr = {'This is an example of lighting of objects in MATLAB'
  ' '
  'In MATLAB You can create any 3-D graphic and display light sources'
  'of any color and position.' 
  ' '
  'In this example, you can use the Pop-up menus to select the number of'
  'light sources.'
  ' '
  'filename: lightdm.m'};
  helpwin(infostr, ttl);
  
case 'Localshow',
  index = get(gcbo, 'value');
  lightdm('draw', index);
end  % switch ...

