0030592: Draw Harness, ViewerTest - provide vbackground command unifying vsetbg,...
authortiv <tiv@opencascade.com>
Mon, 22 Apr 2019 07:51:22 +0000 (10:51 +0300)
committerbugmaster <bugmaster@opencascade.com>
Mon, 22 Apr 2019 16:31:24 +0000 (19:31 +0300)
A new command vbackground is created. Old background commands are made aliases for the newly created command (including vsetdefaultbg).
Tests are modified using newly added command vbackground.

54 files changed:
samples/tcl/ANC101.tcl
samples/tcl/MBBGehauseRohteil.tcl
samples/tcl/Penrose.tcl
samples/tcl/dimensions.tcl
samples/tcl/materials.tcl
samples/tcl/pencil.tcl
samples/tcl/raytrace.tcl
samples/tcl/snowflake.tcl
src/ViewerTest/ViewerTest.cxx
src/ViewerTest/ViewerTest_CmdParser.cxx
src/ViewerTest/ViewerTest_CmdParser.hxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/bugs/vis/bug1188
tests/bugs/vis/bug21747_1
tests/bugs/vis/bug21747_10
tests/bugs/vis/bug21747_11
tests/bugs/vis/bug21747_12
tests/bugs/vis/bug21747_13
tests/bugs/vis/bug21747_14
tests/bugs/vis/bug21747_15
tests/bugs/vis/bug21747_16
tests/bugs/vis/bug21747_17
tests/bugs/vis/bug21747_2
tests/bugs/vis/bug21747_3
tests/bugs/vis/bug21747_4
tests/bugs/vis/bug21747_5
tests/bugs/vis/bug21747_6
tests/bugs/vis/bug21747_7
tests/bugs/vis/bug21747_8
tests/bugs/vis/bug21747_9
tests/bugs/vis/bug22906
tests/bugs/vis/bug23102
tests/bugs/vis/bug23363
tests/bugs/vis/bug25475
tests/bugs/vis/bug25775
tests/bugs/vis/bug25778
tests/bugs/vis/bug26404
tests/bugs/vis/bug26599
tests/bugs/vis/bug27836
tests/bugs/vis/bug29787
tests/bugs/vis/bug29847
tests/v3d/glsl/interior2
tests/v3d/glsl/msaa
tests/v3d/glsl/outline1
tests/v3d/glsl/outline2
tests/v3d/glsl/tiles
tests/v3d/materials/bug24855
tests/v3d/raytrace/bug24130
tests/v3d/raytrace/bug24819
tests/v3d/raytrace/bug25201
tests/v3d/raytrace/bug26617
tests/v3d/raytrace/refraction
tests/v3d/raytrace/textures
tests/v3d/transparency/blend

index 2bfb1ea..818f3eb 100644 (file)
@@ -276,7 +276,7 @@ blend result _model 2 _model_161
 # Show result
 pload VISUALIZATION
 vinit Driver1/Viewer1/View1
-vsetcolorbg 200 200 255
+vbackground -color 0.784314 0.784314 1
 vdisplay -dispMode 1 result
 vfit
 vaspects result -setFaceBoundaryDraw 1 -mostContinuity c2
index da5de6b..7d61a04 100644 (file)
@@ -262,7 +262,7 @@ unifysamedom result  p_1
 # Show result
 pload VISUALIZATION
 vinit Driver1/Viewer1/View1
-vsetcolorbg 200 200 255
+vbackground -color 0.784314 0.784314 1
 vdisplay -dispMode 1 result
 vfit
 vaspects result -setFaceBoundaryDraw 1
