fix bug 12302( TC ). Additionally make possible to edit submeshes with hypos without algos assigned

This commit is contained in:
eap 2006-04-27 13:39:28 +00:00
parent 1e17309dab
commit 3c7fb11b5f

View File

@ -231,6 +231,8 @@ void SMESHGUI_MeshOp::startOperation()
aTab->setAvailableHyps( AddHyp, hypList ); aTab->setAvailableHyps( AddHyp, hypList );
aTab->setExistingHyps( MainHyp, hypList ); aTab->setExistingHyps( MainHyp, hypList );
aTab->setExistingHyps( AddHyp, hypList ); aTab->setExistingHyps( AddHyp, hypList );
myExistingHyps[ i ][ MainHyp ].clear();
myExistingHyps[ i ][ AddHyp ].clear();
// set algos // set algos
availableHyps( i, Algo, hypList, myAvailableHypData[i][Algo] ); availableHyps( i, Algo, hypList, myAvailableHypData[i][Algo] );
aTab->setAvailableHyps( Algo, hypList ); aTab->setAvailableHyps( Algo, hypList );
@ -357,6 +359,7 @@ _PTR(SObject) SMESHGUI_MeshOp::getSubmeshByGeom() const
case GEOM::COMPOUND: tag = SUBMESH_ON_COMPOUND_TAG; break; case GEOM::COMPOUND: tag = SUBMESH_ON_COMPOUND_TAG; break;
default:; default:;
} }
_PTR(GenericAttribute) anAttr;
_PTR(SObject) aSubmeshRoot; _PTR(SObject) aSubmeshRoot;
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
if ( pMesh->FindSubObject( tag, aSubmeshRoot ) ) if ( pMesh->FindSubObject( tag, aSubmeshRoot ) )
@ -365,6 +368,8 @@ _PTR(SObject) SMESHGUI_MeshOp::getSubmeshByGeom() const
for (; smIter->More(); smIter->Next() ) for (; smIter->More(); smIter->Next() )
{ {
_PTR(SObject) aSmObj = smIter->Value(); _PTR(SObject) aSmObj = smIter->Value();
if ( ! aSmObj->FindAttribute( anAttr, "AttributeIOR" ))
continue;
_PTR(ChildIterator) anIter1 = aStudy->NewChildIterator(aSmObj); _PTR(ChildIterator) anIter1 = aStudy->NewChildIterator(aSmObj);
for (; anIter1->More(); anIter1->Next()) { for (; anIter1->More(); anIter1->Next()) {
_PTR(SObject) pGeom2 = anIter1->Value(); _PTR(SObject) pGeom2 = anIter1->Value();
@ -436,6 +441,7 @@ void SMESHGUI_MeshOp::selectionDone()
} }
myDlg->setMaxHypoDim( shapeDim ); myDlg->setMaxHypoDim( shapeDim );
if ( !myToCreate ) // edition: read hypotheses if ( !myToCreate ) // edition: read hypotheses
{ {
QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ); QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
@ -1026,10 +1032,7 @@ void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
// set hypotheses corresponding to the found algoritms // set hypotheses corresponding to the found algoritms
//QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ); _PTR(SObject) pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
_PTR(SObject) pObj;// = studyDS()->FindObjectID( anObjEntry.latin1() );
if ( !pObj )
pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
for ( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ ) for ( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ )
{ {
@ -1039,17 +1042,38 @@ void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
{ {
myAvailableHypData[ dim ][ type ].clear(); myAvailableHypData[ dim ][ type ].clear();
QStringList anAvailable, anExisting; QStringList anAvailable, anExisting;
SMESH::SMESH_Hypothesis_var curHyp;
HypothesisData* curAlgo = algoByDim[ dim ];
int hypIndex = currentHyp( dim, type );
SMESH::SMESH_Hypothesis_var curHyp;
if ( hypIndex >= 0 && hypIndex < myExistingHyps[ dim ][ type ].count() )
curHyp = myExistingHyps[ dim ][ type ][ hypIndex ];
if ( !myToCreate && !curAlgo && !curHyp->_is_nil() ) { // edition, algo not selected
// try to find algo by selected hypothesis in order to keep it selected
bool algoDeselectedByUser = ( theDim < 0 && aDim == dim );
QString curHypType = curHyp->GetName();
if ( !algoDeselectedByUser &&
myObjHyps[ dim ][ type ].count() > 0 &&
curHypType == myObjHyps[ dim ][ type ][ 0 ]->GetName())
{
HypothesisData* hypData = SMESH::GetHypothesisData( curHyp->GetName() );
for ( int i = 0 ; i < myAvailableHypData[ dim ][ Algo ].count(); ++i ) {
curAlgo = myAvailableHypData[ dim ][ Algo ][ i ];
if ( curAlgo && hypData && isCompatible( curAlgo, hypData, type ))
break;
else
curAlgo = 0;
}
}
}
// get hyps compatible with curAlgo // get hyps compatible with curAlgo
if ( HypothesisData* curAlgo = algoByDim[ dim ] ) if ( curAlgo )
{ {
// get current existing hypothesis // check if a selected hyp is compatible with the curAlgo
int hypIndex = currentHyp( dim, type ); if ( !curHyp->_is_nil() ) {
if ( hypIndex >= 0 && hypIndex < myExistingHyps[ dim ][ type ].count() ) { HypothesisData* hypData = SMESH::GetHypothesisData( curHyp->GetName() );
curHyp = myExistingHyps[ dim ][ type ][ hypIndex ];
QString hypTypeName = curHyp->GetName();
HypothesisData* hypData = SMESH::GetHypothesisData( hypTypeName );
if ( !isCompatible( curAlgo, hypData, type )) if ( !isCompatible( curAlgo, hypData, type ))
curHyp = SMESH::SMESH_Hypothesis::_nil(); curHyp = SMESH::SMESH_Hypothesis::_nil();
} }
@ -1061,9 +1085,10 @@ void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
myDlg->tab( dim )->setExistingHyps( type, anExisting ); myDlg->tab( dim )->setExistingHyps( type, anExisting );
// set current existing hypothesis // set current existing hypothesis
int hypIndex = -1;
if ( !curHyp->_is_nil() && !anExisting.isEmpty() ) if ( !curHyp->_is_nil() && !anExisting.isEmpty() )
hypIndex = this->find( curHyp, myExistingHyps[ dim ][ type ]); hypIndex = this->find( curHyp, myExistingHyps[ dim ][ type ]);
else
hypIndex = -1;
if ( !isSubmesh && hypIndex < 0 && anExisting.count() == 1 ) { if ( !isSubmesh && hypIndex < 0 && anExisting.count() == 1 ) {
// none is yet selected => select the sole existing if it is not optional // none is yet selected => select the sole existing if it is not optional
QString hypTypeName = myExistingHyps[ dim ][ type ][ 0 ]->GetName(); QString hypTypeName = myExistingHyps[ dim ][ type ][ 0 ]->GetName();
@ -1434,15 +1459,15 @@ void SMESHGUI_MeshOp::readMesh()
} }
// Get hypotheses and algorithms assigned to the mesh/sub-mesh // Get hypotheses and algorithms assigned to the mesh/sub-mesh
QStringList anExisting;
for ( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ ) for ( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ )
{ {
// get algorithm // get algorithm
QStringList anExisting;
int aHypIndex = -1;
existingHyps( dim, Algo, pObj, anExisting, myObjHyps[ dim ][ Algo ] ); existingHyps( dim, Algo, pObj, anExisting, myObjHyps[ dim ][ Algo ] );
// find algo index among available ones
int aHypIndex = -1;
if ( myObjHyps[ dim ][ Algo ].count() > 0 ) if ( myObjHyps[ dim ][ Algo ].count() > 0 )
{ {
// find algo index among available ones
SMESH::SMESH_Hypothesis_var aVar = myObjHyps[ dim ][ Algo ].first(); SMESH::SMESH_Hypothesis_var aVar = myObjHyps[ dim ][ Algo ].first();
QString aHypTypeName = aVar->GetName(); QString aHypTypeName = aVar->GetName();
HypothesisData* algoData = SMESH::GetHypothesisData( aHypTypeName ); HypothesisData* algoData = SMESH::GetHypothesisData( aHypTypeName );
@ -1456,8 +1481,12 @@ void SMESHGUI_MeshOp::readMesh()
setCurrentHyp( dim, Algo, aHypIndex ); setCurrentHyp( dim, Algo, aHypIndex );
// set existing and available hypothesis according to the selected algo // set existing and available hypothesis according to the selected algo
onAlgoSelected( aHypIndex, dim ); onAlgoSelected( aHypIndex, dim );
}
// get hypotheses // get hypotheses
bool hypWithoutAlgo = false;
for ( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ )
{
for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ ) for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
{ {
// get hypotheses // get hypotheses
@ -1467,15 +1496,23 @@ void SMESHGUI_MeshOp::readMesh()
if ( myObjHyps[ dim ][ hypType ].count() > 0 ) { if ( myObjHyps[ dim ][ hypType ].count() > 0 ) {
aHypIndex = find( myObjHyps[ dim ][ hypType ].first(), aHypIndex = find( myObjHyps[ dim ][ hypType ].first(),
myExistingHyps[ dim ][ hypType ] ); myExistingHyps[ dim ][ hypType ] );
// if ( aHypIndex < 0 ) { if ( aHypIndex < 0 ) {
// // assigned hypothesis is incompatible with the algorithm // assigned hypothesis is incompatible with the algorithm
// myExistingHyps[ dim ][ hypType ].push_back( myObjHyps[ dim ][ hypType ].first() ); if ( currentHyp( dim, Algo ) < 0 )
// aHypIndex = myExistingHyps[ dim ][ hypType ].count() - 1; { // none algo selected; it is edition for sure, of submesh maybe
// } hypWithoutAlgo = true;
myExistingHyps[ dim ][ hypType ].push_back( myObjHyps[ dim ][ hypType ].first() );
aHypIndex = myExistingHyps[ dim ][ hypType ].count() - 1;
myDlg->tab( dim )->setExistingHyps( hypType, anExisting );
}
}
} }
setCurrentHyp( dim, hypType, aHypIndex ); setCurrentHyp( dim, hypType, aHypIndex );
} }
} }
// make available other hyps of same type as one without algo
if ( hypWithoutAlgo )
onAlgoSelected( currentHyp( 0, Algo ), 0 );
} }
//================================================================================ //================================================================================