]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Some simplification.
authormzn <mzn@opencascade.com>
Mon, 13 Feb 2006 15:48:57 +0000 (15:48 +0000)
committermzn <mzn@opencascade.com>
Mon, 13 Feb 2006 15:48:57 +0000 (15:48 +0000)
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISUGUI/VisuGUI_ActionsDef.h
src/VISUGUI/VisuGUI_BuildProgressDlg.cxx
src/VISUGUI/VisuGUI_BuildProgressDlg.h

index eb50916fbfffa6d6a0d46405da72ae53bd25756a..4ded92946a421ab95007419551312319f2e42d89 100644 (file)
@@ -164,13 +164,16 @@ msgstr "Use Shading"
 #: VisuGUI.cxx
 
 msgid "VisuGUI::MEN_IMPORT_FROM_FILE"
+msgstr "MED file"
+
+msgid "VisuGUI::IMPORT_FROM_FILE"
 msgstr "Import from File"
 
-msgid "VisuGUI::MEN_EXPLORE_MED_FILE"
-msgstr "Explore MED File"
+msgid "VisuGUI::USE_BUILD_PROGRESS"
+msgstr "Use build progress"
 
 msgid "VisuGUI::MEN_IMPORT_TABLE"
-msgstr "Import table from File"
+msgstr "Table from file"
 
 msgid "VisuGUI::MEN_SCALAR_MAP"
 msgstr "Scalar Map"
index 3128e69f768cb59652dfe3761370166d33ebc732..8bff4218a59d93df249fff59621bb6b2a9574db6 100644 (file)
@@ -73,6 +73,7 @@
 #include "SalomeApp_Application.h"
 #include "SalomeApp_DataModel.h"
 #include "SalomeApp_Study.h"
+#include "SalomeApp_CheckFileDlg.h"
 #include "LightApp_SelectionMgr.h"
 #include "LightApp_Selection.h"
 #include "LightApp_Preferences.h"
@@ -95,7 +96,6 @@
 
 #include "VisuGUI_PopupTools.h"
 #include "VisuGUI_NameDlg.h"
-#include "VisuGUI_FileDlg.h"
 #include "VisuGUI_CursorDlg.h"
 #include "VisuGUI_Selection.h"
 #include "VisuGUI_TimeAnimation.h"
@@ -172,55 +172,51 @@ OnImportFromFile()
   if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
   if ( CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)) )
     return;
-
-  VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) );
-  aBuildProgressDlg->setGenerator( GetVisuGen(this) );
-  aBuildProgressDlg->show();
-}
-
-
-void
-VisuGUI::
-OnExploreMEDFile()
-{
-  if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
-  _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
-  if ( CheckLock(aStudy,GetDesktop(this)) )
-    return;
-
-  SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
-
+  
+  // Get file name
   QStringList aFilter;
-  aFilter.append( tr("FLT_MED_FILES") );
-  aFilter.append( tr("FLT_ALL_FILES") );
-
-  QFileInfo aFileInfo =
-    SUIT_FileDlg::getFileName(GetDesktop(this),
-                              "",
-                              aFilter,
-                              tr("MEN_EXPLORE_MED_FILE"),
-                              true);
-  if(aFileInfo.exists()){
-    application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
-    std::string aStudyName = aStudy->Name();
-    try
+  aFilter.append( tr( "FLT_MED_FILES" ) );
+  aFilter.append( tr( "FLT_ALL_FILES" ) );
+  
+  bool toUseBuildProgress = GetResourceMgr()->booleanValue("VISU", "use_build_progress", false);
+
+  SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") );
+  fd->setCaption( tr( "IMPORT_FROM_FILE" ) );
+  fd->setFilters( aFilter );
+  fd->SetChecked( toUseBuildProgress );
+  fd->exec();
+  QFileInfo aFileInfo( fd->selectedFile() );
+  toUseBuildProgress = fd->IsChecked();
+  delete fd;
+  
+  // Check the file name
+  if ( !aFileInfo.exists() )
+    return;
+  
+  if ( !toUseBuildProgress )
     {
-      aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
+      QString anInfo("Importing From File " + aFileInfo.filePath() + "..." ); 
+      application()->putInfo( anInfo );
+      VISU::Result_var aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
+      if (CORBA::is_nil(aResult.in())) {
+       SUIT_MessageBox::warn1(GetDesktop(this),
+                              tr("WRN_VISU"),
+                              tr("ERR_ERROR_IN_THE_FILE"),
+                              tr("BUT_OK"));
+      }else{
+       application()->putInfo( anInfo + tr("INF_DONE"));
+       UpdateObjBrowser(this);
+      }
     }
-    catch(...)
+  else
     {
-      SUIT_MessageBox::warn1(GetDesktop(this),
-                             tr("WRN_VISU"),
-                             tr("ERR_ERROR_IN_THE_FILE"),
-                             tr("BUT_OK"));
+      VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) );
+      aBuildProgressDlg->setFileName( aFileInfo.filePath() );
+      aBuildProgressDlg->setGenerator( GetVisuGen(this) );
+      aBuildProgressDlg->show();
     }
