-// SMESH SMESHGUI : GUI for SMESH component
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// SMESH SMESHGUI : GUI for SMESH component
// File : SMESHGUI.cxx
// Author : Nicolas REJNERI
// Module : SMESH
#include "SMESHGUI_MakeNodeAtPointDlg.h"
#include "SMESHGUI_BuildCompoundDlg.h"
#include "SMESHGUI_ComputeDlg.h"
+#include "SMESHGUI_FileInfoDlg.h"
+#include "SMESHGUI_GroupOnShapeDlg.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_GEOMGenUtils.h"
#include "SALOMEconfig.h"
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
-#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
+#include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
// QT Includes
#define INCLUDE_MENUITEM_DEF
// Definitions
//=============================================================
- void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
- int theCommandID)
+ void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
+ int theCommandID )
{
QStringList filter;
string myExtension;
- if(theCommandID == 113){
- filter.append(QObject::tr("MED files (*.med)"));
- filter.append(QObject::tr("All files (*)"));
- }else if (theCommandID == 112){
- filter.append(QObject::tr("IDEAS files (*.unv)"));
- }else if (theCommandID == 111){
- filter.append(QObject::tr("DAT files (*.dat)"));
+ if ( theCommandID == 113 ) {
+ filter.append( QObject::tr( "MED files (*.med)" ) );
+ filter.append( QObject::tr( "All files (*)" ) );
+ }
+ else if ( theCommandID == 112 ) {
+ filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
+ }
+ else if ( theCommandID == 111 ) {
+ filter.append( QObject::tr( "DAT files (*.dat)" ) );
}
QString anInitialPath = "";
- //if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
- // anInitialPath = QDir::currentDirPath();
-
- QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
- anInitialPath,
- filter,
- QObject::tr("Import mesh"),
- true);
- if(!filename.isEmpty()) {
+ if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
+ anInitialPath = QDir::currentDirPath();
+
+ QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
+ anInitialPath,
+ filter,
+ 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;
- switch ( theCommandID ) {
- case 112:
- {
- aMeshes->length( 1 );
- aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
- break;
- }
- case 113:
- {
- 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();
+ 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 ) {
+ errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
+ arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ) ) ) );
+ }
+ break;
}
- 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 ) {
_PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
_PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
- aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
+ 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;
+ }
}
+ }
- if ( isEmpty ) {
- wc.suspend();
- SUIT_MessageBox::warn1(SMESHGUI::desktop(),
- QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_DRS_EMPTY"),
- QObject::tr("SMESH_BUT_OK"));
- wc.resume();
- }
-
- SMESHGUI::GetSMESHGUI()->updateObjBrowser();
+ // 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" ) );
}
- catch (const SALOME::SALOME_Exception& S_ex){
- wc.suspend();
- SalomeApp_Tools::QtCatchCorbaException(S_ex);
- wc.resume();
+
+ // show warning message box, if some imported mesh is empty
+ if ( isEmpty ) {
+ SUIT_MessageBox::warn1( SMESHGUI::desktop(),
+ QObject::tr( "SMESH_WRN_WARNING" ),
+ QObject::tr( "SMESH_DRS_SOME_EMPTY" ),
+ QObject::tr( "SMESH_BUT_OK" ) );
}
}
}
-
void ExportMeshToFile( int theCommandID )
{
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
if( aSel )
aSel->selectedObjects( selected );
- if(selected.Extent()){
- Handle(SALOME_InteractiveObject) anIObject = selected.First();
- SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
- if ( !aMesh->_is_nil() ) {
- QString aFilter, aTitle = QObject::tr("Export mesh");
- QMap<QString, SMESH::MED_VERSION> aFilterMap;
- QMap<QString, int> aFilterMapSTL;
- switch ( theCommandID ) {
- case 125:
- case 122:
- {
- 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;
- }
- // 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::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;
- case 140:
- case 141:
- {
- // export STL
- /*
- there must be check on others mesh elements not equal triangles
- */
- if (aMesh->NbTriangles() < 1) {
- SUIT_MessageBox::warn1
- (SMESHGUI::desktop(),
- QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
- QObject::tr("SMESH_BUT_OK"));
- return;
- }
- if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
- int aRet = SUIT_MessageBox::warn2
- (SMESHGUI::desktop(),
- QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
- QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
- 0, 1, 0);
- if (aRet)
- return;
- }
+ SMESH::SMESH_Mesh_var aMesh;
+ if(selected.Extent() == 1)
+ aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(selected.First());
+ if ( aMesh->_is_nil() ) {
+ SUIT_MessageBox::warn1( SMESHGUI::desktop(),
+ QObject::tr( "SMESH_WRN_WARNING" ),
+ QObject::tr( "SMESH_BAD_MESH_SELECTION" ),
+ QObject::tr( "SMESH_BUT_OK" ) );
+ return;
+ }
- aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
- aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
- }
- break;
- default:
- return;
- }
+ Handle(SALOME_InteractiveObject) anIObject = selected.First();
+ QString aFilter, aTitle = QObject::tr("Export mesh");
+ QMap<QString, SMESH::MED_VERSION> aFilterMap;
+ QMap<QString, int> aFilterMapSTL;
+ switch ( theCommandID ) {
+ case 125:
+ case 122:
+ {
+ 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;
+ }
+ // 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::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;
+ case 140:
+ case 141:
+ {
+ // export STL
+ /*
+ there must be check on others mesh elements not equal triangles
+ */
+ if (aMesh->NbTriangles() < 1) {
+ SUIT_MessageBox::warn1
+ (SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
+ QObject::tr("SMESH_BUT_OK"));
+ return;
+ }
+ if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
+ int aRet = SUIT_MessageBox::warn2
+ (SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
+ QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
+ 0, 1, 0);
+ if (aRet)
+ return;
+ }
- QString aFilename;
- SMESH::MED_VERSION aFormat;
- // Init the parameter with the default value
- bool aIsASCII_STL = true;
- bool toCreateGroups = false;
- SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
- if ( resMgr )
- toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
-
- if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
-
- aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
-
- else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
- QStringList filters;
- QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
- for ( ; it != aFilterMapSTL.end(); ++it )
- filters.push_back( it.key() );
-
- SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
- fd->setCaption( aTitle );
- fd->setFilters( filters );
- fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
- bool is_ok = false;
- while (!is_ok) {
- 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.data() == SMESH::MED_V2_2)
- aDefaultFilter = it.key();
- }
+ aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
+ aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
+ }
+ break;
+ default:
+ return;
+ }
- //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->setSelectedFilter(aDefaultFilter);
- 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 || 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;
- }
- }
+ QString aFilename;
+ SMESH::MED_VERSION aFormat;
+ // Init the parameter with the default value
+ bool aIsASCII_STL = true;
+ bool toCreateGroups = false;
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ if ( resMgr )
+ toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
+
+ QString anInitialPath = "";
+ if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
+ anInitialPath = QDir::currentDirPath();
+
+ if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
+ if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
+ aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
+ aFilter, aTitle, false);
+ }
+ else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
+ QStringList filters;
+ QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
+ for ( ; it != aFilterMapSTL.end(); ++it )
+ filters.push_back( it.key() );
+
+ SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
+ fd->setCaption( aTitle );
+ fd->setFilters( filters );
+ fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
+ if ( !anInitialPath.isEmpty() )
+ fd->setDir( anInitialPath );
+ fd->setSelection(anIObject->getName());
+ bool is_ok = false;
+ while (!is_ok) {
+ 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.data() == 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->setCaption( aTitle );
+ fd->setFilters( filters );
+ //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
+ fd->setSelectedFilter(aDefaultFilter);
+ fd->SetChecked(toCreateGroups);
+ if ( !anInitialPath.isEmpty() )
+ fd->setDir( anInitialPath );
+ fd->setSelection(anIObject->getName());
+ 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 || 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 );
- 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.latin1(), toCreateGroups, aFormat );
- break;
- case 124:
- case 121:
- aMesh->ExportDAT( aFilename.latin1() );
- break;
- case 126:
- case 123:
- aMesh->ExportUNV( aFilename.latin1() );
- break;
- case 140:
- case 141:
- aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
- break;
- default:
- break;
- }
- }
- catch (const SALOME::SALOME_Exception& S_ex){
- wc.suspend();
- SUIT_MessageBox::warn1(SMESHGUI::desktop(),
- QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_EXPORT_FAILED"),
- QObject::tr("SMESH_BUT_OK"));
- wc.resume();
- }
- }
+ }
+ 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.latin1(), toCreateGroups, aFormat );
+ break;
+ case 124:
+ case 121:
+ aMesh->ExportDAT( aFilename.latin1() );
+ break;
+ case 126:
+ case 123:
+ aMesh->ExportUNV( aFilename.latin1() );
+ break;
+ case 140:
+ case 141:
+ aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
+ break;
+ default:
+ break;
+ }
+ }
+ catch (const SALOME::SALOME_Exception& S_ex){
+ wc.suspend();
+ SUIT_MessageBox::warn1(SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_FAILED"),
+ QObject::tr("SMESH_BUT_OK"));
+ wc.resume();
}
}
}
LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeIOR) anIOR;
+
+ int objectCount = 0;
+ QString aNameList;
QString aParentComponent = QString::null;
+ Handle(SALOME_InteractiveObject) anIO;
for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
{
+ anIO = anIt.Value();
QString cur = anIt.Value()->getComponentDataType();
+ _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
+ if (aSO) {
+ // check if object is reference
+ _PTR(SObject) aRefSObj;
+ aNameList.append("\n - ");
+ if ( aSO->ReferencedObject( aRefSObj ) ) {
+ QString aRefName = aRefSObj->GetName();
+ aNameList.append( aRefName );
+ cur = aRefSObj->GetFatherComponent()->ComponentDataType();
+ }
+ else
+ aNameList.append(anIO->getName());
+ objectCount++;
+ }
+
if( aParentComponent.isNull() )
aParentComponent = cur;
else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
aParentComponent = "";
}
+ if ( objectCount == 0 )
+ return; // No Valid Objects Selected
+
if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
QObject::tr("ERR_ERROR"),
if (SUIT_MessageBox::warn2
(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_REALLY_DELETE"),
+ QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
return;
SUIT_ViewManager* vm = anApp->activeViewManager();
int nbSf = vm->getViewsCount();
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
- _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
- _PTR(GenericAttribute) anAttr;
- _PTR(AttributeIOR) anIOR;
-
SALOME_ListIteratorOfListIO It(selected);
aStudyBuilder->NewCommand(); // There is a transaction
if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
continue;
}
+ //Check the referenced object
+ _PTR(SObject) refobj;
+ if ( aSO && aSO->ReferencedObject( refobj ) )
+ aSO = refobj; // Delete main Object instead of reference
// put the whole hierarchy of sub-objects of the selected SO into a list and
// then treat them all starting from the deepest objects (at list back)
break;
}
+ case 150: //MED FILE INFORMATION
+ {
+ SALOME_ListIO selected;
+ LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+ if( aSel )
+ aSel->selectedObjects( selected );
+ if( selected.Extent() )
+ {
+ Handle(SALOME_InteractiveObject) anIObject = selected.First();
+ SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
+ if ( !aMesh->_is_nil() )
+ {
+ SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
+ dlg.exec();
+ }
+ }
+ break;
+ }
case 122: // EXPORT MED
case 121:
case 123:
}*/
break;
}
+ case 806: // CREATE GEO GROUP
+ {
+ startOperation( 806 );
+ break;
+ }
case 801: // CREATE GROUP
{
if ( !vtkwnd )
if ( !aHypothesis->_is_nil() )
{
CORBA::String_var aHypType = aHypothesis->GetName();
- SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
- if (aCreator)
+ // BUG 0020378
+ //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
+ SMESH::HypothesisCreatorPtr aCreator = SMESH::GetHypothesisCreator(aHypType);
+ if (aCreator) {
aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
- else
- {
+ }
+ else {
// report error
}
}
aMesh->Clear();
_PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
SMESH::ModifiedMesh( aMeshSObj, false, true);
+ // hide groups and submeshes
+ _PTR(ChildIterator) anIter =
+ SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
+ for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
+ {
+ _PTR(SObject) so = anIter->Value();
+ SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
+ }
}
catch (const SALOME::SALOME_Exception& S_ex){
wc.suspend();
createSMESHAction( 125, "EXPORT_MED" );
createSMESHAction( 126, "EXPORT_UNV" );
createSMESHAction( 141, "EXPORT_STL" );
+ createSMESHAction( 150, "FILE_INFO" );
createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
createSMESHAction( 5105, "SEL_FILTER_LIB" );
createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
+ createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_GEO_GROUP" );
createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
createMenu( 701, meshId, -1 );
createMenu( separator(), meshId, -1 );
createMenu( 801, meshId, -1 );
+ createMenu( 806, meshId, -1 );
createMenu( 802, meshId, -1 );
createMenu( 803, meshId, -1 );
createMenu( separator(), meshId, -1 );
createTool( 701, meshTb );
createTool( separator(), meshTb );
createTool( 801, meshTb );
+ createTool( 806, meshTb );
createTool( 802, meshTb );
createTool( 803, meshTb );
createTool( separator(), meshTb );
// popup for object browser
+ createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
+
createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
createPopupItem( 803, OB, group ); // EDIT_GROUP
createPopupItem( 903, OB, mesh_group ); // WHAT_IS
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 801, OB, mesh ); // CREATE_GROUP
+ createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
// Clipping
//-------------------------------------------------
popupMgr()->insert( action( 1134 ), -1, -1 );
- popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
+ popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", true );
popupMgr()->insert( separator(), -1, -1 );
action( 33)->setEnabled(true); // Delete: Key_Delete
action(1101)->setEnabled(true); // Rename: Key_F2
+ // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
+ GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
+ if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
+ if ( _PTR(Study) aStudy = s->studyDS()) {
+ GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
+ updateObjBrowser(); // objects can be removed
+ }
+
return res;
}
case 704: // Edit mesh/sub-mesh
op = new SMESHGUI_MeshOp( false );
break;
+ case 806: // Create group on geom
+ op = new SMESHGUI_GroupOnShapeOp();
+ break;
case 417: //convert to quadratic
op = new SMESHGUI_ConvToQuadOp();
break;