Added the usage report to the examples for when no arguments are passed

to the examples.
This commit is contained in:
Robert Osfield 2003-04-06 21:32:44 +00:00
parent 908164d58a
commit 49a28660dc
40 changed files with 166 additions and 72 deletions

View File

@ -123,5 +123,7 @@ EXAMPLE_DIRS = \
osgvertexprogram\ osgvertexprogram\
osgviewer\ osgviewer\
# osgjigsaw\
# comment in you want to compile the cluster demo. # comment in you want to compile the cluster demo.
EXAMPLE_DIRS += osgcluster EXAMPLE_DIRS += osgcluster

View File

@ -193,7 +193,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.

View File

@ -168,7 +168,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.

View File

@ -132,7 +132,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
@ -161,6 +161,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(arguments); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) if (!rootnode)

View File

@ -131,7 +131,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
@ -160,6 +160,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(arguments); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel) if (!loadedModel)

View File

@ -99,7 +99,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("-m","Set viewer to MASTER mode, sending view via packets."); arguments.getApplicationUsage()->addCommandLineOption("-m","Set viewer to MASTER mode, sending view via packets.");
arguments.getApplicationUsage()->addCommandLineOption("-s","Set viewer to SLAVE mode, reciving view via packets."); arguments.getApplicationUsage()->addCommandLineOption("-s","Set viewer to SLAVE mode, reciving view via packets.");
@ -149,6 +149,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// load model. // load model.
osg::ref_ptr<osg::Node> rootnode = osgDB::readNodeFiles(arguments); osg::ref_ptr<osg::Node> rootnode = osgDB::readNodeFiles(arguments);

View File

@ -133,7 +133,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
@ -156,6 +156,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(arguments); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) if (!rootnode)

View File

@ -74,7 +74,7 @@ int main(int argc, char *argv[])
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.
@ -103,6 +103,12 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(arguments); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) { if (!rootnode) {

View File

@ -89,7 +89,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("--fov <float>","Set the Field of View"); arguments.getApplicationUsage()->addCommandLineOption("--fov <float>","Set the Field of View");
@ -122,6 +122,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(arguments); osg::Node* rootnode = osgDB::readNodeFiles(arguments);

View File

@ -646,7 +646,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.

View File

@ -108,7 +108,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.

View File

@ -117,7 +117,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] [filename] ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] [filename] ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
@ -147,7 +147,6 @@ int main( int argc, char **argv )
return 1; return 1;
} }
// read the scene from the list of file specified commandline args. // read the scene from the list of file specified commandline args.
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments); osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);

View File

@ -219,7 +219,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.
@ -253,7 +253,6 @@ int main( int argc, char **argv )
} }
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* model = osgDB::readNodeFiles(arguments); osg::Node* model = osgDB::readNodeFiles(arguments);
if (model) if (model)

View File

@ -381,7 +381,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("-c","Mannually create occluders"); arguments.getApplicationUsage()->addCommandLineOption("-c","Mannually create occluders");
@ -417,7 +417,6 @@ int main( int argc, char **argv )
return 1; return 1;
} }
// attach the scene graph. // attach the scene graph.
viewer.setSceneData( keyboardModel->getScene() ); viewer.setSceneData( keyboardModel->getScene() );

View File

@ -303,7 +303,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.
@ -332,7 +332,6 @@ int main( int argc, char **argv )
return 1; return 1;
} }
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(arguments); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);

View File

@ -11,10 +11,6 @@
#include <osgDB/Registry> #include <osgDB/Registry>
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgUtil/Optimizer> #include <osgUtil/Optimizer>
#include <osgSim/LightPointNode> #include <osgSim/LightPointNode>
@ -119,7 +115,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.
@ -148,7 +144,6 @@ int main( int argc, char **argv )
return 1; return 1;
} }
osg::Group* rootnode = new osg::Group; osg::Group* rootnode = new osg::Group;
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.

View File

@ -407,7 +407,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("ps","Render the Professional Services logo"); arguments.getApplicationUsage()->addCommandLineOption("ps","Render the Professional Services logo");

View File

@ -22,7 +22,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.
@ -51,6 +51,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(arguments); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) if (!rootnode)

View File

@ -283,7 +283,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("-c","Mannually create occluders"); arguments.getApplicationUsage()->addCommandLineOption("-c","Mannually create occluders");

View File

@ -348,7 +348,7 @@ int main(int argc, char **argv)
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] image_file_left_eye image_file_right_eye"); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] image_file_left_eye image_file_right_eye");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");

View File