-    application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
-    getApp()->updateObjectBrowser(true); // as need to update MED tree
-    getApp()->updateActions();
-  }
 }
 
-
 void
 VisuGUI::
 OnImportTableFromFile()
@@ -1960,10 +1956,6 @@ createActions()
                 tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
                 this, SLOT(OnImportFromFile()));
 
-  createAction( VISU_EXPLORE_MED, "", QIconSet(),
-                tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
-                this, SLOT(OnExploreMEDFile()));
-
   createAction( VISU_IMPORT_TABLE, "", QIconSet(),
                 tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
                 this, SLOT(OnImportTableFromFile()));
@@ -2265,9 +2257,10 @@ createMenus()
   int aMenuId;
   aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
   createMenu( separator(), aMenuId, -1, 10 );
-  createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
-  createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
-  createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
+  
+  int anImportId = createMenu( tr( "MEN_IMPORT" ), aMenuId, -1, 10 );
+  createMenu( VISU_IMPORT_FROM_FILE, anImportId ); // import from file
+  createMenu( VISU_IMPORT_TABLE, anImportId ); // import table
 
   aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
   createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
@@ -2974,6 +2967,7 @@ void VisuGUI::createPreferences()
   // group: "MED files import"
   int importGr = addPreference( tr( "MED files import" ), srangeTab );
   setPreferenceProperty( importGr, "columns", 1 );
+  addPreference( tr( "Use build progress" ), importGr, LightApp_Preferences::Bool, "VISU", "use_build_progress" );
   addPreference( tr( "Full MED loading" ), importGr, LightApp_Preferences::Bool, "VISU", "full_med_loading" );
   addPreference( tr( "Build at once" ), importGr, LightApp_Preferences::Bool, "VISU", "build_at_once" );
   addPreference( tr( "Build fields" ), importGr, LightApp_Preferences::Bool, "VISU", "build_fields" );
index 22224d7210d7608406d357093d50ab3c6a70dc9f..cec1e4c2ef98d53d1e59067e99b7e29ce265b8c4 100644 (file)
@@ -81,7 +81,6 @@ public slots:
 
 protected slots:
   void OnImportFromFile();
-  void OnExploreMEDFile();
   void OnImportTableFromFile();
   void OnExportTableToFile();
   void OnImportMedField();
index 1fe7a7b2b1506fe94bfd8674032cc18307d967b1..681a9d131f1500d577b5665346e44b3eda43893f 100644 (file)
 #define VISUGUI_ACTIONSDEF
 
 //#define VISU_IMPORT_FROM_FILE       112
-//#define VISU_EXPLORE_MED            113
 //#define VISU_IMPORT_MED             114
 //#define VISU_IMPORT_TABLE           199
 #define VISU_IMPORT_FROM_FILE       4002
-#define VISU_EXPLORE_MED            4003
-#define VISU_IMPORT_TABLE           4004
-#define VISU_IMPORT_MED_STRUCTURE   4005
-#define VISU_IMPORT_MED_TIMESTAMP   4006
-#define VISU_IMPORT_MED_FIELD       4007
+#define VISU_IMPORT_TABLE           4003
+#define VISU_IMPORT_MED_STRUCTURE   4004
+#define VISU_IMPORT_MED_TIMESTAMP   4005
+#define VISU_IMPORT_MED_FIELD       4006
 
 #define VISU_SCALAR_MAP             4011
 #define VISU_DEFORMED_SHAPE         4012
index 99bea913960dc46ce09f9226f1662797037bf1b6..5c6f69c5b09c57c49d1250e600035f650d94666c 100644 (file)
@@ -208,7 +208,7 @@ VisuGUI_BuildProgressDlg::~VisuGUI_BuildProgressDlg()
 
 void VisuGUI_BuildProgressDlg::show()
 {
-  if( onBrowseFile() )
+  if( !myFileName.isNull() || onBrowseFile() )
     QWidget::show();
 }
 
@@ -393,3 +393,12 @@ void VisuGUI_BuildProgressDlg::onBuildCheckBoxClicked()
     myBuildGroupsButton->setPaletteBackgroundColor( aColor );
 
 }
+
+void VisuGUI_BuildProgressDlg::setFileName( const QString& theFileName )
+{
+  if ( !theFileName.isNull() )
+    {
+      myFileName = theFileName;
+      myFileNameLineEdit->setText( myFileName.section( '/', -1 ) );
+    }
+}
index 4d8805968b1320bc91613f6cfcd8f702edde1c76..d0db591254fdc91727f9f9630ae1933fd4a2f19b 100644 (file)
@@ -54,6 +54,7 @@ public:
   virtual void     show();
 
   QString          fileName() const { return myFileName; }
+  void             setFileName( const QString& theFileName );
 
 protected slots:
   void             done( int );