]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Merge from V6_3_BR branch (Windows porting) 27/10/2011 V6_4_0a1 V6_main_20111101 V6_main_20111103 V6_main_20111107 V6_main_20111108 V6_main_20111109 V6_main_20111110 V6_main_20111111 V6_main_20111114 V6_main_20111115 V6_main_20111116 V6_main_20111117 V6_main_20111118 V6_main_20111122 V6_main_20111123 V6_main_20111124 V6_main_20111125 V6_main_20111128 V6_main_20111129 V6_main_20111130 before_mergefrom_V6_4_BR_05Dec11 mergefrom_V6_3_BR_27Oct11
authorvsr <vsr@opencascade.com>
Thu, 27 Oct 2011 15:33:04 +0000 (15:33 +0000)
committervsr <vsr@opencascade.com>
Thu, 27 Oct 2011 15:33:04 +0000 (15:33 +0000)
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISUGUI/VisuGUI_ActionsDef.h

index 09fd56e140344fe97b1c007836798d6aec0f983f..f8eda5b46887797e85c79e8b8a6dba220e52bc70 100644 (file)
@@ -667,6 +667,10 @@ Input value precision can be adjusted using
         <source>FLT_MED_FILES</source>
         <translation>MED Files (*.med)</translation>
     </message>
+    <message>
+        <source>FLT_SAUV_FILES</source>
+        <translation>SAUV files (*.sauv*)</translation>
+    </message>
     <message>
         <source>FLT_TABLE_FILES</source>
         <translation>Tables (*.txt *.tab *.csv)</translation>
@@ -859,6 +863,10 @@ Input value precision can be adjusted using
         <source>MEN_IMPORT_MED_TIMESTAMP</source>
         <translation>Import TimeStamp</translation>
     </message>
+    <message>
+        <source>MEN_IMPORT_SAUV</source>
+        <translation>SAUV File</translation>
+    </message>
     <message>
         <source>MEN_IMPORT_TABLE</source>
         <translation>Table From File</translation>
@@ -1241,6 +1249,10 @@ Input value precision can be adjusted using
         <source>FLT_MED_FILES</source>
         <translation>MED Files (*.med)</translation>
     </message>
+    <message>
+        <source>FLT_SAUV_FILES</source>
+        <translation>SAUV files (*.sauv*)</translation>
+    </message>
     <message>
         <source>HELP</source>
         <translation>Help</translation>
index c7a8b5763fad0ec4846687cea10d2d8169572c7a..64f2fa6fbbd276f3a067a7c5f7f8775a79a9eb7a 100644 (file)
@@ -221,6 +221,118 @@ VisuGUI
   }
 }
 
