Equalizer 1.0

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     _filenames.push_back( std::string( EQ_INSTALL_DIR ) +
00050                           std::string( "share/Equalizer/data" ));
00051 #else
00052     _filenames.push_back( std::string( EQ_SOURCE_DIR ) + 
00053                           std::string( "examples/eqPly" ));
00054 #endif
00055 }
00056 
00057 const LocalInitData& LocalInitData::operator = ( const LocalInitData& from )
00058 {
00059     _trackerPort = from._trackerPort;  
00060     _maxFrames   = from._maxFrames;    
00061     _color       = from._color;        
00062     _isResident  = from._isResident;
00063     _filenames    = from._filenames;
00064     _pathFilename = from._pathFilename;
00065 
00066     setWindowSystem( from.getWindowSystem( ));
00067     setRenderMode( from.getRenderMode( ));
00068     if( from.useGLSL( )) 
00069         enableGLSL();
00070     if( from.useInvertedFaces( )) 
00071         enableInvertedFaces();
00072     if( !from.showLogo( )) 
00073         disableLogo();
00074 
00075     return *this;
00076 }
00077 
00078 void LocalInitData::parseArguments( const int argc, char** argv )
00079 {
00080     try
00081     {
00082         std::string wsHelp = "Window System API ( one of: ";
00083 #ifdef AGL
00084         wsHelp += "AGL ";
00085 #endif
00086 #ifdef GLX
00087         wsHelp += "glX ";
00088 #endif
00089 #ifdef WGL
00090         wsHelp += "WGL ";
00091 #endif
00092         wsHelp += ")";
00093 
00094         const std::string& desc = EqPly::getHelp();
00095 
00096         TCLAP::CmdLine command( desc );
00097         TCLAP::MultiArg<std::string> modelArg( "m", "model", 
00098                                              "ply model file name or directory",
00099                                                false, "string", command );
00100         TCLAP::ValueArg<std::string> portArg( "p", "port",
00101                                               "tracking device port",
00102                                               false, "/dev/ttyS0", "string",
00103                                               command );
00104         TCLAP::SwitchArg colorArg( "b", "blackAndWhite", 
00105                                    "Don't use colors from ply file", 
00106                                    command, false );
00107         TCLAP::SwitchArg residentArg( "r", "resident", 
00108            "Keep client resident (see resident node documentation on website)", 
00109                                       command, false );
00110         TCLAP::ValueArg<uint32_t> framesArg( "n", "numFrames", 
00111                                            "Maximum number of rendered frames", 
00112                                              false, 0xffffffffu, "unsigned",
00113                                              command );
00114         TCLAP::ValueArg<std::string> wsArg( "w", "windowSystem", wsHelp,
00115                                             false, "auto", "string", command );
00116         TCLAP::ValueArg<std::string> modeArg( "c", "renderMode", 
00117                                  "Rendering Mode (immediate, displayList, VBO)",
00118                                               false, "auto", "string",
00119                                               command );
00120         TCLAP::SwitchArg glslArg( "g", "glsl", "Enable GLSL shaders", 
00121                                     command, false );
00122         TCLAP::SwitchArg invFacesArg( "i", "invertFaces",
00123                              "Invert faces (valid during binary file creation)",
00124                                     command, false );
00125         TCLAP::ValueArg<std::string> pathArg( "a", "cameraPath",
00126                                         "File containing camera path animation",
00127                                               false, "", "string", command );
00128         TCLAP::SwitchArg overlayArg( "o", "noOverlay", "Disable overlay logo", 
00129                                      command, false );
00130         TCLAP::VariableSwitchArg ignoreEqArgs( "eq",
00131                                                "Ignored Equalizer options",
00132                                                command );
00133         TCLAP::UnlabeledMultiArg< std::string >
00134             ignoreArgs( "ignore", "Ignored unlabeled arguments", false, "any",
00135                         command );
00136 
00137         command.parse( argc, argv );
00138 
00139         if( modelArg.isSet( ))
00140         {
00141             _filenames.clear();
00142             _filenames = modelArg.getValue();
00143         }
00144         if( portArg.isSet( ))
00145             _trackerPort = portArg.getValue();
00146         if( wsArg.isSet( ))
00147         {
00148             std::string windowSystem = wsArg.getValue();
00149             transform( windowSystem.begin(), windowSystem.end(),
00150                        windowSystem.begin(), (int(*)(int))std::tolower );
00151 
00152             if( windowSystem == "glx" )
00153                 setWindowSystem( eq::WINDOW_SYSTEM_GLX );
00154             else if( windowSystem == "agl" )
00155                 setWindowSystem( eq::WINDOW_SYSTEM_AGL );
00156             else if( windowSystem == "wgl" )
00157                 setWindowSystem( eq::WINDOW_SYSTEM_WGL );
00158         }
00159 
00160         _color = !colorArg.isSet();
00161 
00162         if( framesArg.isSet( ))
00163             _maxFrames = framesArg.getValue();
00164 
00165         if( residentArg.isSet( ))
00166             _isResident = true;
00167 
00168         if( modeArg.isSet() )
00169         {
00170             std::string mode = modeArg.getValue();
00171             transform( mode.begin(), mode.end(), mode.begin(),
00172                        (int(*)(int))std::tolower );
00173             
00174             if( mode == "immediate" )
00175                 setRenderMode( mesh::RENDER_MODE_IMMEDIATE );
00176             else if( mode == "displaylist" )
00177                 setRenderMode( mesh::RENDER_MODE_DISPLAY_LIST );
00178             else if( mode == "vbo" )
00179                 setRenderMode( mesh::RENDER_MODE_BUFFER_OBJECT );
00180         }
00181 
00182         if( pathArg.isSet( ))
00183             _pathFilename = pathArg.getValue();
00184 
00185         if( glslArg.isSet() )
00186             enableGLSL();
00187         if( invFacesArg.isSet() )
00188             enableInvertedFaces();
00189         if( overlayArg.isSet( ))
00190             disableLogo();
00191     }
00192     catch( TCLAP::ArgException& exception )
00193     {
00194         EQERROR << "Command line parse error: " << exception.error() 
00195                 << " for argument " << exception.argId() << std::endl;
00196         ::exit( EXIT_FAILURE );
00197     }
00198 }
00199 }
00200 
Generated on Sun May 8 2011 19:11:07 for Equalizer 1.0 by  doxygen 1.7.3