_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
QStringList errors;
+ QStringList anEntryList;
bool isEmpty = false;
for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
QString filename = *it;
if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
+ anEntryList.append( aMeshSO->GetID().c_str() );
+
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// update Object browser
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
+ // browse to the published meshes
+ if( LightApp_Application* anApp =
+ dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+ anApp->browseObjects( anEntryList );
+
// show Error message box if there were errors
if ( errors.count() > 0 ) {
SUIT_MessageBox::critical( SMESHGUI::desktop(),
}
}
// PAL18696
- QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
+ //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
- aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
+ //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
}
break;
SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
// create group for each type o elements
QString aName = IObject->getName();
+ QStringList anEntryList;
if (aNodes->length() > 0) {
SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
aGroup->Add(aNodes.inout());
+ if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
+ anEntryList.append( aSObject->GetID().c_str() );
}
if (aEdges->length() > 0) {
SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
aGroup->Add(aEdges.inout());
+ if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
+ anEntryList.append( aSObject->GetID().c_str() );
}
if (aFaces->length() > 0) {
SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
aGroup->Add(aFaces.inout());
+ if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
+ anEntryList.append( aSObject->GetID().c_str() );
}
if (aVolumes->length() > 0) {
SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
aGroup->Add(aVolumes.inout());
+ if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
+ anEntryList.append( aSObject->GetID().c_str() );
}
updateObjBrowser();
-
+ anApp->browseObjects( anEntryList );
}
catch(const SALOME::SALOME_Exception & S_ex){
SalomeApp_Tools::QtCatchCorbaException(S_ex);
}
break;
}
-
- case 1101: // RENAME
- {
- if ( checkLock( aStudy ) )
- break;
-
- LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
- SALOME_ListIO selected;
- if( aSel )
- aSel->selectedObjects( selected );
-
- bool isAny = false; // is there any appropriate object selected
-
- SALOME_ListIteratorOfListIO It( selected );
- for ( ; It.More(); It.Next() )
- {
- Handle(SALOME_InteractiveObject) IObject = It.Value();
- _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
- _PTR(GenericAttribute) anAttr;
- _PTR(AttributeName) aName;
- if ( obj )
- {
- if ( obj->FindAttribute(anAttr, "AttributeName") )
- {
- aName = anAttr;
- QString newName = QString(aName->Value().c_str());
-
- // check type to prevent renaming of inappropriate objects
- int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
- if (aType == MESH || aType == GROUP ||
- aType == SUBMESH || aType == SUBMESH_COMPOUND ||
- aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
- aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
- aType == HYPOTHESIS || aType == ALGORITHM)
- {
- isAny = true;
- newName = LightApp_NameDlg::getName(desktop(), newName);
- if ( !newName.isEmpty() )
- {
- SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
-
- // update name of group object and its actor
- SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
- if( !aGroupObject->_is_nil() )
- {
- aGroupObject->SetName( newName.toLatin1().data() );
- if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
- anActor->setName( newName.toLatin1().data() );
- }
-
- updateObjBrowser();
- }
- }
- }
- }
- } // for
-
- if (!isAny) {
- SUIT_MessageBox::warning(desktop(),
- QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
- }
- break;
- }
-
case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
{
if(checkLock(aStudy)) break;
createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
//createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
- createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
+ //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
createSMESHAction( 1100, "EDIT_HYPO" );
- createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
createSMESHAction( 1102, "UNASSIGN" );
createSMESHAction( 9010, "NUM_NODES", "", 0, true );
createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
createMenu( separator(), meshId, -1 );
createMenu( 900, meshId, -1 );
//createMenu( 902, meshId, -1 );
- createMenu( 903, meshId, -1 );
+ //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
createMenu( 904, meshId, -1 );
createMenu( separator(), meshId, -1 );
createTool( separator(), meshTb );
createTool( 900, meshTb );
//createTool( 902, meshTb );
- createTool( 903, meshTb );
+ //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
createTool( 904, meshTb );
createTool( separator(), meshTb );
createPopupItem( 214, OB, mesh_group ); // UPDATE
createPopupItem( 900, OB, mesh_group ); // ADV_INFO
//createPopupItem( 902, OB, mesh ); // STD_INFO
- createPopupItem( 903, OB, mesh_group ); // WHAT_IS
+ //createPopupItem( 903, OB, mesh_group ); // WHAT_IS // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
createPopupItem( 904, OB, mesh ); // FIND_ELEM
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 801, OB, mesh ); // CREATE_GROUP
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
- createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 214, View, mesh_group ); // UPDATE
createPopupItem( 900, View, mesh_group ); // ADV_INFO
//createPopupItem( 902, View, mesh ); // STD_INFO
- createPopupItem( 903, View, mesh_group ); // WHAT_IS
+ //createPopupItem( 903, View, mesh_group ); // WHAT_IS // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
createPopupItem( 904, View, mesh ); // FIND_ELEM
popupMgr()->insert( separator(), -1, 0 );
// import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
PyGILState_STATE gstate = PyGILState_Ensure();
- PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
+ PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
if(pluginsmanager==NULL)
PyErr_Print();
else
action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
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());
action(113)->setShortcut(QKeySequence()); // Import MED
action( 33)->setEnabled(false); // Delete: Key_Delete
- action(1101)->setEnabled(false); // Rename: Key_F2
return SalomeApp_Module::deactivateModule( study );
}
//================================================================================
void SMESHGUI::update( const int flags )
{
- if ( flags & UF_Viewer | flags & UF_Forced )
+ if ( (flags & UF_Viewer) | (flags & UF_Forced) )
SMESH::UpdateView();
else
SalomeApp_Module::update( flags );
}
}
+/*!
+ \brief Return \c true if object can be renamed
+*/
+bool SMESHGUI::renameAllowed( const QString& entry) const {
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
+ if( !anApp )
+ return false;
+
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
+ if( !aStudy )
+ return false;
+
+ bool appRes = SalomeApp_Module::renameAllowed(entry);
+ if( !appRes )
+ return false;
+
+ // check type to prevent renaming of inappropriate objects
+ int aType = SMESHGUI_Selection::type(qPrintable(entry), aStudy);
+ if (aType == MESH || aType == GROUP ||
+ aType == SUBMESH || aType == SUBMESH_COMPOUND ||
+ aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
+ aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
+ aType == HYPOTHESIS || aType == ALGORITHM)
+ return true;
+
+ return false;
+}
+
+/*!
+ Rename object by entry.
+ \param entry entry of the object
+ \param name new name of the object
+ \brief Return \c true if rename operation finished successfully, \c false otherwise.
+*/
+bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
+
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
+ if( !anApp )
+ return false;
+
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
+ if( !aStudy )
+ return false;
+
+ bool appRes = SalomeApp_Module::renameObject(entry,name);
+ if( !appRes )
+ return false;
+
+ _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeName) aName;
+ if ( obj ) {
+ if ( obj->FindAttribute(anAttr, "AttributeName") ) {
+ aName = anAttr;
+ // check type to prevent renaming of inappropriate objects
+ int aType = SMESHGUI_Selection::type( qPrintable(entry), aStudy );
+ if (aType == MESH || aType == GROUP ||
+ aType == SUBMESH || aType == SUBMESH_COMPOUND ||
+ aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
+ aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
+ aType == HYPOTHESIS || aType == ALGORITHM) {
+ if ( !name.isEmpty() ) {
+ SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
+
+ // update name of group object and its actor
+ Handle(SALOME_InteractiveObject) IObject =
+ new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
+
+ SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
+ if( !aGroupObject->_is_nil() ) {
+ aGroupObject->SetName( qPrintable(name) );
+ if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
+ anActor->setName( qPrintable(name) );
+ }
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}