- QStringList anAvailableAlgs;
- QString anCompareType = "";
- bool isAvailableChoiceAlgo = false;
- int anCurrentAvailableAlgo = 0;
- bool isNone = true;
- switch ( theIndex ) {
- case MT_ANY:{
- anCompareType = "ANY";
- aDim = SMESH::DIM_3D;
- }
- break;
- case MT_TRIANGULAR:{
- aDim = SMESH::DIM_2D;
- anCompareType = "TRIA";
- }
- break;
- case MT_QUADRILATERAL:{
- aDim = SMESH::DIM_2D;
- anCompareType = "QUAD";
- }
- break;
- case MT_TETRAHEDRAL:{
- aDim = SMESH::DIM_3D;
- anCompareType = "TETRA";
- }
- break;
- case MT_HEXAHEDRAL:{
- aDim = SMESH::DIM_3D;
- anCompareType = "HEXA";
- }
- break;
- default:;
- }
- if ( anCompareType == "ANY" )
- {
- for ( int dim = SMESH::DIM_2D; dim <= SMESH::DIM_3D; dim++ )
- {
- isNone = currentHyp( dim, Algo ) < 0;
- isAvailableChoiceAlgo = false;
- // retrieves a list of available algorithms from resources
- availableHyps( dim, Algo, anAvailableAlgs, anAvailableAlgsData );
- //return current algo in current tab and set new algorithm list
- HypothesisData* algoCur;
- if ( !isNone && !myAvailableHypData[dim][Algo].empty() ){
- algoCur = myAvailableHypData[dim][Algo].at( currentHyp( dim, Algo ) );
- }
- myAvailableHypData[dim][Algo].clear();
- anAvailableAlgs.clear();
- for (int i = 0 ; i < anAvailableAlgsData.count(); i++)
- {
- HypothesisData* curAlgo = anAvailableAlgsData.at(i);
- QString anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
- GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
- if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
- {
- aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
- }
- if ( aGeomVar->_is_nil() ||
- ( !aGeomVar->_is_nil() && SMESH::IsApplicable( curAlgo->TypeName, aGeomVar, !myIsMesh ))){
- anAvailableAlgs.append( curAlgo->Label );
- myAvailableHypData[dim][Algo].append( curAlgo );
- }
- }
- if ( !isNone && algoCur ){
- for (int i = 0 ; i < myAvailableHypData[dim][Algo].count(); i++)
- {
- HypothesisData* algoAny = myAvailableHypData[dim][Algo].at(i);
- if ( algoAny->Label == algoCur->Label ){
- isAvailableChoiceAlgo = true;
- anCurrentAvailableAlgo = i;
- break;
- }
- }
- }
- else if ( !isNone ){
- isAvailableChoiceAlgo = true;
- anCurrentAvailableAlgo = currentHyp( dim, Algo );
- }
- myDlg->tab( dim )->setAvailableHyps( Algo, anAvailableAlgs );
- if ( isAvailableChoiceAlgo )
- setCurrentHyp( dim, Algo, anCurrentAvailableAlgo );
- }
- if ( !myIsOnGeometry )
- for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ ) {
- if ( i < SMESH::DIM_3D ) myDlg->disableTab( i );
- else myDlg->enableTab( i );
- }
- else
- for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ ) {
- if ( i > myMaxShapeDim ) myDlg->disableTab( i );
- else myDlg->enableTab( i );
- }
- myDlg->setCurrentTab( theTabIndex );
- }
- else
- {
- QString anCurrentAlgo;
- bool isReqDisBound = true;
- QString anCurrentCompareType = anCompareType;
- isNone = currentHyp( aDim, Algo ) < 0;
- if ( !isNone && !myAvailableHypData[aDim][Algo].empty() &&
- myAvailableHypData[aDim][Algo].count() != anAvailableAlgsData.count() )
- isReqDisBound = myAvailableHypData[aDim][Algo].at( currentHyp( aDim, Algo ) )->InputTypes.isEmpty();
- else if ( !isNone )
- isReqDisBound = anAvailableAlgsData.at( currentHyp( aDim, Algo ) )->InputTypes.isEmpty();
- for ( int dim = aDim; dim >= SMESH::DIM_2D; dim-- )
- {
- bool isNoneAlg = currentHyp( dim, Algo ) < 0;
- isAvailableChoiceAlgo = false;
- // retrieves a list of available algorithms from resources
- availableHyps( dim, Algo, anAvailableAlgs, anAvailableAlgsData );
- // finding algorithm which is selected
- if ( !isNoneAlg && !myAvailableHypData[dim][Algo].empty() &&
- myAvailableHypData[dim][Algo].count() != anAvailableAlgsData.count() )
- anCurrentAlgo = myAvailableHypData[dim][Algo].at( currentHyp( dim, Algo ) )->Label;
- else if ( !isNoneAlg )
- anCurrentAlgo = anAvailableAlgsData.at( currentHyp( dim, Algo ) )->Label;
- anAvailableAlgs.clear();
- myAvailableHypData[dim][Algo].clear();
- myFilteredAlgoData[dim].clear();
- // finding and adding algorithm depending on the type mesh
- for ( int i = 0 ; i < anAvailableAlgsData.count(); i++ )
- {
- HypothesisData* algoIn = anAvailableAlgsData.at( i );
- bool isAvailableAlgo = ( algoIn->OutputTypes.count() == 0 );
- QStringList::const_iterator inElemType = algoIn->OutputTypes.begin();
- for ( ; inElemType != algoIn->OutputTypes.end(); inElemType++ )
- {
- if ( *inElemType == anCurrentCompareType ){
- isAvailableAlgo = true;
- break;
- }
- }
- if ( isAvailableAlgo || algoIn->OutputTypes.count()==0 ){
- QString anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
- GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
- if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
- {
- aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
- }
- if ( aGeomVar->_is_nil() || myMaxShapeDim != dim ||
- ( !aGeomVar->_is_nil() && SMESH::IsApplicable( algoIn->TypeName, aGeomVar, !myIsMesh ))){
- anAvailableAlgs.append( algoIn->Label );
- myAvailableHypData[dim][Algo].append( algoIn );
- myFilteredAlgoData[dim].append( algoIn );
- }
- }
- //algorithm will be active, if the chosen algorithm available in the current mesh type
- if ( !isNoneAlg && isAvailableAlgo && algoIn->Label == anCurrentAlgo ){
- isAvailableChoiceAlgo = true;
- anCurrentAvailableAlgo = anAvailableAlgs.count() - 1 ;
- }
- }
- //set new algorithm list and select the current algorithm
- myDlg->tab( dim )->setAvailableHyps( Algo, anAvailableAlgs );
- anCurrentCompareType = ( anCompareType == "HEXA" ) ? "QUAD" : "TRIA";
- if ( isAvailableChoiceAlgo )
- setCurrentHyp( dim, Algo, anCurrentAvailableAlgo );
- else
- setCurrentHyp( dim, Algo, -1 );
- }
-
- int aMaxShapeDim = ( myMaxShapeDim != aDim) ? aDim : myMaxShapeDim;
- if ( isNone || isReqDisBound ) {
- for ( int i = SMESH::DIM_0D; i <= aMaxShapeDim; i++ ) {
- if ( aDim != i ) {
- myDlg->disableTab( i );
- setCurrentHyp(i, Algo, -1);
- }
- }
- }
- else if ( !isNone ){
- if ( aDim == SMESH::DIM_2D){
- myDlg->disableTab( SMESH::DIM_3D );
- setCurrentHyp( SMESH::DIM_3D, Algo, -1);
- }
- for ( int i = aMaxShapeDim; i > SMESH::DIM_0D; i-- )
- {
- isReqDisBound = ( currentHyp( i, Algo ) < 0 ) ? true :
- myAvailableHypData[i][Algo].at( currentHyp( i, Algo ) )->InputTypes.isEmpty();
- if ( isReqDisBound ) {
- for (int j = i - 1; j >= SMESH::DIM_0D; j--){
- myDlg->disableTab( j );
- setCurrentHyp( j , Algo, -1 );
- }
- break;
- }
- }
- }
- myDlg->enableTab( aDim );
- myDlg->setCurrentTab( aDim );
- }
- QStringList aHypothesesSetsList = SMESH::GetHypothesesSets( aDim );