index 292813f..4b284a5 100644 (file)
@@ -53,7 +53,7 @@ for {set i 1} {$i <= 1} {incr i} {
 
 # prepare a view
 vinit Penrose w=1024 h=512
-vsetcolorbg 255 255 255
+vbackground -color WHITE
 vrenderparams -rayTrace -fsaa on -reflections off -shadows off
 
 # set camera position and adjust lights
index d05f473..e13b49b 100644 (file)
@@ -19,7 +19,7 @@ restore $aBotLoc b
 vinit View1 w=768 h=768
 vclear
 vsetdispmode 0
-vsetcolorbg 255 255 255
+vbackground -color WHITE
 vbottom
 
 puts "Getting cut projection..."
index c3d4867..2ea7a7a 100644 (file)
@@ -69,7 +69,7 @@ vclose ALL
 vinit View1 w=768 h=768
 vtop
 vglinfo
-vsetgradientbg 180 200 255 180 180 180 2
+vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 
 vlight -change 0 -dir 0.577 -0.577 -0.577
 vrenderparams -msaa 8
index 6bc635b..904cadd 100644 (file)
@@ -59,7 +59,7 @@ XShow D
 vfit
 vsetdispmode 1
 vrenderparams -msaa 8
-vsetcolorbg 255 255 255
+vbackground -color WHITE
 
 #param write.iges.brep.mode 1
 #WriteIges D d:/pencil3.igs
index aacb668..c9ab75a 100644 (file)
@@ -30,7 +30,7 @@ vsettransparency glass 0.6
 vlight new spot pos -100 -100 300
 
 # set white background and fit view
-vsetcolorbg 255 255 255
+vbackground -color WHITE
 vfit
 
 # set ray tracing
index f295508..b9e4baf 100644 (file)
@@ -129,7 +129,7 @@ vrenderparams -msaa 8
 vsetcolor snowflake 0 0 0 
 vsetcolor lines 0 0 0 
 vsetcolor text 0 0 0 
-vsetcolorbg 255 255 255
+vbackground -color WHITE
 vtop
 vfit
 
index bee28db..47604ef 100644 (file)
@@ -5965,7 +5965,7 @@ static int VBsdf (Draw_Interpretor& theDI,
 
   ViewerTest_CmdParser aCmd;
 
-  aCmd.AddDescription ("Adjusts parameters of material BSDF:");
+  aCmd.SetDescription ("Adjusts parameters of material BSDF:");
 
   aCmd.AddOption ("print|echo|p", "Prints BSDF");
 
@@ -6007,7 +6007,7 @@ static int VBsdf (Draw_Interpretor& theDI,
   }
 
   // find object
-  TCollection_AsciiString aName (aCmd.Arg ("", 0).c_str());
+  TCollection_AsciiString aName (aCmd.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, 0).c_str());
   Handle(AIS_InteractiveObject) anIObj;
   if (!GetMapOfAIS().Find2 (aName, anIObj))
   {
index a53c059..fbdb9c2 100644 (file)
 #include <ViewerTest_CmdParser.hxx>
 
 #include <Draw.hxx>
+#include <ViewerTest.hxx>
 
+#include <algorithm>
 #include <iostream>
-#include <sstream>
-#include <string>
 
+namespace
+{
+
+  //! Converts the given string to lowercase
+  //! @param theString the string to be converted
+  //! @return a converted string (a string in lowercase)
+  static std::string toLowerCase (std::string theString)
+  {
+    std::transform (theString.begin(), theString.end(), theString.begin(), ::LowerCase);
+    return theString;
+  }
+
+  //! Converts the vector of std::strings to a vector of pointers to its data
+  //! @param theStringList the vector of strings to be converted
+  //! @return a vector of pointers to the data of given strings
+  static std::vector<const char*> convertToRawStringList (const std::vector<std::string>& theStringList)
+  {
+    const std::size_t        aListSize = theStringList.size();
+    std::vector<const char*> aRawStringList (aListSize);
+    for (std::size_t anIndex = 0; anIndex < aListSize; ++anIndex)
+    {
+      aRawStringList[anIndex] = theStringList[anIndex].c_str();
+    }
+    return aRawStringList;
+  }
+
+} // namespace
+
+const std::size_t ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY = (std::numeric_limits<std::size_t>::max)();
+
+const std::size_t ViewerTest_CmdParser::THE_HELP_COMMAND_OPTION_KEY = 0;
 
 //===============================================================================================
-//function : ViewerTest_CmdParser
-//purpose  :
+// function : ViewerTest_CmdParser
+// purpose  :
 //===============================================================================================
-ViewerTest_CmdParser::ViewerTest_CmdParser()
+ViewerTest_CmdParser::ViewerTest_CmdParser (const std::string& theDescription) : myDescription (theDescription)
 {
-  ViewerTest_CmdOption aDefaultOption;
-  myArgumentStorage.push_back (aDefaultOption);
-  myArgumentLists[""] = 0;
-  myArgumentLists["help"] = 0;
+  AddOption ("help|h", "Prints a short description of the command and its options.");
 }
 
 //===============================================================================================
-//function : AddOption
-//purpose  :
+// function : AddOption
+// purpose  :
 //===============================================================================================
-void ViewerTest_CmdParser::AddOption (const std::string& theOptionNames, const std::string& theOptionDescription)
+ViewerTest_CommandOptionKey ViewerTest_CmdParser::AddOption (const std::string& theOptionNames,
+                                                             const std::string& theOptionDescription)
 {
-  ViewerTest_CmdOption aNewOption;
+  CommandOption aNewOption;
 
   // extract option names
   std::vector<std::string> aNames;
-  std::stringstream aStream (theOptionNames);
-  std::string anItem;
+  std::stringstream        aStream (theOptionNames);
+  std::string              anItem;
   while (std::getline (aStream, anItem, '|'))
   {
-    std::transform (anItem.begin(), anItem.end(), anItem.begin(), ::LowerCase);
     if (!anItem.empty())
     {
       aNames.push_back (anItem);
     }
   }
 
-  aNewOption.Name        = aNames.front();
+  aNewOption.Name = aNames.front();
+  if (aNames.size() > 1)
+  {
+    const std::size_t aNumberOfAliases = aNames.size() - 1;
+
+    aNewOption.Aliases.reserve (aNumberOfAliases);
+    std::copy (aNames.begin() + 1, aNames.end(), std::back_inserter (aNewOption.Aliases));
+  }
   aNewOption.Description = theOptionDescription;
-  aNewOption.IsSet       = Standard_False;
 
-  myArgumentStorage.push_back (aNewOption);
+  const ViewerTest_CommandOptionKey aNewOptionKey = myOptionStorage.size();
+
+  myOptionStorage.push_back (aNewOption);
 
   std::vector<std::string>::const_iterator anIt = aNames.begin();
   for (; anIt != aNames.end(); ++anIt)
   {
-    myArgumentLists[*anIt] = (Standard_Integer) myArgumentStorage.size() - 1;
+    const std::string aNameInLowerCase = toLowerCase (*anIt);
+
+    myOptionMap[aNameInLowerCase] = aNewOptionKey;
   }
+
+  return aNewOptionKey;
 }
 
 //===============================================================================================
-//function : Help
-//purpose  :
+// function : PrintHelp
+// purpose  :
 //===============================================================================================
-void ViewerTest_CmdParser::Help()
+void ViewerTest_CmdParser::PrintHelp() const
 {
   std::cout << myDescription << std::endl;
-
-  std::vector<ViewerTest_CmdOption>::const_iterator anIt = myArgumentStorage.begin();
-  for (++anIt; anIt != myArgumentStorage.end(); ++anIt)
+  std::vector<CommandOption>::const_iterator anIt = myOptionStorage.begin();
+  for (++anIt; anIt != myOptionStorage.end(); ++anIt)
   {
-    std::cout << "\n    -" << (*anIt).Name << " : " << (*anIt).Description;
+    const CommandOption& aCommandOption = *anIt;
+    std::cout << "\n\t-" << aCommandOption.Name;
+    const OptionAliases& anAliases = aCommandOption.Aliases;
+    if (!anAliases.empty())
+    {
+      std::cout << " (-" << anAliases.front();
+      for (OptionAliases::const_iterator anAliasIterator = anAliases.begin() + 1; anAliasIterator != anAliases.end();
+           ++anAliasIterator)
+      {
+        std::cout << ", -" << *anAliasIterator;
+      }
+      std::cout << ")";
+    }
+    std::cout << " : " << aCommandOption.Description;
   }
-
   std::cout << std::endl;
 }
 
 //===============================================================================================
-//function : Parse
-//purpose  :
+// function : Parse
+// purpose  :
 //===============================================================================================
-void ViewerTest_CmdParser::Parse (Standard_Integer theArgsNb, const char** theArgVec)
+void ViewerTest_CmdParser::Parse (const Standard_Integer theArgsNb, const char* const* const theArgVec)
 {
-  Standard_Integer aCurrentOption = 0;
-
+  std::size_t aCurrentUsedOptionIndex = 0;
   for (Standard_Integer anIter = 1; anIter < theArgsNb; ++anIter)
   {
-    if (theArgVec[anIter][0] == '-' && !std::isdigit (theArgVec[anIter][1]))
+    const char* const anArgument = theArgVec[anIter];
+    if (anArgument[0] == '-' && !std::isdigit (anArgument[1]))
     {
-      std::string anOptionName (&theArgVec[anIter][1]);
-      std::transform (anOptionName.begin(), anOptionName.end(), anOptionName.begin(), ::LowerCase);
-
-      std::map<std::string, Standard_Integer>::iterator aMapIter = myArgumentLists.find (anOptionName);
-      if (aMapIter != myArgumentLists.end())
+      const std::string   anOptionName = toLowerCase (anArgument + 1);
+      OptionMap::iterator aMapIter     = myOptionMap.find (anOptionName);
+      if (aMapIter != myOptionMap.end())
       {
-        aCurrentOption = aMapIter->second;
-        myArgumentStorage[aCurrentOption].IsSet = true;
-        myArgumentStorage[aCurrentOption].Arguments.clear();
+        const ViewerTest_CommandOptionKey aCurrentUsedOptionKey = aMapIter->second;
+        aCurrentUsedOptionIndex                                 = addUsedOption (aCurrentUsedOptionKey);
       }
       else
       {
-        std::cerr << "Error: unknown argument '" << theArgVec[anIter] << "'\n";
+        std::cerr << "Error: unknown argument '" << anOptionName << "'\n";
+        return;
       }
     }
     else
     {
-      myArgumentStorage[aCurrentOption].Arguments.push_back (theArgVec[anIter]);
+      if (anIter == 1)
+      {
+        aCurrentUsedOptionIndex = addUsedOption (THE_UNNAMED_COMMAND_OPTION_KEY);
+      }
+      myOptionArgumentStorage[aCurrentUsedOptionIndex].push_back (anArgument);
     }
   }
 }
 
 //===============================================================================================
-//function : HasOption
-//purpose  :
+// function : GetOptionNameByKey
+// purpose  :
 //===============================================================================================
-Standard_Boolean ViewerTest_CmdParser::HasOption (const std::string& theOptionName, Standard_Integer theMandatoryArgsNb /*= 0*/, Standard_Boolean isFatal /*= Standard_False*/)
+std::string ViewerTest_CmdParser::GetOptionNameByKey (const ViewerTest_CommandOptionKey theOptionKey) const
 {
-  std::string aLowerName = theOptionName;
-  std::transform (aLowerName.begin(), aLowerName.end(), aLowerName.begin(), ::LowerCase);
+  if (theOptionKey == THE_UNNAMED_COMMAND_OPTION_KEY)
+  {
+    return "Unnamed";
+  }
+  return myOptionStorage[theOptionKey].Name;
+}
 
-  Standard_Boolean aResult = Standard_False;
-  std::map<std::string, Standard_Integer>::iterator aMapIter = myArgumentLists.find (aLowerName);
-  if (aMapIter != myArgumentLists.end())
+//===============================================================================================
+// function : GetUsedOptions
+// purpose  :
+//===============================================================================================
+ViewerTest_CommandOptionKeySet ViewerTest_CmdParser::GetUsedOptions() const
+{
+  ViewerTest_CommandOptionKeySet aUsedOptions;
+  for (UsedOptionMap::const_iterator aUsedOptionMapIterator = myUsedOptionMap.begin();
+       aUsedOptionMapIterator != myUsedOptionMap.end();
+       ++aUsedOptionMapIterator)
   {
-    Standard_Integer anOption = aMapIter->second;
-    aResult = myArgumentStorage[anOption].Arguments.size() >= static_cast<size_t> (theMandatoryArgsNb);
-    if (isFatal && !aResult && myArgumentStorage[anOption].IsSet)
-    {
-      std::cerr << "Error: wrong syntax at argument '" << theOptionName << "'\n";
-    }
+    aUsedOptions.insert (aUsedOptionMapIterator->first);
+  }
+  return aUsedOptions;
+}
 
-    aResult &= myArgumentStorage[anOption].IsSet;
+//===============================================================================================
+// function : HasNoOption
+// purpose  :
+//===============================================================================================
+bool ViewerTest_CmdParser::HasNoOption() const
+{
+  return myUsedOptionMap.empty();
+}
+
+//===============================================================================================
+// function : HasUnnamedOption
+// purpose  :
+//===============================================================================================
+bool ViewerTest_CmdParser::HasUnnamedOption() const
+{
+  return myUsedOptionMap.find (THE_UNNAMED_COMMAND_OPTION_KEY) != myUsedOptionMap.end();
+}
+
+//===============================================================================================
+// function : HasNoUnnamedOption
+// purpose  :
+//===============================================================================================
+bool ViewerTest_CmdParser::HasOnlyUnnamedOption() const
+{
+  return HasUnnamedOption() && (myUsedOptionMap.size() == 1);
+}
+
+//===============================================================================================
+// function : HasOption
+// purpose  :
+//===============================================================================================
+bool ViewerTest_CmdParser::HasOption (const std::string& theOptionName,
+                                      const std::size_t  theMandatoryArgsNb /* = 0 */,
+                                      const bool         isFatal /* = false */) const
+{
+  ViewerTest_CommandOptionKey anOptionKey;
+  if (!findOptionKey (theOptionName, anOptionKey))
+  {
+    return false;
   }
+  return HasOption (anOptionKey, theMandatoryArgsNb, isFatal);
+}
 
+//===============================================================================================
+// function : HasOption
+// purpose  :
+//===============================================================================================
+bool ViewerTest_CmdParser::HasOption (const ViewerTest_CommandOptionKey theOptionKey,
+                                      const std::size_t                 theMandatoryArgsNb /* = 0 */,
+                                      const bool                        isFatal /* = false */) const
+{
+  std::size_t aUsedOptionIndex = 0;
+  if (!findUsedOptionIndex (theOptionKey, aUsedOptionIndex))
+  {
+    return false;
+  }
+  const OptionArguments& anOptionArguments = myOptionArgumentStorage[aUsedOptionIndex];
+  const bool             aResult           = (anOptionArguments.size() >= theMandatoryArgsNb);
+  if (isFatal && !aResult)
+  {
+    std::cerr << "Error: wrong syntax at option '" << myOptionStorage[theOptionKey].Name << "'\n"
+              << "At least " << theMandatoryArgsNb << "expected, but only " << anOptionArguments.size()
+              << "provided.\n";
+  }
   return aResult;
 }
 
 //===============================================================================================
-//function : Arg
-//purpose  :
+// function : GetNumberOfOptionArguments
+// purpose  :
 //===============================================================================================
-std::string ViewerTest_CmdParser::Arg (const std::string& theOptionName, Standard_Integer theArgumentIndex)
+Standard_Integer ViewerTest_CmdParser::GetNumberOfOptionArguments (const std::string& theOptionName) const
 {
-  std::string aLowerName = theOptionName;
-  std::transform (aLowerName.begin(), aLowerName.end(), aLowerName.begin(), ::LowerCase);
+  ViewerTest_CommandOptionKey anOptionKey = THE_UNNAMED_COMMAND_OPTION_KEY;
+  if (!findOptionKey (theOptionName, anOptionKey))
+  {
+    return 0;
+  }
+  return GetNumberOfOptionArguments (anOptionKey);
+}
 
-  std::map<std::string, Standard_Integer>::iterator aMapIter = myArgumentLists.find (aLowerName);
-  if (aMapIter != myArgumentLists.end())
+//===============================================================================================
+// function : GetNumberOfOptionArguments
+// purpose  :
+//===============================================================================================
+Standard_Integer ViewerTest_CmdParser::GetNumberOfOptionArguments (const ViewerTest_CommandOptionKey theOptionKey) const
+{
+  std::size_t aUsedOptionIndex = 0;
+  if (!findUsedOptionIndex (theOptionKey, aUsedOptionIndex))
   {
-    Standard_Integer anOption = aMapIter->second;
-    if (myArgumentStorage[anOption].Arguments.size() > static_cast<size_t> (theArgumentIndex))
-    {
-      return myArgumentStorage[anOption].Arguments[theArgumentIndex];
-    }
-    else
-    {
-      std::cerr << "Error: wrong syntax at argument '" << aLowerName << "'\n";
-    }
+    return false;
+  }
+  return static_cast<Standard_Integer> (myOptionArgumentStorage[aUsedOptionIndex].size());
+}
+
+//===============================================================================================
+// function : Arg
+// purpose  :
+//===============================================================================================
+bool ViewerTest_CmdParser::Arg (const std::string&     theOptionName,
+                                const Standard_Integer theArgumentIndex,
+                                std::string&           theOptionArgument) const
+{
+  Standard_ASSERT_RETURN (theArgumentIndex >= 0,
+                          __FUNCTION__ ": 'theArgumentIndex' must be greater than or equal to zero.",
+                          false);
+  ViewerTest_CommandOptionKey anOptionKey = THE_UNNAMED_COMMAND_OPTION_KEY;
+  if (!theOptionName.empty() && !findOptionKey (theOptionName, anOptionKey))
+  {
+    return false;
+  }
+  return Arg (anOptionKey, theArgumentIndex, theOptionArgument);
+}
+
+//===============================================================================================
+// function : Arg
+// purpose  :
+//===============================================================================================
+bool ViewerTest_CmdParser::Arg (const ViewerTest_CommandOptionKey theOptionKey,
+                                const Standard_Integer            theArgumentIndex,
+                                std::string&                      theOptionArgument) const
+{
+  Standard_ASSERT_RETURN (theArgumentIndex >= 0,
+                          __FUNCTION__ ": 'theArgumentIndex' must be greater than or equal to zero.",
+                          false);
+  std::size_t aUsedOptionIndex = 0;
+  if (!findUsedOptionIndex (theOptionKey, aUsedOptionIndex))
+  {
+    return false;
+  }
+  const OptionArguments& anOptionArguments = myOptionArgumentStorage[aUsedOptionIndex];
+  if (static_cast<std::size_t> (theArgumentIndex) >= anOptionArguments.size())
+  {
+    return false;
+  }
+  theOptionArgument = anOptionArguments[theArgumentIndex];
+  return true;
+}
+
+//===============================================================================================
+// function : Arg
+// purpose  :
+//===============================================================================================
+std::string ViewerTest_CmdParser::Arg (const std::string& theOptionName, const Standard_Integer theArgumentIndex) const
+{
+  Standard_ASSERT_RETURN (theArgumentIndex >= 0,
+                          __FUNCTION__ ": 'theArgumentIndex' must be greater than or equal to zero.",
+                          std::string());
+  std::string anOptionArgument;
+  if (!Arg (theOptionName, theArgumentIndex, anOptionArgument))
+  {
+    return std::string();
   }
+  return anOptionArgument;
+}
 
-  return "";
+//===============================================================================================
+// function : Arg
+// purpose  :
+//===============================================================================================
+std::string ViewerTest_CmdParser::Arg (const ViewerTest_CommandOptionKey theOptionKey,
+                                       const Standard_Integer            theArgumentIndex) const
+{
+  std::string anOptionArgument;
+  if (!Arg (theOptionKey, theArgumentIndex, anOptionArgument))
+  {
+    return std::string();
+  }
+  return anOptionArgument;
 }
 
 //===============================================================================================
-//function : ArgVec3f
-//purpose  :
+// function : ArgVec3f
+// purpose  :
 //===============================================================================================
-Graphic3d_Vec3 ViewerTest_CmdParser::ArgVec3f (const std::string& theOptionName, Standard_Integer theArgumentIndex)
+Graphic3d_Vec3 ViewerTest_CmdParser::ArgVec3f (const std::string& theOptionName,
+                                               Standard_Integer   theArgumentIndex) const
 {
-  return Graphic3d_Vec3 (static_cast<Standard_ShortReal> (Draw::Atof (Arg (theOptionName, theArgumentIndex    ).c_str())),
-                         static_cast<Standard_ShortReal> (Draw::Atof (Arg (theOptionName, theArgumentIndex + 1).c_str())),
-                         static_cast<Standard_ShortReal> (Draw::Atof (Arg (theOptionName, theArgumentIndex + 2).c_str())));
+  return Graphic3d_Vec3 (
+    static_cast<Standard_ShortReal> (Draw::Atof (Arg (theOptionName, theArgumentIndex).c_str())),
+    static_cast<Standard_ShortReal> (Draw::Atof (Arg (theOptionName, theArgumentIndex + 1).c_str())),
+    static_cast<Standard_ShortReal> (Draw::Atof (Arg (theOptionName, theArgumentIndex + 2).c_str())));
 }
 
 //===============================================================================================
-//function : ArgVec3d
-//purpose  :
+// function : ArgVec3d
+// purpose  :
 //===============================================================================================
-Graphic3d_Vec3d ViewerTest_CmdParser::ArgVec3d (const std::string& theOptionName, Standard_Integer theArgumentIndex)
+Graphic3d_Vec3d ViewerTest_CmdParser::ArgVec3d (const std::string& theOptionName,
+                                                Standard_Integer   theArgumentIndex) const
 {
-  return Graphic3d_Vec3d ( Draw::Atof (Arg (theOptionName, theArgumentIndex    ).c_str()),
-                           Draw::Atof (Arg (theOptionName, theArgumentIndex + 1).c_str()),
-                           Draw::Atof (Arg (theOptionName, theArgumentIndex + 2).c_str()));
+  return Graphic3d_Vec3d (Draw::Atof (Arg (theOptionName, theArgumentIndex).c_str()),
+                          Draw::Atof (Arg (theOptionName, theArgumentIndex + 1).c_str()),
+                          Draw::Atof (Arg (theOptionName, theArgumentIndex + 2).c_str()));
 }
 
 //===============================================================================================
-//function : ArgVec
-//purpose  :
+// function : ArgVec
+// purpose  :
 //===============================================================================================
-gp_Vec ViewerTest_CmdParser::ArgVec (const std::string& theOptionName, Standard_Integer theArgumentIndex)
+gp_Vec ViewerTest_CmdParser::ArgVec (const std::string& theOptionName, Standard_Integer theArgumentIndex) const
 {
-  return gp_Vec ( Draw::Atof (Arg (theOptionName, theArgumentIndex    ).c_str()),
-                  Draw::Atof (Arg (theOptionName, theArgumentIndex + 1).c_str()),
-                  Draw::Atof (Arg (theOptionName, theArgumentIndex + 2).c_str()));
+  return gp_Vec (Draw::Atof (Arg (theOptionName, theArgumentIndex).c_str()),
+                 Draw::Atof (Arg (theOptionName, theArgumentIndex + 1).c_str()),
+                 Draw::Atof (Arg (theOptionName, theArgumentIndex + 2).c_str()));
 }
 
 //===============================================================================================
-//function : ArgPnt
-//purpose  :
+// function : ArgPnt
+// purpose  :
 //===============================================================================================
-gp_Pnt ViewerTest_CmdParser::ArgPnt (const std::string& theOptionName, Standard_Integer theArgumentIndex)
+gp_Pnt ViewerTest_CmdParser::ArgPnt (const std::string& theOptionName, Standard_Integer theArgumentIndex) const
 {
-  return gp_Pnt ( Draw::Atof (Arg (theOptionName, theArgumentIndex    ).c_str()),
-                  Draw::Atof (Arg (theOptionName, theArgumentIndex + 1).c_str()),
-                  Draw::Atof (Arg (theOptionName, theArgumentIndex + 2).c_str()));
+  return gp_Pnt (Draw::Atof (Arg (theOptionName, theArgumentIndex).c_str()),
+                 Draw::Atof (Arg (theOptionName, theArgumentIndex + 1).c_str()),
+                 Draw::Atof (Arg (theOptionName, theArgumentIndex + 2).c_str()));
 }
 
 //===============================================================================================
-//function : ArgDouble
-//purpose  :
+// function : ArgDouble
+// purpose  :
 //===============================================================================================
-Standard_Real ViewerTest_CmdParser::ArgDouble (const std::string& theOptionName, Standard_Integer theArgumentIndex)
+Standard_Real ViewerTest_CmdParser::ArgDouble (const std::string& theOptionName,
+                                               Standard_Integer   theArgumentIndex) const
 {
   return Draw::Atof (Arg (theOptionName, theArgumentIndex).c_str());
 }
 
 //===============================================================================================
-//function : ArgFloat
-//purpose  :
+// function : ArgFloat
+// purpose  :
 //===============================================================================================
-Standard_ShortReal ViewerTest_CmdParser::ArgFloat (const std::string& theOptionName, Standard_Integer theArgumentIndex)
+Standard_ShortReal ViewerTest_CmdParser::ArgFloat (const std::string& theOptionName,
+                                                   Standard_Integer   theArgumentIndex) const
 {
   return static_cast<Standard_ShortReal> (Draw::Atof (Arg (theOptionName, theArgumentIndex).c_str()));
 }
 
 //===============================================================================================
-//function : ArgInt
-//purpose  :
+// function : ArgInt
+// purpose  :
 //===============================================================================================
-Standard_Integer ViewerTest_CmdParser::ArgInt (const std::string& theOptionName, const Standard_Integer theArgumentIndex)
+Standard_Integer ViewerTest_CmdParser::ArgInt (const std::string&     theOptionName,
+                                               const Standard_Integer theArgumentIndex) const
 {
   return static_cast<Standard_Integer> (Draw::Atoi (Arg (theOptionName, theArgumentIndex).c_str()));
 }
 
 //===============================================================================================
-//function : ArgBool
-//purpose  :
+// function : ArgBool
+// purpose  :
 //===============================================================================================
-Standard_Boolean ViewerTest_CmdParser::ArgBool (const std::string& theOptionName, const Standard_Integer theArgumentIndex)
+bool ViewerTest_CmdParser::ArgBool (const std::string& theOptionName, const Standard_Integer theArgumentIndex) const
 {
   return Draw::Atoi (Arg (theOptionName, theArgumentIndex).c_str()) != 0;
 }
+
+//===============================================================================================
+// function : ArgColor
+// purpose  :
+//===============================================================================================
+template <typename TheColor>
+bool ViewerTest_CmdParser::ArgColor (const std::string& theOptionName,
+                                     Standard_Integer&  theArgumentIndex,
+                                     TheColor&          theColor) const
+{
+  ViewerTest_CommandOptionKey anOptionKey;
+  if (!findOptionKey (theOptionName, anOptionKey))
+  {
+    return false;
+  }
+  return ArgColor (anOptionKey, theArgumentIndex, theColor);
+}
+
+//! ViewerTest_CmdParser::ArgColor() explicit template instantiation definitions
+template bool ViewerTest_CmdParser::ArgColor (const std::string& theOptionName,
+                                              Standard_Integer&  theArgumentIndex,
+                                              Quantity_Color&    theColor) const;
+
+template bool ViewerTest_CmdParser::ArgColor (const std::string&  theOptionName,
+                                              Standard_Integer&   theArgumentIndex,
+                                              Quantity_ColorRGBA& theColor) const;
+
+//===============================================================================================
+// function : ArgColor
+// purpose  :
+//===============================================================================================
+template <typename TheColor>
+bool ViewerTest_CmdParser::ArgColor (const ViewerTest_CommandOptionKey theOptionKey,
+                                     Standard_Integer&                 theArgumentIndex,
+                                     TheColor&                         theColor) const
+{
+  std::size_t aUsedOptionIndex = 0;
+  if (!findUsedOptionIndex (theOptionKey, aUsedOptionIndex))
+  {
+    return false;
+  }
+  const RawStringArguments aRawStringArguments = getRawStringArguments (aUsedOptionIndex);
+  const Standard_Integer   aNumberOfArguments  = static_cast<Standard_Integer> (aRawStringArguments.size());
+  Standard_ASSERT_RETURN (theArgumentIndex < aNumberOfArguments,
+                          __FUNCTION__ ": 'theArgumentIndex' must be less than the number of command-line arguments "
+                                       "passed with the option which access key is 'theOptionKey'.",
+                          false);
+  const Standard_Integer aNumberOfAvailableArguments = aNumberOfArguments - theArgumentIndex;
+  TheColor               aColor;
+  const Standard_Integer aNumberOfParsedArguments = ViewerTest::ParseColor (aNumberOfAvailableArguments,
+                                                                            &aRawStringArguments[theArgumentIndex],
+                                                                            aColor);
+  if (aNumberOfParsedArguments == 0)
+  {
+    return false;
+  }
+  theArgumentIndex += aNumberOfParsedArguments;
+  theColor = aColor;
+  return true;
+}
+
+//! ViewerTest_CmdParser::ArgColor() explicit template instantiation definitions
+template bool ViewerTest_CmdParser::ArgColor (ViewerTest_CommandOptionKey theOptionKey,
+                                              Standard_Integer&           theArgumentIndex,
+                                              Quantity_Color&             theColor) const;
+
+template bool ViewerTest_CmdParser::ArgColor (ViewerTest_CommandOptionKey theOptionKey,
+                                              Standard_Integer&           theArgumentIndex,
+                                              Quantity_ColorRGBA&         theColor) const;
+
+//===============================================================================================
+// function : findUsedOptionKey
+// purpose  :
+//===============================================================================================
+bool ViewerTest_CmdParser::findOptionKey (const std::string&           theOptionName,
+                                          ViewerTest_CommandOptionKey& theOptionKey) const
+{
+  const std::string               anOptionNameInLowercase = toLowerCase (theOptionName);
+  const OptionMap::const_iterator aMapIter                = myOptionMap.find (anOptionNameInLowercase);
+  if (aMapIter == myOptionMap.end())
+  {
+    return false;
+  }
+  theOptionKey = aMapIter->second;
+  return true;
+}
+
+//===============================================================================================
+// function : findUsedOptionKey
+// purpose  :
+//===============================================================================================
+bool ViewerTest_CmdParser::findUsedOptionIndex (const ViewerTest_CommandOptionKey theOptionKey,
+                                                std::size_t&                      theUsedOptionIndex) const
+{
+  const UsedOptionMap::const_iterator aUsedOptionIterator = myUsedOptionMap.find (theOptionKey);
+  if (aUsedOptionIterator == myUsedOptionMap.end())
+  {
+    return false;
+  }
+  theUsedOptionIndex = aUsedOptionIterator->second;
+  return true;
+}
+
+//===============================================================================================
+// function : findUsedOptionIndex
+// purpose  :
+//===============================================================================================
+bool ViewerTest_CmdParser::findUsedOptionIndex (const std::string& theOptionName, std::size_t& theUsedOptionIndex) const
+{
+  ViewerTest_CommandOptionKey anOptionKey = THE_UNNAMED_COMMAND_OPTION_KEY;
+  if (!findOptionKey (theOptionName, anOptionKey))
+  {
+    return false;
+  }
+  std::size_t aUsedOptionIndex = 0;
+  if (!findUsedOptionIndex (anOptionKey, aUsedOptionIndex))
+  {
+    return false;
+  }
+  theUsedOptionIndex = aUsedOptionIndex;
+  return true;
+}
+
+//===============================================================================================
+// function : addUsedOption
+// purpose  :
+//===============================================================================================
+std::size_t ViewerTest_CmdParser::addUsedOption (const ViewerTest_CommandOptionKey theNewUsedOptionKey)
+{
+  const std::size_t aNewUsedOptionIndex = myOptionArgumentStorage.size();
+  myOptionArgumentStorage.push_back (OptionArguments());
+  myUsedOptionMap[theNewUsedOptionKey] = aNewUsedOptionIndex;
+  return aNewUsedOptionIndex;
+}
+
+//===============================================================================================
+// function : getRawStringArguments
+// purpose  :
+//===============================================================================================
+ViewerTest_CmdParser::RawStringArguments ViewerTest_CmdParser::getRawStringArguments (
+  const std::size_t theUsedOptionIndex) const
+{
+  Standard_ASSERT_RETURN (
+    theUsedOptionIndex < myOptionArgumentStorage.size(),
+    __FUNCTION__ ": 'theUsedOptionIndex' must be less than the size of 'myOptionArgumentStorage'.",
+    RawStringArguments());
+  const OptionArguments& anOptionArguments = myOptionArgumentStorage[theUsedOptionIndex];
+  return convertToRawStringList (anOptionArguments);
+}
index 22487ca..995504b 100644 (file)
 #ifndef _ViewerTest_CmdParser_HeaderFile
 #define _ViewerTest_CmdParser_HeaderFile
 
+#include <Graphic3d_Vec3.hxx>
+
+#include <limits>
 #include <map>
 #include <vector>
+#include <set>
 #include <string>
-#include <algorithm>
 
-#include <Standard.hxx>
-#include <Graphic3d_Vec.hxx>
-#include <gp_Vec.hxx>
+class Quantity_Color;
+class Quantity_ColorRGBA;
+class gp_Vec;
+class gp_Pnt;
+
+//! A key for a command line option used for a ViewerTest_CmdParser work
+typedef std::size_t ViewerTest_CommandOptionKey;
+
+//! A set of keys for command-line options
+typedef std::set<ViewerTest_CommandOptionKey> ViewerTest_CommandOptionKeySet;
 
 //! Command parser.
 class ViewerTest_CmdParser
 {
 public:
+  //! The key of the unnamed command option
+  static const std::size_t THE_UNNAMED_COMMAND_OPTION_KEY;
 
-  //! Initializes default option.
-  ViewerTest_CmdParser();
+  //! The key of the help command option
+  static const std::size_t THE_HELP_COMMAND_OPTION_KEY;
+
+  //! Initializes help option.
+  //! @param theDescription the description of the command
+  ViewerTest_CmdParser (const std::string& theDescription = std::string());
 
   //! Sets description for command.
-  void AddDescription (const std::string& theDescription)
+  void SetDescription (const std::string& theDescription)
   {
     myDescription = theDescription;
   }
 
   //! Adds option to available option list. Several names may be provided if separated with '|'.
-  void AddOption (const std::string& theOptionNames, const std::string& theOptionDescription = "");
+  //! @param theOptionNames the list of possible option names separated with '|'
+  //! (the first name is main, the other names are aliases)
+  //! @param theOptionDescription the description of the option
+  //! @return an access key of the newly added option
+  ViewerTest_CommandOptionKey AddOption (const std::string& theOptionNames,
+                                         const std::string& theOptionDescription = std::string());
 
   //! Prints help message based on provided command and options descriptions.
-  void Help();
+  void PrintHelp() const;
+
+  //! Parses argument list (skips the command name); assigns local arguments to each option.
+  void Parse (Standard_Integer theArgsNb, const char* const* theArgVec);
+
+  //! Gets an option name by its access key
+  //! @param theOptionKey the access key of the option which name is to be found
+  //! @retuan a name of the option with the given access key
+  std::string GetOptionNameByKey (ViewerTest_CommandOptionKey theOptionKey) const;
+
+  //! Gets a set of used options
+  //! @return a set of used options
+  ViewerTest_CommandOptionKeySet GetUsedOptions() const;
+
+  //! Tests if there were no command line options provided
+  //! @return true if no command line options were provided, or false otherwise
+  bool HasNoOption() const;
+
+  //! Tests if the unnamed command line option was provided
+  //! @return true if the unnamed command line option was provided, or false otherwise
+  bool HasUnnamedOption() const;
 
-  //! Parses argument list; assignes local arguments to each option.
-  void Parse (Standard_Integer  theArgsNb,
-              const char**      theArgVec);
+  //! Tests if only unnamed command line option was provided
+  //! @return true if only unnamed command line option was provided, or false otherwise
+  bool HasOnlyUnnamedOption() const;
 
-  //! Checks if option was set with given minimal argument number.
+  //! Checks if option was used with given minimal number of arguments.
   //! Prints error message if isFatal flag was set.
-  Standard_Boolean HasOption (const std::string& theOptionName,
-                              Standard_Integer theMandatoryArgsNb = 0,
-                              Standard_Boolean isFatal = Standard_False);
+  //! @param theOptionName the name of the option to be checked
+  //! @param theMandatoryArgsNb the number of mandatory arguments
+  //! @param isFatal the flag that controls printing of an error message
+  //! @return true if an option was set, or false otherwise
+  bool HasOption (const std::string& theOptionName,
+                  std::size_t        theMandatoryArgsNb = 0,
+                  bool               isFatal            = Standard_False) const;
+
+  //! Checks if option was used with given minimal number of arguments.
+  //! Prints error message if isFatal flag was set.
+  //! @param theOptionKey the access key of the option to be checked
+  //! @param theMandatoryArgsNb the number of mandatory arguments
+  //! @param isFatal the flag that controls printing of an error message
+  //! @return true if an option was set, or false otherwise
+  bool HasOption (ViewerTest_CommandOptionKey theOptionKey,
+                  std::size_t                 theMandatoryArgsNb = 0,
+                  bool                        isFatal            = Standard_False) const;
+
+  //! Gets a number of option arguments
+  //! @param theOptionName the name of the option
+  //! @return a number of option arguments, or 0 if option was not used
+  Standard_Integer GetNumberOfOptionArguments (const std::string& theOptionName) const;
+  
+  //! Gets a number of option arguments
+  //! @param theOptionKey the access key of the option
+  //! @return a number of option arguments, or 0 if option was not used
+  Standard_Integer GetNumberOfOptionArguments (ViewerTest_CommandOptionKey theOptionKey) const;
+
+  //! Accesses local argument of option 'theOptionName' with index 'theArgumentIndex'.
+  //! @param theOptionName the name of the option which argument is to be accessed
+  //! @param theArgumentIndex the index of an accessed argument
+  //! @param theOptionArgument an argument of the option with the given name
+  //! @return true if an access was successful, or false otherwise
+  bool Arg (const std::string& theOptionName, Standard_Integer theArgumentIndex, std::string& theOptionArgument) const;
+
+  //! Accesses a local argument with the index 'theArgumentIndex' of the option with the key 'theOptionKey'.
+  //! @param theOptionKey the access key of the option which argument is to be accessed
+  //! @param theArgumentIndex the index of an accessed argument
+  //! @param theOptionArgument an argument of the option with the given key
+  //! @return true if an access was successful, or false otherwise
+  bool Arg (ViewerTest_CommandOptionKey theOptionKey,
+            Standard_Integer            theArgumentIndex,
+            std::string&                theOptionArgument) const;
 
   //! Accesses local argument of option 'theOptionName' with index 'theArgumentIndex'.
-  std::string Arg (const std::string& theOptionName, Standard_Integer theArgumentIndex);
+  //! @param theOptionName the name of the option which argument is to be accessed
+  //! @param theArgumentIndex the index of an accessed argument
+  //! @return an argument of the option with the given name
+  std::string Arg (const std::string& theOptionName, Standard_Integer theArgumentIndex) const;
+
+  //! Accesses a local argument with the index 'theArgumentIndex' of the option with the key 'theOptionKey'.
+  //! @param theOptionKey the access key of the option which argument is to be accessed
+  //! @param theArgumentIndex the index of an accessed argument
+  //! @return an argument of the option with the given key
+  std::string Arg (ViewerTest_CommandOptionKey theOptionKey, Standard_Integer theArgumentIndex) const;
 
   // Interprets arguments of option 'theOptionName' as float vector starting with index 'theArgumentIndex'.
-  Graphic3d_Vec3 ArgVec3f (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
+  Graphic3d_Vec3 ArgVec3f (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0) const;
 
   // Interprets arguments of option 'theOptionName' as double vector starting with index 'theArgumentIndex'.
-  Graphic3d_Vec3d ArgVec3d (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
+  Graphic3d_Vec3d ArgVec3d (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0) const;
 
   // Interprets arguments of option 'theOptionName' as gp vector starting with index 'theArgumentIndex'.
-  gp_Vec ArgVec (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
+  gp_Vec ArgVec (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0) const;
 
   // Interprets arguments of option 'theOptionName' as gp vector starting with index 'theArgumentIndex'.
-  gp_Pnt ArgPnt (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
+  gp_Pnt ArgPnt (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0) const;
 
   // Interprets arguments of option 'theOptionName' as double at index 'theArgumentIndex'.
-  Standard_Real ArgDouble (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
+  Standard_Real ArgDouble (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0) const;
 
   // Interprets arguments of option 'theOptionName' as float at index 'theArgumentIndex'.
-  Standard_ShortReal ArgFloat (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
+  Standard_ShortReal ArgFloat (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0) const;
 
   // Interprets arguments of option 'theOptionName' as integer at index 'theArgumentIndex'.
-  Standard_Integer ArgInt (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
+  Standard_Integer ArgInt (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0) const;
 
   // Interprets arguments of option 'theOptionName' as boolean at index 'theArgumentIndex'.
-  Standard_Boolean ArgBool (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0);
+  bool ArgBool (const std::string& theOptionName, const Standard_Integer theArgumentIndex = 0) const;
+
+  //! Interprets arguments of the option 'theOptionName' with the index 'theArgumentIndex' as an RGB(A) color object.
+  //! @tparam theColor the type of a resulting RGB(A) color object
+  //! @param theOptionName the name of the option which arguments are to be interpreted
+  //! @param theArgumentIndex the index of the first argument to be interpreted
+  //! (will be promoted to the next argument after the block of interpreted arguments)
+  //! @param theColor a color that is an interpretation of argument(s) of the option with the given name
+  //! @return true if an interpretation was successful, or false otherwise
+  template <typename TheColor>
+  bool ArgColor (const std::string& theOptionName, Standard_Integer& theArgumentIndex, TheColor& theColor) const;
+
+  //! Interprets arguments of the option with the key 'theOptionKey' as an RGB(A) color object.
+  //! @tparam theColor the type of a resulting RGB(A) color object
+  //! @param theOptionKey the access key of the option which arguments are to be interpreted
+  //! @param theArgumentIndex the index of the first argument to be interpreted
+  //! (will be promoted to the next argument after the block of interpreted arguments)
+  //! @param theColor a color that is an interpretation of argument(s) of the option with the given name
+  //! @return true if an interpretation was successful, or false otherwise
+  template <typename TheColor>
+  bool ArgColor (ViewerTest_CommandOptionKey theOptionKey,
+                 Standard_Integer&           theArgumentIndex,
+                 TheColor&                   theColor) const;
 
 private:
+  //! A list of aliases to a command option name
+  typedef std::vector<std::string> OptionAliases;
 
-  //! Object representing option state.
-  struct ViewerTest_CmdOption
-  {
-    ViewerTest_CmdOption() : IsSet (Standard_False) {}
+  //! A map from all possible option names to option access keys
+  typedef std::map<std::string, ViewerTest_CommandOptionKey> OptionMap;
+
+  //! A map from keys of used options to their indices in the storage
+  typedef std::map<ViewerTest_CommandOptionKey, std::size_t> UsedOptionMap;
+
+  //! A list of command option arguments
+  typedef std::vector<std::string> OptionArguments;
+
+  //! A storage of arguments of different command options
+  typedef std::vector<OptionArguments> OptionArgumentsStorage;
 
-    std::string Name;
-    std::string Description;
-    Standard_Boolean IsSet;
-    std::vector<std::string> Arguments;
+  //! A full description of a command option
+  struct CommandOption
+  {
+    std::string   Name;        //!< A command option name
+    OptionAliases Aliases;     //!< A list of aliases to a command option name
+    std::string   Description; //!< A text description of a command option
   };
 
+  // A storage of command options descriptions
+  typedef std::vector<CommandOption> CommandOptionStorage;
+
+  // A list of raw string arguments
+  typedef std::vector<const char*> RawStringArguments;
+
   //! Description of command.
   std::string myDescription;
 
-  //! Map from all possible option names to option object indexes in myArgumentStorage.
-  std::map<std::string, Standard_Integer> myArgumentLists;
-
   //! Container which stores option objects.
-  std::vector<ViewerTest_CmdOption> myArgumentStorage;
+  std::vector<CommandOption> myOptionStorage;
+
+  //! Map from all possible option names to option access keys (that are indices in myOptionStorage)
+  OptionMap myOptionMap;
+
+  //! Map from keys of used options to their indices in the option arguments storage
+  UsedOptionMap myUsedOptionMap;
+
+  //! Container which stores the arguments of all used options
+  OptionArgumentsStorage myOptionArgumentStorage;
+
+  //! Gets an access key of the option
+  //! @param theOptionName the name of the option which key is to be found
+  //! @param theOptionKey an access key of the option with the given name
+  //! @return true if the given option was found, or false otherwise
+  bool findOptionKey (const std::string& theOptionName, ViewerTest_CommandOptionKey& theOptionKey) const;
+
+  //! Gets an index of an option that was used
+  //! @param theOptionKey the access key of the used option which index is to be found
+  //! @param theUsedOptionIndex an index of the used option with the given access key
+  //! @return true if the given option was not found or not used, or false otherwise
+  bool findUsedOptionIndex (ViewerTest_CommandOptionKey theOptionKey, std::size_t& theUsedOptionIndex) const;
+
+  //! Gets an index of an option that was used
+  //! @param theOptionName the name of the used option which index is to be found
+  //! @param theUsedOptionIndex an index of the used option with the given name
+  //! @return true if the given option was not found or not used, or false otherwise
+  bool findUsedOptionIndex (const std::string& theOptionName, std::size_t& theUsedOptionIndex) const;
+
+  //! Adds the option that is used in the passed command line parameters
+  //! @param theNewUsedOptionKey the access key of the adding option
+  //! @return an index of a newly added option
+  std::size_t addUsedOption (ViewerTest_CommandOptionKey theNewUsedOptionKey);
+
+  //! Gets an index of an option that was used
+  //! @param theOptionName the name of the used option which index is to be found
+  //! @param theUsedOptionIndex an index of the used option with the given name
+  //! @return true if the given option was not found or not used, or false otherwise
+  RawStringArguments getRawStringArguments (std::size_t theUsedOptionIndex) const;
 };
 
 #endif // _ViewerTest_CmdParser_HeaderFile
index 08edc43..dd217d6 100644 (file)
@@ -83,6 +83,8 @@
 #include <Prs3d_Text.hxx>
 #include <Select3D_SensitivePrimitiveArray.hxx>
 
+#include <tcl.h>
+
 #ifdef _WIN32
 #undef DrawText
 #endif
@@ -255,6 +257,1029 @@ Standard_Boolean TheIsAnimating = Standard_False;
 Standard_Boolean Draw_ToExitOnCloseView = Standard_False;
 Standard_Boolean Draw_ToCloseViewOnEsc  = Standard_False;
 
+namespace
+{
+
+  //! Checks if some set is a subset of other set
+  //! @tparam TheSuperSet the type of the superset
+  //! @tparam TheSubSet the type of the subset
+  //! @param theSuperSet the superset
+  //! @param theSubSet the subset to be checked
+  //! @return true if the superset includes subset, or false otherwise
+  template <typename TheSuperSet, typename TheSubSet>
+  static bool includes (const TheSuperSet& theSuperSet, const TheSubSet& theSubSet)
+  {
+    return std::includes (theSuperSet.begin(), theSuperSet.end(), theSubSet.begin(), theSubSet.end());
+  }
+
+  //! A variable set of keys for command-line options.
+  //! It includes a set of mandatory keys and a set of all possible keys.
+  class CommandOptionKeyVariableSet
+  {
+  public:
+    //! Default constructor
+    CommandOptionKeyVariableSet()
+    {
+    }
+
+    //! Constructor
+    //! @param theMandatoryKeySet the set of the mandatory option keys
+    //! @param theAdditionalKeySet the set of additional options that could be omitted
+    CommandOptionKeyVariableSet (
+      const ViewerTest_CommandOptionKeySet& theMandatoryKeySet,
+      const ViewerTest_CommandOptionKeySet& theAdditionalKeySet = ViewerTest_CommandOptionKeySet())
+    : myMandatoryKeySet (theMandatoryKeySet)
+    {
+      std::set_union (theMandatoryKeySet.begin(),
+                      theMandatoryKeySet.end(),
+                      theAdditionalKeySet.begin(),
+                      theAdditionalKeySet.end(),
+                      std::inserter (myFullKeySet, myFullKeySet.begin()));
+    }
+
+    //! Checks if the set of option keys fits to the current variable set (it must contain all mandatory keys
+    //! and be contained in the full key set)
+    //! @param theCheckedKeySet the set of option keys to be checked
+    bool IsInSet (const ViewerTest_CommandOptionKeySet& theCheckedKeySet) const
+    {
+      return includes (theCheckedKeySet, myMandatoryKeySet) && includes (myFullKeySet, theCheckedKeySet);
+    }
+
+  private:
+    //! A set of mandatory command-line option keys
+    ViewerTest_CommandOptionKeySet myMandatoryKeySet;
+
+    //! A full set of command-line option keys (includes mandatory and additional option keys)
+    ViewerTest_CommandOptionKeySet myFullKeySet;
+  };
+
+  //! Gets some code by its name
+  //! @tparam TheCode the type of a code to be found
+  //! @param theCodeNameMap the map from code names to codes
+  //! @param theCodeName the name of a code to be found
+  //! @param theCode the code to be found
+  //! @return true if a code is found, or false otherwise
+  template <typename TheCode>
+  static bool getSomeCodeByName (const std::map<TCollection_AsciiString, TheCode>& theCodeNameMap,
+                                 TCollection_AsciiString                           theCodeName,
+                                 TheCode&                                          theCode)
+  {
+    theCodeName.LowerCase();
+    const typename std::map<TCollection_AsciiString, TheCode>::const_iterator aCodeIterator = theCodeNameMap.find (
+      theCodeName);
+    if (aCodeIterator == theCodeNameMap.end())
+    {
+      return false;
+    }
+    theCode = aCodeIterator->second;
+    return true;
+  }
+
+  // Defines possible commands related to background changing
+  enum BackgroundCommand
+  {
+    BackgroundCommand_Main,         //!< The main command that manages other commands through options
+    BackgroundCommand_Image,        //!< Sets an image as a background
+    BackgroundCommand_ImageMode,    //!< Changes a background image mode
+    BackgroundCommand_Gradient,     //!< Sets a gradient as a background
+    BackgroundCommand_GradientMode, //!< Changes a background gradient mode
+    BackgroundCommand_Color,        //!< Fills background with a specified color
+    BackgroundCommand_Default       //!< Sets the background default color or gradient
+  };
+
+  //! Map from background command names to its codes
+  typedef std::map<TCollection_AsciiString, BackgroundCommand> BackgroundCommandNameMap;
+
+  //! Creates a map from background command names to its codes
+  //! @return a map from background command names to its codes
+  static BackgroundCommandNameMap createBackgroundCommandNameMap()
+  {
+    BackgroundCommandNameMap aBackgroundCommandNameMap;
+    aBackgroundCommandNameMap["vbackground"]    = BackgroundCommand_Main;
+    aBackgroundCommandNameMap["vsetbg"]         = BackgroundCommand_Image;
+    aBackgroundCommandNameMap["vsetbgmode"]     = BackgroundCommand_ImageMode;
+    aBackgroundCommandNameMap["vsetgradientbg"] = BackgroundCommand_Gradient;
+    aBackgroundCommandNameMap["vsetgrbgmode"]   = BackgroundCommand_GradientMode;
+    aBackgroundCommandNameMap["vsetcolorbg"]    = BackgroundCommand_Color;
+    aBackgroundCommandNameMap["vsetdefaultbg"]  = BackgroundCommand_Default;
+    return aBackgroundCommandNameMap;
+  }
+
+  //! Gets a background command by its name
+  //! @param theBackgroundCommandName the name of the background command
+  //! @param theBackgroundCommand the background command to be found
+  //! @return true if a background command is found, or false otherwise
+  static bool getBackgroundCommandByName (const TCollection_AsciiString& theBackgroundCommandName,
+                                          BackgroundCommand&             theBackgroundCommand)
+  {
+    static const BackgroundCommandNameMap THE_BACKGROUND_COMMAND_NAME_MAP = createBackgroundCommandNameMap();
+    return getSomeCodeByName (THE_BACKGROUND_COMMAND_NAME_MAP, theBackgroundCommandName, theBackgroundCommand);
+  }
+
+  //! Map from background image fill method names to its codes
+  typedef std::map<TCollection_AsciiString, Aspect_FillMethod> BackgroundImageFillMethodNameMap;
+
+  //! Creates a map from background image fill method names to its codes
+  //! @return a map from background image fill method names to its codes
+  static BackgroundImageFillMethodNameMap createBackgroundImageFillMethodNameMap()
+  {
+    BackgroundImageFillMethodNameMap aBackgroundImageFillMethodNameMap;
+    aBackgroundImageFillMethodNameMap["none"]     = Aspect_FM_NONE;
+    aBackgroundImageFillMethodNameMap["centered"] = Aspect_FM_CENTERED;
+    aBackgroundImageFillMethodNameMap["tiled"]    = Aspect_FM_TILED;
+    aBackgroundImageFillMethodNameMap["stretch"]  = Aspect_FM_STRETCH;
+    return aBackgroundImageFillMethodNameMap;
+  }
+
+  //! Gets a background image fill method by its name
+  //! @param theBackgroundImageFillMethodName the name of the background image fill method
+  //! @param theBackgroundImageFillMethod the background image fill method to be found
+  //! @return true if a background image fill method is found, or false otherwise
+  static bool getBackgroundImageFillMethodByName (const TCollection_AsciiString& theBackgroundImageFillMethodName,
+                                                  Aspect_FillMethod&             theBackgroundImageFillMethod)
+  {
+    static const BackgroundImageFillMethodNameMap THE_BACKGROUND_IMAGE_FILL_METHOD_NAME_MAP =
+      createBackgroundImageFillMethodNameMap();
+    return getSomeCodeByName (THE_BACKGROUND_IMAGE_FILL_METHOD_NAME_MAP,
+                              theBackgroundImageFillMethodName,
+                              theBackgroundImageFillMethod);
+  }
+
+  //! Map from background gradient fill method names to its codes
+  typedef std::map<TCollection_AsciiString, Aspect_GradientFillMethod> BackgroundGradientFillMethodNameMap;
+
+  //! Creates a map from background gradient fill method names to its codes
+  //! @return a map from background gradient fill method names to its codes
+  static BackgroundGradientFillMethodNameMap createBackgroundGradientFillMethodNameMap()
+  {
+    BackgroundGradientFillMethodNameMap aBackgroundGradientFillMethodNameMap;
+    aBackgroundGradientFillMethodNameMap["none"]       = Aspect_GFM_NONE;
+    aBackgroundGradientFillMethodNameMap["hor"]        = Aspect_GFM_HOR;
+    aBackgroundGradientFillMethodNameMap["horizontal"] = Aspect_GFM_HOR;
+    aBackgroundGradientFillMethodNameMap["ver"]        = Aspect_GFM_VER;
+    aBackgroundGradientFillMethodNameMap["vertical"]   = Aspect_GFM_VER;
+    aBackgroundGradientFillMethodNameMap["diag1"]      = Aspect_GFM_DIAG1;
+    aBackgroundGradientFillMethodNameMap["diagonal1"]  = Aspect_GFM_DIAG1;
+    aBackgroundGradientFillMethodNameMap["diag2"]      = Aspect_GFM_DIAG2;
+    aBackgroundGradientFillMethodNameMap["diagonal2"]  = Aspect_GFM_DIAG2;
+    aBackgroundGradientFillMethodNameMap["corner1"]    = Aspect_GFM_CORNER1;
+    aBackgroundGradientFillMethodNameMap["corner2"]    = Aspect_GFM_CORNER2;
+    aBackgroundGradientFillMethodNameMap["corner3"]    = Aspect_GFM_CORNER3;
+    aBackgroundGradientFillMethodNameMap["corner4"]    = Aspect_GFM_CORNER4;
+    return aBackgroundGradientFillMethodNameMap;
+  }
+
+  //! Gets a gradient fill method by its name
+  //! @param theBackgroundGradientFillMethodName the name of the gradient fill method
+  //! @param theBackgroundGradientFillMethod the gradient fill method to be found
+  //! @return true if a gradient fill method is found, or false otherwise
+  static bool getBackgroundGradientFillMethodByName (const TCollection_AsciiString& theBackgroundGradientFillMethodName,
+                                                     Aspect_GradientFillMethod&     theBackgroundGradientFillMethod)
+  {
+    static const BackgroundGradientFillMethodNameMap THE_BACKGROUND_GRADIENT_FILL_METHOD_NAME_MAP =
+      createBackgroundGradientFillMethodNameMap();
+    return getSomeCodeByName (THE_BACKGROUND_GRADIENT_FILL_METHOD_NAME_MAP,
+                              theBackgroundGradientFillMethodName,
+                              theBackgroundGradientFillMethod);
+  }
+
+  //! Changes the background in accordance with passed command line options
+  class BackgroundChanger
+  {
+  public:
+    //! Constructor. Prepares the command parser
+    BackgroundChanger()
+    {
+      prepareCommandParser();
+    }
+
+    //! Processes the command line and changes the background
+    //! @param theDrawInterpretor the interpreter of the Draw Harness application
+    //! @param theNumberOfCommandLineArguments the number of passed command line arguments
+    //! @param theCommandLineArguments the array of command line arguments
+    bool ProcessCommandLine (Draw_Interpretor&        theDrawInterpretor,
+                             const Standard_Integer   theNumberOfCommandLineArguments,
+                             const char* const* const theCommandLineArguments)
+    {
+      const char* const aBackgroundCommandName = theCommandLineArguments[0];
+      BackgroundCommand aBackgroundCommand = BackgroundCommand_Main;
+      if (!getBackgroundCommandByName (aBackgroundCommandName, aBackgroundCommand))
+      {
+        return false;
+      }
+      addCommandDescription (aBackgroundCommand);
+      myCommandParser.Parse (theNumberOfCommandLineArguments, theCommandLineArguments);
+      return processCommandOptions (aBackgroundCommandName, aBackgroundCommand, theDrawInterpretor);
+    }
+
+  private:
+    //! The type of functions that are able to set gradient background filling
+    typedef void SetGradientFunction (const Quantity_Color& /* theColor1 */,
+                                      const Quantity_Color& /* theColor2 */,
+                                      const Aspect_GradientFillMethod /* theGradientMode */);
+
+    //! The type of functions that are able to fill a background with a specific color
+    typedef void SetColorFunction (const Quantity_Color& /* theColor */);
+
+    //! the command parser used to parse command line options and its arguments
+    ViewerTest_CmdParser myCommandParser;
+
+    //! the option key for the command that sets an image as a background
+    ViewerTest_CommandOptionKey myImageOptionKey;
+
+    //! the option key for the command that sets a background image fill type
+    ViewerTest_CommandOptionKey myImageModeOptionKey;
+
+    //! the option key for the command that sets a gradient filling for the background
+    ViewerTest_CommandOptionKey myGradientOptionKey;
+
+    //! the option key for the command that sets a background gradient filling method
+    ViewerTest_CommandOptionKey myGradientModeOptionKey;
+
+    //! the option key for the command that fills background with a specific color
+    ViewerTest_CommandOptionKey myColorOptionKey;
+
+    //! the option key for the command that sets default background gradient or color
+    ViewerTest_CommandOptionKey myDefaultOptionKey;
+
+    //! the variable set of options that are allowed for the old scenario (without any option passed)
+    CommandOptionKeyVariableSet myUnnamedOptionVariableSet;
+
+    //! the variable set of options that are allowed for setting an image as a background
+    CommandOptionKeyVariableSet myImageOptionVariableSet;
+
+    //! the variable set of options that are allowed for setting a background image fill type
+    CommandOptionKeyVariableSet myImageModeOptionVariableSet;
+
+    //! the variable set of options that are allowed for setting a gradient filling for the background
+    CommandOptionKeyVariableSet myGradientOptionVariableSet;
+
+    //! the variable set of options that are allowed for setting a background gradient filling method
+    CommandOptionKeyVariableSet myGradientModeOptionVariableSet;
+
+    //! the variable set of options that are allowed for filling a background with a specific color
+    CommandOptionKeyVariableSet myColorOptionVariableSet;
+
+    //! the variable set of options that are allowed for setting a default background gradient
+    CommandOptionKeyVariableSet myDefaultGradientOptionVariableSet;
+
+    //! the variable set of options that are allowed for setting a default background color
+    CommandOptionKeyVariableSet myDefaultColorOptionVariableSet;
+
+    //! the variable set of options that are allowed for printing help
+    CommandOptionKeyVariableSet myHelpOptionVariableSet;
+
+    //! Adds options to command parser
+    void addOptionsToCommandParser()
+    {
+      myImageOptionKey     = myCommandParser.AddOption ("imageFile|image|imgFile|img",
+                                                    "filename of image used as background");
+      myImageModeOptionKey = myCommandParser.AddOption (
+        "imageMode|imgMode", "image fill type, should be one of CENTERED, TILED, STRETCH, NONE");
+      myGradientOptionKey = myCommandParser.AddOption ("gradient|grad|gr",
+                                                       "sets background gradient starting and ending colors");
+      myGradientModeOptionKey =
+        myCommandParser.AddOption ("gradientMode|gradMode|gradMd|grMode|grMd",
+                                   "gradient fill method, should be one of NONE, HOR[IZONTAL], VER[TICAL], "
+                                   "DIAG[ONAL]1, DIAG[ONAL]2, CORNER1, CORNER2, CORNER3, CORNER4");
+      myColorOptionKey   = myCommandParser.AddOption ("color|col", "background color");
+      myDefaultOptionKey = myCommandParser.AddOption ("default|def", "sets background default gradient or color");
+    }
+
+    //! Creates option sets used to determine if a passed option set is valid or not
+    void createOptionSets()
+    {
+      ViewerTest_CommandOptionKeySet anUnnamedOptionSet;
+      anUnnamedOptionSet.insert (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY);
+      myUnnamedOptionVariableSet = CommandOptionKeyVariableSet (anUnnamedOptionSet);
+
+      ViewerTest_CommandOptionKeySet anImageOptionSet;
+      anImageOptionSet.insert (myImageOptionKey);
+      ViewerTest_CommandOptionKeySet anImageModeOptionSet;
+      anImageModeOptionSet.insert (myImageModeOptionKey);
+      myImageOptionVariableSet     = CommandOptionKeyVariableSet (anImageOptionSet, anImageModeOptionSet);
+      myImageModeOptionVariableSet = CommandOptionKeyVariableSet (anImageModeOptionSet);
+
+      ViewerTest_CommandOptionKeySet aGradientOptionSet;
+      aGradientOptionSet.insert (myGradientOptionKey);
+      ViewerTest_CommandOptionKeySet aGradientModeOptionSet;
+      aGradientModeOptionSet.insert (myGradientModeOptionKey);
+      myGradientOptionVariableSet     = CommandOptionKeyVariableSet (aGradientOptionSet, aGradientModeOptionSet);
+      myGradientModeOptionVariableSet = CommandOptionKeyVariableSet (aGradientModeOptionSet);
+
+      ViewerTest_CommandOptionKeySet aColorOptionSet;
+      aColorOptionSet.insert (myColorOptionKey);
+      myColorOptionVariableSet = CommandOptionKeyVariableSet (aColorOptionSet);
+
+      aGradientOptionSet.insert (myDefaultOptionKey);
+      myDefaultGradientOptionVariableSet = CommandOptionKeyVariableSet (aGradientOptionSet, aGradientModeOptionSet);
+      aColorOptionSet.insert (myDefaultOptionKey);
+      myDefaultColorOptionVariableSet = CommandOptionKeyVariableSet (aColorOptionSet);
+
+      ViewerTest_CommandOptionKeySet aHelpOptionSet;
+      aHelpOptionSet.insert (ViewerTest_CmdParser::THE_HELP_COMMAND_OPTION_KEY);
+      myHelpOptionVariableSet = CommandOptionKeyVariableSet (aHelpOptionSet);
+    }
+
+    //! Prepares the command parser. Adds options and creates option sets used to determine
+    //! if a passed option set is valid or not
+    void prepareCommandParser()
+    {
+      addOptionsToCommandParser();
+      createOptionSets();
+    }
+
+    //! Adds a command description to the command parser
+    //! @param theBackgroundCommand the key of the command which description is added to the command parser
+    void addCommandDescription (const BackgroundCommand theBackgroundCommand)
+    {
+      std::string aDescription;
+      bool        isMainCommand = false;
+      switch (theBackgroundCommand)
+      {
+        case BackgroundCommand_Main:
+          aDescription  = "Command: vbackground (changes background or some background settings)";
+          isMainCommand = true;
+          break;
+        case BackgroundCommand_Image:
+          aDescription = "Command: vsetbg (loads image as a background)";
+          break;
+        case BackgroundCommand_ImageMode:
+          aDescription = "Command: vsetbgmode (changes background fill type)";
+          break;
+        case BackgroundCommand_Gradient:
+          aDescription = "Command: vsetgradientbg (mounts gradient background)";
+          break;
+        case BackgroundCommand_GradientMode:
+          aDescription = "Command: vsetgradientbgmode (changes gradient background fill method)";
+          break;
+        case BackgroundCommand_Color:
+          aDescription = "Command: vsetcolorbg (sets color background)";
+          break;
+        case BackgroundCommand_Default:
+          aDescription = "Command: vsetdefaultbg (sets default viewer background gradient or fill color)";
+          break;
+        default:
+          return;
+      }
+      if (!isMainCommand)
+      {
+        aDescription += "\nThis command is obsolete. Use vbackground instead.";
+      }
+      myCommandParser.SetDescription (aDescription);
+    }
+
+    //! Check if a viewer is needed to be initialized
+    //! @param theBackgroundCommand the key of the command that changes the background
+    //! @return true if processing was successful, or false otherwise
+    bool checkViewerIsNeeded (const BackgroundCommand theBackgroundCommand) const
+    {
+      const bool                           isMain             = (theBackgroundCommand == BackgroundCommand_Main);
+      const ViewerTest_CommandOptionKeySet aUsedOptions       = myCommandParser.GetUsedOptions();
+      const bool                           aViewerIsNotNeeded =
+        (theBackgroundCommand == BackgroundCommand_Default)
+        || (myDefaultGradientOptionVariableSet.IsInSet (aUsedOptions) && isMain)
+        || (myDefaultColorOptionVariableSet.IsInSet (aUsedOptions) && isMain)
+        || myHelpOptionVariableSet.IsInSet (aUsedOptions);
+      return !aViewerIsNotNeeded;
+    }
+
+    //! Check if a viewer is initialized
+    //! @param theBackgroundCommandName the name of the command that changes the background
+    //! @param theDrawInterpretor the interpreter of the Draw Harness application
+    //! @return true if a viewer is initialized, or false otherwise
+    static bool checkViewerIsInitialized (const char* const theBackgroundCommandName,
+                                          Draw_Interpretor& theDrawInterpretor)
+    {
+      const Handle (AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext();
+      if (anAISContext.IsNull())
+      {
+        theDrawInterpretor << "Use 'vinit' command before executing '" << theBackgroundCommandName << "' command.\n";
+        return false;
+      }
+      return true;
+    }
+
+    //! Processes command options
+    //! @param theBackgroundCommandName the name of the command that changes the background
+    //! @param theBackgroundCommand the key of the command that changes the background
+    //! @param theDrawInterpretor the interpreter of the Draw Harness application
+    //! @return true if processing was successful, or false otherwise
+    bool processCommandOptions (const char* const       theBackgroundCommandName,
+                                const BackgroundCommand theBackgroundCommand,
+                                Draw_Interpretor&       theDrawInterpretor) const
+    {
+      if (myCommandParser.HasNoOption())
+      {
+        return printHelp (theBackgroundCommandName, theDrawInterpretor);
+      }
+      if (checkViewerIsNeeded (theBackgroundCommand)
+          && !checkViewerIsInitialized (theBackgroundCommandName, theDrawInterpretor))
+      {
+        return false;
+      }
+      if (myCommandParser.HasOnlyUnnamedOption())
+      {
+        return processUnnamedOption (theBackgroundCommand);
+      }
+      return processNamedOptions (theBackgroundCommandName, theBackgroundCommand, theDrawInterpretor);
+    }
+
+    //! Processes the unnamed option
+    //! @param theBackgroundCommand the key of the command that changes the background
+    //! @return true if processing was successful, or false otherwise
+    bool processUnnamedOption (const BackgroundCommand theBackgroundCommand) const
+    {
+      switch (theBackgroundCommand)
+      {
+        case BackgroundCommand_Main:
+          return false;
+        case BackgroundCommand_Image:
+          return processImageUnnamedOption();
+        case BackgroundCommand_ImageMode:
+          return processImageModeUnnamedOption();
+        case BackgroundCommand_Gradient:
+          return processGradientUnnamedOption();
+        case BackgroundCommand_GradientMode:
+          return processGradientModeUnnamedOption();
+        case BackgroundCommand_Color:
+          return processColorUnnamedOption();
+        case BackgroundCommand_Default:
+          return processDefaultUnnamedOption();
+        default:
+          return false;
+      }
+    }
+
+    //! Processes the image unnamed option
+    //! @return true if processing was successful, or false otherwise
+    bool processImageUnnamedOption() const
+    {
+      const std::size_t aNumberOfImageUnnamedOptionArguments = myCommandParser.GetNumberOfOptionArguments (
+        ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY);
+      if ((aNumberOfImageUnnamedOptionArguments != 1) && (aNumberOfImageUnnamedOptionArguments != 2))
+      {
+        return false;
+      }
+      std::string anImageFileName;
+      if (!myCommandParser.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, 0, anImageFileName))
+      {
+        return false;
+      }
+      Aspect_FillMethod anImageMode = Aspect_FM_CENTERED;
+      if (aNumberOfImageUnnamedOptionArguments == 2)
+      {
+        std::string anImageModeString;
+        if (!myCommandParser.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, 1, anImageModeString))
+        {
+          return false;
+        }
+        if (!getBackgroundImageFillMethodByName (anImageModeString.c_str(), anImageMode))
+        {
+          return false;
+        }
+      }
+      setImage (anImageFileName.c_str(), anImageMode);
+      return true;
+    }
+
+    //! Processes the image mode unnamed option
+    //! @return true if processing was successful, or false otherwise
+    bool processImageModeUnnamedOption() const
+    {
+      return processImageModeOptionSet (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY);
+    }
+
+    //! Processes the gradient unnamed option
+    //! @param theSetGradient the function used to set a background gradient filling
+    //! @return true if processing was successful, or false otherwise
+    bool processGradientUnnamedOption (SetGradientFunction* const theSetGradient = setGradient) const
+    {
+      const Standard_Integer aNumberOfGradientUnnamedOptionArguments = myCommandParser.GetNumberOfOptionArguments (
+        ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY);
+      if (aNumberOfGradientUnnamedOptionArguments < 2)
+      {
+        return false;
+      }
+
+      Standard_Integer anArgumentIndex = 0;
+      Quantity_Color   aColor1;
+      if (!myCommandParser.ArgColor (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, anArgumentIndex, aColor1))
+      {
+        return false;
+      }
+      if (anArgumentIndex >= aNumberOfGradientUnnamedOptionArguments)
+      {
+        return false;
+      }
+
+      Quantity_Color aColor2;
+      if (!myCommandParser.ArgColor (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, anArgumentIndex, aColor2))
+      {
+        return false;
+      }
+      if (anArgumentIndex > aNumberOfGradientUnnamedOptionArguments)
+      {
+        return false;
+      }
+
+      Aspect_GradientFillMethod aGradientMode = Aspect_GFM_HOR;
+      if (anArgumentIndex == aNumberOfGradientUnnamedOptionArguments - 1)
+      {
+        std::string anGradientModeString;
+
+        if (!myCommandParser.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY,
+                                  anArgumentIndex,
+                                  anGradientModeString))
+        {
+          return false;
+        }
+        if (!getBackgroundGradientFillMethodByName (anGradientModeString.c_str(), aGradientMode))
+        {
+          return false;
+        }
+        ++anArgumentIndex;
+      }
+      if (anArgumentIndex != aNumberOfGradientUnnamedOptionArguments)
+      {
+        return false;
+      }
+      theSetGradient (aColor1, aColor2, aGradientMode);
+      return true;
+    }
+
+    //! Processes the gradient mode unnamed option
+    //! @return true if processing was successful, or false otherwise
+    bool processGradientModeUnnamedOption() const
+    {
+      return processGradientModeOptionSet (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY);
+    }
+
+    //! Processes the color unnamed option
+    //! @param theSetColor the function used to set a background color
+    //! @return true if processing was successful, or false otherwise
+    bool processColorUnnamedOption (SetColorFunction* const theSetColor = setColor) const
+    {
+      return processColorOptionSet (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, theSetColor);
+    }
+
+    //! Processes the default back unnamed option
+    //! @return true if processing was successful, or false otherwise
+    bool processDefaultUnnamedOption() const
+    {
+      if (processGradientUnnamedOption (setDefaultGradient))
+      {
+        return true;
+      }
+      return processColorUnnamedOption (setDefaultColor);
+    }
+
+    //! Processes named options
+    //! @param theBackgroundCommandName the name of the command that changes the background
+    //! @param theBackgroundCommand the key of the command that changes the background
+    //! @param theDrawInterpretor the interpreter of the Draw Harness application
+    //! @return true if processing was successful, or false otherwise
+    bool processNamedOptions (const char* const       theBackgroundCommandName,
+                              const BackgroundCommand theBackgroundCommand,
+                              Draw_Interpretor&       theDrawInterpretor) const
+    {
+      const bool                           isMain       = (theBackgroundCommand == BackgroundCommand_Main);
+      const ViewerTest_CommandOptionKeySet aUsedOptions = myCommandParser.GetUsedOptions();
+      if (myImageOptionVariableSet.IsInSet (aUsedOptions)
+          && (isMain || (theBackgroundCommand == BackgroundCommand_Image)))
+      {
+        return processImageOptionSet();
+      }
+      if (myImageModeOptionVariableSet.IsInSet (aUsedOptions)
+          && (isMain || (theBackgroundCommand == BackgroundCommand_ImageMode)))
+      {
+        return processImageModeOptionSet();
+      }
+      if (myGradientOptionVariableSet.IsInSet (aUsedOptions)
+          && (isMain || (theBackgroundCommand == BackgroundCommand_Gradient)))
+      {
+        return processGradientOptionSet();
+      }
+      if (myGradientModeOptionVariableSet.IsInSet (aUsedOptions)
+          && (isMain || (theBackgroundCommand == BackgroundCommand_GradientMode)))
+      {
+        return processGradientModeOptionSet();
+      }
+      if (myColorOptionVariableSet.IsInSet (aUsedOptions)
+          && (isMain || (theBackgroundCommand == BackgroundCommand_Color)))
+      {
+        return processColorOptionSet();
+      }
+      if ((myDefaultGradientOptionVariableSet.IsInSet (aUsedOptions) && isMain)
+          || (myGradientOptionVariableSet.IsInSet (aUsedOptions)
+              && (theBackgroundCommand == BackgroundCommand_Default)))
+      {
+        return processDefaultGradientOptionSet();
+      }
+      if ((myDefaultColorOptionVariableSet.IsInSet (aUsedOptions) && isMain)
+          || (myColorOptionVariableSet.IsInSet (aUsedOptions) && (theBackgroundCommand == BackgroundCommand_Default)))
+      {
+        return processDefaultColorOptionSet();
+      }
+      if (myHelpOptionVariableSet.IsInSet (aUsedOptions))
+      {
+        return processHelpOptionSet (theBackgroundCommandName, theDrawInterpretor);
+      }
+      return false;
+    }
+
+    //! Processes the image option set
+    //! @return true if processing was successful, or false otherwise
+    bool processImageOptionSet() const
+    {
+      std::string anImageFileName;
+      if (!processImageOption (anImageFileName))
+      {
+        return false;
+      }
+      Aspect_FillMethod anImageMode = Aspect_FM_CENTERED;
+      if (myCommandParser.HasOption (myImageModeOptionKey) && !processImageModeOption (anImageMode))
+      {
+        return false;
+      }
+      setImage (anImageFileName.c_str(), anImageMode);
+      return true;
+    }
+
+    //! Processes the image mode option set
+    //! @return true if processing was successful, or false otherwise
+    bool processImageModeOptionSet() const
+    {
+      return processImageModeOptionSet (myImageModeOptionKey);
+    }
+
+    //! Processes the image mode option set
+    //! @param theImageModeOptionKey the key of the option that is interpreted as an image mode option
+    //! @return true if processing was successful, or false otherwise
+    bool processImageModeOptionSet (const ViewerTest_CommandOptionKey theImageModeOptionKey) const
+    {
+      Aspect_FillMethod anImageMode = Aspect_FM_NONE;
+      if (!processImageModeOption (theImageModeOptionKey, anImageMode))
+      {
+        return false;
+      }
+      setImageMode (anImageMode);
+      return true;
+    }
+
+    //! Processes the gradient option set
+    //! @param theSetGradient the function used to set a background gradient filling
+    //! @return true if processing was successful, or false otherwise
+    bool processGradientOptionSet (SetGradientFunction* const theSetGradient = setGradient) const
+    {
+      Quantity_Color aColor1;
+      Quantity_Color aColor2;
+      if (!processGradientOption (aColor1, aColor2))
+      {
+        return false;
+      }
+      Aspect_GradientFillMethod aGradientMode = Aspect_GFM_HOR;
+      if (myCommandParser.HasOption (myGradientModeOptionKey) && !processGradientModeOption (aGradientMode))
+      {
+        return false;
+      }
+      theSetGradient (aColor1, aColor2, aGradientMode);
+      return true;
+    }
+
+    //! Processes the gradient mode option set
+    //! @return true if processing was successful, or false otherwise
+    bool processGradientModeOptionSet() const
+    {
+      return processGradientModeOptionSet (myGradientModeOptionKey);
+    }
+
+    //! Processes the gradient mode option set
+    //! @param theGradientModeOptionKey the key of the option that is interpreted as a gradient mode option
+    //! @return true if processing was successful, or false otherwise
+    bool processGradientModeOptionSet (const ViewerTest_CommandOptionKey theGradientModeOptionKey) const
+    {
+      Aspect_GradientFillMethod aGradientMode = Aspect_GFM_NONE;
+      if (!processGradientModeOption (theGradientModeOptionKey, aGradientMode))
+      {
+        return false;
+      }
+      setGradientMode (aGradientMode);
+      return true;
+    }
+
+    //! Processes the color option set
+    //! @param theSetColor the function used to set a background color
+    //! @return true if processing was successful, or false otherwise
+    bool processColorOptionSet (SetColorFunction* const theSetColor = setColor) const
+    {
+      return processColorOptionSet (myColorOptionKey, theSetColor);
+    }
+
+    //! Processes the default color option set
+    //! @return true if processing was successful, or false otherwise
+    bool processDefaultGradientOptionSet() const
+    {
+      return processGradientOptionSet (setDefaultGradient);
+    }
+
+    //! Processes the default gradient option set
+    //! @return true if processing was successful, or false otherwise
+    bool processDefaultColorOptionSet() const
+    {
+      return processColorOptionSet (setDefaultColor);
+    }
+
+    //! Processes the color option set
+    //! @param theColorOptionKey the key of the option that is interpreted as a color option
+    //! @param theSetColor the function used to set a background color
+    //! @return true if processing was successful, or false otherwise
+    bool processColorOptionSet (const ViewerTest_CommandOptionKey theColorOptionKey,
+                                SetColorFunction* const           theSetColor = setColor) const
+    {
+      Quantity_Color aColor;
+      if (!processColorOption (theColorOptionKey, aColor))
+      {
+        return false;
+      }
+      theSetColor (aColor);
+      return true;
+    }
+
+    //! Processes the help option set
+    //! @param theBackgroundCommandName the name of the command that changes the background
+    //! @param theDrawInterpretor the interpreter of the Draw Harness application
+    //! @return true if processing was successful, or false otherwise
+    bool processHelpOptionSet (const char* const theBackgroundCommandName, Draw_Interpretor& theDrawInterpretor) const
+    {
+      const Standard_Integer aNumberOfHelpOptionArguments = myCommandParser.GetNumberOfOptionArguments (
+        ViewerTest_CmdParser::THE_HELP_COMMAND_OPTION_KEY);
+      if (aNumberOfHelpOptionArguments != 0)
+      {
+        return false;
+      }
+      return printHelp (theBackgroundCommandName, theDrawInterpretor);
+    }
+
+    //! Processes the image option
+    //! @param theImageFileName the filename of the image to be used as a background
+    //! @return true if processing was successful, or false otherwise
+    bool processImageOption (std::string& theImageFileName) const
+    {
+      const Standard_Integer aNumberOfImageOptionArguments = myCommandParser.GetNumberOfOptionArguments (
+        myImageOptionKey);
+      if (aNumberOfImageOptionArguments != 1)
+      {
+        return false;
+      }
+      std::string anImageFileName;
+      if (!myCommandParser.Arg (myImageOptionKey, 0, anImageFileName))
+      {
+        return false;
+      }
+      theImageFileName = anImageFileName;
+      return true;
+    }
+
+    //! Processes the image mode option
+    //! @param theImageMode the fill type used for a background image
+    //! @return true if processing was successful, or false otherwise
+    bool processImageModeOption (Aspect_FillMethod& theImageMode) const
+    {
+      return processImageModeOption (myImageModeOptionKey, theImageMode);
+    }
+
+    //! Processes the image mode option
+    //! @param theImageModeOptionKey the key of the option that is interpreted as an image mode option
+    //! @param theImageMode the fill type used for a background image
+    //! @return true if processing was successful, or false otherwise
+    bool processImageModeOption (const ViewerTest_CommandOptionKey theImageModeOptionKey,
+                                 Aspect_FillMethod&                theImageMode) const
+    {
+      return processModeOption (theImageModeOptionKey, getBackgroundImageFillMethodByName, theImageMode);
+    }
+
+    //! Processes the gradient option
+    //! @param theColor1 the gradient starting color
+    //! @param theColor2 the gradient ending color
+    //! @return true if processing was successful, or false otherwise
+    bool processGradientOption (Quantity_Color& theColor1, Quantity_Color& theColor2) const
+    {
+      Standard_Integer anArgumentIndex = 0;
+      Quantity_Color   aColor1;
+      if (!myCommandParser.ArgColor (myGradientOptionKey, anArgumentIndex, aColor1))
+      {
+        return false;
+      }
+      Quantity_Color aColor2;
+      if (!myCommandParser.ArgColor (myGradientOptionKey, anArgumentIndex, aColor2))
+      {
+        return false;
+      }
+      const Standard_Integer aNumberOfGradientOptionArguments = myCommandParser.GetNumberOfOptionArguments (
+        myGradientOptionKey);
+      if (anArgumentIndex != aNumberOfGradientOptionArguments)
+      {
+        return false;
+      }
+      theColor1 = aColor1;
+      theColor2 = aColor2;
+      return true;
+    }
+
+    //! Processes the gradient mode option
+    //! @param theGradientMode the fill method used for a background gradient filling
+    //! @return true if processing was successful, or false otherwise
+    bool processGradientModeOption (Aspect_GradientFillMethod& theGradientMode) const
+    {
+      return processGradientModeOption (myGradientModeOptionKey, theGradientMode);
+    }
+
+    //! Processes the gradient mode option
+    //! @param theGradientModeOptionKey the key of the option that is interpreted as a gradient mode option
+    //! @param theGradientMode the fill method used for a background gradient filling
+    //! @return true if processing was successful, or false otherwise
+    bool processGradientModeOption (const ViewerTest_CommandOptionKey theGradientModeOptionKey,
+                                    Aspect_GradientFillMethod&        theGradientMode) const
+    {
+      return processModeOption (theGradientModeOptionKey, getBackgroundGradientFillMethodByName, theGradientMode);
+    }
+
+    //! Processes some mode option
+    //! @tparam TheMode the type of a mode to be processed
+    //! @param theModeOptionKey the key of the option that is interpreted as a mode option
+    //! @param theMode a mode to be processed
+    //! @return true if processing was successful, or false otherwise
+    template <typename TheMode>
+    bool processModeOption (const ViewerTest_CommandOptionKey theModeOptionKey,
+                            bool (*const theGetModeByName) (const TCollection_AsciiString& /* theModeName */,
+                                                            TheMode& /* theMode */),
+                            TheMode& theMode) const
+    {
+      const Standard_Integer aNumberOfModeOptionArguments = myCommandParser.GetNumberOfOptionArguments (
+        theModeOptionKey);
+      if (aNumberOfModeOptionArguments != 1)
+      {
+        return false;
+      }
+      std::string aModeString;
+      if (!myCommandParser.Arg (theModeOptionKey, 0, aModeString))
+      {
+        return false;
+      }
+      TheMode aMode = TheMode();
+      if (!theGetModeByName (aModeString.c_str(), aMode))
+      {
+        return false;
+      }
+      theMode = aMode;
+      return true;
+    }
+
+    //! Processes the color option
+    //! @param theColor a color used for filling a background
+    //! @return true if processing was successful, or false otherwise
+    bool processColorOption (Quantity_Color& theColor) const
+    {
+      return processColorOption (myColorOptionKey, theColor);
+    }
+
+    //! Processes the color option
+    //! @param theColorOptionKey the key of the option that is interpreted as a color option
+    //! @param theColor a color used for filling a background
+    //! @return true if processing was successful, or false otherwise
+    bool processColorOption (const ViewerTest_CommandOptionKey theColorOptionKey, Quantity_Color& theColor) const
+    {
+      Standard_Integer anArgumentIndex = 0;
+      Quantity_Color   aColor;
+      if (!myCommandParser.ArgColor (theColorOptionKey, anArgumentIndex, aColor))
+      {
+        return false;
+      }
+      const Standard_Integer aNumberOfColorOptionArguments = myCommandParser.GetNumberOfOptionArguments (
+        theColorOptionKey);
+      if (anArgumentIndex != aNumberOfColorOptionArguments)
+      {
+        return false;
+      }
+      theColor = aColor;
+      return true;
+    }
+
+    //! Prints helping message
+    //! @param theBackgroundCommandName the name of the command that changes the background
+    //! @param theDrawInterpretor the interpreter of the Draw Harness application
+    //! @return true if printing was successful, or false otherwise
+    static bool printHelp (const char* const theBackgroundCommandName, Draw_Interpretor& theDrawInterpretor)
+    {
+      return theDrawInterpretor.PrintHelp (theBackgroundCommandName) == TCL_OK;
+    }
+
+    //! Sets the image as a background
+    //! @param theImageFileName the filename of the image to be used as a background
+    //! @param theImageMode the fill type used for a background image
+    static void setImage (const Standard_CString theImageFileName, const Aspect_FillMethod theImageMode)
+    {
+      const Handle (V3d_View)& aCurrentView = ViewerTest::CurrentView();
+      aCurrentView->SetBackgroundImage (theImageFileName, theImageMode, Standard_True);
+    }
+
+    //! Sets the fill type used for a background image
+    //! @param theImageMode the fill type used for a background image
+    static void setImageMode (const Aspect_FillMethod theImageMode)
+    {
+      const Handle (V3d_View)& aCurrentView = ViewerTest::CurrentView();
+      aCurrentView->SetBgImageStyle (theImageMode, Standard_True);
+    }
+
+    //! Sets the gradient filling for a background
+    //! @param theColor1 the gradient starting color
+    //! @param theColor2 the gradient ending color
+    //! @param theGradientMode the fill method used for a background gradient filling
+    static void setGradient (const Quantity_Color&           theColor1,
+                             const Quantity_Color&           theColor2,
+                             const Aspect_GradientFillMethod theGradientMode)
+    {
+      const Handle (V3d_View)& aCurrentView = ViewerTest::CurrentView();
+      aCurrentView->SetBgGradientColors (theColor1, theColor2, theGradientMode, Standard_True);
+    }
+
+    //! Sets the fill method used for a background gradient filling
+    //! @param theGradientMode the fill method used for a background gradient filling
+    static void setGradientMode (const Aspect_GradientFillMethod theGradientMode)
+    {
+      const Handle (V3d_View)& aCurrentView = ViewerTest::CurrentView();
+      aCurrentView->SetBgGradientStyle (theGradientMode, Standard_True);
+    }
+
+    //! Sets the color used for filling a background
+    //! @param theColor the color used for filling a background
+    static void setColor (const Quantity_Color& theColor)
+    {
+      const Handle (V3d_View)& aCurrentView = ViewerTest::CurrentView();
+      aCurrentView->SetBgGradientStyle (Aspect_GFM_NONE);
+      aCurrentView->SetBackgroundColor (theColor);
+      aCurrentView->Update();
+    }
+
+    //! Sets the gradient filling for a background in a default viewer
+    //! @param theColor1 the gradient starting color
+    //! @param theColor2 the gradient ending color
+    //! @param theGradientMode the fill method used for a background gradient filling
+    static void setDefaultGradient (const Quantity_Color&           theColor1,
+                                    const Quantity_Color&           theColor2,
+                                    const Aspect_GradientFillMethod theGradientMode)
+    {
+      ViewerTest_DefaultBackground.GradientColor1 = theColor1;
+      ViewerTest_DefaultBackground.GradientColor2 = theColor2;
+      ViewerTest_DefaultBackground.FillMethod     = theGradientMode;
+      setDefaultGradient();
+    }
+
+    //! Sets the color used for filling a background in a default viewer
+    //! @param theColor the color used for filling a background
+    static void setDefaultColor (const Quantity_Color& theColor)
+    {
+      ViewerTest_DefaultBackground.GradientColor1 = Quantity_Color();
+      ViewerTest_DefaultBackground.GradientColor2 = Quantity_Color();
+      ViewerTest_DefaultBackground.FillMethod     = Aspect_GFM_NONE;
+      ViewerTest_DefaultBackground.FlatColor      = theColor;
+      setDefaultGradient();
+      setDefaultColor();
+    }
+
+    //! Sets the gradient filling for a background in a default viewer.
+    //! Gradient settings are taken from ViewerTest_DefaultBackground structure
+    static void setDefaultGradient()
+    {
+      for (NCollection_DoubleMap<TCollection_AsciiString, Handle (AIS_InteractiveContext)>::Iterator
+             anInteractiveContextIterator (ViewerTest_myContexts);
+           anInteractiveContextIterator.More();
+           anInteractiveContextIterator.Next())
+      {
+        const Handle (V3d_Viewer)& aViewer = anInteractiveContextIterator.Value()->CurrentViewer();
+        aViewer->SetDefaultBgGradientColors (ViewerTest_DefaultBackground.GradientColor1,
+                                             ViewerTest_DefaultBackground.GradientColor2,
+                                             ViewerTest_DefaultBackground.FillMethod);
+      }
+    }
+
+    //! Sets the color used for filling a background in a default viewer.
+    //! The color value is taken from ViewerTest_DefaultBackground structure
+    static void setDefaultColor()
+    {
+      for (NCollection_DoubleMap<TCollection_AsciiString, Handle (AIS_InteractiveContext)>::Iterator
+             anInteractiveContextIterator (ViewerTest_myContexts);
+           anInteractiveContextIterator.More();
+           anInteractiveContextIterator.Next())
+      {
+        const Handle (V3d_Viewer)& aViewer = anInteractiveContextIterator.Value()->CurrentViewer();
+        aViewer->SetDefaultBackgroundColor (ViewerTest_DefaultBackground.FlatColor);
+      }
+    }
+  };
+
+} // namespace
 
 Standard_EXPORT const Handle(AIS_RubberBand)& GetRubberBand()
 {
@@ -3251,263 +4276,36 @@ while (ViewerMainLoop( argc, argv)) {
 return 0;
 }
 
-//==============================================================================
-//function : VSetBg
-//purpose  : Load image as background
-//==============================================================================
-
-static int VSetBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
-  if (argc < 2 || argc > 3)
-  {
-    di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background\n";
-    di << "filltype can be one of CENTERED, TILED, STRETCH, NONE\n";
-    return 1;
-  }
-
-  Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
-  if(AISContext.IsNull())
-  {
-    di << "use 'vinit' command before " << argv[0] << "\n";
-    return 1;
-  }
-
-  Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
-  if (argc == 3)
-  {
-    const char* szType = argv[2];
-    if      (strcmp(szType, "NONE"    ) == 0) aFillType = Aspect_FM_NONE;
-    else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
-    else if (strcmp(szType, "TILED"   ) == 0) aFillType = Aspect_FM_TILED;
-    else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
-    else
-    {
-      di << "Wrong fill type : " << szType << "\n";
-      di << "Must be one of CENTERED, TILED, STRETCH, NONE\n";
-      return 1;
-    }
-  }
-
-  Handle(V3d_View) V3dView = ViewerTest::CurrentView();
-  V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
-
-  return 0;
-}
-
-//==============================================================================
-//function : VSetBgMode
-//purpose  : Change background image fill type
-//==============================================================================
-
-static int VSetBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
-  if (argc != 2)
-  {
-    di << "Usage : " << argv[0] << " filltype : Change background image mode\n";
-    di << "filltype must be one of CENTERED, TILED, STRETCH, NONE\n";
-    return 1;
-  }
-
-  Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
-  if(AISContext.IsNull())
-  {
-    di << "use 'vinit' command before " << argv[0] << "\n";
-    return 1;
-  }
-  Aspect_FillMethod aFillType = Aspect_FM_NONE;
-  const char* szType = argv[1];
-  if      (strcmp(szType, "NONE"    ) == 0) aFillType = Aspect_FM_NONE;
-  else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
-  else if (strcmp(szType, "TILED"   ) == 0) aFillType = Aspect_FM_TILED;
-  else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
-  else
-  {
-    di << "Wrong fill type : " << szType << "\n";
-    di << "Must be one of CENTERED, TILED, STRETCH, NONE\n";
-    return 1;
-  }
-  Handle(V3d_View) V3dView = ViewerTest::CurrentView();
-  V3dView->SetBgImageStyle(aFillType, Standard_True);
-  return 0;
-}
-
-//==============================================================================
-//function : VSetGradientBg
-//purpose  : Mount gradient background
-//==============================================================================
-static int VSetGradientBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+namespace
 {
-  if (argc != 8 )
-  {
-    di << "Usage : " << argv[0] << " R1 G1 B1 R2 G2 B2 Type : Mount gradient background\n";
-    di << "R1,G1,B1,R2,G2,B2 = [0..255]\n";
-    di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2\n";
-    di << "                    5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4\n";
-    return 1;
-  }
 
-  Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
-  if(AISContext.IsNull())
-  {
-    di << "use 'vinit' command before " << argv[0] << "\n";
-    return 1;
-  }
-  if (argc == 8)
+  //! Changes the background
+  //! @param theDrawInterpretor the interpreter of the Draw Harness application
+  //! @param theNumberOfCommandLineArguments the number of passed command line arguments
+  //! @param theCommandLineArguments the array of command line arguments
+  //! @return TCL_OK if changing was successful, or TCL_ERROR otherwise
+  static int vbackground (Draw_Interpretor&      theDrawInterpretor,
+                          const Standard_Integer theNumberOfCommandLineArguments,
+                          const char** const     theCommandLineArguments)
   {
-
-    Standard_Real R1 = Draw::Atof(argv[1])/255.;
-    Standard_Real G1 = Draw::Atof(argv[2])/255.;
-    Standard_Real B1 = Draw::Atof(argv[3])/255.;
-    Quantity_Color aColor1(R1,G1,B1,Quantity_TOC_RGB);
-
-    Standard_Real R2 = Draw::Atof(argv[4])/255.;
-    Standard_Real G2 = Draw::Atof(argv[5])/255.;
-    Standard_Real B2 = Draw::Atof(argv[6])/255.;
-
-    Quantity_Color aColor2(R2,G2,B2,Quantity_TOC_RGB);
-    int aType = Draw::Atoi(argv[7]);
-    if( aType < 0 || aType > 8 )
+    if (theNumberOfCommandLineArguments < 1)
     {
-      di << "Wrong fill type \n";
-      di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2\n";
-      di << "               5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4\n";
-      return 1;
+      return TCL_ERROR;
     }
-
-    Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType);
-
-    Handle(V3d_View) V3dView = ViewerTest::CurrentView();
-    V3dView->SetBgGradientColors( aColor1, aColor2, aMethod, 1);
-  }
-
-  return 0;
-}
-
-//==============================================================================
-//function : VSetGradientBgMode
-//purpose  : Change gradient background fill style
-//==============================================================================
-static int VSetGradientBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
-  if (argc != 2 )
-  {
-    di << "Usage : " << argv[0] << " Type : Change gradient background fill type\n";
-    di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2\n";
-    di << "                    5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4\n";
-    return 1;
-  }
-
-  Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
-  if(AISContext.IsNull())
-  {
-    di << "use 'vinit' command before " << argv[0] << "\n";
-    return 1;
-  }
-  if (argc == 2)
-  {
-    int aType = Draw::Atoi(argv[1]);
-    if( aType < 0 || aType > 8 )
+    BackgroundChanger aBackgroundChanger;
+    if (!aBackgroundChanger.ProcessCommandLine (theDrawInterpretor,
+                                                theNumberOfCommandLineArguments,
+                                                theCommandLineArguments))
     {
-      di << "Wrong fill type \n";
-      di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2\n";
-      di << "               5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4\n";
-      return 1;
+      theDrawInterpretor << "Wrong command arguments.\n"
+                            "Type 'help "
+                         << theCommandLineArguments[0] << "' for information about command options and its arguments.\n";
+      return TCL_ERROR;
     }
-
-    Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType);
-
-    Handle(V3d_View) V3dView = ViewerTest::CurrentView();
-    V3dView->SetBgGradientStyle( aMethod, 1 );
-  }
-
-  return 0;
-}
-
-//==============================================================================
-//function : VSetColorBg
-//purpose  : Set color background
-//==============================================================================
-static int VSetColorBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
-  if (argc != 4 )
-  {
-    di << "Usage : " << argv[0] << " R G B : Set color background\n";
-    di << "R,G,B = [0..255]\n";
-    return 1;
-  }
-
-  Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
-  if(AISContext.IsNull())
-  {
-    di << "use 'vinit' command before " << argv[0] << "\n";
-    return 1;
-  }
-  if (argc == 4)
-  {
-
-    Standard_Real R = Draw::Atof(argv[1])/255.;
-    Standard_Real G = Draw::Atof(argv[2])/255.;
-    Standard_Real B = Draw::Atof(argv[3])/255.;
-    Quantity_Color aColor(R,G,B,Quantity_TOC_RGB);
-
-    Handle(V3d_View) V3dView = ViewerTest::CurrentView();
-    V3dView->SetBackgroundColor( aColor );
-    V3dView->Update();
+    return TCL_OK;
   }
 
-  return 0;
-}
-
-//==============================================================================
-//function : VSetDefaultBg
-//purpose  : Set default viewer background fill color
-//==============================================================================
-static int VSetDefaultBg (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
-{
-  if (theArgNb != 4
-   && theArgNb != 8)
-  {
-    std::cout << "Error: wrong syntax! See usage:\n";
-    theDI.PrintHelp (theArgVec[0]);
-    return 1;
-  }
-
-  ViewerTest_DefaultBackground.FillMethod =
-    theArgNb == 4 ? Aspect_GFM_NONE
-                  : (Aspect_GradientFillMethod) Draw::Atoi (theArgVec[7]);
-
-  if (theArgNb == 4)
-  {
-    Standard_Real R = Draw::Atof (theArgVec[1]) / 255.;
-    Standard_Real G = Draw::Atof (theArgVec[2]) / 255.;
-    Standard_Real B = Draw::Atof (theArgVec[3]) / 255.;
-    ViewerTest_DefaultBackground.FlatColor.SetValues (R, G, B, Quantity_TOC_RGB);
-  }
-  else
-  {
-    Standard_Real R1 = Draw::Atof (theArgVec[1]) / 255.;
-    Standard_Real G1 = Draw::Atof (theArgVec[2]) / 255.;
-    Standard_Real B1 = Draw::Atof (theArgVec[3]) / 255.;
-    ViewerTest_DefaultBackground.GradientColor1.SetValues (R1, G1, B1, Quantity_TOC_RGB);
-
-    Standard_Real R2 = Draw::Atof (theArgVec[4]) / 255.;
-    Standard_Real G2 = Draw::Atof (theArgVec[5]) / 255.;
-    Standard_Real B2 = Draw::Atof (theArgVec[6]) / 255.;
-    ViewerTest_DefaultBackground.GradientColor2.SetValues (R2, G2, B2, Quantity_TOC_RGB);
-  }
-
-  for (NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
-       anIter (ViewerTest_myContexts); anIter.More(); anIter.Next())
-  {
-    const Handle(V3d_Viewer)& aViewer = anIter.Value()->CurrentViewer();
-    aViewer->SetDefaultBackgroundColor (ViewerTest_DefaultBackground.FlatColor);
-    aViewer->SetDefaultBgGradientColors (ViewerTest_DefaultBackground.GradientColor1,
-                                         ViewerTest_DefaultBackground.GradientColor2,
-                                         ViewerTest_DefaultBackground.FillMethod);
-  }
-
-  return 0;
-}
+} // namespace
 
 //==============================================================================
 //function : VScale
@@ -11981,7 +12779,7 @@ static int VManipulator (Draw_Interpretor& theDi,
   }
 
   ViewerTest_CmdParser aCmd;
-  aCmd.AddDescription ("Manages manipulator for interactive objects:");
+  aCmd.SetDescription ("Manages manipulator for interactive objects:");
   aCmd.AddOption ("attach",         "... object - attach manipulator to an object");
   aCmd.AddOption ("adjustPosition", "... {0|1} - adjust position when attaching");
   aCmd.AddOption ("adjustSize",     "... {0|1} - adjust size when attaching ");
@@ -12017,7 +12815,7 @@ static int VManipulator (Draw_Interpretor& theDi,
 
   ViewerTest_DoubleMapOfInteractiveAndName& aMapAIS = GetMapOfAIS();
 
-  TCollection_AsciiString aName (aCmd.Arg ("", 0).c_str());
+  TCollection_AsciiString aName (aCmd.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, 0).c_str());
 
   if (aName.IsEmpty())
   {
@@ -12800,26 +13598,88 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "vclear          : vclear"
     "\n\t\t: remove all the object from the viewer",
     __FILE__,VClear,group);
-  theCommands.Add("vsetbg",
-    "vsetbg          : vsetbg imagefile [filltype] : Load image as background",
-    __FILE__,VSetBg,group);
-  theCommands.Add("vsetbgmode",
-    "vsetbgmode      : vsetbgmode filltype : Change background image fill type",
-    __FILE__,VSetBgMode,group);
-  theCommands.Add("vsetgradientbg",
-    "vsetgradientbg  : vsetgradientbg r1 g1 b1 r2 g2 b2 filltype : Mount gradient background",
-    __FILE__,VSetGradientBg,group);
-  theCommands.Add("vsetgrbgmode",
-    "vsetgrbgmode    : vsetgrbgmode filltype : Change gradient background fill type",
-    __FILE__,VSetGradientBgMode,group);
-  theCommands.Add("vsetcolorbg",
-    "vsetcolorbg     : vsetcolorbg r g b : Set background color",
-    __FILE__,VSetColorBg,group);
-  theCommands.Add("vsetdefaultbg",
-    "vsetdefaultbg r g b\n"
-    "\n\t\t: vsetdefaultbg r1 g1 b1 r2 g2 b2 fillmode"
-    "\n\t\t: Set default viewer background fill color (flat/gradient).",
-    __FILE__,VSetDefaultBg,group);
+  theCommands.Add (
+    "vbackground",
+    "Changes background or some background settings.\n"
+    "\n"
+    "Usage:\n"
+    "  vbackground -imageFile ImageFile [-imageMode FillType]\n"
+    "  vbackground -imageMode FillType\n"
+    "  vbackground -gradient Color1 Color2 [-gradientMode FillMethod]\n"
+    "  vbackground -gradientMode FillMethod\n"
+    "  vbackground -color Color\n"
+    "  vbackground -default -gradient Color1 Color2 [-gradientMode FillType]\n"
+    "  vbackground -default -color Color\n"
+    "  vbackground -help\n"
+    "\n"
+    "Options:\n"
+    "  -imageFile    (-imgFile, -image, -img):             sets filename of image used as background\n"
+    "  -imageMode    (-imgMode, -imageMd, -imgMd):         sets image fill type\n"
+    "  -gradient     (-grad, -gr):                         sets background gradient starting and ending colors\n"
+    "  -gradientMode (-gradMode, -gradMd, -grMode, -grMd): sets gradient fill method\n"
+    "  -color        (-col):                               sets background color\n"
+    "  -default      (-def):                               sets background default gradient or color\n"
+    "  -help         (-h):                                 outputs short help message\n"
+    "\n"
+    "Arguments:\n"
+    "  Color:      Red Green Blue  - where Red, Green, Blue must be integers within the range [0, 255]\n"
+    "                                  or reals within the range [0.0, 1.0]\n"
+    "              ColorName       - one of WHITE, BLACK, RED, GREEN, BLUE, etc.\n"
+    "              #HHH, [#]HHHHHH - where H is a hexadecimal digit (0 .. 9, a .. f, or A .. F)\n"
+    "  FillMethod: one of NONE, HOR[IZONTAL], VER[TICAL], DIAG[ONAL]1, DIAG[ONAL]2, CORNER1, CORNER2, CORNER3, "
+    "CORNER4\n"
+    "  FillType:   one of CENTERED, TILED, STRETCH, NONE\n"
+    "  ImageFile:  a name of the file with the image used as a background\n",
+    __FILE__,
+    vbackground,
+    group);
+  theCommands.Add ("vsetbg",
+                   "Loads image as background."
+                   "\n\t\t: vsetbg ImageFile [FillType]"
+                   "\n\t\t: vsetbg -imageFile ImageFile [-imageMode FillType]"
+                   "\n\t\t: Alias for 'vbackground -imageFile ImageFile [-imageMode FillType]'.",
+                   __FILE__,
+                   vbackground,
+                   group);
+  theCommands.Add ("vsetbgmode",
+                   "Changes background image fill type."
+                   "\n\t\t: vsetbgmode [-imageMode] FillType"
+                   "\n\t\t: Alias for 'vbackground -imageMode FillType'.",
+                   __FILE__,
+                   vbackground,
+                   group);
+  theCommands.Add ("vsetgradientbg",
+                   "Mounts gradient background."
+                   "\n\t\t: vsetgradientbg Color1 Color2 [FillMethod]"
+                   "\n\t\t: vsetgradientbg -gradient Color1 Color2 [-gradientMode FillMethod]"
+                   "\n\t\t: Alias for 'vbackground -gradient Color1 Color2 -gradientMode FillMethod'.",
+                   __FILE__,
+                   vbackground,
+                   group);
+  theCommands.Add ("vsetgrbgmode",
+                   "Changes gradient background fill method."
+                   "\n\t\t: vsetgrbgmode [-gradientMode] FillMethod"
+                   "\n\t\t: Alias for 'vbackground -gradientMode FillMethod'.",
+                   __FILE__,
+                   vbackground,
+                   group);
+  theCommands.Add ("vsetcolorbg",
+                   "Sets background color."
+                   "\n\t\t: vsetcolorbg [-color] Color."
+                   "\n\t\t: Alias for 'vbackground -color Color'.",
+                   __FILE__,
+                   vbackground,
+                   group);
+  theCommands.Add ("vsetdefaultbg",
+                   "Sets default viewer background fill color (flat/gradient)."
+                   "\n\t\t: vsetdefaultbg Color1 Color2 [FillMethod]"
+                   "\n\t\t: vsetdefaultbg -gradient Color1 Color2 [-gradientMode FillMethod]"
+                   "\n\t\t: Alias for 'vbackground -default -gradient Color1 Color2 [-gradientMode FillMethod]'."
+                   "\n\t\t: vsetdefaultbg [-color] Color"
+                   "\n\t\t: Alias for 'vbackground -default -color Color'.",
+                   __FILE__,
+                   vbackground,
+                   group);
   theCommands.Add("vscale",
     "vscale          : vscale X Y Z",
     __FILE__,VScale,group);
@@ -13422,3 +14282,4 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     __FILE__, VProgressiveMode, group);
 #endif
 }
+
index 53af177..e576f70 100755 (executable)
@@ -5,7 +5,7 @@ puts ""
 
 vinit View1
 
-vsetbg [locate_data_file OCC1188.gif]
+vbackground -image [locate_data_file OCC1188.gif]
 if { [vreadpixel 200 200 rgb name] != "WHITE" } { puts "Error: image background is not set" }
 
 vdump $imagedir/${casename}.png
index 3d3852a..dfb7c27 100755 (executable)
@@ -2,40 +2,15 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 255
-set G1 0
-set B1 0
-set R2 0
-set G2 0
-set B2 255
-set Type 0
 
 puts "${BugNumber}"
 puts "Type=NONE, Color from RED to BLUE"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient RED BLUE1 -gradientMode NONE
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 251c8c6..c73519c 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 255
-set G1 0
-set B1 0
-set R2 0
-set G2 0
-set B2 255
-set Type 5
-
 puts "${BugNumber}"
 puts "Type=CORNER1, Color from RED to BLUE, Direction from LEFT TOP CORNER"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient RED BLUE1 -gradientMode CORNER1
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 0db85b5..bbca109 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 255
-set G1 0
-set B1 0
-set R2 0
-set G2 0
-set B2 255
-set Type 6
-
 puts "${BugNumber}"
 puts "Type=CORNER2, Color from RED to BLUE, Direction from RIGHT TOP CORNER"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient RED BLUE1 -gradientMode CORNER2
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 7930131..eccff5e 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 255
-set G1 0
-set B1 0
-set R2 0
-set G2 0
-set B2 255
-set Type 7
-
 puts "${BugNumber}"
 puts "Type=CORNER3, Color from RED to BLUE, Direction from RIGHT BOTTOM CORNER"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient RED BLUE1 -gradientMode CORNER3
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 3750c41..e11807c 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 255
-set G1 0
-set B1 0
-set R2 0
-set G2 0
-set B2 255
-set Type 8
-
 puts "${BugNumber}"
 puts "Type=CORNER4, Color from RED to BLUE, Direction from LEFT BOTTOM CORNER"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient RED BLUE1 -gradientMode CORNER4
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 330f8e8..dc69bcf 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 0
-set G1 0
-set B1 255
-set R2 255
-set G2 0
-set B2 0
-set Type 5
-
 puts "${BugNumber}"
 puts "Type=CORNER1, Color from BLUE to RED, Direction from LEFT TOP CORNER"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient BLUE1 RED -gradientMode CORNER1
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index d41c0f2..a3eaec9 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 0
-set G1 0
-set B1 255
-set R2 255
-set G2 0
-set B2 0
-set Type 6
-
 puts "${BugNumber}"
 puts "Type=CORNER2, Color from BLUE to RED, Direction from RIGHT TOP CORNER"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient BLUE1 RED -gradientMode CORNER2
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index f207187..4823543 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 0
-set G1 0
-set B1 255
-set R2 255
-set G2 0
-set B2 0
-set Type 7
-
 puts "${BugNumber}"
 puts "Type=CORNER3, Color from BLUE to RED, Direction from RIGHT BOTTOM CORNER"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient BLUE1 RED -gradientMode CORNER3
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 383145e..0f881ad 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 0
-set G1 0
-set B1 255
-set R2 255
-set G2 0
-set B2 0
-set Type 8
-
 puts "${BugNumber}"
 puts "Type=CORNER4, Color from BLUE to RED, Direction from LEFT BOTTOM CORNER"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient BLUE1 RED -gradientMode CORNER4
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 0fc15f3..d5b40f8 100755 (executable)
@@ -2,40 +2,15 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 255
-set G1 0
-set B1 0
-set R2 0
-set G2 0
-set B2 255
-set Type 1
 
 puts "${BugNumber}"
 puts "Type=HORIZONTAL, Color from RED to BLUE, Direction from LEFT to RIGHT"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient RED BLUE1 -gradientMode HORIZONTAL
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 6eb07b4..120c64b 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 0
-set G1 0
-set B1 255
-set R2 255
-set G2 0
-set B2 0
-set Type 1
-
 puts "${BugNumber}"
 puts "Type=HORIZONTAL, Color from BLUE to RED, Direction from LEFT to RIGHT"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient BLUE1 RED -gradientMode HORIZONTAL
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index f6f0768..ac8031a 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 255
-set G1 0
-set B1 0
-set R2 0
-set G2 0
-set B2 255
-set Type 2
-
 puts "${BugNumber}"
 puts "Type=VERTICAL, Color from RED to BLUE, Direction from TOP to BOTTOM"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient RED BLUE1 -gradientMode VERTICAL
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 2eb6167..2cf45cc 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 0
-set G1 0
-set B1 255
-set R2 255
-set G2 0
-set B2 0
-set Type 2
-
 puts "${BugNumber}"
 puts "Type=VERTICAL, Color from BLUE to RED, Direction from TOP to BOTTOM"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient BLUE1 RED -gradientMode VERTICAL
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index b1af9f9..1f5fbc5 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 255
-set G1 0
-set B1 0
-set R2 0
-set G2 0
-set B2 255
-set Type 3
-
 puts "${BugNumber}"
 puts "Type=DIAGONAL1, Color from RED to BLUE, Direction from LEFT TOP CORNER to RIGHT BOTTOM CORNER"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient RED BLUE1 -gradientMode DIAGONAL1
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 2c7d134..1d54454 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 0
-set G1 0
-set B1 255
-set R2 255
-set G2 0
-set B2 0
-set Type 3
-
 puts "${BugNumber}"
 puts "Type=DIAGONAL1, Color from BLUE to RED, Direction from LEFT TOP CORNER to RIGHT BOTTOM CORNER"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient BLUE1 RED -gradientMode DIAGONAL1
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 5d70453..92b9ba8 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 255
-set G1 0
-set B1 0
-set R2 0
-set G2 0
-set B2 255
-set Type 4
-
 puts "${BugNumber}"
 puts "Type=DIAGONAL2, Color from RED to BLUE, Direction from RIGHT TOP CORNER to LEFT BOTTOM CORNER"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient RED BLUE1 -gradientMode DIAGONAL2
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index fcc4d67..80fcccf 100755 (executable)
@@ -2,40 +2,14 @@ puts "============"
 puts "OCC21747"
 puts "============"
 puts ""
-#######################################################################
-# Implementation of gradient background style 
-# 
-# vsetgradientbg: vsetgradientbg R1 G1 B1 R2 G2 B2 Type
-# R1\G1\B1 - First color [0..255]
-# R2\G2\B2 - Second color [0..255]
-# Type 0 to 8
-# 0 = NONE,
-# 1 = HORIZONTAL,
-# 2 = VERTICAL,
-# 3 = DIAGONAL1,
-# 4 = DIAGONAL2,
-# 5 = CORNER1,
-# 6 = CORNER2,
-# 7 = CORNER3,
-# 8 = CORNER4
-#######################################################################
 
 set BugNumber OCC21747
 
 vinit
 
-set R1 0
-set G1 0
-set B1 255
-set R2 255
-set G2 0
-set B2 0
-set Type 4
-
 puts "${BugNumber}"
 puts "Type=DIAGONAL2, Color from BLUE to RED, Direction from RIGHT TOP CORNER to LEFT BOTTOM CORNER"
-puts "R1=${R1} G1=${G1} B1=${B1} R2=${R2} G2=${G2} B2=${B2} Type=${Type}"
 
-vsetgradientbg ${R1} ${G1} ${B1} ${R2} ${G2} ${B2} ${Type}
+vbackground -gradient BLUE1 RED -gradientMode DIAGONAL2
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index e0f5fc7..ab6558a 100755 (executable)
@@ -21,7 +21,7 @@ set x4 87
 set y4 232
 
 vinit
-vsetgradientbg 255 0 0 0 0 255 4
+vbackground -gradient RED BLUE1 -gradientMode DIAGONAL2
 set Color1 [vreadpixel ${x1} ${y1} rgb]
 set Color2 [vreadpixel ${x2} ${y2} rgb]
 set Color3 [vreadpixel ${x3} ${y3} rgb]
index 7840aba..b2e688b 100755 (executable)
@@ -9,7 +9,7 @@ puts ""
 set BugNumber OCC23102
 
 vinit
-vsetbg [locate_data_file OCC23102.bmp] TILED
+vbackground -image [locate_data_file OCC23102.bmp] -imageMode TILED
 
 set x1 58
 set y1 4
index eb307c6..cfc3865 100755 (executable)
@@ -6,7 +6,7 @@ puts ""
 vclear
 vinit View1
 vaxo
-vsetgradientbg 250 0 0 0 255 0 2
+vbackground -gradient 0.980392 0 0 GREEN -gradientMode VERTICAL
 pcylinder p 100 200
 vdisplay -dispMode 1 p
 vaspects p -setInteriorStyle HOLLOW -setDrawEdges 1
index 1ba94b0..078dfc9 100644 (file)
@@ -9,16 +9,16 @@ set aTextureFile [locate_data_file hatch_1.png]
 pload VISUALIZATION
 vinit View1
 
-vsetbg $aTextureFile STRETCH
+vbackground -image $aTextureFile -imageMode STRETCH
 vdump $imagedir/${casename}_1.png
 
-vsetbg $aTextureFile NONE
-vsetbg $aTextureFile TILED
+vbackground -image $aTextureFile -imageMode NONE
+vbackground -image $aTextureFile -imageMode TILED
 vdump $imagedir/${casename}_2.png
 
-vsetgradientbg 255 0 0 0 0 255 1
-vsetbg $aTextureFile CENTERED
+vbackground -gradient RED BLUE1 -gradientMode HORIZONTAL
+vbackground -image $aTextureFile -imageMode CENTERED
 vdump $imagedir/${casename}_3.png
 
-vsetbg $aTextureFile NONE
+vbackground -image $aTextureFile -imageMode NONE
 vdump $imagedir/${casename}_4.png
index fa8dd32..f1b7aba 100644 (file)
@@ -7,7 +7,7 @@ puts ""
 ################################################################
 
 pload ALL
-vsetdefaultbg 0 0 0 64 64 64 1
+vbackground -default -gradient BLACK GRAY25 -gradientMode HORIZONTAL
 vinit View1 w=400 h=400
 if { [checkcolor 399 100 0.25 0.25 0.25] != 1 } {
   puts "Error: bug with default gradient color is reproduced."
@@ -18,7 +18,7 @@ if { [checkcolor 399 100 0.25 0.25 0.25] != 1 } {
   puts "Error: bug with default gradient color is reproduced."
 }
 
-vsetdefaultbg 128 128 128
+vbackground -default -color 0.501961 0.501961 0.501961
 vinit View3
 if { [checkcolor 100 100 0.5 0.5 0.5] != 1 } {
   puts "Error: bug with default background color is reproduced."
index 8b254f0..55b9839 100644 (file)
@@ -20,11 +20,11 @@ vclipplane create pln
 vclipplane set pln view Driver1/Viewer1/View1
 vclipplane change pln equation 0 1 0 -0.5
 
-vsetgradientbg 0 0 0 0 0 0 0
+vbackground -gradient BLACK BLACK -gradientMode NONE
 
 vdump $aExpectedImg
 
-vsetgradientbg 0 0 0 0 0 0 1
+vbackground -gradient BLACK BLACK -gradientMode HORIZONTAL
 
 vdump $aVerifiedImg
 
index 81f43a8..21cfdbf 100644 (file)
@@ -11,7 +11,7 @@ vinit View1
 vclear
 vaxo
 vsetdispmode 1
-vsetcolorbg 10 10 10
+vbackground -color GRAY4
 vdisplay b
 vfit
 vraytrace 1
@@ -19,8 +19,8 @@ set bug_info_1 [vreadpixel 50 50 rgb name]
 if {$bug_info_1 != "GRAY4"} {
   puts "ERROR: OCC26404 is reproduced. Background color is invalid (case #1)."
 }
-vsetgradientbg 255 0 0 0 0 255 1
-vsetgradientbg 255 0 0 0 0 255 0
+vbackground -gradient RED BLUE1 -gradientMode HORIZONTAL
+vbackground -gradient RED BLUE1 -gradientMode NONE
 set bug_info_2 [vreadpixel 50 50 rgb name]
 if {$bug_info_2 != "GRAY4"} {
   puts "ERROR: OCC26404 is reproduced. Background color is invalid (case #2)."
index 8854b47..6ae9f9b 100755 (executable)
@@ -13,7 +13,7 @@ vinit View1
 vclear
 vaxo
 
-vsetgradientbg 255 0 0 0 0 255 2
+vbackground -gradient RED BLUE1 -gradientMode VERTICAL
 box b 1 2 3
 vdisplay b
 
index 61a9e66..cc70b24 100644 (file)
@@ -11,7 +11,7 @@ box b 0 0 -100 100 90 10
 vclear
 vinit View1
 vaxo
-vsetgradientbg 180 200 255 180 180 180 2
+vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 vzbufftrihedron
 vdisplay -dispMode 1 b
 vsetlocation b 0 0 1000
index eec0d73..847e64e 100644 (file)
@@ -7,7 +7,7 @@ pload MODELING VISUALIZATION
 
 vclear
 vinit View1
-vsetcolorbg 255 255 255
+vbackground -color WHITE
 
 psphere s1 1
 psphere s2 1
index e4f1ccf..b108e53 100644 (file)
@@ -6,9 +6,9 @@ puts ""
 pload VISUALIZATION
 vclear
 vinit View1
-vsetcolorbg 127 127 127
+vbackground -color GRAY50
 vdump $imagedir/${casename}_127.png
-vsetcolorbg 130 130 130
+vbackground -color GRAY51
 vdump $imagedir/${casename}_130.png
 set aNbDiff0  [diffimage $imagedir/${casename}_127.png $imagedir/${casename}_130.png $imagedir/${casename}_0.png  -toleranceOfColor 0]
 set aNbDiff1  [diffimage $imagedir/${casename}_127.png $imagedir/${casename}_130.png $imagedir/${casename}_1.png  -toleranceOfColor 0.1]
index b852e5b..1ca952e 100644 (file)
@@ -9,7 +9,7 @@ vclear
 vclose ALL
 vinit View1 -width 768 -height 409
 vzbufftrihedron
-vsetgradientbg 180 200 255 180 180 180 2
+vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 box b1 -2 0  2 1 0.2 1
 box b2  2 0  2 1 0.2 1
 box b3  0 0  0 1 0.2 1
index da4fc73..76fe339 100644 (file)
@@ -7,7 +7,7 @@ box b 2 3 1
 vclear
 vclose ALL
 vinit View1 w=512 h=512
-vsetgradientbg 180 200 255 180 180 180 2
+vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 vsetdispmode 0
 vdisplay b
 vfit
index 40e4fc5..cd2b298 100644 (file)
@@ -8,8 +8,8 @@ pload MODELING VISUALIZATION
 
 vclear
 vinit View1
-vsetcolorbg 220 220 220
-#vsetgradientbg 180 200 255 180 180 180 2
+vbackground -color GAINSBORO
+#vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 vaxo
 
 psphere s 1.0
index c932618..b3ea270 100644 (file)
@@ -9,7 +9,7 @@ pload MODELING VISUALIZATION
 # test for creation of bottle as in tutorial (script is in samples)
 source $env(CSF_OCCTSamplesPath)/tcl/bottle.tcl
 
-vsetcolorbg 255 255 255
+vbackground -color WHITE
 vzbufftrihedron -type wireframe -colorLabels BLACK
 vaspects bottle -setDrawSilhouette 1 -setEdgeColor BLACK -setFaceBoundaryDraw 1 -setMostContinuity c0 -setFaceBoundaryColor BLACK -setInteriorStyle HIDDENLINE 
 vrenderparams -rendScale 2
index ddbe000..80d16c7 100644 (file)
@@ -19,7 +19,7 @@ vclear
 vclose ALL
 vinit View1
 vraytrace 0
-vsetgradientbg 180 200 255 180 180 180 2
+vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 vsetdispmode 0
 vdisplay -dispMode 1 b
 vfit
index 937c011..141b3ea 100644 (file)
@@ -9,7 +9,7 @@ set aShape [locate_data_file occ/Top.brep]
 vinit View1 w=768 h=768
 vglinfo
 
-vsetgradientbg 180 200 255 180 180 180 2
+vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 
 # display shape
 vlight -change 0 -dir 0.577 -0.577 -0.577
index 66bb214..52d715c 100644 (file)
@@ -12,7 +12,7 @@ vglinfo
 
 vvbo 0
 vsetdispmode 1
-vsetgradientbg 180 200 255 180 180 180 2
+vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 restore $aShape1 s1
 restore $aShape2 s2
 vdisplay s1 s2
index dbf3260..b496999 100644 (file)
@@ -10,7 +10,7 @@ vglinfo
 
 vvbo 0
 vsetdispmode 1
-vsetgradientbg 180 200 255 180 180 180 2
+vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 # boxes
 box b1 1 1 1
 vdisplay b1
index 6ece710..5ed06e6 100644 (file)
@@ -12,7 +12,7 @@ vglinfo
 
 vvbo 0
 vsetdispmode 1
-vsetgradientbg 180 200 255 180 180 180 2
+vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 vtextureenv on 4
 restore $aShape1 s1
 restore $aShape2 s2
index dfd63de..89c7765 100644 (file)
@@ -17,7 +17,7 @@ vglinfo
 
 vvbo 0
 vsetdispmode 1
-vsetgradientbg 180 200 255 180 180 180 2
+vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 restore $aShape1 s1
 restore $aShape2 s2
 vdisplay s1 s2
index 1576337..c0bfed6 100644 (file)
@@ -6,7 +6,7 @@ vinit View1
 vclear
 vrenderparams -rasterization
 vsetdispmode 1
-vsetgradientbg 180 200 255 180 180 180 2
+vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 
 box wall1 1 8 8
 box wall2 1 8 8
index 14da6f0..76eaae5 100644 (file)
@@ -6,7 +6,7 @@ vinit View1
 vclear
 vrenderparams -rasterization
 vsetdispmode 1
-vsetgradientbg 180 200 255 180 180 180 2
+vbackground -gradient 0.705882 0.784314 1  0.705882 0.705882 0.705882 -gradientMode VERTICAL
 
 box wall1 1 8 8
 box wall2 1 8 8
index 0c40cd9..ffb18bd 100644 (file)
@@ -8,7 +8,7 @@ set aShape2 [locate_data_file occ/Bottom.brep]
 
 vinit View1
 vsetdispmode 1
-vsetgradientbg 180 180 180 255 255 255 2
+vbackground -gradient 0.705882 0.705882 0.705882 WHITE -gradientMode VERTICAL
 restore $aShape1 s1
 restore $aShape2 s2
 vdisplay s1