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

0028646: Draw Harness, ViewerTest - rename vsetfilter command with vselfilter

TopAbs::ShapeTypeToString() is now used instead of duplicating TopAbs_ShapeEnum printing code.
vselmode now accepts shape type string for activating standard AIS_Shape selection modes.
This commit is contained in:
kgv
2017-05-16 16:37:18 +03:00
committed by abv
parent c9776c7ac0
commit d2e6068829
17 changed files with 198 additions and 505 deletions

View File

@@ -14,10 +14,62 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// Modified by model, Thu Jun 25 10:40:27 1992
#include <TopAbs.hxx>
#include <TCollection_AsciiString.hxx>
namespace
{
static Standard_CString TopAbs_Table_PrintShapeEnum[9] =
{
"COMPOUND","COMPSOLID","SOLID","SHELL","FACE","WIRE","EDGE","VERTEX","SHAPE"
};
static Standard_CString TopAbs_Table_PrintOrientation[4] =
{
"FORWARD","REVERSED","INTERNAL","EXTERNAL"
};
}
//=======================================================================
//function : ShapeTypeToString
//purpose :
//=======================================================================
Standard_CString TopAbs::ShapeTypeToString (TopAbs_ShapeEnum theType)
{
return TopAbs_Table_PrintShapeEnum[theType];
}
//=======================================================================
//function : ShapeTypeFromString
//purpose :
//=======================================================================
Standard_Boolean TopAbs::ShapeTypeFromString (Standard_CString theTypeString,
TopAbs_ShapeEnum& theType)
{
TCollection_AsciiString aName (theTypeString);
aName.UpperCase();
for (Standard_Integer aTypeIter = 0; aTypeIter <= TopAbs_SHAPE; ++aTypeIter)
{
Standard_CString aTypeName = TopAbs_Table_PrintShapeEnum[aTypeIter];
if (aName == aTypeName)
{
theType = TopAbs_ShapeEnum(aTypeIter);
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : ShapeOrientationToString
//purpose :
//=======================================================================
Standard_CString TopAbs::ShapeOrientationToString (TopAbs_Orientation theOrientation)
{
return TopAbs_Table_PrintOrientation[theOrientation];
}
//=======================================================================
//function : TopAbs_Compose
//purpose : Compose two orientations
@@ -64,36 +116,6 @@ TopAbs_Orientation TopAbs::Complement(const TopAbs_Orientation Ori)
return TopAbs_Table_Complement[(Standard_Integer)Ori];
}
//=======================================================================
//function : TopAbs_Print
//purpose : print the name of a ShapeEnum on a stream.
//=======================================================================
Standard_OStream& TopAbs::Print(const TopAbs_ShapeEnum se,
Standard_OStream& s)
{
static const Standard_CString TopAbs_Table_PrintShapeEnum[9] =
{
"COMPOUND","COMPSOLID","SOLID","SHELL","FACE","WIRE","EDGE","VERTEX","SHAPE"
};
return (s << TopAbs_Table_PrintShapeEnum[(Standard_Integer)se]);
}
//=======================================================================
//function : TopAbs_Print
//purpose : print the name of an Orientation on a stream
//=======================================================================
Standard_OStream& TopAbs::Print(const TopAbs_Orientation ori,
Standard_OStream& s)
{
static const Standard_CString TopAbs_Table_PrintOrientation[4] =
{
"FORWARD","REVERSED","INTERNAL","EXTERNAL"
};
return (s << TopAbs_Table_PrintOrientation[(Standard_Integer)ori]);
}
//=======================================================================
//function : TopAbs_Print
//purpose : print the name of a State on a stream.

View File

@@ -98,39 +98,49 @@ public:
//! becomes outside.
Standard_EXPORT static TopAbs_Orientation Complement (const TopAbs_Orientation Or);
//! Prints the name of Shape <SEq> as a String on the
//! Stream <S> and returns <S>.
Standard_EXPORT static Standard_OStream& Print (const TopAbs_ShapeEnum SE, Standard_OStream& S);
//! Prints the name of Shape type as a String on the Stream.
static Standard_OStream& Print (const TopAbs_ShapeEnum theShapeType, Standard_OStream& theStream)
{
return (theStream << ShapeTypeToString (theShapeType));
}
//! Prints the name of the Orientation <Or> as a String on
//! the Stream <S> and returns <S>.
Standard_EXPORT static Standard_OStream& Print (const TopAbs_Orientation Or, Standard_OStream& S);
//! Prints the name of the Orientation as a String on the Stream.
static Standard_OStream& Print (const TopAbs_Orientation theOrientation, Standard_OStream& theStream)
{
return (theStream << ShapeOrientationToString (theOrientation));
}
//! Prints the name of the State <St> as a String on
//! the Stream <S> and returns <S>.
Standard_EXPORT static Standard_OStream& Print (const TopAbs_State St, Standard_OStream& S);
//! Returns the string name for a given shape type.
//! @param theType shape type
//! @return string identifier from the list COMPOUND, COMPSOLID, SOLID, SHELL, FACE, WIRE, EDGE, VERTEX, SHAPE
Standard_EXPORT static Standard_CString ShapeTypeToString (TopAbs_ShapeEnum theType);
//! Returns the shape type from the given string identifier (using case-insensitive comparison).
//! @param theTypeString string identifier
//! @return shape type or TopAbs_SHAPE if string identifier is invalid
static TopAbs_ShapeEnum ShapeTypeFromString (Standard_CString theTypeString)
{
TopAbs_ShapeEnum aType = TopAbs_SHAPE;
ShapeTypeFromString (theTypeString, aType);
return aType;
}
//! Determines the shape type from the given string identifier (using case-insensitive comparison).
//! @param theTypeString string identifier
//! @param theType detected shape type
//! @return TRUE if string identifier is known
Standard_EXPORT static Standard_Boolean ShapeTypeFromString (Standard_CString theTypeString,
TopAbs_ShapeEnum& theType);
protected:
private:
//! Returns the string name for a given shape orientation.
//! @param theOrientation shape orientation
//! @return string identifier from the list FORWARD, REVERSED, INTERNAL, EXTERNAL
Standard_EXPORT static Standard_CString ShapeOrientationToString (TopAbs_Orientation theOrientation);
};
#endif // _TopAbs_HeaderFile