Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1221 - in trunk: Engine/Control Engine/Factory Interface StandAlone SwigInterface UserInterface fox/FManta fox/dm_demo include scenes


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1221 - in trunk: Engine/Control Engine/Factory Interface StandAlone SwigInterface UserInterface fox/FManta fox/dm_demo include scenes
  • Date: Fri, 13 Oct 2006 17:18:50 -0600 (MDT)

Author: abe
Date: Fri Oct 13 17:18:43 2006
New Revision: 1221

Added:
   trunk/Engine/Factory/Factory.cc
   trunk/Engine/Factory/Factory.h
Modified:
   trunk/Engine/Control/RTRT.cc
   trunk/Engine/Control/RTRT.h
   trunk/Engine/Factory/CMakeLists.txt
   trunk/Engine/Factory/Create.cc
   trunk/Engine/Factory/RegisterKnownComponents.cc
   trunk/Engine/Factory/RegisterKnownComponents.h
   trunk/Interface/Callback.h
   trunk/Interface/CallbackHelpers.h
   trunk/Interface/MantaInterface.h
   trunk/StandAlone/manta.cc
   trunk/SwigInterface/manta.h
   trunk/SwigInterface/manta.i
   trunk/SwigInterface/runmanta.py
   trunk/SwigInterface/wxManta.py
   trunk/UserInterface/PromptUI.cc
   trunk/UserInterface/PromptUI.h
   trunk/fox/FManta/FMantaWindow.cc
   trunk/fox/FManta/FMantaWindow.h
   trunk/fox/dm_demo/dm_demo.cc
   trunk/include/RegisterConfigurableComponents.h.CMakeTemplate
   trunk/scenes/0.cc
   trunk/scenes/acceltest.cc
   trunk/scenes/cube.cc
Log:


This commit contains a change to MantaInterface. In an attempt to
simplify the implementation of the pipeline in RTRT.cc, all of the
select* and register* command line parsing related methods have been
moved from the MantaInterface interface to a Factory class which
operates externally on a MantaInterface pointer using get and set
methods. Get/set methods have been added for all the pipeline
components.

RTRT.cc, which contains the main pipeline implementation, is now about
300 lines shorter down to 1200 lines. The remaining code breaks down
as follows:

330 lines : Pipeline code.
270 lines : Pipeline setup & framebuffer resize.
200 lines : Transactions & callback invocation.
180 lines : Get & set methods for pipeline components.
100 lines : Adding transactions & callbacks. 
100 lines : Unregister callback method (!).

Our eventual goal is to simplify the implementation sufficientlly so
that it would be easy to understand the code in RTRT.cc and modify the
pipeline implementation in a derived class.

M    scenes/0.cc
M    scenes/acceltest.cc
M    scenes/cube.cc
M    include/RegisterConfigurableComponents.h.CMakeTemplate
M    StandAlone/manta.cc
M    SwigInterface/manta.h
M    SwigInterface/manta.i
M    SwigInterface/wxManta.py
M    SwigInterface/runmanta.py
M    fox/dm_demo/dm_demo.cc
M    fox/FManta/FMantaWindow.cc
M    fox/FManta/FMantaWindow.h
M    UserInterface/PromptUI.cc
M    UserInterface/PromptUI.h
M    Interface/MantaInterface.h
M    Interface/Callback.h
M    Interface/CallbackHelpers.h
M    Engine/Control/RTRT.cc
M    Engine/Control/RTRT.h
M    Engine/Factory/Create.cc
M    Engine/Factory/RegisterKnownComponents.cc
A    Engine/Factory/Factory.cc
M    Engine/Factory/CMakeLists.txt
M    Engine/Factory/RegisterKnownComponents.h
A    Engine/Factory/Factory.h


Modified: trunk/Engine/Control/RTRT.cc
==============================================================================
--- trunk/Engine/Control/RTRT.cc        (original)
+++ trunk/Engine/Control/RTRT.cc        Fri Oct 13 17:18:43 2006
@@ -1,6 +1,33 @@
 
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005-2006
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
 #include <Engine/Control/RTRT.h>
-#include <Core/Util/Args.h>
 #include <Interface/AmbientLight.h>
 #include <Interface/Background.h>
 #include <Interface/Callback.h>
@@ -21,12 +48,11 @@
 #include <Interface/SetupCallback.h>
 #include <Interface/UserInterface.h>
 #include <Interface/ShadowAlgorithm.h>
-#include <Core/Containers/StringUtil.h>
 #include <Core/Exceptions/IllegalValue.h>
 #include <Core/Exceptions/InternalError.h>
 #include <Core/Exceptions/InvalidState.h>
-#include <Core/Exceptions/InputError.h>
-#include <Core/Exceptions/UnknownComponent.h>
+
+
 #include <Core/Thread/Thread.h>
 #include <Core/Thread/Time.h>
 #include <Core/Util/Assert.h>
@@ -38,11 +64,6 @@
 #include <iostream>
 #include <sgi_stl_warnings_on.h>
 
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dlfcn.h>
-#include <stdio.h>
 
 #include <Interface/Material.h>
 
@@ -53,11 +74,16 @@
 using SCIRun::InternalError;
 using SCIRun::Thread;
 using SCIRun::Time;
-using SCIRun::split_string;
 
 #define RENDER_THREAD_STACKSIZE 8*1024*1024
 
 
///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// Thread Worker Class
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
 
////////////////////////////////////////////////////////////////////////////////
 // RTRT Worker class.
 RTRT::Worker::Worker(RTRT* rtrt, int workerIndex, bool lateComerFlag)
@@ -77,6 +103,11 @@
 
///////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////
 
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// Default Constructor.
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 
 RTRT::RTRT()
   : runningLock("RTRT running mutex"),
@@ -98,7 +129,6 @@
   timeScale = 1;
   frameRate = 15;
   pipelineNeedsSetup = true;
-  currentImageCreator = 0;
   scene = 0;
   verbose_transactions = false;
   currentPixelSampler = 0;
@@ -120,6 +150,14 @@
   delete currentRenderer;
 }
 
