+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ LineEditC1A2->setText( QString(aName->Value()) ) ;
+ }
+ }
+ }
+}
+
+//=================================================================================
+// function : UpdateControlState()
+// purpose :
+//=================================================================================
+void SMESHGUI_EditHypothesesDlg::UpdateControlState()
+{
+ bool isEnabled = ( !myMesh ->_is_nil() && !myGeomShape->_is_nil() && ListHypAssignation->count() && ListAlgoAssignation->count() ) ||
+ ( !mySubMesh->_is_nil() && !myGeomShape->_is_nil() && ( ListHypAssignation->count() || ListAlgoAssignation->count() ) );
+
+ buttonOk ->setEnabled( isEnabled && !myImportedMesh );
+ buttonApply->setEnabled( isEnabled && !myImportedMesh );
+
+ SelectButtonC1A2 ->setEnabled( ALLOW_CHANGE_SHAPE && !myImportedMesh );
+ LineEditC1A2 ->setEnabled( ALLOW_CHANGE_SHAPE && !myImportedMesh );
+ ListHypDefinition ->setEnabled( !myImportedMesh );
+ ListHypAssignation ->setEnabled( !myImportedMesh );
+ ListAlgoDefinition ->setEnabled( !myImportedMesh );
+ ListAlgoAssignation->setEnabled( !myImportedMesh );
+}
+
+//=================================================================================
+// function : StoreMesh()
+// purpose :
+//=================================================================================
+bool SMESHGUI_EditHypothesesDlg::StoreMesh()
+{
+ SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
+ MapIOR anOldHypos, aNewHypos;
+ if ( myGeomShape->_is_nil() )
+ return false;
+ // 1. Check whether the geometric shape has changed
+ SALOMEDS::SObject_var aMeshSO = myStudyAPI.FindObject( myMesh );
+ GEOM::GEOM_Shape_var aIniGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh( aMeshSO );
+ bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent( myGeomShape );
+ if ( bShapeChanged ) {
+ // VSR : TODO : Set new shape - not supported yet by SMESH engine
+ // 1) remove all old hypotheses and algorithms and also submeshes
+ // 2) set new shape
+ }
+ MapIOR::iterator it;
+ // 2. remove not used hypotheses from the mesh
+ for ( it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it ) {
+ string ior = it->first;
+ int index = findItem( ListHypAssignation, ior );
+ if ( index < 0 ) {
+ CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+ if ( !CORBA::is_nil( anObject ) ) {
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+ if ( !aHyp->_is_nil() )
+ if ( !mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh( aMeshSO, aHyp ) )
+ return false;
+ }
+ }
+ }
+ // 3. remove not used algorithms from the mesh
+ for ( it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it ) {
+ string ior = it->first;
+ int index = findItem( ListAlgoAssignation, ior );
+ if ( index < 0 ) {
+ CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+ if ( !CORBA::is_nil( anObject ) ) {
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+ if ( !aHyp->_is_nil() )
+ if ( !mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh( aMeshSO, aHyp ) )
+ return false;
+ }
+ }
+ }
+ // 4. Add new hypotheses
+ for ( int i = 0; i < ListHypAssignation->count(); i++ ) {
+ if ( ListHypAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) {
+ ListBoxIOR* anItem = ( ListBoxIOR* )( ListHypAssignation->item( i ) );
+ if ( anItem ) {
+ string ior = anItem->GetIOR();
+ if ( myMapOldHypos.find( ior ) == myMapOldHypos.end() ) {
+ CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+ if ( !CORBA::is_nil( anObject ) ) {
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+ if ( !aHyp->_is_nil() )
+ if ( !mySMESHGUI->AddHypothesisOnMesh( myMesh, aHyp ) )
+ return false;
+ }
+ }
+ }
+ }
+ }
+ // 4. Add new algorithms
+ for ( int i = 0; i < ListAlgoAssignation->count(); i++ ) {
+ if ( ListAlgoAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) {
+ ListBoxIOR* anItem = ( ListBoxIOR* )( ListAlgoAssignation->item( i ) );
+ if ( anItem ) {
+ string ior = anItem->GetIOR();
+ if ( myMapOldAlgos.find( ior ) == myMapOldAlgos.end() ) {
+ CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+ if ( !CORBA::is_nil( anObject ) ) {
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+ if ( !aHyp->_is_nil() )
+ if ( !mySMESHGUI->AddAlgorithmOnMesh( myMesh, aHyp ) )
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+}
+
+//=================================================================================
+// function : StoreSubMesh()
+// purpose :
+//=================================================================================
+bool SMESHGUI_EditHypothesesDlg::StoreSubMesh()
+{
+ SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
+ MapIOR anOldHypos, aNewHypos;
+ if ( myGeomShape->_is_nil() )
+ return false;
+ // 1. Check whether the geometric shape has changed
+ SALOMEDS::SObject_var aSubMeshSO = myStudyAPI.FindObject( mySubMesh );
+ GEOM::GEOM_Shape_var aIniGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh( aSubMeshSO );
+ bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent( myGeomShape );
+ if ( bShapeChanged ) {
+ // VSR : TODO : Set new shape - not supported yet by engine
+ // 1) remove all old hypotheses and algorithms
+ // 2) set new shape
+ }
+ MapIOR::iterator it;
+ // 2. remove not used hypotheses from the submesh
+ for ( it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it ) {
+ string ior = it->first;
+ int index = findItem( ListHypAssignation, ior );
+ if ( index < 0 ) {
+ CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+ if ( !CORBA::is_nil( anObject ) ) {
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+ if ( !aHyp->_is_nil() )
+ if ( !mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh( aSubMeshSO, aHyp ) )
+ return false;
+ }
+ }
+ }
+ // 3. remove not used algorithms from the submesh
+ for ( it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it ) {
+ string ior = it->first;
+ int index = findItem( ListAlgoAssignation, ior );
+ if ( index < 0 ) {
+ CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+ if ( !CORBA::is_nil( anObject ) ) {
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+ if ( !aHyp->_is_nil() )
+ if ( !mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh( aSubMeshSO, aHyp ) )
+ return false;
+ }
+ }
+ }
+ // 4. Add new hypotheses
+ for ( int i = 0; i < ListHypAssignation->count(); i++ ) {
+ if ( ListHypAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) {
+ ListBoxIOR* anItem = ( ListBoxIOR* )( ListHypAssignation->item( i ) );
+ if ( anItem ) {
+ string ior = anItem->GetIOR();
+ if ( myMapOldHypos.find( ior ) == myMapOldHypos.end() ) {
+ CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+ if ( !CORBA::is_nil( anObject ) ) {
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+ if ( !aHyp->_is_nil() )
+ if ( !mySMESHGUI->AddHypothesisOnSubMesh( mySubMesh, aHyp ) )
+ return false;
+ }
+ }
+ }
+ }
+ }
+ // 4. Add new algorithms
+ for ( int i = 0; i < ListAlgoAssignation->count(); i++ ) {
+ if ( ListAlgoAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) {
+ ListBoxIOR* anItem = ( ListBoxIOR* )( ListAlgoAssignation->item( i ) );
+ if ( anItem ) {
+ string ior = anItem->GetIOR();
+ if ( myMapOldAlgos.find( ior ) == myMapOldAlgos.end() ) {
+ CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+ if ( !CORBA::is_nil( anObject ) ) {
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+ if ( !aHyp->_is_nil() )
+ if ( !mySMESHGUI->AddAlgorithmOnSubMesh( mySubMesh, aHyp ) )
+ return false;
+ }
+ }