From 30eac79d5551483cde101a4bdd3b2192566f9367 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 9 Dec 2009 10:58:32 +0100 Subject: [PATCH] argList gets addNote() static method - output any notes in the usage --- .../surfaceTransformPoints.C | 47 +++++++++++++++---- src/OpenFOAM/global/argList/argList.C | 28 ++++++++++- src/OpenFOAM/global/argList/argList.H | 9 +++- 3 files changed, 74 insertions(+), 10 deletions(-) diff --git a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C index 85e3cc1172..8bb87d3ee9 100644 --- a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C +++ b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C @@ -23,8 +23,8 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description - Transform (scale/rotate) a surface. Like transformPoints but then for - surfaces. + Transform (scale/rotate) a surface. + Like transformPoints but for surfaces. The rollPitchYaw option takes three angles (degrees): - roll (rotation about x) followed by @@ -54,16 +54,47 @@ using namespace Foam::constant::mathematical; int main(int argc, char *argv[]) { + argList::addNote + ( + "Transform (scale/rotate) a surface. " + "Like transformPoints but for surfaces." + ); argList::noParallel(); argList::validArgs.clear(); - argList::validArgs.append("surface file"); argList::validArgs.append("output surface file"); - argList::addOption("translate", "vector"); - argList::addOption("rotate", "(vector vector)"); - argList::addOption("scale", "vector"); - argList::addOption("rollPitchYaw", "(roll pitch yaw)"); - argList::addOption("yawPitchRoll", "(yaw pitch roll)"); + argList::addOption + ( + "translate", + "vector", + "translate by the specified - eg, '(1 0 0)'" + ); + argList::addOption + ( + "rotate", + "(vectorA vectorB)", + "transform in terms of a rotation between and " + "- eg, '( (1 0 0) (0 0 1) )'" + ); + argList::addOption + ( + "scale", + "vector", + "scale by the specified amount - eg, '(0.001 0.001 0.001)' for a " + "uniform [mm] to [m] scaling" + ); + argList::addOption + ( + "rollPitchYaw", + "vector", + "transform in terms of '( roll pitch yaw )' in degrees" + ); + argList::addOption + ( + "yawPitchRoll", + "vector", + "transform in terms of '( yaw pitch roll )' in degrees" + ); argList args(argc, argv); fileName surfFileName(args.additionalArgs()[0]); diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index cd2de41fa9..f574fde3e6 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -43,6 +43,7 @@ Foam::SLList Foam::argList::validArgs; Foam::HashTable Foam::argList::validOptions; Foam::HashTable Foam::argList::validParOptions; Foam::HashTable Foam::argList::optionUsage; +Foam::SLList Foam::argList::notes; Foam::string::size_type Foam::argList::usageMin = 20; Foam::string::size_type Foam::argList::usageMax = 80; @@ -108,6 +109,15 @@ void Foam::argList::addUsage } +void Foam::argList::addNote(const string& note) +{ + if (!note.empty()) + { + notes.append(note); + } +} + + void Foam::argList::removeOption(const word& opt) { validOptions.erase(opt); @@ -765,7 +775,7 @@ void Foam::argList::printUsage() const HashTable::const_iterator iter = validOptions.find(optionName); Info<< " -" << optionName; - label len = optionName.size() + 3; // include leading " -" + label len = optionName.size() + 3; // length includes leading ' -' if (iter().size()) { @@ -815,6 +825,22 @@ void Foam::argList::printUsage() const "print the usage" ); + + // output notes directly - no automatic text wrapping + if (!notes.empty()) + { + Info<< nl; + for + ( + SLList::const_iterator iter = notes.begin(); + iter != notes.end(); + ++iter + ) + { + Info<< iter().c_str() << nl; + } + } + Info<< nl <<"Using OpenFOAM-" << Foam::FOAMversion <<" (build: " << Foam::FOAMbuild << ") - see www.OpenFOAM.org" diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index b1efcb0669..da75c4d066 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -153,7 +153,10 @@ public: //- Short usage information for validOptions static HashTable optionUsage; - //- Min offset for displaying usage (default: 16) + //- Additional notes for usage + static SLList notes; + + //- Min offset for displaying usage (default: 20) static string::size_type usageMin; //- Max screen width for displaying usage (default: 80) @@ -287,6 +290,10 @@ public: const string& usage ); + //- Add extra notes for the usage information + // This string is used "as-is" without additional formatting + static void addNote(const string&); + //- Remove option from validOptions and from optionUsage static void removeOption(const word& opt);