]> OCCT Git - occt.git/commitdiff
0031039: Visualization - add elliptical gradient background style
authorachesnok <achesnok@opencascade.com>
Tue, 21 Sep 2021 15:42:21 +0000 (18:42 +0300)
committerkgv <kgv@opencascade.com>
Sun, 26 Sep 2021 08:05:34 +0000 (11:05 +0300)
Added new elliptical gradient fill method and updated vbackground command.
Renamed enum values of Aspect_GradientFillMethod and defined aliases for old ones.
Changed draw mode in OpenGl_BackgroundArray from triangle-strip to GL_TRIANGLES.

src/Aspect/Aspect_GradientBackground.cxx
src/Aspect/Aspect_GradientBackground.hxx
src/Aspect/Aspect_GradientFillMethod.hxx
src/OpenGl/OpenGl_BackgroundArray.cxx
src/OpenGl/OpenGl_View.cxx
src/V3d/V3d_View.hxx
src/V3d/V3d_Viewer.hxx
src/ViewerTest/ViewerTest_OpenGlCommands.cxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/opengl/data/background/bug25775
tests/opengl/data/background/elliptical [new file with mode: 0644]

index 6bbfc67a349319dd2215531e2236466735b39cac..ae3a2754c9243e35f3cea70a36860e0e873df052 100644 (file)
@@ -22,7 +22,7 @@ Aspect_GradientBackground::Aspect_GradientBackground () {
 
   SetColor( Black );
   MyColor2 = Black;
-  MyGradientMethod = Aspect_GFM_NONE;   
+  MyGradientMethod = Aspect_GradientFillMethod_None;
 
 }
 
index 2bc111e7318ebccaa7394ab8bf034518280960f7..c204ea32d2065ce14337ae228f9446230dabff69 100644 (file)
 #ifndef _Aspect_GradientBackground_HeaderFile
 #define _Aspect_GradientBackground_HeaderFile
 
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
-#include <Quantity_Color.hxx>
 #include <Aspect_GradientFillMethod.hxx>
 #include <Aspect_Background.hxx>
-class Quantity_Color;
-
 
-//! This class allows the definition of
-//! a window gradient background.
+//! This class allows the definition of a window gradient background.
 class Aspect_GradientBackground  : public Aspect_Background
 {
 public:
 
   DEFINE_STANDARD_ALLOC
 
-  
   //! Creates a window gradient background.
-  //! Default colors : Quantity_NOC_BLACK.
-  //! Default fill method : Aspect_GFM_NONE
+  //! Default color is Quantity_NOC_BLACK.
+  //! Default fill method is Aspect_GradientFillMethod_None.
   Standard_EXPORT Aspect_GradientBackground();
-  
-  //! Creates a window gradient background with colours <AColor1, AColor2>.
-  Standard_EXPORT Aspect_GradientBackground(const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AMethod = Aspect_GFM_HOR);
-  
-  //! Modifies the colours of the window gradient background <me>.
-  Standard_EXPORT void SetColors (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AMethod = Aspect_GFM_HOR);
-  
-  //! Returns colours of the window gradient background <me>.
-  Standard_EXPORT void Colors (Quantity_Color& AColor1, Quantity_Color& AColor2) const;
-  
-  //! Returns the current gradient background fill mode.
-  Standard_EXPORT Aspect_GradientFillMethod BgGradientFillMethod() const;
-  
-  //! Dumps the content of me into the stream
-  Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
+  //! Creates a window gradient background with two colours.
+  Standard_EXPORT Aspect_GradientBackground (const Quantity_Color& theColor1,
+                                             const Quantity_Color& theColor2,
+                                             const Aspect_GradientFillMethod theMethod = Aspect_GradientFillMethod_Horizontal);
 
+  //! Modifies the colours of the window gradient background.
+  Standard_EXPORT void SetColors (const Quantity_Color& theColor1,
+                                  const Quantity_Color& theColor2,
+                                  const Aspect_GradientFillMethod theMethod = Aspect_GradientFillMethod_Horizontal);
 
+  //! Returns colours of the window gradient background.
+  Standard_EXPORT void Colors (Quantity_Color& theColor1, Quantity_Color& theColor2) const;
 
-protected:
-
-
-
+  //! Returns the current gradient background fill mode.
+  Standard_EXPORT Aspect_GradientFillMethod BgGradientFillMethod() const;
 
+  //! Dumps the content of me into the stream
+  Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
 private:
 
-
-
   Quantity_Color MyColor2;
   Aspect_GradientFillMethod MyGradientMethod;
 
-
 };
 
