From: apl Date: Fri, 16 Mar 2012 09:12:26 +0000 (+0400) Subject: 0023015: TKOpenGl redesign regression in text printing X-Git-Tag: V6_5_3_beta1~30 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=34a44cbd3bef2a041f922e102a4ca80221dd7f9d 0023015: TKOpenGl redesign regression in text printing Changes: - the lost code block for scaling text restored; - the color attributes fixed. --- diff --git a/src/OpenGl/OpenGl_Display_1.cxx b/src/OpenGl/OpenGl_Display_1.cxx index 87ec26bdae..3e0d48c2f4 100644 --- a/src/OpenGl/OpenGl_Display_1.cxx +++ b/src/OpenGl/OpenGl_Display_1.cxx @@ -3,13 +3,14 @@ // Author: Sergey ZERCHANINOV // Copyright: OPEN CASCADE 2011 +#include #include #include #include #include - +#include #include #ifdef HAVE_GL2PS @@ -554,6 +555,22 @@ void OpenGl_Display::RenderText (const wchar_t* str, const int is2d, const float if( !aspect->IsZoomable() ) { +#ifdef WNT + // if the context has assigned printer context, use it's parameters + OpenGl_PrinterContext* aPrinterContext = + OpenGl_PrinterContext::GetPrinterContext( GET_GL_CONTEXT() ); + if( aPrinterContext ) + { + // get printing scaling in x and y dimensions + GLfloat aTextScalex = 1, aTextScaley = 1; + aPrinterContext->GetScale( aTextScalex, aTextScaley ); + + // text should be scaled in all directions with same + // factor to save its proportions, so use height (y) scaling + // as it is better for keeping text/3d graphics proportions + glScalef( aTextScaley, aTextScaley, aTextScaley ); + } +#endif glScaled( h, h, h ); } else diff --git a/src/OpenGl/OpenGl_View_2.cxx b/src/OpenGl/OpenGl_View_2.cxx index 97c7637409..2f7a546997 100644 --- a/src/OpenGl/OpenGl_View_2.cxx +++ b/src/OpenGl/OpenGl_View_2.cxx @@ -1173,6 +1173,12 @@ D = -[Px,Py,Pz] dot |Nx| if (!myGraduatedTrihedron.IsNull()) myGraduatedTrihedron->Render(AWorkspace); + // The applied aspects should be reset to make it possible to + // update gl state and bring it into line with currently set + // aspects by reapplying them. Reset should be done, because + // the glPopAttrib() will return original gl state while the + // internal TKOpenGl state stills unchanged. + AWorkspace->ResetAppliedAspect(); glPopAttrib(); // GL_FOG_BIT | GL_LIGHTING_BIT | GL_ENABLE_BIT // Restore face culling diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index fe2a4ed02b..7f2a00ce31 100644 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -146,6 +146,9 @@ public: const OpenGl_AspectMarker* AspectMarker (const Standard_Boolean theWithApply); const OpenGl_AspectText* AspectText (const Standard_Boolean theWithApply); + //! Clear the applied aspect state. + void ResetAppliedAspect(); + //// RELATED TO FONTS //// int FindFont (const char* theFontName, diff --git a/src/OpenGl/OpenGl_Workspace_5.cxx b/src/OpenGl/OpenGl_Workspace_5.cxx index cda04ced14..a17e2a7389 100644 --- a/src/OpenGl/OpenGl_Workspace_5.cxx +++ b/src/OpenGl/OpenGl_Workspace_5.cxx @@ -623,3 +623,17 @@ const OpenGl_AspectText * OpenGl_Workspace::AspectText(const Standard_Boolean Wi } /*----------------------------------------------------------------------*/ + +//======================================================================= +//function : ResetAppliedAspect +//purpose : +//======================================================================= + +void OpenGl_Workspace::ResetAppliedAspect() +{ + AspectLine_applied = NULL; + AspectFace_applied = NULL; + AspectMarker_applied = NULL; + AspectText_applied = NULL; + TextParam_applied = NULL; +}