+
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// Control Methods.
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
 void RTRT::changeNumWorkers(int newNumWorkers)
 {
   if(newNumWorkers < 0)
@@ -133,8 +171,13 @@
   return workersWanted;
 }
 
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// Register/Add Callback Functions.
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 
-void RTRT::addOneShotCallback(Whence whence, long frame,
+void RTRT::addOneShotCallback(OneShotTime whence, FrameNumber frame,
                               CallbackBase_2Data<int, int>* callback)
 {
 #if NOTFINISHED
@@ -152,7 +195,7 @@
   callbackLock.writeUnlock();
 }
 
-void RTRT::addParallelOneShotCallback(Whence whence, long frame,
+void RTRT::addParallelOneShotCallback(OneShotTime whence, FrameNumber frame,
                                       CallbackBase_2Data<int, int>* callback)
 {
   callbackLock.writeLock();
@@ -165,7 +208,6 @@
   callbackLock.writeUnlock();
 }
 
-
 CallbackHandle* RTRT::registerSetupCallback(SetupCallback* callback)
 {
   setupCallbacks.push_back(callback);
@@ -309,6 +351,12 @@
   callbackLock.writeUnlock();
 }
 
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// Time Methods
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
 void RTRT::setTimeMode(TimeMode /*tm*/, double /*rate*/)
 {
   NOT_FINISHED("RTRT::setTimeMode");
@@ -316,6 +364,12 @@
 
 #define MANTA_CHECK_POINTER(ptr) if (ptr == 0) throw SCIRun::InvalidState( 
#ptr, __FILE__, __LINE__ ); 
 
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// BEGIN RENDERING
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
 void RTRT::beginRendering(bool blockUntilFinished) throw (SCIRun::Exception 
&)
 {
   runningLock.lock();
@@ -349,7 +403,8 @@
     MANTA_CHECK_POINTER(channel->camera)
   }
 
-  if(!currentImageCreator)
+  // Check to see if an image creator has been specified.
+  if(create_image==0)
     throw InvalidState("Image type was not selected", __FILE__, __LINE__ );
 
 #if NOTFINISHED
@@ -396,6 +451,12 @@
   workers[0]->join();
 }
 
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// MAIN RENDERING LOOP
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
 void RTRT::internalRenderLoop(int proc, bool lateComerFlag)
 {
 #ifdef MANTA_SSE
@@ -720,8 +781,10 @@
 }
 
 
///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 // POST TRANSACTIONS  
 
///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 void RTRT::postTransactions(bool& changed)
 {
   if(transactions.size() > 0){
@@ -763,6 +826,12 @@
   }
 }
 
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// Execute Callback Helpers
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
 void RTRT::doParallelPreRenderCallbacks(int proc, int numProcs)
 {
   // All threads do the parallel pre-render callbacks
@@ -807,22 +876,11 @@
   workersWanted = 0;
 }
 
-int RTRT::createChannel(const string& spec, Camera* camera, bool stereo, int 
xres, int yres)
-{
-  string name;
-  vector<string> args;
-
-  // Parse the arg string.
-  parseSpec(spec, name, args);
-
-  // Search for an image display creator with the name.
-  ImageDisplayMapType::iterator iter = imageDisplays.find(name);
-  if(iter == imageDisplays.end())
-    throw UnknownComponent( "Image display not found", spec );
-
-  // Create the channel with the image display.
-  return createChannel( (*iter->second)(args), camera, stereo, xres, yres );
-}
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// Create Channel.
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 
 int RTRT::createChannel(ImageDisplay *image_display, Camera* camera, bool 
stereo, int xres, int yres)
 {
@@ -842,7 +900,7 @@
   channel->xres    = xres;
   channel->yres    = yres;
   channel->active  = true;
-  channel->imageCreator  = 0;
+  channel->create_image  = create_image;
   channel->pipelineDepth = 2;
   channel->images.resize(channel->pipelineDepth);
   channel->camera = camera;
@@ -856,62 +914,11 @@
   return channel->id;
 }
 
-void RTRT::registerComponent(const string& name, ImageDisplayCreator fun)
-{
-  ImageDisplayMapType::iterator iter = imageDisplays.find(name);
-  if(iter != imageDisplays.end())
-    throw IllegalValue<string>("Duplicate ImageDisplay component", name);
-  imageDisplays[name] = fun;
-}
-
-MantaInterface::listType RTRT::listImageDisplays() const
-{
-  MantaInterface::listType list;
-  for(ImageDisplayMapType::const_iterator iter = imageDisplays.begin();
-      iter != imageDisplays.end(); iter++)
-    list.push_back(iter->first);
-  return list;
-}
-
-Camera* RTRT::getCamera(int channel) const
-{
-  return channels[channel]->camera;
-}
-
-void RTRT::setCamera(int channel, Camera *camera ) {
-
-  channels[channel]->camera = camera;
-}
-
-void RTRT::getResolution(int channel, bool& stereo, int& xres, int& yres)
-{
-  stereo = channels[channel]->stereo;
-  xres = channels[channel]->xres;
-  yres = channels[channel]->yres;
-}
-
-void RTRT::changeResolution(int channel, int xres, int yres,
-                            bool changePipeline)
-{
-  channels[channel]->xres = xres;
-  channels[channel]->yres = yres;
-  if (changePipeline)
-    pipelineNeedsSetup = true;
-}
-
-ImageDisplay *RTRT::getImageDisplay( int channel ) {
-
-  return channels[channel]->display;
-}
-
-void RTRT::setImageDisplay( int channel, ImageDisplay *display ) {
-
-  channels[channel]->display = display;
-  
-  // Setup the image display with the pipeline.
-  pipelineNeedsSetup = true;
-}
-
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// Setup Pipelines by invoking setup callbacks.
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 
 void RTRT::setupPipelines(int numProcs)
 {
@@ -996,10 +1003,15 @@
   }
 }
 
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// Resize Images
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
 void RTRT::resizeImages(long frame)
 {
 
-
   for(ChannelListType::iterator iter = channels.begin();
       iter != channels.end(); iter++){
     Channel* channel = *iter;
@@ -1007,18 +1019,22 @@
     long which = frame%channel->pipelineDepth;
     bool stereo;
     int xres, yres;
+    
     if(channel->images[which])
       channel->images[which]->getResolution(stereo, xres, yres);
     if(!channel->images[which] || channel->stereo != stereo
        || channel->xres != xres || channel->yres != yres){
+
+      // Delete the image if it already exists.
       if(channel->images[which])
         delete channel->images[which];
-      ImageCreator creator = channel->imageCreator;
-      if(!creator)
-        creator = currentImageCreator;
-      channel->images[which] = (creator)(currentImageCreatorArgs,
-                                         channel->stereo,
-                                         channel->xres, channel->yres);
+      
+      // Invoke the create image callback.
+      channel->create_image->call( channel->stereo,
+                                   channel->xres,
+                                   channel->yres,
+                                   channel->images[which] );
+      
     } else {
       if (channel->pipelineDepth > 1)
         channel->images[which]->setValid(false);
@@ -1026,529 +1042,143 @@
   }
 }
 
-bool RTRT::selectImageType(const string& spec)
-{
-  string name;
-  currentImageCreatorArgs.resize(0);
-  parseSpec(spec, name, currentImageCreatorArgs);
-  ImageCreatorMapType::iterator iter = imageCreators.find(name);
-  if(iter == imageCreators.end())
-    return false;
-  currentImageCreator = iter->second;
-  return true;
-}
 
-void RTRT::registerComponent(const string& name, ImageCreator fun)
-{
-  ImageCreatorMapType::iterator iter = imageCreators.find(name);
-  if(iter != imageCreators.end())
-    throw IllegalValue<string>("Duplicate ImageCreator component", name);
-  imageCreators[name] = fun;
-}
-
-MantaInterface::listType RTRT::listImageTypes() const
-{
-  MantaInterface::listType list;
-  for(ImageCreatorMapType::const_iterator iter = imageCreators.begin();
-      iter != imageCreators.end(); iter++)
-    list.push_back(iter->first);
-  return list;
-}
 
-void RTRT::setImageTraverser( ImageTraverser *image_traverser_ ) {
 
-  currentImageTraverser = image_traverser_;
-}
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// Pipeline Get / Set Methods.
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 
-ImageTraverser *RTRT::getImageTraverser() {
+// Image Display
 
-  return currentImageTraverser;
-}
+ImageDisplay *RTRT::getImageDisplay( int channel ) {
+  return channels[channel]->display; }
 
-bool RTRT::selectImageTraverser(const string& spec)
-{
-  string name;
-  vector<string> args;
-  parseSpec(spec, name, args);
-  ImageTraverserMapType::iterator iter = imageTraversers.find(name);
-  if(iter == imageTraversers.end())
-    return false;
-  currentImageTraverser = (*iter->second)(args);
+void RTRT::setImageDisplay( int channel, ImageDisplay *display ) {
 
-  // Setup the pipeline again so that the traverser's
-  // setup display channel will be called.
+  channels[channel]->display = display;
+  
+  // Setup the image display with the pipeline.
   pipelineNeedsSetup = true;
-
-  return true;
 }
 
-void RTRT::registerComponent(const string& name, ImageTraverserCreator fun)
-{
-  ImageTraverserMapType::iterator iter = imageTraversers.find(name);
-  if(iter != imageTraversers.end())
-    throw IllegalValue<string>("Duplicate ImageTraverser component", name);
-  imageTraversers[name] = fun;
-}
-
-MantaInterface::listType RTRT::listImageTraversers() const
-{
-  MantaInterface::listType list;
-  for(ImageTraverserMapType::const_iterator iter = imageTraversers.begin();
-      iter != imageTraversers.end(); iter++)
-    list.push_back(iter->first);
-  return list;
-}
+// Camera
 
-bool RTRT::selectLoadBalancer(const string& spec)
-{
-  string name;
-  vector<string> args;
-  parseSpec(spec, name, args);
-  LoadBalancerMapType::iterator iter = loadBalancers.find(name);
-  if(iter == loadBalancers.end())
-    return false;
-  currentLoadBalancer = (*iter->second)(args);
-  pipelineNeedsSetup = true;
-  return true;
+void RTRT::setCamera(int channel, Camera *camera ) {
+  channels[channel]->camera = camera;
 }
 
-void RTRT::registerComponent(const string& name, LoadBalancerCreator fun)
-{
-  LoadBalancerMapType::iterator iter = loadBalancers.find(name);
-  if(iter != loadBalancers.end())
-    throw IllegalValue<string>("Duplicate LoadBalancer component", name);
-  loadBalancers[name] = fun;
+Camera* RTRT::getCamera(int channel) const {
+  return channels[channel]->camera;
 }
 
-MantaInterface::listType RTRT::listLoadBalancers() const
-{
-  MantaInterface::listType list;
-  for(LoadBalancerMapType::const_iterator iter = loadBalancers.begin();
-      iter != loadBalancers.end(); iter++)
-    list.push_back(iter->first);
-  return list;
-}
+// Resolution.
 
-void RTRT::setPixelSampler( PixelSampler *sampler_ ) {
-  currentPixelSampler = sampler_;
+void RTRT::getResolution(int channel, bool& stereo, int& xres, int& yres) {
+  stereo = channels[channel]->stereo;
+  xres = channels[channel]->xres;
+  yres = channels[channel]->yres;
 }
 
-bool RTRT::selectPixelSampler(const string& spec)
-{
-  string name;
-  vector<string> args;
-  parseSpec(spec, name, args);
-  PixelSamplerMapType::iterator iter = pixelSamplers.find(name);
-  if(iter == pixelSamplers.end())
-    return false;
-  // Try to clean up our memory.  This function should be called with
-  // the transactions or before rendering.
-  if (running) {
-    // Currently there isn't anything special to make sure this is
-    // called safely, so you are on your own.
-  }
-  if (currentPixelSampler) {
-    // It would be nice to see if the current pixel sampler can be
-    // simply updated rather than recreated, but for now we will do it
-    // the hard way.
-    delete currentPixelSampler;
-  }
-  currentPixelSampler = (*iter->second)(args);
-  pipelineNeedsSetup = true;
-  return true;
+void RTRT::changeResolution(int channel, int xres, int yres, bool 
changePipeline) {
+  channels[channel]->xres = xres;
+  channels[channel]->yres = yres;
+  if (changePipeline)
+    pipelineNeedsSetup = true;
 }
 
-void RTRT::registerComponent(const string& name, PixelSamplerCreator fun)
-{
-  PixelSamplerMapType::iterator iter = pixelSamplers.find(name);
-  if(iter != pixelSamplers.end())
-    throw IllegalValue<string>("Duplicate PixelSampler component", name);
-  pixelSamplers[name] = fun;
-}
+// Image Traverser
 
-MantaInterface::listType RTRT::listPixelSamplers() const
-{
-  MantaInterface::listType list;
-  for(PixelSamplerMapType::const_iterator iter = pixelSamplers.begin();
-      iter != pixelSamplers.end(); iter++)
-    list.push_back(iter->first);
-  return list;
+void RTRT::setImageTraverser( ImageTraverser *image_traverser_ ) {
+  currentImageTraverser = image_traverser_;
 }
 
-void RTRT::setRenderer( Renderer *renderer_ ) {
-
-  currentRenderer = renderer_;
+ImageTraverser *RTRT::getImageTraverser() const {
+  return currentImageTraverser;
 }
 
-Renderer* RTRT::getRenderer(void)
-{
-  return currentRenderer;
-}
+// Image Type
 
-bool RTRT::selectRenderer(const string& spec)
-{
-  string name;
-  vector<string> args;
-  parseSpec(spec, name, args);
-  RendererMapType::iterator iter = renderers.find(name);
-  if(iter == renderers.end())
-    return false;
-  currentRenderer = (*iter->second)(args);
-  return true;
-}
+void RTRT::setCreateImageCallback( CreateImageCallback * const callback ) {
 
-void RTRT::registerComponent(const string& name, RendererCreator fun)
-{
-  RendererMapType::iterator iter = renderers.find(name);
-  if(iter != renderers.end())
-    throw IllegalValue<string>("Duplicate Renderer component", name);
-  renderers[name] = fun;
+  create_image = callback;
 }
+MantaInterface::CreateImageCallback * RTRT::getCreateImageCallback() const {
 
-MantaInterface::listType RTRT::listRenderers() const
-{
-  MantaInterface::listType list;
-  for(RendererMapType::const_iterator iter = renderers.begin();
-      iter != renderers.end(); iter++)
-    list.push_back(iter->first);
-  return list;
+  return create_image;
 }
 
-bool RTRT::addIdleMode(const string& spec)
-{
-  string name;
-  vector<string> args;
-  parseSpec(spec, name, args);
-  IdleModeMapType::iterator iter = idleModes.find(name);
-  if(iter == idleModes.end())
-    return false;
-  currentIdleModes.push_back((*iter->second)(args));
-  return true;
-}
+// Load Balancer.
 
-void RTRT::registerComponent(const string& name, IdleModeCreator fun)
-{
-  IdleModeMapType::iterator iter = idleModes.find(name);
-  if(iter != idleModes.end())
-    throw IllegalValue<string>("Duplicate IdleMode component", name);
-  idleModes[name] = fun;
-}
+void RTRT::setLoadBalancer( LoadBalancer *load_balancer_ ) {
 
-MantaInterface::listType RTRT::listIdleModes() const
-{
-  MantaInterface::listType list;
-  for(IdleModeMapType::const_iterator iter = idleModes.begin();
-      iter != idleModes.end(); iter++)
-    list.push_back(iter->first);
-  return list;
+  currentLoadBalancer = load_balancer_;
 }
 
-void RTRT::setShadowAlgorithm(ShadowAlgorithm* shadows)
-{
-  currentShadowAlgorithm = shadows;
-}
+LoadBalancer *RTRT::getLoadBalancer() const {
 
-ShadowAlgorithm* RTRT::getShadowAlgorithm(void)
-{
-  return currentShadowAlgorithm;
+  return currentLoadBalancer;
 }
 
-bool RTRT::selectShadowAlgorithm(const string& spec)
-{
-  string name;
-  vector<string> args;
-  parseSpec(spec, name, args);
-  ShadowAlgorithmMapType::iterator iter = shadowAlgorithms.find(name);
-  if(iter == shadowAlgorithms.end())
-    return false;
-  currentShadowAlgorithm = (*iter->second)(args);
-  return true;
-}
+// Pixel Sampler
 
-void RTRT::registerComponent(const string& name, ShadowAlgorithmCreator fun)
-{
-  ShadowAlgorithmMapType::iterator iter = shadowAlgorithms.find(name);
-  if(iter != shadowAlgorithms.end())
-    throw IllegalValue<string>("Duplicate ShadowAlgorithm component", name);
-  shadowAlgorithms[name] = fun;
+void RTRT::setPixelSampler( PixelSampler *sampler_ ) {
+  currentPixelSampler = sampler_;
 }
 
-MantaInterface::listType RTRT::listShadowAlgorithms() const
-{
-  MantaInterface::listType list;
-  for(ShadowAlgorithmMapType::const_iterator iter = shadowAlgorithms.begin();
-      iter != shadowAlgorithms.end(); iter++)
-    list.push_back(iter->first);
-  return list;
+PixelSampler *RTRT::getPixelSampler() const {
+  return currentPixelSampler;
 }
 
-Camera* RTRT::createCamera(const string& spec)
-{
-  string name;
-  vector<string> args;
-  parseSpec(spec, name, args);
-  CameraMapType::iterator iter = cameras.find(name);
-  if(iter == cameras.end()){
-    return 0;
-  }
-  return (*iter->second)(args);
-}
+// Renderer
 
-void RTRT::registerComponent(const string& name, CameraCreator fun)
-{
-  CameraMapType::iterator iter = cameras.find(name);
-  if(iter != cameras.end())
-    throw IllegalValue<string>("Duplicate Camera component", name);
-  cameras[name] = fun;
-}
+void RTRT::setRenderer( Renderer *renderer_ ) {
 
-MantaInterface::listType RTRT::listCameras() const
-{
-  MantaInterface::listType list;
-  for(CameraMapType::const_iterator iter = cameras.begin();
-      iter != cameras.end(); iter++)
-    list.push_back(iter->first);
-  return list;
+  currentRenderer = renderer_;
 }
 
-bool RTRT::haveScene()
-{
-  return scene != 0;
-}
+Renderer* RTRT::getRenderer(void) const {
 
-void RTRT::setScene(Scene* newScene)
-{
-  scene = newScene;
+  return currentRenderer;
 }
 
-Scene *RTRT::getScene() {
-
-  return scene;
-}
+// Idle Mode
 
-bool RTRT::readScene(const string& spec)
+RTRT::IdleModeHandle RTRT::addIdleMode(IdleMode *idle_mode)
 {
-  string name;
-  vector<string> args;
-  parseSpec(spec, name, args);
-
-  // Pull off the suffix...
-  string::size_type dot = name.rfind('.');
-  string suffix;
-  if(dot == string::npos){
-    suffix="";
-  } else {
-    suffix = name.substr(dot+1);
-  }
-  Scene* newScene = 0;
-
-  // These are to try and guess what the shared library extension is
-  // on various systems.
-  string system_suffix;
-#if defined (__APPLE__)
-  system_suffix = "dylib";
-#elif defined (_WIN32) || defined (__CYGWIN__)
-  system_suffix = "dll";
-#else
-  system_suffix = "so";
-#endif
-
-  if((suffix == "mo") || (suffix == "so") || (suffix == "dylib") ||
-     (suffix == "dll")) {
-    // Do this twice - once silently and once printing errors
-    newScene = readMOScene(name, args, true);
-    // if(!newScene)
-    //   readMOScene(name, args, true);
-  } else {
-    // Try reading it as an MO
-    newScene = readMOScene(name+"."+system_suffix, args, false);
-  }
-  if(!newScene){
-    return false;
-  } else {
-    scene = newScene;
-    return true;
-  }
+  currentIdleModes.push_back(idle_mode);
+  return currentIdleModes.size()-1;
 }
 
-void RTRT::readStack(const string &name, const vector<string> &args )
-{
-  readMOStack(name, args, true);
-}
+IdleMode *RTRT::getIdleMode( IdleModeHandle i ) const {
 
-void RTRT::setScenePath(const string& path)
-{
-  scenePath = path;
+  return currentIdleModes[i];
 }
 
-Group* RTRT::makeGroup(const string& groupSpec)
+void RTRT::setShadowAlgorithm(ShadowAlgorithm* shadows)
 {
-  string name;
-  vector<string> args;
-  parseSpec(groupSpec, name, args);
-  GroupMapType::iterator iter = groups.find(name);
-  if(iter == groups.end())
-    return 0;
-  Group* group = (*iter->second)(args);
-  return group;
+  currentShadowAlgorithm = shadows;
 }
 
-void RTRT::registerObject(const string& name, GroupCreator creator)
+ShadowAlgorithm* RTRT::getShadowAlgorithm(void) const 
 {
-  GroupMapType::iterator iter = groups.find(name);
-  if(iter != groups.end())
-    throw IllegalValue<string>("Duplicate group", name);
-  groups[name] = creator;
+  return currentShadowAlgorithm;
 }
 
-MantaInterface::listType RTRT::listGroups() const
+void RTRT::setScene(Scene* newScene)
 {
-  MantaInterface::listType list;
-  for(GroupMapType::const_iterator iter = groups.begin();
-      iter != groups.end(); iter++)
-    list.push_back(iter->first);
-  return list;
+  scene = newScene;
 }
 
-Scene* RTRT::readMOScene(const string& name, const vector<string>& args,
-                         bool printErrors)
-{
-  // Determine which directories to search for the scene library.
-  string fullname = name;
-  vector<string> dirs = split_string(scenePath, ':');
-  for(vector<string>::iterator dir = dirs.begin(); dir != dirs.end(); dir++){
-
-    fullname = *dir + "/" + name;
-    
-    // Check to see if the file exists.
-    struct stat statbuf;
-    if(stat(fullname.c_str(), &statbuf) == 0){
-      break;
-    }
-  }
-
-  // Attempt to open the file name.
-  void* handle=dlopen(fullname.c_str(), RTLD_NOW);
-  if(!handle){
-    throw InputError( dlerror() );
-  }
-
-  // Look up the scene function.
-  void* scene_fn=dlsym(handle, "make_scene");
-  if(!scene_fn){
-    throw InputError( "Could not find \"make_scene\" function.\n" );
-  }
-
-  typedef Scene* (*MakerType)(const ReadContext&, const vector<string>&);
-  MakerType make_scene = (MakerType)(scene_fn);
-
-  // Call the make_scene function.
-  ReadContext context(this);
-  Scene* scene=(*make_scene)(context, args);
-  if(!scene){
-    throw InputError( "make_scene returned null" );
-  }
-
-  return scene;
-
-}
+Scene *RTRT::getScene() { return scene; }
 
 
///////////////////////////////////////////////////////////////////////////////
-// This dynamically loads code to configure the manta rendering stack.
-void RTRT::readMOStack(const string& name, const vector<string>& args, bool 
printErrors )
-{
-
-  // Assume an absolute path by default
-  string fullname = name;
-  
-  vector<string> dirs = split_string(scenePath, ':');
-  for(vector<string>::iterator dir = dirs.begin(); dir != dirs.end(); dir++){
-
-    fullname = *dir + "/"+name;
-    
-    // Check to see if the file exists in the directory.
-    struct stat statbuf;
-    if(stat(fullname.c_str(), &statbuf) != 0){
-      break;
-    }
-  }
-  
-  // Open the file.
-  void* handle=dlopen(fullname.c_str(), RTLD_NOW);
-  if(!handle){
-    throw InputError( "Could not load stack" );
-  }
-  
-  // Access the make_stack symbol
-  void* stack_fn=dlsym(handle, "make_stack");
-  if(!stack_fn){
-    if(printErrors){
-      cerr << "Stack configuration file found, but make_stack() function not 
found\n";
-    }
-    return;
-  }
-  
-  ///////////////////////////////////////////////////////////////////////////
-  // Invoke the function.  
-  typedef void (*MakerType)(ReadContext &, const vector<string>&);
-  MakerType make_stack = (MakerType)(stack_fn);
-  ReadContext context(this);
-  
-  // Call the function.
-  (*make_stack)(context, args);
-  
-}
-
-UserInterface* RTRT::createUserInterface(const string& spec)
-{
-  string name;
-  vector<string> args;
-  parseSpec(spec, name, args);
-  UserInterfaceMapType::iterator iter = userInterfaces.find(name);
-  if(iter == userInterfaces.end())
-    return 0;
-  // This will create a new UserInterface
-  UserInterface *ui = (*iter->second)(args, this);
-  return ui;
-}
-
-void RTRT::registerComponent(const string& name, UserInterfaceCreator 
creator)
-{
-  // Allow components to be re-registered.
-  // UserInterfaceMapType::iterator iter = userInterfaces.find(name);
-  // if(iter != userInterfaces.end())
-  //   throw IllegalValue<string>("Duplicate User Interface component", 
name);
-  userInterfaces[name] = creator;
-}
-
-MantaInterface::listType RTRT::listUserInterfaces() const
-{
-  MantaInterface::listType list;
-  for(UserInterfaceMapType::const_iterator iter = userInterfaces.begin();
-      iter != userInterfaces.end(); iter++)
-    list.push_back(iter->first);
-  return list;
-}
-
-bool RTRT::queryState(const string& which, vector<string>& results) {
-  if (which == "shadows") {
-    results.push_back(currentShadowAlgorithm->getName());
-    results.push_back(currentShadowAlgorithm->getSpecs());
-  } else if (which == "numworkers") {
-    int numworkers = static_cast<int>(workers.size());
-    char buf[100];
-    sprintf(buf, "%d", numworkers);
-    results.push_back(buf);
-  }  else {
-    return false;
-  }
-  return true;
-}
-
-/*
- * Transactions
- */
-
+///////////////////////////////////////////////////////////////////////////////
+// Transactions.
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 void RTRT::addTransaction(TransactionBase* transaction)
 {
   transaction_lock.lock();

Modified: trunk/Engine/Control/RTRT.h
==============================================================================
--- trunk/Engine/Control/RTRT.h (original)
+++ trunk/Engine/Control/RTRT.h Fri Oct 13 17:18:43 2006
@@ -1,3 +1,30 @@
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005-2006
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
 
 #ifndef Manta_Engine_RTRT_h
 #define Manta_Engine_RTRT_h
@@ -34,97 +61,74 @@
     RTRT();
     ~RTRT();
 
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Pipeline Components.
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    
     // Image Modes (opengl, file, mpeg, etc.)
-    virtual int createChannel(const string& modespec, Camera* camera,
-                             bool stereo, int xres, int yres);
-    virtual int createChannel(ImageDisplay *image_display, Camera* camera,
-                              bool stereo, int xres, int yres);
-    virtual void registerComponent(const string& name, ImageDisplayCreator 
display);
-    virtual listType listImageDisplays() const;
+    virtual int createChannel(ImageDisplay *image_display, Camera* camera, 
bool stereo, int xres, int yres);
+
+    virtual ImageDisplay *getImageDisplay( int channel );
+    virtual void setImageDisplay( int channel, ImageDisplay *display );
+    
     virtual Camera* getCamera(int channel) const;
                virtual void    setCamera(int channel, Camera *camera );
+
     virtual void getResolution(int channel, bool& stereo, int& xres, int& 
yres);
-    virtual void changeResolution(int channel, int xres, int yres,
-                                  bool changePipeline);
-    virtual ImageDisplay *getImageDisplay( int channel );
-    virtual void setImageDisplay( int channel, ImageDisplay *display );
+    virtual void changeResolution(int channel, int xres, int yres, bool 
changePipeline);
     
     // Image Traversers
     virtual void setImageTraverser( ImageTraverser *image_traverser_ );
-    virtual ImageTraverser *getImageTraverser();
-    virtual bool selectImageTraverser(const string& spec);
-    virtual void registerComponent(const string& name, ImageTraverserCreator 
creator);
-    virtual listType listImageTraversers() const;
+    virtual ImageTraverser *getImageTraverser() const;
 
     // Image Types (rgb, rgba, float, etc.)
-    virtual bool selectImageType(const string& spec);
-    virtual void registerComponent(const string& name, ImageCreator display);
-    virtual listType listImageTypes() const;
+    virtual void setCreateImageCallback( CreateImageCallback * const 
callback );
+    virtual CreateImageCallback * getCreateImageCallback() const;
 
     // Load Balancers
-    virtual bool selectLoadBalancer(const string& spec);
-    virtual void registerComponent(const string& name, LoadBalancerCreator 
creator);
-    virtual listType listLoadBalancers() const;
+    virtual void setLoadBalancer( LoadBalancer *load_balancer_ );
+    virtual LoadBalancer *getLoadBalancer() const;
 
     // PixelSamplers
                virtual void setPixelSampler( PixelSampler *sampler_ );
-    virtual bool selectPixelSampler(const string& spec);
-    virtual void registerComponent(const string& name, PixelSamplerCreator 
creator);
-    virtual listType listPixelSamplers() const;
-
+    virtual PixelSampler *getPixelSampler() const;
+    
     // Renderers
     virtual void setRenderer( Renderer *renderer_ );
-    virtual Renderer* getRenderer();
-    virtual bool selectRenderer(const string& spec);
-    virtual void registerComponent(const string& name, RendererCreator 
creator);
-    virtual listType listRenderers() const;
+    virtual Renderer* getRenderer() const;
 
     // Shadow Algorithms
     virtual void setShadowAlgorithm(ShadowAlgorithm* shadows);
-    virtual ShadowAlgorithm* getShadowAlgorithm();
-    virtual bool selectShadowAlgorithm(const string& spec);
-    virtual void registerComponent(const string& name, 
ShadowAlgorithmCreator creator);
-    virtual listType listShadowAlgorithms() const;
+    virtual ShadowAlgorithm* getShadowAlgorithm() const;
 
     // Idle modes
-    virtual bool addIdleMode(const string& spec);
-    virtual void registerComponent(const string& name, IdleModeCreator 
creator);
-    virtual listType listIdleModes() const;
-
-    // Camera
-    virtual Camera* createCamera(const string& spec);
-    virtual void registerComponent(const string& name, CameraCreator 
creator);
-    virtual listType listCameras() const;
-
+    virtual IdleModeHandle addIdleMode( IdleMode *idle_mode );
+    virtual IdleMode *getIdleMode( IdleModeHandle i ) const;
+    
     // Scenes
-    virtual bool haveScene();
     virtual void setScene(Scene* scene);
                virtual Scene *getScene();
-    virtual bool readScene(const string& sceneSpec/*, const vector<string> 
&args*/);
-    virtual void readStack( const string &name, const vector<string> &args );
-    virtual void setScenePath(const string& path);
-
-    // Groups
-    virtual Group* makeGroup(const string& groupSpec);
-    virtual void registerObject(const string& name, GroupCreator creator);
-    virtual listType listGroups() const;
 
-    // Callbacks
-    virtual void addOneShotCallback(Whence whence, long frame,
-                                    CallbackBase_2Data<int, int>* callback);
-    virtual void addParallelOneShotCallback(Whence whence, long frame,
-                                            CallbackBase_2Data<int, int>* 
callback);    
-    virtual CallbackHandle* registerSetupCallback(SetupCallback*);
-    virtual CallbackHandle* 
registerSerialAnimationCallback(CallbackBase_3Data<int, int, bool&>*);
-    virtual CallbackHandle* 
registerParallelAnimationCallback(CallbackBase_3Data<int, int, bool&>*);
-    virtual CallbackHandle* 
registerSerialPreRenderCallback(CallbackBase_2Data<int, int>*);
-    virtual CallbackHandle* 
registerParallelPreRenderCallback(CallbackBase_2Data<int, int>*);
-    virtual CallbackHandle* registerTerminationCallback( CallbackBase_1Data< 
MantaInterface *> *);
-    virtual void unregisterCallback(CallbackHandle*);
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Time Mode
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
 
     // Control of time/animation
     virtual void setTimeMode(TimeMode tm, double rate);
 
+    // Query functions
+    virtual int getCurrentFrame() const { return animFrameState.frameNumber; 
};
+    
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Control
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////   
 
+    
     // Parallel processing
     virtual void changeNumWorkers(int workers);
     virtual TValue<int>& numWorkers();
@@ -132,35 +136,86 @@
     // Control
     virtual void beginRendering(bool blockUntilFinished) throw 
(SCIRun::Exception &);
     virtual void blockUntilFinished();
-
-    // Control
     virtual void finish();
-
-    // User Interfaces
-    virtual UserInterface* createUserInterface(const string& spec);
-    virtual void registerComponent(const string& name, UserInterfaceCreator 
creator);
-    virtual listType listUserInterfaces() const;
-
-
-    // Query functions
-    virtual int getCurrentFrame() const { return animFrameState.frameNumber; 
};
     
-    // what specifies what you want which is then placed in result.
-    // If the function cannot determine what you want, false is return.
-    virtual bool queryState(const string& what, vector<string>& results);
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Transactions
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
     
     // Transactions
     virtual void addTransaction(TransactionBase* );
-               
+
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Callbacks.
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    
+    // Callbacks
+    virtual void addOneShotCallback(OneShotTime whence, FrameNumber frame, 
CallbackBase_2Data<int, int>* callback);
+    virtual void addParallelOneShotCallback(OneShotTime whence, FrameNumber 
frame, CallbackBase_2Data<int, int>* callback);    
+
+    virtual CallbackHandle* registerSetupCallback(SetupCallback*);
+    virtual CallbackHandle* 
registerSerialAnimationCallback(CallbackBase_3Data<int, int, bool&>*);
+    virtual CallbackHandle* 
registerParallelAnimationCallback(CallbackBase_3Data<int, int, bool&>*);
+    virtual CallbackHandle* 
registerSerialPreRenderCallback(CallbackBase_2Data<int, int>*);
+    virtual CallbackHandle* 
registerParallelPreRenderCallback(CallbackBase_2Data<int, int>*);
+    virtual CallbackHandle* registerTerminationCallback( CallbackBase_1Data< 
MantaInterface *> *);
+    virtual void unregisterCallback(CallbackHandle*);
+    
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Debug
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////   
 
+    
                // Debug:
                virtual void shootOneRay( Color &result_color, RayPacket 
&result_rays, Real image_x, Real image_y, int channel_index );
-  
+
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+
+    // End of Public Interface.
+
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
        
        protected:
     void internalRenderLoop(int workerIndex, bool lateComerFlag);
 
     
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Channel Structure.
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    struct Channel {
+      int id;                   // The index into the list of
+                                // channels, use this index to access
+                                // channel specifics through other
+                                // functions.
+      ImageDisplay* display;
+      int xres, yres;
+      bool stereo;
+      int pipelineDepth;
+      bool active;
+      CreateImageCallback *create_image;
+      vector<Image*> images;
+      Camera* camera;
+    };
+    typedef vector<Channel*> ChannelListType;
+    ChannelListType channels;
+    
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
     // Worker class for the RTRT Pipeline.
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
     class Worker : public SCIRun::Runnable {
     public:
       Worker(RTRT* rtrt, int workerIndex, bool lateComerFlag);
@@ -172,35 +227,51 @@
       int workerIndex;
       bool lateComerFlag;
     };
+
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Pipeline Configuration.
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////   
 
+
+    ImageTraverser*  currentImageTraverser;
+    LoadBalancer*    currentLoadBalancer;
+    PixelSampler*    currentPixelSampler;
+    Renderer*        currentRenderer;
+    ShadowAlgorithm* currentShadowAlgorithm;
+    vector<IdleMode*> currentIdleModes;
+
+    CreateImageCallback *create_image;
     
   private:
     RTRT(const RTRT&);
     RTRT& operator=(const RTRT&);
 
+    // Callback Helpers.
     void doParallelAnimationCallbacks(bool& changed, int proc, int numProcs);
     void doSerialAnimationCallbacks(bool& changed, int proc, int numProcs);
     
     void doParallelPreRenderCallbacks(int proc, int numProcs);
     void doSerialPreRenderCallbacks(int proc, int numProcs);
 
-    void doIdleModeCallbacks(bool changed, bool firstFrame,
-                             bool& pipelineNeedsSetup,
-                             int proc, int numProcs);
+    void doIdleModeCallbacks(bool changed, bool firstFrame, bool& 
pipelineNeedsSetup, int proc, int numProcs);
     void doTerminationCallbacks();
-
-
     
     void resizeImages(long frameNumber);
     void setupPipelines(int numProcs);
+
+    // Worker Thread Info.
     TValue<int> workersWanted;
     int workersRendering;
     int workersAnimAndImage;
     bool workersChanged;
     vector<SCIRun::Thread*> workers;
 
+    // Running flag.
     SCIRun::Mutex runningLock;
     bool running;
 
+    // Pipeline Synchronization barriers.
     SCIRun::CrowdMonitor callbackLock;
     SCIRun::Barrier barrier1;
     SCIRun::Barrier barrier2;
@@ -212,77 +283,42 @@
     vector<ReductionData> changedFlags;
     bool lastChanged;
 
-    // Callbacks
-    typedef multimap<long, CallbackBase_2Data<int, int>*, less<long> > 
OneShotMapType;
-    OneShotMapType oneShots;
+    
///////////////////////////////////////////////////////////////////////////
+    // Callbacks Queues
 
+    typedef multimap<long, CallbackBase_2Data<int, int>*, less<long> > 
OneShotMapType;
     typedef multimap<long, CallbackBase_2Data<int, int>*, less<long> > 
ParallelOneShotMapType;
+    
+    OneShotMapType         oneShots;
     ParallelOneShotMapType parallelOneShots;
 
+    // Helper function.
     void deleteParallelOneShot( ParallelOneShotMapType::iterator iter );
-    
+
     typedef vector<CallbackBase_2Data<int, int>*> PRCallbackMapType;
     typedef vector<CallbackBase_3Data<int, int, bool&>*> ACallbackMapType;
+    typedef vector<CallbackBase_1Data<MantaInterface *>*> TCallbackMapType;
+    typedef vector<SetupCallback *>                       SCallbackMapType;
+
+    // Callback lists.
     PRCallbackMapType parallelPreRenderCallbacks;
     PRCallbackMapType serialPreRenderCallbacks;
-    ACallbackMapType parallelAnimationCallbacks;
-    ACallbackMapType serialAnimationCallbacks;
-    vector<SetupCallback*> setupCallbacks;
-
-    typedef vector<CallbackBase_1Data<MantaInterface *>*> TCallbackMapType;
-    TCallbackMapType terminationCallbacks;
-    
+    ACallbackMapType  parallelAnimationCallbacks;
+    ACallbackMapType  serialAnimationCallbacks;
+    SCallbackMapType  setupCallbacks;
+    TCallbackMapType  terminationCallbacks;
 
+    
///////////////////////////////////////////////////////////////////////////
     // Transactions
     typedef list<TransactionBase*> TransactionListType;
+
     TransactionListType transactions;
     SCIRun::Mutex transaction_lock;
+
+    // Transaction helper.
     void postTransactions(bool& changed);
     bool verbose_transactions;
 
-    // Component databases and current instances
-    typedef map<string, ImageDisplayCreator> ImageDisplayMapType;
-    ImageDisplayMapType imageDisplays;
-               
-    typedef map<string, ImageCreator> ImageCreatorMapType;
-    ImageCreatorMapType imageCreators;
-    
-               vector<string> currentImageCreatorArgs;
-    ImageCreator currentImageCreator;
-    typedef map<string, ImageTraverserCreator> ImageTraverserMapType;
-    
-               ImageTraverserMapType imageTraversers;
-    ImageTraverser* currentImageTraverser;
-    
-               typedef map<string, LoadBalancerCreator> LoadBalancerMapType;
-    LoadBalancerMapType loadBalancers;
-    LoadBalancer* currentLoadBalancer;
-    
-               typedef map<string, PixelSamplerCreator> PixelSamplerMapType;
-    PixelSamplerMapType pixelSamplers;
-    PixelSampler* currentPixelSampler;
-    
-               typedef map<string, RendererCreator> RendererMapType;
-    RendererMapType renderers;
-    Renderer* currentRenderer;
-    
-               typedef map<string, ShadowAlgorithmCreator> 
ShadowAlgorithmMapType;
-    ShadowAlgorithmMapType shadowAlgorithms;
-    ShadowAlgorithm* currentShadowAlgorithm;
-    
-               typedef map<string, IdleModeCreator> IdleModeMapType;
-    IdleModeMapType idleModes;
-    vector<IdleMode*> currentIdleModes;
-    
-               typedef map<string, CameraCreator> CameraMapType;
-    CameraMapType cameras;
-    
-               typedef map<string, UserInterfaceCreator> 
UserInterfaceMapType;
-    UserInterfaceMapType userInterfaces;
-    
-               typedef map<string, GroupCreator> GroupMapType;
-    GroupMapType groups;
-
     // The pipeline
     bool pipelineNeedsSetup;
 
@@ -297,34 +333,12 @@
     FrameState renderFrameState;
     char pad2[MAXCACHELINESIZE];
 
-    struct Channel {
-      int id;                   // The index into the list of
-                                // channels, use this index to access
-                                // channel specifics through other
-                                // functions.
-      ImageDisplay* display;
-      int xres, yres;
-      bool stereo;
-      int pipelineDepth;
-      bool active;
-      ImageCreator imageCreator;
-      vector<Image*> images;
-      Camera* camera;
-    };
-    typedef vector<Channel*> ChannelListType;
-    ChannelListType channels;
-
     // Thread local storage allocator.
     ThreadStorage *thread_storage;
     
     Scene* scene;
-    string scenePath;
 
     SCIRun::Mutex channel_create_lock;
-
-    Scene* readMOScene(const string& name, const vector<string>& args,
-                       bool printErrors);
-    void readMOStack(const string& name, const vector<string>& args, bool 
printErrors );
   };
 }
 

Modified: trunk/Engine/Factory/CMakeLists.txt
==============================================================================
--- trunk/Engine/Factory/CMakeLists.txt (original)
+++ trunk/Engine/Factory/CMakeLists.txt Fri Oct 13 17:18:43 2006
@@ -1,6 +1,8 @@
 SET (Manta_Factory_SRCS
   Create.cc
   Create.h
+  Factory.cc
+  Factory.h
   RegisterKnownComponents.cc
   RegisterKnownComponents.h
   )

Modified: trunk/Engine/Factory/Create.cc
==============================================================================
--- trunk/Engine/Factory/Create.cc      (original)
+++ trunk/Engine/Factory/Create.cc      Fri Oct 13 17:18:43 2006
@@ -1,6 +1,34 @@
 
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005-2006
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
 #include <Engine/Factory/Create.h>
-#include <Engine/Factory/RegisterKnownComponents.h>
+#include <Engine/Factory/Factory.h>
 #include <Engine/Control/RTRT.h>
 
 using namespace Manta;
@@ -9,7 +37,6 @@
   MantaInterface* createManta()
   {
     MantaInterface* manta = new RTRT();
-    registerKnownComponents(manta);
     return manta;
   }
 }

Added: trunk/Engine/Factory/Factory.cc
==============================================================================
--- (empty file)
+++ trunk/Engine/Factory/Factory.cc     Fri Oct 13 17:18:43 2006
@@ -0,0 +1,554 @@
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005-2006
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Engine/Factory/Factory.h>
+#include <Engine/Factory/RegisterKnownComponents.h>
+
+#include <Interface/MantaInterface.h>
+#include <Interface/Context.h>
+
+#include <Core/Util/Args.h>
+#include <Core/Exceptions/UnknownComponent.h>
+#include <Core/Exceptions/IllegalValue.h>
+#include <Core/Exceptions/InputError.h>
+
+#include <Core/Containers/StringUtil.h>
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dlfcn.h>
+#include <stdio.h>
+
+
+using namespace Manta;
+using namespace SCIRun;
+
+
+ImageDisplay *Factory::createImageDisplay(const string& spec ) const
+{
+  string name;
+  vector<string> args;
+
+  // Parse the arg string.
+  parseSpec(spec, name, args);
+
+  // Search for an image display creator with the name.
+  ImageDisplayMapType::const_iterator iter = imageDisplays.find(name);
+  if(iter == imageDisplays.end())
+    throw UnknownComponent( "Image display not found", spec );
+  
+  return (*iter->second)(args);
+}
+
+void Factory::registerComponent(const string& name, ImageDisplayCreator fun)
+{
+  ImageDisplayMapType::iterator iter = imageDisplays.find(name);
+  if(iter != imageDisplays.end())
+    throw IllegalValue<string>("Duplicate ImageDisplay component", name);
+  imageDisplays[name] = fun;  
+}
+
+Factory::listType Factory::listImageDisplays() const
+{
+  Factory::listType list;
+  for(ImageDisplayMapType::const_iterator iter = imageDisplays.begin();
+      iter != imageDisplays.end(); iter++)
+    list.push_back(iter->first);
+  return list;
+}
+
+
+bool Factory::selectImageType(const string& spec) const
+{
+  string name;
+  vector<string> args;
+  parseSpec(spec, name, args);
+  
+  ImageCreatorMapType::const_iterator iter = imageCreators.find(name);
+  if(iter == imageCreators.end())
+    return 0;
+  
+  ImageCreator creator = iter->second;
+
+  // Create a static method callback.
+  manta_interface->setCreateImageCallback( Callback::create( 
&Factory::createImageCallback,
+                                                             creator,
+                                                             args ) );
+
+  return true;
+}
+
+void Factory::createImageCallback( bool stereo, int xres, int yres, Image *& 
image, ImageCreator creator, vector<string> args ) {
+
+  // Invoke the legacy image creator.
+  image = (creator)(args, stereo, xres, yres);
+}
+
+void Factory::registerComponent(const string& name, ImageCreator fun)
+{
+  ImageCreatorMapType::iterator iter = imageCreators.find(name);
+  if(iter != imageCreators.end())
+    throw IllegalValue<string>("Duplicate ImageCreator component", name);
+  imageCreators[name] = fun;
+}
+
+Factory::listType Factory::listImageTypes() const
+{
+  Factory::listType list;
+  for(ImageCreatorMapType::const_iterator iter = imageCreators.begin();
+      iter != imageCreators.end(); iter++)
+    list.push_back(iter->first);
+  return list;
+}
+
+bool Factory::selectImageTraverser(const string& spec) const
+{
+  string name;
+  vector<string> args;
+  parseSpec(spec, name, args);
+  ImageTraverserMapType::const_iterator iter = imageTraversers.find(name);
+  if(iter == imageTraversers.end())
+    return false;
+
+  manta_interface->setImageTraverser( (*iter->second)(args) );
+
+  return true;
+}
+
+void Factory::registerComponent(const string& name, ImageTraverserCreator 
fun)
+{
+  ImageTraverserMapType::iterator iter = imageTraversers.find(name);
+  if(iter != imageTraversers.end())
+    throw IllegalValue<string>("Duplicate ImageTraverser component", name);
+  imageTraversers[name] = fun;
+}
+
+Factory::listType Factory::listImageTraversers() const
+{
+  Factory::listType list;
+  for(ImageTraverserMapType::const_iterator iter = imageTraversers.begin();
+      iter != imageTraversers.end(); iter++)
+    list.push_back(iter->first);
+  return list;
+}
+
+bool Factory::selectLoadBalancer(const string& spec) const
+{
+  string name;
+  vector<string> args;
+  parseSpec(spec, name, args);
+  LoadBalancerMapType::const_iterator iter = loadBalancers.find(name);
+  if(iter == loadBalancers.end())
+    return false;
+
+  manta_interface->setLoadBalancer((*iter->second)(args));
+
+  return true;
+}
+
+void Factory::registerComponent(const string& name, LoadBalancerCreator fun)
+{
+  LoadBalancerMapType::iterator iter = loadBalancers.find(name);
+  if(iter != loadBalancers.end())
+    throw IllegalValue<string>("Duplicate LoadBalancer component", name);
+  loadBalancers[name] = fun;
+}
+
+Factory::listType Factory::listLoadBalancers() const
+{
+  Factory::listType list;
+  for(LoadBalancerMapType::const_iterator iter = loadBalancers.begin();
+      iter != loadBalancers.end(); iter++)
+    list.push_back(iter->first);
+  return list;
+}
+
+
+
+bool Factory::selectPixelSampler(const string& spec) const
+{
+  string name;
+  vector<string> args;
+  parseSpec(spec, name, args);
+  PixelSamplerMapType::const_iterator iter = pixelSamplers.find(name);
+  if(iter == pixelSamplers.end())
+    return false;
+
+  manta_interface->setPixelSampler( (*iter->second)(args) );
+
+  return true;
+}
+
+
+
+void Factory::registerComponent(const string& name, PixelSamplerCreator fun)
+{
+  PixelSamplerMapType::iterator iter = pixelSamplers.find(name);
+  if(iter != pixelSamplers.end())
+    throw IllegalValue<string>("Duplicate PixelSampler component", name);
+  pixelSamplers[name] = fun;
+}
+
+Factory::listType Factory::listPixelSamplers() const
+{
+  Factory::listType list;
+  for(PixelSamplerMapType::const_iterator iter = pixelSamplers.begin();
+      iter != pixelSamplers.end(); iter++)
+    list.push_back(iter->first);
+  return list;
+}
+
+
+bool Factory::selectRenderer(const string& spec) const
+{
+  string name;
+  vector<string> args;
+  parseSpec(spec, name, args);
+  RendererMapType::const_iterator iter = renderers.find(name);
+  if(iter == renderers.end())
+    return false;
+
+  manta_interface->setRenderer( (*iter->second)(args) );
+
+  return true;
+}
+
+void Factory::registerComponent(const string& name, RendererCreator fun)
+{
+  RendererMapType::iterator iter = renderers.find(name);
+  if(iter != renderers.end())
+    throw IllegalValue<string>("Duplicate Renderer component", name);
+  renderers[name] = fun;
+}
+
+Factory::listType Factory::listRenderers() const
+{
+  Factory::listType list;
+  for(RendererMapType::const_iterator iter = renderers.begin();
+      iter != renderers.end(); iter++)
+    list.push_back(iter->first);
+  return list;
+}
+
+MantaInterface::IdleModeHandle Factory::addIdleMode(const string& spec) const
+{
+  string name;
+  vector<string> args;
+  parseSpec(spec, name, args);
+  IdleModeMapType::const_iterator iter = idleModes.find(name);
+  if(iter == idleModes.end())
+    return (MantaInterface::IdleModeHandle)-1;
+
+  return manta_interface->addIdleMode( (*iter->second)(args) );
+}
+
+void Factory::registerComponent(const string& name, IdleModeCreator fun)
+{
+  IdleModeMapType::iterator iter = idleModes.find(name);
+  if(iter != idleModes.end())
+    throw IllegalValue<string>("Duplicate IdleMode component", name);
+  idleModes[name] = fun;
+}
+
+Factory::listType Factory::listIdleModes() const
+{
+  Factory::listType list;
+  for(IdleModeMapType::const_iterator iter = idleModes.begin();
+      iter != idleModes.end(); iter++)
+    list.push_back(iter->first);
+  return list;
+}
+
+
+bool Factory::selectShadowAlgorithm(const string& spec) const
+{
+  string name;
+  vector<string> args;
+  parseSpec(spec, name, args);
+  ShadowAlgorithmMapType::const_iterator iter = shadowAlgorithms.find(name);
+  if(iter == shadowAlgorithms.end())
+    return false;
+  manta_interface->setShadowAlgorithm(((*iter->second)(args)));
+  return true;
+}
+
+void Factory::registerComponent(const string& name, ShadowAlgorithmCreator 
fun)
+{
+  ShadowAlgorithmMapType::iterator iter = shadowAlgorithms.find(name);
+  if(iter != shadowAlgorithms.end())
+    throw IllegalValue<string>("Duplicate ShadowAlgorithm component", name);
+  shadowAlgorithms[name] = fun;
+}
+
+Factory::listType Factory::listShadowAlgorithms() const
+{
+  Factory::listType list;
+  for(ShadowAlgorithmMapType::const_iterator iter = shadowAlgorithms.begin();
+      iter != shadowAlgorithms.end(); iter++)
+    list.push_back(iter->first);
+  return list;
+}
+
+Camera* Factory::createCamera(const string& spec) const
+{
+  string name;
+  vector<string> args;
+  parseSpec(spec, name, args);
+  CameraMapType::const_iterator iter = cameras.find(name);
+  if(iter == cameras.end()){
+    return 0;
+  }
+  return (*iter->second)(args);
+}
+
+void Factory::registerComponent(const string& name, CameraCreator fun)
+{
+  CameraMapType::iterator iter = cameras.find(name);
+  if(iter != cameras.end())
+    throw IllegalValue<string>("Duplicate Camera component", name);
+  cameras[name] = fun;
+}
+
+Factory::listType Factory::listCameras() const
+{
+  Factory::listType list;
+  for(CameraMapType::const_iterator iter = cameras.begin();
+      iter != cameras.end(); iter++)
+    list.push_back(iter->first);
+  return list;
+}
+
+
+Scene *Factory::readScene(const string& spec) const
+{
+  string name;
+  vector<string> args;
+  parseSpec(spec, name, args);
+
+  // Pull off the suffix...
+  string::size_type dot = name.rfind('.');
+  string suffix;
+  if(dot == string::npos){
+    suffix="";
+  } else {
+    suffix = name.substr(dot+1);
+  }
+  Scene* newScene = 0;
+
+  // These are to try and guess what the shared library extension is
+  // on various systems.
+  string system_suffix;
+#if defined (__APPLE__)
+  system_suffix = "dylib";
+#elif defined (_WIN32) || defined (__CYGWIN__)
+  system_suffix = "dll";
+#else
+  system_suffix = "so";
+#endif
+
+  if((suffix == "mo") || (suffix == "so") || (suffix == "dylib") ||
+     (suffix == "dll")) {
+    // Do this twice - once silently and once printing errors
+    newScene = readMOScene(name, args, true);
+    // if(!newScene)
+    //   readMOScene(name, args, true);
+  } else {
+    // Try reading it as an MO
+    newScene = readMOScene(name+"."+system_suffix, args, false);
+  }
+  if(!newScene){
+    return 0;
+  } else {
+    manta_interface->setScene( newScene );
+    return newScene;
+  }
+}
+
+void Factory::readStack(const string &name, const vector<string> &args ) 
const
+{
+  readMOStack(name, args, true);
+}
+
+void Factory::setScenePath(const string& path)
+{
+  scenePath = path;
+}
+
+Group* Factory::makeGroup(const string& groupSpec) const
+{
+  string name;
+  vector<string> args;
+  parseSpec(groupSpec, name, args);
+  GroupMapType::const_iterator iter = groups.find(name);
+  if(iter == groups.end())
+    return 0;
+  Group* group = (*iter->second)(args);
+  return group;
+}
+
+void Factory::registerObject(const string& name, GroupCreator creator)
+{
+  GroupMapType::iterator iter = groups.find(name);
+  if(iter != groups.end())
+    throw IllegalValue<string>("Duplicate group", name);
+  groups[name] = creator;
+}
+
+Factory::listType Factory::listGroups() const
+{
+  Factory::listType list;
+  for(GroupMapType::const_iterator iter = groups.begin();
+      iter != groups.end(); iter++)
+    list.push_back(iter->first);
+  return list;
+}
+
+Scene* Factory::readMOScene(const string& name, const vector<string>& args,
+                         bool printErrors) const
+{
+  using SCIRun::split_string;
+
+  // Determine which directories to search for the scene library.
+  string fullname = name;
+  vector<string> dirs = split_string(scenePath, ':');
+  for(vector<string>::iterator dir = dirs.begin(); dir != dirs.end(); dir++){
+
+    fullname = *dir + "/" + name;
+    
+    // Check to see if the file exists.
+    struct stat statbuf;
+    if(stat(fullname.c_str(), &statbuf) == 0){
+      break;
+    }
+  }
+
+  // Attempt to open the file name.
+  void* handle=dlopen(fullname.c_str(), RTLD_NOW);
+  if(!handle){
+    throw InputError( dlerror() );
+  }
+
+  // Look up the scene function.
+  void* scene_fn=dlsym(handle, "make_scene");
+  if(!scene_fn){
+    throw InputError( "Could not find \"make_scene\" function.\n" );
+  }
+
+  typedef Scene* (*MakerType)(const ReadContext&, const vector<string>&);
+  MakerType make_scene = (MakerType)(scene_fn);
+
+  // Call the make_scene function.
+  ReadContext context(manta_interface);
+  Scene* scene=(*make_scene)(context, args);
+  if(!scene){
+    throw InputError( "make_scene returned null" );
+  }
+
+  return scene;
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// This dynamically loads code to configure the manta rendering stack.
+void Factory::readMOStack(const string& name, const vector<string>& args, 
bool printErrors ) const
+{
+
+  // Assume an absolute path by default
+  string fullname = name;
+  
+  vector<string> dirs = split_string(scenePath, ':');
+  for(vector<string>::iterator dir = dirs.begin(); dir != dirs.end(); dir++){
+
+    fullname = *dir + "/"+name;
+    
+    // Check to see if the file exists in the directory.
+    struct stat statbuf;
+    if(stat(fullname.c_str(), &statbuf) != 0){
+      break;
+    }
+  }
+  
+  // Open the file.
+  void* handle=dlopen(fullname.c_str(), RTLD_NOW);
+  if(!handle){
+    throw InputError( "Could not load stack" );
+  }
+  
+  // Access the make_stack symbol
+  void* stack_fn=dlsym(handle, "make_stack");
+  if(!stack_fn){
+    if(printErrors){
+      cerr << "Stack configuration file found, but make_stack() function not 
found\n";
+    }
+    return;
+  }
+  
+  ///////////////////////////////////////////////////////////////////////////
+  // Invoke the function.  
+  typedef void (*MakerType)(ReadContext &, const vector<string>&);
+  MakerType make_stack = (MakerType)(stack_fn);
+  ReadContext context(manta_interface);
+  
+  // Call the function.
+  (*make_stack)(context, args);
+  
+}
+
+UserInterface* Factory::createUserInterface(const string& spec)
+{
+  string name;
+  vector<string> args;
+  parseSpec(spec, name, args);
+  UserInterfaceMapType::iterator iter = userInterfaces.find(name);
+  if(iter == userInterfaces.end())
+    return 0;
+  // This will create a new UserInterface
+  UserInterface *ui = (*iter->second)(args, manta_interface);
+  return ui;
+}
+
+void Factory::registerComponent(const string& name, UserInterfaceCreator 
creator)
+{
+  // Allow components to be re-registered.
+  // UserInterfaceMapType::iterator iter = userInterfaces.find(name);
+  // if(iter != userInterfaces.end())
+  //   throw IllegalValue<string>("Duplicate User Interface component", 
name);
+  userInterfaces[name] = creator;
+}
+
+Factory::listType Factory::listUserInterfaces() const
+{
+  Factory::listType list;
+  for(UserInterfaceMapType::const_iterator iter = userInterfaces.begin();
+      iter != userInterfaces.end(); iter++)
+    list.push_back(iter->first);
+  return list;
+}
+
+

Added: trunk/Engine/Factory/Factory.h
==============================================================================
--- (empty file)
+++ trunk/Engine/Factory/Factory.h      Fri Oct 13 17:18:43 2006
@@ -0,0 +1,211 @@
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005-2006
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef Manta_Engine_Control_Factory__h
+#define Manta_Engine_Control_Factory__h
+
+#include <vector>
+#include <string>
+#include <map>
+
+#include <Interface/MantaInterface.h>
+#include <Engine/Factory/RegisterKnownComponents.h>
+
+namespace Manta {
+
+  using namespace std;
+  
+  class Camera;
+  class CameraPath;
+  class Group;
+  class IdleMode;
+  class ImageDisplay;
+  class Image;
+  class ImageTraverser;
+  class LoadBalancer;
+  class PixelSampler;
+  class Renderer;
+  class Scene;
+  class SetupCallback;
+  class ShadowAlgorithm;
+  class UserInterface;
+  class RayPacket;
+
+  class Factory {
+  public:
+
+    
/////////////////////////////////////////////////////////////////////////////
+    // Constructor.
+    Factory( MantaInterface *interface_, bool AutoRegisterKnownComponents = 
true ) :
+      manta_interface( interface_ ) {      
+      if (AutoRegisterKnownComponents) registerKnownComponents( this );
+    }
+
+    typedef vector<string> listType;
+    
+    // ImageDisplay
+    typedef ImageDisplay* (*ImageDisplayCreator)(const vector<string>& args);
+    
+    virtual ImageDisplay* createImageDisplay(const string& spec) const;
+    virtual void registerComponent(const string& name, ImageDisplayCreator 
display);
+    virtual listType listImageDisplays() const;
+
+    // ImageTraverser
+    typedef ImageTraverser* (*ImageTraverserCreator)(const vector<string>& 
args);
+    virtual void registerComponent(const string& name, ImageTraverserCreator 
creator);
+    virtual listType listImageTraversers() const;
+    virtual bool selectImageTraverser(const string& spec) const;
+  
+    // Image Creator.
+    typedef Image* (*ImageCreator)(const vector<string>& args, bool stereo, 
int xres, int yres);
+    virtual bool selectImageType(const string& spec) const;
+    virtual void registerComponent(const string& name, ImageCreator creator);
+    virtual listType listImageTypes() const;  
+
+    // Load Balancer.
+    typedef LoadBalancer* (*LoadBalancerCreator)(const vector<string>& args);
+    virtual bool selectLoadBalancer(const string& spec) const;
+    virtual void registerComponent(const string& name, LoadBalancerCreator 
creator);
+    virtual listType listLoadBalancers() const;
+
+    // Pixel Sampler
+    typedef PixelSampler* (*PixelSamplerCreator)(const vector<string>& args);
+    virtual bool selectPixelSampler(const string& spec) const;
+    virtual void registerComponent(const string& name, PixelSamplerCreator 
creator);
+    virtual listType listPixelSamplers() const;
+
+    // Renderer
+    typedef Renderer* (*RendererCreator)(const vector<string>& args);
+    virtual bool selectRenderer(const string& spec) const;
+    virtual void registerComponent(const string& name, RendererCreator 
creator);
+    virtual listType listRenderers() const;  
+
+    // Shadow Algorithm
+    typedef ShadowAlgorithm* (*ShadowAlgorithmCreator)(const vector<string>& 
args);
+    virtual bool selectShadowAlgorithm(const string& spec) const;
+    virtual void registerComponent(const string& name, 
ShadowAlgorithmCreator creator);
+    virtual listType listShadowAlgorithms() const;
+
+    // Idle Modes
+    typedef IdleMode* (*IdleModeCreator)(const vector<string>& args);
+    MantaInterface::IdleModeHandle addIdleMode(const string& spec) const;
+    virtual void registerComponent(const string& name, IdleModeCreator 
creator);
+    virtual listType listIdleModes() const;
+
+    // Camera
+    typedef Camera* (*CameraCreator)(const vector<string>& args);
+    virtual Camera* createCamera(const string& spec) const;
+    virtual void registerComponent(const string& name, CameraCreator 
creator);
+    virtual listType listCameras() const;
+
+    // Scene Modules.
+    virtual Scene *readScene(const string& sceneSpec) const;
+    virtual void readStack( const string &name, const vector<string> &args ) 
const;
+    virtual void setScenePath(const string& path);    
+
+    // Groups
+    typedef Group* (*GroupCreator)(const vector<string>& args);
+    virtual Group* makeGroup(const string& groupSpec) const;
+    virtual void registerObject(const string& name, GroupCreator creator);
+    virtual listType listGroups() const;
+
+    // User Interfaces
+    typedef UserInterface* (*UserInterfaceCreator)(const vector<string>& 
args, MantaInterface *rtrt_interface);
+    virtual UserInterface* createUserInterface(const string& spec);
+    virtual void registerComponent(const string& name, UserInterfaceCreator 
creator);
+    virtual listType listUserInterfaces() const;
+
+    // Member accessors.
+    void setMantaInterface( MantaInterface *manta_interface_ ) { 
manta_interface = manta_interface_; }
+    MantaInterface *getMantaInterface() { return manta_interface; }
+    
+  private:
+    
+    // CreateImageCallback
+    static void createImageCallback( bool stereo, int xres, int yres, Image 
*& image,
+                                     ImageCreator creator,
+                                     vector<string> args );
+    
+    // Component databases and current instances
+    typedef map<string, ImageDisplayCreator> ImageDisplayMapType;
+    ImageDisplayMapType imageDisplays;
+               
+    typedef map<string, ImageCreator> ImageCreatorMapType;
+    ImageCreatorMapType imageCreators;
+
+    vector<string> currentImageCreatorArgs;
+
+    typedef map<string, ImageTraverserCreator> ImageTraverserMapType;
+    
+               ImageTraverserMapType imageTraversers;
+
+    
+               typedef map<string, LoadBalancerCreator> LoadBalancerMapType;
+    LoadBalancerMapType loadBalancers;
+
+    
+               typedef map<string, PixelSamplerCreator> PixelSamplerMapType;
+    PixelSamplerMapType pixelSamplers;
+
+    
+               typedef map<string, RendererCreator> RendererMapType;
+    RendererMapType renderers;
+
+    
+               typedef map<string, ShadowAlgorithmCreator> 
ShadowAlgorithmMapType;
+    ShadowAlgorithmMapType shadowAlgorithms;
+
+    
+               typedef map<string, IdleModeCreator> IdleModeMapType;
+    IdleModeMapType idleModes;
+
+    
+               typedef map<string, CameraCreator> CameraMapType;
+    CameraMapType cameras;
+    
+               typedef map<string, UserInterfaceCreator> 
UserInterfaceMapType;
+    UserInterfaceMapType userInterfaces;
+    
+               typedef map<string, GroupCreator> GroupMapType;
+    GroupMapType groups;
+
+    // Scene
+  
+    string scenePath;
+    
+    Scene* readMOScene(const string& name, const vector<string>& args, bool 
printErrors) const;
+    void readMOStack(const string& name, const vector<string>& args, bool 
printErrors ) const;
+
+  private:
+
+    MantaInterface *manta_interface;
+  };
+
+};
+  
+#endif

Modified: trunk/Engine/Factory/RegisterKnownComponents.cc
==============================================================================
--- trunk/Engine/Factory/RegisterKnownComponents.cc     (original)
+++ trunk/Engine/Factory/RegisterKnownComponents.cc     Fri Oct 13 17:18:43 
2006
@@ -1,4 +1,32 @@
-#include <Interface/MantaInterface.h>
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005-2006
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Engine/Factory/Factory.h>
 #include <Engine/Display/NullDisplay.h>
 #include <Engine/Display/OpenGLDisplay.h>
 #include <Engine/Display/FileDisplay.h>
@@ -44,7 +72,7 @@
 #include <RegisterConfigurableComponents.h>
 
 namespace Manta {
-  void registerKnownComponents(MantaInterface* engine)
+  extern "C" void registerKnownComponents(Factory* engine)
   {
     // Register display components
     engine->registerComponent("null", &NullDisplay::create);
@@ -65,10 +93,8 @@
     engine->registerComponent("abgr8", &SimpleImage<ABGR8Pixel>::create);
     engine->registerComponent("argb8", &SimpleImage<ARGB8Pixel>::create);
     engine->registerComponent("bgra8", &SimpleImage<BGRA8Pixel>::create);
-    engine->registerComponent("rgbafloat",
-                            &SimpleImage<RGBAfloatPixel>::create);
-    engine->registerComponent("rgbfloat",
-                            &SimpleImage<RGBfloatPixel>::create);
+    engine->registerComponent("rgbafloat", 
&SimpleImage<RGBAfloatPixel>::create);
+    engine->registerComponent("rgbfloat", 
&SimpleImage<RGBfloatPixel>::create);
 
     // Register load balancers
     engine->registerComponent("cyclic", &CyclicLoadBalancer::create);

Modified: trunk/Engine/Factory/RegisterKnownComponents.h
==============================================================================
--- trunk/Engine/Factory/RegisterKnownComponents.h      (original)
+++ trunk/Engine/Factory/RegisterKnownComponents.h      Fri Oct 13 17:18:43 
2006
@@ -32,13 +32,13 @@
 
 namespace Manta {
 
-  class MantaInterface;
+  class Factory;
        
   
/////////////////////////////////////////////////////////////////////////////
   // Register all "known" components with the RTRTInterface.
   // ImageTraversers, PixelSamplers, other command line args should be added 
to
   // the RTRT_register.cc file.
-  void registerKnownComponents(MantaInterface* rtrt);
+  extern "C" void registerKnownComponents(Factory* engine);
 };
 
 #endif

Modified: trunk/Interface/Callback.h
==============================================================================
--- trunk/Interface/Callback.h  (original)
+++ trunk/Interface/Callback.h  Fri Oct 13 17:18:43 2006
@@ -77,6 +77,16 @@
       return new Callback_Static_3Data_2Arg<Data1, Data2, Data3, Arg1, 
Arg2>(pmf, arg1, arg2);
     }
 
+    // 4 Data
+    template<typename Data1, typename Data2, typename Data3, typename Data4,
+             typename Arg1, typename Arg2> static
+    CallbackBase_4Data<Data1, Data2, Data3, Data4>*
+    create(void (*pmf)(Data1, Data2, Data3, Data4, Arg1, Arg2),
+           Arg1 arg1, Arg2 arg2) {
+      return new Callback_Static_4Data_2Arg<Data1, Data2, Data3, Data4, 
Arg1, Arg2>(pmf, arg1, arg2);
+    }
+    
+
     ///////////////////////////////////////////////////////////
     // Class member functions
 
@@ -195,6 +205,18 @@
       return new Callback_4Data_0Arg<T, Data1, Data2, Data3, Data4>(ptr, 
pmf);
     }
 
+    template<class T, typename Data1, typename Data2, typename Data3, 
typename Data4, typename Arg1> static
+    CallbackBase_4Data<Data1, Data2, Data3, Data4>*
+    create(T* ptr, void (T::*pmf)(Data1, Data2, Data3, Data4, Arg1), Arg1) {
+      return new Callback_4Data_1Arg<T, Data1, Data2, Data3, Data4, 
Arg1>(ptr, pmf, arg1);
+    }
+
+    template<class T, typename Data1, typename Data2, typename Data3, 
typename Data4, typename Arg1, typename Arg2> static
+    CallbackBase_4Data<Data1, Data2, Data3, Data4>*
+    create(T* ptr, void (T::*pmf)(Data1, Data2, Data3, Data4, Arg1, Arg2), 
Arg1, Arg2) {
+      return new Callback_4Data_2Arg<T, Data1, Data2, Data3, Data4, Arg1, 
Arg2>(ptr, pmf, arg1, arg2);
+    }
+    
     // 5 data elements
     template<class T, typename Data1, typename Data2, typename Data3, 
typename Data4, typename Data5> static
     CallbackBase_5Data<Data1, Data2, Data3, Data4, Data5>*

Modified: trunk/Interface/CallbackHelpers.h
==============================================================================
--- trunk/Interface/CallbackHelpers.h   (original)
+++ trunk/Interface/CallbackHelpers.h   Fri Oct 13 17:18:43 2006
@@ -272,6 +272,29 @@
     Arg2 arg2;
   };
 
+  // 4 Data
+  template<typename Data1, typename Data2, typename Data3, typename Data4,
+           typename Arg1, typename Arg2>
+  class Callback_Static_4Data_2Arg : public CallbackBase_4Data<Data1, Data2, 
Data3, Data4> {
+  public:
+    Callback_Static_4Data_2Arg(void (*pmf)(Data1, Data2, Data3, Data4, Arg1, 
Arg2),
+                               Arg1 arg1, Arg2 arg2)
+      : pmf(pmf), arg1(arg1), arg2(arg2)
+    {
+    }
+    virtual ~Callback_Static_4Data_2Arg()
+    {
+    }
+    virtual void call(Data1 data1, Data2 data2, Data3 data3, Data4 data4)
+    {
+      pmf(data1, data2, data3, data4, arg1, arg2);
+    }
+  private:
+    void (*pmf)(Data1, Data2, Data3, Data4, Arg1, Arg2);
+    Arg1 arg1;
+    Arg2 arg2;
+  };
+  
   ///////////////////////////////////////////////////////////
   // Class member functions
   

Modified: trunk/Interface/MantaInterface.h
==============================================================================
--- trunk/Interface/MantaInterface.h    (original)
+++ trunk/Interface/MantaInterface.h    Fri Oct 13 17:18:43 2006
@@ -1,4 +1,32 @@
 
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005-2006
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
 #ifndef Manta_Interface_MantaInterface_H
 #define Manta_Interface_MantaInterface_H
 
@@ -37,121 +65,91 @@
 
     virtual ~MantaInterface();
 
-    typedef vector<string> listType;
-
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Pipeline Components.
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    
     // Image Displays (opengl, file, mpeg, etc.)
-    typedef ImageDisplay* (*ImageDisplayCreator)(const vector<string>& args);
-    virtual int createChannel(const string& modespec, Camera* camera,
-                             bool stereo, int xres, int yres) = 0;
                                                
     // Create a channel given a pointer to the ImageDisplay for the channel.
-    virtual int createChannel( ImageDisplay *image_display, Camera *camera,
-                               bool stereo, int xres, int yres) = 0;
+    virtual int createChannel( ImageDisplay *image_display, Camera *camera, 
bool stereo, int xres, int yres) = 0;
     virtual ImageDisplay *getImageDisplay( int channel ) = 0;
     virtual void setImageDisplay( int channel, ImageDisplay *display ) = 0;
                                                
-    virtual void registerComponent(const string& name, ImageDisplayCreator 
display) = 0;
-    virtual listType listImageDisplays() const = 0;
     virtual Camera* getCamera(int channel) const = 0;
     virtual void    setCamera(int channel, Camera *camera ) = 0;
     virtual void getResolution(int channel, bool& stereo, int& xres, int& 
yres) = 0;
+
     // You can change the resolution of the rendered image without
     // having to change the pipeline.  If you want the pipeline
     // changed, then set this parameter to true.
-    virtual void changeResolution(int channel, int xres, int yres,
-                                  bool changePipeline) = 0;
+    virtual void changeResolution(int channel, int xres, int yres, bool 
changePipeline) = 0;
+
+    // Idle modes
+    typedef unsigned int IdleModeHandle;
+    virtual IdleModeHandle addIdleMode( IdleMode *idle_mode_ ) = 0;
+    virtual IdleMode *getIdleMode( IdleModeHandle i ) const = 0;
+    
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Render Stack Components.
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////   
 
 
     // Image Traversers
-    typedef ImageTraverser* (*ImageTraverserCreator)(const vector<string>& 
args);
     virtual void setImageTraverser( ImageTraverser *image_traverser_ ) = 0;
-    virtual ImageTraverser *getImageTraverser() = 0;
-    virtual bool selectImageTraverser(const string& spec) = 0;
-    virtual void registerComponent(const string& name, ImageTraverserCreator 
creator) = 0;
-    virtual listType listImageTraversers() const = 0;
+    virtual ImageTraverser *getImageTraverser() const = 0;
 
     // Image Types (rgb, rgba, float, etc.)
-    typedef Image* (*ImageCreator)(const vector<string>& args,
-                                  bool stereo, int xres, int yres);
-    virtual bool selectImageType(const string& spec) = 0;
-    virtual void registerComponent(const string& name, ImageCreator creator) 
= 0;
-    virtual listType listImageTypes() const = 0;
+    typedef CallbackBase_4Data<bool,int,int,Image *&> CreateImageCallback; 
+    virtual void setCreateImageCallback( CreateImageCallback * const 
callback ) = 0;
+    virtual CreateImageCallback * getCreateImageCallback() const = 0;
 
     // Load Balancers
-    typedef LoadBalancer* (*LoadBalancerCreator)(const vector<string>& args);
-    virtual bool selectLoadBalancer(const string& spec) = 0;
-    virtual void registerComponent(const string& name, LoadBalancerCreator 
creator) = 0;
-    virtual listType listLoadBalancers() const = 0;
-
+    virtual void setLoadBalancer( LoadBalancer *load_balancer_ ) = 0;
+    virtual LoadBalancer *getLoadBalancer() const = 0;
+        
     // PixelSamplers
                virtual void setPixelSampler( PixelSampler *sampler_ ) = 0;
-    typedef PixelSampler* (*PixelSamplerCreator)(const vector<string>& args);
-    virtual bool selectPixelSampler(const string& spec) = 0;
-    virtual void registerComponent(const string& name, PixelSamplerCreator 
creator) = 0;
-    virtual listType listPixelSamplers() const = 0;
-
+    virtual PixelSampler *getPixelSampler() const = 0;
+    
     // Renderers
-    typedef Renderer* (*RendererCreator)(const vector<string>& args);
     virtual void setRenderer( Renderer *renderer_ ) = 0;
-    virtual Renderer* getRenderer(void) = 0;
-    virtual bool selectRenderer(const string& spec) = 0;
-    virtual void registerComponent(const string& name, RendererCreator 
creator) = 0;
-    virtual listType listRenderers() const = 0;
+    virtual Renderer* getRenderer() const = 0;
 
     // Shadow Algorithms
-    typedef ShadowAlgorithm* (*ShadowAlgorithmCreator)(const vector<string>& 
args);
     virtual void setShadowAlgorithm(ShadowAlgorithm* shadows) = 0;
-    virtual ShadowAlgorithm* getShadowAlgorithm(void) = 0;
-    virtual bool selectShadowAlgorithm(const string& spec) = 0;
-    virtual void registerComponent(const string& name, 
ShadowAlgorithmCreator creator) = 0;
-    virtual listType listShadowAlgorithms() const = 0;
-
-    // Idle modes
-    typedef IdleMode* (*IdleModeCreator)(const vector<string>& args);
-    virtual bool addIdleMode(const string& spec) = 0;
-    virtual void registerComponent(const string& name, IdleModeCreator 
creator) = 0;
-    virtual listType listIdleModes() const = 0;
-
-    // Camera
-    typedef Camera* (*CameraCreator)(const vector<string>& args);
-    virtual Camera* createCamera(const string& spec) = 0;
-    virtual void registerComponent(const string& name, CameraCreator 
creator) = 0;
-    virtual listType listCameras() const = 0;
+    virtual ShadowAlgorithm* getShadowAlgorithm(void) const = 0;
 
-    // Scenes
-    virtual bool haveScene() = 0;
+    // Scene
     virtual void setScene(Scene* scene) = 0;
     virtual Scene *getScene() = 0;
-    virtual bool readScene(const string& sceneSpec) = 0;
-    virtual void readStack( const string &name, const vector<string> &args ) 
= 0;
-    virtual void setScenePath(const string& path) = 0;
-
-    typedef Group* (*GroupCreator)(const vector<string>& args);
-    virtual Group* makeGroup(const string& groupSpec) = 0;
-    virtual void registerObject(const string& name, GroupCreator creator) = 
0;
-    virtual listType listGroups() const = 0;
-
-    // Callbacks
-    enum Whence {
-      Absolute, Relative
-    };
-    virtual void addOneShotCallback(Whence whence, long frame,
-                                    CallbackBase_2Data<int, int>* callback) 
= 0;
-    virtual void addParallelOneShotCallback(Whence whence, long frame,
-                                            CallbackBase_2Data<int, int>* 
callback) = 0;
-    virtual CallbackHandle* registerSetupCallback(SetupCallback*) = 0;
-    virtual CallbackHandle* 
registerSerialAnimationCallback(CallbackBase_3Data<int, int, bool&>*) = 0;
-    virtual CallbackHandle* 
registerParallelAnimationCallback(CallbackBase_3Data<int, int, bool&>*) = 0;
-    virtual CallbackHandle* 
registerSerialPreRenderCallback(CallbackBase_2Data<int, int>*) = 0;
-    virtual CallbackHandle* 
registerParallelPreRenderCallback(CallbackBase_2Data<int, int>*) = 0;
-    virtual CallbackHandle* registerTerminationCallback( CallbackBase_1Data< 
MantaInterface *> *) = 0;
-    virtual void unregisterCallback(CallbackHandle*) = 0;
 
-    // Settings
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Time Mode
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    
     enum TimeMode {
-      RealTime, FixedRate, Static, FixedSamplingRate
+      RealTime,
+      FixedRate,
+      Static,
+      FixedSamplingRate
     };
     virtual void setTimeMode(TimeMode tm, double rate) = 0;
 
+    // Query functions
+    virtual int getCurrentFrame() const = 0;
+    
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Control
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////   
 
+    
     // Parallel processing
     virtual void changeNumWorkers(int) = 0;
     virtual TValue<int>& numWorkers() = 0;
@@ -163,18 +161,11 @@
     // Control
     virtual void finish() = 0;
 
-    // User Interfaces
-    typedef UserInterface* (*UserInterfaceCreator)(const vector<string>& 
args,
-                                                  MantaInterface 
*rtrt_interface);
-    virtual UserInterface* createUserInterface(const string& spec) = 0;
-    virtual void registerComponent(const string& name, UserInterfaceCreator 
creator) = 0;
-    virtual listType listUserInterfaces() const = 0;
-
-    // Query functions
-    virtual bool queryState(const string& what, vector<string>& results) = 0;
-    virtual int getCurrentFrame() const = 0;
-
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
     // Transactions
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
     virtual void addTransaction(TransactionBase*) = 0;
                
     template<class T, class Op>
@@ -186,7 +177,36 @@
       addTransaction(new CallbackTransaction(name, callback, flag ));
     }
 
-    // Others
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Callbacks.
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    
+    typedef unsigned long FrameNumber;
+    
+    enum OneShotTime {
+      // Callbacks
+      Absolute,
+      Relative
+    };
+    
+    virtual void addOneShotCallback(OneShotTime whence, FrameNumber frame, 
CallbackBase_2Data<int, int>* callback) = 0;
+    virtual void addParallelOneShotCallback(OneShotTime whence, FrameNumber 
frame, CallbackBase_2Data<int, int>* callback) = 0;
+
+    virtual CallbackHandle* registerSetupCallback(SetupCallback*) = 0;
+    virtual CallbackHandle* 
registerSerialAnimationCallback(CallbackBase_3Data<int, int, bool&>*) = 0;
+    virtual CallbackHandle* 
registerParallelAnimationCallback(CallbackBase_3Data<int, int, bool&>*) = 0;
+    virtual CallbackHandle* 
registerSerialPreRenderCallback(CallbackBase_2Data<int, int>*) = 0;
+    virtual CallbackHandle* 
registerParallelPreRenderCallback(CallbackBase_2Data<int, int>*) = 0;
+    virtual CallbackHandle* registerTerminationCallback( CallbackBase_1Data< 
MantaInterface *> *) = 0;
+    virtual void unregisterCallback(CallbackHandle*) = 0;
+    
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // Debug
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////   
 
 
     // This should only be called from within a transaction called function.
                virtual void shootOneRay( Color &result_color, RayPacket 
&result_rays, Real image_x, Real image_y, int channel_index ) = 0;

Modified: trunk/StandAlone/manta.cc
==============================================================================
--- trunk/StandAlone/manta.cc   (original)
+++ trunk/StandAlone/manta.cc   Fri Oct 13 17:18:43 2006
@@ -28,6 +28,9 @@
 */
 
 #include <Interface/MantaInterface.h>
+
+#include <Engine/Factory/Factory.h>
+
 #include <Core/Util/Args.h>
 #include <Interface/Callback.h>
 #include <Interface/Scene.h>
@@ -81,11 +84,11 @@
 static void make_stack( ReadContext &context, const vector<string> &args );
 
 static void
-printList(ostream& out, const MantaInterface::listType& list, int spaces=0)
+printList(ostream& out, const Factory::listType& list, int spaces=0)
 {
   for(int i=0;i<spaces;i++)
     out << ' ';
-  for(MantaInterface::listType::const_iterator iter = list.begin();
+  for(Factory::listType::const_iterator iter = list.begin();
       iter != list.end(); ++iter){
     if(iter != list.begin())
       out << ", ";
@@ -94,7 +97,7 @@
   out << "\n";
 }
 
-static void usage(MantaInterface* rtrt)
+static void usage(Factory* rtrt)
 {
 
   cerr << "Manta Interactive Ray Tracer" << "\n\n";
@@ -173,6 +176,8 @@
   delete this;
 }
 
+Factory *factory = 0;
+
 int
 main(int argc, char* argv[])
 {
@@ -191,24 +196,28 @@
     // Create Manta.
     MantaInterface* rtrt = createManta();
 
+    // Create a Manta Factory.
+    factory = new Factory( rtrt );
+    
     // Set the scene search path based on an env variable.
     if(getenv("MANTA_SCENEPATH"))
-      rtrt->setScenePath(getenv("MANTA_SCENEPATH"));
+      factory->setScenePath(getenv("MANTA_SCENEPATH"));
     else
-      rtrt->setScenePath("");
+      factory->setScenePath("");
 
     // Use one worker by default.
     rtrt->changeNumWorkers(1);
 
     // Default options.
-    if(!rtrt->selectImageType("argb8"))
+    MantaInterface::CreateImageCallback *defaultCreateImage = 0;
+    if(!factory->selectImageType("argb8"))
       throw InternalError("default image not found", __FILE__, __LINE__);
     
-    if(!rtrt->selectShadowAlgorithm("hard"))
+    if(!factory->selectShadowAlgorithm("hard"))
       throw InternalError("default shadow algorithm not found", __FILE__, 
__LINE__ );
     
     // Set camera for the default scene.
-    Camera* currentCamera = rtrt->createCamera("pinhole(-normalizeRays)");
+    Camera* currentCamera = factory->createCamera("pinhole(-normalizeRays)");
     if(!currentCamera)
       throw InternalError("cannot create default camera", __FILE__, __LINE__ 
);
 
@@ -226,7 +235,7 @@
       for(int i=0;i<argc;i++){
         string arg = args[i];
         if(arg == "-help"){
-          usage(rtrt);
+          usage(factory);
 
         
         } else if(arg == "-bench" || arg == "-quietbench"){
@@ -253,17 +262,17 @@
         } else if(arg == "-camera"){
           string s;
           if(!getStringArg(i, args, s))
-            usage(rtrt);
-          currentCamera = rtrt->createCamera(s);
+            usage(factory);
+          currentCamera = factory->createCamera(s);
           if(!currentCamera){
             cerr << "Error creating camera: " << s << ", available cameras 
are:\n";
-            printList(cerr, rtrt->listCameras());
+            printList(cerr, factory->listCameras());
             throw IllegalArgument( s, i, args );
           }
         } else if(arg == "-res"){
           if(!getResolutionArg(i, args, xres, yres)){
             cerr << "Error parsing resolution: " << args[i+1] << '\n';
-            usage(rtrt);
+            usage(factory);
           }
         } else if(arg == "-stereo") {
           stereo = true;
@@ -271,16 +280,19 @@
         } else if(arg == "-imagedisplay"){
           string s;
           if(!getStringArg(i, args, s))
-            usage(rtrt);
+            usage(factory);
 
           // Create the channel.
           try {
-            rtrt->createChannel(s, currentCamera, stereo, xres, yres);
+            ImageDisplay *display = factory->createImageDisplay( s );
+            
+            rtrt->createChannel(display, currentCamera, stereo, xres, yres);
+            
             
           } catch (UnknownComponent e) {
             cerr << e.message() << "\n"
                  << "Available image displays: ";
-            printList(cerr, rtrt->listImageDisplays());
+            printList(cerr, factory->listImageDisplays());
             throw e;
           }
           channelCreated=true;
@@ -288,36 +300,36 @@
         } else if(arg == "-imagetype"){
           string s;
           if(!getStringArg(i, args, s))
-            usage(rtrt);
-          if(!rtrt->selectImageType(s)){
+            usage(factory);
+          if(!factory->selectImageType(s)){
             cerr << "Invalid image type: " << s << ", available image types 
are:\n";
-            printList(cerr, rtrt->listImageTypes());
+            printList(cerr, factory->listImageTypes());
             throw IllegalArgument( s, i, args );
           }        
         
         } else if(arg == "-idlemode"){
           string s;
           if(!getStringArg(i, args, s))
-            usage(rtrt);
-          if(!rtrt->addIdleMode(s)){
+            usage(factory);
+          if(!factory->addIdleMode(s)){
             cerr << "Invalid idle mode: " << s << ", available idle modes 
are:\n";
-            printList(cerr, rtrt->listIdleModes());
+            printList(cerr, factory->listIdleModes());
             throw IllegalArgument( s, i, args );
           }
         } else if(arg == "-np"){
           long np;
           if(!getLongArg(i, args, np))
-            usage(rtrt);
+            usage(factory);
           rtrt->changeNumWorkers(static_cast<int>(np));
         
         } else if(arg == "-ui"){
           string s;
           if(!getStringArg(i, args, s))
-            usage(rtrt);
-          UserInterface* ui = rtrt->createUserInterface(s);
+            usage(factory);
+          UserInterface* ui = factory->createUserInterface(s);
           if(!ui){
             cerr << "Unknown user interface: " << s << ", available user 
interfaces are:\n";
-            printList(cerr, rtrt->listUserInterfaces());
+            printList(cerr, factory->listUserInterfaces());
             throw IllegalArgument( s, i, args );
           }
           ui->startup();
@@ -326,27 +338,27 @@
         } else if(arg == "-shadows"){
           string s;
           if(!getStringArg(i, args, s))
-            usage(rtrt);
-          if(!rtrt->selectShadowAlgorithm(s)){
+            usage(factory);
+          if(!factory->selectShadowAlgorithm(s)){
             cerr << "Invalid shadow algorithm: " << s << ", available shadow 
algorithms are:\n";
-            printList(cerr, rtrt->listShadowAlgorithms());
+            printList(cerr, factory->listShadowAlgorithms());
             throw IllegalArgument( s, i, args );
           }
         
         } else if(arg == "-scene"){
-          if(rtrt->haveScene())
+          if(rtrt->getScene()!=0)
             cerr << "WARNING: multiple scenes specified, will use last 
one\n";
           string scene;
           if(!getStringArg(i, args, scene))
-            usage(rtrt);
-          if(!rtrt->readScene(scene)){
+            usage(factory);
+          if(!factory->readScene(scene)){
             cerr << "Error reading scene: " << scene << '\n';
             throw IllegalArgument( "-scene", i, args );
           }
         }
         else if (arg == "-stack") {
           if (!getStringArg(i,args,stack_file))
-            usage(rtrt);
+            usage(factory);
         }
       }
     }
@@ -370,22 +382,23 @@
 
     // Check to see if a channel  was created.
     if(!channelCreated){
-      rtrt->createChannel("opengl", currentCamera, stereo, xres, yres);
+      ImageDisplay *display = factory->createImageDisplay( "opengl" );
+      rtrt->createChannel(display, currentCamera, stereo, xres, yres);
     }
 
     // Check to see if a UI was specified
     if(!haveUI){
-      UserInterface* ui = rtrt->createUserInterface("X");
+      UserInterface* ui = factory->createUserInterface("X");
       if(!ui){
                                cerr << "Cannot find default user interface: 
X, available user interfaces are:\n";
-                               printList(cerr, rtrt->listUserInterfaces());
+                               printList(cerr, 
factory->listUserInterfaces());
         Thread::exitAll(1);
       }
       ui->startup();
     }
 
     // Check if default scene should be used.
-    if(!rtrt->haveScene()){
+    if(rtrt->getScene()==0){
       rtrt->setScene(createDefaultScene());
     }
 
@@ -393,7 +406,7 @@
     
///////////////////////////////////////////////////////////////////////////
     // Configure the rendering stack from a specified file.
     if (stack_file.size()) {
-      rtrt->readStack( stack_file, args );
+      factory->readStack( stack_file, args );
     }
     else {
       // Pass a read context and all of the command line args to the scene
@@ -441,16 +454,16 @@
 
   // Defaults.
   
-  if(!rtrt->selectLoadBalancer("workqueue"))
+  if(!factory->selectLoadBalancer("workqueue"))
     throw InternalError("default load balancer not found", __FILE__, 
__LINE__);
   
-  if(!rtrt->selectImageTraverser("tiled"))
+  if(!factory->selectImageTraverser("tiled"))
     throw InternalError("default image traverser not found", __FILE__, 
__LINE__ );
   
-  if(!rtrt->selectPixelSampler("singlesample"))
+  if(!factory->selectPixelSampler("singlesample"))
     throw InternalError("default pixel sampler not found", __FILE__, 
__LINE__ );
   
-  if(!rtrt->selectRenderer("raytracer"))
+  if(!factory->selectRenderer("raytracer"))
     throw InternalError("default renderer not found", __FILE__, __LINE__ );
 
   // Parse command line args.
@@ -460,39 +473,39 @@
     if(arg == "-imagetraverser"){
       string s;
       if(!getStringArg(i, args, s))
-        usage(rtrt);
-      if(!rtrt->selectImageTraverser(s)){
+        usage(factory);
+      if(!factory->selectImageTraverser(s)){
         cerr << "Invalid image traverser: " << s << ", available image 
traversers are:\n";
-        printList(cerr, rtrt->listImageTraversers());
+        printList(cerr, factory->listImageTraversers());
         throw IllegalArgument( s, i, args );
       }
 
     } else if(arg == "-loadbalancer"){
       string s;
       if(!getStringArg(i, args, s))
-        usage(rtrt);
-      if(!rtrt->selectLoadBalancer(s)){
+        usage(factory);
+      if(!factory->selectLoadBalancer(s)){
         cerr << "Invalid load balancer: " << s << ", available load 
balancers are:\n";
-        printList(cerr, rtrt->listLoadBalancers());
+        printList(cerr, factory->listLoadBalancers());
         throw IllegalArgument( s, i, args );
       }
     } else if(arg == "-pixelsampler"){
       string s;
       if(!getStringArg(i, args, s))
-        usage(rtrt);
-      if(!rtrt->selectPixelSampler(s)){
+        usage(factory);
+      if(!factory->selectPixelSampler(s)){
         cerr << "Invalid pixel sampler: " << s << ", available pixel 
samplers are:\n";
-        printList(cerr, rtrt->listPixelSamplers());
+        printList(cerr, factory->listPixelSamplers());
         throw IllegalArgument( s, i, args );
       }
     } else if(arg == "-renderer"){
       cerr << "renderer\n";
       string s;
       if(!getStringArg(i, args, s)){
-        usage(rtrt);
+        usage(factory);
         cerr << "oops\n";
       }
-      if(!rtrt->selectRenderer(s)){
+      if(!factory->selectRenderer(s)){
         cerr << "Invalid renderer: " << s << ", available renderers are:\n";
         throw IllegalArgument( s, i, args );
       }

Modified: trunk/SwigInterface/manta.h
==============================================================================
--- trunk/SwigInterface/manta.h (original)
+++ trunk/SwigInterface/manta.h Fri Oct 13 17:18:43 2006
@@ -1,6 +1,9 @@
 #include <Interface/MantaInterface.h>
 #include <Interface/Callback.h>
 
+#include <Engine/Factory/Factory.h>
+#include <Engine/Factory/RegisterKnownComponents.h>
+
 #include <sgi_stl_warnings_off.h>
 #include <string>
 #include <sgi_stl_warnings_on.h>
@@ -10,15 +13,19 @@
 
   class PipelineChanger {
     MantaInterface* rtrt_interface;
+    Factory factory;
   public:
     PipelineChanger(MantaInterface* rtrt_interface):
-      rtrt_interface(rtrt_interface)
-    {}
+      rtrt_interface(rtrt_interface),
+      factory( rtrt_interface )
+    {
+      registerKnownComponents( &factory );
+    }
     
     void changePixelSamplerCallback(int, int,
                                     string spec)
     {
-      rtrt_interface->selectPixelSampler(spec);
+      factory.selectPixelSampler(spec);
     }
 
     void changeResolutionCallBack(int, int,

Modified: trunk/SwigInterface/manta.i
==============================================================================
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Fri Oct 13 17:18:43 2006
@@ -240,6 +240,13 @@
 %template(Array1_ObjectP) SCIRun::Array1<Manta::Object*>;
 
 ///////////////////////////////////////////////////////
+// Engine Factory
+%{
+#include <Engine/Factory/Factory.h>
+%}
+%include <Engine/Factory/Factory.h>
+
+///////////////////////////////////////////////////////
 // Engine Control
 %{
 #include <Engine/Control/RTRT.h>

Modified: trunk/SwigInterface/runmanta.py
==============================================================================
--- trunk/SwigInterface/runmanta.py     (original)
+++ trunk/SwigInterface/runmanta.py     Fri Oct 13 17:18:43 2006
@@ -1,5 +1,7 @@
 from manta import *
 
+global factory
+
 def createDefaultScenePython():
     scene = manta_new(Scene())
     
scene.setBackground(manta_new(ConstantBackground(ColorDB.getNamedColor("SkyBlue3").scaled(0.5))))
@@ -93,19 +95,25 @@
 def setupDefaultEngine(numworkers):
     print "Using " + str(numworkers) + " rendering threads."
     engine = createManta()
+
+    global factory
+    factory = Factory( engine )
+    factory.registerKnownComponents()
+    
     engine.changeNumWorkers(numworkers)
-    engine.selectImageType("rgba8")
-    engine.selectLoadBalancer("workqueue")
-    engine.selectImageTraverser("tiled")
-    engine.selectPixelSampler("singlesample")
-    #engine.selectPixelSampler("jittersample(-numberOfSamples 4)")
-    engine.selectRenderer("raytracer")
-    engine.selectShadowAlgorithm("hard")
+    factory.selectImageType("rgba8")
+    factory.selectLoadBalancer("workqueue")
+    factory.selectImageTraverser("tiled")
+    factory.selectPixelSampler("singlesample")
+    #factory.selectPixelSampler("jittersample(-numberOfSamples 4)")
+    factory.selectRenderer("raytracer")
+    factory.selectShadowAlgorithm("hard")
     #
     return engine
 
 def addXInterface(engine, camera, xres, yres):
-    xinterface = engine.createUserInterface("X")
+
+    xinterface = factory.createUserInterface("X")
     xinterface.startup()
     args = vectorStr()
     ogl_display = manta_new(OpenGLDisplay(args))
@@ -117,15 +125,15 @@
 #    engine.createChannel("opengl", camera, False, xres, yres)
 
 def addNullInterface(engine, camera, xres, yres):
-    ui = engine.createUserInterface("null")
+    ui = factory.createUserInterface("null")
     ui.startup()
     engine.createChannel("null", camera, False, xres, yres)
 
 
 engine = setupDefaultEngine(2)
 
-defaultCamera = engine.createCamera("pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up 
0 0 1 -fov 60)")
-#defaultCamera = engine.createCamera("pinhole(-eye 8 -18 8.5 -lookat -4.7 
2.5 2.5 -up 0 0 1 -fov 15)")
+defaultCamera = factory.createCamera("pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up 
0 0 1 -fov 60)")
+#defaultCamera = factory.createCamera("pinhole(-eye 8 -18 8.5 -lookat -4.7 
2.5 2.5 -up 0 0 1 -fov 15)")
 
 addXInterface(engine, defaultCamera, 512, 512)
 #addNullInterface(engine, defaultCamera, 512, 512)

Modified: trunk/SwigInterface/wxManta.py
==============================================================================
--- trunk/SwigInterface/wxManta.py      (original)
+++ trunk/SwigInterface/wxManta.py      Fri Oct 13 17:18:43 2006
@@ -333,16 +333,20 @@
 
         # Basic settings.
         self.engine = createManta()
-        self.engine.changeNumWorkers     (num_workers)
-        self.engine.selectImageType      ("rgba8")
-        self.engine.selectLoadBalancer   ("workqueue")
-        self.engine.selectImageTraverser ("tiled")
-        self.engine.selectPixelSampler   ("singlesample")
-        self.engine.selectRenderer       ("raytracer")
-        self.engine.selectShadowAlgorithm("hard")
+
+        self.factory = Factory( self.engine )
+        
+        self.factory.selectImageType      ("rgba8")
+        self.factory.selectLoadBalancer   ("workqueue")
+        self.factory.selectImageTraverser ("tiled")
+        self.factory.selectPixelSampler   ("singlesample")
+        self.factory.selectRenderer       ("raytracer")
+        self.factory.selectShadowAlgorithm("hard")
 
         # Create the camera.
-        camera = self.engine.createCamera("pinhole(-eye 3 3 2 -lookat 0 0 
0.3 -up 0 0 1 -fov 60)")
+        camera = self.factory.createCamera("pinhole(-eye 3 3 2 -lookat 0 0 
0.3 -up 0 0 1 -fov 60)")
+
+        self.engine.changeNumWorkers     (num_workers)
 
         # Image display.
         use_stereo = False
@@ -771,9 +775,15 @@
                  filename=None):
         wx.App.__init__(self, redirect, filename)
 
-        # Create a manta frame with the given initialize_callback function.
-        self.frame = MantaFrame( initialize_callback_, num_workers, 
renderSize )
-        self.frame.Show()
+        try:
+
+            # Create a manta frame with the given initialize_callback 
function.
+            self.frame = MantaFrame( initialize_callback_, num_workers, 
renderSize )
+            self.frame.Show()
+
+        except Exception, e:
+            print e.type() + " occurred intializing program"
+            print e.message()
 
 
 

Modified: trunk/UserInterface/PromptUI.cc
==============================================================================
--- trunk/UserInterface/PromptUI.cc     (original)
+++ trunk/UserInterface/PromptUI.cc     Fri Oct 13 17:18:43 2006
@@ -37,6 +37,8 @@
 #include <Core/Thread/Runnable.h>
 #include <Core/Thread/Thread.h>
 
+#include <Engine/Factory/RegisterKnownComponents.h>
+
 #include <sgi_stl_warnings_off.h>
 #include <vector>
 #include <string>
@@ -62,8 +64,10 @@
 
 PromptUI::PromptUI(const vector<string>& args, MantaInterface 
*manta_interface_) :
   manta_interface( manta_interface_ ),
+  factory( manta_interface_ ),
   current_channel( 0 )
 {
+  registerKnownComponents( &factory );
 }
 
 PromptUI::~PromptUI() {
@@ -202,7 +206,7 @@
     else if (option_string == "-shadows") {
     }  
     else if (option_string == "-ui") {
-      UserInterface *ui = manta_interface->createUserInterface( value_string 
);
+      UserInterface *ui = factory.createUserInterface( value_string );
 
       // Make sure a ui was created.
       if (ui == 0) {
@@ -249,7 +253,7 @@
 void PromptUI::mantaCamera( string text ) {
 
   // Create the camera.
-       Camera *new_camera = manta_interface->createCamera( text );
+       Camera *new_camera = factory.createCamera( text );
        if (new_camera == 0) {
                std::cerr << "Could not select camera " << text << std::endl;
                return;
@@ -266,7 +270,7 @@
 
 void PromptUI::mantaImageTraverser( string text ) {
 
-  manta_interface->selectImageTraverser( text );
+  factory.selectImageTraverser( text );
 }
 
 void PromptUI::automatorComplete() {
@@ -290,31 +294,31 @@
   cerr << " -np N           - Use N processors\n";
   cerr << " -res NxM        - Use N by M pixels for rendering (needs the 
x).\n";
   cerr << " -imagedisplay S - Use image display mode named S, valid modes 
are:\n";
-  printList(cerr, manta_interface->listImageDisplays(), 4);
+  printList(cerr, factory.listImageDisplays(), 4);
   cerr << " -imagetype S    - Use image display mode named S, valid modes 
are:\n";
-  printList(cerr, manta_interface->listImageTypes(), 4);
+  printList(cerr, factory.listImageTypes(), 4);
   cerr << " -ui S           - Use the user interface S, valid options 
are:\n";
-  printList(cerr, manta_interface->listUserInterfaces(), 4);
+  printList(cerr, factory.listUserInterfaces(), 4);
   cerr << " -shadows S      - Use S mode for rendering shadows, valid modes 
are:\n";
-  printList(cerr, manta_interface->listShadowAlgorithms(), 4);
+  printList(cerr, factory.listShadowAlgorithms(), 4);
   cerr << " -imagetraverser S - Use S method for image traversing, valid 
modes are:\n";
-  printList(cerr, manta_interface->listImageTraversers(), 4);
+  printList(cerr, factory.listImageTraversers(), 4);
   cerr << " -pixelsampler S - Use S method for pixel sampling, valid modes 
are:\n";
-  printList(cerr, manta_interface->listPixelSamplers(), 4);
+  printList(cerr, factory.listPixelSamplers(), 4);
   cerr << " -camera S       - User camera model S, valid cameras are:\n";
-  printList(cerr, manta_interface->listCameras(), 4);
+  printList(cerr, factory.listCameras(), 4);
   cerr << " -renderer S     - Use renderer S, valid renderers are:\n";
-  printList(cerr, manta_interface->listRenderers(), 2);
+  printList(cerr, factory.listRenderers(), 2);
   cerr << " -scene S        - Render Scene S\n";
 }
 
 // This method prints a list of options.
-void PromptUI::printList( ostream& out, const MantaInterface::listType& 
list, int spaces ) {
+void PromptUI::printList( ostream& out, const Factory::listType& list, int 
spaces ) {
   
   for(int i=0;i<spaces;i++)
     out << ' ';
   
-  for(MantaInterface::listType::const_iterator iter = list.begin();
+  for(Factory::listType::const_iterator iter = list.begin();
       iter != list.end(); ++iter){
     if(iter != list.begin())
       out << ", ";

Modified: trunk/UserInterface/PromptUI.h
==============================================================================
--- trunk/UserInterface/PromptUI.h      (original)
+++ trunk/UserInterface/PromptUI.h      Fri Oct 13 17:18:43 2006
@@ -33,6 +33,8 @@
 #include <Interface/UserInterface.h>
 #include <Core/Thread/Runnable.h>
 
+#include <Engine/Factory/Factory.h>
+
 #include <sgi_stl_warnings_off.h>
 #include <vector>
 #include <string>
@@ -60,13 +62,14 @@
   class PromptUI: public UserInterface, public SCIRun::Runnable {
   protected:
     MantaInterface *manta_interface;
+    Factory factory;
 
     // Channel that the ui is operating on.
     int current_channel;
 
     // Helper methods.
     void printHelp();
-    void printList( ostream& out, const MantaInterface::listType& list, int 
spaces=0 );
+    void printList( ostream& out, const Factory::listType& list, int 
spaces=0 );
 
     void processCommand( const string &input_line );
 

Modified: trunk/fox/FManta/FMantaWindow.cc
==============================================================================
--- trunk/fox/FManta/FMantaWindow.cc    (original)
+++ trunk/fox/FManta/FMantaWindow.cc    Fri Oct 13 17:18:43 2006
@@ -102,6 +102,7 @@
   : FXMainWindow( app, name, ic, mi, opts, x, y, width, height, pl, pr, pt, 
pb, hs, vs ),
        
     manta_interface( 0 ),
+    manta_factory( manta_interface ),
     fast_quit( false ) ,
     cutting_snap( 1 ),
     debug_packet( 1 ), 
@@ -1025,7 +1026,7 @@
   std::cerr << "Camera text: " << camera_text << std::endl;
        
   // Create the new camera.
-  Camera *new_camera = manta_interface->createCamera( camera_text );
+  Camera *new_camera = manta_factory.createCamera( camera_text );
        
   // Check to make sure the camera text was valid.
   if (new_camera != 0) {
@@ -1117,7 +1118,7 @@
   int channel = manta_frame->getMantaChannel();
        
   // Update the shadow algorithm.
-  Camera *new_camera = manta_interface->createCamera( text );
+  Camera *new_camera = manta_factory.createCamera( text );
   if (new_camera == 0) {
     std::cout << "Could not select camera " << text << std::endl;
     return;
@@ -1141,7 +1142,7 @@
   int channel = manta_frame->getMantaChannel();
        
   try {
-    if (!manta_interface->selectShadowAlgorithm( text )) {
+    if (!manta_factory.selectShadowAlgorithm( text )) {
       std::cout << "Could not select shadow algorithm " << text << std::endl;
     }
   }
@@ -1156,7 +1157,7 @@
   int channel = manta_frame->getMantaChannel();
        
   try {
-    if (!manta_interface->selectPixelSampler( text )) {
+    if (!manta_factory.selectPixelSampler( text )) {
       std::cout << "Could not select pixel sampler " << text << std::endl;
     }
   }
@@ -1174,7 +1175,7 @@
   int channel = manta_frame->getMantaChannel();
        
   try {
-    if (!manta_interface->selectImageTraverser( text )) {
+    if (!manta_factory.selectImageTraverser( text )) {
       std::cout << "Could not select image traverser " << text << std::endl;
     }
   }

Modified: trunk/fox/FManta/FMantaWindow.h
==============================================================================
--- trunk/fox/FManta/FMantaWindow.h     (original)
+++ trunk/fox/FManta/FMantaWindow.h     Fri Oct 13 17:18:43 2006
@@ -13,6 +13,8 @@
 
 #include <UserInterface/CameraPathAutomator.h>
 
+#include <Engine/Factory/Factory.h>
+
 #include <vector>
 
 namespace fox_manta {
@@ -33,6 +35,9 @@
        
     // Interface to the manta rendering library.
     MantaInterface *manta_interface;
+
+    // Factory for parsing strings into manta components.
+    Factory manta_factory;
                
     // Other manta pipeline components which the application "controls"
     // (Transactions must be sent through manta in order to manipulate
@@ -151,7 +156,7 @@
     };
                
     // Constructors.
-    FMantaWindow() : manta_interface( 0 ), fast_quit( false ) {  };
+    FMantaWindow() : manta_interface( 0 ), manta_factory( manta_interface ), 
fast_quit( false ) {  };
     FMantaWindow( FXApp *app, const FXString &name,
 
                  bool use_glx = true,
@@ -207,7 +212,10 @@
                
     // Accessors.
     void setMantaInterface( MantaInterface *manta_interface_, int 
manta_channel_ ) { 
-      manta_interface = manta_interface_; manta_frame->setMantaInterface( 
manta_interface_, manta_channel_ ); };
+      manta_interface = manta_interface_;
+      manta_frame->setMantaInterface( manta_interface_, manta_channel_ );
+      manta_factory.setMantaInterface( manta_interface );
+    };
     void setNavigator( FMantaNavigator *navigator_ ) { 
manta_frame->setNavigator( navigator_ ); };
                
     MantaInterface    *getMantaInterface() { return manta_interface; };

Modified: trunk/fox/dm_demo/dm_demo.cc
==============================================================================
--- trunk/fox/dm_demo/dm_demo.cc        (original)
+++ trunk/fox/dm_demo/dm_demo.cc        Fri Oct 13 17:18:43 2006
@@ -40,6 +40,7 @@
 
 #include <X11/Xlib.h>
 
+#include <Engine/Factory/Factory.h>
 #include <Engine/Display/OpenGLDisplay.h>
 #include <Model/Cameras/PinholeCamera.h>
 
@@ -149,19 +150,22 @@
 
   // Setup the manta pipeline.
   MantaInterface *manta_interface = 0;
+  Factory *manta_factory = 0;
+
   OpenGLDisplay *glx_image_display = 0;
-  
+
   try {
     
     // Construct Manta.
     manta_interface = createManta();
-       
-    manta_interface->setScenePath         ("");
+    manta_factory = new Factory( manta_interface );
+    
+    manta_factory->setScenePath         ("");
     manta_interface->changeNumWorkers     ( np );
-    manta_interface->selectImageType      ( "rgb8" );
-    manta_interface->selectLoadBalancer   ( "workqueue" );
-    manta_interface->selectRenderer       ( "raytracer" );
-    manta_interface->selectShadowAlgorithm( "hard" );    
+    manta_factory->selectImageType      ( "rgb8" );
+    manta_factory->selectLoadBalancer   ( "workqueue" );
+    manta_factory->selectRenderer       ( "raytracer" );
+    manta_factory->selectShadowAlgorithm( "hard" );    
     
     // Camera *camera = new PinholeCamera( Vector ( 0, 0, 0 ), Vector ( 0, 
-1, 0 ), Vector( 0, 0, 1 ), 60 );
        
@@ -178,7 +182,7 @@
 
     
///////////////////////////////////////////////////////////////////////////
     // Try to load a scene.
-    if ((scene_text == 0) || (!manta_interface->readScene( scene_text ))) {
+    if ((scene_text == 0) || (!manta_factory->readScene( scene_text ))) {
       // Create a default scene.
       manta_interface->setScene( createDefaultScene() );
     }
@@ -237,7 +241,7 @@
     
///////////////////////////////////////////////////////////////////////////
     // Configure the renderer stack.
     if (stack_file.size()) {
-      manta_interface->readStack( stack_file, args );
+      manta_factory->readStack( stack_file, args );
     }
     else {
       // Pass a read context and all of the command line args to the scene
@@ -251,7 +255,7 @@
   
     // Create the camera using the first camera bookmark.
     Camera *camera = 0;
-    if ((camera = manta_interface->createCamera( 
manta_window.getCameraBookmark( 0 ) )) == 0) {
+    if ((camera = manta_factory->createCamera( 
manta_window.getCameraBookmark( 0 ) )) == 0) {
       
       std::cerr << "Error could not create camera: " << default_camera << 
std::endl;
       return 1;
@@ -365,11 +369,11 @@
 
///////////////////////////////////////////////////////////////////////////////
 // Default stack setup
 
-void printList(ostream& out, const MantaInterface::listType& list, int 
spaces=0)
+void printList(ostream& out, const Factory::listType& list, int spaces=0)
 {
   for(int i=0;i<spaces;i++)
     out << ' ';
-  for(MantaInterface::listType::const_iterator iter = list.begin();
+  for(Factory::listType::const_iterator iter = list.begin();
       iter != list.end(); ++iter){
     if(iter != list.begin())
       out << ", ";
@@ -378,7 +382,7 @@
   out << "\n";
 }
 
-static void usage(MantaInterface* rtrt)
+static void usage(Factory* rtrt)
 {
   cerr << "Usage: manta [options]\n";
   cerr << "Valid options are:\n";
@@ -409,8 +413,8 @@
 void make_stack( ReadContext &context, const vector<string> &args ) {
 
   // Obtain a pointer to manta.
-  MantaInterface *rtrt = context.manta_interface;
-
+  Factory *rtrt = new Factory( context.manta_interface );
+  
   // Defaults.
   
   if(!rtrt->selectLoadBalancer("workqueue"))

Modified: trunk/include/RegisterConfigurableComponents.h.CMakeTemplate
==============================================================================
--- trunk/include/RegisterConfigurableComponents.h.CMakeTemplate        
(original)
+++ trunk/include/RegisterConfigurableComponents.h.CMakeTemplate        Fri 
Oct 13 17:18:43 2006
@@ -29,6 +29,8 @@
 #ifndef RegisterConfigurableComponents_H
 #define RegisterConfigurableComponents_H
 
+#include <Engine/Factory/Factory.h>
+
 // Add new includes in their own block that can be defined in and out
 // of existence.  Make sure in the CMakeLists.txt file that you create
 // a variable that will be either 1 or 0 based on the configuration.
@@ -37,7 +39,7 @@
 #endif
 
 namespace Manta {
-  static void RegisterConfigurableComponents(MantaInterface* engine)
+  static void RegisterConfigurableComponents(Factory* engine)
   {
     // Now optionally add code
 #if ${PABST_FOUND_DEF}

Modified: trunk/scenes/0.cc
==============================================================================
--- trunk/scenes/0.cc   (original)
+++ trunk/scenes/0.cc   Fri Oct 13 17:18:43 2006
@@ -19,6 +19,8 @@
 #include <Core/Geometry/AffineTransform.h>
 #include <Core/Util/NotFinished.h>
 
+#include <Engine/Factory/Factory.h>
+
 #include <sgi_stl_warnings_off.h>
 #include <iostream>
 #include <sgi_stl_warnings_on.h>
@@ -138,6 +140,9 @@
   double light_radius=0.8;
   int argc = static_cast<int>(args.size());
   Group* group = 0;
+
+  Factory factory( context.manta_interface );
+  
   for(int i=0;i<argc;i++){
     string arg = args[i];
     if(arg == "-size"){
@@ -150,7 +155,7 @@
       string s;
       if(!getStringArg(i, args, s))
         throw IllegalArgument("scene 0 -group", i, args);
-      group = context.manta_interface->makeGroup(s);
+      group = factory.makeGroup(s);
       if ( group == 0 )
         throw IllegalArgument("scene 0 -group", i, args);
     } else {

Modified: trunk/scenes/acceltest.cc
==============================================================================
--- trunk/scenes/acceltest.cc   (original)
+++ trunk/scenes/acceltest.cc   Fri Oct 13 17:18:43 2006
@@ -13,6 +13,8 @@
 #include <Model/Materials/Phong.h>
 #include <Model/Primitives/Sphere.h>
 
+#include <Engine/Factory/Factory.h>
+
 #include <Core/Math/MinMax.h>
 #include <sgi_stl_warnings_off.h>
 #include <string>
@@ -30,6 +32,8 @@
     const vector< string > &args )
 {
 
+  Factory factory( context.manta_interface );
+  
   Group *world = 0;
   string model_name = "/usr/sci/data/Geometry/particle/sd022-crop.mpm";
   int argc = static_cast< int >( args.size() );
@@ -39,7 +43,7 @@
       string s;
       if ( !getStringArg( i, args, s ) )
         throw IllegalArgument("scene acceltest -group", i, args);
-      world = context.manta_interface->makeGroup( s );
+      world = factory.makeGroup( s );
       if ( world == 0 )
         throw IllegalArgument( "scene acceltest -group", i, args );
     } else if ( arg == "-model" ) {

Modified: trunk/scenes/cube.cc
==============================================================================
--- trunk/scenes/cube.cc        (original)
+++ trunk/scenes/cube.cc        Fri Oct 13 17:18:43 2006
@@ -50,6 +50,8 @@
 #include <Core/Geometry/AffineTransform.h>
 #include <Core/Util/NotFinished.h>
 
+#include <Engine/Factory/Factory.h>
+
 #include <Model/MiscObjects/CuttingPlane.h>
 
 #include <sgi_stl_warnings_off.h>
@@ -65,6 +67,8 @@
 extern "C"
 Scene* make_scene(const ReadContext& context, const vector<string>& args)
 {
+  Factory factory( context.manta_interface );
+  
   int argc = static_cast<int>(args.size());
   Group* world = 0;
   for(int i=0;i<argc;i++){
@@ -73,7 +77,7 @@
       string s;
       if(!getStringArg(i, args, s))
         throw IllegalArgument("cube -bv", i, args);
-      world = context.manta_interface->makeGroup(s);
+      world = factory.makeGroup(s);
     } else {
       cerr << "Valid options for cube:\n";
       cerr << "-bv <group,bvh,grid>\n";




  • [MANTA] r1221 - in trunk: Engine/Control Engine/Factory Interface StandAlone SwigInterface UserInterface fox/FManta fox/dm_demo include scenes, abe, 10/13/2006

Archive powered by MHonArc 2.6.16.

Top of page