Salome HOME
Default MED version for export is 2.3.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.cxx
index 9c0f854b2ebca43a6df121990bc13c2750e27e6c..996e6eef3358632bf381c39eb2f810a2935663a1 100644 (file)
@@ -182,8 +182,13 @@ using namespace std;
     }else if (theCommandID == 111){
       filter.append(QObject::tr("DAT files (*.dat)"));
     }
+
+    QString anInitialPath = "";
+    if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
+      anInitialPath = QDir::currentDirPath();
+
     QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
-                                                QDir::currentDirPath(),
+                                                anInitialPath,
                                                 filter,
                                                 QObject::tr("Import mesh"),
                                                 true);
@@ -207,9 +212,9 @@ using namespace std;
            if ( res != SMESH::DRS_OK ) {
              wc.suspend();
              SUIT_MessageBox::warn1(SMESHGUI::desktop(),
-                                   QObject::tr("SMESH_WRN_WARNING"),
-                                   QObject::tr(QString("SMESH_DRS_%1").arg(res)),
-                                   QObject::tr("SMESH_BUT_OK"));
+                                     QObject::tr("SMESH_WRN_WARNING"),
+                                     QObject::tr(QString("SMESH_DRS_%1").arg(res)),
+                                     QObject::tr("SMESH_BUT_OK"));
              aMeshes->length( 0 );
              wc.resume();
            }
@@ -233,9 +238,9 @@ using namespace std;
        if ( isEmpty ) {
          wc.suspend();
          SUIT_MessageBox::warn1(SMESHGUI::desktop(),
-                               QObject::tr("SMESH_WRN_WARNING"),
-                               QObject::tr("SMESH_DRS_EMPTY"),
-                               QObject::tr("SMESH_BUT_OK"));
+                                 QObject::tr("SMESH_WRN_WARNING"),
+                                 QObject::tr("SMESH_DRS_EMPTY"),
+                                 QObject::tr("SMESH_BUT_OK"));
          wc.resume();
        }
 
@@ -371,18 +376,23 @@ using namespace std;
          }
           delete fd;
        }
-       else {
+       else { // Export to MED
           QStringList filters;
+          QString aDefaultFilter;
           QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
-          for ( ; it != aFilterMap.end(); ++it )
+          for ( ; it != aFilterMap.end(); ++it ) {
             filters.push_back( it.key() );
+            if (it.data() == SMESH::MED_V2_2)
+              aDefaultFilter = it.key();
+          }
 
           //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
           SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
             ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
           fd->setCaption( aTitle );
           fd->setFilters( filters );
-          fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
+          //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
+          fd->setSelectedFilter(aDefaultFilter);
           fd->SetChecked(toCreateGroups);
           bool is_ok = false;
           while (!is_ok) {
@@ -3039,6 +3049,30 @@ void SMESHGUI::initialize( CAM_Application* app )
           this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
 }
 
+//================================================================================
+/*!
+ * \brief Return true if SMESH or GEOM objects are selected.
+ * Is called form LightApp_Module::activateModule() which clear selection if
+ * not isSelectionCompatible()
+ */
+//================================================================================
+
+bool SMESHGUI::isSelectionCompatible()
+{
+  bool isCompatible = true;
+  SALOME_ListIO selected;
+  if ( LightApp_SelectionMgr *Sel = selectionMgr() )
+    Sel->selectedObjects( selected );
+
+  SALOME_ListIteratorOfListIO It( selected );
+  for ( ; isCompatible && It.More(); It.Next())
+    isCompatible =
+      ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
+      ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
+
+  return isCompatible;
+}
+
 bool SMESHGUI::activateModule( SUIT_Study* study )
 {
   bool res = SalomeApp_Module::activateModule( study );
@@ -3051,6 +3085,9 @@ bool SMESHGUI::activateModule( SUIT_Study* study )
   action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
   action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
 
+  action(  33)->setEnabled(true); // Delete: Key_Delete
+  action(1101)->setEnabled(true); // Rename: Key_F2
+
   return res;
 }
 
@@ -3066,6 +3103,9 @@ bool SMESHGUI::deactivateModule( SUIT_Study* study )
   action(112)->setAccel(QKeySequence()); // Import UNV
   action(113)->setAccel(QKeySequence()); // Import MED
 
+  action(  33)->setEnabled(false); // Delete: Key_Delete
+  action(1101)->setEnabled(false); // Rename: Key_F2
+
   return SalomeApp_Module::deactivateModule( study );
 }
 
@@ -3107,11 +3147,22 @@ QString SMESHGUI::engineIOR() const
   return QString( anIOR.in() );
 }
 
-void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
+void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
 {
   SMESHGUI_Selection sel;
   sel.init( client, selectionMgr() );
   popupMgr()->updatePopup( menu, &sel );
+
+  SALOME_ListIO lst;
+  selectionMgr()->selectedObjects( lst );
+  if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
+    Handle(SALOME_InteractiveObject) io = lst.First();
+    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
+    _PTR(Study) study = appStudy->studyDS();
+    _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
+    if ( obj )
+      title = QString( obj->GetName().c_str() );
+  }
 }
 
 void SMESHGUI::windows( QMap<int, int>& aMap ) const