Salome HOME
0023595: [CEA 2275] : Manual test KO GEOM : The fields are not displayed
[modules/geom.git] / src / OBJECT / GEOM_AISShape.cxx
index df0464e442615cab01dec807c89c53de67ebe0e2..06cd122b363e36d57e1f6c211b48f2025c67c708 100644 (file)
@@ -30,8 +30,6 @@
 
 #include <GEOMUtils.hxx>
 
-#include <Basics_OCCTVersion.hxx>
-
 // Open CASCADE Includes
 #include <AIS_InteractiveContext.hxx>
 #include <BRepAdaptor_Surface.hxx>
@@ -43,6 +41,7 @@
 #include <Graphic3d_AspectLine3d.hxx>
 #include <Graphic3d_AspectMarker3d.hxx>
 #include <Graphic3d_AspectText3d.hxx>
+#include <Prs3d.hxx>
 #include <Prs3d_Arrow.hxx>
 #include <Prs3d_IsoAspect.hxx>
 #include <Prs3d_ShadingAspect.hxx>
@@ -51,6 +50,7 @@
 #include <SelectMgr_IndexedMapOfOwner.hxx>
 #include <SelectMgr_Selection.hxx>
 #include <StdPrs_ShadedShape.hxx>
+#include <StdPrs_ToolTriangulatedShape.hxx>
 #include <StdSelect_BRepOwner.hxx>
 #include <StdSelect_DisplayMode.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
 #include <gp_Dir.hxx>
 #include <gp_Pnt.hxx>
 #include <gp_Vec.hxx>
-
-#if OCC_VERSION_LARGE > 0x06070200
 #include <Prs3d_VertexDrawMode.hxx>
-#endif
-
-#if OCC_VERSION_MAJOR < 7
-  #include <StdPrs_WFDeflectionShape.hxx>
-#else
-  #include <StdPrs_WFShape.hxx>
-#endif
+#include <StdPrs_WFShape.hxx>
 
 #include <SalomeApp_Tools.h>
 #include <SUIT_Session.h>
 #include <SUIT_ResourceMgr.h>
 
-OCCT_IMPLEMENT_STANDARD_RTTIEXT(GEOM_AISShape, SALOME_AISShape)
+IMPLEMENT_STANDARD_RTTIEXT(GEOM_AISShape, SALOME_AISShape)
 
 GEOM_AISShape::TopLevelDispMode GEOM_AISShape::myTopLevelDm = GEOM_AISShape::TopKeepCurrent;
 Quantity_Color GEOM_AISShape::myTopLevelColor;
@@ -107,15 +99,11 @@ static void getEntityOwners( const Handle(AIS_InteractiveObject)&  theObj,
     Handle(SelectMgr_Selection) sel = theObj->Selection( m );
 
     for ( sel->Init(); sel->More(); sel->Next() ) {
-#if OCC_VERSION_LARGE > 0x06080100
       const Handle(SelectMgr_SensitiveEntity) aHSenEntity = sel->Sensitive();
       if( aHSenEntity.IsNull() )
         continue;
 
       Handle(SelectBasics_SensitiveEntity) entity = aHSenEntity->BaseSensitive();
-#else
-      Handle(SelectBasics_SensitiveEntity) entity = sel->Sensitive();
-#endif
       if ( entity.IsNull() )
         continue;
       Handle(SelectMgr_EntityOwner) owner =
@@ -218,10 +206,15 @@ Standard_CString GEOM_AISShape::getName()
   return myName.ToCString();
 }
 
+Standard_Boolean GEOM_AISShape::AcceptDisplayMode(const Standard_Integer theMode) const
+{
+  return theMode >= Wireframe && theMode <= CustomHighlight;
+}
+
 void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
                             const Handle(Prs3d_Presentation)&           aPrs,
                             const Standard_Integer                      aMode)
