Salome HOME
Porting to OCCT-7.4.0
authorrnv <rnv@opencascade.com>
Tue, 17 Dec 2019 19:17:17 +0000 (22:17 +0300)
committerrnv <rnv@opencascade.com>
Tue, 17 Dec 2019 19:17:17 +0000 (22:17 +0300)
src/Material/Material_Model.cxx
src/OBJECT/GEOM_AISShape.cxx
src/OBJECT/GEOM_Annotation.cxx
src/OBJECT/GEOM_Annotation.hxx

index 0b6792f342319162231a5f8fae8f2b1e5b8f4c06..8f66ac34a3c31f3fc0eb4681113b5f788d8ebbda 100644 (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( 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( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
+    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 ) );
index 11ef68e1c7505d7bb2c569a33e09adafc92f0c0b..abfab4f731d4ff7e651a78f362bc50fc0edced4c 100644 (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);
   }
index 932466d9b94a69c3c8e3b66e9f4b100041d687c6..830569b6538617d0729ff45c52b196fa1a6058cc 100644 (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;
index 5ecb3817488a7c1f981864a2b7deb5004cdc803f..bcc5f0b72a5beed9bb538b48499bbc9a2d67be7c 100644 (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>
 #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.