PAL11563: Naming Policy. Export to MED groups with duplicated names forbidden: ask user whether to rename automatically or cancel exporting.

This commit is contained in:
jfa 2006-02-21 08:52:26 +00:00
parent 56ee43a2eb
commit e8c71ef8da
2 changed files with 73 additions and 50 deletions

View File

@ -146,7 +146,7 @@
using namespace std;
namespace{
// Decalarations
// Declarations
//=============================================================
void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
int theCommandID);
@ -260,30 +260,45 @@ namespace{
switch ( theCommandID ) {
case 125:
case 122:
aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
{
if (aMesh->HasDuplicatedGroupNamesMED()) {
int aRet = SUIT_MessageBox::warn2
(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
0, 1, 0);
if (aRet)
return;
}
aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
}
break;
case 124:
case 121:
aFilter = QObject::tr("DAT files (*.dat)");
break;
case 126:
case 123: {
if(aMesh->NbPyramids()){
int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
QObject::tr("SMESH_BUT_YES"),
QObject::tr("SMESH_BUT_NO"),
0,1,0);
if(aRet)
return;
}
aFilter = QObject::tr("IDEAS files (*.unv)");
case 123:
{
if (aMesh->NbPyramids()) {
int aRet = SUIT_MessageBox::warn2
(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
0, 1, 0);
if (aRet)
return;
}
aFilter = QObject::tr("IDEAS files (*.unv)");
}
break;
default:
return;
}}
}
QString aFilename;
SMESH::MED_VERSION aFormat;
@ -295,41 +310,42 @@ namespace{
if ( theCommandID != 122 && theCommandID != 125 )
aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
else
{
QStringList filters;
for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
filters.push_back( it.key() );
else {
QStringList filters;
QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
for ( ; it != aFilterMap.end(); ++it )
filters.push_back( it.key() );
//SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
fd->setCaption( aTitle );
fd->setFilters( filters );
fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
fd->SetChecked(toCreateGroups);
bool is_ok = false;
while(!is_ok){
fd->exec();
aFilename = fd->selectedFile();
aFormat = aFilterMap[fd->selectedFilter()];
is_ok = true;
if( !aFilename.isEmpty()
&& (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
&& aFormat==SMESH::MED_V2_1){
int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
QObject::tr("SMESH_BUT_YES"),
QObject::tr("SMESH_BUT_NO"),
0,1,0);
if(aRet){
is_ok = false;
}
}
}
toCreateGroups = fd->IsChecked();
delete fd;
}
//SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
fd->setCaption( aTitle );
fd->setFilters( filters );
fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
fd->SetChecked(toCreateGroups);
bool is_ok = false;
while (!is_ok) {
fd->exec();
aFilename = fd->selectedFile();
aFormat = aFilterMap[fd->selectedFilter()];
is_ok = true;
if ( !aFilename.isEmpty()
&& (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
&& aFormat==SMESH::MED_V2_1) {
int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
QObject::tr("SMESH_BUT_YES"),
QObject::tr("SMESH_BUT_NO"),
0,1,0);
if (aRet) {
is_ok = false;
}
}
}
toCreateGroups = fd->IsChecked();
delete fd;
}
if ( !aFilename.isEmpty() ) {
// Check whether the file already exists and delete it if yes
QFile aFile( aFilename );

View File

@ -1260,6 +1260,13 @@ msgid "SMESH_EXPORT_UNV"
msgstr "During export mesh with name - \"%1\" to UNV\n"
" pyramid's elements will be missed"
msgid "SMESH_EXPORT_MED_DUPLICATED_GRP"
msgstr "There are duplicated group names in mesh \"%1\".\n"
"You can cancel exporting and rename them,\n"
"otherwise some group names in the resulting MED file\n"
"will not match ones in the study.\n"
"Do you want to continue ?"
msgid "SMESH_EXPORT_MED_V2_1"
msgstr "During export mesh with name - \"%1\" to MED 2.1\n"
"polygons and polyhedrons elements will be missed\n"