@chapsummary
Render, update and refine gui-based demo in @code{boxm2} 
@endchapsummary

@section @code{boxm2_render_tableau}
The bulk of the gui-based demo code is located in 
@code{ocl/view/boxm2_render_tableau.h/cxx}. This tableau is initialized with 
a @code{scene.xml} full path, a viewport size (ni,nj), a single initial camera
vpgl_perspective_camera<double>*, a vector of camera file paths, and a vector of 
image file paths.  

@example
  //: initialize tableau with scene_file, viewport size, initial cam,  
  bool init(vcl_string scene_file,
            unsigned ni,
            unsigned nj,
            vpgl_perspective_camera<double>* cam,
            vcl_vector<vcl_string> cam_files,
            vcl_vector<vcl_string> img_files);
@end example

All events are handled in the virtual method @code{handle}: 
@example
  //: virtual function handles mouse and keyboard actions
  virtual bool handle( vgui_event const& e );
@end example

After the tableau is initialized using the method above, the tableau must also 
initialize an OpenGL context, some OpenCL objects, and some @code{boxm2} data 
structures, which are handled in the following methods: 
@example
  cl_context create_clgl_context();
  bool init_clgl();
@end example


The handle method is currently equipped to handle the following commands: 
@itemize
@item Mouse Dragging: rotates the camera around a focus point
@item Middle Click Dragging:  zooms in or out in the current look vector
@item Ctrl+Click Dragging: Pans the camera in the image plane
@item Keystroke 'U': updates the model from a random frame from the vector of image file paths
@item Keystroke 'D': refines the model, will display new cells as black
@item Keystroke 'S': will write the model to disk
@item Keystroke 'R': will return the camera to its initial position
@item Keystroke 'X', 'Y', or 'Z': will move the camera to look straight down the 'X', 'Y', or 'Z' axis respectively  
@item Keystroke 'C': will toggle to change detect mode on the images in the 
      specified image directory.  While in change detect mode, keystroke 'N' will 
      change the frame to the next image.  
@end itemize


@subsection Updating the voxel model
The following is an outline of the updating procedure performed by the 
tableau.  

@example
//: updates given a random frame
float boxm2_render_tableau::update_frame()
{
  //choose random frame and corresponding camera (create portable sptrs)
  vil_image_view<float>* floatimg = random_frame(); 
  vil_image_view_base_sptr floatimg_sptr(floatimg);
  brdb_value_sptr brdb_inimg = new brdb_value_t<vil_image_view_base_sptr>(floatimg_sptr);
  vpgl_camera_double_sptr cam_sptr(pcam);
  brdb_value_sptr brdb_cam = new brdb_value_t<vpgl_camera_double_sptr>(cam_sptr);

  //create brdb pointer to scene
  brdb_value_sptr brdb_scene = new brdb_value_t<boxm2_scene_sptr>(scene_);

  //set inputs
  vcl_vector<brdb_value_sptr> input;
  input.push_back(brdb_scene);
  input.push_back(brdb_cam);
  input.push_back(brdb_inimg);

  //initoutput vector
  vcl_vector<brdb_value_sptr> output;

  //execute gpu_update (update_ is of type boxm2_opencl_update_process)
  gpu_pro_->run(&update_, input, output);
  return gpu_pro_->exec_time();
}
@end example
