IMP 001989: multi selection in "Import" dialog boxes

This commit is contained in:
vsr 2008-07-02 08:41:03 +00:00
parent dcb0b83441
commit 4324ec1b43
2 changed files with 93 additions and 62 deletions

View File

@ -178,9 +178,11 @@ using namespace std;
if ( theCommandID == 113 ) {
filter.append( QObject::tr( "MED files (*.med)" ) );
filter.append( QObject::tr( "All files (*)" ) );
}else if (theCommandID == 112){
}
else if ( theCommandID == 112 ) {
filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
}else if (theCommandID == 111){
}
else if ( theCommandID == 111 ) {
filter.append( QObject::tr( "DAT files (*.dat)" ) );
}
@ -188,42 +190,56 @@ using namespace std;
if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
anInitialPath = QDir::currentDirPath();
QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
anInitialPath,
filter,
QObject::tr("Import mesh"),
true);
if(!filename.isEmpty()) {
QObject::tr( "SMESH_IMPORT_MESH" ) );
if ( filenames.count() > 0 ) {
SUIT_OverrideCursor wc;
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
try {
QStringList errors;
bool isEmpty = false;
for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
QString filename = *it;
SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
try {
switch ( theCommandID ) {
case 111:
{
// DAT format (currently unsupported)
errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
break;
}
case 112:
{
// UNV format
aMeshes->length( 1 );
aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.latin1() );
if ( aMeshes[0]->_is_nil() )
errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
break;
}
case 113:
{
// MED format
SMESH::DriverMED_ReadStatus res;
aMeshes = theComponentMesh->CreateMeshesFromMED( filename.latin1(), res );
if ( res != SMESH::DRS_OK ) {
wc.suspend();
SUIT_MessageBox::warn1(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr(QString("SMESH_DRS_%1").arg(res)),
QObject::tr("SMESH_BUT_OK"));
aMeshes->length( 0 );
wc.resume();
errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ) ) ) );
}
break;
}
}
}
catch ( const SALOME::SALOME_Exception& S_ex ) {
errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
}
bool isEmpty = false;
for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
_PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
if ( aMeshSO ) {
@ -232,30 +248,34 @@ using namespace std;
aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
} else
}
else {
isEmpty = true;
}
}
}
// update Object browser
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
// show Error message box if there were errors
if ( errors.count() > 0 ) {
SUIT_MessageBox::error1( SMESHGUI::desktop(),
QObject::tr( "SMESH_ERROR" ),
QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ),
QObject::tr( "SMESH_BUT_OK" ) );
}
// show warning message box, if some imported mesh is empty
if ( isEmpty ) {
wc.suspend();
SUIT_MessageBox::warn1( SMESHGUI::desktop(),
QObject::tr( "SMESH_WRN_WARNING" ),
QObject::tr("SMESH_DRS_EMPTY"),
QObject::tr( "SMESH_DRS_SOME_EMPTY" ),
QObject::tr( "SMESH_BUT_OK" ) );
wc.resume();
}
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
}
catch (const SALOME::SALOME_Exception& S_ex){
wc.suspend();
SalomeApp_Tools::QtCatchCorbaException(S_ex);
wc.resume();
}
}
}
void ExportMeshToFile( int theCommandID )
{
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();

View File

@ -1384,20 +1384,16 @@ msgid "SMESH_DRS_1"
msgstr "MED file contains no mesh with the given name"
msgid "SMESH_DRS_2"
msgstr ""
"MED file has overlapped ranges of element numbers,\n"
" the numbers from the file are ignored"
msgstr "MED file has overlapped ranges of element numbers, the numbers from the file are ignored"
msgid "SMESH_DRS_3"
msgstr "Some elements were skipped due to incorrect file data"
msgid "SMESH_DRS_4"
msgstr " The file is incorrect,\n"
"some information will be missed"
msgstr "The file is incorrect, some data is missed"
msgid "SMESH_DRS_EMPTY"
msgstr " The file is empty,\n"
"there is nothing to be published"
msgstr "The file is empty, there is nothing to be published"
msgid "SMESH_EXPORT_UNV"
msgstr "During export mesh with name - \"%1\" to UNV\n"
@ -3568,3 +3564,18 @@ msgstr "File size (bytes)"
msgid "SMESHGUI_FileInfoDlg::MED_VERSION"
msgstr "MED version"
msgid "SMESH_IMPORT_MESH"
msgstr "Import mesh data from files"
msgid "SMESH_ERR_NOT_SUPPORTED_FORMAT"
msgstr "Unsupported file format"
msgid "SMESH_ERR_UNKNOWN_IMPORT_ERROR"
msgstr "Unknown error"
msgid "SMESH_IMPORT_ERRORS"
msgstr "Import operation has finished with errors:"
msgid "SMESH_DRS_SOME_EMPTY"
msgstr "One or more mesh files were empty, data has not been published"