0027700: Visualization - glPolygonMode() used for frame drawing affects label text...
authorapl <apl@opencascade.com>
Mon, 1 Aug 2016 19:09:20 +0000 (22:09 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 4 Aug 2016 08:56:59 +0000 (11:56 +0300)
Patch extends GL-state caching mechanism of OpenGl_Context by new methods.
The methods allow setting/inquiring polygon rasterization and hatching modes:
- OpenGl_Context::SetPolygonMode
- OpenGl_Context::SetPolygonHatchEnabled
- OpenGl_Context::SetPolygonHatchStyle

With these methods OpenGl_Text is able to configure shading as necessary.
And this configuration is done irrespectively of currently defined face aspect.
Code of OpenGl_Workspace is also modified to use these methods as well.

Porting notes:
- OpenGl_LineAttributes now require OpenGl_Context instance for calling GL API.
- OpenGl_LineAttributes has new flag IsEnabled, it turns on/off hatching without changing the hatch type.
  By default this flag is turned on and can be never modified for compatibility with old code.
- OpenGl_LineAttributes is not anymore a field of OpenGl_Workspace::myLineAttrib.
  This resource is directly created by an OpenGl_Context instance on demand.
  If you use custom implementation of hatch patterns please create and share custom resource
  under resource-key "OpenGl_LineAttributes" in corresponding OpenGl_Context before using
  methods SetPolygonHatchEnabled, SetPolygonHatchStyle.

src/OpenGl/OpenGl_Context.cxx
src/OpenGl/OpenGl_Context.hxx
src/OpenGl/OpenGl_LineAttributes.cxx
src/OpenGl/OpenGl_LineAttributes.hxx
src/OpenGl/OpenGl_Text.cxx
src/OpenGl/OpenGl_Workspace.cxx
src/OpenGl/OpenGl_Workspace.hxx
src/QABugs/QABugs_19.cxx
tests/bugs/vis/bug27700 [new file with mode: 0644]

index 0e5432b..0a21ead 100644 (file)
@@ -141,9 +141,11 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
 #if !defined(GL_ES_VERSION_2_0)
   myPointSpriteOrig (GL_UPPER_LEFT),
   myRenderMode (GL_RENDER),
+  myPolygonMode (GL_FILL),
 #else
   myPointSpriteOrig (0),
   myRenderMode (0),
+  myPolygonMode (0),
 #endif
   myToCullBackFaces (false),
   myReadBuffer (0),
@@ -2844,6 +2846,70 @@ Standard_Boolean OpenGl_Context::SetGlNormalizeEnabled (Standard_Boolean isEnabl
   return anOldGlNormalize;
 }
 
+// =======================================================================
+// function : SetPolygonMode
+// purpose  :
+// =======================================================================
+Standard_Integer OpenGl_Context::SetPolygonMode (const Standard_Integer theMode)
+{
+  if (myPolygonMode == theMode)
+  {
+    return myPolygonMode;
+  }
+
+  const Standard_Integer anOldPolygonMode = myPolygonMode;
+
+  myPolygonMode = theMode;
+
+#if !defined(GL_ES_VERSION_2_0)
+  ::glPolygonMode (GL_FRONT_AND_BACK, (GLenum)theMode);
+#endif
+
+  return anOldPolygonMode;
+}
+
+// =======================================================================
+// function : SetPolygonHatchEnabled
+// purpose  :
+// =======================================================================
+bool OpenGl_Context::SetPolygonHatchEnabled (const bool theIsEnabled)
+{
+  if (myHatchStyles.IsNull())
+  {
+    return false;
+  }
+  else if (myHatchStyles->IsEnabled() == theIsEnabled)
+  {
+    return theIsEnabled;
+  }
+
+  return myHatchStyles->SetEnabled (this, theIsEnabled);
+}
+
+// =======================================================================
+// function : SetPolygonHatchStyle
+// purpose  :
+// =======================================================================
+Standard_Integer OpenGl_Context::SetPolygonHatchStyle (const Standard_Integer theType)
+{
+  if (myHatchStyles.IsNull())
+  {
+    if (!GetResource ("OpenGl_LineAttributes", myHatchStyles))
+    {
+      // share and register for release once the resource is no longer used
+      myHatchStyles = new OpenGl_LineAttributes();
+      ShareResource ("OpenGl_LineAttributes", myHatchStyles);
+      myHatchStyles->Init (this);
+    }
+  }
+  if (myHatchStyles->TypeOfHatch() == theType)
+  {
+    return theType;
+  }
+
+  return myHatchStyles->SetTypeOfHatch (this, theType);
+}
+
 // =======================================================================
 // function : ApplyModelWorldMatrix
 // purpose  :
index 91c8833..e89b4d1 100644 (file)
@@ -17,6 +17,7 @@
 #define _OpenGl_Context_H__
 
 #include <Aspect_Handle.hxx>
+#include <Aspect_HatchStyle.hxx>
 #include <Aspect_Drawable.hxx>
 #include <Aspect_Display.hxx>
 #include <Aspect_RenderingContext.hxx>
@@ -27,6 +28,7 @@
 #include <NCollection_List.hxx>
 #include <Message.hxx>
 #include <OpenGl_Caps.hxx>
+#include <OpenGl_LineAttributes.hxx>
 #include <OpenGl_MatrixState.hxx>
 #include <OpenGl_Vec.hxx>
 #include <OpenGl_Resource.hxx>
@@ -455,6 +457,38 @@ public:
   //! @return old value of the flag
   Standard_EXPORT Standard_Boolean SetGlNormalizeEnabled (Standard_Boolean isEnabled);
 
+  //! @return cached state of polygon rasterization mode (glPolygonMode()).
+  Standard_Integer PolygonMode() const { return myPolygonMode; }
+
+  //! Sets polygon rasterization mode (glPolygonMode() function).
+  //! @return old value of the rasterization mode.
+  Standard_EXPORT Standard_Integer SetPolygonMode (const Standard_Integer theMode);
+
+  //! @return cached enabled state of polygon hatching rasterization.
+  bool IsPolygonHatchEnabled() const
+  {
+    return !myHatchStyles.IsNull() && myHatchStyles->TypeOfHatch() != 0;
+  }
+
+  //! Sets enabled state of polygon hatching rasterization
+  //! without affecting currently selected hatching pattern.
+  //! @return previous state of polygon hatching mode.
+  Standard_EXPORT bool SetPolygonHatchEnabled (const bool theIsEnabled);
+
+  //! @return cached state of polygon hatch type.
+  Standard_Integer PolygonHatchStyle() const
+  {
+    return myHatchStyles.IsNull() ? Aspect_HS_SOLID : myHatchStyles->TypeOfHatch();
+  }
+
+  //! Sets polygon hatch pattern.
+  //! Zero-index value is a default alias for solid filling.
+  //! @param the type of hatch supported by base implementation of
+  //! OpenGl_LineAttributes (Aspect_HatchStyle) or the type supported by custom
+  //! implementation derived from OpenGl_LineAttributes class.
+  //! @return old type of hatch.
+  Standard_EXPORT Standard_Integer SetPolygonHatchStyle (const Standard_Integer theStyle);
+
   //! Applies matrix stored in ModelWorldState to OpenGl.
   Standard_EXPORT void ApplyModelWorldMatrix();
 
@@ -725,19 +759,21 @@ private: // context info
 
 private: //! @name fields tracking current state
 
-  Handle(OpenGl_ShaderProgram) myActiveProgram;   //!< currently active GLSL program
-  Handle(OpenGl_Sampler)       myTexSampler;      //!< currently active sampler object
-  Handle(OpenGl_FrameBuffer)   myDefaultFbo;      //!< default Frame Buffer Object
-  Standard_Integer             myPointSpriteOrig; //!< GL_POINT_SPRITE_COORD_ORIGIN state (GL_UPPER_LEFT by default)
-  Standard_Integer             myRenderMode;      //!< value for active rendering mode
-  bool                         myToCullBackFaces; //!< back face culling mode enabled state (glIsEnabled (GL_CULL_FACE))
-  Standard_Integer             myReadBuffer;      //!< current read buffer
-  Standard_Integer             myDrawBuffer;      //!< current draw buffer
-  unsigned int                 myDefaultVao;      //!< default Vertex Array Object
-  Standard_Boolean             myIsGlDebugCtx;    //!< debug context initialization state
-  TCollection_AsciiString      myVendor;          //!< Graphics Driver's vendor
-  TColStd_PackedMapOfInteger   myFilters[6];      //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB)
-  Standard_ShortReal           myResolutionRatio; //!< scaling factor for parameters like text size
+  Handle(OpenGl_ShaderProgram)  myActiveProgram;   //!< currently active GLSL program
+  Handle(OpenGl_Sampler)        myTexSampler;      //!< currently active sampler object
+  Handle(OpenGl_FrameBuffer)    myDefaultFbo;      //!< default Frame Buffer Object
+  Handle(OpenGl_LineAttributes) myHatchStyles;     //!< resource holding predefined hatch styles patterns
+  Standard_Integer              myPointSpriteOrig; //!< GL_POINT_SPRITE_COORD_ORIGIN state (GL_UPPER_LEFT by default)
+  Standard_Integer              myRenderMode;      //!< value for active rendering mode
+  Standard_Integer              myPolygonMode;     //!< currently used polygon rasterization mode (glPolygonMode)
+  bool                          myToCullBackFaces; //!< back face culling mode enabled state (glIsEnabled (GL_CULL_FACE))
+  Standard_Integer              myReadBuffer;      //!< current read buffer
+  Standard_Integer              myDrawBuffer;      //!< current draw buffer
+  unsigned int                  myDefaultVao;      //!< default Vertex Array Object
+  Standard_Boolean              myIsGlDebugCtx;    //!< debug context initialization state
+  TCollection_AsciiString       myVendor;          //!< Graphics Driver's vendor
+  TColStd_PackedMapOfInteger    myFilters[6];      //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB)
+  Standard_ShortReal            myResolutionRatio; //!< scaling factor for parameters like text size
                                                   //!< to be properly displayed on device (screen / printer)
 
 public:
index be48861..1d58616 100644 (file)
@@ -479,13 +479,14 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] =
   }
 };
 
