Commit 30eac79d authored by Mark Olesen's avatar Mark Olesen
Browse files

argList gets addNote() static method

- output any notes in the usage
parent dd8f4f65
......@@ -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 <vector> - eg, '(1 0 0)'"
);
argList::addOption
(
"rotate",
"(vectorA vectorB)",
"transform in terms of a rotation between <vectorA> and <vectorB> "
"- 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]);
......
......@@ -43,6 +43,7 @@ Foam::SLList<Foam::string> Foam::argList::validArgs;
Foam::HashTable<Foam::string> Foam::argList::validOptions;
Foam::HashTable<Foam::string> Foam::argList::validParOptions;
Foam::HashTable<Foam::string> Foam::argList::optionUsage;
Foam::SLList<Foam::string> 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<string>::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<string>::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"
......
......@@ -153,7 +153,10 @@ public:
//- Short usage information for validOptions
static HashTable<string> optionUsage;
//- Min offset for displaying usage (default: 16)
//- Additional notes for usage
static SLList<string> 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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment