eqPly/localInitData.cpp

00001 
00002 /* Copyright (c) 2007-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
00016  */
00017 
00018 #include "localInitData.h"
00019 #include "frameData.h"
00020 
00021 #include <algorithm>
00022 #include <cctype>
00023 #include <functional>
00024 
00025 #ifndef MIN
00026 #  define MIN EQ_MIN
00027 #endif
00028 #include <tclap/CmdLine.h>
00029 
00030 using namespace std;
00031 
00032 namespace eqPly
00033 {
00034 LocalInitData::LocalInitData() 
00035         : _maxFrames( 0xffffffffu )
00036         , _color( true )
00037         , _isResident( false )
00038 {
00039     _filenames.push_back( "examples/eqPly/" );
00040     _filenames.push_back( "../examples/eqPly/" );
00041     _filenames.push_back( "../share/data/" );
00042     _filenames.push_back( "/opt/local/share/data/" );
00043     _filenames.push_back( "/usr/local/share/data/" );
00044     _filenames.push_back( "/usr/share/data/" );
00045 }
00046 
00047 const LocalInitData& LocalInitData::operator = ( const LocalInitData& from )
00048 {
00049     _trackerPort = from._trackerPort;  
00050     _maxFrames   = from._maxFrames;    
00051     _color       = from._color;        
00052     _isResident  = from._isResident;
00053     _filenames    = from._filenames;
00054     _pathFilename = from._pathFilename;
00055 
00056     setWindowSystem( from.getWindowSystem( ));
00057     setRenderMode( from.getRenderMode( ));
00058     if( from.useGLSL( )) 
00059         enableGLSL();
00060     if( from.useInvertedFaces( )) 
00061         enableInvertedFaces();
00062     if( !from.showLogo( )) 
00063         disableLogo();
00064 
00065     return *this;
00066 }
00067 
00068 void LocalInitData::parseArguments( const int argc, char** argv )
00069 {
00070     try
00071     {
00072         string wsHelp = "Window System API ( one of: ";
00073 #ifdef AGL
00074         wsHelp += "AGL ";
00075 #endif
00076 #ifdef GLX
00077         wsHelp += "glX ";
00078 #endif
00079 #ifdef WGL
00080         wsHelp += "WGL ";
00081 #endif
00082         wsHelp += ")";
00083 
00084         const std::string& desc = EqPly::getHelp();
00085 
00086         TCLAP::CmdLine command( desc );
00087         TCLAP::MultiArg<string> modelArg( "m", "model", 
00088                                           "ply model file name or directory", 
00089                                           false, "string", command );
00090         TCLAP::ValueArg<string> portArg( "p", "port", "tracking device port",
00091                                          false, "/dev/ttyS0", "string",
00092                                          command );
00093         TCLAP::SwitchArg colorArg( "b", "blackAndWhite", 
00094                                    "Don't use colors from ply file", 
00095                                    command, false );
00096         TCLAP::SwitchArg residentArg( "r", "resident", 
00097            "Keep client resident (see resident node documentation on website)", 
00098                                       command, false );
00099         TCLAP::ValueArg<uint32_t> framesArg( "n", "numFrames", 
00100                                            "Maximum number of rendered frames", 
00101                                              false, 0xffffffffu, "unsigned",
00102                                              command );
00103         TCLAP::ValueArg<string> wsArg( "w", "windowSystem", wsHelp,
00104                                        false, "auto", "string", command );
00105         TCLAP::ValueArg<string> modeArg( "c", "renderMode", 
00106                                  "Rendering Mode (immediate, displayList, VBO)",
00107                                        false, "auto", "string", command );
00108         TCLAP::SwitchArg glslArg( "g", "glsl", "Enable GLSL shaders", 
00109                                     command, false );
00110         TCLAP::SwitchArg invFacesArg( "i", "invertFaces",
00111                             "Invert faces (valid during binary file creation)", 
00112                                     command, false );
00113         TCLAP::ValueArg<string> logArg( "l", "log", "output log file",
00114                                         false, "eqPly.log", "string",
00115                                         command );
00116         TCLAP::ValueArg<string> pathArg( "a", "cameraPath",
00117                                         "File containing camera path animation",
00118                                          false, "", "string", command );
00119         TCLAP::SwitchArg overlayArg( "o", "noOverlay", "Disable overlay logo", 
00120                                      command, false );
00121 
00122         command.parse( argc, argv );
00123 
00124         if( modelArg.isSet( ))
00125         {
00126             _filenames.clear();
00127             _filenames = modelArg.getValue();
00128         }
00129         if( portArg.isSet( ))
00130             _trackerPort = portArg.getValue();
00131         if( wsArg.isSet( ))
00132         {
00133             string windowSystem = wsArg.getValue();
00134             transform( windowSystem.begin(), windowSystem.end(),
00135                        windowSystem.begin(), (int(*)(int))std::tolower );
00136 
00137             if( windowSystem == "glx" )
00138                 setWindowSystem( eq::WINDOW_SYSTEM_GLX );
00139             else if( windowSystem == "agl" )
00140                 setWindowSystem( eq::WINDOW_SYSTEM_AGL );
00141             else if( windowSystem == "wgl" )
00142                 setWindowSystem( eq::WINDOW_SYSTEM_WGL );
00143         }
00144 
00145         _color = !colorArg.isSet();
00146 
00147         if( framesArg.isSet( ))
00148             _maxFrames = framesArg.getValue();
00149 
00150         if( residentArg.isSet( ))
00151             _isResident = true;
00152 
00153         if( modeArg.isSet() )
00154         {
00155             string mode = modeArg.getValue();
00156             transform( mode.begin(), mode.end(), mode.begin(),
00157                        (int(*)(int))std::tolower );
00158             
00159             if( mode == "immediate" )
00160                 setRenderMode( mesh::RENDER_MODE_IMMEDIATE );
00161             else if( mode == "displaylist" )
00162                 setRenderMode( mesh::RENDER_MODE_DISPLAY_LIST );
00163             else if( mode == "vbo" )
00164                 setRenderMode( mesh::RENDER_MODE_BUFFER_OBJECT );
00165         }
00166 
00167         if( pathArg.isSet( ))
00168             _pathFilename = pathArg.getValue();
00169 
00170         if( logArg.isSet( ))
00171             _logFilename = logArg.getValue();
00172         
00173         if( glslArg.isSet() )
00174             enableGLSL();
00175         if( invFacesArg.isSet() )
00176             enableInvertedFaces();
00177         if( overlayArg.isSet( ))
00178             disableLogo();
00179     }
00180     catch( TCLAP::ArgException& exception )
00181     {
00182         EQERROR << "Command line parse error: " << exception.error() 
00183                 << " for argument " << exception.argId() << endl;
00184     }
00185 }
00186 }
00187 
Generated on Mon Aug 10 18:58:40 2009 for Equalizer 0.9 by  doxygen 1.5.8