-
 // =======================================================================
 // function : OpenGl_LineAttributes
 // purpose  :
 // =======================================================================
 OpenGl_LineAttributes::OpenGl_LineAttributes()
-: myPatternBase(0)
+: myPatternBase (0),
+  myTypeOfHatch (0),
+  myIsEnabled (true)
 {
   //
 }
@@ -508,12 +509,14 @@ void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx)
   // Delete surface patterns
   if (myPatternBase != 0)
   {
+#if !defined(GL_ES_VERSION_2_0)
     if (theGlCtx->IsValid())
     {
-    #if !defined(GL_ES_VERSION_2_0)
-      glDeleteLists ((GLuint )myPatternBase, TEL_HS_USER_DEF_START);
-    #endif
+      theGlCtx->core11->glDeleteLists ((GLuint )myPatternBase, TEL_HS_USER_DEF_START);
     }
+#else
+    (void )theGlCtx;
+#endif
     myPatternBase = 0;
   }
 }
@@ -522,7 +525,7 @@ void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx)
 // function : Init
 // purpose  :
 // =======================================================================
-void OpenGl_LineAttributes::Init (const Handle(OpenGl_Context)& theGlCtx)
+void OpenGl_LineAttributes::Init (const OpenGl_Context* theGlCtx)
 {
   // Return if already initialized
   if (myPatternBase != 0)
@@ -541,9 +544,9 @@ void OpenGl_LineAttributes::Init (const Handle(OpenGl_Context)& theGlCtx)
   myPatternBase = glGenLists(TEL_HS_USER_DEF_START);
   for (int i = 1; i < TEL_HS_USER_DEF_START; i++)
   {
-    glNewList ((GLuint )myPatternBase + i, GL_COMPILE);
-    glPolygonStipple ((const GLubyte* )myInteriors[i < nbi ? i : 0]);
-    glEndList();
+    theGlCtx->core11->glNewList ((GLuint )myPatternBase + i, GL_COMPILE);
+    theGlCtx->core11->glPolygonStipple ((const GLubyte* )myInteriors[i < nbi ? i : 0]);
+    theGlCtx->core11->glEndList();
   }
 #else
   (void )theGlCtx;
@@ -554,22 +557,69 @@ void OpenGl_LineAttributes::Init (const Handle(OpenGl_Context)& theGlCtx)
 // function : SetTypeOfHatch
 // purpose  :
 // =======================================================================
-void OpenGl_LineAttributes::SetTypeOfHatch (const int theType) const
+int OpenGl_LineAttributes::SetTypeOfHatch (const OpenGl_Context* theGlCtx, const int theType)
 {
-#if !defined(GL_ES_VERSION_2_0)
+  // Return if not initialized
   if (myPatternBase == 0)
   {
-    return;
+    return 0;
   }
 
+  const int anOldType = myTypeOfHatch;
+
+#if !defined(GL_ES_VERSION_2_0)
   if (theType != 0)
   {
-    glCallList ((GLuint )myPatternBase + (GLuint )theType);
-    glEnable (GL_POLYGON_STIPPLE);
+    theGlCtx->core11->glCallList ((GLuint )myPatternBase + (GLuint )theType);
+
+    if (myIsEnabled)
+    {
+      theGlCtx->core11fwd->glEnable (GL_POLYGON_STIPPLE);
+    }
+  }
+  else
+  {
+    theGlCtx->core11fwd->glDisable (GL_POLYGON_STIPPLE);
+  }
+#else
+  (void )theGlCtx;
+#endif
+  myTypeOfHatch = theType;
+
+  return anOldType;
+}
+
+// =======================================================================
+// function : SetEnabled
+// purpose  :
+// =======================================================================
+bool OpenGl_LineAttributes::SetEnabled (const OpenGl_Context* theGlCtx,
+                                        const bool theToEnable)
+{
+  // Return if not initialized
+  if (myPatternBase == 0)
+  {
+    return false;
+  }
+
+  const bool anOldIsEnabled = myIsEnabled;
+
+#if !defined(GL_ES_VERSION_2_0)
+  if (theToEnable)
+  {
+    if (myTypeOfHatch != 0)
+    {
+      theGlCtx->core11fwd->glEnable (GL_POLYGON_STIPPLE);
+    }
   }
   else
-    glDisable (GL_POLYGON_STIPPLE);
+  {
+    theGlCtx->core11fwd->glDisable (GL_POLYGON_STIPPLE);
+  }
 #else
-  (void )theType;
+  (void )theGlCtx;
 #endif
+  myIsEnabled = theToEnable;
+
+  return anOldIsEnabled;
 }
index 39392b2..db753ce 100644 (file)
@@ -26,26 +26,59 @@ class OpenGl_Context;
 
 #define TEL_HS_USER_DEF_START 15
 
+//! Utility class to manage OpenGL state of polygon hatching rasterization
+//! and keeping its cached state. The hatching rasterization is implemented
+//! using glPolygonStipple function of OpenGL. State of hatching is controlled
+//! by two parameters - type of hatching and IsEnabled parameter.
+//! The hatching rasterization is enabled only if non-zero index pattern type
+//! is selected (zero by default is reserved for solid filling) and if
+//! IsEnabled flag is set to true. The IsEnabled parameter is useful for temporarily
+//! turning on/off the hatching rasterization without making any costly GL calls
+//! for changing the hatch pattern. This is a sharable resource class - it creates
+//! OpenGL context objects for each hatch pattern to achieve quicker switching between
+//! them, thesse GL objects are freed when the resource is released by owner context.
+//! @note The implementation is not supported by Core Profile and by ES version.
 class OpenGl_LineAttributes : public OpenGl_Resource
 {
 public:
 
+  //! Default constructor.
+  //! By default the parameters are:
+  //! - IsEnabled (true),
+  //! - TypeOfHatch (0).
   OpenGl_LineAttributes();
+
+  //! Default destructor.
   virtual ~OpenGl_LineAttributes();
 
-  void Init (const Handle(OpenGl_Context)& theGlCtx);
+  //! Initialize hatch patterns as GL resources.
+  //! Call this method before using hatching.
+  void Init (const OpenGl_Context* theGlCtx);
+
+  //! Release GL resources.
   virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE;
 
-  void SetTypeOfHatch (const int theType) const;
+  //! Index of currently selected type of hatch.
+  int TypeOfHatch() const { return myTypeOfHatch; }
+
+  //! Sets type of the hatch.
+  int SetTypeOfHatch (const OpenGl_Context* theGlCtx, const int theType);
+
+  //! Current enabled state of the hatching rasterization.
+  bool IsEnabled() const { return myIsEnabled; }
+
+  //! Turns on/off the hatching rasterization rasterization.
+  bool SetEnabled (const OpenGl_Context* theGlCtx, const bool theToEnable);
 
 protected:
 
-  unsigned int myPatternBase;
+  unsigned int myPatternBase; //!< Base index for predefined hatch patterns
+  int myTypeOfHatch; //!< Currently activated type of hatch
+  bool myIsEnabled; //!< Current enabled state of hatching rasterization.
 
 public:
 
   DEFINE_STANDARD_RTTIEXT(OpenGl_LineAttributes,OpenGl_Resource)
-
 };
 
 DEFINE_STANDARD_HANDLE(OpenGl_LineAttributes, OpenGl_Resource)
index 394c97a..b8ddfcd 100644 (file)
@@ -414,6 +414,10 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
   const OpenGl_AspectText*      aTextAspect  = theWorkspace->ApplyAspectText();
   const Handle(OpenGl_Texture)  aPrevTexture = theWorkspace->DisableTexture();
   const Handle(OpenGl_Context)& aCtx         = theWorkspace->GetGlContext();
+#if !defined(GL_ES_VERSION_2_0)
+  const Standard_Integer aPrevPolygonMode  = aCtx->SetPolygonMode (GL_FILL);
+  const bool             aPrevHatchingMode = aCtx->SetPolygonHatchEnabled (false);
+#endif
 
   // Bind custom shader program or generate default version
   if (aCtx->core20fwd != NULL)
@@ -439,6 +443,10 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
   {
     theWorkspace->EnableTexture (aPrevTexture);
   }
+#if !defined(GL_ES_VERSION_2_0)
+  aCtx->SetPolygonMode         (aPrevPolygonMode);
+  aCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
+#endif
 
   // restore Z buffer settings
   if (theWorkspace->UseZBuffer())
index 0a4e3f5..a0e7656 100644 (file)
@@ -153,16 +153,7 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
   {
     myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
 
-    if (!myGlContext->GetResource ("OpenGl_LineAttributes", myLineAttribs))
-    {
-      // share and register for release once the resource is no longer used
-      myLineAttribs = new OpenGl_LineAttributes();
-      myGlContext->ShareResource ("OpenGl_LineAttributes", myLineAttribs);
-      myLineAttribs->Init (myGlContext);
-    }
-
     // General initialization of the context
-
   #if !defined(GL_ES_VERSION_2_0)
     if (myGlContext->core11 != NULL)
     {
@@ -188,19 +179,6 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
   myFrontCulling.Aspect()->SetDrawEdges (false);
 }
 
-// =======================================================================
-// function : ~OpenGl_Workspace
-// purpose  :
-// =======================================================================
-OpenGl_Workspace::~OpenGl_Workspace()
-{
-  if (!myLineAttribs.IsNull())
-  {
-    myLineAttribs.Nullify();
-    myGlContext->ReleaseResource ("OpenGl_LineAttributes", Standard_True);
-  }
-}
-
 // =======================================================================
 // function : Activate
 // purpose  :
@@ -836,28 +814,25 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
       case Aspect_IS_EMPTY:
       case Aspect_IS_HOLLOW:
       {
-        glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
+        myGlContext->SetPolygonMode (GL_LINE);
         break;
       }
       case Aspect_IS_HATCH:
       {
-        glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
-        myLineAttribs->SetTypeOfHatch (!myAspectFaceApplied.IsNull() ? myAspectFaceApplied->HatchStyle() : Aspect_HS_SOLID);
+        myGlContext->SetPolygonMode (GL_FILL);
+        myGlContext->SetPolygonHatchEnabled (true);
         break;
       }
       case Aspect_IS_SOLID:
       case Aspect_IS_HIDDENLINE:
       {
-        glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
-        if (myGlContext->core11 != NULL)
-        {
-          glDisable (GL_POLYGON_STIPPLE);
-        }
+        myGlContext->SetPolygonMode (GL_FILL);
+        myGlContext->SetPolygonHatchEnabled (false);
         break;
       }
       case Aspect_IS_POINT:
       {
-        glPolygonMode (GL_FRONT_AND_BACK, GL_POINT);
+        myGlContext->SetPolygonMode (GL_POINT);
         break;
       }
     }
@@ -865,12 +840,7 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
 
   if (anIntstyle == Aspect_IS_HATCH)
   {
-    const Aspect_HatchStyle hatchstyle = myAspectFaceSet->Aspect()->HatchStyle();
-    if (myAspectFaceApplied.IsNull()
-     || myAspectFaceApplied->HatchStyle() != hatchstyle)
-    {
-      myLineAttribs->SetTypeOfHatch (hatchstyle);
-    }
+    myGlContext->SetPolygonHatchStyle (myAspectFaceSet->Aspect()->HatchStyle());
   }
 #endif
 
index 7e40713..81f505a 100644 (file)
@@ -21,7 +21,6 @@
 #include <OpenGl_AspectFace.hxx>
 #include <OpenGl_CappingAlgo.hxx>
 #include <OpenGl_FrameBuffer.hxx>
-#include <OpenGl_LineAttributes.hxx>
 #include <OpenGl_Matrix.hxx>
 #include <OpenGl_NamedStatus.hxx>
 #include <OpenGl_PrinterContext.hxx>
@@ -121,7 +120,7 @@ public:
   Standard_EXPORT OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Window)& theWindow);
 
   //! Destructor
