From fd631fab5de4c427094daf110335d7602872d6a1 Mon Sep 17 00:00:00 2001 From: mzn Date: Mon, 13 Feb 2006 15:48:57 +0000 Subject: [PATCH] Some simplification. --- src/VISUGUI/VISU_msg_en.po | 9 ++- src/VISUGUI/VisuGUI.cxx | 94 +++++++++++------------- src/VISUGUI/VisuGUI.h | 1 - src/VISUGUI/VisuGUI_ActionsDef.h | 10 +-- src/VISUGUI/VisuGUI_BuildProgressDlg.cxx | 11 ++- src/VISUGUI/VisuGUI_BuildProgressDlg.h | 1 + 6 files changed, 65 insertions(+), 61 deletions(-) diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index eb50916f..4ded9294 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -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" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 3128e69f..8bff4218 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -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" ); diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 22224d72..cec1e4c2 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -81,7 +81,6 @@ public slots: protected slots: void OnImportFromFile(); - void OnExploreMEDFile(); void OnImportTableFromFile(); void OnExportTableToFile(); void OnImportMedField(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 1fe7a7b2..681a9d13 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -21,15 +21,13 @@ #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 diff --git a/src/VISUGUI/VisuGUI_BuildProgressDlg.cxx b/src/VISUGUI/VisuGUI_BuildProgressDlg.cxx index 99bea913..5c6f69c5 100644 --- a/src/VISUGUI/VisuGUI_BuildProgressDlg.cxx +++ b/src/VISUGUI/VisuGUI_BuildProgressDlg.cxx @@ -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 ) ); + } +} diff --git a/src/VISUGUI/VisuGUI_BuildProgressDlg.h b/src/VISUGUI/VisuGUI_BuildProgressDlg.h index 4d880596..d0db5912 100644 --- a/src/VISUGUI/VisuGUI_BuildProgressDlg.h +++ b/src/VISUGUI/VisuGUI_BuildProgressDlg.h @@ -54,6 +54,7 @@ public: virtual void show(); QString fileName() const { return myFileName; } + void setFileName( const QString& theFileName ); protected slots: void done( int ); -- 2.39.2