Salome HOME
Fix for bug PAL10393 ( Set MED2.2 as the default version in the export to med dialog...
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.cxx
index 17f9fdc9b691bac480600eaf4e2a580d46e54023..4b966ce5981016e3d65165797a20a3bca284a2d6 100644 (file)
@@ -95,8 +95,7 @@
 #include <SVTK_ViewModel.h>
 #include <SVTK_InteractorStyle.h>
 #include <SVTK_RenderWindowInteractor.h>
-
-#include <VTKViewer_ViewManager.h>
+#include <SVTK_ViewManager.h>
 
 #include "OB_Browser.h"
 
@@ -301,6 +300,7 @@ namespace{
            SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
            fd->setCaption( aTitle );
            fd->setFilters( filters );
+           fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
            bool is_ok = false;
            while(!is_ok){
              fd->exec();
@@ -583,6 +583,10 @@ namespace{
            aTitle = QObject::tr( "SKEW_ELEMENTS" );
            aControl = SMESH_Actor::eSkew;
            break;
+         case 6009:
+           aTitle = QObject::tr( "VOLUME_3D_ELEMENTS" );
+           aControl = SMESH_Actor::eVolume3D;
+           break;
          }
          anActor->SetControlMode(aControl);
          anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
@@ -664,7 +668,7 @@ namespace{
   {
     // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
     SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
-    SALOME_ListIO selected; aSel->selectedObjects( selected );
+    SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
 
     QString aParentComponent = QString::null;
     for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
@@ -805,8 +809,8 @@ SalomeApp_Module( "SMESH" )
     myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
   }
 
-  myActiveDialogBox = 0 ;
-  myState = -1 ;
+  myActiveDialogBox = 0;
+  myState = -1;
   myDisplayer = 0;
 
   SMESH::GetFilterManager();
@@ -1059,6 +1063,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   if( !mgr )
     return false;
 
+  if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
+    GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
+  }
+
   SUIT_ViewWindow* view = application()->desktop()->activeWindow();
   SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
 
@@ -1182,11 +1190,11 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
                         comp = SC->ComponentDataType().c_str(),
                        val = valSO->GetName().c_str();
 
-               Handle( SALOME_InteractiveObject ) new_obj = 
+               Handle( SALOME_InteractiveObject ) new_obj =
                  new SALOME_InteractiveObject( id.latin1(), comp.latin1(), val.latin1() );
                to_process.Append( new_obj );
              }
-             anIter->Next();       
+             anIter->Next();
            }
            continue;
          }
@@ -1822,7 +1830,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
       SALOME_ListIO selected;
       if( aSel )
-        aSel->selectedObjects( selected );
+        aSel->selectedObjects( selected, QString::null, false );
 
       SALOME_ListIteratorOfListIO It(selected);
       for (int i = 0; It.More(); It.Next(), i++) {
@@ -2058,6 +2066,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case 6002:
   case 6003:
   case 6004:
+  case 6009:
     if ( vtkwnd ) {
 
       SalomeApp_SelectionMgr* mgr = selectionMgr();
@@ -2279,6 +2288,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction( 6017, "ASPECT_3D",       "ICON_ASPECT_3D",     0, true );
   createSMESHAction( 6018, "LENGTH_2D",       "ICON_LENGTH_2D",     0, true );
   createSMESHAction( 6019, "CONNECTION_2D",   "ICON_CONNECTION_2D", 0, true );
+  createSMESHAction( 6009, "VOLUME_3D",       "ICON_VOLUME_3D",     0, true );
   createSMESHAction(  400, "NODE",            "ICON_DLG_NODE" );
   createSMESHAction(  401, "EDGE",            "ICON_DLG_EDGE" );
   createSMESHAction( 4021, "TRIANGLE",        "ICON_DLG_TRIANGLE" );
@@ -2402,6 +2412,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( 6016, ctrlId, -1 );
   createMenu( separator(), ctrlId, -1 );
   createMenu( 6017, ctrlId, -1 );
+  createMenu( 6009, ctrlId, -1 );
   createMenu( separator(), ctrlId, -1 );
 
   createMenu( 400, addId, -1 );
@@ -2476,6 +2487,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( 6016, ctrlTb );
   createTool( separator(), ctrlTb );
   createTool( 6017, ctrlTb );
+  createTool( 6009, ctrlTb );
   createTool( separator(), ctrlTb );
 
   createTool( 400, addRemTb );
@@ -2740,6 +2752,10 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
   popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
 
+  popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
+  popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
+  popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
+
   popupMgr()->insert( separator(), anId, -1 );
 
   popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
@@ -2751,11 +2767,11 @@ void SMESHGUI::initialize( CAM_Application* app )
   // Display / Erase
   //-------------------------------------------------
   aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
-  QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
+  QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
   QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
 
-  QString aRule = "type='Component' or (" + aClient + " and " + aType + " and " + aSelCount +
-     " and " + anActiveVTK + " and " + isNotEmpty + " %1 )";
+  QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
+    aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
   popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
   popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
 
@@ -2767,8 +2783,8 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   popupMgr()->insert( separator(), -1, -1 );
 
-  connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
-          this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
+  connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
+          this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
 }
 
 bool SMESHGUI::activateModule( SUIT_Study* study )
@@ -2836,9 +2852,9 @@ void SMESHGUI::viewManagers( QStringList& list ) const
   list.append( SVTK_Viewer::Type() );
 }
 
-void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
+void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
 {
-  if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
+  if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
     SMESH::UpdateSelectionProp( this );
 }
 
@@ -3007,6 +3023,11 @@ void SMESHGUI::createPreferences()
 
 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
 {
+  if( sect=="SMESH" )
+    if( name=="selection_object_color" || name=="selection_element_color" || 
+        name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
+        name=="selection_precision_node" || name=="selection_precision_element" )
+      SMESH::UpdateSelectionProp( this );
 }
 
 //================================================================================