-  Standard_EXPORT virtual ~OpenGl_Workspace();
+  virtual ~OpenGl_Workspace() {}
 
   //! Activate rendering context.
   Standard_EXPORT Standard_Boolean Activate();
@@ -306,7 +305,7 @@ public:
   //! Sets and applies current polygon offset.
   void SetPolygonOffset (const Graphic3d_PolygonOffset& theParams);
 
-  //! Returns currently applied polygon offset params.
+  //! Returns currently applied polygon offset parameters.
   const Graphic3d_PolygonOffset& AppliedPolygonOffset() { return myPolygonOffsetApplied; }
 
   //! Returns capping algorithm rendering filter.
@@ -358,7 +357,6 @@ protected: //! @name protected fields
   Handle(OpenGl_Window)            myWindow;
   Handle(OpenGl_Context)           myGlContext;
   Handle(OpenGl_PrinterContext)    myPrintContext;
-  Handle(OpenGl_LineAttributes)    myLineAttribs;
   Standard_Boolean                 myUseZBuffer;
   Standard_Boolean                 myUseDepthWrite;
   Standard_Boolean                 myUseGLLight;
index 73f2e49..3c9096a 100644 (file)
 
 #include <QABugs.hxx>
 
-#include <Draw_Interpretor.hxx>
-#include <DBRep.hxx>
-#include <DrawTrSurf.hxx>
-#include <ViewerTest.hxx>
-#include <V3d_View.hxx>
-#include <TopoDS_Shape.hxx>
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_LocalContext.hxx>
 #include <AIS_TexturedShape.hxx>
