}
}
+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()
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()));
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 );
// 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
// 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 );