eVolve/localInitData.cpp

00001 /*
00002  * Copyright (c) 2007-2008, Stefan Eilemann <eile@equalizergraphics.com> 
00003   ! All rights reserved. 
00004  */
00005 
00006 #include "localInitData.h"
00007 #include "frameData.h"
00008 
00009 #include <algorithm>
00010 #include <cctype>
00011 #include <functional>
00012 
00013 #ifndef MIN
00014 #  define MIN EQ_MIN
00015 #endif
00016 #include <tclap/CmdLine.h>
00017 
00018 using namespace std;
00019 
00020 namespace eVolve
00021 {
00022 LocalInitData::LocalInitData()
00023         : _maxFrames( 0xffffffffu )
00024         , _isResident( false )
00025         , _ortho( false )
00026 {}
00027 
00028 const LocalInitData& LocalInitData::operator = ( const LocalInitData& from )
00029 {
00030     _maxFrames   = from._maxFrames;    
00031     _isResident  = from._isResident;
00032     _ortho       = from._ortho;
00033 
00034     setFilename( from.getFilename( ));
00035     setWindowSystem( from.getWindowSystem( ));
00036     setPrecision( from.getPrecision( ));
00037     setBrightness( from.getBrightness( ));
00038     setAlpha( from.getAlpha( ));
00039     return *this;
00040 }
00041 
00042 void LocalInitData::parseArguments( const int argc, char** argv )
00043 {
00044     try
00045     {
00046         string wsHelp = "Window System API ( one of: ";
00047 #ifdef AGL
00048         wsHelp += "AGL ";
00049 #endif
00050 #ifdef GLX
00051         wsHelp += "glX ";
00052 #endif
00053 #ifdef WGL
00054         wsHelp += "WGL ";
00055 #endif
00056         wsHelp += ")";
00057 
00058         string desc = 
00059             string( "eVolve - Equalizer volume rendering example\n" ) +
00060             string( "\tRun-time commands:\n" ) +
00061             string( "\t\tLeft Mouse Button:         Rotate model\n" ) +
00062             string( "\t\tMiddle Mouse Button:       Move model in X, Y\n" ) +
00063             string( "\t\tRight Mouse Button:        Move model in Z\n" ) +
00064             string( "\t\t<Esc>, All Mouse Buttons:  Exit program\n" ) +
00065             string( "\t\t<Space>, r:                Reset camera\n" ) +
00066             string( "\t\to:                         Toggle perspective/orthographic\n" );
00067             string( "\t\ts:                         Toggle statistics overlay\n" );
00068 
00069         TCLAP::CmdLine command( desc );
00070         
00071         TCLAP::ValueArg<string> modelArg( "m", "model", "raw model file name",
00072                                           false, "Bucky32x32x32.raw", "string",
00073                                           command );
00074         TCLAP::SwitchArg residentArg( "r", "resident", 
00075            "Keep client resident (see resident node documentation on website)", 
00076                                       command, false );
00077         TCLAP::ValueArg<uint32_t> framesArg( "n", "numFrames", 
00078                                            "Maximum number of rendered frames", 
00079                                              false, 0xffffffffu, "unsigned",
00080                                              command );
00081         TCLAP::ValueArg<uint32_t> precisionArg( "p", "precision", 
00082                 "Rendering precision (default 2, bigger is better and slower)", 
00083                                                 false, 2, "unsigned",
00084                                                 command );
00085         TCLAP::ValueArg<float> brightnessArg( "b", "brightness",
00086                                               "brightness factor", false, 1.0f,
00087                                               "float", command );
00088         TCLAP::ValueArg<float> alphaArg( "a", "alpha", "alpha attenuation", 
00089                                          false, 1.0f, "float", command );
00090         TCLAP::SwitchArg orthoArg( "o", "ortho", 
00091                                    "use orthographic projection", 
00092                                    command, false );
00093         TCLAP::ValueArg<string> wsArg( "w", "windowSystem", wsHelp,
00094                                        false, "auto", "string", command );
00095 
00096         command.parse( argc, argv );
00097 
00098         if( modelArg.isSet( ))
00099             setFilename( modelArg.getValue( ));
00100         if( wsArg.isSet( ))
00101         {
00102             string windowSystem = wsArg.getValue();
00103             transform( windowSystem.begin(), windowSystem.end(),
00104                        windowSystem.begin(), (int(*)(int))std::tolower );
00105 
00106             if( windowSystem == "glx" )
00107                 setWindowSystem( eq::WINDOW_SYSTEM_GLX );
00108             else if( windowSystem == "agl" )
00109                 setWindowSystem( eq::WINDOW_SYSTEM_AGL );
00110             else if( windowSystem == "wgl" )
00111                 setWindowSystem( eq::WINDOW_SYSTEM_WGL );
00112         }
00113 
00114         if( framesArg.isSet( ))
00115             _maxFrames = framesArg.getValue();
00116         if( precisionArg.isSet( ))
00117             setPrecision( precisionArg.getValue( ));
00118         if( brightnessArg.isSet( ))
00119             setBrightness( brightnessArg.getValue( ));
00120         if( alphaArg.isSet( ))
00121             setAlpha( alphaArg.getValue( ));
00122         if( residentArg.isSet( ))
00123             _isResident = true;
00124         if( orthoArg.isSet( ))
00125             _ortho = true;
00126     }
00127     catch( TCLAP::ArgException& exception )
00128     {
00129         EQERROR << "Command line parse error: " << exception.error() 
00130                 << " for argument " << exception.argId() << endl;
00131     }
00132 }
00133 }
00134 
Generated on Mon Aug 10 18:58:40 2009 for Equalizer 0.9 by  doxygen 1.5.8