Methods ParseOnOff()/ParseColor() have been moved from package ViewerTest to Draw.
Command "vlight -color" now accepts RGB values, not only name.
Implementation of pload command has been cleaned up.
//=================================================================================
//
//=================================================================================
-void Draw::Load(Draw_Interpretor& theDI, const TCollection_AsciiString& theKey,
- const TCollection_AsciiString& theResourceFileName,
- TCollection_AsciiString& theDefaultsDirectory,
- TCollection_AsciiString& theUserDefaultsDirectory,
- const Standard_Boolean Verbose ) {
-
+void Draw::Load (Draw_Interpretor& theDI,
+ const TCollection_AsciiString& theKey,
+ const TCollection_AsciiString& theResourceFileName,
+ const TCollection_AsciiString& theDefaultsDirectory,
+ const TCollection_AsciiString& theUserDefaultsDirectory,
+ const Standard_Boolean theIsVerbose)
+{
static Plugin_MapOfFunctions theMapOfFunctions;
- OSD_Function f;
-
- if(!theMapOfFunctions.IsBound(theKey)) {
-
- Handle(Resource_Manager) aPluginResource = new Resource_Manager(theResourceFileName.ToCString(), theDefaultsDirectory, theUserDefaultsDirectory, Verbose);
-
- if(!aPluginResource->Find(theKey.ToCString())) {
- Standard_SStream aMsg; aMsg << "Could not find the resource:";
- aMsg << theKey.ToCString()<< std::endl;
- std::cout << "could not find the resource:"<<theKey.ToCString()<< std::endl;
- throw Draw_Failure(aMsg.str().c_str());
+ OSD_Function aFunc = NULL;
+ if (!theMapOfFunctions.Find (theKey, aFunc))
+ {
+ TCollection_AsciiString aPluginLibrary;
+ Handle(Resource_Manager) aPluginResource = new Resource_Manager (theResourceFileName, theDefaultsDirectory, theUserDefaultsDirectory, theIsVerbose);
+ if (!aPluginResource->Find (theKey, aPluginLibrary))
+ {
+ Message::SendFail() << "could not find the resource:" << theKey;
+ Standard_SStream aMsg; aMsg << "Could not find the resource:" << theKey << std::endl;
+ throw Draw_Failure (aMsg.str().c_str());
}
- TCollection_AsciiString aPluginLibrary("");
#if !defined(_WIN32) || defined(__MINGW32__)
- aPluginLibrary += "lib";
+ aPluginLibrary = TCollection_AsciiString ("lib") + aPluginLibrary;
#endif
- aPluginLibrary += aPluginResource->Value(theKey.ToCString());
#ifdef _WIN32
aPluginLibrary += ".dll";
#elif __APPLE__
#else
aPluginLibrary += ".so";
#endif
- OSD_SharedLibrary aSharedLibrary(aPluginLibrary.ToCString());
- if(!aSharedLibrary.DlOpen(OSD_RTLD_LAZY)) {
- TCollection_AsciiString error(aSharedLibrary.DlError());
- Standard_SStream aMsg; aMsg << "Could not open: ";
- aMsg << aPluginResource->Value(theKey.ToCString());
- aMsg << "; reason: ";
- aMsg << error.ToCString();
+ OSD_SharedLibrary aSharedLibrary (aPluginLibrary.ToCString());
+ if (!aSharedLibrary.DlOpen (OSD_RTLD_LAZY))
+ {
+ const TCollection_AsciiString anError (aSharedLibrary.DlError());
+ Standard_SStream aMsg;
+ aMsg << "Could not open: " << aPluginLibrary << "; reason: " << anError;
#ifdef OCCT_DEBUG
- std::cout << "could not open: " << aPluginResource->Value(theKey.ToCString())<< " ; reason: "<< error.ToCString() << std::endl;
+ std::cout << "could not open: " << aPluginLibrary << " ; reason: "<< anError << std::endl;
#endif
throw Draw_Failure(aMsg.str().c_str());
}
- f = aSharedLibrary.DlSymb("PLUGINFACTORY");
- if( f == NULL ) {
- TCollection_AsciiString error(aSharedLibrary.DlError());
- Standard_SStream aMsg; aMsg << "Could not find the factory in: ";
- aMsg << aPluginResource->Value(theKey.ToCString());
- aMsg << error.ToCString();
+
+ aFunc = aSharedLibrary.DlSymb ("PLUGINFACTORY");
+ if (aFunc == NULL)
+ {
+ const TCollection_AsciiString anError (aSharedLibrary.DlError());
+ Standard_SStream aMsg;
+ aMsg << "Could not find the factory in: " << aPluginLibrary << anError;
throw Draw_Failure(aMsg.str().c_str());
}
- theMapOfFunctions.Bind(theKey, f);
+ theMapOfFunctions.Bind (theKey, aFunc);
}
- else
- f = theMapOfFunctions(theKey);
-
-// void (*fp) (Draw_Interpretor&, const TCollection_AsciiString&) = NULL;
-// fp = (void (*)(Draw_Interpretor&, const TCollection_AsciiString&)) f;
-// (*fp) (theDI, theKey);
void (*fp) (Draw_Interpretor&) = NULL;
- fp = (void (*)(Draw_Interpretor&)) f;
+ fp = (void (*)(Draw_Interpretor&) )aFunc;
(*fp) (theDI);
+}
+
+namespace
+{
+ const Standard_Integer THE_MAX_INTEGER_COLOR_COMPONENT = 255;
+ const Standard_ShortReal THE_MAX_REAL_COLOR_COMPONENT = 1.0f;
+
+ //! Parses string and get an integer color component (only values within range 0 .. 255 are allowed)
+ //! @param theColorComponentString the string representing the color component
+ //! @param theIntegerColorComponent an integer color component that is a result of parsing
+ //! @return true if parsing was successful, or false otherwise
+ static bool parseNumericalColorComponent (const Standard_CString theColorComponentString,
+ Standard_Integer& theIntegerColorComponent)
+ {
+ Standard_Integer anIntegerColorComponent;
+ if (!Draw::ParseInteger (theColorComponentString, anIntegerColorComponent))
+ {
+ return false;
+ }
+ if ((anIntegerColorComponent < 0) || (anIntegerColorComponent > THE_MAX_INTEGER_COLOR_COMPONENT))
+ {
+ return false;
+ }
+ theIntegerColorComponent = anIntegerColorComponent;
+ return true;
+ }
+
+ //! Parses the string and gets a real color component from it (only values within range 0.0 .. 1.0 are allowed)
+ //! @param theColorComponentString the string representing the color component
+ //! @param theRealColorComponent a real color component that is a result of parsing
+ //! @return true if parsing was successful, or false otherwise
+ static bool parseNumericalColorComponent (const Standard_CString theColorComponentString,
+ Standard_ShortReal& theRealColorComponent)
+ {
+ Standard_Real aRealColorComponent;
+ if (!Draw::ParseReal (theColorComponentString, aRealColorComponent))
+ {
+ return false;
+ }
+ const Standard_ShortReal aShortRealColorComponent = static_cast<Standard_ShortReal> (aRealColorComponent);
+ if ((aShortRealColorComponent < 0.0f) || (aShortRealColorComponent > THE_MAX_REAL_COLOR_COMPONENT))
+ {
+ return false;
+ }
+ theRealColorComponent = aShortRealColorComponent;
+ return true;
+ }
+
+ //! Parses the string and gets a real color component from it (integer values 2 .. 255 are scaled to the 0.0 .. 1.0
+ //! range, values 0 and 1 are leaved as they are)
+ //! @param theColorComponentString the string representing the color component
+ //! @param theColorComponent a color component that is a result of parsing
+ //! @return true if parsing was successful, or false otherwise
+ static bool parseColorComponent (const Standard_CString theColorComponentString,
+ Standard_ShortReal& theColorComponent)
+ {
+ Standard_Integer anIntegerColorComponent;
+ if (parseNumericalColorComponent (theColorComponentString, anIntegerColorComponent))
+ {
+ if (anIntegerColorComponent == 1)
+ {
+ theColorComponent = THE_MAX_REAL_COLOR_COMPONENT;
+ }
+ else
+ {
+ theColorComponent = anIntegerColorComponent * 1.0f / THE_MAX_INTEGER_COLOR_COMPONENT;
+ }
+ return true;
+ }
+ return parseNumericalColorComponent (theColorComponentString, theColorComponent);
+ }
+
+ //! Parses the array of strings and gets an integer color (only values within range 0 .. 255 are allowed and at least
+ //! one of components must be greater than 1)
+ //! @tparam TheNumber the type of resulting color vector elements
+ //! @param theNumberOfColorComponents the number of color components
+ //! @param theColorComponentStrings the array of strings representing color components
+ //! @param theNumericalColor a 4-component vector that is a result of parsing
+ //! @return true if parsing was successful, or false otherwise
+ template <typename TheNumber>
+ static bool parseNumericalColor (Standard_Integer& theNumberOfColorComponents,
+ const char* const* const theColorComponentStrings,
+ NCollection_Vec4<TheNumber>& theNumericalColor)
+ {
+ for (Standard_Integer aColorComponentIndex = 0; aColorComponentIndex < theNumberOfColorComponents;
+ ++aColorComponentIndex)
+ {
+ const char* const aColorComponentString = theColorComponentStrings[aColorComponentIndex];
+ TheNumber aNumericalColorComponent;
+ if (parseNumericalColorComponent (aColorComponentString, aNumericalColorComponent))
+ {
+ theNumericalColor[aColorComponentIndex] = aNumericalColorComponent;
+ }
+ else
+ {
+ if (aColorComponentIndex == 3)
+ {
+ theNumberOfColorComponents = 3;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ //! Parses an array of strings and get an integer color (only values within range 0 .. 255 are allowed and at least
+ //! one of components must be greater than 1)
+ //! @param theNumberOfColorComponents the number of color components
+ //! @param theColorComponentStrings the array of strings representing color components
+ //! @param theColor a color that is a result of parsing
+ //! @return true if parsing was successful, or false otherwise
+ static bool parseIntegerColor (Standard_Integer& theNumberOfColorComponents,
+ const char* const* const theColorComponentStrings,
+ Quantity_ColorRGBA& theColor)
+ {
+ const Standard_Integer THE_COLOR_COMPONENT_NOT_PARSED = -1;
+ NCollection_Vec4<int> anIntegerColor (THE_COLOR_COMPONENT_NOT_PARSED);
+ if (!parseNumericalColor (theNumberOfColorComponents, theColorComponentStrings, anIntegerColor)
+ || anIntegerColor.maxComp() <= 1)
+ {
+ return false;
+ }
+ if (anIntegerColor.a() == THE_COLOR_COMPONENT_NOT_PARSED)
+ {
+ anIntegerColor.a() = THE_MAX_INTEGER_COLOR_COMPONENT;
+ }
+
+ const NCollection_Vec4<float> aRealColor = NCollection_Vec4<float> (anIntegerColor) / static_cast<float> (THE_MAX_INTEGER_COLOR_COMPONENT);
+ theColor = Quantity_ColorRGBA (Quantity_ColorRGBA::Convert_sRGB_To_LinearRGB (aRealColor));
+ return true;
+ }
+
+ //! Parses an array of strings and get a real color (only values within range 0.0 .. 1.0 are allowed)
+ //! @param theNumberOfColorComponents the number of color components
+ //! @param theColorComponentStrings the array of strings representing color components
+ //! @param theColor a color that is a result of parsing
+ //! @return true if parsing was successful, or false otherwise
+ static bool parseRealColor (Standard_Integer& theNumberOfColorComponents,
+ const char* const* const theColorComponentStrings,
+ Quantity_ColorRGBA& theColor)
+ {
+ NCollection_Vec4<float> aRealColor (THE_MAX_REAL_COLOR_COMPONENT);
+ if (!parseNumericalColor (theNumberOfColorComponents, theColorComponentStrings, aRealColor))
+ {
+ return false;
+ }
+ theColor = Quantity_ColorRGBA (aRealColor);
+ return true;
+ }
+}
+
+//=======================================================================
+// function : parseColor
+// purpose :
+//=======================================================================
+Standard_Integer Draw::parseColor (const Standard_Integer theArgNb,
+ const char* const* const theArgVec,
+ Quantity_ColorRGBA& theColor,
+ const bool theToParseAlpha)
+{
+ if ((theArgNb >= 1) && Quantity_ColorRGBA::ColorFromHex (theArgVec[0], theColor, !theToParseAlpha))
+ {
+ return 1;
+ }
+ if (theArgNb >= 1 && Quantity_ColorRGBA::ColorFromName (theArgVec[0], theColor))
+ {
+ if (theArgNb >= 2 && theToParseAlpha)
+ {
+ const Standard_CString anAlphaStr = theArgVec[1];
+ Standard_ShortReal anAlphaComponent;
+ if (parseColorComponent (anAlphaStr, anAlphaComponent))
+ {
+ theColor.SetAlpha (anAlphaComponent);
+ return 2;
+ }
+ }
+ return 1;
+ }
+ if (theArgNb >= 3)
+ {
+ const Standard_Integer aNumberOfColorComponentsToParse = Min (theArgNb, theToParseAlpha ? 4 : 3);
+ Standard_Integer aNumberOfColorComponentsParsed = aNumberOfColorComponentsToParse;
+ if (parseIntegerColor (aNumberOfColorComponentsParsed, theArgVec, theColor))
+ {
+ return aNumberOfColorComponentsParsed;
+ }
+ aNumberOfColorComponentsParsed = aNumberOfColorComponentsToParse;
+ if (parseRealColor (aNumberOfColorComponentsParsed, theArgVec, theColor))
+ {
+ return aNumberOfColorComponentsParsed;
+ }
+ return 0;
+ }
+ return 0;
+}
+//=======================================================================
+//function : ParseOnOff
+//purpose :
+//=======================================================================
+Standard_Boolean Draw::ParseOnOff (Standard_CString theArg,
+ Standard_Boolean& theIsOn)
+{
+ TCollection_AsciiString aFlag(theArg);
+ aFlag.LowerCase();
+ if (aFlag == "on"
+ || aFlag == "1")
+ {
+ theIsOn = Standard_True;
+ return Standard_True;
+ }
+ else if (aFlag == "off"
+ || aFlag == "0")
+ {
+ theIsOn = Standard_False;
+ return Standard_True;
+ }
+ return Standard_False;
}
#ifndef _Draw_HeaderFile
#define _Draw_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Quantity_ColorRGBA.hxx>
#include <Standard_Handle.hxx>
-#include <Draw_Interpretor.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_CString.hxx>
-#include <Standard_Real.hxx>
-#include <Standard_Integer.hxx>
-class TCollection_AsciiString;
-class Draw_Drawable3D;
-class Draw_ProgressIndicator;
class Draw_Drawable3D;
-class Draw_Drawable2D;
-class Draw_Color;
-class Draw_Display;
-class Draw_Segment3D;
-class Draw_Segment2D;
-class Draw_Marker3D;
-class Draw_Marker2D;
-class Draw_Axis3D;
-class Draw_Axis2D;
-class Draw_Text3D;
-class Draw_Text2D;
-class Draw_Circle3D;
-class Draw_Circle2D;
-class Draw_Number;
-class Draw_Chronometer;
-class Draw_Grid;
-class Draw_Box;
class Draw_ProgressIndicator;
-class Draw_Printer;
-
//! MAQUETTE DESSIN MODELISATION
class Draw
DEFINE_STANDARD_ALLOC
-
- Standard_EXPORT static void Load (Draw_Interpretor& theDI, const TCollection_AsciiString& theKey, const TCollection_AsciiString& theResourceFileName, TCollection_AsciiString& theDefaultsDirectory, TCollection_AsciiString& theUserDefaultsDirectory, const Standard_Boolean Verbose = Standard_False);
-
+ //! (Re)Load a Draw Harness plugin.
+ //! @param theDI [in] [out] Tcl interpretor to append loaded commands
+ //! @param theKey [in] plugin code name to be resolved in resource file
+ //! @param theResourceFileName [in] description file name
+ //! @param theDefaultsDirectory [in] default folder for looking description file
+ //! @param theUserDefaultsDirectory [in] user folder for looking description file
+ //! @param theIsVerbose [in] print verbose messages
+ Standard_EXPORT static void Load (Draw_Interpretor& theDI,
+ const TCollection_AsciiString& theKey,
+ const TCollection_AsciiString& theResourceFileName,
+ const TCollection_AsciiString& theDefaultsDirectory,
+ const TCollection_AsciiString& theUserDefaultsDirectory,
+ const Standard_Boolean theIsVerbose = Standard_False);
+
+public: //! @name Tcl variables management tools
+
//! Sets a variable. Display it if <Disp> is true.
Standard_EXPORT static void Set (const Standard_CString Name, const Handle(Draw_Drawable3D)& D, const Standard_Boolean Disp);
//! Sets a TCL sting variable
Standard_EXPORT static void Set (const Standard_CString Name, const Standard_CString val);
+
+public: //! @name argument parsing tools
//! Converts numeric expression, that can involve DRAW
//! variables, to real value.
Standard_EXPORT static Standard_Real Atof (const Standard_CString Name);
//! Converts the numeric expression, that can involve DRAW variables, to a real value
- //! @param theExpressionString the strings that containes the expression involving DRAW variables to be parsed
+ //! @param theExpressionString the strings that contains the expression involving DRAW variables to be parsed
//! @param theParsedRealValue a real value that is a result of parsing
- //! @return true if parsing was successfull, or false otherwise
+ //! @return true if parsing was successful, or false otherwise
Standard_EXPORT static bool ParseReal (const Standard_CString theExpressionString, Standard_Real& theParsedRealValue);
//! Converts numeric expression, that can involve DRAW
Standard_EXPORT static Standard_Integer Atoi (const Standard_CString Name);
//! Converts the numeric expression, that can involve DRAW variables, to an integer value
- //! @param theExpressionString the strings that containes the expression involving DRAW variables to be parsed
+ //! @param theExpressionString the strings that contains the expression involving DRAW variables to be parsed
//! @param theParsedIntegerValue an integer value that is a result of parsing
- //! @return true if parsing was successfull, or false otherwise
+ //! @return true if parsing was successful, or false otherwise
Standard_EXPORT static bool ParseInteger (const Standard_CString theExpressionString,
Standard_Integer& theParsedIntegerValue);
+ //! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
+ //! Handles either color specified by name (single argument) or by RGB(A) components (3-4 arguments) in range 0..1.
+ //! The result is stored in theColor on success.
+ //!
+ //! Usage code sample for command argument in form "cmd -color {ColorName|R G B [A]|ColorHex}":
+ //! @code
+ //! for (int anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ //! {
+ //! TCollection_AsciiString aParam (theArgVec[anArgIter]);
+ //! aParam.LowerCase();
+ //! if (aParam == "-color")
+ //! {
+ //! Quantity_ColorRGBA aColor;
+ //! Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1,
+ //! theArgVec + anArgIter + 1, aColor);
+ //! anArgIter += aNbParsed;
+ //! if (aNbParsed == 0) { std::cerr << "Syntax error at '" << aParam << "'"; return 1; }
+ //! // process color
+ //! }
+ //! }
+ //! @endcode
+ //!
+ //! @param theArgNb [in] number of available arguments in theArgVec (array limits)
+ //! @param theArgVec [in] argument list
+ //! @param theColor [out] retrieved color
+ //! @return number of handled arguments (1, 2, 3 or 4) or 0 on syntax error
+ static Standard_Integer ParseColor (const Standard_Integer theArgNb,
+ const char* const* const theArgVec,
+ Quantity_ColorRGBA& theColor)
+ {
+ return parseColor (theArgNb, theArgVec, theColor, true);
+ }
+
+ //! Parses RGB color argument(s).
+ //! @param theArgNb [in] number of available arguments in theArgVec (array limits)
+ //! @param theArgVec [in] argument list
+ //! @param theColor [out] retrieved color
+ //! @return number of handled arguments (1 or 3) or 0 on syntax error.
+ static Standard_Integer ParseColor (const Standard_Integer theArgNb,
+ const char* const* const theArgVec,
+ Quantity_Color& theColor)
+ {
+ Quantity_ColorRGBA anRgba;
+ const Standard_Integer aNbParsed = parseColor (theArgNb, theArgVec, anRgba, false);
+ if (aNbParsed != 0)
+ {
+ theColor = anRgba.GetRGB();
+ }
+ return aNbParsed;
+ }
+
+ //! Parses boolean argument. Handles either flag specified by 0|1 or on|off.
+ //!
+ //! Usage code sample for command argument in form "cmd -usefeature [on|off|1|0]=on":
+ //! @code
+ //! for (int anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ //! {
+ //! TCollection_AsciiString aParam (theArgVec[anArgIter]);
+ //! aParam.LowerCase();
+ //! if (aParam == "-usefeature")
+ //! {
+ //! bool toUseFeature = true;
+ //! if (anArgIter + 1 < theNbArgs && Draw::ParseOnOff (theArgVec[anArgIter + 1]))
+ //! {
+ //! ++anArgIter;
+ //! }
+ //! // process feature
+ //! }
+ //! }
+ //! @endcode
+ //!
+ //! @param theArg [in] argument value
+ //! @param theIsOn [out] decoded Boolean flag
+ //! @return FALSE on syntax error
+ Standard_EXPORT static Standard_Boolean ParseOnOff (Standard_CString theArg,
+ Standard_Boolean& theIsOn);
+
+public:
+
//! Returns last graphic selection description.
Standard_EXPORT static void LastPick (Standard_Integer& view, Standard_Integer& X, Standard_Integer& Y, Standard_Integer& button);
//! gets progress indicator
Standard_EXPORT static Handle(Draw_ProgressIndicator) GetProgressBar();
-
+
+public: //! @name methods loading standard command sets
+
//! Defines all Draw commands
Standard_EXPORT static void Commands (Draw_Interpretor& I);
Standard_EXPORT static Handle(Draw_Drawable3D) getDrawable (Standard_CString& theName,
Standard_Boolean theToAllowPick);
-private:
-
-friend class Draw_Drawable3D;
-friend class Draw_Drawable2D;
-friend class Draw_Color;
-friend class Draw_Display;
-friend class Draw_Segment3D;
-friend class Draw_Segment2D;
-friend class Draw_Marker3D;
-friend class Draw_Marker2D;
-friend class Draw_Axis3D;
-friend class Draw_Axis2D;
-friend class Draw_Text3D;
-friend class Draw_Text2D;
-friend class Draw_Circle3D;
-friend class Draw_Circle2D;
-friend class Draw_Number;
-friend class Draw_Chronometer;
-friend class Draw_Grid;
-friend class Draw_Box;
-friend class Draw_ProgressIndicator;
-friend class Draw_Printer;
+ //! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
+ //! Handles either color specified by name (single argument)
+ //! or by RGB(A) components (3-4 arguments) in range 0..1.
+ //! The result is stored in theColor on success.
+ //! Returns number of handled arguments (1, 2, 3 or 4) or 0 on syntax error.
+ Standard_EXPORT static Standard_Integer parseColor (Standard_Integer theArgNb,
+ const char* const* theArgVec,
+ Quantity_ColorRGBA& theColor,
+ bool theToParseAlpha);
};
-
-
-
-
-
-
#endif // _Draw_HeaderFile
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <TCollection_AsciiString.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Draw_MapOfAsciiString.hxx>
+#include <Draw.hxx>
+#include <Message.hxx>
#include <OSD_Path.hxx>
#include <OSD_Directory.hxx>
#include <OSD_File.hxx>
#include <OSD_Environment.hxx>
#include <OSD_SharedLibrary.hxx>
#include <Resource_Manager.hxx>
-#include <Draw_Interpretor.hxx>
-#include <Draw_MapOfAsciiString.hxx>
-#include <Draw.hxx>
-
-static Handle(Resource_Manager) myResources;
-
-//=======================================================================
-//function : FindPluginFile
-//purpose : Searches for the existence of the plugin file according to its name thePluginName:
-// - if thePluginName is empty then it defaults to DrawPlugin
-// - the search directory is defined according to the variable
-// CSF_<filename>Defaults (if it is omitted then it defaults to
-// $CASROOT/src/DrawResources)
-// - finally existence of the file is verified in the search directory
-// - if the file exists but corresponding variable (CSF_...) has not been
-// explicitly set, it is forced to (for further reuse by Resource_Manager)
-// Returns True if the file exists, otherwise - False.
-//=======================================================================
+#include <TCollection_AsciiString.hxx>
-#define FAILSTR "Failed to load plugin: "
-
-//static Standard_Boolean FindPluginFile (TCollection_AsciiString& thePluginName)
-static Standard_Boolean FindPluginFile (TCollection_AsciiString& thePluginName, TCollection_AsciiString& aPluginDir)
+//! Searches for the existence of the plugin file according to its name thePluginName:
+//! - if thePluginName is empty then it defaults to DrawPlugin
+//! - the search directory is defined according to the variable
+//! CSF_<filename>Defaults (if it is omitted then it defaults to
+//! $CASROOT/src/DrawResources)
+//! - finally existence of the file is verified in the search directory
+//! - if the file exists but corresponding variable (CSF_...) has not been
+//! explicitly set, it is forced to (for further reuse by Resource_Manager)
+//! @return TRUE if the file exists, otherwise - False
+static Standard_Boolean findPluginFile (TCollection_AsciiString& thePluginName,
+ TCollection_AsciiString& thePluginDir)
{
- Standard_Boolean aResult = Standard_True;
-
// check if the file name has been specified and use default value if not
- if (thePluginName.IsEmpty()) {
+ if (thePluginName.IsEmpty())
+ {
thePluginName += "DrawPlugin";
#ifdef OCCT_DEBUG
std::cout << "Plugin file name has not been specified. Defaults to " << thePluginName.ToCString() << std::endl;
#endif
}
- //TCollection_AsciiString aPluginDir; // the search directory
- Standard_Boolean aDirFound = Standard_True, aToSetCSFVariable = Standard_False;
+ Standard_Boolean aToSetCSFVariable = Standard_False;
// the order of search : by CSF_<PluginFileName>Defaults and then by CASROOT
- TCollection_AsciiString aCSFVariable = TCollection_AsciiString ("CSF_") + thePluginName + "Defaults";
- aPluginDir = OSD_Environment (aCSFVariable).Value();
- if (aPluginDir.IsEmpty())
+ const TCollection_AsciiString aCSFVariable = TCollection_AsciiString ("CSF_") + thePluginName + "Defaults";
+ thePluginDir = OSD_Environment (aCSFVariable).Value();
+ if (thePluginDir.IsEmpty())
{
- aPluginDir = OSD_Environment ("DRAWHOME").Value();
- if (!aPluginDir.IsEmpty())
+ thePluginDir = OSD_Environment ("DRAWHOME").Value();
+ if (!thePluginDir.IsEmpty())
{
aToSetCSFVariable = Standard_True; //CSF variable to be set later
}
else
{
// now try by CASROOT
- aPluginDir = OSD_Environment ("CASROOT").Value();
- if (!aPluginDir.IsEmpty())
+ thePluginDir = OSD_Environment ("CASROOT").Value();
+ if (!thePluginDir.IsEmpty())
{
- aPluginDir += "/src/DrawResources";
+ thePluginDir += "/src/DrawResources";
aToSetCSFVariable = Standard_True; //CSF variable to be set later
}
else
{
- aResult = aDirFound = Standard_False;
- std::cout << FAILSTR "Neither " << aCSFVariable << ", nor CASROOT variables have been set\n";
+ Message::SendFail() << "Failed to load plugin: Neither " << aCSFVariable << ", nor CASROOT variables have been set";
+ return Standard_False;
}
}
}
-
- if (aDirFound) {
- // search directory name has been constructed, now check whether it and the file exist
-
- TCollection_AsciiString aPluginFileName = aPluginDir + "/" + thePluginName;
- OSD_File PluginFile ( aPluginFileName );
- if ( PluginFile.Exists() ) {
- if (aToSetCSFVariable) {
- OSD_Environment aCSFVarEnv ( aCSFVariable, aPluginDir );
- aCSFVarEnv.Build();
+
+ // search directory name has been constructed, now check whether it and the file exist
+ const TCollection_AsciiString aPluginFileName = thePluginDir + "/" + thePluginName;
+ OSD_File aPluginFile (aPluginFileName);
+ if (!aPluginFile.Exists())
+ {
+ Message::SendFail() << "Failed to load plugin: File " << aPluginFileName << " not found";
+ return Standard_False;
+ }
+
+ if (aToSetCSFVariable)
+ {
+ OSD_Environment aCSFVarEnv (aCSFVariable, thePluginDir);
+ aCSFVarEnv.Build();
#ifdef OCCT_DEBUG
- std::cout << "Variable " << aCSFVariable.ToCString() << " has not been explicitly defined. Set to " << aPluginDir.ToCString() << std::endl;
+ std::cout << "Variable " << aCSFVariable << " has not been explicitly defined. Set to " << thePluginDir << std::endl;
#endif
- if ( aCSFVarEnv.Failed() ) {
- aResult = Standard_False;
- std::cout << FAILSTR "Failed to initialize " << aCSFVariable.ToCString() << " with " << aPluginDir.ToCString() << std::endl;
- }
- }
- } else {
- aResult = Standard_False;
- std::cout << FAILSTR "File " << aPluginFileName.ToCString() << " not found" << std::endl;
+ if (aCSFVarEnv.Failed())
+ {
+ Message::SendFail() << "Failed to load plugin: Failed to initialize " << aCSFVariable << " with " << thePluginDir;
+ return Standard_False;
}
}
- return aResult;
+ return Standard_True;
}
-//=======================================================================
-//function : Parse
-//purpose : Parse the input keys to atomic keys (<key> --> <akey>[<akey> ..])
-//=======================================================================
-
-static void Parse (Draw_MapOfAsciiString& theMap)
+//! Resolve keys within input map (groups, aliases and toolkits) to the list of destination toolkits (plugins to load).
+//! @param theMap [in] [out] map to resolve (will be rewritten)
+//! @param theResMgr [in] resource manager to resolve keys
+static void resolveKeys (Draw_MapOfAsciiString& theMap,
+ const Handle(Resource_Manager)& theResMgr)
{
+ if (theResMgr.IsNull())
+ {
+ return;
+ }
+
Draw_MapOfAsciiString aMap, aMap2;
- Standard_Integer j, k;
- Standard_Integer aMapExtent, aMap2Extent;
- aMapExtent = theMap.Extent();
- for(j = 1; j <= aMapExtent; j++) {
- if (!myResources.IsNull()) {
- const TCollection_AsciiString& aKey = theMap.FindKey(j);
- TCollection_AsciiString aResource = aKey;
- if(myResources->Find(aResource.ToCString())) {
-#ifdef OCCT_DEBUG
- std::cout << "Parse Value ==> " << myResources->Value(aResource.ToCString()) << std::endl;
-#endif
- TCollection_AsciiString aValue(myResources->Value(aResource.ToCString()));
- // parse aValue string
- Standard_Integer i=1;
- for(;;) {
- TCollection_AsciiString aCurKey = aValue.Token(" \t,", i++);
-#ifdef OCCT_DEBUG
- std::cout << "Parse aCurKey = " << aCurKey.ToCString() << std::endl;
-#endif
- if(aCurKey.IsEmpty()) break;
- if(!myResources->Find(aCurKey.ToCString())) {
- // It is toolkit
- aMap.Add(aResource);
- }
- else
- aMap2.Add(aCurKey);
- }
- } else
- std::cout <<"Pload : Resource = " << aResource << " is not found" << std::endl;
- if(!aMap2.IsEmpty())
- Parse(aMap2);
- //
- aMap2Extent = aMap2.Extent();
- for(k = 1; k <= aMap2Extent; k++) {
- aMap.Add(aMap2.FindKey(k));
+ const Standard_Integer aMapExtent = theMap.Extent();
+ for (Standard_Integer j = 1; j <= aMapExtent; ++j)
+ {
+ TCollection_AsciiString aValue;
+ const TCollection_AsciiString aResource = theMap.FindKey (j);
+ if (theResMgr->Find (aResource, aValue))
+ {
+ #ifdef OCCT_DEBUG
+ std::cout << "Parse Value ==> " << aValue << std::endl;
+ #endif
+ for (Standard_Integer aKeyIter = 1;; ++aKeyIter)
+ {
+ const TCollection_AsciiString aCurKey = aValue.Token (" \t,", aKeyIter);
+ #ifdef OCCT_DEBUG
+ std::cout << "Parse aCurKey = " << aCurKey << std::endl;
+ #endif
+ if (aCurKey.IsEmpty())
+ {
+ break;
+ }
+
+ if (theResMgr->Find (aCurKey.ToCString()))
+ {
+ aMap2.Add (aCurKey);
+ }
+ else
+ {
+ aMap.Add (aResource); // It is toolkit
+ }
}
+ }
+ else
+ {
+ Message::SendFail() << "Pload : Resource = " << aResource << " is not found";
+ }
+
+ if (!aMap2.IsEmpty())
+ {
+ resolveKeys (aMap2, theResMgr);
+ }
+ //
+ const Standard_Integer aMap2Extent = aMap2.Extent();
+ for (Standard_Integer k = 1; k <= aMap2Extent; ++k)
+ {
+ aMap.Add (aMap2.FindKey (k));
}
}
- theMap.Assign(aMap);
+ theMap.Assign (aMap);
}
//=======================================================================
//purpose :
//=======================================================================
-static Standard_Integer Pload (Draw_Interpretor& di,
- Standard_Integer n,
- const char** argv)
+static Standard_Integer Pload (Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- char adef[] = "-";
- TCollection_AsciiString aPluginFileName("");
- TCollection_AsciiString aPluginDir(""), aPluginDir2("");
- Standard_Integer aStart = 0;
- Standard_Integer aFinish = n - 1;
-
- if (n == 1) {
- // Load DEFAULT key
- aStart = 0;
- } else {
- if(argv[1][0] == adef[0]) {
- aPluginFileName = argv[1];
- aPluginFileName.Remove(1,1);
- if (n == 2) {
- // Load DEFAULT key from aPluginFileName file
- aStart = 0;
- aFinish = n - 2;
- } else {
- aStart = 2;
- }
- } else {
- aStart = 1;
+ Draw_MapOfAsciiString aMap;
+ TCollection_AsciiString aPluginFileName;
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ const TCollection_AsciiString aTK (theArgVec[anArgIter]);
+ if (anArgIter == 1
+ && aTK.Value (1) == '-')
+ {
+ aPluginFileName = aTK.SubString (2, aTK.Length());
+ }
+ else
+ {
+ aMap.Add (aTK);
}
}
+ if (aMap.IsEmpty())
+ {
+ aMap.Add ("DEFAULT"); // Load DEFAULT key
+ }
- //if ( !FindPluginFile (aPluginFileName) ) {
- if ( !FindPluginFile (aPluginFileName, aPluginDir) ) {
+ TCollection_AsciiString aPluginDir, aPluginDir2;
+ if (!findPluginFile (aPluginFileName, aPluginDir))
+ {
return 1;
- }
+ }
- Draw_MapOfAsciiString aMap;
- TCollection_AsciiString aDEFAULT("DEFAULT");
- //for(Standard_Integer i = aStart; i < n; i++)
- for(Standard_Integer i = aStart; i <= aFinish; i++)
- if (i == 0) {
- // Load DEFAULT key
- aMap.Add(aDEFAULT);
- } else {
- TCollection_AsciiString aTK(argv[i]);
- aMap.Add(aTK);
+ Handle(Resource_Manager) aResMgr = new Resource_Manager (aPluginFileName.ToCString(), aPluginDir, aPluginDir2, Standard_False);
+ resolveKeys (aMap, aResMgr);
+
+ const Standard_Integer aMapExtent = aMap.Extent();
+ for (Standard_Integer aResIter = 1; aResIter <= aMapExtent; ++aResIter)
+ {
+ const TCollection_AsciiString aResource = aMap.FindKey (aResIter);
+ #ifdef OCCT_DEBUG
+ std::cout << "aResource = " << aResource << std::endl;
+ #endif
+ TCollection_AsciiString aValue;
+ if (!aResMgr->Find (aResource, aValue))
+ {
+ Message::SendWarning() <<"Pload : Resource = " << aResource << " is not found";
+ continue;
}
-
- //myResources = new Resource_Manager(aPluginFileName.ToCString());
- myResources = new Resource_Manager(aPluginFileName.ToCString(), aPluginDir, aPluginDir2, Standard_False);
- Parse(aMap);
- Standard_Integer j;
- Standard_Integer aMapExtent;
- aMapExtent = aMap.Extent();
- for(j = 1; j <= aMapExtent; j++) {
- const TCollection_AsciiString& aKey = aMap.FindKey(j);
- TCollection_AsciiString aResource = aKey;
-#ifdef OCCT_DEBUG
- std::cout << "aResource = " << aResource << std::endl;
-#endif
- if(myResources->Find(aResource.ToCString())) {
- const TCollection_AsciiString& aValue = myResources->Value(aResource.ToCString());
-#ifdef OCCT_DEBUG
- std::cout << "Value ==> " << aValue << std::endl;
-#endif
-
- //Draw::Load(di, aKey, aPluginFileName);
- Draw::Load(di, aKey, aPluginFileName, aPluginDir, aPluginDir2, Standard_False);
+ #ifdef OCCT_DEBUG
+ std::cout << "Value ==> " << aValue << std::endl;
+ #endif
- // Load TclScript
- TCollection_AsciiString aCSFVariable ("CSF_DrawPluginTclDir");
- TCollection_AsciiString aTclScriptDir;
- aTclScriptDir = getenv (aCSFVariable.ToCString());
- TCollection_AsciiString aTclScriptFileName;
- TCollection_AsciiString aTclScriptFileNameDefaults;
- aTclScriptFileName = aTclScriptDir + "/" + aValue + ".tcl";
- aTclScriptFileNameDefaults = aPluginDir + "/" + aValue + ".tcl";
- OSD_File aTclScriptFile ( aTclScriptFileName );
- OSD_File aTclScriptFileDefaults ( aTclScriptFileNameDefaults );
- if (!aTclScriptDir.IsEmpty() && aTclScriptFile.Exists()) {
-#ifdef OCCT_DEBUG
- std::cout << "Load " << aTclScriptFileName << " TclScript" << std::endl;
-#endif
- di.EvalFile( aTclScriptFileName.ToCString() );
- } else if (!aPluginDir.IsEmpty() && aTclScriptFileDefaults.Exists()) {
-#ifdef OCCT_DEBUG
- std::cout << "Load " << aTclScriptFileNameDefaults << " TclScript" << std::endl;
-#endif
- di.EvalFile( aTclScriptFileNameDefaults.ToCString() );
- }
-
- } else
- std::cout <<"Pload : Resource = " << aResource << " is not found" << std::endl;
+ Draw::Load (theDI, aResource, aPluginFileName, aPluginDir, aPluginDir2, Standard_False);
+
+ // Load TclScript
+ const TCollection_AsciiString aTclScriptDir = OSD_Environment ("CSF_DrawPluginTclDir").Value();
+ const TCollection_AsciiString aTclScriptFileName = aTclScriptDir + "/" + aValue + ".tcl";
+ const TCollection_AsciiString aTclScriptFileNameDefaults = aPluginDir + "/" + aValue + ".tcl";
+ OSD_File aTclScriptFile (aTclScriptFileName);
+ OSD_File aTclScriptFileDefaults (aTclScriptFileNameDefaults);
+ if (!aTclScriptDir.IsEmpty()
+ && aTclScriptFile.Exists())
+ {
+ #ifdef OCCT_DEBUG
+ std::cout << "Load " << aTclScriptFileName << " TclScript" << std::endl;
+ #endif
+ theDI.EvalFile (aTclScriptFileName.ToCString());
+ }
+ else if (!aPluginDir.IsEmpty()
+ && aTclScriptFileDefaults.Exists())
+ {
+ #ifdef OCCT_DEBUG
+ std::cout << "Load " << aTclScriptFileNameDefaults << " TclScript" << std::endl;
+ #endif
+ theDI.EvalFile (aTclScriptFileNameDefaults.ToCString());
+ }
}
return 0;
}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <Resource_Manager.hxx>
#include <OSD_Directory.hxx>
#include <OSD_Environment.hxx>
#include <OSD_Protection.hxx>
#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
#include <Resource_LexicalCompare.hxx>
-#include <Resource_Manager.hxx>
#include <Resource_NoSuchResource.hxx>
#include <Resource_Unicode.hxx>
#include <Standard_ErrorHandler.hxx>
static Standard_Boolean Debug;
-Resource_Manager::Resource_Manager(const Standard_CString aName,
- TCollection_AsciiString& aDefaultsDirectory,
- TCollection_AsciiString& anUserDefaultsDirectory,
- const Standard_Boolean Verbose) : myName(aName), myVerbose(Verbose)
+// =======================================================================
+// function : Resource_Manager
+// purpose :
+// =======================================================================
+Resource_Manager::Resource_Manager (const TCollection_AsciiString& theName,
+ const TCollection_AsciiString& theDefaultsDirectory,
+ const TCollection_AsciiString& theUserDefaultsDirectory,
+ const Standard_Boolean theIsVerbose)
+: myName (theName),
+ myVerbose (theIsVerbose)
{
- if ( !aDefaultsDirectory.IsEmpty() ) {
- OSD_Path anOSDPath(aDefaultsDirectory);
+ if (!theDefaultsDirectory.IsEmpty())
+ {
+ OSD_Path anOSDPath (theDefaultsDirectory);
if (!anOSDPath.Name().IsEmpty())
{
- anOSDPath.DownTrek (anOSDPath.Name () + anOSDPath.Extension ());
+ anOSDPath.DownTrek (anOSDPath.Name() + anOSDPath.Extension());
}
- anOSDPath.SetName(aName);
- anOSDPath.SetExtension("");
+ anOSDPath.SetName (theName);
+ anOSDPath.SetExtension ("");
TCollection_AsciiString aPath;
- anOSDPath.SystemName(aPath);
- Load(aPath,myRefMap);
+ anOSDPath.SystemName (aPath);
+ Load (aPath, myRefMap);
+ }
+ else if (myVerbose)
+ {
+ std::cout << "Resource Manager Warning: aDefaultsDirectory is empty." << std::endl;
}
- else
- if (myVerbose)
- std::cout << "Resource Manager Warning: aDefaultsDirectory is empty." << std::endl;
- if ( !anUserDefaultsDirectory.IsEmpty() ) {
- OSD_Path anOSDPath(anUserDefaultsDirectory);
+ if (!theUserDefaultsDirectory.IsEmpty())
+ {
+ OSD_Path anOSDPath (theUserDefaultsDirectory);
if (!anOSDPath.Name().IsEmpty())
{
- anOSDPath.DownTrek (anOSDPath.Name () + anOSDPath.Extension ());
+ anOSDPath.DownTrek (anOSDPath.Name() + anOSDPath.Extension());
}
- anOSDPath.SetName(aName);
- anOSDPath.SetExtension("");
+ anOSDPath.SetName (theName);
+ anOSDPath.SetExtension ("");
TCollection_AsciiString aPath;
- anOSDPath.SystemName(aPath);
- Load(aPath,myRefMap);
+ anOSDPath.SystemName (aPath);
+ Load (aPath, myRefMap);
+ }
+ else if (myVerbose)
+ {
+ std::cout << "Resource Manager Warning: anUserDefaultsDirectory is empty." << std::endl;
}
- else
- if (myVerbose)
- std::cout << "Resource Manager Warning: anUserDefaultsDirectory is empty." << std::endl;
}
Resource_Manager::Resource_Manager(const Standard_CString aName,
std::cout << "Resource Manager Warning: Environment variable \"CSF_" << aName << "UserDefaults\" not set." << std::endl;
}
-void Resource_Manager::Load(TCollection_AsciiString& aPath,
+// =======================================================================
+// function : Load
+// purpose :
+// =======================================================================
+void Resource_Manager::Load(const TCollection_AsciiString& thePath,
Resource_DataMapOfAsciiStringAsciiString& aMap)
{
Resource_KindOfLine aKind;
TCollection_AsciiString Token1, Token2;
- OSD_Path Path(aPath);
+ OSD_Path Path (thePath);
OSD_File File = Path;
TCollection_AsciiString FileName = Path.Name();
File.Open(OSD_ReadOnly,OSD_Protection());
return Standard_False;
}
+//=======================================================================
+//function : Find
+//purpose :
+//=======================================================================
+Standard_Boolean Resource_Manager::Find (const TCollection_AsciiString& theResource,
+ TCollection_AsciiString& theValue) const
+{
+ return myUserMap.Find (theResource, theValue)
+ || myRefMap .Find (theResource, theValue);
+}
+
//=======================================================================
//function : GetResourcePath
//purpose :
//! Defines a resource structure and its management methods.
class Resource_Manager : public Standard_Transient
{
-
+ DEFINE_STANDARD_RTTIEXT(Resource_Manager,Standard_Transient)
public:
-
//! Create a Resource manager.
//! Attempts to find the two following files:
//! $CSF_`aName`Defaults/aName
//! lines terminated by newline characters or end of file. The
//! syntax of an individual resource line is:
Standard_EXPORT Resource_Manager(const Standard_CString aName, const Standard_Boolean Verbose = Standard_False);
-
- Standard_EXPORT Resource_Manager(const Standard_CString aName, TCollection_AsciiString& aDefaultsDirectory, TCollection_AsciiString& anUserDefaultsDirectory, const Standard_Boolean Verbose = Standard_False);
+
+ //! Create a Resource manager.
+ //! @param theName [in] description file name
+ //! @param theDefaultsDirectory [in] default folder for looking description file
+ //! @param theUserDefaultsDirectory [in] user folder for looking description file
+ //! @param theIsVerbose [in] print verbose messages
+ Standard_EXPORT Resource_Manager (const TCollection_AsciiString& theName,
+ const TCollection_AsciiString& theDefaultsDirectory,
+ const TCollection_AsciiString& theUserDefaultsDirectory,
+ const Standard_Boolean theIsVerbose = Standard_False);
//! Save the user resource structure in the specified file.
//! Creates the file if it does not exist.
//! returns True if the Resource does exist.
Standard_EXPORT Standard_Boolean Find (const Standard_CString aResource) const;
-
+
+ //! returns True if the Resource does exist.
+ Standard_EXPORT Standard_Boolean Find (const TCollection_AsciiString& theResource,
+ TCollection_AsciiString& theValue) const;
+
//! Gets the value of an integer resource according to its
//! instance and its type.
Standard_EXPORT virtual Standard_Integer Integer (const Standard_CString aResourceName) const;
//! or file doesn't exist returns empty string.
Standard_EXPORT static void GetResourcePath (TCollection_AsciiString& aPath, const Standard_CString aName, const Standard_Boolean isUserDefaults);
+private:
-
-
- DEFINE_STANDARD_RTTIEXT(Resource_Manager,Standard_Transient)
-
-protected:
-
-
-
+ Standard_EXPORT void Load (const TCollection_AsciiString& thePath,
+ Resource_DataMapOfAsciiStringAsciiString& aMap);
private:
-
- Standard_EXPORT void Load (TCollection_AsciiString& aPath, Resource_DataMapOfAsciiStringAsciiString& aMap);
-
TCollection_AsciiString myName;
Resource_DataMapOfAsciiStringAsciiString myRefMap;
Resource_DataMapOfAsciiStringAsciiString myUserMap;
Resource_DataMapOfAsciiStringExtendedString myExtStrMap;
Standard_Boolean myVerbose;
-
};
-
-
-
-
-
-
#endif // _Resource_Manager_HeaderFile
#define DEFAULT_FREEBOUNDARY_COLOR Quantity_NOC_GREEN
#define DEFAULT_MATERIAL Graphic3d_NOM_BRASS
-namespace
-{
-
- const Standard_Integer THE_MAX_INTEGER_COLOR_COMPONENT = 255;
-
- const Standard_ShortReal THE_MAX_REAL_COLOR_COMPONENT = 1.0f;
-
- //! Parses string and get an integer color component (only values within range 0 .. 255 are allowed)
- //! @param theColorComponentString the string representing the color component
- //! @param theIntegerColorComponent an integer color component that is a result of parsing
- //! @return true if parsing was successful, or false otherwise
- static bool parseNumericalColorComponent (const Standard_CString theColorComponentString,
- Standard_Integer& theIntegerColorComponent)
- {
- Standard_Integer anIntegerColorComponent;
- if (!Draw::ParseInteger (theColorComponentString, anIntegerColorComponent))
- {
- return false;
- }
- if ((anIntegerColorComponent < 0) || (anIntegerColorComponent > THE_MAX_INTEGER_COLOR_COMPONENT))
- {
- return false;
- }
- theIntegerColorComponent = anIntegerColorComponent;
- return true;
- }
-
- //! Parses the string and gets a real color component from it (only values within range 0.0 .. 1.0 are allowed)
- //! @param theColorComponentString the string representing the color component
- //! @param theRealColorComponent a real color component that is a result of parsing
- //! @return true if parsing was successful, or false otherwise
- static bool parseNumericalColorComponent (const Standard_CString theColorComponentString,
- Standard_ShortReal& theRealColorComponent)
- {
- Standard_Real aRealColorComponent;
- if (!Draw::ParseReal (theColorComponentString, aRealColorComponent))
- {
- return false;
- }
- const Standard_ShortReal aShortRealColorComponent = static_cast<Standard_ShortReal> (aRealColorComponent);
- if ((aShortRealColorComponent < 0.0f) || (aShortRealColorComponent > THE_MAX_REAL_COLOR_COMPONENT))
- {
- return false;
- }
- theRealColorComponent = aShortRealColorComponent;
- return true;
- }
-
- //! Parses the string and gets a real color component from it (integer values 2 .. 255 are scaled to the 0.0 .. 1.0
- //! range, values 0 and 1 are leaved as they are)
- //! @param theColorComponentString the string representing the color component
- //! @param theColorComponent a color component that is a result of parsing
- //! @return true if parsing was successful, or false otherwise
- static bool parseColorComponent (const Standard_CString theColorComponentString,
- Standard_ShortReal& theColorComponent)
- {
- Standard_Integer anIntegerColorComponent;
- if (parseNumericalColorComponent (theColorComponentString, anIntegerColorComponent))
- {
- if (anIntegerColorComponent == 1)
- {
- theColorComponent = THE_MAX_REAL_COLOR_COMPONENT;
- }
- else
- {
- theColorComponent = anIntegerColorComponent * 1.0f / THE_MAX_INTEGER_COLOR_COMPONENT;
- }
- return true;
- }
- return parseNumericalColorComponent (theColorComponentString, theColorComponent);
- }
-
- //! Parses the array of strings and gets an integer color (only values within range 0 .. 255 are allowed and at least
- //! one of components must be greater than 1)
- //! @tparam TheNumber the type of resulting color vector elements
- //! @param theNumberOfColorComponents the number of color components
- //! @param theColorComponentStrings the array of strings representing color components
- //! @param theNumericalColor a 4-component vector that is a result of parsing
- //! @return true if parsing was successful, or false otherwise
- template <typename TheNumber>
- static bool parseNumericalColor (Standard_Integer& theNumberOfColorComponents,
- const char* const* const theColorComponentStrings,
- NCollection_Vec4<TheNumber>& theNumericalColor)
- {
- for (Standard_Integer aColorComponentIndex = 0; aColorComponentIndex < theNumberOfColorComponents;
- ++aColorComponentIndex)
- {
- const char* const aColorComponentString = theColorComponentStrings[aColorComponentIndex];
- TheNumber aNumericalColorComponent;
- if (parseNumericalColorComponent (aColorComponentString, aNumericalColorComponent))
- {
- theNumericalColor[aColorComponentIndex] = aNumericalColorComponent;
- }
- else
- {
- if (aColorComponentIndex == 3)
- {
- theNumberOfColorComponents = 3;
- }
- else
- {
- return false;
- }
- }
- }
- return true;
- }
-
- //! Parses an array of strings and get an integer color (only values within range 0 .. 255 are allowed and at least
- //! one of components must be greater than 1)
- //! @param theNumberOfColorComponents the number of color components
- //! @param theColorComponentStrings the array of strings representing color components
- //! @param theColor a color that is a result of parsing
- //! @return true if parsing was successful, or false otherwise
- static bool parseIntegerColor (Standard_Integer& theNumberOfColorComponents,
- const char* const* const theColorComponentStrings,
- Quantity_ColorRGBA& theColor)
- {
- const Standard_Integer THE_COLOR_COMPONENT_NOT_PARSED = -1;
- Graphic3d_Vec4i anIntegerColor (THE_COLOR_COMPONENT_NOT_PARSED);
- if (!parseNumericalColor (theNumberOfColorComponents, theColorComponentStrings, anIntegerColor)
- || anIntegerColor.maxComp() <= 1)
- {
- return false;
- }
- if (anIntegerColor.a() == THE_COLOR_COMPONENT_NOT_PARSED)
- {
- anIntegerColor.a() = THE_MAX_INTEGER_COLOR_COMPONENT;
- }
-
- const Graphic3d_Vec4 aRealColor = Graphic3d_Vec4 (anIntegerColor) / static_cast<Standard_ShortReal> (THE_MAX_INTEGER_COLOR_COMPONENT);
- theColor = Quantity_ColorRGBA (Quantity_ColorRGBA::Convert_sRGB_To_LinearRGB (aRealColor));
- return true;
- }
-
- //! Parses an array of strings and get a real color (only values within range 0.0 .. 1.0 are allowed)
- //! @param theNumberOfColorComponents the number of color components
- //! @param theColorComponentStrings the array of strings representing color components
- //! @param theColor a color that is a result of parsing
- //! @return true if parsing was successful, or false otherwise
- static bool parseRealColor (Standard_Integer& theNumberOfColorComponents,
- const char* const* const theColorComponentStrings,
- Quantity_ColorRGBA& theColor)
- {
- Graphic3d_Vec4 aRealColor (THE_MAX_REAL_COLOR_COMPONENT);
- if (!parseNumericalColor (theNumberOfColorComponents, theColorComponentStrings, aRealColor))
- {
- return false;
- }
- theColor = Quantity_ColorRGBA (aRealColor);
- return true;
- }
-
-} // namespace
-
//=======================================================================
// function : GetColorFromName
// purpose : get the Quantity_NameOfColor from a string
}
//=======================================================================
-// function : parseColor
+// function : ParseColor
// purpose :
//=======================================================================
-Standard_Integer ViewerTest::parseColor (const Standard_Integer theArgNb,
+Standard_Integer ViewerTest::ParseColor (const Standard_Integer theArgNb,
const char* const* const theArgVec,
- Quantity_ColorRGBA& theColor,
- const bool theToParseAlpha)
+ Quantity_ColorRGBA& theColor)
{
- if ((theArgNb >= 1) && Quantity_ColorRGBA::ColorFromHex (theArgVec[0], theColor, !theToParseAlpha))
- {
- return 1;
- }
- if (theArgNb >= 1 && Quantity_ColorRGBA::ColorFromName (theArgVec[0], theColor))
- {
- if (theArgNb >= 2 && theToParseAlpha)
- {
- const Standard_CString anAlphaStr = theArgVec[1];
- Standard_ShortReal anAlphaComponent;
- if (parseColorComponent (anAlphaStr, anAlphaComponent))
- {
- theColor.SetAlpha (anAlphaComponent);
- return 2;
- }
- }
- return 1;
- }
- if (theArgNb >= 3)
- {
- const Standard_Integer aNumberOfColorComponentsToParse = Min (theArgNb, theToParseAlpha ? 4 : 3);
- Standard_Integer aNumberOfColorComponentsParsed = aNumberOfColorComponentsToParse;
- if (parseIntegerColor (aNumberOfColorComponentsParsed, theArgVec, theColor))
- {
- return aNumberOfColorComponentsParsed;
- }
- aNumberOfColorComponentsParsed = aNumberOfColorComponentsToParse;
- if (parseRealColor (aNumberOfColorComponentsParsed, theArgVec, theColor))
- {
- return aNumberOfColorComponentsParsed;
- }
- return 0;
- }
- return 0;
+ return Draw::ParseColor (theArgNb, theArgVec, theColor);
+}
+
+//=======================================================================
+// function : ParseColor
+// purpose :
+//=======================================================================
+Standard_Integer ViewerTest::ParseColor (const Standard_Integer theArgNb,
+ const char* const* const theArgVec,
+ Quantity_Color& theColor)
+{
+ return Draw::ParseColor (theArgNb, theArgVec, theColor);
}
//=======================================================================
Standard_Boolean ViewerTest::ParseOnOff (Standard_CString theArg,
Standard_Boolean& theIsOn)
{
- TCollection_AsciiString aFlag(theArg);
- aFlag.LowerCase();
- if (aFlag == "on"
- || aFlag == "1")
- {
- theIsOn = Standard_True;
- return Standard_True;
- }
- else if (aFlag == "off"
- || aFlag == "0")
- {
- theIsOn = Standard_False;
- return Standard_True;
- }
- return Standard_False;
+ return Draw::ParseOnOff (theArg, theIsOn);
}
//=======================================================================
aNames.Value (aNames.Upper() - 0).ToCString(),
};
- Standard_Integer aNbParsed = ViewerTest::ParseColor (3, anArgVec, aChangeSet->Color);
+ Standard_Integer aNbParsed = Draw::ParseColor (3, anArgVec, aChangeSet->Color);
isOk = aNbParsed == 3;
aNames.Remove (aNames.Length());
aNames.Remove (aNames.Length());
|| anArg == "-boundarycolor")
{
Quantity_Color aColor;
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
- theArgVec + anArgIter + 1,
- aColor);
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aColor);
if (aNbParsed == 0)
{
Message::SendFail() << "Syntax error at '" << anArg << "'";
|| anArg == "-fb")
{
bool toEnable = true;
- if (!ViewerTest::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
+ if (!Draw::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
{
Message::SendFail() << "Error: wrong syntax at " << anArg;
return 1;
|| anArg == "-setfbcolor"
|| anArg == "-fbcolor")
{
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
- theArgVec + anArgIter + 1,
- aChangeSet->FreeBoundaryColor);
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aChangeSet->FreeBoundaryColor);
if (aNbParsed == 0)
{
Message::SendFail() << "Syntax error at '" << anArg << "'";
|| anArg == "-isoontriang")
{
bool toEnable = true;
- if (!ViewerTest::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
+ if (!Draw::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
{
Message::SendFail() << "Error: wrong syntax at " << anArg;
return 1;
|| anArg == "-faceedges")
{
bool toEnable = true;
- if (!ViewerTest::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
+ if (!Draw::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
{
Message::SendFail() << "Error: wrong syntax at " << anArg;
return 1;
{
bool toDrawOutline = true;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toDrawOutline))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toDrawOutline))
{
++anArgIter;
}
{
bool toDrawEdges = true;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toDrawEdges))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toDrawEdges))
{
++anArgIter;
}
{
bool isQuadMode = true;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isQuadMode))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], isQuadMode))
{
++anArgIter;
}
|| anArg == "-edgecolor"
|| anArg == "-edgescolor")
{
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
- theArgVec + anArgIter + 1,
- aChangeSet->EdgeColor);
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aChangeSet->EdgeColor);
if (aNbParsed == 0)
{
Message::SendFail() << "Syntax error at '" << anArg << "'";
else if (anArg == "-dumpcompact")
{
toCompactDump = Standard_False;
- if (++anArgIter >= theArgNb && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toCompactDump))
+ if (++anArgIter >= theArgNb && Draw::ParseOnOff (theArgVec[anArgIter + 1], toCompactDump))
++anArgIter;
}
else if (anArg == "-dumpdepth")
{
bool toModulateBool = true;
if (anArgIter + 1 < theArgsNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toModulateBool))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toModulateBool))
{
++anArgIter;
}
Standard_EXPORT static void RemoveSelected();
- Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
-
- //! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
- //! Handles either color specified by name (single argument)
- //! or by RGB(A) components (3-4 arguments) in range 0..1.
- //! The result is stored in theColor on success.
- //! Returns number of handled arguments (1, 2, 3 or 4) or 0 on syntax error.
- static Standard_Integer ParseColor (const Standard_Integer theArgNb,
- const char* const* const theArgVec,
- Quantity_ColorRGBA& theColor)
- {
- return parseColor (theArgNb, theArgVec, theColor, true);
- }
-
- //! Parses RGB color argument(s).
- //! Returns number of handled arguments (1 or 3) or 0 on syntax error.
- static Standard_Integer ParseColor (const Standard_Integer theArgNb,
- const char* const* const theArgVec,
- Quantity_Color& theColor)
- {
- Quantity_ColorRGBA anRgba;
- const Standard_Integer aNbParsed = parseColor (theArgNb, theArgVec, anRgba, false);
- if (aNbParsed != 0)
- {
- theColor = anRgba.GetRGB();
- }
- return aNbParsed;
- }
-
//! redraws all defined views.
Standard_EXPORT static void RedrawAllViews();
TCollection_AsciiString& theName,
TCollection_AsciiString& theValue);
- //! Parses boolean argument.
- //! Handles either flag specified by 0|1 or on|off.
- Standard_EXPORT static Standard_Boolean ParseOnOff (Standard_CString theArg,
- Standard_Boolean& theIsOn);
-
//! Returns list of selected shapes.
Standard_EXPORT static void GetSelectedShapes (TopTools_ListOfShape& theShapes);
return parseZLayer (theArg, true, theLayer);
}
-private:
+public: //! @name deprecated methods
//! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
- //! Handles either color specified by name (single argument)
- //! or by RGB(A) components (3-4 arguments) in range 0..1.
- //! The result is stored in theColor on success.
- //! Returns number of handled arguments (1, 2, 3 or 4) or 0 on syntax error.
- Standard_EXPORT static Standard_Integer parseColor (Standard_Integer theArgNb,
- const char* const* theArgVec,
- Quantity_ColorRGBA& theColor,
- bool theToParseAlpha);
+ Standard_DEPRECATED("Method has been moved to Draw::ParseColor()")
+ Standard_EXPORT static Standard_Integer ParseColor (const Standard_Integer theArgNb,
+ const char* const* const theArgVec,
+ Quantity_ColorRGBA& theColor);
+
+ //! Parses RGB color argument(s).
+ //! Returns number of handled arguments (1 or 3) or 0 on syntax error.
+ Standard_DEPRECATED("Method has been moved to Draw::ParseColor()")
+ Standard_EXPORT static Standard_Integer ParseColor (const Standard_Integer theArgNb,
+ const char* const* const theArgVec,
+ Quantity_Color& theColor);
+
+ //! Parses boolean argument.
+ //! Handles either flag specified by 0|1 or on|off.
+ Standard_DEPRECATED("Method has been moved to Draw::ParseOnOff()")
+ Standard_EXPORT static Standard_Boolean ParseOnOff (Standard_CString theArg,
+ Standard_Boolean& theIsOn);
+
+ Standard_DEPRECATED("Method has been moved to Quantity_Color::ColorFromName()")
+ Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
+
+private:
//! Parses ZLayer name.
//! @param theArg [in] layer name, enumeration alias or index (of existing Layer)
false);
const Standard_Integer aNumberOfAvailableArguments = aNumberOfArguments - theArgumentIndex;
TheColor aColor;
- const Standard_Integer aNumberOfParsedArguments = ViewerTest::ParseColor (aNumberOfAvailableArguments,
- &aRawStringArguments[theArgumentIndex],
- aColor);
+ const Standard_Integer aNumberOfParsedArguments = Draw::ParseColor (aNumberOfAvailableArguments,
+ &aRawStringArguments[theArgumentIndex],
+ aColor);
if (aNumberOfParsedArguments == 0)
{
return false;
theColorValues->Size() >= 2 ? theColorValues->Value (2).ToCString() : "",
theColorValues->Size() >= 3 ? theColorValues->Value (3).ToCString() : ""
};
- return ViewerTest::ParseColor (theColorValues->Size(), anArgs, theColor) != 0;
+ return Draw::ParseColor (theColorValues->Size(), anArgs, theColor) != 0;
}
static bool convertToDatumPart (const TCollection_AsciiString& theValue,
Standard_Boolean toHideLabels = Standard_True;
if (aValues->Size() == 1)
{
- ViewerTest::ParseOnOff (aValues->First().ToCString(), toHideLabels);
+ Draw::ParseOnOff (aValues->First().ToCString(), toHideLabels);
}
else if (aValues->Size() != 0)
{
Standard_Boolean toHideArrows = Standard_True;
if (aValues->Size() == 1)
{
- ViewerTest::ParseOnOff (aValues->First().ToCString(), toHideArrows);
+ Draw::ParseOnOff (aValues->First().ToCString(), toHideArrows);
}
else if (aValues->Size() != 0)
{
else if (aParam == "-color")
{
Quantity_Color aColor;
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgsNb - anArgIt - 1,
- theArgVec + anArgIt + 1,
- aColor);
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgsNb - anArgIt - 1,
+ theArgVec + anArgIt + 1,
+ aColor);
if (aNbParsed == 0)
{
Message::SendFail() << "Syntax error at '" << aParam << "'";
|| aParam == "-subtitlecolor")
{
Quantity_Color aColor;
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgsNb - anArgIt - 1,
- theArgVec + anArgIt + 1,
- aColor);
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgsNb - anArgIt - 1,
+ theArgVec + anArgIt + 1,
+ aColor);
if (aNbParsed == 0)
{
Message::SendFail() << "Syntax error at '" << aParam << "'";
{
toShowHiddenEdges = true;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toShowHiddenEdges))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toShowHiddenEdges))
{
++anArgIter;
}
{
toShowCNEdges = true;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toShowCNEdges))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toShowCNEdges))
{
++anArgIter;
}
const TCollection_AsciiString aName (argv[anArgIter++]);
Handle(AIS_MultipleConnectedInteractive) aMultiConObject;
TCollection_AsciiString aColorString (argv[argc-1]);
- Standard_CString aColorName = "";
+ Quantity_Color aColor;
Standard_Boolean hasColor = Standard_False;
if (aColorString.Search ("color=") != -1)
{
hasColor = Standard_True;
aColorString.Remove (1, 6);
- aColorName = aColorString.ToCString();
+ if (!Quantity_Color::ColorFromName (aColorString.ToCString(), aColor))
+ {
+ Message::SendFail() << "Syntax error at " << aColorString;
+ return 1;
+ }
}
const Standard_Integer aNbShapes = hasColor ? (argc - 1) : argc;
anObject = aConnectedOrig;
aContext->Load (anObject);
- anObject->SetColor (ViewerTest::GetColorFromName (aColorName));
+ anObject->SetColor (aColor);
}
if (aMultiConObject.IsNull())
{
bool aVal = true;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff(theArgVec[anArgIter + 1], aVal))
+ && Draw::ParseOnOff(theArgVec[anArgIter + 1], aVal))
{
++anArgIter;
}
}
}
if (anObjNames.Size() < 2
- || !ViewerTest::ParseOnOff (anObjNames.Last().ToCString(), toTurnOn))
+ || !Draw::ParseOnOff (anObjNames.Last().ToCString(), toTurnOn))
{
Message::SendFail ("Syntax error: wrong number of arguments");
return 1;
return 1;
}
- ViewerTest::ParseOnOff (theArgVec[anArgIt], anIsCompositeCurve);
+ Draw::ParseOnOff (theArgVec[anArgIt], anIsCompositeCurve);
}
else if (aParam == "-plane")
{
{
bool toEnable = true;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
{
++anArgIter;
}
{
bool toEnable = true;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
{
++anArgIter;
}
TCollection_AsciiString aParam (theArgs[anArgIter]);
aParam.LowerCase();
if (anArgIter == 2
- && ViewerTest::ParseOnOff (aParam.ToCString(), isOn))
+ && Draw::ParseOnOff (aParam.ToCString(), isOn))
{
continue;
}
{
isOriented = Standard_True;
if (anArgIter + 1 < theArgNum
- && ViewerTest::ParseOnOff (theArgs[anArgIter + 1], isOriented))
+ && Draw::ParseOnOff (theArgs[anArgIter + 1], isOriented))
{
++anArgIter;
}
}
else if (aParam.IsEqual ("-color"))
{
- theAspect->SetCommonColor (Quantity_Color (ViewerTest::GetColorFromName (theArgVec[++anIt])));
+ Quantity_Color aColor;
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgNum - anIt - 1,
+ theArgVec + anIt + 1,
+ aColor);
+ anIt += aNbParsed;
+ if (aNbParsed == 0)
+ {
+ Message::SendFail() << "Error: wrong syntax at '" << aParam << "'";
+ return 1;
+ }
+ theAspect->SetCommonColor (aColor);
}
else if (aParam.IsEqual ("-extension"))
{
{
ViewerTest_EventManager::ToExitOnCloseView() = true;
if (anArgIt + 1 < theArgsNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIt + 1], ViewerTest_EventManager::ToExitOnCloseView()))
+ && Draw::ParseOnOff (theArgVec[anArgIt + 1], ViewerTest_EventManager::ToExitOnCloseView()))
{
++anArgIt;
}
{
ViewerTest_EventManager::ToCloseViewOnEscape() = true;
if (anArgIt + 1 < theArgsNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIt + 1], ViewerTest_EventManager::ToCloseViewOnEscape()))
+ && Draw::ParseOnOff (theArgVec[anArgIt + 1], ViewerTest_EventManager::ToCloseViewOnEscape()))
{
++anArgIt;
}
{
bool toEnable = true;
if (anArgIt + 1 < theArgsNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIt + 1], toEnable))
+ && Draw::ParseOnOff (theArgVec[anArgIt + 1], toEnable))
{
++anArgIt;
}
}
else if (anArg == "-showhidden"
&& anArgIter + 1 < argc
- && ViewerTest::ParseOnOff (argv[anArgIter + 1], toShowHidden))
+ && Draw::ParseOnOff (argv[anArgIter + 1], toShowHidden))
{
++anArgIter;
hasShowHiddenArg = Standard_True;
continue;
}
else if (!hasHlrOnArg
- && ViewerTest::ParseOnOff (argv[anArgIter], isHLROn))
+ && Draw::ParseOnOff (argv[anArgIter], isHLROn))
{
hasHlrOnArg = Standard_True;
continue;
}
// old syntax
else if (!hasShowHiddenArg
- && ViewerTest::ParseOnOff(argv[anArgIter], toShowHidden))
+ && Draw::ParseOnOff(argv[anArgIter], toShowHidden))
{
hasShowHiddenArg = Standard_True;
continue;
{
isImmediateUpdate = Standard_True;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isImmediateUpdate))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], isImmediateUpdate))
{
++anArgIter;
}
else if (aFlag == "-colorlabel"
|| aFlag == "-colorlabels")
{
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
- theArgVec + anArgIter + 1,
- aLabelsColor);
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aLabelsColor);
if (aNbParsed == 0)
{
Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
}
else if (aFlag == "-colorarrowx")
{
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
- theArgVec + anArgIter + 1,
- anArrowColorX);
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ anArrowColorX);
if (aNbParsed == 0)
{
Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
}
else if (aFlag == "-colorarrowy")
{
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
- theArgVec + anArgIter + 1,
- anArrowColorY);
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ anArrowColorY);
if (aNbParsed == 0)
{
Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
}
else if (aFlag == "-colorarrowz")
{
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
- theArgVec + anArgIter + 1,
- anArrowColorZ);
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ anArrowColorZ);
if (aNbParsed == 0)
{
Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
}
Standard_Boolean IsLog;
- if (!ViewerTest::ParseOnOff(theArgVec[++anArgIter], IsLog))
+ if (!Draw::ParseOnOff(theArgVec[++anArgIter], IsLog))
{
Message::SendFail() << "Syntax error at argument '" << anArg << "'";
return 1;
else if (aFlag == "-colorrange")
{
Quantity_Color aColorMin, aColorMax;
- Standard_Integer aNbParsed1 = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
- theArgVec + (anArgIter + 1),
- aColorMin);
+ Standard_Integer aNbParsed1 = Draw::ParseColor (theArgNb - (anArgIter + 1),
+ theArgVec + (anArgIter + 1),
+ aColorMin);
anArgIter += aNbParsed1;
- Standard_Integer aNbParsed2 = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
- theArgVec + (anArgIter + 1),
- aColorMax);
+ Standard_Integer aNbParsed2 = Draw::ParseColor (theArgNb - (anArgIter + 1),
+ theArgVec + (anArgIter + 1),
+ aColorMax);
anArgIter += aNbParsed2;
if (aNbParsed1 == 0
|| aNbParsed2 == 0)
{
Standard_Boolean toEnable = Standard_True;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff(theArgVec[anArgIter + 1], toEnable))
+ && Draw::ParseOnOff(theArgVec[anArgIter + 1], toEnable))
{
++anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
{
++anArgIter;
}
}
Quantity_Color aColor;
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
- theArgVec + (anArgIter + 1),
- aColor);
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - (anArgIter + 1),
+ theArgVec + (anArgIter + 1),
+ aColor);
if (aNbParsed == 0)
{
Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
toEnable = (aLabAtBorder == 1);
}
else if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
{
++anArgIter;
}
for (;;)
{
Quantity_Color aColor;
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - (anArgIter + 1),
- theArgVec + (anArgIter + 1),
- aColor);
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - (anArgIter + 1),
+ theArgVec + (anArgIter + 1),
+ aColor);
if (aNbParsed == 0)
{
break;
{
Standard_Boolean toShowWarns = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toShowWarns))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toShowWarns))
{
--anArgIter;
}
{
Standard_Boolean toShow = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toShow))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toShow))
{
--anArgIter;
}
{
Standard_Boolean toSuppress = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toSuppress))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toSuppress))
{
--anArgIter;
}
{
Standard_Boolean toSync = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toSync))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toSync))
{
--anArgIter;
}
else if (anArgCase == "-debug")
{
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnableDebug))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnableDebug))
{
--anArgIter;
}
aDefCaps->contextDebug = toEnableDebug;
}
- else if (ViewerTest::ParseOnOff (anArg, toEnableDebug)
+ else if (Draw::ParseOnOff (anArg, toEnableDebug)
&& (anArgIter + 1 == theArgNb))
{
// simple alias to turn on almost everything
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toDisable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toDisable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toDisable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
{
++anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
{
++anArgIter;
}
{
ViewerTest_EventManager::ToExitOnCloseView() = true;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], ViewerTest_EventManager::ToExitOnCloseView()))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], ViewerTest_EventManager::ToExitOnCloseView()))
{
++anArgIter;
}
{
ViewerTest_EventManager::ToCloseViewOnEscape() = true;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], ViewerTest_EventManager::ToCloseViewOnEscape()))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], ViewerTest_EventManager::ToCloseViewOnEscape()))
{
++anArgIter;
}
{
toAllowOverlap = true;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toAllowOverlap))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toAllowOverlap))
{
++anArgIter;
}
else if (anArgCase == "-mode")
{
if (anArgIt + 1 < theArgsNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIt + 1], is2dMode))
+ && Draw::ParseOnOff (theArgVec[anArgIt + 1], is2dMode))
{
++anArgIt;
}
}
- else if (ViewerTest::ParseOnOff (theArgVec[anArgIt], is2dMode))
+ else if (Draw::ParseOnOff (theArgVec[anArgIt], is2dMode))
{
//
}
aChangeArg.LowerCase();
Standard_Boolean toEnable = Standard_True;
- if (ViewerTest::ParseOnOff (aChangeArgs[0], toEnable))
+ if (Draw::ParseOnOff (aChangeArgs[0], toEnable))
{
aClipPlane->SetOn (toEnable);
}
return 1;
}
- if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
+ if (Draw::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->SetCapping (toEnable);
anArgIter += 1;
return 1;
}
- if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
+ if (Draw::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->SetUseObjectMaterial (toEnable == Standard_True);
anArgIter += 1;
return 1;
}
- if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
+ if (Draw::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->SetUseObjectTexture (toEnable == Standard_True);
anArgIter += 1;
return 1;
}
- if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
+ if (Draw::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->SetUseObjectShader (toEnable == Standard_True);
anArgIter += 1;
|| aChangeArg == "color")
{
Quantity_Color aColor;
- Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
- aChangeArgs + 1,
- aColor);
+ Standard_Integer aNbParsed = Draw::ParseColor (aNbChangeArgs - 1,
+ aChangeArgs + 1,
+ aColor);
if (aNbParsed == 0)
{
Message::SendFail ("Syntax error: need more arguments");
{
bool toLockUp = true;
if (++anArgIter < theArgsNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toLockUp))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toLockUp))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
{
Standard_Boolean toDisable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toDisable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toDisable))
{
--anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
++anArgIter;
bool toTurnOn = true;
if (anArgIter >= theArgsNb
- || !ViewerTest::ParseOnOff (theArgVec[anArgIter], toTurnOn))
+ || !Draw::ParseOnOff (theArgVec[anArgIter], toTurnOn))
{
Message::SendFail() << "Syntax error at '" << anArg << "'";
return 1;
|| anArgCase.IsEqual ("-COLOR")
|| anArgCase.IsEqual ("-COLOUR"))
{
- if (++anArgIt >= theArgsNb
+ Quantity_Color aColor;
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgsNb - anArgIt - 1,
+ theArgVec + anArgIt + 1,
+ aColor);
+ anArgIt += aNbParsed;
+ if (aNbParsed == 0
|| aLightCurr.IsNull())
{
Message::SendFail() << "Syntax error at argument '" << anArg << "'";
return 1;
}
-
- TCollection_AsciiString anArgNext (theArgVec[anArgIt]);
- anArgNext.UpperCase();
- const Quantity_Color aColor = ViewerTest::GetColorFromName (anArgNext.ToCString());
aLightCurr->SetColor (aColor);
}
else if (anArgCase.IsEqual ("POS")
Standard_Boolean isHeadLight = Standard_True;
if (anArgIt + 1 < theArgsNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIt + 1], isHeadLight))
+ && Draw::ParseOnOff (theArgVec[anArgIt + 1], isHeadLight))
{
++anArgIt;
}
bool isRayTrace = true;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isRayTrace))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], isRayTrace))
{
++anArgIter;
}
bool isRaster = true;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isRaster))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], isRaster))
{
++anArgIter;
}
}
aParams.ToEnableDepthPrepass = Standard_True;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], aParams.ToEnableDepthPrepass))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], aParams.ToEnableDepthPrepass))
{
++anArgIter;
}
}
aParams.ToEnableAlphaToCoverage = Standard_True;
if (anArgIter + 1 < theArgNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], aParams.ToEnableAlphaToCoverage))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], aParams.ToEnableAlphaToCoverage))
{
++anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
- && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ && !Draw::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
TCollection_AsciiString aStateStr(theArgVec[anArgIter]);
aStateStr.LowerCase();
bool toEnable = true;
- if (ViewerTest::ParseOnOff (aStateStr.ToCString(), toEnable))
+ if (Draw::ParseOnOff (aStateStr.ToCString(), toEnable))
{
aState = toEnable ? Graphic3d_RenderingParams::FrustumCulling_On : Graphic3d_RenderingParams::FrustumCulling_Off;
}
return 0;
}
else if (theArgsNb != 2
- || !ViewerTest::ParseOnOff (theArgVec[1], toEnable))
+ || !Draw::ParseOnOff (theArgVec[1], toEnable))
{
Message::SendFail ("Syntax error: wrong number of parameters");
return 1;
{
Standard_Boolean toEnable = Standard_True;
if (anArgIter + 1 < theArgsNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
{
++anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (anArgIter + 1 < theArgsNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
{
++anArgIter;
}
{
Standard_Boolean toEnable = Standard_True;
if (anArgIter + 1 < theArgsNb
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toEnable))
{
++anArgIter;
}
}
Quantity_Color aColor;
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgsNb - anArgIter - 1,
- theArgVec + anArgIter + 1,
- aColor);
+ Standard_Integer aNbParsed = Draw::ParseColor (theArgsNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aColor);
if (aNbParsed == 0)
{
Message::SendFail ("Syntax error: need more arguments");
|| anArg == "-innercolor"
|| anArg == "-textcolor")
{
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theNbArgs - anArgIter - 1,
- theArgVec + anArgIter + 1,
- aColorRgb);
+ Standard_Integer aNbParsed = Draw::ParseColor (theNbArgs - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aColorRgb);
if (aNbParsed == 0)
{
Message::SendFail() << "Syntax error at '" << anArg << "'";
{
bool toShow = true;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toShow))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toShow))
{
++anArgIter;
}
{
bool isOn = true;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isOn))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], isOn))
{
++anArgIter;
}
{
myToPrefixDocName = Standard_True;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], myToPrefixDocName))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], myToPrefixDocName))
{
++anArgIter;
}
{
myToGetNames = Standard_True;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], myToGetNames))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], myToGetNames))
{
++anArgIter;
}
{
myToExplore = Standard_True;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], myToExplore))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], myToExplore))
{
++anArgIter;
}
Standard_Integer theNbArgs,
const char** theArgVec)
{
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theNbArgs - theArgIter - 1,
- theArgVec + theArgIter + 1,
- theColor);
+ Standard_Integer aNbParsed = Draw::ParseColor (theNbArgs - theArgIter - 1,
+ theArgVec + theArgIter + 1,
+ theColor);
if (aNbParsed == 0)
{
std::cout << "Syntax error at '" << theArgVec[theArgIter] << "'\n";
else if (!isColorDefined)
{
isColorDefined = true;
- Standard_Integer aNbParsed = ViewerTest::ParseColor (argc - anArgIter,
- argv + anArgIter,
- aColor);
+ Standard_Integer aNbParsed = Draw::ParseColor (argc - anArgIter,
+ argv + anArgIter,
+ aColor);
if (aNbParsed == 0)
{
std::cout << "Syntax error at '" << argv[anArgIter] << "'\n";
}
Quantity_ColorRGBA aColRGBA;
- Standard_Integer aNbParsed = ViewerTest::ParseColor (argc - 2, argv + 2, aColRGBA);
+ Standard_Integer aNbParsed = Draw::ParseColor (argc - 2, argv + 2, aColRGBA);
if (aNbParsed != argc - 2)
{
std::cout << "Syntax error at '" << argv[2] << "'\n";
}
Quantity_ColorRGBA aColRGBA;
- Standard_Integer aNbParsed = ViewerTest::ParseColor (argc - 2, argv + 2, aColRGBA);
+ Standard_Integer aNbParsed = Draw::ParseColor (argc - 2, argv + 2, aColRGBA);
if (aNbParsed != argc - 2)
{
std::cout << "Syntax error at '" << argv[2] << "'\n";
}
else
{
- Standard_Integer aNbParsed = ViewerTest::ParseColor (argc - anArgIter,
- argv + anArgIter,
- aColRGBA);
+ Standard_Integer aNbParsed = Draw::ParseColor (argc - anArgIter,
+ argv + anArgIter,
+ aColRGBA);
if (aNbParsed == 0)
{
std::cout << "Syntax error at '" << argv[anArgIter] << "'\n";
|| anArg == "-albedo")
{
Quantity_ColorRGBA aColorRGBA;
- Standard_Integer aNbParsed = ViewerTest::ParseColor (theNbArgs - anArgIter - 1,
- theArgVec + anArgIter + 1,
- aColorRGBA);
+ Standard_Integer aNbParsed = Draw::ParseColor (theNbArgs - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aColorRGBA);
if (aNbParsed == 0)
{
std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
aMatPbr.IsDefined = true;
bool isDoubleSided = true;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isDoubleSided))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], isDoubleSided))
{
++anArgIter;
}
{
toUseExistingDoc = Standard_True;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toUseExistingDoc))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toUseExistingDoc))
{
++anArgIter;
}
{
isParallel = Standard_True;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isParallel))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], isParallel))
{
++anArgIter;
}
{
toForceUVExport = true;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toForceUVExport))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toForceUVExport))
{
++anArgIter;
}
{
toCreateCompOfTris = true;
if (anArgIter + 1 < theArgc
- && ViewerTest::ParseOnOff (theArgv[anArgIter + 1], toCreateCompOfTris))
+ && Draw::ParseOnOff (theArgv[anArgIter + 1], toCreateCompOfTris))
{
++anArgIter;
}
{
isSinglePrecision = Standard_True;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isSinglePrecision))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], isSinglePrecision))
{
++anArgIter;
}
{
toUseExistingDoc = Standard_True;
if (anArgIter + 1 < theNbArgs
- && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toUseExistingDoc))
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toUseExistingDoc))
{
++anArgIter;
}
}
else if (aParam == "-color")
{
- aColor = ViewerTest::GetColorFromName(argv[anIdx]);
+ if (!Quantity_Color::ColorFromName (argv[anIdx], aColor))
+ {
+ Message::SendFail() << "Syntax error at " << aParam;
+ return 1;
+ }
}
else if (aParam == "-arrowpart")
{