+//================================================================================
+/*!
+ * \brief Creates and selects hypothesis of hypotheses set
+ * \param theSetName - The name of hypotheses set
+ */
+//================================================================================
+
+void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
+{
+ HypothesesSet* aHypoSet = SMESH::GetHypothesesSet( theSetName );
+ if ( !aHypoSet ) return;
+
+ for ( int aHypType = Algo; aHypType < AddHyp; aHypType++ )
+ {
+ bool isAlgo = (aHypType == Algo);
+
+ // clear all hyps
+ for ( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ )
+ setCurrentHyp( dim, aHypType, -1 );
+
+ // set hyps from the set
+
+ QStringList* aHypoList = isAlgo ? & aHypoSet->AlgoList : & aHypoSet->HypoList;
+ for ( int i = 0, n = aHypoList->count(); i < n; i++ )
+ {
+ const QString& aHypoTypeName = (*aHypoList)[ i ];
+ HypothesisData* aHypData = SMESH::GetHypothesisData( aHypoTypeName );
+ int aDim = aHypData->Dim[0];
+ // create or/and set
+ int index = -1;
+ if ( isAlgo )
+ {
+ QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, aDim );
+ index = aHypTypeNameList.findIndex( aHypoTypeName );
+ if ( index < 0 ) continue;
+ setCurrentHyp ( aDim, aHypType, index );
+ }
+ else
+ {
+ // try to find an existing hypo
+ QValueList<SMESH::SMESH_Hypothesis_var> & aList = myExistingHyps[ aDim ][ aHypType ];
+ int iHyp = 0, nbHyp = aList.count();
+ for ( ; iHyp < nbHyp; ++iHyp )
+ {
+ SMESH::SMESH_Hypothesis_var aHyp = aList[ iHyp ];
+ if ( !aHyp->_is_nil() && aHypoTypeName == aHyp->GetName() ) {
+ index = iHyp;
+ break;
+ }
+ }
+ if ( index >= 0 ) // found
+ {
+ setCurrentHyp ( aDim, aHypType, index );
+ }
+ else
+ {
+ // silently create a hypothesis
+ SMESH::CreateHypothesis( aHypoTypeName, aHypData->Label, isAlgo );
+ QStringList aNewHyps;
+ _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
+ existingHyps( aDim, aHypType, aFather, aNewHyps, aList );
+ if ( aList.count() > nbHyp )
+ {
+ for ( int i = nbHyp; i < aNewHyps.count(); i++ )
+ myDlg->tab( aDim )->addHyp( aHypType, aNewHyps[ i ] );
+ }
+ }
+ }
+ } // loop on hypos in the set
+ } // loop on algo/hypo
+}
+