-#include <Image_PixMap.hxx>
-#include <Image_Color.hxx>
-
-#include <gp_Pnt2d.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Quaternion.hxx>
-#include <GCE2d_MakeSegment.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
-#include <DrawTrSurf.hxx>
-
-#include <Precision.hxx>
-
-#include <cstdio>
-#include <cmath>
-#include <iostream>
-#include <OSD_Timer.hxx>
-#include <OSD_Parallel.hxx>
-#include <OSD_PerfMeter.hxx>
+#include <BRepAlgo_Cut.hxx>
+#include <BRepOffsetAPI_MakePipe.hxx>
 #include <BRepPrimAPI_MakeBox.hxx>
 #include <BRepPrimAPI_MakeSphere.hxx>
-#include <BRepAlgo_Cut.hxx>
-#include <NCollection_Map.hxx>
+#include <DBRep.hxx>
+#include <Draw_Interpretor.hxx>
+#include <DrawTrSurf.hxx>
+#include <GCE2d_MakeSegment.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <GeomFill_Trihedron.hxx>
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Quaternion.hxx>
+#include <Image_Color.hxx>
+#include <Image_PixMap.hxx>
 #include <NCollection_Handle.hxx>
 #include <NCollection_IncAllocator.hxx>
-#include <TCollection_HAsciiString.hxx>
-#include <GeomFill_Trihedron.hxx>
-#include <BRepOffsetAPI_MakePipe.hxx>
-#include <TopExp_Explorer.hxx>
+#include <NCollection_Map.hxx>
+#include <OSD_Parallel.hxx>
+#include <OSD_PerfMeter.hxx>
+#include <OSD_Timer.hxx>
+#include <Precision.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <Prs3d_Text.hxx>
 #include <SelectMgr_Filter.hxx>
