1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0032055: Draw Harness, ViewerTest - add more vmanipulator position adjusting options

Draw::ParseOnOffIterator() - added auxiliary wrapper over Draw::ParseOnOff() for more compact syntax.
strncasecmp() definition for msvc compilers has been moved to Standard_CString for consistency with strcasecmp().
vmanipulator command has been refactored to use more straightforward parser.

vmanipulator now accepts "-adjustPosition {0|center|location|shapeLocation}" options
adjusting position to object's AABB center (existed before), object's local transformation or TopoDS_Shape location.
This commit is contained in:
kgv
2021-01-13 21:22:00 +03:00
committed by bugmaster
parent 607f045954
commit ff6122e008
6 changed files with 533 additions and 248 deletions

View File

@@ -958,3 +958,34 @@ Standard_Boolean Draw::ParseOnOff (Standard_CString theArg,
}
return Standard_False;
}
//=======================================================================
//function : ParseOnOffIterator
//purpose :
//=======================================================================
Standard_Boolean Draw::ParseOnOffIterator (Standard_Integer theArgsNb,
const char** theArgVec,
Standard_Integer& theArgIter)
{
Standard_Boolean isOn = Standard_True;
if (theArgIter + 1 < theArgsNb
&& Draw::ParseOnOff (theArgVec[theArgIter + 1], isOn))
{
++theArgIter;
}
return isOn;
}
//=======================================================================
//function : ParseOnOffNoIterator
//purpose :
//=======================================================================
Standard_Boolean Draw::ParseOnOffNoIterator (Standard_Integer theArgsNb,
const char** theArgVec,
Standard_Integer& theArgIter)
{
Standard_Boolean toReverse = strncasecmp (theArgVec[theArgIter], "no", 2) == 0
|| strncasecmp (theArgVec[theArgIter], "-no", 3) == 0;
Standard_Boolean isOn = Draw::ParseOnOffIterator (theArgsNb, theArgVec, theArgIter);
return toReverse ? !isOn : isOn;
}

View File

@@ -179,6 +179,39 @@ public: //! @name argument parsing tools
Standard_EXPORT static Standard_Boolean ParseOnOff (Standard_CString theArg,
Standard_Boolean& theIsOn);
//! Parses boolean argument at specified iterator position with optional on/off coming next.
//!
//! Usage code sample for command argument in form "cmd -usefeature [on|off|1|0]=on":
//! @code
//! for (int anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
//! {
//! if (strcasecmp (theArgVec[anArgIter], "-usefeature") == 0)
//! {
//! bool toUseFeature = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
//! // process feature
//! }
//! }
//! @endcode
//!
//! @param theArgsNb [in] overall number of arguments
//! @param theArgVec [in] vector of arguments
//! @param theArgIter [in] [out] argument position to parse
//! @return flag value
Standard_EXPORT static Standard_Boolean ParseOnOffIterator (Standard_Integer theArgsNb,
const char** theArgVec,
Standard_Integer& theArgIter);
//! Parses boolean argument at specified iterator position with optional on/off coming next.
//! Similar to ParseOnOffIterator() but also reverses returned value if argument name starts with "no" prefix.
//! E.g. if nominal argument is "cmd -usefeature [on|off|1|0]=on", then "-nousefeature" argument will return FALSE.
//! @param theArgsNb [in] overall number of arguments
//! @param theArgVec [in] vector of arguments
//! @param theArgIter [in] [out] argument position to parse
//! @return flag value
Standard_EXPORT static Standard_Boolean ParseOnOffNoIterator (Standard_Integer theArgsNb,
const char** theArgVec,
Standard_Integer& theArgIter);
public:
//! Returns last graphic selection description.