group.</li>
</ol>
+\n <em>To convert an existing group on geometry into standalone group
+of elements and modify:</em>
+<ol>
+<li>Select your group on geometry in the Object Browser and in the \b Mesh menu click
+the <b>Edit Group as Standalone</b> item.</li>
+
+\image html image74.gif
+<center><em>"Edit Group as Standalone" button</em></center>
+
+The group on geometry will be converted into standalone group and can
+be modified as group of elements
+<li>Click the \b Apply or <b>Apply and Close</b> button to confirm modification of the
+group.</li>
+
<br><b>See Also</b> a sample TUI Script of an
\ref tui_edit_group "Edit Group" operation.
-*/
\ No newline at end of file
+*/
in string name )
raises (SALOME::SALOME_Exception);
+ /*!
+ * Convert group on geometry into standalone group
+ */
+ SMESH_Group ConvertToStandalone( in SMESH_GroupOnGeom theGeomGroup )
+ raises (SALOME::SALOME_Exception);
+
/*!
* Add hypothesis to the mesh, under a particular subShape
* (or the main shape itself)
{
return _myMeshDS->GetElementType( id, iselem );
}
+
+//=============================================================================
+/*!
+ * \brief Convert group on geometry into standalone group
+ */
+//=============================================================================
+
+SMESH_Group* SMESH_Mesh::ConvertToStandalone ( int theGroupID )
+{
+ SMESH_Group* aGroup = 0;
+ std::map < int, SMESH_Group * >::iterator itg = _mapGroup.find( theGroupID );
+ if ( itg == _mapGroup.end() )
+ return aGroup;
+
+ SMESH_Group* anOldGrp = (*itg).second;
+ SMESHDS_GroupBase* anOldGrpDS = anOldGrp->GetGroupDS();
+ if ( !anOldGrp || !anOldGrpDS )
+ return aGroup;
+
+ // create new standalone group
+ aGroup = new SMESH_Group (theGroupID, this, anOldGrpDS->GetType(), anOldGrp->GetName() );
+ _mapGroup[theGroupID] = aGroup;
+
+ SMESHDS_Group* aNewGrpDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
+ GetMeshDS()->RemoveGroup( anOldGrpDS );
+ GetMeshDS()->AddGroup( aNewGrpDS );
+
+ // add elements (or nodes) into new created group
+ SMDS_ElemIteratorPtr anItr = anOldGrpDS->GetElements();
+ while ( anItr->more() )
+ aNewGrpDS->Add( (anItr->next())->GetID() );
+
+ // remove old group
+ delete anOldGrp;
+
+ return aGroup;
+}
+
void RemoveGroup (const int theGroupID);
+ SMESH_Group* ConvertToStandalone ( int theGroupID );
SMDSAbs_ElementType GetElementType( const int id, const bool iselem );
break;
}
+ case 815: // Edit GEOM GROUP as standalone
+ {
+ if ( !vtkwnd )
+ {
+ SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
+ tr( "NOT_A_VTK_VIEWER" ) );
+ break;
+ }
+
+ if(checkLock(aStudy)) break;
+ EmitSignalDeactivateDialog();
+
+ LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+ SALOME_ListIO selected;
+ if( aSel )
+ aSel->selectedObjects( selected );
+
+ SALOME_ListIteratorOfListIO It (selected);
+ for ( ; It.More(); It.Next() )
+ {
+ SMESH::SMESH_GroupOnGeom_var aGroup =
+ SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
+ if (!aGroup->_is_nil()) {
+ SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
+ aDlg->show();
+ }
+ }
+ break;
+ }
+
case 810: // Union Groups
case 811: // Intersect groups
case 812: // Cut groups
createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
+ createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
createSMESHAction( 804, "ADD" );
createSMESHAction( 805, "REMOVE" );
createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
createMenu( 806, meshId, -1 );
createMenu( 802, meshId, -1 );
createMenu( 803, meshId, -1 );
+ createMenu( 815, meshId, -1 );
createMenu( separator(), meshId, -1 );
createMenu( 810, meshId, -1 );
createMenu( 811, meshId, -1 );
createTool( 806, meshTb );
createTool( 802, meshTb );
createTool( 803, meshTb );
+ //createTool( 815, meshTb );
createTool( separator(), meshTb );
createTool( 900, meshTb );
createTool( 902, meshTb );
createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
createPopupItem( 803, OB, group ); // EDIT_GROUP
+ createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
+
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
createPopupItem( 711, OB, mesh, "&& isComputable" ); // PRECOMPUTE
createPopupItem( 803, View, group ); // EDIT_GROUP
createPopupItem( 804, View, elems ); // ADD
createPopupItem( 805, View, elems ); // REMOVE
+
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 214, View, mesh_group ); // UPDATE
createPopupItem( 900, View, mesh_group ); // ADV_INFO
// purpose :
//=================================================================================
SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule,
- SMESH::SMESH_GroupBase_ptr theGroup )
+ SMESH::SMESH_GroupBase_ptr theGroup,
+ const bool theIsConvert )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
{
initDialog( false );
if ( !theGroup->_is_nil() )
- init( theGroup );
+ init( theGroup, theIsConvert );
else
{
mySelectSubMesh->setEnabled( false );
// function : Init()
// purpose :
//=================================================================================
-void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
+void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup,
+ const bool theIsConvert)
{
restoreShowEntityMode();
myMesh = theGroup->GetMesh();
myTypeGroup->button(aType)->setChecked(true);
myGroup = SMESH::SMESH_Group::_narrow( theGroup );
+ myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
- if (!myGroup->_is_nil())
- {
- // NPAL19389: create a group with a selection in another group
- // set actor of myMesh, if it is visible, else set
- // actor of myGroup, if it is visible, else try
- // any visible actor of group or submesh of myMesh
- // commented, because an attempt to set selection on not displayed cells leads to error
- //SetAppropriateActor();
- myActor = SMESH::FindActorByObject(myMesh);
- if ( !myActor )
- myActor = SMESH::FindActorByObject(myGroup);
- SMESH::SetPickable(myActor);
+ if (myGroup->_is_nil() && myGroupOnGeom->_is_nil())
+ return;
+
+ // NPAL19389: create a group with a selection in another group
+ // set actor of myMesh, if it is visible, else set
+ // actor of theGroup, if it is visible, else try
+ // any visible actor of group or submesh of myMesh
+ // commented, because an attempt to set selection on not displayed cells leads to error
+ //SetAppropriateActor();
+ myActor = SMESH::FindActorByObject(myMesh);
+ if ( !myActor )
+ myActor = SMESH::FindActorByObject(theGroup);
+ SMESH::SetPickable(myActor);
- myGrpTypeGroup->button(0)->setChecked(true);
- onGrpTypeChanged(0);
+ int grpType = (!myGroup->_is_nil() ? 0 : (theIsConvert ? 0 : 1));
+ myGrpTypeGroup->button(grpType)->setChecked(true);
+ onGrpTypeChanged(grpType);
+ if ( grpType == 0 ) {
myCurrentLineEdit = 0;
myElements->clear();
setSelectionMode(aType);
setShowEntityMode(); // depends on myTypeId
myIdList.clear();
- if (!myGroup->IsEmpty()) {
- SMESH::long_array_var anElements = myGroup->GetListOfID();
+ if (!theGroup->IsEmpty()) {
+ SMESH::long_array_var anElements = theGroup->GetListOfID();
int k = anElements->length();
for (int i = 0; i < k; i++) {
myIdList.append(anElements[i]);
}
else
{
- myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
-
- if ( !myGroupOnGeom->_is_nil() )
+ QString aShapeName( "" );
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
+ if (!aGroupShape->_is_nil())
{
- // NPAL19389: create a group with a selection in another group
- // set actor of myMesh, if it is visible, else set
- // actor of myGroupOnGeom, if it is visible, else try
- // any visible actor of group or submesh of myMesh
- // commented, because an attempt to set selection on not displayed cells leads to error
- //SetAppropriateActor();
- myActor = SMESH::FindActorByObject(myMesh);
- if ( !myActor )
- myActor = SMESH::FindActorByObject(myGroupOnGeom);
- SMESH::SetPickable(myActor);
-
- myGrpTypeGroup->button(1)->setChecked(true);
- onGrpTypeChanged(1);
-
- QString aShapeName( "" );
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
- GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
- if (!aGroupShape->_is_nil())
- {
- _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
- aShapeName = aGroupShapeSO->GetName().c_str();
- }
- myGeomGroupLine->setText( aShapeName );
- myNameChanged = true;
- myName->blockSignals(true);
- myName->setText( "Group On " + aShapeName);
- myName->blockSignals(false);
+ _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
+ aShapeName = aGroupShapeSO->GetName().c_str();
}
+ myGeomGroupLine->setText( aShapeName );
+ myNameChanged = true;
+ myName->blockSignals(true);
+ myName->setText( "Group On " + aShapeName);
+ myName->blockSignals(false);
}
}
mySelectionMgr->clearSelected();
+ if (myGroup->_is_nil()) { // creation or conversion
+ // check if group on geometry is not null
+ if (!CORBA::is_nil(myGroupOnGeom)) {
+ if (myMesh->_is_nil())
+ return false;
+ myGroup = myMesh->ConvertToStandalone( myGroupOnGeom );
+ // nullify pointer, because object become dead
+ myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
+ }
+ }
+
if (myGroup->_is_nil()) { // creation
if (myMesh->_is_nil())
return false;
SMESHGUI_GroupDlg( SMESHGUI*,
SMESH::SMESH_Mesh_ptr = SMESH::SMESH_Mesh::_nil() );
SMESHGUI_GroupDlg( SMESHGUI*,
- SMESH::SMESH_GroupBase_ptr );
+ SMESH::SMESH_GroupBase_ptr,
+ const bool theIsConvert = false );
~SMESHGUI_GroupDlg();
static QString GetDefaultName( const QString& );
private:
void initDialog( bool );
void init( SMESH::SMESH_Mesh_ptr );
- void init( SMESH::SMESH_GroupBase_ptr );
+ void init( SMESH::SMESH_GroupBase_ptr,
+ const bool theIsConvert = false );
void closeEvent( QCloseEvent* );
void enterEvent( QEvent* );
void hideEvent( QHideEvent* ); /* ESC key */
else if ( p=="hasReference" ) val = QVariant( hasReference( ind ) );
else if ( p=="isImported" ) val = QVariant( isImported( ind ) );
else if ( p=="facesOrientationMode" ) val = QVariant( facesOrientationMode( ind ) );
+ else if ( p=="groupType" ) val = QVariant( groupType( ind ) );
if( val.isValid() )
return val;
*/
return res;
}
+
+//=======================================================================
+//function : groupType
+//purpose :
+//=======================================================================
+
+QString SMESHGUI_Selection::groupType( int ind ) const
+{
+ QString e = entry( ind );
+ _PTR(SObject) SO = SMESH::GetActiveStudyDocument()->FindObjectID( e.toLatin1().constData() );
+ QString type;
+ if( SO )
+ {
+ CORBA::Object_var obj = SMESH::SObjectToObject( SO );
+
+ SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( obj );
+ SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( obj );
+ if( !aGroup->_is_nil() )
+ type = QString( "Group" );
+ else if ( !aGroupOnGeom->_is_nil() )
+ type = QString( "GroupOnGeom" );
+ }
+ return type;
+}
virtual QList<QVariant> entityMode( int ) const;
virtual QString controlMode( int ) const;
virtual QString facesOrientationMode( int ) const;
+ virtual QString groupType( int ) const;
SMESH_Actor* getActor( int ) const;
<source>MEN_EDIT_GROUP</source>
<translation>Edit Group</translation>
</message>
+ <message>
+ <source>MEN_EDIT_GEOMGROUP_AS_GROUP</source>
+ <translation>Edit Group as Standalone</translation>
+ </message>
<message>
<source>MEN_EDIT_HYPO</source>
<translation>Edit Hypothesis</translation>
<source>SMESH_EDIT_GROUP_TITLE</source>
<translation>Edit Group</translation>
</message>
+ <message>
+ <source>SMESH_EDIT_GEOMGROUP_AS_GROUP_TITLE</source>
+ <translation>Edit Group as Standalone</translation>
+ </message>
<message>
<source>SMESH_EDIT_HYPOTHESES</source>
<translation>Hypotheses Assignation</translation>
<source>STB_EDIT_GROUP</source>
<translation>Edit Group</translation>
</message>
+ <message>
+ <source>STB_EDIT_GEOMGROUP_AS_GROUP</source>
+ <translation>Edit Group as Standalone</translation>
+ </message>
<message>
<source>STB_EDIT_HYPO</source>
<translation>Edit Hypothesis</translation>
<source>TOP_EDIT_GROUP</source>
<translation>Edit Group</translation>
</message>
+ <message>
+ <source>TOP_EDIT_GEOMGROUP_AS_GROUP</source>
+ <translation>Edit Group as Standalone</translation>
+ </message>
<message>
<source>TOP_EDIT_HYPO</source>
<translation>Edit Hypothesis</translation>
theCommand->SetArg( 1, grp );
}
else {
- AddMeshAccess( theCommand );
+ _pyID type = theCommand->GetArg( 1 );
+ _pyID name = theCommand->GetArg( 2 );
+ theCommand->SetMethod( "GroupOnGeom" );
+ theCommand->RemoveArgs();
+ theCommand->SetArg( 1, grp );
+ theCommand->SetArg( 2, name );
+ theCommand->SetArg( 3, type );
}
}
// ----------------------------------------------------------------------
"GetNodeInverseElements","GetShapeID","GetShapeIDForElem","GetElemNbNodes",
"GetElemNode","IsMediumNode","IsMediumNodeOfAnyElem","ElemNbEdges","ElemNbFaces",
"IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", "SetAutoColor", "GetAutoColor",
- "Clear"
+ "Clear", "ConvertToStandalone"
,"" }; // <- mark of end
sameMethods.Insert( names );
}
void SMESH_GroupBase_i::SetName( const char* theName )
{
- // Update Python script
- TPythonDump() << _this() << ".SetName( '" << theName << "' )";
-
// Perform renaming
::SMESH_Group* aGroup = GetSmeshGroup();
- if (aGroup) {
- aGroup->SetName(theName);
-
- // Update group name in a study
- SMESH_Gen_i* aGen = myMeshServant->GetGen();
- aGen->SetName( aGen->ObjectToSObject( aGen->GetCurrentStudy(), _this() ), theName );
+ if (!aGroup) {
+ MESSAGE("can't set name of a vague group");
return;
}
- MESSAGE("can't set name of a vague group");
+
+ if ( aGroup->GetName() && !strcmp( aGroup->GetName(), theName ) )
+ return; // nothing to rename
+
+ aGroup->SetName(theName);
+
+ // Update group name in a study
+ SMESH_Gen_i* aGen = myMeshServant->GetGen();
+ aGen->SetName( aGen->ObjectToSObject( aGen->GetCurrentStudy(), _this() ), theName );
+
+ // Update Python script
+ TPythonDump() << _this() << ".SetName( '" << theName << "' )";
}
//=============================================================================
}
}
+//=============================================================================
+/*!
+ * \brief Create standalone group instead if group on geometry
+ *
+ */
+//=============================================================================
+
+SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupOnGeom_ptr theGroup )
+{
+ SMESH::SMESH_Group_var aGroup;
+ if ( theGroup->_is_nil() )
+ return aGroup._retn();
+
+ Unexpect aCatch(SALOME_SalomeException);
+
+ SMESH_GroupBase_i* aGroupToRem =
+ dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( theGroup ).in() );
+ if ( !aGroupToRem )
+ return aGroup._retn();
+
+ int anId = aGroupToRem->GetLocalID();
+ if ( !_impl->ConvertToStandalone( anId ) )
+ return aGroup._retn();
+
+ SMESH_GroupBase_i* aGroupImpl;
+ aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, anId );
+
+
+ // remove old instance of group from own map
+ _mapGroups.erase( anId );
+
+ SALOMEDS::StudyBuilder_var builder;
+ SALOMEDS::SObject_var aGroupSO;
+ SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+ if ( !aStudy->_is_nil() ) {
+ builder = aStudy->NewBuilder();
+ aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup );
+ if ( !aGroupSO->_is_nil() ) {
+
+ // remove reference to geometry
+ SALOMEDS::ChildIterator_var chItr = aStudy->NewChildIterator(aGroupSO);
+ for ( ; chItr->More(); chItr->Next() )
+ // Remove group's child SObject
+ builder->RemoveObject( chItr->Value() );
+
+ // Update Python script
+ TPythonDump() << aGroupSO << " = " << _this() << ".ConvertToStandalone( "
+ << aGroupSO << " )";
+ }
+ }
+
+ // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
+ SMESH_Gen_i::GetPOA()->activate_object( aGroupImpl );
+ aGroupImpl->Register();
+ // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
+
+ // remember new group in own map
+ aGroup = SMESH::SMESH_Group::_narrow( aGroupImpl->_this() );
+ _mapGroups[anId] = SMESH::SMESH_GroupBase::_duplicate( aGroup );
+
+ // register CORBA object for persistence
+ //int nextId = _gen_i->RegisterObject( aGroup );
+ //if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId);
+ builder->SetIOR( aGroupSO, _gen_i->GetORB()->object_to_string( aGroup ) );
+
+ return aGroup._retn();
+}
+
//=============================================================================
/*!
*
throw (SALOME::SALOME_Exception);
+ SMESH::SMESH_Group_ptr ConvertToStandalone( SMESH::SMESH_GroupOnGeom_ptr theGeomGroup );
+
// SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
// throw (SALOME::SALOME_Exception);
return self.mesh.CreateDimGroup(groups, elem_type, name)
+ ## Convert group on geom into standalone group
+ # @ingroup l2_grps_delete
+ def ConvertToStandalone(self, group):
+ return self.mesh.ConvertToStandalone(group)
+
# Get some info about mesh:
# ------------------------