mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-30 19:30:35 +05:00
20002: EDF 821 SMESH : ExportMED GUI behavior
warning if no valid mesh selected
This commit is contained in:
parent
c5e983833f
commit
964fe4af29
@ -267,214 +267,219 @@
|
|||||||
if( aSel )
|
if( aSel )
|
||||||
aSel->selectedObjects( selected );
|
aSel->selectedObjects( selected );
|
||||||
|
|
||||||
if(selected.Extent()){
|
SMESH::SMESH_Mesh_var aMesh;
|
||||||
Handle(SALOME_InteractiveObject) anIObject = selected.First();
|
if(selected.Extent() == 1)
|
||||||
SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
|
aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(selected.First());
|
||||||
if ( !aMesh->_is_nil() ) {
|
if ( aMesh->_is_nil() ) {
|
||||||
QString aFilter, aTitle = QObject::tr("Export mesh");
|
SUIT_MessageBox::warning( SMESHGUI::desktop(),
|
||||||
QMap<QString, SMESH::MED_VERSION> aFilterMap;
|
QObject::tr( "SMESH_WRN_WARNING" ),
|
||||||
QMap<QString, int> aFilterMapSTL;
|
QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
|
||||||
switch ( theCommandID ) {
|
return;
|
||||||
case 125:
|
}
|
||||||
case 122:
|
|
||||||
{
|
|
||||||
if (aMesh->HasDuplicatedGroupNamesMED()) {
|
|
||||||
int aRet = SUIT_MessageBox::warning
|
|
||||||
(SMESHGUI::desktop(),
|
|
||||||
QObject::tr("SMESH_WRN_WARNING"),
|
|
||||||
QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
|
|
||||||
SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
|
|
||||||
if (aRet != SUIT_MessageBox::Yes)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// PAL18696
|
|
||||||
QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
|
|
||||||
QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
|
|
||||||
aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
|
|
||||||
aFilterMap.insert( QString("MED ") + v22 + " (*.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::warning
|
|
||||||
(SMESHGUI::desktop(),
|
|
||||||
QObject::tr("SMESH_WRN_WARNING"),
|
|
||||||
QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
|
|
||||||
SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
|
|
||||||
if (aRet != SUIT_MessageBox::Yes)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
aFilter = QObject::tr("IDEAS files (*.unv)");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 140:
|
|
||||||
case 141:
|
|
||||||
{
|
|
||||||
// export STL
|
|
||||||
/*
|
|
||||||
there must be check on others mesh elements not equal triangles
|
|
||||||
*/
|
|
||||||
if (aMesh->NbTriangles() < 1) {
|
|
||||||
SUIT_MessageBox::warning
|
|
||||||
(SMESHGUI::desktop(),
|
|
||||||
QObject::tr("SMESH_WRN_WARNING"),
|
|
||||||
QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
|
|
||||||
int aRet = SUIT_MessageBox::warning
|
|
||||||
(SMESHGUI::desktop(),
|
|
||||||
QObject::tr("SMESH_WRN_WARNING"),
|
|
||||||
QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
|
|
||||||
SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
|
|
||||||
if (aRet != SUIT_MessageBox::Yes)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
|
Handle(SALOME_InteractiveObject) anIObject = selected.First();
|
||||||
aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
|
QString aFilter, aTitle = QObject::tr("Export mesh");
|
||||||
}
|
QMap<QString, SMESH::MED_VERSION> aFilterMap;
|
||||||
break;
|
QMap<QString, int> aFilterMapSTL;
|
||||||
default:
|
switch ( theCommandID ) {
|
||||||
return;
|
case 125:
|
||||||
}
|
case 122:
|
||||||
|
{
|
||||||
QString aFilename;
|
if (aMesh->HasDuplicatedGroupNamesMED()) {
|
||||||
SMESH::MED_VERSION aFormat;
|
int aRet = SUIT_MessageBox::warning
|
||||||
// Init the parameter with the default value
|
(SMESHGUI::desktop(),
|
||||||
bool aIsASCII_STL = true;
|
QObject::tr("SMESH_WRN_WARNING"),
|
||||||
bool toCreateGroups = false;
|
QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
|
||||||
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
|
||||||
if ( resMgr )
|
if (aRet != SUIT_MessageBox::Yes)
|
||||||
toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
|
return;
|
||||||
|
}
|
||||||
QString anInitialPath = "";
|
// PAL18696
|
||||||
if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
|
QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
|
||||||
anInitialPath = QDir::currentPath();
|
QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
|
||||||
|
aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
|
||||||
if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
|
aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
|
||||||
if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
|
}
|
||||||
aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
|
break;
|
||||||
aFilter, aTitle, false);
|
case 124:
|
||||||
}
|
case 121:
|
||||||
else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
|
aFilter = QObject::tr("DAT files (*.dat)");
|
||||||
QStringList filters;
|
break;
|
||||||
QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
|
case 126:
|
||||||
for ( ; it != aFilterMapSTL.end(); ++it )
|
case 123:
|
||||||
filters.push_back( it.key() );
|
{
|
||||||
|
if (aMesh->NbPyramids()) {
|
||||||
SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
|
int aRet = SUIT_MessageBox::warning
|
||||||
fd->setWindowTitle( aTitle );
|
(SMESHGUI::desktop(),
|
||||||
fd->setFilters( filters );
|
QObject::tr("SMESH_WRN_WARNING"),
|
||||||
fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
|
QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
|
||||||
if ( !anInitialPath.isEmpty() )
|
SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
|
||||||
fd->setDirectory( anInitialPath );
|
if (aRet != SUIT_MessageBox::Yes)
|
||||||
fd->selectFile(anIObject->getName());
|
return;
|
||||||
bool is_ok = false;
|
}
|
||||||
while (!is_ok) {
|
aFilter = QObject::tr("IDEAS files (*.unv)");
|
||||||
if ( fd->exec() )
|
}
|
||||||
aFilename = fd->selectedFile();
|
break;
|
||||||
aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
|
case 140:
|
||||||
is_ok = true;
|
case 141:
|
||||||
}
|
{
|
||||||
delete fd;
|
// export STL
|
||||||
}
|
/*
|
||||||
else { // Export to MED
|
there must be check on others mesh elements not equal triangles
|
||||||
QStringList filters;
|
*/
|
||||||
QString aDefaultFilter;
|
if (aMesh->NbTriangles() < 1) {
|
||||||
QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
|
SUIT_MessageBox::warning
|
||||||
for ( ; it != aFilterMap.end(); ++it ) {
|
(SMESHGUI::desktop(),
|
||||||
filters.push_back( it.key() );
|
QObject::tr("SMESH_WRN_WARNING"),
|
||||||
if (it.value() == SMESH::MED_V2_2)
|
QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()));
|
||||||
aDefaultFilter = it.key();
|
return;
|
||||||
}
|
}
|
||||||
|
if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
|
||||||
//SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
|
int aRet = SUIT_MessageBox::warning
|
||||||
SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
|
(SMESHGUI::desktop(),
|
||||||
( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
|
QObject::tr("SMESH_WRN_WARNING"),
|
||||||
fd->setWindowTitle( aTitle );
|
QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
|
||||||
fd->setFilters( filters );
|
SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
|
||||||
//fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
|
if (aRet != SUIT_MessageBox::Yes)
|
||||||
fd->selectFilter(aDefaultFilter);
|
return;
|
||||||
fd->SetChecked(toCreateGroups);
|
|
||||||
if ( !anInitialPath.isEmpty() )
|
|
||||||
fd->setDirectory( anInitialPath );
|
|
||||||
fd->selectFile(anIObject->getName());
|
|
||||||
bool is_ok = false;
|
|
||||||
while (!is_ok) {
|
|
||||||
if ( fd->exec() )
|
|
||||||
aFilename = fd->selectedFile();
|
|
||||||
aFormat = aFilterMap[fd->selectedFilter()];
|
|
||||||
is_ok = true;
|
|
||||||
if ( !aFilename.isEmpty()
|
|
||||||
&& (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
|
|
||||||
&& aFormat==SMESH::MED_V2_1) {
|
|
||||||
int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
|
|
||||||
QObject::tr("SMESH_WRN_WARNING"),
|
|
||||||
QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
|
|
||||||
SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
|
|
||||||
if (aRet != SUIT_MessageBox::Yes) {
|
|
||||||
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 );
|
|
||||||
if ( aFile.exists() )
|
|
||||||
aFile.remove();
|
|
||||||
SUIT_OverrideCursor wc;
|
|
||||||
|
|
||||||
try {
|
aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
|
||||||
bool Renumber = false;
|
aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
|
||||||
// PAL 14172 : Check of we have to renumber or not from the preferences before export
|
}
|
||||||
if (resMgr)
|
break;
|
||||||
Renumber= resMgr->booleanValue("SMESH","renumbering");
|
default:
|
||||||
if (Renumber){
|
return;
|
||||||
SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
|
}
|
||||||
aMeshEditor->RenumberNodes();
|
|
||||||
aMeshEditor->RenumberElements();
|
QString aFilename;
|
||||||
if ( SMESHGUI::automaticUpdate() )
|
SMESH::MED_VERSION aFormat;
|
||||||
SMESH::UpdateView();
|
// Init the parameter with the default value
|
||||||
}
|
bool aIsASCII_STL = true;
|
||||||
switch ( theCommandID ) {
|
bool toCreateGroups = false;
|
||||||
case 125:
|
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||||
case 122:
|
if ( resMgr )
|
||||||
aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
|
toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
|
||||||
break;
|
|
||||||
case 124:
|
QString anInitialPath = "";
|
||||||
case 121:
|
if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
|
||||||
aMesh->ExportDAT( aFilename.toLatin1().data() );
|
anInitialPath = QDir::currentPath();
|
||||||
break;
|
|
||||||
case 126:
|
if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
|
||||||
case 123:
|
if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
|
||||||
aMesh->ExportUNV( aFilename.toLatin1().data() );
|
aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
|
||||||
break;
|
aFilter, aTitle, false);
|
||||||
case 140:
|
}
|
||||||
case 141:
|
else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
|
||||||
aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
|
QStringList filters;
|
||||||
break;
|
QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
|
||||||
default:
|
for ( ; it != aFilterMapSTL.end(); ++it )
|
||||||
break;
|
filters.push_back( it.key() );
|
||||||
}
|
|
||||||
}
|
SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
|
||||||
catch (const SALOME::SALOME_Exception& S_ex){
|
fd->setWindowTitle( aTitle );
|
||||||
wc.suspend();
|
fd->setFilters( filters );
|
||||||
SUIT_MessageBox::warning(SMESHGUI::desktop(),
|
fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
|
||||||
QObject::tr("SMESH_WRN_WARNING"),
|
if ( !anInitialPath.isEmpty() )
|
||||||
QObject::tr("SMESH_EXPORT_FAILED"));
|
fd->setDirectory( anInitialPath );
|
||||||
wc.resume();
|
fd->selectFile(anIObject->getName());
|
||||||
}
|
bool is_ok = false;
|
||||||
}
|
while (!is_ok) {
|
||||||
|
if ( fd->exec() )
|
||||||
|
aFilename = fd->selectedFile();
|
||||||
|
aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
|
||||||
|
is_ok = true;
|
||||||
|
}
|
||||||
|
delete fd;
|
||||||
|
}
|
||||||
|
else { // Export to MED
|
||||||
|
QStringList filters;
|
||||||
|
QString aDefaultFilter;
|
||||||
|
QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
|
||||||
|
for ( ; it != aFilterMap.end(); ++it ) {
|
||||||
|
filters.push_back( it.key() );
|
||||||
|
if (it.value() == SMESH::MED_V2_2)
|
||||||
|
aDefaultFilter = 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->setWindowTitle( aTitle );
|
||||||
|
fd->setFilters( filters );
|
||||||
|
//fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
|
||||||
|
fd->selectFilter(aDefaultFilter);
|
||||||
|
fd->SetChecked(toCreateGroups);
|
||||||
|
if ( !anInitialPath.isEmpty() )
|
||||||
|
fd->setDirectory( anInitialPath );
|
||||||
|
fd->selectFile(anIObject->getName());
|
||||||
|
bool is_ok = false;
|
||||||
|
while (!is_ok) {
|
||||||
|
if ( fd->exec() )
|
||||||
|
aFilename = fd->selectedFile();
|
||||||
|
aFormat = aFilterMap[fd->selectedFilter()];
|
||||||
|
is_ok = true;
|
||||||
|
if ( !aFilename.isEmpty()
|
||||||
|
&& (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
|
||||||
|
&& aFormat==SMESH::MED_V2_1) {
|
||||||
|
int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
|
||||||
|
QObject::tr("SMESH_WRN_WARNING"),
|
||||||
|
QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
|
||||||
|
SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
|
||||||
|
if (aRet != SUIT_MessageBox::Yes) {
|
||||||
|
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 );
|
||||||
|
if ( aFile.exists() )
|
||||||
|
aFile.remove();
|
||||||
|
SUIT_OverrideCursor wc;
|
||||||
|
|
||||||
|
try {
|
||||||
|
bool Renumber = false;
|
||||||
|
// PAL 14172 : Check of we have to renumber or not from the preferences before export
|
||||||
|
if (resMgr)
|
||||||
|
Renumber= resMgr->booleanValue("SMESH","renumbering");
|
||||||
|
if (Renumber){
|
||||||
|
SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
|
||||||
|
aMeshEditor->RenumberNodes();
|
||||||
|
aMeshEditor->RenumberElements();
|
||||||
|
if ( SMESHGUI::automaticUpdate() )
|
||||||
|
SMESH::UpdateView();
|
||||||
|
}
|
||||||
|
switch ( theCommandID ) {
|
||||||
|
case 125:
|
||||||
|
case 122:
|
||||||
|
aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
|
||||||
|
break;
|
||||||
|
case 124:
|
||||||
|
case 121:
|
||||||
|
aMesh->ExportDAT( aFilename.toLatin1().data() );
|
||||||
|
break;
|
||||||
|
case 126:
|
||||||
|
case 123:
|
||||||
|
aMesh->ExportUNV( aFilename.toLatin1().data() );
|
||||||
|
break;
|
||||||
|
case 140:
|
||||||
|
case 141:
|
||||||
|
aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const SALOME::SALOME_Exception& S_ex){
|
||||||
|
wc.suspend();
|
||||||
|
SUIT_MessageBox::warning(SMESHGUI::desktop(),
|
||||||
|
QObject::tr("SMESH_WRN_WARNING"),
|
||||||
|
QObject::tr("SMESH_EXPORT_FAILED"));
|
||||||
|
wc.resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -805,6 +805,10 @@ Please enter correct values and try again</translation>
|
|||||||
<source>SMESH_BAD_SELECTION</source>
|
<source>SMESH_BAD_SELECTION</source>
|
||||||
<translation>No valid selection</translation>
|
<translation>No valid selection</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>SMESH_BAD_MESH_SELECTION</source>
|
||||||
|
<translation>No valid mesh selection</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>SMESH_BOUNDARYEDGES</source>
|
<source>SMESH_BOUNDARYEDGES</source>
|
||||||
<translation>Boundary Edges</translation>
|
<translation>Boundary Edges</translation>
|
||||||
|
Loading…
Reference in New Issue
Block a user