Salome HOME
Update the "Colors / Size" dialog.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.cxx
index 30773a389553e208ea5f6fe2670173383c861e81..a3a601a831b81859f51529fb251f0ca797e347cb 100644 (file)
       type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
     else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
       type = QObject::tr( "OVER_CONSTRAINED_FACE" );
+    else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
+      type = QObject::tr( "EQUAL_NODE" );
+    else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
+      type = QObject::tr( "EQUAL_EDGE" );
+    else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
+      type = QObject::tr( "EQUAL_FACE" );
+    else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
+      type = QObject::tr( "EQUAL_VOLUME" );
     return type;
   }
 
       Handle(SALOME_InteractiveObject) anIO = selected.First();
       if(!anIO.IsNull()){
         SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
-        if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
+        if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
           switch ( theCommandID ){
           case 6001:
             aControl = SMESH_Actor::eLength;
           case 6027:
             aControl = SMESH_Actor::eOverConstrainedFace;
             break;
+          case 6028:
+            aControl = SMESH_Actor::eCoincidentNodes;
+            break;
+          case 6029:
+            aControl = SMESH_Actor::eCoincidentElems1D;
+            break;
+          case 6030:
+            aControl = SMESH_Actor:: eCoincidentElems2D;
+            break;
+          case 6031:
+            aControl = SMESH_Actor::eCoincidentElems3D;
+            break;
           }
+            
           anActor->SetControlMode(aControl);
           anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
           SMESH::RepaintCurrentView();
@@ -1692,6 +1713,14 @@ LightApp_Module( "SMESH" )
     myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
     nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
     myComponentSMESH->SetDefaultNbSegments( nbSeg );
+
+    const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
+    for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
+      if ( aResourceMgr->hasValue( "SMESH", options[i] ))
+      {
+        QString val = aResourceMgr->stringValue( "SMESH", options[i] );
+        myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
+      }
   }
 
   myActiveDialogBox = 0;
@@ -2116,7 +2145,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
 
   case 1134: // Clipping
   case 1133: // Tranparency
-  case 1132: // Colors / Size
+  case 1132: // Display preferences (colors, shrink size, line width, ...)
 
     // Display Mode
   case 215: // Nodes
@@ -3187,6 +3216,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case 6025:
   case 6026:
   case 6027:
+  case 6028:
+  case 6029:
+  case 6030:
+  case 6031:
     if ( vtkwnd ) {
 
       LightApp_SelectionMgr* mgr = selectionMgr();
@@ -3434,12 +3467,16 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction( 6001, "LENGTH",          "ICON_LENGTH",        0, true );
   createSMESHAction( 6002, "FREE_EDGE",       "ICON_FREE_EDGE",     0, true );
   createSMESHAction( 6021, "FREE_FACES",      "ICON_FREE_FACES",    0, true );
-  createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
-  createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
-  createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
-  createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
+  createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D",  "ICON_MAX_ELEMENT_LENGTH_2D",   0, true );
+  createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D",  "ICON_MAX_ELEMENT_LENGTH_3D",   0, true );
+  createSMESHAction( 6024, "BARE_BORDER_VOLUME",     "ICON_BARE_BORDER_VOLUME",      0, true );
+  createSMESHAction( 6025, "BARE_BORDER_FACE",       "ICON_BARE_BORDER_FACE",        0, true );
   createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
-  createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
+  createSMESHAction( 6027, "OVER_CONSTRAINED_FACE",  "ICON_OVER_CONSTRAINED_FACE",   0, true );
+  createSMESHAction( 6028, "EQUAL_NODE",      "ICON_EQUAL_NODE",    0, true );
+  createSMESHAction( 6029, "EQUAL_EDGE",      "ICON_EQUAL_EDGE",    0, true );
+  createSMESHAction( 6030, "EQUAL_FACE",      "ICON_EQUAL_FACE",    0, true );
+  createSMESHAction( 6031, "EQUAL_VOLUME",    "ICON_EQUAL_VOLUME",  0, true );
   createSMESHAction( 6003, "FREE_BORDER",     "ICON_FREE_EDGE_2D",  0, true );
   createSMESHAction( 6004, "CONNECTION",      "ICON_CONNECTION",    0, true );
   createSMESHAction( 6005, "FREE_NODE",       "ICON_FREE_NODE",     0, true );
@@ -3619,10 +3656,12 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( separator(), meshId, -1 );
 
   createMenu( 6005, nodeId, -1 );
+  createMenu( 6028, nodeId, -1 );
   createMenu( 6002, edgeId, -1 );
   createMenu( 6003, edgeId, -1 );
   createMenu( 6001, edgeId, -1 );
   createMenu( 6004, edgeId, -1 );
+  createMenu( 6029, edgeId, -1 );
   createMenu( 6021, faceId, -1 );
   createMenu( 6025, faceId, -1 );
   createMenu( 6027, faceId, -1 );
@@ -3635,11 +3674,13 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( 6015, faceId, -1 );
   createMenu( 6016, faceId, -1 );
   createMenu( 6022, faceId, -1 );
+  createMenu( 6030, faceId, -1 );
   createMenu( 6017, volumeId, -1 );
   createMenu( 6009, volumeId, -1 );
   createMenu( 6023, volumeId, -1 );
   createMenu( 6024, volumeId, -1 );
   createMenu( 6026, volumeId, -1 );
+  createMenu( 6031, volumeId, -1 );
 
   createMenu( 4000, addId, -1 );
   createMenu( 4009, addId, -1 );
@@ -3734,11 +3775,13 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( separator(), meshTb );
 
   createTool( 6005, ctrlTb );
+  createTool( 6028, ctrlTb );
   createTool( separator(), ctrlTb );
   createTool( 6002, ctrlTb );
   createTool( 6003, ctrlTb );
   createTool( 6001, ctrlTb );
   createTool( 6004, ctrlTb );
+  createTool( 6029, ctrlTb );
   createTool( separator(), ctrlTb );
   createTool( 6021, ctrlTb );
   createTool( 6025, ctrlTb );
@@ -3752,12 +3795,14 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( 6015, ctrlTb );
   createTool( 6016, ctrlTb );
   createTool( 6022, ctrlTb );
+  createTool( 6030, ctrlTb );
   createTool( separator(), ctrlTb );
   createTool( 6017, ctrlTb );
   createTool( 6009, ctrlTb );
   createTool( 6023, ctrlTb );
   createTool( 6024, ctrlTb );
   createTool( 6026, ctrlTb );
+  createTool( 6031, ctrlTb );
   createTool( separator(), ctrlTb );
 
   createTool( 4000, addRemTb );
@@ -4045,6 +4090,10 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
   popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
 
+  popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
+  popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
+  popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
+
   aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
 
   popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
@@ -4062,6 +4111,9 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
   popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
   popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
+  popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
+  popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
+  popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
 
   aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
 
@@ -4113,6 +4165,9 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
   popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
   popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
+  popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
+  popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
+  popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
 
   aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
 
@@ -4136,6 +4191,10 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
   popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
 
+  popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
+  popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
+  popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
+
   popupMgr()->insert( separator(), anId, -1 );
 
   popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
@@ -4435,6 +4494,11 @@ void SMESHGUI::createPreferences()
   int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
   setPreferenceProperty( prec, "min", 0 );
   setPreferenceProperty( prec, "max", 16 );
+  int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
+  setPreferenceProperty( doubleNodesTol, "precision", 10 );
+  setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
+  setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
+  setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
 
   int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
   setPreferenceProperty( dispgroup, "columns", 2 );
@@ -4518,6 +4582,11 @@ void SMESHGUI::createPreferences()
   setPreferenceProperty( nbSeg, "min", 1 );
   setPreferenceProperty( nbSeg, "max", 10000000 );
 
+  int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
+  addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
+                 "SMESH", "forget_mesh_on_hyp_modif" );
+
+
   // Quantities with individual precision settings
   int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
   setPreferenceProperty( precGroup, "columns", 2 );
@@ -4551,6 +4620,9 @@ void SMESHGUI::createPreferences()
   setPreferenceProperty( chunkSize, "max",  1000 );
   setPreferenceProperty( chunkSize, "step", 50 );
 
+  int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
+  addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
+
   // Mesh tab ------------------------------------------------------------------------
   int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
   int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
@@ -4635,19 +4707,11 @@ void SMESHGUI::createPreferences()
 
   addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
   addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
-  int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
-
-  setPreferenceProperty( selW, "min", 1 );
-  setPreferenceProperty( selW, "max", 5 );
 
   int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
   setPreferenceProperty( preGroup, "columns", 2 );
 
   addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
-  int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
-
-  setPreferenceProperty( preW, "min", 1 );
-  setPreferenceProperty( preW, "max", 5 );
 
   int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
   setPreferenceProperty( precSelGroup, "columns", 2 );
@@ -4750,7 +4814,7 @@ void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
     std::string aWarning;
     SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
     if( name=="selection_object_color" || name=="selection_element_color" ||
-        name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
+        name=="highlight_color" ||
         name=="selection_precision_node" || name=="selection_precision_element" ||
         name=="selection_precision_object")
       SMESH::UpdateSelectionProp( this );
@@ -4804,6 +4868,11 @@ void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
       int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
       myComponentSMESH->SetDefaultNbSegments( nbSeg );
     }
+    else if ( name == "historical_python_dump" ||
+              name == "forget_mesh_on_hyp_modif") {
+      QString val = aResourceMgr->stringValue( "SMESH", name );
+      myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
+    }
 
     if(aWarning.size() != 0){
       aWarning += "The default values are applied instead.";