Salome HOME
0023595: [CEA 2275] : Manual test KO GEOM : The fields are not displayed
[modules/geom.git] / src / OBJECT / GEOM_AISShape.cxx
index ed3d535e0e846bafd6f4806a74cc1043f1fa7217..06cd122b363e36d57e1f6c211b48f2025c67c708 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  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
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-//  GEOM OBJECT : interactive object for Geometry entities visualization
-//  File   : GEOM_AISShape.cxx
-//  Author : Nicolas REJNERI
-//  Module : GEOM
-
 /*!
   \class GEOM_AISShape GEOM_AISShape.hxx
   \brief ....
 */
 
-#include "GEOM_AISShape.ixx"
-#include "SALOME_InteractiveObject.hxx"
+#include "GEOM_AISShape.hxx"
 #include "GEOM_AISVector.hxx"
 
+#include <GEOMUtils.hxx>
+
 // Open CASCADE Includes
-#include <AIS_Drawer.hxx>
 #include <AIS_InteractiveContext.hxx>
-
+#include <BRepAdaptor_Surface.hxx>
 #include <BRep_Tool.hxx>
-
 #include <GCPnts_AbscissaPoint.hxx>
 #include <GeomAdaptor_Curve.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Vec.hxx>
+#include <Graphic3d_ArrayOfPoints.hxx>
 #include <Graphic3d_AspectFillArea3d.hxx>
 #include <Graphic3d_AspectLine3d.hxx>
-
-#include <Prs3d_ShadingAspect.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_AspectText3d.hxx>
+#include <Prs3d.hxx>
 #include <Prs3d_Arrow.hxx>
 #include <Prs3d_IsoAspect.hxx>
-
+#include <Prs3d_ShadingAspect.hxx>
 #include <SelectBasics_SensitiveEntity.hxx>
 #include <SelectMgr_EntityOwner.hxx>
-#include <StdSelect_BRepOwner.hxx>
 #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 <StdPrs_WFDeflectionShape.hxx>
-
 #include <TColStd_IndexedMapOfInteger.hxx>
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
 #include <TColStd_ListOfInteger.hxx>
 #include <TopExp.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
-#include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Vertex.hxx>
-
-#include <TColStd_SequenceOfInteger.hxx>
-
 #include <V3d_View.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <Prs3d_VertexDrawMode.hxx>
+#include <StdPrs_WFShape.hxx>
 
 #include <SalomeApp_Tools.h>
-
 #include <SUIT_Session.h>
 #include <SUIT_ResourceMgr.h>
 
+IMPLEMENT_STANDARD_RTTIEXT(GEOM_AISShape, SALOME_AISShape)
+
 GEOM_AISShape::TopLevelDispMode GEOM_AISShape::myTopLevelDm = GEOM_AISShape::TopKeepCurrent;
 Quantity_Color GEOM_AISShape::myTopLevelColor;
 
 
-static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj,
+static void getEntityOwners( const Handle(AIS_InteractiveObject)&  theObj,
                              const Handle(AIS_InteractiveContext)& theIC,
-                             SelectMgr_IndexedMapOfOwner& theMap )
+                             SelectMgr_IndexedMapOfOwner&          theMap )
 {
   if ( theObj.IsNull() || theIC.IsNull() )
     return;
@@ -105,10 +99,13 @@ static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj,
     Handle(SelectMgr_Selection) sel = theObj->Selection( m );
 
     for ( sel->Init(); sel->More(); sel->Next() ) {
-      Handle(SelectBasics_SensitiveEntity) entity = sel->Sensitive();
-      if ( entity.IsNull() )
+      const Handle(SelectMgr_SensitiveEntity) aHSenEntity = sel->Sensitive();
+      if( aHSenEntity.IsNull() )
         continue;
 
+      Handle(SelectBasics_SensitiveEntity) entity = aHSenEntity->BaseSensitive();
+      if ( entity.IsNull() )
+        continue;
       Handle(SelectMgr_EntityOwner) owner =
         Handle(SelectMgr_EntityOwner)::DownCast(entity->OwnerId());
       if ( !owner.IsNull() )
@@ -118,9 +115,9 @@ static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj,
 }
 
 static void indicesToOwners( const TColStd_IndexedMapOfInteger& aIndexMap,
-                             const TopoDS_Shape& aMainShape,
-                             const SelectMgr_IndexedMapOfOwner& anAllMap, 
-                             SelectMgr_IndexedMapOfOwner& aToHiliteMap )
+                             const TopoDS_Shape&                aMainShape,
+                             const SelectMgr_IndexedMapOfOwner& anAllMap,
+                             SelectMgr_IndexedMapOfOwner&       aToHiliteMap )
 {
   TopTools_IndexedMapOfShape aMapOfShapes;
   TopExp::MapShapes(aMainShape, aMapOfShapes);
@@ -134,52 +131,64 @@ static void indicesToOwners( const TColStd_IndexedMapOfInteger& aIndexMap,
     Standard_Integer aSubShapeId = aMapOfShapes.FindIndex( aSubShape );
     if ( !aSubShapeId || !aIndexMap.Contains( aSubShapeId ) )
       continue;
-    
+
     if ( !aToHiliteMap.Contains( anOwner ) )
       aToHiliteMap.Add( anOwner );
   }
 }
 
-GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
+GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape&    shape,
                              const Standard_CString aName)
-  : SALOME_AISShape(shape), myName(aName), myDisplayVectors(false)
+  : SALOME_AISShape(shape),
+    myName(aName),
+    myDisplayVectors(false),
+    myDisplayVertices(false),
+    myFieldDataType(GEOM::FDT_Double),
+    myFieldDimension(0),
+    myFieldStepRangeMin(0),
+    myFieldStepRangeMax(0)
 {
+  //rnv: Commented to avoid bug with local selection
+  //SetHilightMode( CustomHighlight ); // override setting the mode to 0 inside AIS_Shape constructor
+
   myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
   myPrevDisplayMode = 0;
-  storeBoundaryColors();
-
 
   myEdgesInShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
 
-  myUIsoNumber = -1;
-  myVIsoNumber = -1;
-
   myTopLevel = Standard_False;
   Graphic3d_MaterialAspect aMatAspect;
   if ( !HasMaterial() ) {
-        aMatAspect.SetAmbient( 0.5 );
-        aMatAspect.SetDiffuse( 0.5 );
-        aMatAspect.SetEmissive( 0.5 );
-        aMatAspect.SetShininess(0.5 );
-        aMatAspect.SetSpecular( 0.5 );
-        
-        myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
-        myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect);
+    aMatAspect.SetAmbient( 0.5 );
+    aMatAspect.SetDiffuse( 0.5 );
+    aMatAspect.SetEmissive( 0.5 );
+    aMatAspect.SetShininess(0.5 );
+    aMatAspect.SetSpecular( 0.5 );
+
+    myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
+    myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect);
   }
 }
 
-void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){
+GEOM_AISShape::~GEOM_AISShape()
+{
+}
+
+void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io)
+{
   SetOwner( io );
 }
 
