X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOBJECT%2FGEOM_Annotation.cxx;h=42fe984179a40cf7d5c5f49b254c8b9742c127b2;hb=922cc08eea7fdde898b17104ced238c4978c2ec2;hp=d45fed6c86fce779eb23a46b3758803335188f33;hpb=a9fe5759c52e7f225c6b1403bf93fc97c10874b9;p=modules%2Fgeom.git diff --git a/src/OBJECT/GEOM_Annotation.cxx b/src/OBJECT/GEOM_Annotation.cxx old mode 100755 new mode 100644 index d45fed6c8..42fe98417 --- a/src/OBJECT/GEOM_Annotation.cxx +++ b/src/OBJECT/GEOM_Annotation.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -52,6 +52,8 @@ #include #include +#include + IMPLEMENT_STANDARD_RTTIEXT( GEOM_Annotation, AIS_InteractiveObject ) // ======================================================================= @@ -536,11 +538,20 @@ Bnd_Box GEOM_Annotation::TextBoundingBox() const { Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect(); Font_FTFont aFont; +#if OCC_VERSION_LARGE >= 0x070400FF + Font_FTFontParams aFontParams; + aFontParams.PointSize = (unsigned int)anAsp->Height(); + aFontParams.Resolution = GetContext()->CurrentViewer()->DefaultRenderingParams().Resolution; + if ( aFont.FindAndInit(anAsp->Aspect()->Font().ToCString(), + anAsp->Aspect()->GetTextFontAspect(), + aFontParams) ) +#else unsigned int aResolution = GetContext()->CurrentViewer()->DefaultRenderingParams().Resolution; if ( aFont.Init( anAsp->Aspect()->Font().ToCString(), anAsp->Aspect()->GetTextFontAspect(), - (unsigned int)anAsp->Height(), - aResolution ) ) + (unsigned int)anAsp->Height(), + aResolution ) ) // deprecated API, to be removed (see above) +#endif { const NCollection_String aText( (Standard_Utf16Char* )myText.ToExtString() ); const Font_Rect aFontRect = aFont.BoundingBox( aText, Graphic3d_HTA_CENTER, Graphic3d_VTA_CENTER ); @@ -622,10 +633,18 @@ GEOM_Annotation::OpenGl_Annotation::OpenGl_Annotation( GEOM_Annotation* theAnnot myTextDPI( 0 ) { // graphical resources for drawing text and underline +#if OCC_VERSION_LARGE >= 0x07040000 + myTextParams = new Graphic3d_Text( theTextHeight ); + myTextParams->SetText( myText.ToCString() ); + myTextParams->SetHorizontalAlignment ( Graphic3d_HTA_CENTER ); + myTextParams->SetVerticalAlignment ( Graphic3d_VTA_CENTER ); + myTextDraw = new OpenGl_Text( myTextParams ); +#else myTextParams.Height = theTextHeight; myTextParams.HAlign = Graphic3d_HTA_CENTER; myTextParams.VAlign = Graphic3d_VTA_CENTER; myTextDraw = new OpenGl_Text( myText.ToCString(), OpenGl_Vec3(), myTextParams ); +#endif myTextLineDraw = new OpenGl_PrimitiveArray( theDriver ); // graphical resources for drawing extension line and marker @@ -689,16 +708,24 @@ void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)& const unsigned int aDPI = theWorkspace->View()->RenderingParams().Resolution; if (myTextDPI != aDPI) { - const OpenGl_AspectText* anAspect = theWorkspace->AspectText(); + const OpenGl_Aspects* anAspect = theWorkspace->Aspects(); // getting string size will also initialize font library +#if OCC_VERSION_LARGE >= 0x07070000 + Font_Hinting aFH = theWorkspace->View()->RenderingParams().FontHinting; + myTextDraw->StringSize( aContext, + myText, *anAspect, myTextParams->Height(), aDPI, aFH, + myTextSize.x, myTextSize.a, myTextSize.d ); +#else myTextDraw->StringSize( aContext, - myText, *anAspect, myTextParams, aDPI, + myText, *anAspect, myTextParams->Height(), aDPI, myTextSize.x, myTextSize.a, myTextSize.d ); +#endif myTextDPI = aDPI; myTextSize.y = myTextSize.a - myTextSize.d; - switch (myTextParams.HAlign) + + switch ( myTextParams->HorizontalAlignment() ) { case Graphic3d_HTA_LEFT: myTextUnderline.x() = 0.f; break; case Graphic3d_HTA_CENTER: myTextUnderline.x() = -myTextSize.x / 2.f; break; @@ -706,7 +733,8 @@ void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)& default: break; } - switch (myTextParams.VAlign) + + switch ( myTextParams->VerticalAlignment() ) { case Graphic3d_VTA_TOPFIRSTLINE: case Graphic3d_VTA_TOP: myTextUnderline.y() = -myTextSize.y; break; @@ -751,7 +779,7 @@ void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)& { Handle(Graphic3d_PresentationAttributes) empty; theWorkspace->SetHighlightStyle(empty); - theWorkspace->ApplyAspectLine(); + theWorkspace->ApplyAspects(); } GLint myOldDepthMode = 0; @@ -772,7 +800,7 @@ void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)& // to avoid jittering when dragging text myTextDraw->SetPosition( OpenGl_Vec3( static_cast( myAISObject->myPosition.X() ), static_cast( myAISObject->myPosition.Y() ), - static_cast( myAISObject->myPosition.Z() ) ) ); + static_cast( myAISObject->myPosition.Z() ) ) ); // todo: deprecated OCCT API } myTextDraw->Render( theWorkspace ); @@ -803,14 +831,22 @@ void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)& // ------------------------------------------------------------ OpenGl_Vec4 aCenter (0.f, 0.f, 0.f, 1.f); +# if OCC_VERSION_LARGE >= 0x07040000 + switch ( myTextParams->HorizontalAlignment() ) +#else switch (myTextParams.HAlign) +#endif { case Graphic3d_HTA_LEFT: aCenter.x() = myTextSize.x / 2.f; break; case Graphic3d_HTA_CENTER: aCenter.x() = 0.f; break; case Graphic3d_HTA_RIGHT: aCenter.x() = -myTextSize.x / 2.f; break; default: break; } +# if OCC_VERSION_LARGE >= 0x07040000 + switch ( myTextParams->VerticalAlignment() ) +#else switch (myTextParams.VAlign) +#endif { case Graphic3d_VTA_TOPFIRSTLINE: case Graphic3d_VTA_TOP: aCenter.y() = -myTextSize.y / 2.f; break;