Equalizer  1.6.1
eVolve/localInitData.cpp
1 
2 /* Copyright (c) 2007-2012, Stefan Eilemann <eile@equalizergraphics.com>
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * - Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  * - Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * - Neither the name of Eyescale Software GmbH nor the names of its
13  * contributors may be used to endorse or promote products derived from this
14  * software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include "localInitData.h"
30 #include "frameData.h"
31 
32 #include <algorithm>
33 #include <cctype>
34 #include <functional>
35 
36 #ifndef MIN
37 # define MIN LB_MIN
38 #endif
39 #include <tclap/CmdLine.h>
40 
41 namespace eVolve
42 {
43 LocalInitData::LocalInitData()
44  : _maxFrames( 0xffffffffu )
45  , _isResident( false )
46  , _ortho( false )
47 {}
48 
49 const LocalInitData& LocalInitData::operator = ( const LocalInitData& from )
50 {
51  _maxFrames = from._maxFrames;
52  _isResident = from._isResident;
53  _ortho = from._ortho;
54 
55  setFilename( from.getFilename( ));
56  setWindowSystem( from.getWindowSystem( ));
57  setPrecision( from.getPrecision( ));
58  setBrightness( from.getBrightness( ));
59  setAlpha( from.getAlpha( ));
60  return *this;
61 }
62 
63 void LocalInitData::parseArguments( const int argc, char** argv )
64 {
65  try
66  {
67  std::string wsHelp = "Window System API ( one of: ";
68 #ifdef AGL
69  wsHelp += "AGL ";
70 #endif
71 #ifdef GLX
72  wsHelp += "glX ";
73 #endif
74 #ifdef WGL
75  wsHelp += "WGL ";
76 #endif
77  wsHelp += ")";
78 
79  std::string desc = EVolve::getHelp();
80 
81  TCLAP::CmdLine command( desc, ' ', eq::Version::getString( ));
82  TCLAP::ValueArg<std::string> modelArg( "m", "model",
83  "raw model file name",
84  false, "Bucky32x32x32.raw",
85  "string", command );
86  TCLAP::SwitchArg residentArg( "r", "resident",
87  "Keep client resident (see resident node documentation on website)",
88  command, false );
89  TCLAP::ValueArg<uint32_t> framesArg( "n", "numFrames",
90  "Maximum number of rendered frames",
91  false, 0xffffffffu, "unsigned",
92  command );
93  TCLAP::ValueArg<uint32_t> precisionArg( "p", "precision",
94  "Rendering precision (default 2, bigger is better and slower)",
95  false, 2, "unsigned",
96  command );
97  TCLAP::ValueArg<float> brightnessArg( "b", "brightness",
98  "brightness factor", false, 1.0f,
99  "float", command );
100  TCLAP::ValueArg<float> alphaArg( "a", "alpha", "alpha attenuation",
101  false, 1.0f, "float", command );
102  TCLAP::SwitchArg orthoArg( "o", "ortho",
103  "use orthographic projection",
104  command, false );
105  TCLAP::ValueArg<std::string> wsArg( "w", "windowSystem", wsHelp,
106  false, "auto", "string", command );
107  TCLAP::UnlabeledMultiArg< std::string >
108  ignoreArgs( "ignore", "Ignored unlabeled arguments", false, "any",
109  command );
110 
111 #ifdef TCPLAP_HAS_IGNOREUNMATCHED
112  command.ignoreUnmatched( true );
113 #endif
114  command.parse( argc, argv );
115 
116  if( modelArg.isSet( ))
117  setFilename( modelArg.getValue( ));
118  if( wsArg.isSet( ))
119  {
120  std::string windowSystem = wsArg.getValue();
121  transform( windowSystem.begin(), windowSystem.end(),
122  windowSystem.begin(), (int(*)(int))std::toupper );
123 
124  setWindowSystem( windowSystem );
125  }
126 
127  if( framesArg.isSet( ))
128  _maxFrames = framesArg.getValue();
129  if( precisionArg.isSet( ))
130  setPrecision( precisionArg.getValue( ));
131  if( brightnessArg.isSet( ))
132  setBrightness( brightnessArg.getValue( ));
133  if( alphaArg.isSet( ))
134  setAlpha( alphaArg.getValue( ));
135  if( residentArg.isSet( ))
136  _isResident = true;
137  if( orthoArg.isSet( ))
138  _ortho = true;
139  }
140  catch( const TCLAP::ArgException& exception )
141  {
142  LBERROR << "Command line parse error: " << exception.error()
143  << " for argument " << exception.argId() << std::endl;
144  ::exit( EXIT_FAILURE );
145  }
146 }
147 }
148 
static std::string getString()
bool exit()
De-initialize the Equalizer fabric namespace.