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