@ -585,7 +585,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
@ -615,6 +615,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(arguments); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);

View File

@ -369,7 +369,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.
@ -398,6 +398,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(arguments); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);

View File

@ -325,7 +325,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
@ -355,6 +355,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// read the scene from the list of file specified commandline args. // read the scene from the list of file specified commandline args.
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments); osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
@ -362,7 +368,7 @@ int main( int argc, char **argv )
// if no model has been successfully loaded report failure. // if no model has been successfully loaded report failure.
if (!loadedModel) if (!loadedModel)
{ {
std::cout << arguments.getProgramName() <<": No data loaded" << std::endl; std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
return 1; return 1;
} }

View File

@ -20,7 +20,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.
@ -49,6 +49,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(arguments); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel) if (!loadedModel)

View File

@ -96,7 +96,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.
@ -125,6 +125,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// assumes any remaining parameters are models // assumes any remaining parameters are models
std::vector<osg::Node*> model; std::vector<osg::Node*> model;
for (int i = 1; i < arguments.argc(); i++) for (int i = 1; i < arguments.argc(); i++)

View File

@ -171,7 +171,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.
@ -200,6 +200,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* model = createModel(); osg::Node* model = createModel();
if (!model) if (!model)

View File

@ -86,7 +86,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.

View File

@ -395,7 +395,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] image_file_left_eye image_file_right_eye"); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] image_file_left_eye image_file_right_eye");
arguments.getApplicationUsage()->addCommandLineOption("-d <float>","Time delay in sceonds between the display of successive image pairs when in auto advance mode."); arguments.getApplicationUsage()->addCommandLineOption("-d <float>","Time delay in sceonds between the display of successive image pairs when in auto advance mode.");
arguments.getApplicationUsage()->addCommandLineOption("-a","Enter auto advance of image pairs on start up."); arguments.getApplicationUsage()->addCommandLineOption("-a","Enter auto advance of image pairs on start up.");
arguments.getApplicationUsage()->addCommandLineOption("-x <float>","Horizontal offset of left and right images."); arguments.getApplicationUsage()->addCommandLineOption("-x <float>","Horizontal offset of left and right images.");
@ -447,6 +447,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// extract the filenames from the arguments list. // extract the filenames from the arguments list.
FileList fileList; FileList fileList;
for(int pos=1;pos<arguments.argc();++pos) for(int pos=1;pos<arguments.argc();++pos)

View File

@ -319,7 +319,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.

View File

@ -430,7 +430,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] [filename] ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] [filename] ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");

View File

@ -144,7 +144,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.
@ -173,6 +173,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// load the images specified on command line // load the images specified on command line
osg::Node* loadedModel = osgDB::readNodeFiles(arguments); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);

View File

@ -687,7 +687,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.

View File

@ -218,7 +218,7 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");

View File

