Salome HOME
Merge from V6_5_BR 05/06/2012
[modules/smesh.git] / src / OBJECT / SMESH_Actor.cxx
index b4f703c2fdd65429cfb59f28e0f52bec21e1fdd3..f46baed8c209f16c2f12169b01fbb0a9e4bf338f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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
@@ -203,6 +203,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   my3DActor->SetProperty(mySurfaceProp);
   my3DActor->SetBackfaceProperty(myBackSurfaceProp);
   my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
+  my3DActor->SetCoincident3DAllowed(true);
   aFilter = my3DActor->GetExtractUnstructuredGrid();
   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
   aFilter->RegisterCellsWithType(VTK_TETRA);
@@ -228,6 +229,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   my3DExtActor->SetProperty(my2DExtProp);
   my3DExtActor->SetBackfaceProperty(my2DExtProp);
   my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
+  my3DExtActor->SetCoincident3DAllowed(true);
   aFilter = my3DExtActor->GetExtractUnstructuredGrid();
   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
   aFilter->RegisterCellsWithType(VTK_TETRA);
@@ -376,7 +378,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   myBaseActor->SetStoreGemetryMapping(true);
   myBaseActor->GetProperty()->SetOpacity(0.0);
   myPickableActor = myBaseActor;
-
+  
   myHighlightProp = vtkProperty::New();
   myHighlightProp->SetAmbient(1.0);
   myHighlightProp->SetDiffuse(0.0);
@@ -384,6 +386,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
   myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
   myHighlightProp->SetPointSize(aElem0DSize); // ??
+  myHighlightProp->SetLineWidth(aLineWidth);
   myHighlightProp->SetRepresentation(1);
 
   myOutLineProp = vtkProperty::New();
@@ -393,6 +396,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
   myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
   myOutLineProp->SetPointSize(aElem0DSize); // ??
+  myOutLineProp->SetLineWidth(aLineWidth);
   myOutLineProp->SetRepresentation(1);
 
   myPreselectProp = vtkProperty::New();
@@ -402,12 +406,14 @@ SMESH_ActorDef::SMESH_ActorDef()
   SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
   myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
   myPreselectProp->SetPointSize(aElem0DSize); // ??
+  myPreselectProp->SetLineWidth(aLineWidth);
   myPreselectProp->SetRepresentation(1);
 
   myHighlitableActor = SMESH_DeviceActor::New();
   myHighlitableActor->SetUserMatrix(aMatrix);
   myHighlitableActor->PickableOff();
   myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
+  myHighlitableActor->SetCoincident3DAllowed(true);
 
   aMatrix->Delete();
 
@@ -486,9 +492,6 @@ SMESH_ActorDef::~SMESH_ActorDef()
   }
 #endif
 
-  // caught by SMESHGUI::ProcessEvents() static method
-  this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
-
   myScalarBarActor->Delete();
   myLookupTable->Delete();
 
@@ -532,6 +535,17 @@ SMESH_ActorDef::~SMESH_ActorDef()
   myTimeStamp->Delete();
 }
 
+void SMESH_ActorDef::Delete()
+{
+  // This is just to guarantee that the DeleteActorEvent (which was previously invoked
+  // from the actor's destructor) will be thrown before removing the actor's observers,
+  // that is done inside the Superclass::Delete() method but before the destructor itself
+  // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
+  // The event is caught by SMESHGUI::ProcessEvents() static method.
+  this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
+
+  Superclass::Delete();
+}
 
 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
 {    
@@ -691,6 +705,27 @@ SetControlMode(eControl theMode,
       myFunctor.reset(new SMESH::Controls::FreeFaces());
       myControlActor = my2DActor;
       break;
+    case eCoincidentNodes:
+      {
+        SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
+        double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
+        cn->SetTolerance( tol );
+        myFunctor.reset(cn);
+        myControlActor = myNodeActor;
+        break;
+      }
+    case eCoincidentElems1D:
+      myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
+      myControlActor = my1DActor;
+      break;
+    case eCoincidentElems2D:
+      myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
+      myControlActor = my2DActor;
+      break;
+    case eCoincidentElems3D:
+      myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
+      myControlActor = my3DActor;
+      break;
     case eBareBorderFace:
       myFunctor.reset(new SMESH::Controls::BareBorderFace());
       myControlActor = my2DActor;
@@ -809,19 +844,23 @@ SetControlMode(eControl theMode,
       myControlMode = theMode;
       switch(myControlMode){
       case eFreeNodes:
+      case eCoincidentNodes:
         myNodeExtActor->SetExtControlMode(myFunctor);
         break;
       case eFreeEdges:
       case eFreeBorders:
+      case eCoincidentElems1D:
         my1DExtActor->SetExtControlMode(myFunctor);
         break;
       case eFreeFaces:
       case eBareBorderFace:
       case eOverConstrainedFace:
+      case eCoincidentElems2D:
         my2DExtActor->SetExtControlMode(myFunctor);
         break;
       case eBareBorderVolume:
       case eOverConstrainedVolume:
+      case eCoincidentElems3D:
         my3DExtActor->SetExtControlMode(myFunctor);
         break;
       case eLength2D:
@@ -852,21 +891,21 @@ SetControlMode(eControl theMode,
           if (!myIsEntityModeCache){
             myEntityModeCache = GetEntityMode();
             myIsEntityModeCache=true;
-         } 
+          
           SetEntityMode(eFaces);
           break;
         default:
           if (!myIsEntityModeCache){
             myEntityModeCache = GetEntityMode();
             myIsEntityModeCache=true;
-         }
+          }
           SetEntityMode(eFaces);
         }
       }else if(myControlActor == my3DActor) {
         if (!myIsEntityModeCache){
             myEntityModeCache = GetEntityMode();
             myIsEntityModeCache=true;
-       } 
+        
         SetEntityMode(eVolumes);
     }
     }
@@ -1199,19 +1238,23 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
     if(myControlMode != eNone){
       switch(myControlMode){
       case eFreeNodes:
+      case eCoincidentNodes:
         myNodeExtActor->VisibilityOn();
         break;
       case eFreeEdges:
       case eFreeBorders:
+      case eCoincidentElems1D:
         my1DExtActor->VisibilityOn();
         break;
       case eFreeFaces:
       case eBareBorderFace:
       case eOverConstrainedFace:
+      case eCoincidentElems2D:
         my2DExtActor->VisibilityOn();
         break;
       case eBareBorderVolume:
       case eOverConstrainedVolume:
+      case eCoincidentElems3D:
         my3DExtActor->VisibilityOn();
         break;
       case eLength2D:
@@ -1784,8 +1827,11 @@ void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
   myEdgeProp->SetLineWidth(theVal);
 
   my1DProp->SetLineWidth(theVal + aLineWidthInc);
-  my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
-
+  my1DExtProp->SetLineWidth(theVal + aLineWidthInc);    
+  my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
+  myOutLineProp->SetLineWidth(theVal);
+  myHighlightProp->SetLineWidth(theVal);
+  myPreselectProp->SetLineWidth(theVal);
   Modified();
 }