-
-
-
-
-
-
 #endif // _Aspect_GradientBackground_HeaderFile
index cb6315defb473435e67d603750459dfeee2ac992..a3231c88982486cd8fcf1a69a9db0156a21635a0 100644 (file)
 #ifndef _Aspect_GradientFillMethod_HeaderFile
 #define _Aspect_GradientFillMethod_HeaderFile
 
-//! Defines the fill methods to
-//! write gradient background in a window.
+//! Defines the fill methods to write gradient background in a window.
 enum Aspect_GradientFillMethod
 {
-Aspect_GFM_NONE,
-Aspect_GFM_HOR,
-Aspect_GFM_VER,
-Aspect_GFM_DIAG1,
-Aspect_GFM_DIAG2,
-Aspect_GFM_CORNER1,
-Aspect_GFM_CORNER2,
-Aspect_GFM_CORNER3,
-Aspect_GFM_CORNER4
+  Aspect_GradientFillMethod_None,        //!< fill method not specified
+  Aspect_GradientFillMethod_Horizontal,  //!< gradient directed from left (Color1) to right (Color2)
+  Aspect_GradientFillMethod_Vertical,    //!< gradient directed from top (Color1) to bottom (Color2)
+  Aspect_GradientFillMethod_Diagonal1,   //!< gradient directed from upper left corner (Color1) to lower right (Color2)
+  Aspect_GradientFillMethod_Diagonal2,   //!< gradient directed from upper right corner (Color1) to lower left (Color2)
+  Aspect_GradientFillMethod_Corner1,     //!< highlights upper left corner with Color1
+  Aspect_GradientFillMethod_Corner2,     //!< highlights upper right corner with Color1
+  Aspect_GradientFillMethod_Corner3,     //!< highlights lower right corner with Color1
+  Aspect_GradientFillMethod_Corner4,     //!< highlights lower left corner with Color1
+  Aspect_GradientFillMethod_Elliptical,  //!< gradient directed from center (Color1) in all directions forming an elliptic shape (Color2)
+
+  // obsolete aliases
+  Aspect_GFM_NONE    = Aspect_GradientFillMethod_None,
+  Aspect_GFM_HOR     = Aspect_GradientFillMethod_Horizontal,
+  Aspect_GFM_VER     = Aspect_GradientFillMethod_Vertical,
+  Aspect_GFM_DIAG1   = Aspect_GradientFillMethod_Diagonal1,
+  Aspect_GFM_DIAG2   = Aspect_GradientFillMethod_Diagonal2,
+  Aspect_GFM_CORNER1 = Aspect_GradientFillMethod_Corner1,
+  Aspect_GFM_CORNER2 = Aspect_GradientFillMethod_Corner2,
+  Aspect_GFM_CORNER3 = Aspect_GradientFillMethod_Corner3,
+  Aspect_GFM_CORNER4 = Aspect_GradientFillMethod_Corner4
 };
 
 #endif // _Aspect_GradientFillMethod_HeaderFile
index 6bd91930687b09cb539f779a70cfa9bb467df2a7..cceff8f5118ff1d266b57c5309729304dfc385c8 100644 (file)
 // purpose :
 // =======================================================================
 OpenGl_BackgroundArray::OpenGl_BackgroundArray (const Graphic3d_TypeOfBackground theType)