-Handle(SALOME_InteractiveObject) GEOM_AISShape::getIO(){
+Handle(SALOME_InteractiveObject) GEOM_AISShape::getIO()
+{
   Handle(SALOME_InteractiveObject) IO;
   if ( !GetOwner().IsNull() )
     IO = Handle(SALOME_InteractiveObject)::DownCast( GetOwner() );
   return IO;
 }
 
-Standard_Boolean GEOM_AISShape::hasIO(){
+Standard_Boolean GEOM_AISShape::hasIO()
+{
   return !getIO().IsNull();
 }
 
@@ -192,81 +201,83 @@ void GEOM_AISShape::setName(const Standard_CString aName)
     IO->setName(aName);
 }
 
-Standard_CString GEOM_AISShape::getName(){
+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)
-{  
+                            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();
+  // AKL: use old behavior to avoid keeping object's wireframe
+  //      if to change shape properties (for example: 'Clear Top Level State','Color', 'Isos') 
+  //      calling popup menu over(!) the shape in OCC viewer.
+  anIC->SetToHilightSelected( false );
+
+  bool anIsField = !myFieldStepData.isEmpty();
+  bool anIsColorField = anIsField && myFieldDataType != GEOM::FDT_String;
+  bool anIsTextField = anIsField && myFieldDataType == GEOM::FDT_String;
+
+  if (isShowVertices())
+    myDrawer->SetVertexDrawMode(Prs3d_VDM_All);
+
   //   StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode;
   bool isTopLev = isTopLevel() && switchTopLevel();
   switch (aMode) {
-    case 0://StdSelect_DM_Wireframe: 
+    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:
     {
-      restoreIsoNumbers();
-      // Restore wireframe edges colors
-      restoreBoundaryColors();
       if(isTopLev) {
               SetColor(topLevelColor());
               Handle(Prs3d_LineAspect) anAspect = Attributes()->WireAspect();
               anAspect->SetColor( topLevelColor() );
               Attributes()->SetWireAspect( anAspect );
       }
-     StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);      
+      if( !isTopLev && anIsColorField && myFieldDimension == 1 )
+        drawField( aPrs, false, aMode == CustomHighlight );
+      else
+        StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
       break;
     }
-    case 1://StdSelect_DM_Shading:
+    case Shading:
     {
-      restoreIsoNumbers();
       shadingMode(aPresentationManager, aPrs, aMode);
-      // Store wireframe edges colors
-      storeBoundaryColors();
       break;
     }
-    case 3: //StdSelect_DM_HLR:
+    case ShadingWithEdges:
     {
-      if(!isTopLev)
-              AIS_TexturedShape::Compute(aPresentationManager, aPrs, aMode);
-      else 
-              shadingMode(aPresentationManager, aPrs, AIS_Shaded);
+      myDrawer->SetFaceBoundaryDraw( Standard_True );
+      shadingMode(aPresentationManager, aPrs, Shading);
+      if( anIsColorField && myFieldDimension == 1 ) {
+        myDrawer->SetFaceBoundaryDraw( Standard_False );
+        drawField( aPrs );
+      }
+      break;
+    }
+    case TexturedShape:
+    {
+      shadingMode(aPresentationManager, aPrs, Shading);
       break;
     }
   }
-
-  if ( aMode == ShadingWithEdges ) {
-    // Temporary store number of iso lines in order to recover its later 
-    // when display mode is achnged to 'Wirefame' or 'Shading'.
-    // Iso lines are not displayed in 'Shading with edges' mode.
-    storeIsoNumbers();
-
-    // Reset number of iso lines to 0
-    resetIsoNumbers();
-
-    //Shaded faces
-    shadingMode(aPresentationManager, aPrs, AIS_Shaded);
-
-    // Store wireframe edges colors
-    storeBoundaryColors();
-
-    // Coloring edges
-    Handle(Prs3d_LineAspect) anAspect = myDrawer->UnFreeBoundaryAspect();
-    anAspect->SetColor( myEdgesInShadingColor );
-    myDrawer->SetUnFreeBoundaryAspect( anAspect );
-    
-    anAspect = myDrawer->FreeBoundaryAspect();
-    anAspect->SetColor( myEdgesInShadingColor );
-    myDrawer->SetFreeBoundaryAspect( anAspect );
-
-    // Add edges to presentation
-    StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
-  }
-
   if (isShowVectors())
   {
     const bool isVector = IsKind(STANDARD_TYPE(GEOM_AISVector));
@@ -312,6 +323,18 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent
       }
     }
   }
+
+  // draw color field on vertices
+  if( anIsColorField && myFieldDimension == 0 && aMode != CustomHighlight )
+    drawField( aPrs );
+
+  // draw text field
+  if( anIsTextField )
+    drawField( aPrs, true );
+
+  if( isShowName() )
+    drawName( aPrs );
+
   //  aPrs->ReCompute(); // for hidden line recomputation if necessary...
 }
 
@@ -325,8 +348,13 @@ void GEOM_AISShape::SetEdgesInShadingColor(const Quantity_Color &aCol)
   myEdgesInShadingColor = aCol;
 }
 
+void GEOM_AISShape::SetLabelColor(const Quantity_Color &aCol)
+{
+  myLabelColor = aCol;
+}
+
 void GEOM_AISShape::highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, 