-{  
+{ 
   if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL
 
   Handle(AIS_InteractiveContext) anIC = GetContext();
@@ -234,15 +227,22 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent
   bool anIsColorField = anIsField && myFieldDataType != GEOM::FDT_String;
   bool anIsTextField = anIsField && myFieldDataType == GEOM::FDT_String;
 
-#if OCC_VERSION_LARGE > 0x06070200
   if (isShowVertices())
     myDrawer->SetVertexDrawMode(Prs3d_VDM_All);
-#endif
 
   //   StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode;
   bool isTopLev = isTopLevel() && switchTopLevel();
   switch (aMode) {
     case Wireframe:
+    // Begin 0023271: [CEA 1823] Deflection Coefficient not taken into account in wireframe
+    {
+      StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
+
+      // After this call if type of deflection is relative
+      // computed deflection coefficient is stored as absolute.
+      Prs3d::GetDeflection (myshape, myDrawer);
+    }
+    // End 0023271
     case CustomHighlight:
     {
       if(isTopLev) {
@@ -254,11 +254,7 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent
       if( !isTopLev && anIsColorField && myFieldDimension == 1 )
         drawField( aPrs, false, aMode == CustomHighlight );
       else
-#if OCC_VERSION_MAJOR < 7
-        StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);      
-#else
         StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
-#endif
       break;
     }
     case Shading:
@@ -278,11 +274,8 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent
     }
     case TexturedShape:
     {
-#ifdef USE_TEXTURED_SHAPE
-        AIS_TexturedShape::Compute(aPresentationManager, aPrs, aMode);
-#else
-        AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
-#endif
+      shadingMode(aPresentationManager, aPrs, Shading);
+      break;
     }
   }
   if (isShowVectors())
@@ -437,11 +430,7 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre
   {
     // PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces
     //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
-#ifdef USE_TEXTURED_SHAPE
-    AIS_TexturedShape::Compute(aPresentationManager, aPrs, aMode);
-#else
-    AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
-#endif
+    SALOME_AISShape::Compute(aPresentationManager, aPrs, aMode);
   }
 }
 
@@ -598,12 +587,13 @@ void GEOM_AISShape::drawField( const Handle(Prs3d_Presentation)& thePrs,
           anAspectText3d->SetColor( myLabelColor );
           aGroup->SetPrimitivesAspect( anAspectText3d );
 
-          aGroup->Text( aString.toLatin1().constData(), aVertex, 14 );
+          aGroup->Text( aString.toUtf8().constData(), aVertex, 14 );
         }
       }
       else
       {
         Quantity_Color aColor( aQColor.redF(), aQColor.greenF(), aQColor.blueF(), Quantity_TOC_RGB );
+        SetCustomColor( aSubShape, aColor );
         if( myFieldDimension == 0 )
         {
           TopoDS_Vertex aVertexShape = TopoDS::Vertex( aSubShape );
@@ -630,22 +620,25 @@ void GEOM_AISShape::drawField( const Handle(Prs3d_Presentation)& thePrs,
             myDrawer->WireAspect()->SetWidth( myOwnWidth );
           else
             myDrawer->WireAspect()->SetWidth( myOwnWidth + 4 );
-#if OCC_VERSION_MAJOR < 7
-          StdPrs_WFDeflectionShape::Add( thePrs, aSubShape, myDrawer );
-#else
+          /*
           StdPrs_WFShape::Add( thePrs, aSubShape, myDrawer );
-#endif
+          */
         }
         else if( myFieldDimension == 2 ||
                  myFieldDimension == 3 ||
                  myFieldDimension == -1 )
         {
-          myDrawer->ShadingAspect()->SetColor( aColor );
-          StdPrs_ShadedShape::Add( thePrs, aSubShape, myDrawer );
+          //Handle(Prs3d_ShadingAspect) anAspect = new Prs3d_ShadingAspect();
+          //anAspect->SetColor( aColor );
+          //myDrawer->SetShadingAspect( anAspect );
+          //StdPrs_ShadedShape::Add( thePrs, aSubShape, myDrawer );
         }
       }
     }
   }
+
+  SALOME_AISShape::Compute( Handle(PrsMgr_PresentationManager3d)(),
+                            thePrs, AIS_Shaded );
 }
 
 void GEOM_AISShape::drawName( const Handle(Prs3d_Presentation)& thePrs )
@@ -707,10 +700,14 @@ Standard_Boolean GEOM_AISShape::computeMassCenter( const TopoDS_Shape& theShape,
         C += ( uv1.XY() + uv2.XY() + uv3.XY() ) / 3. * a;
         A += a;
       }
-      C /= A;
-      theCenter = surface.Value( C.X(), C.Y() );
+      if ( A > std::numeric_limits<double>::min() )
+      {
+        C /= A;
+        theCenter = surface.Value( C.X(), C.Y() );
+        aNbPoints = 1;
+      }
     }
-    else
+    if ( aNbPoints == 0 )
     {
       theCenter = surface.Value( 0.5 * ( surface.FirstUParameter() + surface.LastUParameter() ),
                                  0.5 * ( surface.FirstVParameter() + surface.LastVParameter() ));