-: OpenGl_PrimitiveArray (NULL, Graphic3d_TOPA_TRIANGLESTRIPS, NULL, NULL, NULL),
+: OpenGl_PrimitiveArray (NULL, Graphic3d_TOPA_TRIANGLES, NULL, NULL, NULL),
   myType (theType),
   myFillMethod (Aspect_FM_NONE),
   myViewWidth (0),
   myViewHeight (0),
   myToUpdate (Standard_False)
 {
-  myDrawMode = GL_TRIANGLE_STRIP;
+  myDrawMode = GL_TRIANGLES;
   myIsFillType = true;
 
   myGradientParams.color1 = OpenGl_Vec4 (0.0f, 0.0f, 0.0f, 1.0f);
   myGradientParams.color2 = OpenGl_Vec4 (0.0f, 0.0f, 0.0f, 1.0f);
-  myGradientParams.type   = Aspect_GFM_NONE;
+  myGradientParams.type   = Aspect_GradientFillMethod_None;
 }
 
 // =======================================================================
@@ -112,7 +112,7 @@ bool OpenGl_BackgroundArray::IsDefined() const
 {
   switch (myType)
   {
-    case Graphic3d_TOB_GRADIENT: return myGradientParams.type != Aspect_GFM_NONE;
+    case Graphic3d_TOB_GRADIENT: return myGradientParams.type != Aspect_GradientFillMethod_None;
     case Graphic3d_TOB_TEXTURE:  return myFillMethod          != Aspect_FM_NONE;
     case Graphic3d_TOB_CUBEMAP:  return Standard_True;
     case Graphic3d_TOB_NONE:     return Standard_False;
@@ -136,6 +136,16 @@ void OpenGl_BackgroundArray::invalidateData()
 Standard_Boolean OpenGl_BackgroundArray::init (const Handle(OpenGl_Workspace)& theWorkspace) const
 {
   const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
+
+  if (myIndices.IsNull())
+  {
+    myIndices = new Graphic3d_IndexBuffer (Graphic3d_Buffer::DefaultAllocator());
+  }
+  if (myAttribs.IsNull())
+  {
+    myAttribs = new Graphic3d_Buffer (Graphic3d_Buffer::DefaultAllocator());
+  }
+
   switch (myType)
   {
     case Graphic3d_TOB_GRADIENT:
@@ -195,10 +205,6 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG
     { Graphic3d_TOA_COLOR, Graphic3d_TOD_VEC3 }
   };
 
-  if (myAttribs.IsNull())
-  {
-    myAttribs = new Graphic3d_Buffer (Graphic3d_Buffer::DefaultAllocator());
-  }
   if (!myAttribs->Init (4, aGragientAttribInfo, 2))
   {
     return Standard_False;
@@ -218,7 +224,7 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG
 
   switch (myGradientParams.type)
   {
-    case Aspect_GFM_HOR:
+    case Aspect_GradientFillMethod_Horizontal:
     {
       aCorners[0] = myGradientParams.color2.ChangeData();
       aCorners[1] = myGradientParams.color2.ChangeData();
@@ -226,7 +232,7 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG
       aCorners[3] = myGradientParams.color1.ChangeData();
       break;
     }
-    case Aspect_GFM_VER:
+    case Aspect_GradientFillMethod_Vertical:
     {
       aCorners[0] = myGradientParams.color2.ChangeData();
       aCorners[1] = myGradientParams.color1.ChangeData();
@@ -234,7 +240,7 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG
       aCorners[3] = myGradientParams.color1.ChangeData();
       break;
     }
-    case Aspect_GFM_DIAG1:
+    case Aspect_GradientFillMethod_Diagonal1:
     {
       aCorners[0] = myGradientParams.color2.ChangeData();
       aCorners[3] = myGradientParams.color1.ChangeData();
@@ -245,7 +251,7 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG
       aCorners[2] = aDiagCorner2;
       break;
     }
-    case Aspect_GFM_DIAG2:
+    case Aspect_GradientFillMethod_Diagonal2:
     {
       aCorners[1] = myGradientParams.color1.ChangeData();
       aCorners[2] = myGradientParams.color2.ChangeData();
@@ -256,7 +262,7 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG
       aCorners[3] = aDiagCorner2;
       break;
     }
-    case Aspect_GFM_CORNER1:
+    case Aspect_GradientFillMethod_Corner1:
     {
       aVertices[0] = OpenGl_Vec2(float(myViewWidth), float(myViewHeight));
       aVertices[1] = OpenGl_Vec2(0.0f,               float(myViewHeight));
@@ -269,7 +275,7 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG
       aCorners[3] = myGradientParams.color2.ChangeData();
       break;
     }
-    case Aspect_GFM_CORNER2:
+    case Aspect_GradientFillMethod_Corner2:
     {
       aCorners[0] = myGradientParams.color2.ChangeData();
       aCorners[1] = myGradientParams.color1.ChangeData();
@@ -277,7 +283,7 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG
       aCorners[3] = myGradientParams.color2.ChangeData();
       break;
     }
-    case Aspect_GFM_CORNER3:
+    case Aspect_GradientFillMethod_Corner3:
     {
       aVertices[0] = OpenGl_Vec2(float(myViewWidth), float(myViewHeight));
       aVertices[1] = OpenGl_Vec2(0.0f,               float(myViewHeight));
@@ -290,7 +296,7 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG
       aCorners[3] = myGradientParams.color2.ChangeData();
       break;
     }
-    case Aspect_GFM_CORNER4:
+    case Aspect_GradientFillMethod_Corner4:
     {
       aCorners[0] = myGradientParams.color2.ChangeData();
       aCorners[1] = myGradientParams.color2.ChangeData();
@@ -298,7 +304,53 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG
       aCorners[3] = myGradientParams.color2.ChangeData();
       break;
     }
-    case Aspect_GFM_NONE:
+    case Aspect_GradientFillMethod_Elliptical:
+    {
+      // construction of a circle circumscribed about a view rectangle
+      // using parametric equation (scaled by aspect ratio and centered)
+      const Standard_Integer aSubdiv = 64;
+      if (!myAttribs->Init (aSubdiv + 2, aGragientAttribInfo, 2))
+      {
+        return Standard_False;
+      }
+
+      OpenGl_Vec2 anEllipVerts[aSubdiv + 2];
+      anEllipVerts[0] = OpenGl_Vec2 (float (myViewWidth) / 2.0f, float (myViewHeight) / 2.0f);
+      Standard_Real aTetta = (M_PI * 2.0) / aSubdiv;
+      Standard_Real aParam = 0.0;
+      for (Standard_Integer anIt = 1; anIt < aSubdiv + 2; ++anIt)
+      {
+        anEllipVerts[anIt] = OpenGl_Vec2 (float (Cos (aParam) * Sqrt (2.0) * myViewWidth  / 2.0 + myViewWidth  / 2.0f),
+                                          float (Sin (aParam) * Sqrt (2.0) * myViewHeight / 2.0 + myViewHeight / 2.0f));
+
+        aParam += aTetta;
+      }
+      for (Standard_Integer anIt = 0; anIt < aSubdiv + 2; ++anIt)
+      {
+        OpenGl_Vec2* aVertData = reinterpret_cast<OpenGl_Vec2*>(myAttribs->changeValue (anIt));
+        *aVertData = anEllipVerts[anIt];
+
+        OpenGl_Vec3* aColorData = reinterpret_cast<OpenGl_Vec3*>(myAttribs->changeValue (anIt) + myAttribs->AttributeOffset (1));
+        *aColorData = myGradientParams.color2.rgb();
+      }
+      // the central vertex is colored in different way
+      OpenGl_Vec3* aColorData = reinterpret_cast<OpenGl_Vec3*>(myAttribs->changeValue (0) + myAttribs->AttributeOffset (1));
+      *aColorData = myGradientParams.color1.rgb();
+
+      if (!myIndices->Init<unsigned short> (3 * aSubdiv))
+      {
+        return Standard_False;
+      }
+      for (Standard_Integer aCurTri = 0; aCurTri < aSubdiv; aCurTri++)
+      {
+        myIndices->SetIndex (aCurTri * 3 + 0, 0);
+        myIndices->SetIndex (aCurTri * 3 + 1, aCurTri + 1);
+        myIndices->SetIndex (aCurTri * 3 + 2, aCurTri + 2);
+      }
+
+      return Standard_True;
+    }
+    case Aspect_GradientFillMethod_None:
     {
       break;
     }
@@ -313,6 +365,15 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG
     *aColorData = theCtx->Vec4FromQuantityColor (OpenGl_Vec4(aCorners[anIt][0], aCorners[anIt][1], aCorners[anIt][2], 1.0f)).rgb();
   }
 
+  if (!myIndices->Init<unsigned short>(6))
+  {
+    return Standard_False;
+  }
+  const unsigned short THE_FS_QUAD_TRIS[6] = {0, 1, 2, 1, 3, 2};
+  for (unsigned int aVertIter = 0; aVertIter < 6; ++aVertIter)
+  {
+    myIndices->SetIndex (aVertIter, THE_FS_QUAD_TRIS[aVertIter]);
+  }
   return Standard_True;
 }
 
@@ -328,10 +389,6 @@ Standard_Boolean OpenGl_BackgroundArray::createTextureArray (const Handle(OpenGl
     { Graphic3d_TOA_UV,  Graphic3d_TOD_VEC2 }
   };
 
-  if (myAttribs.IsNull())
-  {
-    myAttribs = new Graphic3d_Buffer (Graphic3d_Buffer::DefaultAllocator());
-  }
   if (!myAttribs->Init (4, aTextureAttribInfo, 2))
   {
     return Standard_False;
@@ -386,6 +443,16 @@ Standard_Boolean OpenGl_BackgroundArray::createTextureArray (const Handle(OpenGl
   aData[0] = OpenGl_Vec2 (-anOffsetX, aCoef * anOffsetY);
   aData[1] = OpenGl_Vec2 (0.0f, aCoef * aTexRangeY);
 
+  if (!myIndices->Init<unsigned short>(6))
+  {
+    return Standard_False;
+  }
+  const unsigned short THE_FS_QUAD_TRIS[6] = {0, 1, 2, 1, 3, 2};
+  for (unsigned int aVertIter = 0; aVertIter < 6; ++aVertIter)
+  {
+    myIndices->SetIndex (aVertIter, THE_FS_QUAD_TRIS[aVertIter]);
+  }
+
   return Standard_True;
 }
 
@@ -406,7 +473,7 @@ Standard_Boolean OpenGl_BackgroundArray::createCubeMapArray() const
     myIndices = new Graphic3d_IndexBuffer (Graphic3d_Buffer::DefaultAllocator());
   }
   if (!myAttribs->Init (8, aCubeMapAttribInfo, 1)
-   || !myIndices->Init<unsigned short> (14))
+   || !myIndices->Init<unsigned short> (6 * 3 * 2))
   {
     return Standard_False;
   }
@@ -423,10 +490,18 @@ Standard_Boolean OpenGl_BackgroundArray::createCubeMapArray() const
     aData[7].SetValues ( 1.0,  1.0, -1.0);
   }
   {
-    const unsigned short THE_BOX_TRISTRIP[14] = { 0, 1, 2, 3, 7, 1, 5, 4, 7, 6, 2, 4, 0, 1 };
-    for (unsigned int aVertIter = 0; aVertIter < 14; ++aVertIter)
+    const unsigned short THE_BOX_TRIS[] =
+    {
+      0, 1, 2, 2, 1, 3, // top face
+      1, 5, 7, 1, 7, 3, // right face
+      0, 6, 4, 0, 2, 6, // left face
+      4, 6, 5, 6, 7, 5, // bottom face
+      0, 5, 1, 0, 4, 5, // front face
+      2, 7, 6, 2, 3, 7  // back face
+    };
+    for (unsigned int aVertIter = 0; aVertIter < 6 * 3 * 2; ++aVertIter)
     {
-      myIndices->SetIndex (aVertIter, THE_BOX_TRISTRIP[aVertIter]);
+      myIndices->SetIndex (aVertIter, THE_BOX_TRIS[aVertIter]);
     }
   }
 
index 0fd648c30ce1f1daa98f9abe349632490e9d453f..ed411f2fc47a2182df606d8b53b41ed69c683d91 100644 (file)
@@ -967,7 +967,7 @@ void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace,
         || myBackgroundType == Graphic3d_TOB_TEXTURE)
   {
     // Drawing background gradient if:
-    // - gradient fill type is not Aspect_GFM_NONE and
+    // - gradient fill type is not Aspect_GradientFillMethod_None and
     // - either background texture is no specified or it is drawn in Aspect_FM_CENTERED mode
     if (myBackgrounds[Graphic3d_TOB_GRADIENT]->IsDefined()
       && (!myTextureParams->Aspect()->ToMapTexture()
index 22beabcc7e84fe01eda233f507718e24b82d2115..e48a255d267461d015468e8f81042e5233676b79 100644 (file)
@@ -188,11 +188,11 @@ public:
   //! and the fill method (horizontal by default).
   Standard_EXPORT void SetBgGradientColors (const Quantity_Color& theColor1,
                                             const Quantity_Color& theColor2,
-                                            const Aspect_GradientFillMethod theFillStyle = Aspect_GFM_HOR,
+                                            const Aspect_GradientFillMethod theFillStyle = Aspect_GradientFillMethod_Horizontal,
                                             const Standard_Boolean theToUpdate = Standard_False);
 
   //! Defines the gradient background fill method of the view.
-  Standard_EXPORT void SetBgGradientStyle (const Aspect_GradientFillMethod theMethod = Aspect_GFM_HOR,
+  Standard_EXPORT void SetBgGradientStyle (const Aspect_GradientFillMethod theMethod = Aspect_GradientFillMethod_Horizontal,
                                            const Standard_Boolean theToUpdate = Standard_False);
 
   //! Defines the background texture of the view by supplying the texture image file name
index 2e368f82db90619385ece250f59d21c724fac375..4e8aa7d8cdc6a7aa4be1e6573612a962d506e0aa 100644 (file)
@@ -130,7 +130,7 @@ public:
   //! attached to the viewer by supplying the colour objects
   void SetDefaultBgGradientColors (const Quantity_Color& theColor1,
                                    const Quantity_Color& theColor2,
-                                   const Aspect_GradientFillMethod theFillStyle = Aspect_GFM_HOR)
+                                   const Aspect_GradientFillMethod theFillStyle = Aspect_GradientFillMethod_Horizontal)
   {
     myGradientBackground.SetColors (theColor1, theColor2, theFillStyle);
   }
index dd42d4a8f55d995c2bad9da5f63b5c590dc124c4..7f4af794399c76e6e1cbffdcf809c7062ee6db8b 100644 (file)
@@ -926,7 +926,7 @@ static Standard_Integer VListColors (Draw_Interpretor& theDI,
     ViewerTest::ViewerInit (0, 0, anImgParams.Width, anImgParams.Height, "TmpDriver/TmpViewer/TmpView");
     aView = ViewerTest::CurrentView();
     aView->SetImmediateUpdate (false);
-    aView->SetBgGradientStyle (Aspect_GFM_NONE, false);
+    aView->SetBgGradientStyle (Aspect_GradientFillMethod_None, false);
   }
 
   if (!aDumpFile.IsEmpty())
index 8200867aab2e90217a99d2cb0e77163a8b3fee6f..6a3a1f74a99032be8719394540fc4b22442add95 100644 (file)
@@ -214,7 +214,7 @@ static struct
     }
   }
 
-} ViewerTest_DefaultBackground = { Quantity_NOC_BLACK, Quantity_NOC_BLACK, Quantity_NOC_BLACK, Aspect_GFM_NONE };
+} ViewerTest_DefaultBackground = { Quantity_NOC_BLACK, Quantity_NOC_BLACK, Quantity_NOC_BLACK, Aspect_GradientFillMethod_None };
 
 //==============================================================================
 //  EVENT GLOBAL VARIABLES
@@ -2613,46 +2613,51 @@ static bool parseGradientMode (const TCollection_AsciiString& theName,
   aName.LowerCase();
   if (aName == "none")
   {
-    theMode = Aspect_GFM_NONE;
+    theMode = Aspect_GradientFillMethod_None;
   }
   else if (aName == "hor"
         || aName == "horizontal")
   {
-    theMode = Aspect_GFM_HOR;
+    theMode = Aspect_GradientFillMethod_Horizontal;
   }
   else if (aName == "ver"
         || aName == "vert"
         || aName == "vertical")
   {
-    theMode = Aspect_GFM_VER;
+    theMode = Aspect_GradientFillMethod_Vertical;
   }
   else if (aName == "diag"
         || aName == "diagonal"
         || aName == "diag1"
         || aName == "diagonal1")
   {
-    theMode = Aspect_GFM_DIAG1;
+    theMode = Aspect_GradientFillMethod_Diagonal1;
   }
   else if (aName == "diag2"
         || aName == "diagonal2")
   {
-    theMode = Aspect_GFM_DIAG2;
+    theMode = Aspect_GradientFillMethod_Diagonal2;
   }
   else if (aName == "corner1")
   {
-    theMode = Aspect_GFM_CORNER1;
+    theMode = Aspect_GradientFillMethod_Corner1;
   }
   else if (aName == "corner2")
   {
-    theMode = Aspect_GFM_CORNER2;
+    theMode = Aspect_GradientFillMethod_Corner2;
   }
   else if (aName == "corner3")
   {
-    theMode = Aspect_GFM_CORNER3;
+    theMode = Aspect_GradientFillMethod_Corner3;
   }
   else if (aName == "corner4")
   {
-    theMode = Aspect_GFM_CORNER4;
+    theMode = Aspect_GradientFillMethod_Corner4;
+  }
+  else if (aName == "ellip"
+        || aName == "elliptical")
+  {
+    theMode = Aspect_GradientFillMethod_Elliptical;
   }
   else
   {
@@ -2680,7 +2685,7 @@ static int VBackground (Draw_Interpretor& theDI,
   Standard_Integer aNbColors = 0;
   Quantity_ColorRGBA aColors[2];
 
-  Aspect_GradientFillMethod aGradientMode = Aspect_GFM_NONE;
+  Aspect_GradientFillMethod aGradientMode = Aspect_GradientFillMethod_None;
   bool hasGradientMode = false;
 
   TCollection_AsciiString anImagePath;
@@ -2891,14 +2896,14 @@ static int VBackground (Draw_Interpretor& theDI,
     {
       ViewerTest_DefaultBackground.GradientColor1 = Quantity_Color();
       ViewerTest_DefaultBackground.GradientColor2 = Quantity_Color();
-      ViewerTest_DefaultBackground.FillMethod     = Aspect_GFM_NONE;
+      ViewerTest_DefaultBackground.FillMethod     = Aspect_GradientFillMethod_None;
       ViewerTest_DefaultBackground.FlatColor      = aColors[0].GetRGB();
       ViewerTest_DefaultBackground.SetDefaultGradient();
       ViewerTest_DefaultBackground.SetDefaultColor();
     }
     else
     {
-      aView->SetBgGradientStyle (hasGradientMode ? aGradientMode : Aspect_GFM_NONE);
+      aView->SetBgGradientStyle (hasGradientMode ? aGradientMode : Aspect_GradientFillMethod_None);
       aView->SetBackgroundColor (aColors[0].GetRGB());
     }
   }
@@ -2912,9 +2917,9 @@ static int VBackground (Draw_Interpretor& theDI,
       {
         ViewerTest_DefaultBackground.FillMethod = aGradientMode;
       }
-      else if (ViewerTest_DefaultBackground.FillMethod == Aspect_GFM_NONE)
+      else if (ViewerTest_DefaultBackground.FillMethod == Aspect_GradientFillMethod_None)
       {
-        ViewerTest_DefaultBackground.FillMethod = Aspect_GFM_VER;
+        ViewerTest_DefaultBackground.FillMethod = Aspect_GradientFillMethod_Vertical;
       }
       ViewerTest_DefaultBackground.SetDefaultGradient();
     }
@@ -2923,9 +2928,9 @@ static int VBackground (Draw_Interpretor& theDI,
       if (!hasGradientMode)
       {
         aGradientMode = aView->GradientBackground().BgGradientFillMethod();
-        if (aGradientMode == Aspect_GFM_NONE)
+        if (aGradientMode == Aspect_GradientFillMethod_None)
         {
-          aGradientMode = Aspect_GFM_VER;
+          aGradientMode = Aspect_GradientFillMethod_Vertical;
         }
       }
       aView->SetBgGradientColors (aColors[0].GetRGB(), aColors[1].GetRGB(), aGradientMode);
@@ -13654,7 +13659,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
   theCommands.Add ("vbackground",
            "vbackground [-color Color [-default]]"
     "\n\t\t:            [-gradient Color1 Color2 [-default]"
-    "\n\t\t:            [-gradientMode {NONE|HORIZONTAL|VERTICAL|DIAG1|DIAG2|CORNER1|CORNER2|CORNER3}]=VERT]"
+    "\n\t\t:            [-gradientMode {NONE|HORIZONTAL|VERTICAL|DIAG1|DIAG2|CORNER1|CORNER2|CORNER3|ELLIPTICAL}]=VERT]"
     "\n\t\t:            [-imageFile ImageFile [-imageMode {CENTERED|TILED|STRETCH|NONE}]=CENTERED [-srgb {0|1}]=1]"
     "\n\t\t:            [-cubemap CubemapFile1 [CubeMapFiles2-5] [-order TilesIndexes1-6] [-invertedz]=0 [-pbrEnv {0|1}]=1]"
     "\n\t\t: Changes background or some background settings."
index 66c0cea0c9f3d5a5a82d525cf5211dbb4fb127a7..7e8828bdc8d9ddd08a20851f0dd3be2e1df3829d 100644 (file)
@@ -7,10 +7,13 @@ pload VISUALIZATION
 vbackground -default -gradient BLACK GRAY25 -gradientMode HORIZONTAL
 vinit View1 w=400 h=400
 if { [vreadpixel 399 100 -rgb -name] != "GRAY25" } { puts "Error: bug with default gradient color is reproduced." }
+vdump $imagedir/${casename}_v1.png
 
 vinit View2 w=400 h=400
 if { [vreadpixel 399 100 -rgb -name] != "GRAY25" } { puts "Error: bug with default gradient color is reproduced." }
+vdump $imagedir/${casename}_v2.png
 
 vbackground -default -color GRAY50
 vinit View3
 if { [vreadpixel 100 100 -rgb -name] != "GRAY50" } { puts "Error: bug with default background color is reproduced." }
+vdump $imagedir/${casename}_v3.png
diff --git a/tests/opengl/data/background/elliptical b/tests/opengl/data/background/elliptical
new file mode 100644 (file)
index 0000000..771bf59
--- /dev/null
@@ -0,0 +1,10 @@
+puts "============"
+puts "0031039: Visualization - add elliptical gradient background style"
+puts "============"
+puts ""
+
+pload VISUALIZATION
+vinit View1
+
+vbackground -gradient WHITE BLACK -gradientMode ELLIPTICAL
+vdump $imagedir/${casename}.png