-                                       const Standard_Boolean aHighlight )
+                                       const Standard_Boolean             aHighlight )
 {
   Handle(AIS_InteractiveObject) anObj = this;
   Handle(AIS_InteractiveContext) anIC = GetContext();
@@ -361,9 +389,19 @@ void GEOM_AISShape::SetDisplayVectors(bool isDisplayed)
   myDisplayVectors = isDisplayed;
 }
 
+void GEOM_AISShape::SetDisplayVertices(bool isDisplayed)
+{
+  myDisplayVertices = isDisplayed;
+}
+
+void GEOM_AISShape::SetDisplayName(bool isDisplayed)
+{
+  myDisplayName = isDisplayed;
+}
+
 void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
-                                const Handle(Prs3d_Presentation)& aPrs,
-                                const Standard_Integer aMode)
+                                const Handle(Prs3d_Presentation)&           aPrs,
+                                const Standard_Integer                      aMode)
 {
   myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn();
 
@@ -376,87 +414,42 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre
 
   if( isTopLevel() && switchTopLevel() )
     myDrawer->ShadingAspect()->SetColor( topLevelColor() );
-  else { 
+  else {
     if(myDrawer->ShadingAspect()->Aspect()->FrontMaterial().MaterialType( Graphic3d_MATERIAL_ASPECT ))
       myDrawer->ShadingAspect()->SetColor(myShadingColor);
     else
       myDrawer->ShadingAspect()->SetColor(myDrawer->ShadingAspect()->Aspect()->FrontMaterial().AmbientColor());
   }
 
-  // PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces
-  //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
-  AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
-}
-
-void GEOM_AISShape::storeIsoNumbers()
-{
-  myUIsoNumber = myDrawer->UIsoAspect()->Number();
-  myVIsoNumber = myDrawer->VIsoAspect()->Number();
-}
-
-void GEOM_AISShape::restoreIsoNumbers()
-{
-  if ( myUIsoNumber > 0 ) {
-    // Restore number of U iso lines
-    Handle(Prs3d_IsoAspect) anAspect = myDrawer->UIsoAspect();
-    anAspect->SetNumber( myUIsoNumber );
-    myDrawer->SetUIsoAspect( anAspect );
+  bool anIsColorField = !myFieldStepData.isEmpty() && myFieldDataType != GEOM::FDT_String;
+  if( anIsColorField && ( myFieldDimension == 2 || myFieldDimension == 3 || myFieldDimension == -1 ) )
+  {
+    drawField( aPrs );
   }
-  
-  if ( myVIsoNumber > 0 ) {
-    // Restore number of V iso lines
-    Handle(Prs3d_IsoAspect) anAspect = myDrawer->VIsoAspect();
-    anAspect->SetNumber( myVIsoNumber );
-    myDrawer->SetVIsoAspect( anAspect );
+  else
+  {
+    // PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces
+    //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
+    SALOME_AISShape::Compute(aPresentationManager, aPrs, aMode);
   }
 }
 
-void GEOM_AISShape::resetIsoNumbers()
+Standard_Boolean GEOM_AISShape::isTopLevel()
 {
-  Handle(Prs3d_IsoAspect) anAspect = myDrawer->UIsoAspect();
-  anAspect->SetNumber( 0 );
-  myDrawer->SetUIsoAspect( anAspect );
-  
-  anAspect = myDrawer->VIsoAspect();
-  anAspect->SetNumber( 0 );
-  myDrawer->SetVIsoAspect( anAspect );
-}
-
-void GEOM_AISShape::storeBoundaryColors()
-{
-  Aspect_TypeOfLine aLT;
-  Standard_Real aW;
-
-  myDrawer->FreeBoundaryAspect()->Aspect()->Values( myFreeBoundaryColor, aLT, aW);
-  myDrawer->UnFreeBoundaryAspect()->Aspect()->Values( myUnFreeBoundaryColor, aLT, aW);
-}
-void GEOM_AISShape::restoreBoundaryColors()
-{
-  Handle(Prs3d_LineAspect) anAspect = myDrawer->FreeBoundaryAspect();
-  anAspect->SetColor( myFreeBoundaryColor );
-  myDrawer->SetFreeBoundaryAspect( anAspect );
-
-  anAspect = myDrawer->UnFreeBoundaryAspect();
-  anAspect->SetColor( myUnFreeBoundaryColor );
-  myDrawer->SetUnFreeBoundaryAspect( anAspect );
-}
-
-
-Standard_Boolean GEOM_AISShape::isTopLevel() {
   return myTopLevel;
 }
 
-void GEOM_AISShape::setTopLevel(Standard_Boolean f) {
+void GEOM_AISShape::setTopLevel(Standard_Boolean f)
+{
   if(f) {
     if(f != myTopLevel)
       myPrevDisplayMode = DisplayMode();
     Standard_Integer dm;
     switch(topLevelDisplayMode()) {
-      case TopKeepCurrent : dm = myPrevDisplayMode; break;
-      case TopWireFrame : dm = AIS_WireFrame; break;     
-      case TopShadingWithEdges : dm = ShadingWithEdges; break;
-      default : dm = AIS_Shaded; break;
+      case TopWireFrame :        dm = Wireframe;         break;
+      case TopShading :          dm = Shading;           break;
+      case TopShadingWithEdges : dm = ShadingWithEdges;  break;
+      default :                  dm = myPrevDisplayMode; break;
     }
     SetDisplayMode(dm);
   } else {
@@ -466,29 +459,279 @@ void GEOM_AISShape::setTopLevel(Standard_Boolean f) {
   myTopLevel = f;
 }
 
-void GEOM_AISShape::setPrevDisplayMode(const Standard_Integer mode) {
+void GEOM_AISShape::setPrevDisplayMode(const Standard_Integer mode)
+{
   myPrevDisplayMode = mode;
 }
 
-Quantity_Color GEOM_AISShape::topLevelColor() {
+Quantity_Color GEOM_AISShape::topLevelColor()
+{
   return myTopLevelColor;
 }
 
-void GEOM_AISShape::setTopLevelColor(const Quantity_Color c) {
+void GEOM_AISShape::setTopLevelColor(const Quantity_Color c)
+{
   myTopLevelColor = c;
 }
 
-GEOM_AISShape::TopLevelDispMode GEOM_AISShape::topLevelDisplayMode() {
+GEOM_AISShape::TopLevelDispMode GEOM_AISShape::topLevelDisplayMode()
+{
   return myTopLevelDm;
 }
-void GEOM_AISShape::setTopLevelDisplayMode(const GEOM_AISShape::TopLevelDispMode dm) {
+
+void GEOM_AISShape::setTopLevelDisplayMode(const GEOM_AISShape::TopLevelDispMode dm)
+{
   myTopLevelDm = dm;
 }
 
-Standard_Boolean GEOM_AISShape::switchTopLevel() {
-        return myTopLevelDm != TopShowAdditionalWActor;
+Standard_Boolean GEOM_AISShape::switchTopLevel()
+{
+  return myTopLevelDm != TopShowAdditionalWActor;
+}
+
+Standard_Boolean GEOM_AISShape::toActivate()
+{
+  return ( myTopLevel && myTopLevelDm == TopShowAdditionalWActor ) ? false : true;
 }
 
-Standard_Boolean GEOM_AISShape::toActivate() {
-        return Standard_True;
+void GEOM_AISShape::setFieldStepInfo( const GEOM::field_data_type    theFieldDataType,
+                                      const int                      theFieldDimension,
+                                      const QList<QVariant>&         theFieldStepData,
+                                      const TCollection_AsciiString& theFieldStepName,
+                                      const double                   theFieldStepRangeMin,
+                                      const double                   theFieldStepRangeMax )
+{
+  myFieldDataType     = theFieldDataType;
+  myFieldDimension    = theFieldDimension;
+  myFieldStepData     = theFieldStepData;
+  myFieldStepName     = theFieldStepName;
+  myFieldStepRangeMin = theFieldStepRangeMin;
+  myFieldStepRangeMax = theFieldStepRangeMax;
+}
+
+void GEOM_AISShape::getFieldStepInfo( GEOM::field_data_type&   theFieldDataType,
+                                      int&                     theFieldDimension,
+                                      QList<QVariant>&         theFieldStepData,
+                                      TCollection_AsciiString& theFieldStepName,
+                                      double&                  theFieldStepRangeMin,
+                                      double&                  theFieldStepRangeMax ) const
+{
+  theFieldDataType     = myFieldDataType;
+  theFieldDimension    = myFieldDimension;
+  theFieldStepData     = myFieldStepData;
+  theFieldStepName     = myFieldStepName;
+  theFieldStepRangeMin = myFieldStepRangeMin;
+  theFieldStepRangeMax = myFieldStepRangeMax;
+}
+
+void GEOM_AISShape::drawField( const Handle(Prs3d_Presentation)& thePrs,
+                               const bool                        theIsString,
+                               const bool                        theIsHighlight )
+{
+  if( myFieldStepData.isEmpty() )
+    return;
+
+  QListIterator<QVariant> aFieldStepDataIter( myFieldStepData );
+
+  TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
+  switch( myFieldDimension )
+  {
+    case 0:  aShapeType = TopAbs_VERTEX; break;
+    case 1:  aShapeType = TopAbs_EDGE; break;
+    case 2:  aShapeType = TopAbs_FACE; break;
+    case 3:  aShapeType = TopAbs_SOLID; break;
+    case -1: aShapeType = TopAbs_VERTEX; break;
+  }
+
+  TopTools_IndexedMapOfShape aShapeMap;
+  TopExp::MapShapes( myshape, aShapeMap );
+
+  TColStd_IndexedMapOfInteger anIndexMap;
+
+  TopExp_Explorer anExp;
+  for( anExp.Init( myshape, aShapeType ); anExp.More(); anExp.Next() )
+  {
+    TopoDS_Shape aSubShape = anExp.Current();
+    if( !aSubShape.IsNull() )
+    {
+      Standard_Integer aSubShapeIndex = aShapeMap.FindIndex( aSubShape );
+      if( anIndexMap.Contains( aSubShapeIndex ) )
+        continue;
+
+      anIndexMap.Add( aSubShapeIndex );
+
+      Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup( thePrs );
+
+      QColor aQColor;
+      QString aString;
+      if( aFieldStepDataIter.hasNext() )
+      {
+        const QVariant& aVariant = aFieldStepDataIter.next();
+        if( theIsString )
+          aString = aVariant.toString();
+        else
+          aQColor = aVariant.value<QColor>();
+      }
+      else
+        break;
+
+      if( theIsString )
+      {
+        gp_Pnt aCenter;
+        if( computeMassCenter( aSubShape, aCenter ) )
+        {
+          Graphic3d_Vertex aVertex( aCenter.X(), aCenter.Y(), aCenter.Z() );
+
+          Handle(Graphic3d_AspectText3d) anAspectText3d = new Graphic3d_AspectText3d();
+          anAspectText3d->SetStyle( Aspect_TOST_ANNOTATION );
+          anAspectText3d->SetColor( myLabelColor );
+          aGroup->SetPrimitivesAspect( anAspectText3d );
+
+          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 );
+          if( !aVertexShape.IsNull() )
+          {
+            gp_Pnt aPnt = BRep_Tool::Pnt( aVertexShape );
+
+            Handle(Graphic3d_AspectMarker3d) anAspectMarker3d = new Graphic3d_AspectMarker3d();
+            anAspectMarker3d->SetColor( aColor );
+            anAspectMarker3d->SetType( Aspect_TOM_POINT );
+            anAspectMarker3d->SetScale( 10.0 );
+            aGroup->SetPrimitivesAspect( anAspectMarker3d );
+
+            Handle(Graphic3d_ArrayOfPoints) anArray = new Graphic3d_ArrayOfPoints( 1 );
+            anArray->AddVertex( aPnt.X(), aPnt.Y(), aPnt.Z() );
+
+            aGroup->AddPrimitiveArray( anArray );
+          }
+        }
+        else if( myFieldDimension == 1 )
+        {
+          myDrawer->WireAspect()->SetColor( aColor );
+          if( theIsHighlight )
+            myDrawer->WireAspect()->SetWidth( myOwnWidth );
+          else
+            myDrawer->WireAspect()->SetWidth( myOwnWidth + 4 );
+          /*
+          StdPrs_WFShape::Add( thePrs, aSubShape, myDrawer );
+          */
+        }
+        else if( myFieldDimension == 2 ||
+                 myFieldDimension == 3 ||
+                 myFieldDimension == -1 )
+        {
+          //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 )
+{
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup( thePrs );
+
+  gp_Ax3 anAx3 = GEOMUtils::GetPosition(myshape);
+  gp_Pnt aCenter = anAx3.Location();
+
+  Graphic3d_Vertex aVertex( aCenter.X(), aCenter.Y(), aCenter.Z() );
+
+  Handle(Graphic3d_AspectText3d) anAspectText3d = new Graphic3d_AspectText3d();
+  anAspectText3d->SetStyle( Aspect_TOST_ANNOTATION );
+  anAspectText3d->SetColor( myLabelColor );
+  aGroup->SetPrimitivesAspect( anAspectText3d );
+
+  const char* aName = getIO()->getName();
+  aGroup->Text( TCollection_ExtendedString( aName ), aVertex, 16 );
+}
+
+Standard_Boolean GEOM_AISShape::computeMassCenter( const TopoDS_Shape& theShape,
+                                                   gp_Pnt&             theCenter )
+{
+  theCenter.SetCoord( 0,0,0 );
+  Standard_Integer aNbPoints = 0;
+
+  if ( theShape.ShapeType() == TopAbs_EDGE )
+  {
+    double f,l;
+    Handle(Geom_Curve) curve = BRep_Tool::Curve( TopoDS::Edge( theShape ), f, l );
+    if ( !curve.IsNull() )
+    {
+      theCenter = curve->Value( 0.5 * ( f + l ));
+      aNbPoints = 1;
+    }
+  }
+  else if ( theShape.ShapeType() == TopAbs_FACE )
+  {
+    const TopoDS_Face& F = TopoDS::Face( theShape );
+    BRepAdaptor_Surface surface( F );
+
+    TopLoc_Location L;
+    Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation( F, L );
+    if ( !triangulation.IsNull() && triangulation->HasUVNodes() )
+    {
+      gp_XY C( 0, 0 );
+      double A = 0;
+      const TColgp_Array1OfPnt2d& uvArray = triangulation->UVNodes();
+      const Poly_Array1OfTriangle&  trias = triangulation->Triangles();
+      Standard_Integer n1,n2,n3;
+      for ( int iT = trias.Lower(); iT <= trias.Upper(); ++iT )
+      {
+        trias( iT ).Get( n1,n2,n3 );
+        const gp_Pnt2d& uv1 = uvArray( n1 );
+        const gp_Pnt2d& uv2 = uvArray( n2 );
+        const gp_Pnt2d& uv3 = uvArray( n3 );
+        double a = 0.5 * sqrt(( uv1.X() - uv3.X() ) * ( uv2.Y() - uv1.Y() ) -
+                              ( uv1.X() - uv2.X() ) * ( uv3.Y() - uv1.Y() ));
+        C += ( uv1.XY() + uv2.XY() + uv3.XY() ) / 3. * a;
+        A += a;
+      }
+      if ( A > std::numeric_limits<double>::min() )
+      {
+        C /= A;
+        theCenter = surface.Value( C.X(), C.Y() );
+        aNbPoints = 1;
+      }
+    }
+    if ( aNbPoints == 0 )
+    {
+      theCenter = surface.Value( 0.5 * ( surface.FirstUParameter() + surface.LastUParameter() ),
+                                 0.5 * ( surface.FirstVParameter() + surface.LastVParameter() ));
+    }
+    aNbPoints = 1;
+  }
+
+  if ( aNbPoints == 0 )
+  {
+    TopExp_Explorer anExp;
+    for( anExp.Init( theShape, TopAbs_VERTEX ); anExp.More(); anExp.Next() )
+    {
+      TopoDS_Vertex aVertex = TopoDS::Vertex( anExp.Current() );
+      if( !aVertex.IsNull() )
+      {
+        gp_Pnt aPnt = BRep_Tool::Pnt( aVertex );
+        theCenter.ChangeCoord() += aPnt.XYZ();
+        aNbPoints++;
+      }
+    }
+  }
+
+  if ( aNbPoints > 0 )
+    theCenter.ChangeCoord() /= (Standard_Real) aNbPoints;
+
+  return aNbPoints;
 }