From 2a6619b00996a9ad086021df4d1edf74c3614169 Mon Sep 17 00:00:00 2001 From: ana Date: Mon, 19 Sep 2011 07:05:03 +0000 Subject: [PATCH] Integrate patches for win32 version --- src/VISUGUI/VISU_msg_en.ts | 12 ++++ src/VISUGUI/VisuGUI.cxx | 119 +++++++++++++++++++++++++++++++ src/VISUGUI/VisuGUI.h | 1 + src/VISUGUI/VisuGUI_ActionsDef.h | 1 + 4 files changed, 133 insertions(+) diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index af51cd21..747d84c7 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -667,6 +667,10 @@ Input value precision can be adjusted using FLT_MED_FILES MED Files (*.med) + + FLT_SAUV_FILES + SAUV files (*.sauv*) + FLT_TABLE_FILES Tables (*.txt *.tab *.csv) @@ -855,6 +859,10 @@ Input value precision can be adjusted using MEN_IMPORT_MED_TIMESTAMP Import TimeStamp + + MEN_IMPORT_SAUV + SAUV File + MEN_IMPORT_TABLE Table From File @@ -1237,6 +1245,10 @@ Input value precision can be adjusted using FLT_MED_FILES MED Files (*.med) + + FLT_SAUV_FILES + SAUV files (*.sauv*) + HELP Help diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index e67f340e..b3a28afd 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -220,6 +220,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() @@ -2478,6 +2590,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())); @@ -2899,6 +3015,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 ); @@ -2975,6 +3092,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 @@ -3117,6 +3235,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 ); diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index b7b4b4fd..55fdb39d 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -102,6 +102,7 @@ public slots: protected slots: void OnImportFromFile(); + void OnImportFromSauvFile(); void OnImportTableFromFile(); void OnExportTableToFile(); void OnImportMedField(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 972a922c..0b025237 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -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 -- 2.39.2