From 6d0e6be5a215a332bcc50aacbfd3f1e6ae1e11ef Mon Sep 17 00:00:00 2001 From: apl Date: Mon, 1 Aug 2016 22:09:20 +0300 Subject: [PATCH] 0027700: Visualization - glPolygonMode() used for frame drawing affects label text shading 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 | 66 +++++++++++++ src/OpenGl/OpenGl_Context.hxx | 62 +++++++++--- src/OpenGl/OpenGl_LineAttributes.cxx | 82 ++++++++++++---- src/OpenGl/OpenGl_LineAttributes.hxx | 41 +++++++- src/OpenGl/OpenGl_Text.cxx | 8 ++ src/OpenGl/OpenGl_Workspace.cxx | 44 ++------- src/OpenGl/OpenGl_Workspace.hxx | 6 +- src/QABugs/QABugs_19.cxx | 135 ++++++++++++++++++++------- tests/bugs/vis/bug27700 | 16 ++++ 9 files changed, 352 insertions(+), 108 deletions(-) create mode 100644 tests/bugs/vis/bug27700 diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index 0e5432b5ce..0a21ead0f8 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -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 : diff --git a/src/OpenGl/OpenGl_Context.hxx b/src/OpenGl/OpenGl_Context.hxx index 91c8833259..e89b4d1bf5 100644 --- a/src/OpenGl/OpenGl_Context.hxx +++ b/src/OpenGl/OpenGl_Context.hxx @@ -17,6 +17,7 @@ #define _OpenGl_Context_H__ #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -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: diff --git a/src/OpenGl/OpenGl_LineAttributes.cxx b/src/OpenGl/OpenGl_LineAttributes.cxx index be48861198..1d586162f2 100644 --- a/src/OpenGl/OpenGl_LineAttributes.cxx +++ b/src/OpenGl/OpenGl_LineAttributes.cxx @@ -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 - glDisable (GL_POLYGON_STIPPLE); + { + theGlCtx->core11fwd->glDisable (GL_POLYGON_STIPPLE); + } #else - (void )theType; + (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 + { + theGlCtx->core11fwd->glDisable (GL_POLYGON_STIPPLE); + } +#else + (void )theGlCtx; +#endif + myIsEnabled = theToEnable; + + return anOldIsEnabled; } diff --git a/src/OpenGl/OpenGl_LineAttributes.hxx b/src/OpenGl/OpenGl_LineAttributes.hxx index 39392b2fd8..db753ce812 100644 --- a/src/OpenGl/OpenGl_LineAttributes.hxx +++ b/src/OpenGl/OpenGl_LineAttributes.hxx @@ -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) diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index 394c97a8f0..b8ddfcda40 100644 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -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()) diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index 0a4e3f5050..a0e76563af 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -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 diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index 7e40713802..81f505a718 100644 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -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; diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index 73f2e49639..3c9096aa31 100644 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -15,49 +15,48 @@ #include -#include -#include -#include -#include -#include -#include #include #include #include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include #define QCOMPARE(val1, val2) \ di << "Checking " #val1 " == " #val2 << \ @@ -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 index 0000000000..07702addd9 --- /dev/null +++ b/tests/bugs/vis/bug27700 @@ -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