diff --git a/Make/makedirdefs b/Make/makedirdefs index 5e114efc1..90412aa85 100644 --- a/Make/makedirdefs +++ b/Make/makedirdefs @@ -123,5 +123,7 @@ EXAMPLE_DIRS = \ osgvertexprogram\ osgviewer\ +# osgjigsaw\ + # comment in you want to compile the cluster demo. EXAMPLE_DIRS += osgcluster diff --git a/examples/osganimate/osganimate.cpp b/examples/osganimate/osganimate.cpp index b18b56072..8996c6c13 100644 --- a/examples/osganimate/osganimate.cpp +++ b/examples/osganimate/osganimate.cpp @@ -193,7 +193,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // initialize the viewer. @@ -221,7 +221,7 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); return 1; } - + // load the nodes from the commandline arguments. osg::Node* model = createModel(); if (!model) diff --git a/examples/osgbillboard/osgbillboard.cpp b/examples/osgbillboard/osgbillboard.cpp index 55f72b2f6..5191e6c9a 100644 --- a/examples/osgbillboard/osgbillboard.cpp +++ b/examples/osgbillboard/osgbillboard.cpp @@ -168,7 +168,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // initialize the viewer. @@ -196,7 +196,7 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); return 1; } - + // create a model from the images. osg::Node* rootNode = createModel(); diff --git a/examples/osgcallback/osgcallback.cpp b/examples/osgcallback/osgcallback.cpp index d42e8bbf7..7adc6845e 100644 --- a/examples/osgcallback/osgcallback.cpp +++ b/examples/osgcallback/osgcallback.cpp @@ -132,7 +132,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // initialize the viewer. @@ -160,6 +160,12 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); 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. osg::Node* rootnode = osgDB::readNodeFiles(arguments); diff --git a/examples/osgclip/osgclip.cpp b/examples/osgclip/osgclip.cpp index 02761597a..c8d5055cd 100644 --- a/examples/osgclip/osgclip.cpp +++ b/examples/osgclip/osgclip.cpp @@ -131,7 +131,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // initialize the viewer. @@ -159,6 +159,12 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); 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. osg::Node* loadedModel = osgDB::readNodeFiles(arguments); diff --git a/examples/osgcluster/osgcluster.cpp b/examples/osgcluster/osgcluster.cpp index 7dba97fbd..8ea8280ba 100644 --- a/examples/osgcluster/osgcluster.cpp +++ b/examples/osgcluster/osgcluster.cpp @@ -99,7 +99,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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("-m","Set viewer to MASTER mode, sending 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; } + if (arguments.argc()<=1) + { + arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); + return 1; + } + // load model. osg::ref_ptr rootnode = osgDB::readNodeFiles(arguments); diff --git a/examples/osgcopy/osgcopy.cpp b/examples/osgcopy/osgcopy.cpp index be16a727b..1dcecd2cd 100644 --- a/examples/osgcopy/osgcopy.cpp +++ b/examples/osgcopy/osgcopy.cpp @@ -133,7 +133,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // initialize the viewer. @@ -155,6 +155,12 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); 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. osg::Node* rootnode = osgDB::readNodeFiles(arguments); diff --git a/examples/osgcubemap/osgcubemap.cpp b/examples/osgcubemap/osgcubemap.cpp index 4828916eb..891ba0d3c 100644 --- a/examples/osgcubemap/osgcubemap.cpp +++ b/examples/osgcubemap/osgcubemap.cpp @@ -74,7 +74,7 @@ int main(int argc, char *argv[]) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. @@ -102,6 +102,12 @@ int main(int argc, char *argv[]) arguments.writeErrorMessages(std::cout); 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. osg::Node* rootnode = osgDB::readNodeFiles(arguments); diff --git a/examples/osggeodemo/osggeodemo.cpp b/examples/osggeodemo/osggeodemo.cpp index 4b1cd4447..14eaa9b18 100644 --- a/examples/osggeodemo/osggeodemo.cpp +++ b/examples/osggeodemo/osggeodemo.cpp @@ -89,7 +89,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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("--fov ","Set the Field of View"); @@ -121,6 +121,12 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); 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. diff --git a/examples/osggeometry/osggeometry.cpp b/examples/osggeometry/osggeometry.cpp index 8e8ef614f..6a322a0b9 100644 --- a/examples/osggeometry/osggeometry.cpp +++ b/examples/osggeometry/osggeometry.cpp @@ -646,7 +646,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. @@ -674,7 +674,7 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); return 1; } - + // create the model osg::Group* root = new osg::Group; diff --git a/examples/osghangglide/osghangglide.cpp b/examples/osghangglide/osghangglide.cpp index dcf8e9e7e..255011a62 100644 --- a/examples/osghangglide/osghangglide.cpp +++ b/examples/osghangglide/osghangglide.cpp @@ -108,7 +108,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. @@ -139,7 +139,7 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); return 1; } - + // load the nodes from the commandline arguments. osg::Node* rootnode = osgDB::readNodeFiles(arguments); if (!rootnode) rootnode = createModel(); diff --git a/examples/osghud/osghud.cpp b/examples/osghud/osghud.cpp index b522bfcf1..447e8bda3 100644 --- a/examples/osghud/osghud.cpp +++ b/examples/osghud/osghud.cpp @@ -117,7 +117,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); @@ -146,8 +146,7 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); return 1; } - - + // read the scene from the list of file specified commandline args. osg::ref_ptr scene = osgDB::readNodeFiles(arguments); diff --git a/examples/osgimpostor/osgimpostor.cpp b/examples/osgimpostor/osgimpostor.cpp index b628ae93b..a86e2e64b 100644 --- a/examples/osgimpostor/osgimpostor.cpp +++ b/examples/osgimpostor/osgimpostor.cpp @@ -219,7 +219,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. @@ -253,7 +253,6 @@ int main( int argc, char **argv ) } - // load the nodes from the commandline arguments. osg::Node* model = osgDB::readNodeFiles(arguments); if (model) diff --git a/examples/osgkeyboard/osgkeyboard.cpp b/examples/osgkeyboard/osgkeyboard.cpp index 23010a147..b8325407f 100644 --- a/examples/osgkeyboard/osgkeyboard.cpp +++ b/examples/osgkeyboard/osgkeyboard.cpp @@ -381,7 +381,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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("-c","Mannually create occluders"); @@ -416,7 +416,6 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); return 1; } - // attach the scene graph. viewer.setSceneData( keyboardModel->getScene() ); diff --git a/examples/osglight/osglight.cpp b/examples/osglight/osglight.cpp index e01657f1b..91bf10da3 100644 --- a/examples/osglight/osglight.cpp +++ b/examples/osglight/osglight.cpp @@ -303,7 +303,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. @@ -332,7 +332,6 @@ int main( int argc, char **argv ) return 1; } - // load the nodes from the commandline arguments. osg::Node* loadedModel = osgDB::readNodeFiles(arguments); diff --git a/examples/osglightpoint/osglightpoint.cpp b/examples/osglightpoint/osglightpoint.cpp index 48762a544..65e5599c8 100644 --- a/examples/osglightpoint/osglightpoint.cpp +++ b/examples/osglightpoint/osglightpoint.cpp @@ -11,10 +11,6 @@ #include #include -#include -#include -#include - #include #include @@ -119,7 +115,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. @@ -147,8 +143,7 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); return 1; } - - + osg::Group* rootnode = new osg::Group; // load the nodes from the commandline arguments. diff --git a/examples/osglogo/osglogo.cpp b/examples/osglogo/osglogo.cpp index 14acce987..24c0989bd 100644 --- a/examples/osglogo/osglogo.cpp +++ b/examples/osglogo/osglogo.cpp @@ -407,7 +407,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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("ps","Render the Professional Services logo"); @@ -438,7 +438,7 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); return 1; } - + osg::Node* node = createLogo(); // add model to viewer. diff --git a/examples/osgmultitexture/osgmultitexture.cpp b/examples/osgmultitexture/osgmultitexture.cpp index c8a4c2955..0b4b8c0e8 100644 --- a/examples/osgmultitexture/osgmultitexture.cpp +++ b/examples/osgmultitexture/osgmultitexture.cpp @@ -22,7 +22,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. @@ -50,6 +50,12 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); 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. osg::Node* rootnode = osgDB::readNodeFiles(arguments); diff --git a/examples/osgoccluder/osgoccluder.cpp b/examples/osgoccluder/osgoccluder.cpp index bdf0a4ec7..96bc52239 100644 --- a/examples/osgoccluder/osgoccluder.cpp +++ b/examples/osgoccluder/osgoccluder.cpp @@ -283,7 +283,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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("-c","Mannually create occluders"); diff --git a/examples/osgparticle/osgparticle.cpp b/examples/osgparticle/osgparticle.cpp index 211ccab59..e778c9c0f 100644 --- a/examples/osgparticle/osgparticle.cpp +++ b/examples/osgparticle/osgparticle.cpp @@ -348,7 +348,7 @@ int main(int argc, char **argv) osg::ArgumentParser arguments(&argc,argv); // 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"); @@ -377,7 +377,7 @@ int main(int argc, char **argv) arguments.writeErrorMessages(std::cout); return 1; } - + osg::Group *root = new osg::Group; build_world(root); diff --git a/examples/osgpbuffer/osgpbuffer.cpp b/examples/osgpbuffer/osgpbuffer.cpp index ea091e198..11e001f8b 100644 --- a/examples/osgpbuffer/osgpbuffer.cpp +++ b/examples/osgpbuffer/osgpbuffer.cpp @@ -585,7 +585,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); @@ -615,6 +615,12 @@ int main( int argc, char **argv ) 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. osg::Node* loadedModel = osgDB::readNodeFiles(arguments); diff --git a/examples/osgprerender/osgprerender.cpp b/examples/osgprerender/osgprerender.cpp index 1f7e8a267..7485bdfe4 100644 --- a/examples/osgprerender/osgprerender.cpp +++ b/examples/osgprerender/osgprerender.cpp @@ -369,7 +369,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. @@ -397,6 +397,12 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); 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. diff --git a/examples/osgreflect/osgreflect.cpp b/examples/osgreflect/osgreflect.cpp index 012543e98..559f1ea9a 100644 --- a/examples/osgreflect/osgreflect.cpp +++ b/examples/osgreflect/osgreflect.cpp @@ -325,7 +325,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); @@ -354,6 +354,12 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); 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. @@ -362,7 +368,7 @@ int main( int argc, char **argv ) // if no model has been successfully loaded report failure. if (!loadedModel) { - std::cout << arguments.getProgramName() <<": No data loaded" << std::endl; + std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl; return 1; } diff --git a/examples/osgscribe/osgscribe.cpp b/examples/osgscribe/osgscribe.cpp index 56371ed5c..23ac6d2e9 100644 --- a/examples/osgscribe/osgscribe.cpp +++ b/examples/osgscribe/osgscribe.cpp @@ -20,7 +20,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. @@ -48,6 +48,12 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); 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. osg::Node* loadedModel = osgDB::readNodeFiles(arguments); diff --git a/examples/osgsequence/osgsequence.cpp b/examples/osgsequence/osgsequence.cpp index a2a82c0b5..46653d6c8 100644 --- a/examples/osgsequence/osgsequence.cpp +++ b/examples/osgsequence/osgsequence.cpp @@ -96,7 +96,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. @@ -125,6 +125,12 @@ int main( int argc, char **argv ) return 1; } + if (arguments.argc()<=1) + { + arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); + return 1; + } + // assumes any remaining parameters are models std::vector model; for (int i = 1; i < arguments.argc(); i++) diff --git a/examples/osgshadowtexture/osgshadowtexture.cpp b/examples/osgshadowtexture/osgshadowtexture.cpp index 206cee36e..5380330e9 100644 --- a/examples/osgshadowtexture/osgshadowtexture.cpp +++ b/examples/osgshadowtexture/osgshadowtexture.cpp @@ -171,7 +171,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. @@ -199,6 +199,12 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); 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. osg::Node* model = createModel(); diff --git a/examples/osgshape/osgshape.cpp b/examples/osgshape/osgshape.cpp index 3d7245817..3d8e5d5ff 100644 --- a/examples/osgshape/osgshape.cpp +++ b/examples/osgshape/osgshape.cpp @@ -86,7 +86,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. diff --git a/examples/osgstereoimage/osgstereoimage.cpp b/examples/osgstereoimage/osgstereoimage.cpp index e0ad29524..9f0ceec15 100644 --- a/examples/osgstereoimage/osgstereoimage.cpp +++ b/examples/osgstereoimage/osgstereoimage.cpp @@ -395,7 +395,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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 ","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("-x ","Horizontal offset of left and right images."); @@ -446,6 +446,12 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); 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. FileList fileList; diff --git a/examples/osgteapot/osgteapot.cpp b/examples/osgteapot/osgteapot.cpp index 33f1404b2..a302cbed7 100644 --- a/examples/osgteapot/osgteapot.cpp +++ b/examples/osgteapot/osgteapot.cpp @@ -319,7 +319,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. diff --git a/examples/osgtext/osgtext.cpp b/examples/osgtext/osgtext.cpp index 9ee5e7a9a..581e3adcb 100644 --- a/examples/osgtext/osgtext.cpp +++ b/examples/osgtext/osgtext.cpp @@ -430,7 +430,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); @@ -459,7 +459,7 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); return 1; } - + // read the scene from the list of file specified commandline args. osg::ref_ptr rootNode = osgDB::readNodeFiles(arguments); diff --git a/examples/osgtexture1D/osgtexture1D.cpp b/examples/osgtexture1D/osgtexture1D.cpp index d89131e3f..60fccfb24 100644 --- a/examples/osgtexture1D/osgtexture1D.cpp +++ b/examples/osgtexture1D/osgtexture1D.cpp @@ -144,7 +144,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. @@ -172,6 +172,12 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); 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 osg::Node* loadedModel = osgDB::readNodeFiles(arguments); diff --git a/examples/osgtexture2D/osgtexture2D.cpp b/examples/osgtexture2D/osgtexture2D.cpp index f3a821869..f572d3477 100644 --- a/examples/osgtexture2D/osgtexture2D.cpp +++ b/examples/osgtexture2D/osgtexture2D.cpp @@ -687,7 +687,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. diff --git a/examples/osgtexture3D/osgtexture3D.cpp b/examples/osgtexture3D/osgtexture3D.cpp index d9315fd12..5f7dc94e2 100644 --- a/examples/osgtexture3D/osgtexture3D.cpp +++ b/examples/osgtexture3D/osgtexture3D.cpp @@ -218,7 +218,7 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // 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"); @@ -247,7 +247,7 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); return 1; } - + // create a model from the images. osg::Node* rootNode = createModel(); diff --git a/examples/osgunittests/osgunittests.cpp b/examples/osgunittests/osgunittests.cpp index c67e55e45..b12d7618d 100644 --- a/examples/osgunittests/osgunittests.cpp +++ b/examples/osgunittests/osgunittests.cpp @@ -7,7 +7,7 @@ int main( int argc, char** argv ) osg::ArgumentParser arguments(&argc,argv); // 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("qt","Display qualified tests."); @@ -32,6 +32,12 @@ int main( int argc, char** argv ) arguments.writeErrorMessages(std::cout); return 1; } + + if (arguments.argc()<=1) + { + arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); + return 1; + } if (printQualifiedTest) diff --git a/examples/osgvertexprogram/osgvertexprogram.cpp b/examples/osgvertexprogram/osgvertexprogram.cpp index 4f9c9f455..5fd8e9dbb 100644 --- a/examples/osgvertexprogram/osgvertexprogram.cpp +++ b/examples/osgvertexprogram/osgvertexprogram.cpp @@ -345,7 +345,7 @@ int main(int argc, char *argv[]) osg::ArgumentParser arguments(&argc,argv); // 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"); // construct the viewer. diff --git a/examples/osgviewer/osgviewer.cpp b/examples/osgviewer/osgviewer.cpp index 0e7e5badc..524ab582b 100644 --- a/examples/osgviewer/osgviewer.cpp +++ b/examples/osgviewer/osgviewer.cpp @@ -20,9 +20,9 @@ int main( int argc, char **argv ) osg::ArgumentParser arguments(&argc,argv); // set up the usage document, in case we need to print out how to use this program. - arguments.getApplicationUsage()->setApplicatonName(arguments.getProgramName()); - arguments.getApplicationUsage()->setDescription(arguments.getProgramName()+" is the standard OpenSceneGraph example which loads and visualises 3d models."); - arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ..."); + arguments.getApplicationUsage()->setApplicatonName(arguments.getApplicationName()); + arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models."); + arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); @@ -51,7 +51,12 @@ int main( int argc, char **argv ) arguments.writeErrorMessages(std::cout); 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. osg::ref_ptr loadedModel = osgDB::readNodeFiles(arguments); @@ -59,7 +64,7 @@ int main( int argc, char **argv ) // if no model has been successfully loaded report failure. if (!loadedModel) { - std::cout << arguments.getProgramName() <<": No data loaded" << std::endl; + std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl; return 1; } diff --git a/include/osg/ApplicationUsage b/include/osg/ApplicationUsage index 1257b860f..2bf232ae9 100644 --- a/include/osg/ApplicationUsage +++ b/include/osg/ApplicationUsage @@ -43,9 +43,9 @@ class SG_EXPORT ApplicationUsage enum Type { - COMMAND_LINE_OPTION, - ENVIRONMENTAL_VARIABLE, - KEYBOARD_MOUSE_BINDING + COMMAND_LINE_OPTION = 0x1, + ENVIRONMENTAL_VARIABLE = 0x2, + KEYBOARD_MOUSE_BINDING = 0x4 }; 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,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: diff --git a/include/osg/ArgumentParser b/include/osg/ArgumentParser index d233ef96d..96692fad4 100644 --- a/include/osg/ArgumentParser +++ b/include/osg/ArgumentParser @@ -46,8 +46,8 @@ class SG_EXPORT ArgumentParser /** return const char* argument at specificed position.*/ const char* operator [] (int pos) const { return _argv[pos]; } - /** return the program name, as specified by argv[0] */ - std::string getProgramName() const; + /** return the application name, as specified by argv[0] */ + std::string getApplicationName() const; /** return the position of an occurance of a string in the argument list. * return -1 when no string is found.*/ diff --git a/src/osg/ApplicationUsage.cpp b/src/osg/ApplicationUsage.cpp index df6800d38..1d7255b2d 100644 --- a/src/osg/ApplicationUsage.cpp +++ b/src/osg/ApplicationUsage.cpp @@ -145,12 +145,12 @@ void ApplicationUsage::write(std::ostream& output, const ApplicationUsage::Usage 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: "<0) return std::string(_argv[0]); return ""; @@ -314,7 +314,7 @@ void ArgumentParser::reportRemainingOptionsAsUnrecognized(ErrorSeverity severity // if an option and havn't been previous querried for report as unrecognized. 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) { - output<< getProgramName() << ": " << itr->first << std::endl; + output<< getApplicationName() << ": " << itr->first << std::endl; } } }