// Module : SMESH
// $Header$
-using namespace std;
#include "SMESHGUI_EditHypothesesDlg.h"
+
#include "SMESHGUI.h"
+#include "SMESHGUI_Utils.h"
+#include "SMESHGUI_GEOMGenUtils.h"
+#include "SMESHGUI_HypothesesUtils.h"
+
#include "SALOME_ListIteratorOfListIO.hxx"
#include "QAD_Application.h"
#include "QAD_WaitCursor.h"
#include "QAD_Operation.h"
+#include "SALOMEconfig.h"
+#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
+
#include "utilities.h"
// QT Includes
#include <qlayout.h>
#include <qpixmap.h>
+using namespace std;
+
//VRV: porting on Qt 3.0.5
#if QT_VERSION >= 0x030005
#include <qlistbox.h>
SelectButtonC1A1->setPixmap( image0 );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
+ LineEditC1A1->setReadOnly( true );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
TextLabelC1A2 = new QLabel( tr( "SMESH_OBJECT_GEOM" ), GroupC1, "TextLabelC1A2" );
SelectButtonC1A2->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
+ LineEditC1A2->setReadOnly( true );
GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupC1, 0, 0 );
myGeomFilter = new SALOME_TypeFilter( "GEOM" );
myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
- myGeomShape = GEOM::GEOM_Shape::_nil();
+ myGeomShape = GEOM::GEOM_Object::_nil();
myMesh = SMESH::SMESH_Mesh::_nil();
mySubMesh = SMESH::SMESH_subMesh::_nil();
//=================================================================================
bool SMESHGUI_EditHypothesesDlg::ClickOnApply()
{
+ if (mySMESHGUI->ActiveStudyLocked())
+ return false;
+
bool aRes = false;
QAD_WaitCursor wc;
else if ( !mySubMesh->_is_nil() )
aRes = StoreSubMesh();
- if ( aRes )
+ if ( true/*aRes*/ ) // abort desynchronizes contents of a Study and a mesh on server
+ {
// commit transaction
op->finish();
+ InitHypAssignation();
+ InitAlgoAssignation();
+ }
else
// abort transaction
op->abort();
+ UpdateControlState();
+
return aRes;
}
{
QString aString = "";
- int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString) ;
if ( myEditCurrentArgument == LineEditC1A1 ) {
if ( nbSel != 1 ) {
mySubMesh = SMESH::SMESH_subMesh::_nil();
aString = "";
} else {
- Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
- myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ;
- if( !testResult ) {
- myMesh = SMESH::SMESH_Mesh::_nil();
- mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IO, testResult) ;
- if( !testResult ) {
- mySubMesh = SMESH::SMESH_subMesh::_nil();
+ myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO) ;
+ if(myMesh->_is_nil()){
+ mySubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
+ if(mySubMesh->_is_nil()){
aString = "";
}
}
}
myEditCurrentArgument->setText( aString );
- myGeomShape = GEOM::GEOM_Shape::_nil(); // InitGeom() will try to retrieve a shape from myMesh or mySubMesh
+ myGeomShape = GEOM::GEOM_Object::_nil(); // InitGeom() will try to retrieve a shape from myMesh or mySubMesh
InitGeom();
myImportedMesh = myGeomShape->_is_nil();
InitHypAssignation();
InitAlgoAssignation();
- }
+ }
else if ( myEditCurrentArgument == LineEditC1A2 ) {
if ( nbSel != 1 )
- myGeomShape = GEOM::GEOM_Shape::_nil();
+ myGeomShape = GEOM::GEOM_Object::_nil();
else {
- Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
- myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ;
- if( !testResult )
- myGeomShape = GEOM::GEOM_Shape::_nil();
+ myGeomShape = SMESH::IObjectToInterface<GEOM::GEOM_Object>(IO) ;
}
InitGeom();
}
QDialog::closeEvent( e );
}
+//=======================================================================
+//function : IsOld
+//purpose :
+//=======================================================================
+
+bool SMESHGUI_EditHypothesesDlg::IsOld(QListBoxItem* hypItem)
+{
+ if ( hypItem->rtti() == ListBoxIOR::RTTI_IOR ) {
+ ListBoxIOR* hyp = ( ListBoxIOR* ) hypItem;
+ return (myMapOldHypos.find( hyp->GetIOR() ) != myMapOldHypos.end() ||
+ myMapOldAlgos.find( hyp->GetIOR() ) != myMapOldAlgos.end() );
+ }
+
+ return false;
+}
//=================================================================================
// function : removeItem()
if (!item) return;
if ( aSender == ListHypAssignation ) {
+ myNbModification += IsOld( item ) ? 1 : -1;
ListHypAssignation->removeItem( ListHypAssignation->index( item ) );
}
else if ( aSender == ListAlgoAssignation ) {
+ myNbModification += IsOld( item ) ? 1 : -1;
ListAlgoAssignation->removeItem( ListAlgoAssignation->index( item ) );
}
+
UpdateControlState();
}
}
if ( !isFound )
ListBoxIOR* anItem = new ListBoxIOR( ListHypAssignation,
- strdup( i->GetIOR() ),
- strdup( i->text().latin1() ) );
+ CORBA::string_dup( i->GetIOR() ),
+ CORBA::string_dup( i->text().latin1() ) );
}
else if ( aSender == ListAlgoDefinition ) {
for ( int j = 0, n = ListAlgoAssignation->count(); !isFound && j < n; j++ ) {
}
if ( !isFound )
ListBoxIOR* anItem = new ListBoxIOR( ListAlgoAssignation,
- strdup( i->GetIOR() ),
- strdup( i->text().latin1() ) );
+ CORBA::string_dup( i->GetIOR() ),
+ CORBA::string_dup( i->text().latin1() ) );
}
+ if ( !isFound )
+ myNbModification += IsOld( item ) ? -1 : 1;
+
UpdateControlState();
}
{
ListHypDefinition->clear();
- SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH");
+ SALOMEDS::SComponent_var father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
if ( father->_is_nil() )
return;
int Tag_HypothesisRoot = 1;
if (father->FindSubObject (1, HypothesisRoot)) {
- SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(HypothesisRoot);
+ SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(HypothesisRoot);
for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value();
if (Obj->FindAttribute(anAttr, "AttributeName") ) {
//=================================================================================
void SMESHGUI_EditHypothesesDlg::InitHypAssignation()
{
- MESSAGE ( " InitHypAssignation " << myMesh->_is_nil() )
- MESSAGE ( " InitHypAssignation " << mySubMesh->_is_nil() )
+ myNbModification = 0;
+// MESSAGE ( " InitHypAssignation " << myMesh->_is_nil() )
+// MESSAGE ( " InitHypAssignation " << mySubMesh->_is_nil() )
myMapOldHypos.clear();
ListHypAssignation->clear();
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
- SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
if ( !myMesh->_is_nil() )
- aMorSM = myStudyAPI.FindObject( myMesh );
+ aMorSM = SMESH::FindSObject( myMesh );
else if ( !mySubMesh->_is_nil() )
- aMorSM = myStudyAPI.FindObject( mySubMesh );
+ aMorSM = SMESH::FindSObject( mySubMesh );
if ( !aMorSM->_is_nil() && aMorSM->FindSubObject (2, AHR)) {
- SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
+ SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(AHR);
for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value();
if ( Obj->ReferencedObject(aRef) ) {
{
ListAlgoDefinition->clear();
- SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH");
+ SALOMEDS::SComponent_var father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
if ( father->_is_nil() )
return;
SALOMEDS::AttributeIOR_var anIOR;
if (father->FindSubObject (2, AlgorithmsRoot)) {
- SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AlgorithmsRoot);
+ SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(AlgorithmsRoot);
for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value();
if (Obj->FindAttribute(anAttr, "AttributeName") ) {
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
- SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
if ( !myMesh->_is_nil() )
- aMorSM = myStudyAPI.FindObject( myMesh );
+ aMorSM = SMESH::FindSObject( myMesh );
else if ( !mySubMesh->_is_nil() )
- aMorSM = myStudyAPI.FindObject( mySubMesh );
+ aMorSM = SMESH::FindSObject( mySubMesh );
if ( !aMorSM->_is_nil() && aMorSM->FindSubObject (3, AHR)) {
- SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
+ SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(AHR);
for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value();
if ( Obj->ReferencedObject(aRef) ) {
void SMESHGUI_EditHypothesesDlg::InitGeom()
{
LineEditC1A2->setText("") ;
- SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
if ( myGeomShape->_is_nil() && !myMesh->_is_nil() ) {
- SALOMEDS::SObject_var aMesh = myStudyAPI.FindObject( myMesh );
+ SALOMEDS::SObject_var aMesh = SMESH::FindSObject( myMesh );
if ( !aMesh->_is_nil() )
- myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aMesh);
+ myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMesh);
}
if ( myGeomShape->_is_nil() && !mySubMesh->_is_nil() ) {
- SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindObject( mySubMesh );
+ SALOMEDS::SObject_var aSubMesh = SMESH::FindSObject( mySubMesh );
if ( !aSubMesh->_is_nil() )
- myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aSubMesh);
+ myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aSubMesh);
}
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
if ( !myGeomShape->_is_nil() && (!myMesh->_is_nil() || !mySubMesh->_is_nil()) ) {
- SALOMEDS::SObject_var aSO = mySMESHGUI->GetStudy()->FindObjectIOR( myGeomShape->Name() );
+ SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
+ SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myGeomShape) );
if ( !aSO->_is_nil() ) {
if (aSO->FindAttribute(anAttr, "AttributeName") ) {
- aName = SALOMEDS::AttributeName::_narrow(anAttr);
- LineEditC1A2->setText( QString(aName->Value()) ) ;
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ LineEditC1A2->setText( QString(aName->Value()) ) ;
}
}
}
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 );
+ buttonOk ->setEnabled( myNbModification && isEnabled && !myImportedMesh );
+ buttonApply->setEnabled( myNbModification && isEnabled && !myImportedMesh );
SelectButtonC1A2 ->setEnabled( ALLOW_CHANGE_SHAPE && !myImportedMesh );
LineEditC1A2 ->setEnabled( ALLOW_CHANGE_SHAPE && !myImportedMesh );
//=================================================================================
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 );
+ SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh );
+ GEOM::GEOM_Object_var aIniGeomShape = SMESH::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
+ // 1. remove all old hypotheses and algorithms and also submeshes
+ // 2. set new shape
}
+
+ int nbFail = 0;
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;
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str());
+ if ( !aHyp->_is_nil() ){
+ if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( aMeshSO, aHyp ))
+ nbFail++;
}
}
}
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;
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str());
+ if ( !aHyp->_is_nil() ){
+ if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( aMeshSO, aHyp ))
+ nbFail++;
}
}
}
- // 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 ) );
+ // 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 ( 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;
+ if ( myMapOldAlgos.find( ior ) == myMapOldAlgos.end() ) {
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str());
+ if ( !aHyp->_is_nil() ){
+ if (!SMESH::AddHypothesisOnMesh( myMesh, aHyp ))
+ nbFail++;
}
}
}
}
}
- // 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 ) );
+ // 5. 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 ( 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;
+ if ( myMapOldHypos.find( ior ) == myMapOldHypos.end() ) {
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str());
+ if ( !aHyp->_is_nil() ){
+ if (!SMESH::AddHypothesisOnMesh( myMesh, aHyp ))
+ nbFail++;
}
}
}
}
}
- return true;
+ return ( nbFail == 0 );
}
//=================================================================================
//=================================================================================
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 );
+ SALOMEDS::SObject_var aSubMeshSO = SMESH::FindSObject( mySubMesh );
+ GEOM::GEOM_Object_var aIniGeomShape = SMESH::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
+ // 1. remove all old hypotheses and algorithms
+ // 2. set new shape
}
+ int nbFail = 0;
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;
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str());
+ if ( !aHyp->_is_nil() ){
+ if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( aSubMeshSO, aHyp ))
+ nbFail++;
}
}
}
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;
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str());
+ if ( !aHyp->_is_nil() ){
+ if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( aSubMeshSO, aHyp ))
+ nbFail++;
}
}
}
- // 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 ) );
+ // 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 ( 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;
+ if ( myMapOldAlgos.find( ior ) == myMapOldAlgos.end() ) {
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str());
+ if ( !aHyp->_is_nil() ){
+ if (!SMESH::AddHypothesisOnSubMesh( mySubMesh, aHyp ))
+ nbFail++;
}
}
}
}
}
- // 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 ) );
+ // 5. 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 ( 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;
+ if ( myMapOldHypos.find( ior ) == myMapOldHypos.end() ) {
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str());
+ if ( !aHyp->_is_nil() ){
+ if (!SMESH::AddHypothesisOnSubMesh( mySubMesh, aHyp ))
+ nbFail++;
}
}
}
}
}
- return true;
+ return ( nbFail == 0 );
}