mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-12 17:50:35 +05:00
Porting to OCCT-7.4.0
This commit is contained in:
parent
e87935b0f9
commit
d07a864e83
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
|
|
||||||
|
#include <Basics_OCCTVersion.hxx>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Constructor
|
\brief Constructor
|
||||||
|
|
||||||
@ -557,17 +559,34 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect( bool theIsFront )
|
|||||||
QColor c;
|
QColor c;
|
||||||
|
|
||||||
// ambient reflection
|
// ambient reflection
|
||||||
|
#if OCC_VERSION_LARGE >= 0x07040000
|
||||||
if ( color( Ambient ).isValid() ) {
|
if ( color( Ambient ).isValid() ) {
|
||||||
c = color( Ambient );
|
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 ));
|
aspect.SetAmbient( reflection( Ambient, theIsFront ));
|
||||||
if ( hasReflection( Ambient ) )
|
if ( hasReflection( Ambient ) )
|
||||||
aspect.SetReflectionModeOn( Graphic3d_TOR_AMBIENT );
|
aspect.SetReflectionModeOn( Graphic3d_TOR_AMBIENT );
|
||||||
else
|
else
|
||||||
aspect.SetReflectionModeOff( Graphic3d_TOR_AMBIENT );
|
aspect.SetReflectionModeOff( Graphic3d_TOR_AMBIENT );
|
||||||
|
#endif
|
||||||
|
|
||||||
// diffuse reflection
|
// 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() ) {
|
if ( color( Diffuse ).isValid() ) {
|
||||||
c = color( Diffuse );
|
c = color( Diffuse );
|
||||||
aspect.SetDiffuseColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
|
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 );
|
aspect.SetReflectionModeOn( Graphic3d_TOR_DIFFUSE );
|
||||||
else
|
else
|
||||||
aspect.SetReflectionModeOff( Graphic3d_TOR_DIFFUSE );
|
aspect.SetReflectionModeOff( Graphic3d_TOR_DIFFUSE );
|
||||||
|
#endif
|
||||||
|
|
||||||
// specular reflection
|
// 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() ) {
|
if ( color( Specular ).isValid() ) {
|
||||||
c = color( Specular );
|
c = color( Specular );
|
||||||
aspect.SetSpecularColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
|
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 );
|
aspect.SetReflectionModeOn( Graphic3d_TOR_SPECULAR );
|
||||||
else
|
else
|
||||||
aspect.SetReflectionModeOff( Graphic3d_TOR_SPECULAR );
|
aspect.SetReflectionModeOff( Graphic3d_TOR_SPECULAR );
|
||||||
|
#endif
|
||||||
|
|
||||||
// emissive reflection
|
// 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() ) {
|
if ( color( Emissive ).isValid() ) {
|
||||||
c = color( Emissive );
|
c = color( Emissive );
|
||||||
aspect.SetEmissiveColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
|
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 );
|
aspect.SetReflectionModeOn( Graphic3d_TOR_EMISSION );
|
||||||
else
|
else
|
||||||
aspect.SetReflectionModeOff( Graphic3d_TOR_EMISSION );
|
aspect.SetReflectionModeOff( Graphic3d_TOR_EMISSION );
|
||||||
|
#endif
|
||||||
|
|
||||||
// shininess
|
// shininess
|
||||||
aspect.SetShininess( shininess( theIsFront ) );
|
aspect.SetShininess( shininess( theIsFront ) );
|
||||||
|
@ -161,12 +161,18 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
|
|||||||
myTopLevel = Standard_False;
|
myTopLevel = Standard_False;
|
||||||
Graphic3d_MaterialAspect aMatAspect;
|
Graphic3d_MaterialAspect aMatAspect;
|
||||||
if ( !HasMaterial() ) {
|
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.SetAmbient( 0.5 );
|
||||||
aMatAspect.SetDiffuse( 0.5 );
|
aMatAspect.SetDiffuse( 0.5 );
|
||||||
aMatAspect.SetEmissive( 0.5 );
|
aMatAspect.SetEmissive( 0.5 );
|
||||||
aMatAspect.SetShininess(0.5 );
|
|
||||||
aMatAspect.SetSpecular( 0.5 );
|
aMatAspect.SetSpecular( 0.5 );
|
||||||
|
#endif
|
||||||
|
aMatAspect.SetShininess(0.5 );
|
||||||
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
|
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
|
||||||
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect);
|
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect);
|
||||||
}
|
}
|
||||||
|
@ -624,10 +624,18 @@ GEOM_Annotation::OpenGl_Annotation::OpenGl_Annotation( GEOM_Annotation* theAnnot
|
|||||||
myTextDPI( 0 )
|
myTextDPI( 0 )
|
||||||
{
|
{
|
||||||
// graphical resources for drawing text and underline
|
// 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.Height = theTextHeight;
|
||||||
myTextParams.HAlign = Graphic3d_HTA_CENTER;
|
myTextParams.HAlign = Graphic3d_HTA_CENTER;
|
||||||
myTextParams.VAlign = Graphic3d_VTA_CENTER;
|
myTextParams.VAlign = Graphic3d_VTA_CENTER;
|
||||||
myTextDraw = new OpenGl_Text( myText.ToCString(), OpenGl_Vec3(), myTextParams );
|
myTextDraw = new OpenGl_Text( myText.ToCString(), OpenGl_Vec3(), myTextParams );
|
||||||
|
#endif
|
||||||
myTextLineDraw = new OpenGl_PrimitiveArray( theDriver );
|
myTextLineDraw = new OpenGl_PrimitiveArray( theDriver );
|
||||||
|
|
||||||
// graphical resources for drawing extension line and marker
|
// graphical resources for drawing extension line and marker
|
||||||
@ -698,13 +706,24 @@ void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)&
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// getting string size will also initialize font library
|
// 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,
|
myTextDraw->StringSize( aContext,
|
||||||
myText, *anAspect, myTextParams, aDPI,
|
myText, *anAspect, myTextParams, aDPI,
|
||||||
myTextSize.x, myTextSize.a, myTextSize.d );
|
myTextSize.x, myTextSize.a, myTextSize.d );
|
||||||
|
#endif
|
||||||
|
|
||||||
myTextDPI = aDPI;
|
myTextDPI = aDPI;
|
||||||
myTextSize.y = myTextSize.a - myTextSize.d;
|
myTextSize.y = myTextSize.a - myTextSize.d;
|
||||||
|
|
||||||
|
# if OCC_VERSION_LARGE >= 0x07040000
|
||||||
|
switch ( myTextParams->HorizontalAlignment() )
|
||||||
|
#else
|
||||||
switch (myTextParams.HAlign)
|
switch (myTextParams.HAlign)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
case Graphic3d_HTA_LEFT: myTextUnderline.x() = 0.f; break;
|
case Graphic3d_HTA_LEFT: myTextUnderline.x() = 0.f; break;
|
||||||
case Graphic3d_HTA_CENTER: myTextUnderline.x() = -myTextSize.x / 2.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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# if OCC_VERSION_LARGE >= 0x07040000
|
||||||
|
switch ( myTextParams->VerticalAlignment() )
|
||||||
|
#else
|
||||||
switch (myTextParams.VAlign)
|
switch (myTextParams.VAlign)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
case Graphic3d_VTA_TOPFIRSTLINE:
|
case Graphic3d_VTA_TOPFIRSTLINE:
|
||||||
case Graphic3d_VTA_TOP: myTextUnderline.y() = -myTextSize.y; break;
|
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);
|
OpenGl_Vec4 aCenter (0.f, 0.f, 0.f, 1.f);
|
||||||
|
# if OCC_VERSION_LARGE >= 0x07040000
|
||||||
|
switch ( myTextParams->HorizontalAlignment() )
|
||||||
|
#else
|
||||||
switch (myTextParams.HAlign)
|
switch (myTextParams.HAlign)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
case Graphic3d_HTA_LEFT: aCenter.x() = myTextSize.x / 2.f; break;
|
case Graphic3d_HTA_LEFT: aCenter.x() = myTextSize.x / 2.f; break;
|
||||||
case Graphic3d_HTA_CENTER: aCenter.x() = 0.f; break;
|
case Graphic3d_HTA_CENTER: aCenter.x() = 0.f; break;
|
||||||
case Graphic3d_HTA_RIGHT: aCenter.x() = -myTextSize.x / 2.f; break;
|
case Graphic3d_HTA_RIGHT: aCenter.x() = -myTextSize.x / 2.f; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
# if OCC_VERSION_LARGE >= 0x07040000
|
||||||
|
switch ( myTextParams->VerticalAlignment() )
|
||||||
|
#else
|
||||||
switch (myTextParams.VAlign)
|
switch (myTextParams.VAlign)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
case Graphic3d_VTA_TOPFIRSTLINE:
|
case Graphic3d_VTA_TOPFIRSTLINE:
|
||||||
case Graphic3d_VTA_TOP: aCenter.y() = -myTextSize.y / 2.f; break;
|
case Graphic3d_VTA_TOP: aCenter.y() = -myTextSize.y / 2.f; break;
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include <NCollection_Handle.hxx>
|
#include <NCollection_Handle.hxx>
|
||||||
#include <NCollection_String.hxx>
|
#include <NCollection_String.hxx>
|
||||||
#include <OpenGl_Element.hxx>
|
#include <OpenGl_Element.hxx>
|
||||||
#include <OpenGl_TextParam.hxx>
|
|
||||||
#include <Prs3d_Presentation.hxx>
|
#include <Prs3d_Presentation.hxx>
|
||||||
#include <Prs3d_LineAspect.hxx>
|
#include <Prs3d_LineAspect.hxx>
|
||||||
#include <Prs3d_TextAspect.hxx>
|
#include <Prs3d_TextAspect.hxx>
|
||||||
@ -45,6 +44,11 @@
|
|||||||
#include <TCollection_ExtendedString.hxx>
|
#include <TCollection_ExtendedString.hxx>
|
||||||
|
|
||||||
#include <Basics_OCCTVersion.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_GraphicDriver;
|
||||||
class OpenGl_PrimitiveArray;
|
class OpenGl_PrimitiveArray;
|
||||||
@ -329,7 +333,11 @@ private:
|
|||||||
|
|
||||||
GEOM_Annotation* myAISObject; //!< Instance of presentation class.
|
GEOM_Annotation* myAISObject; //!< Instance of presentation class.
|
||||||
NCollection_String myText; //!< Text string of annotation label.
|
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.
|
OpenGl_TextParam myTextParams; //!< Text draw parameters.
|
||||||
|
#endif
|
||||||
OpenGl_Text* myTextDraw; //!< Text draw element.
|
OpenGl_Text* myTextDraw; //!< Text draw element.
|
||||||
OpenGl_PrimitiveArray* myTextLineDraw; //!< Text underline draw element.
|
OpenGl_PrimitiveArray* myTextLineDraw; //!< Text underline draw element.
|
||||||
OpenGl_PrimitiveArray* myExtLineDraw; //!< Extension line draw element.
|
OpenGl_PrimitiveArray* myExtLineDraw; //!< Extension line draw element.
|
||||||
|
Loading…
Reference in New Issue
Block a user