Porting to OCCT-7.4.0

This commit is contained in:
rnv 2019-12-17 22:17:17 +03:00
parent e87935b0f9
commit d07a864e83
4 changed files with 88 additions and 4 deletions

View File

@ -27,6 +27,8 @@
#include <QMutexLocker>
#include <Basics_OCCTVersion.hxx>
/*!
\brief Constructor
@ -557,17 +559,34 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect( bool theIsFront )
QColor c;
// ambient reflection
#if OCC_VERSION_LARGE >= 0x07040000
if ( color( Ambient ).isValid() ) {
c = color( Ambient );
aspect.SetAmbientColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
aspect.SetAmbientColor( Quantity_Color( Graphic3d_Vec3( c.redF(), c.greenF(), c.blueF() ) * reflection( Ambient, theIsFront ) ) );
}
if ( !hasReflection( Ambient ) )
aspect.SetAmbientColor( Quantity_NOC_BLACK );
#else
if ( color( Ambient ).isValid() ) {
c = color( Ambient );
aspect.SetAmbientColor( ( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
}
aspect.SetAmbient( reflection( Ambient, theIsFront ));
if ( hasReflection( Ambient ) )
aspect.SetReflectionModeOn( Graphic3d_TOR_AMBIENT );
else
aspect.SetReflectionModeOff( Graphic3d_TOR_AMBIENT );
#endif
// diffuse reflection
#if OCC_VERSION_LARGE >= 0x07040000
if ( color( Diffuse ).isValid() ) {
c = color( Diffuse );
aspect.SetDiffuseColor( Quantity_Color( Graphic3d_Vec3( c.redF(), c.greenF(), c.blueF() ) * reflection( Diffuse, theIsFront ) ) );
}
if ( !hasReflection( Diffuse ) )
aspect.SetDiffuseColor( Quantity_NOC_BLACK );
#else
if ( color( Diffuse ).isValid() ) {
c = color( Diffuse );
aspect.SetDiffuseColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
@ -577,8 +596,17 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect( bool theIsFront )
aspect.SetReflectionModeOn( Graphic3d_TOR_DIFFUSE );
else
aspect.SetReflectionModeOff( Graphic3d_TOR_DIFFUSE );
#endif
// specular reflection
#if OCC_VERSION_LARGE >= 0x07040000
if ( color( Specular ).isValid() ) {
c = color( Specular );
aspect.SetSpecularColor( Quantity_Color( Graphic3d_Vec3( c.redF(), c.greenF(), c.blueF() ) * reflection( Specular, theIsFront ) ) );
}
if ( !hasReflection( Specular ) )
aspect.SetSpecularColor( Quantity_NOC_BLACK );
#else
if ( color( Specular ).isValid() ) {
c = color( Specular );
aspect.SetSpecularColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
@ -588,8 +616,17 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect( bool theIsFront )
aspect.SetReflectionModeOn( Graphic3d_TOR_SPECULAR );
else
aspect.SetReflectionModeOff( Graphic3d_TOR_SPECULAR );
#endif
// emissive reflection
#if OCC_VERSION_LARGE >= 0x07040000
if ( color( Emissive ).isValid() ) {
c = color( Emissive );
aspect.SetEmissiveColor( Quantity_Color( Graphic3d_Vec3( c.redF(), c.greenF(), c.blueF() ) * reflection( Emissive, theIsFront ) ) );
}
if ( !hasReflection( Emissive ) )
aspect.SetEmissiveColor( Quantity_NOC_BLACK );
#else
if ( color( Emissive ).isValid() ) {
c = color( Emissive );
aspect.SetEmissiveColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
@ -599,6 +636,7 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect( bool theIsFront )
aspect.SetReflectionModeOn( Graphic3d_TOR_EMISSION );
else
aspect.SetReflectionModeOff( Graphic3d_TOR_EMISSION );
#endif
// shininess
aspect.SetShininess( shininess( theIsFront ) );

View File

@ -161,12 +161,18 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
myTopLevel = Standard_False;
Graphic3d_MaterialAspect aMatAspect;
if ( !HasMaterial() ) {
#if OCC_VERSION_LARGE >= 0x07040000
aMatAspect.SetAmbientColor( Quantity_Color (Graphic3d_Vec3( 0.5f ) ) );
aMatAspect.SetDiffuseColor( Quantity_Color (Graphic3d_Vec3( 0.5f ) ) );
aMatAspect.SetEmissiveColor( Quantity_Color (Graphic3d_Vec3( 0.5f ) ) );
aMatAspect.SetSpecularColor( Quantity_Color (Graphic3d_Vec3( 0.5f ) ) );
#else
aMatAspect.SetAmbient( 0.5 );
aMatAspect.SetDiffuse( 0.5 );
aMatAspect.SetEmissive( 0.5 );
aMatAspect.SetShininess(0.5 );
aMatAspect.SetSpecular( 0.5 );
#endif
aMatAspect.SetShininess(0.5 );
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect);
}

View File

@ -624,10 +624,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
@ -698,13 +706,24 @@ void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)&
#endif
// getting string size will also initialize font library
#if OCC_VERSION_LARGE >= 0x07040000
myTextDraw->StringSize( aContext,
myText, *anAspect, myTextParams->Height(), aDPI,
myTextSize.x, myTextSize.a, myTextSize.d );
#else
myTextDraw->StringSize( aContext,
myText, *anAspect, myTextParams, aDPI,
myTextSize.x, myTextSize.a, myTextSize.d );
#endif
myTextDPI = aDPI;
myTextSize.y = myTextSize.a - myTextSize.d;
# if OCC_VERSION_LARGE >= 0x07040000
switch ( myTextParams->HorizontalAlignment() )
#else
switch (myTextParams.HAlign)
#endif
{
case Graphic3d_HTA_LEFT: myTextUnderline.x() = 0.f; break;
case Graphic3d_HTA_CENTER: myTextUnderline.x() = -myTextSize.x / 2.f; break;
@ -712,7 +731,12 @@ void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)&
default:
break;
}
# if OCC_VERSION_LARGE >= 0x07040000
switch ( myTextParams->VerticalAlignment() )
#else
switch (myTextParams.VAlign)
#endif
{
case Graphic3d_VTA_TOPFIRSTLINE:
case Graphic3d_VTA_TOP: myTextUnderline.y() = -myTextSize.y; break;
@ -813,14 +837,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;

View File

@ -34,7 +34,6 @@
#include <NCollection_Handle.hxx>
#include <NCollection_String.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_TextParam.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_TextAspect.hxx>
@ -45,6 +44,11 @@
#include <TCollection_ExtendedString.hxx>
#include <Basics_OCCTVersion.hxx>
#if OCC_VERSION_LARGE >= 0x07040000
#include <Graphic3d_Text.hxx>
#else
#include <OpenGl_TextParam.hxx>
#endif
class OpenGl_GraphicDriver;
class OpenGl_PrimitiveArray;
@ -329,7 +333,11 @@ private:
GEOM_Annotation* myAISObject; //!< Instance of presentation class.
NCollection_String myText; //!< Text string of annotation label.
#if OCC_VERSION_LARGE >= 0x07040000
Handle(Graphic3d_Text) myTextParams; //!< Text draw parameters.
#else
OpenGl_TextParam myTextParams; //!< Text draw parameters.
#endif
OpenGl_Text* myTextDraw; //!< Text draw element.
OpenGl_PrimitiveArray* myTextLineDraw; //!< Text underline draw element.
OpenGl_PrimitiveArray* myExtLineDraw; //!< Extension line draw element.