-#include <StdSelect_BRepOwner.hxx>
-
 #include <Standard_Version.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS_Shape.hxx>
+#include <V3d_View.hxx>
+#include <ViewerTest.hxx>
 #include <XmlDrivers_DocumentRetrievalDriver.hxx>
 #include <XmlDrivers_DocumentStorageDriver.hxx>
 
+#include <cstdio>
+#include <cmath>
+#include <iostream>
+
 #define QCOMPARE(val1, val2) \
   di << "Checking " #val1 " == " #val2 << \
         ((val1) == (val2) ? ": OK\n" : ": Error\n")
@@ -5182,6 +5181,72 @@ static Standard_Integer OCC27523 (Draw_Interpretor& theDI, Standard_Integer theA
   return 0;
 }
 
+//========================================================================
+//function : OCC27700
+//purpose  : glPolygonMode() used for frame drawing affects label text shading
+//========================================================================
+
+class OCC27700_Text : public AIS_InteractiveObject
+{
+public:
+
+  DEFINE_STANDARD_RTTI_INLINE (OCC27700_Text, AIS_InteractiveObject)
+
+  virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
+                        const Handle(Prs3d_Presentation)& thePresentation,
+                        const Standard_Integer /*theMode*/) Standard_OVERRIDE
+  {
+    Handle(Graphic3d_ArrayOfTriangles) aFrame = new Graphic3d_ArrayOfTriangles (6, 6);
+    aFrame->AddVertex (gp_Pnt (-1, 0, 0));
+    aFrame->AddVertex (gp_Pnt (-1, 1, 0));
+    aFrame->AddVertex (gp_Pnt ( 3, 1, 0));
+    aFrame->AddVertex (gp_Pnt ( 3, 0, 0));
+
+    aFrame->AddEdge (1);
+    aFrame->AddEdge (2);
+    aFrame->AddEdge (3);
+
+    aFrame->AddEdge (2);
+    aFrame->AddEdge (3);
+    aFrame->AddEdge (4);
+
+    Handle(Graphic3d_AspectFillArea3d) aFillAspect =
+      new Graphic3d_AspectFillArea3d (*myDrawer->ShadingAspect()->Aspect().get());
+    aFillAspect->SetInteriorStyle (Aspect_IS_POINT);
+
+    // create separate group for frame elements
+    Handle(Graphic3d_Group) aFrameGroup = Prs3d_Root::NewGroup (thePresentation);
+    aFrameGroup->AddPrimitiveArray (aFrame);
+    aFrameGroup->SetGroupPrimitivesAspect (aFillAspect);
+
+    // create separate group for text elements
+    Handle(Graphic3d_Group) aTextGroup = Prs3d_Root::NewGroup (thePresentation);
+    TCollection_ExtendedString aString ("YOU SHOULD SEE THIS TEXT", Standard_True);
+    Prs3d_Text::Draw (thePresentation, myDrawer->TextAspect(), aString, gp_Ax2 (gp::Origin(), gp::DZ()));
+  }
+
+  virtual void ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/,
+                                 const Standard_Integer /*theMode*/) Standard_OVERRIDE {}
+};
+
+static Standard_Integer OCC27700 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgNb*/, const char** /*theArgVec*/)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cout << "Error: no view available, call 'vinit' before!" << std::endl;
+    return 1;
+  }
+  Handle(OCC27700_Text) aPresentation = new OCC27700_Text();
+  aContext->Display (aPresentation);
+  return 0;
+}
+
+//========================================================================
+//function : Commands_19
+//purpose  :
+//========================================================================
+
 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -5301,6 +5366,8 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   theCommands.Add ("OCC27523",
                    "OCC27523: Checks recomputation of deactivated selection mode after object's redisplaying",
                    __FILE__, OCC27523, group);
-
+  theCommands.Add ("OCC27700",
+                   "OCC27700: Checks drawing text after setting interior style",
+                   __FILE__, OCC27700, group);
   return;
 }
diff --git a/tests/bugs/vis/bug27700 b/tests/bugs/vis/bug27700
new file mode 100644 (file)
index 0000000..07702ad
--- /dev/null
@@ -0,0 +1,16 @@
+puts "========"
+puts "CR27700"
+puts "========"
+puts ""
+############################################################################################
+puts "Visualization - glPolygonMode() used for frame drawing affects label text shading"
+############################################################################################
+
+vclear
+vinit View1
+
+OCC27700
+vtop
+vfit
+
+vdump $imagedir/${casename}.png