Equalizer  1.2.1
eqPly/localInitData.cpp
00001 
00002 /* Copyright (c) 2007-2011, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *
00007  * - Redistributions of source code must retain the above copyright notice, this
00008  *   list of conditions and the following disclaimer.
00009  * - Redistributions in binary form must reproduce the above copyright notice,
00010  *   this list of conditions and the following disclaimer in the documentation
00011  *   and/or other materials provided with the distribution.
00012  * - Neither the name of Eyescale Software GmbH nor the names of its
00013  *   contributors may be used to endorse or promote products derived from this
00014  *   software without specific prior written permission.
00015  *
00016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00026  * POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00029 #include "localInitData.h"
00030 #include "frameData.h"
00031 
00032 #include <algorithm>
00033 #include <cctype>
00034 #include <functional>
00035 
00036 #ifndef MIN
00037 #  define MIN EQ_MIN
00038 #endif
00039 #include <tclap/CmdLine.h>
00040 
00041 namespace eqPly
00042 {
00043 LocalInitData::LocalInitData() 
00044         : _maxFrames( 0xffffffffu )
00045         , _color( true )
00046         , _isResident( false )
00047 {
00048 #ifdef EQ_RELEASE
00049 #  ifdef _WIN32 // final INSTALL_DIR is not known at compile time
00050     _filenames.push_back( "../share/Equalizer/data" );
00051 #  else
00052     _filenames.push_back( std::string( EQ_INSTALL_DIR ) +
00053                           std::string( "share/Equalizer/data" ));
00054 #  endif
00055 #else
00056     _filenames.push_back( std::string( EQ_SOURCE_DIR ) + 
00057                           std::string( "examples/eqPly" ));
00058 #endif
00059 }
00060 
00061 const LocalInitData& LocalInitData::operator = ( const LocalInitData& from )
00062 {
00063     _trackerPort = from._trackerPort;  
00064     _maxFrames   = from._maxFrames;    
00065     _color       = from._color;        
00066     _isResident  = from._isResident;
00067     _filenames    = from._filenames;
00068     _pathFilename = from._pathFilename;
00069 
00070     setWindowSystem( from.getWindowSystem( ));
00071     setRenderMode( from.getRenderMode( ));
00072     if( from.useGLSL( )) 
00073         enableGLSL();
00074     if( from.useInvertedFaces( )) 
00075         enableInvertedFaces();
00076     if( !from.showLogo( )) 
00077         disableLogo();
00078 
00079     return *this;
00080 }
00081 
00082 void LocalInitData::parseArguments( const int argc, char** argv )
00083 {
00084     try
00085     {
00086         std::string wsHelp = "Window System API ( one of: ";
00087 #ifdef AGL
00088         wsHelp += "AGL ";
00089 #endif
00090 #ifdef GLX
00091         wsHelp += "glX ";
00092 #endif
00093 #ifdef WGL
00094         wsHelp += "WGL ";
00095 #endif
00096         wsHelp += ")";
00097 
00098         const std::string& desc = EqPly::getHelp();
00099 
00100         TCLAP::CmdLine command( desc );
00101         TCLAP::MultiArg<std::string> modelArg( "m", "model", 
00102                                              "ply model file name or directory",
00103                                                false, "string", command );
00104         TCLAP::ValueArg<std::string> portArg( "p", "port",
00105                                               "tracking device port",
00106                                               false, "/dev/ttyS0", "string",
00107                                               command );
00108         TCLAP::SwitchArg colorArg( "b", "blackAndWhite", 
00109                                    "Don't use colors from ply file", 
00110                                    command, false );
00111         TCLAP::SwitchArg residentArg( "r", "resident", 
00112            "Keep client resident (see resident node documentation on website)", 
00113                                       command, false );
00114         TCLAP::ValueArg<uint32_t> framesArg( "n", "numFrames", 
00115                                            "Maximum number of rendered frames", 
00116                                              false, 0xffffffffu, "unsigned",
00117                                              command );
00118         TCLAP::ValueArg<std::string> wsArg( "w", "windowSystem", wsHelp,
00119                                             false, "auto", "string", command );
00120         TCLAP::ValueArg<std::string> modeArg( "c", "renderMode", 
00121                                  "Rendering Mode (immediate, displayList, VBO)",
00122                                               false, "auto", "string",
00123                                               command );
00124         TCLAP::SwitchArg glslArg( "g", "glsl", "Enable GLSL shaders", 
00125                                     command, false );
00126         TCLAP::SwitchArg invFacesArg( "i", "invertFaces",
00127                              "Invert faces (valid during binary file creation)",
00128                                     command, false );
00129         TCLAP::ValueArg<std::string> pathArg( "a", "cameraPath",
00130                                         "File containing camera path animation",
00131                                               false, "", "string", command );
00132         TCLAP::SwitchArg overlayArg( "o", "noOverlay", "Disable overlay logo", 
00133                                      command, false );
00134         TCLAP::VariableSwitchArg ignoreEqArgs( "eq",
00135                                                "Ignored Equalizer options",
00136                                                command );
00137         TCLAP::UnlabeledMultiArg< std::string >
00138             ignoreArgs( "ignore", "Ignored unlabeled arguments", false, "any",
00139                         command );
00140 
00141         command.parse( argc, argv );
00142 
00143         if( modelArg.isSet( ))
00144         {
00145             _filenames.clear();
00146             _filenames = modelArg.getValue();
00147         }
00148         if( portArg.isSet( ))
00149             _trackerPort = portArg.getValue();
00150         if( wsArg.isSet( ))
00151         {
00152             std::string windowSystem = wsArg.getValue();
00153             transform( windowSystem.begin(), windowSystem.end(),
00154                        windowSystem.begin(), (int(*)(int))std::toupper );
00155 
00156             setWindowSystem( windowSystem );
00157         }
00158 
00159         _color = !colorArg.isSet();
00160 
00161         if( framesArg.isSet( ))
00162             _maxFrames = framesArg.getValue();
00163 
00164         if( residentArg.isSet( ))
00165             _isResident = true;
00166 
00167         if( modeArg.isSet() )
00168         {
00169             std::string mode = modeArg.getValue();
00170             transform( mode.begin(), mode.end(), mode.begin(),
00171                        (int(*)(int))std::tolower );
00172             
00173             if( mode == "immediate" )
00174                 setRenderMode( mesh::RENDER_MODE_IMMEDIATE );
00175             else if( mode == "displaylist" )
00176                 setRenderMode( mesh::RENDER_MODE_DISPLAY_LIST );
00177             else if( mode == "vbo" )
00178                 setRenderMode( mesh::RENDER_MODE_BUFFER_OBJECT );
00179         }
00180 
00181         if( pathArg.isSet( ))
00182             _pathFilename = pathArg.getValue();
00183 
00184         if( glslArg.isSet() )
00185             enableGLSL();
00186         if( invFacesArg.isSet() )
00187             enableInvertedFaces();
00188         if( overlayArg.isSet( ))
00189             disableLogo();
00190     }
00191     catch( const TCLAP::ArgException& exception )
00192     {
00193         EQERROR << "Command line parse error: " << exception.error() 
00194                 << " for argument " << exception.argId() << std::endl;
00195         ::exit( EXIT_FAILURE );
00196     }
00197 }
00198 }
00199 
Generated on Fri Jun 8 2012 15:44:31 for Equalizer 1.2.1 by  doxygen 1.8.0