@ -7,7 +7,7 @@ int main( int argc, char** argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options]"); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options]");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("qt","Display qualified tests."); arguments.getApplicationUsage()->addCommandLineOption("qt","Display qualified tests.");
@ -33,6 +33,12 @@ int main( int argc, char** argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
if (printQualifiedTest) if (printQualifiedTest)
{ {

View File

@ -345,7 +345,7 @@ int main(int argc, char *argv[])
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer. // construct the viewer.

View File

@ -20,9 +20,9 @@ int main( int argc, char **argv )
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program. // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setApplicatonName(arguments.getProgramName()); arguments.getApplicationUsage()->setApplicatonName(arguments.getApplicationName());
arguments.getApplicationUsage()->setDescription(arguments.getProgramName()+" is the standard OpenSceneGraph example which loads and visualises 3d models."); arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models.");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
@ -52,6 +52,11 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// read the scene from the list of file specified commandline args. // read the scene from the list of file specified commandline args.
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments); osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
@ -59,7 +64,7 @@ int main( int argc, char **argv )
// if no model has been successfully loaded report failure. // if no model has been successfully loaded report failure.
if (!loadedModel) if (!loadedModel)
{ {
std::cout << arguments.getProgramName() <<": No data loaded" << std::endl; std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
return 1; return 1;
} }

View File

@ -43,9 +43,9 @@ class SG_EXPORT ApplicationUsage
enum Type enum Type
{ {
COMMAND_LINE_OPTION, COMMAND_LINE_OPTION = 0x1,
ENVIRONMENTAL_VARIABLE, ENVIRONMENTAL_VARIABLE = 0x2,
KEYBOARD_MOUSE_BINDING KEYBOARD_MOUSE_BINDING = 0x4
}; };
void addUsageExplanation(Type type,const std::string& option,const std::string& explanation); void addUsageExplanation(Type type,const std::string& option,const std::string& explanation);
@ -74,7 +74,7 @@ class SG_EXPORT ApplicationUsage
void write(std::ostream& output,const UsageMap& um,unsigned int widthOfOutput=80); void write(std::ostream& output,const UsageMap& um,unsigned int widthOfOutput=80);
void write(std::ostream& output,unsigned int widthOfOutput=80); void write(std::ostream& output,unsigned int type=COMMAND_LINE_OPTION|ENVIRONMENTAL_VARIABLE|KEYBOARD_MOUSE_BINDING, unsigned int widthOfOutput=80);
protected: protected:

View File

@ -46,8 +46,8 @@ class SG_EXPORT ArgumentParser
/** return const char* argument at specificed position.*/ /** return const char* argument at specificed position.*/
const char* operator [] (int pos) const { return _argv[pos]; } const char* operator [] (int pos) const { return _argv[pos]; }
/** return the program name, as specified by argv[0] */ /** return the application name, as specified by argv[0] */
std::string getProgramName() const; std::string getApplicationName() const;
/** return the position of an occurance of a string in the argument list. /** return the position of an occurance of a string in the argument list.
* return -1 when no string is found.*/ * return -1 when no string is found.*/

View File

@ -145,12 +145,12 @@ void ApplicationUsage::write(std::ostream& output, const ApplicationUsage::Usage
output << str << std::endl; output << str << std::endl;
} }
void ApplicationUsage::write(std::ostream& output,unsigned int widthOfOutput) void ApplicationUsage::write(std::ostream& output, unsigned int type, unsigned int widthOfOutput)
{ {
output << "Usage: "<<getCommandLineUsage()<<std::endl; output << "Usage: "<<getCommandLineUsage()<<std::endl;
bool needspace = false; bool needspace = false;
if (!getCommandLineOptions().empty()) if ((type&COMMAND_LINE_OPTION) && !getCommandLineOptions().empty())
{ {
if (needspace) output << std::endl; if (needspace) output << std::endl;
output << "Options:"<<std::endl; output << "Options:"<<std::endl;
@ -158,7 +158,7 @@ void ApplicationUsage::write(std::ostream& output,unsigned int widthOfOutput)
needspace = true; needspace = true;
} }
if (!getEnvironmentalVariables().empty()) if ((type&ENVIRONMENTAL_VARIABLE) && !getEnvironmentalVariables().empty())
{ {
if (needspace) output << std::endl; if (needspace) output << std::endl;
output << "Environmental Variables:"<<std::endl; output << "Environmental Variables:"<<std::endl;
@ -166,7 +166,7 @@ void ApplicationUsage::write(std::ostream& output,unsigned int widthOfOutput)
needspace = true; needspace = true;
} }
if (!getKeyboardMouseBindings().empty()) if ((type&KEYBOARD_MOUSE_BINDING) && !getKeyboardMouseBindings().empty())
{ {
if (needspace) output << std::endl; if (needspace) output << std::endl;
output << "Keyboard and Mouse Bindings:"<<std::endl; output << "Keyboard and Mouse Bindings:"<<std::endl;

View File

@ -14,7 +14,7 @@ ArgumentParser::ArgumentParser(int* argc,char **argv):
{ {
} }
std::string ArgumentParser::getProgramName() const std::string ArgumentParser::getApplicationName() const
{ {
if (_argc>0) return std::string(_argv[0]); if (_argc>0) return std::string(_argv[0]);
return ""; return "";
@ -314,7 +314,7 @@ void ArgumentParser::reportRemainingOptionsAsUnrecognized(ErrorSeverity severity
// if an option and havn't been previous querried for report as unrecognized. // if an option and havn't been previous querried for report as unrecognized.
if (isOption(pos) && options.find(_argv[pos])==options.end()) if (isOption(pos) && options.find(_argv[pos])==options.end())
{ {
reportError(getProgramName() +": unrceognized option "+_argv[pos],severity); reportError(getApplicationName() +": unrceognized option "+_argv[pos],severity);
} }
} }
} }
@ -326,7 +326,7 @@ void ArgumentParser::writeErrorMessages(std::ostream& output,ErrorSeverity sever
{ {
if (itr->second>=severity) if (itr->second>=severity)
{ {
output<< getProgramName() << ": " << itr->first << std::endl; output<< getApplicationName() << ": " << itr->first << std::endl;
} }
} }
} }