+void
+VisuGUI
+::OnImportFromSauvFile()
+{
+  if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromSauvFile()");
+
+  if ( CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)) )
+    return;
+
+  SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
+
+  // Get file name(s)
+  QStringList aFilter;
+  aFilter.append( tr( "FLT_SAUV_FILES" ) );
+  aFilter.append( tr( "FLT_ALL_FILES" ) );
+
+  bool toUseBuildProgress = aResourceMgr->booleanValue("VISU", "use_build_progress", false);
+
+  SalomeApp_CheckFileDlg fd( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") );
+  fd.setWindowTitle( tr( "IMPORT_FROM_FILE" ) );
+  fd.setFileMode( SalomeApp_CheckFileDlg::ExistingFiles );
+  fd.setFilters( aFilter );
+  fd.SetChecked( toUseBuildProgress );
+  if ( SalomeApp_CheckFileDlg::getLastVisitedPath().isEmpty() )
+    fd.setDirectory( QDir::currentPath() );
+
+  QStringList fileNames;
+  if ( !fd.exec() )
+    return; // cancelled, return
+
+  fileNames = fd.selectedFiles();
+  toUseBuildProgress = fd.IsChecked();
+
+  if ( fileNames.count() == 0 )
+    return; // nothing selected, return
+
+  SUIT_OverrideCursor wc;
+  QStringList errors;
+
+  for ( QStringList::ConstIterator it = fileNames.begin(); it != fileNames.end(); ++it ) {
+    QFileInfo aFileInfo( *it );
+
+    if ( !aFileInfo.exists() ) {
+      // file not exist
+      errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
+                     arg( tr( "ERR_FILE_NOT_EXISTS" ) ) );
+    }
+    else {
+      std::string file_in = aFileInfo.filePath().toLatin1().constData();
+      std::string file_tmp = file_in + ".med";
+#ifdef WNT
+      std::string cmd = "%PYTHONBIN% ";
+#else
+      std::string cmd = "python ";
+#endif
+      cmd += "-c \"";
+      cmd += "from medutilities import convert ; convert(r'" + file_in + "', 'GIBI', 'MED', 1, r'" + file_tmp + "')";
+      cmd += "\"";
+      system(cmd.c_str());
+      QString fff(file_tmp.c_str());
+      aFileInfo = fff;
+      try {
+        if ( !toUseBuildProgress ) {
+          // build progress is not used, use build flags from settings
+          bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields",     true );
+          bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max",    true );
+          bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups",     true );
+          bool toBuildAll    = aResourceMgr->booleanValue( "VISU", "full_med_loading", false );
+          bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once",    false );
+
+          QString anInfo( tr( "IMPORT_FROM_FILE" ) + " " + aFileInfo.filePath() + " ... " );
+          application()->putInfo( anInfo );
+
+          VISU::Result_var aResult = GetVisuGen( this )->CreateResult( aFileInfo.filePath().toLatin1().constData() );
+
+          if ( CORBA::is_nil( aResult.in() ) ) {
+            errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
+                           arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) );
+          }
+          else {
+            aResult->SetBuildFields( toBuildFields, toBuildMinMax );
+            aResult->SetBuildGroups( toBuildGroups );
+            aResult->Build( toBuildAll, toBuildAtOnce );
+            application()->putInfo( anInfo + tr("INF_DONE") );
+          }
+        } // if ( !toUseBuildProgress )
+        else {
+          // use build progress
+          wc.suspend();
+          VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) );
+          aBuildProgressDlg->setFileName( aFileInfo.filePath() );
+          aBuildProgressDlg->setGenerator( GetVisuGen(this) );
+          aBuildProgressDlg->exec();
+          wc.resume();
+        }
+      } // try
+      catch(...) {
+        errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) );
+      }
+    } // else // if ( !aFileInfo.exists() )
+  } // for (...)
+
+  if ( errors.count() > 0 ) {
+    SUIT_MessageBox::critical( GetDesktop(this),
+                               tr("ERR_ERROR"),
+                               tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
+  }
+  else {
+    UpdateObjBrowser(this);
+  }
+}
+
 void
 VisuGUI
 ::OnImportFromFile()
@@ -2520,6 +2632,10 @@ VisuGUI
                 tr("MEN_IMPORT_FROM_FILE"), "", (Qt::CTRL + Qt::Key_I), aParent, false,
                 this, SLOT(OnImportFromFile()));
 
+  createAction( VISU_IMPORT_SAUV, "", QIcon(),
+                tr("MEN_IMPORT_SAUV"), "", 0, aParent, false,
+                this, SLOT(OnImportFromSauvFile()));
+
   createAction( VISU_IMPORT_TABLE, "", QIcon(),
                 tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
                 this, SLOT(OnImportTableFromFile()));
@@ -2945,6 +3061,7 @@ VisuGUI
 
   int anImportId = createMenu( tr( "MEN_IMPORT" ), aMenuId, -1, 10 );
   createMenu( VISU_IMPORT_FROM_FILE, anImportId ); // import from file
+  createMenu( VISU_IMPORT_SAUV, anImportId ); // import sauv file
   createMenu( VISU_IMPORT_TABLE, anImportId ); // import table
 
   aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
@@ -3021,6 +3138,7 @@ VisuGUI
 
   // VISU root commands
   mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
+  mgr->insert( action( VISU_IMPORT_SAUV ), -1, -1, -1 ); // import SAUV file
   mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
   mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
 
@@ -3164,6 +3282,7 @@ VisuGUI
   // VISU root commands
   QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'";
   mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule );
+  mgr->setRule( action( VISU_IMPORT_SAUV ), aRule );
   mgr->setRule( action( VISU_IMPORT_TABLE ), aRule );
   mgr->setRule( action( VISU_PLOT2D ), aRule );
 
index 87967ffba72e0b64634e66c4fc82591948386733..173562582aaced9a80b0d1927292a8f975ddcbdd 100644 (file)
@@ -102,6 +102,7 @@ public slots:
 
 protected slots:
   void OnImportFromFile();
+  void OnImportFromSauvFile();
   void OnImportTableFromFile();
   void OnExportTableToFile();
   void OnImportMedField();
index 2f854f15e245c36f62115d5fbc40789c2457ecef..a07f0a1f9548b8ec285f1911a87cdb1802609728 100644 (file)
@@ -32,6 +32,7 @@
 #define VISU_IMPORT_MED_TIMESTAMP   4005
 #define VISU_IMPORT_MED_FIELD       4006
 #define VISU_LOAD_COMPONENT_DATA    4007
+#define VISU_IMPORT_SAUV            4008
 
 #define VISU_SCALAR_MAP             4011
 #define VISU_DEFORMED_SHAPE         4012