1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0031709: Draw Harness - move methods ViewerTest::ParseOnOff()/ParseColor() to package Draw

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.
This commit is contained in:
kgv
2020-08-12 15:58:22 +03:00
committed by bugmaster
parent 76fada6839
commit dae2a92241
14 changed files with 851 additions and 774 deletions

View File

@@ -12,6 +12,7 @@
// 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>
@@ -20,7 +21,6 @@
#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>
@@ -54,42 +54,52 @@ static Standard_Integer GetLine(OSD_File& aFile,TCollection_AsciiString& aLine);
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,
@@ -119,12 +129,16 @@ 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());
@@ -482,6 +496,17 @@ Standard_Boolean Resource_Manager::Find(const Standard_CString aResource) const
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 :

View File

@@ -41,10 +41,9 @@ DEFINE_STANDARD_HANDLE(Resource_Manager, Standard_Transient)
//! 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
@@ -58,8 +57,16 @@ public:
//! 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.
@@ -67,7 +74,11 @@ public:
//! 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;
@@ -105,20 +116,12 @@ public:
//! or file doesn't exist returns empty string.
Standard_EXPORT static void GetResourcePath (TCollection_AsciiString& aPath, const Standard_CString aName, const Standard_Boolean isUserDefaults);
DEFINE_STANDARD_RTTIEXT(Resource_Manager,Standard_Transient)
protected:
private:
Standard_EXPORT void Load (TCollection_AsciiString& aPath, Resource_DataMapOfAsciiStringAsciiString& aMap);
Standard_EXPORT void Load (const TCollection_AsciiString& thePath,
Resource_DataMapOfAsciiStringAsciiString& aMap);
private:
TCollection_AsciiString myName;
Resource_DataMapOfAsciiStringAsciiString myRefMap;
@@ -126,13 +129,6 @@ private:
Resource_DataMapOfAsciiStringExtendedString myExtStrMap;
Standard_Boolean myVerbose;
};
#endif // _Resource_Manager_HeaderFile