mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-01 04:10:33 +05:00
Small improvement to allow plugins not providing default hypotheses creator for algorithms.
This commit is contained in:
parent
9a5fe30faf
commit
8a5c42b09c
@ -745,78 +745,82 @@ SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
|
|||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
/*!
|
/*!
|
||||||
* \brief Calls plugin methods for hypothesis creation
|
* \brief Create hypothesis
|
||||||
* \param theHypType - specifies whether main hypotheses or additional ones
|
* \param theHypType - hypothesis category (main or additional)
|
||||||
* are created
|
|
||||||
* \param theIndex - index of type of hypothesis to be cerated
|
* \param theIndex - index of type of hypothesis to be cerated
|
||||||
*
|
*
|
||||||
* Speicfies dimension of hypothesis to be created (using sender() method), specifies
|
* Specifies dimension of hypothesis to be created (using sender() method),
|
||||||
* its type and calls plugin methods for hypothesis creation
|
* specifies its type and calls method for hypothesis creation
|
||||||
*/
|
*/
|
||||||
//================================================================================
|
//================================================================================
|
||||||
void SMESHGUI_MeshOp::onCreateHyp( const int theHypType, const int theIndex )
|
void SMESHGUI_MeshOp::onCreateHyp( const int theHypType, const int theIndex )
|
||||||
{
|
{
|
||||||
// Speicfies dimension of hypothesis to be created
|
// Specifies dimension of hypothesis to be created
|
||||||
const QObject* aSender = sender();
|
const QObject* aSender = sender();
|
||||||
int aDim = -1;
|
int aDim = -1;
|
||||||
for ( int i = SMESH::DIM_1D; i <= SMESH::DIM_3D; i++ )
|
for (int i = SMESH::DIM_1D; i <= SMESH::DIM_3D; i++)
|
||||||
if ( aSender == myDlg->tab( i ) )
|
if (aSender == myDlg->tab(i))
|
||||||
aDim = i;
|
aDim = i;
|
||||||
if ( aDim == -1 )
|
if (aDim == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Speicfies type of hypothesis to be created
|
// Specifies type of hypothesis to be created
|
||||||
QStringList aHypTypeNames = SMESH::GetAvailableHypotheses( false , aDim, theHypType == AddHyp );
|
QStringList aHypTypeNames = SMESH::GetAvailableHypotheses(false, aDim, theHypType == AddHyp);
|
||||||
if ( theIndex < 0 || theIndex >= aHypTypeNames.count() )
|
if (theIndex < 0 || theIndex >= aHypTypeNames.count())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString aHypTypeName = aHypTypeNames[ theIndex ];
|
QString aHypTypeName = aHypTypeNames[ theIndex ];
|
||||||
HypothesisData* aData = SMESH::GetHypothesisData( aHypTypeName.latin1() );
|
|
||||||
if ( aData == 0 )
|
// Create hypothesis
|
||||||
|
createHypothesis(aDim, theHypType, aHypTypeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* Create hypothesis and update dialog.
|
||||||
|
* \param theDim - dimension of hypothesis to be created
|
||||||
|
* \param theType - hypothesis category (algorithm, hypothesis, additional hypothesis)
|
||||||
|
* \param theTypeName - specifies hypothesis to be created
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
void SMESHGUI_MeshOp::createHypothesis (const int theDim,
|
||||||
|
const int theType,
|
||||||
|
const QString& theTypeName)
|
||||||
|
{
|
||||||
|
HypothesisData* aData = SMESH::GetHypothesisData(theTypeName.latin1());
|
||||||
|
if (!aData)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// existing hypos
|
||||||
|
QValueList<SMESH::SMESH_Hypothesis_var>& aList = myExistingHyps[theDim][theType];
|
||||||
|
int nbHyp = aList.count();
|
||||||
|
|
||||||
QString aClientLibName = aData->ClientLibName;
|
QString aClientLibName = aData->ClientLibName;
|
||||||
QStringList anOldHyps;
|
if (aClientLibName == "") {
|
||||||
_PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
|
|
||||||
existingHyps( aDim, theHypType, aFather, anOldHyps, myExistingHyps[ aDim ][ theHypType ] );
|
|
||||||
|
|
||||||
if ( aClientLibName == "" )
|
|
||||||
{
|
|
||||||
// Call hypothesis creation server method (without GUI)
|
// Call hypothesis creation server method (without GUI)
|
||||||
QString aHypName = aData->Label;
|
SMESH::CreateHypothesis(theTypeName, aData->Label, false);
|
||||||
SMESH::CreateHypothesis( aHypTypeName, aHypName, false );
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Get hypotheses creator client (GUI)
|
// Get hypotheses creator client (GUI)
|
||||||
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aHypTypeName );
|
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
|
||||||
|
|
||||||
// Create hypothesis
|
// Create hypothesis
|
||||||
if ( aCreator )
|
if (aCreator) {
|
||||||
{
|
|
||||||
// When create or edit a submesh, try to initialize a new hypothesis
|
// When create or edit a submesh, try to initialize a new hypothesis
|
||||||
// with values used to mesh a subshape
|
// with values used to mesh a subshape
|
||||||
SMESH::SMESH_Hypothesis_var initParamHyp =
|
SMESH::SMESH_Hypothesis_var initParamHyp =
|
||||||
getInitParamsHypothesis( aHypTypeName, aData->ServerLibName );
|
getInitParamsHypothesis(theTypeName, aData->ServerLibName);
|
||||||
|
aCreator->create(initParamHyp, myDlg);
|
||||||
if ( initParamHyp->_is_nil() )
|
} else {
|
||||||
aCreator->create( false, myDlg );
|
SMESH::CreateHypothesis(theTypeName, aData->Label, false);
|
||||||
else
|
|
||||||
aCreator->create( initParamHyp, myDlg );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SMESH::CreateHypothesis( aHypTypeName, aData->Label, false );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
|
||||||
|
|
||||||
QStringList aNewHyps;
|
QStringList aNewHyps;
|
||||||
aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
|
existingHyps(theDim, theType, aFather, aNewHyps, myExistingHyps[theDim][theType]);
|
||||||
existingHyps( aDim, theHypType, aFather, aNewHyps, myExistingHyps[ aDim ][ theHypType ] );
|
if (aNewHyps.count() > nbHyp) {
|
||||||
if ( aNewHyps.count() > anOldHyps.count() )
|
for (int i = nbHyp; i < aNewHyps.count(); i++)
|
||||||
{
|
myDlg->tab(theDim)->addHyp(theType, aNewHyps[i]);
|
||||||
for ( int i = anOldHyps.count(); i < aNewHyps.count(); i++ )
|
|
||||||
myDlg->tab( aDim )->addHyp( theHypType, aNewHyps[ i ] );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -858,92 +862,35 @@ void SMESHGUI_MeshOp::onEditHyp( const int theHypType, const int theIndex )
|
|||||||
* \param theSetName - The name of hypotheses set
|
* \param theSetName - The name of hypotheses set
|
||||||
*/
|
*/
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
||||||
void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
|
void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
|
||||||
{
|
{
|
||||||
HypothesesSet* aHypoSet = SMESH::GetHypothesesSet( theSetName );
|
HypothesesSet* aHypoSet = SMESH::GetHypothesesSet(theSetName);
|
||||||
if ( !aHypoSet ) return;
|
if (!aHypoSet) return;
|
||||||
|
|
||||||
for ( int aHypType = Algo; aHypType < AddHyp; aHypType++ )
|
for (int aHypType = Algo; aHypType < AddHyp; aHypType++) {
|
||||||
{
|
|
||||||
bool isAlgo = (aHypType == Algo);
|
bool isAlgo = (aHypType == Algo);
|
||||||
|
|
||||||
// clear all hyps
|
// clear all hyps
|
||||||
for ( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ )
|
for (int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++)
|
||||||
setCurrentHyp( dim, aHypType, -1 );
|
setCurrentHyp(dim, aHypType, -1);
|
||||||
|
|
||||||
// set hyps from the set
|
// set hyps from the set
|
||||||
|
QStringList* aHypoList = isAlgo ? &aHypoSet->AlgoList : &aHypoSet->HypoList;
|
||||||
QStringList* aHypoList = isAlgo ? & aHypoSet->AlgoList : & aHypoSet->HypoList;
|
for (int i = 0, n = aHypoList->count(); i < n; i++) {
|
||||||
for ( int i = 0, n = aHypoList->count(); i < n; i++ )
|
|
||||||
{
|
|
||||||
const QString& aHypoTypeName = (*aHypoList)[ i ];
|
const QString& aHypoTypeName = (*aHypoList)[ i ];
|
||||||
HypothesisData* aHypData = SMESH::GetHypothesisData( aHypoTypeName );
|
HypothesisData* aHypData = SMESH::GetHypothesisData(aHypoTypeName);
|
||||||
if ( !aHypData )
|
if (!aHypData)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int aDim = aHypData->Dim[0];
|
int aDim = aHypData->Dim[0];
|
||||||
// create or/and set
|
// create or/and set
|
||||||
int index = -1;
|
if (isAlgo) {
|
||||||
if ( isAlgo )
|
QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses(isAlgo, aDim);
|
||||||
{
|
int index = aHypTypeNameList.findIndex(aHypoTypeName);
|
||||||
QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, aDim );
|
if (index < 0) continue;
|
||||||
index = aHypTypeNameList.findIndex( aHypoTypeName );
|
setCurrentHyp(aDim, aHypType, index);
|
||||||
if ( index < 0 ) continue;
|
} else {
|
||||||
setCurrentHyp ( aDim, aHypType, index );
|
createHypothesis(aDim, aHypType, aHypoTypeName);
|
||||||
}
|
|
||||||
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
|
|
||||||
{
|
|
||||||
// select the found hypothesis
|
|
||||||
setCurrentHyp ( aDim, aHypType, index );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// create a hypothesis
|
|
||||||
QString aClientLibName = aHypData->ClientLibName;
|
|
||||||
if ( aClientLibName == "" ) {
|
|
||||||
// Call hypothesis creation server method (without GUI)
|
|
||||||
SMESH::CreateHypothesis( aHypoTypeName, aHypData->Label, isAlgo );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Get hypotheses creator client (GUI)
|
|
||||||
SMESHGUI_GenericHypothesisCreator* aCreator =
|
|
||||||
SMESH::GetHypothesisCreator( aHypoTypeName );
|
|
||||||
if ( aCreator )
|
|
||||||
{
|
|
||||||
// When create or edit a submesh, try to initialize a new hypothesis
|
|
||||||
// with values used to mesh a subshape
|
|
||||||
SMESH::SMESH_Hypothesis_var initParamHyp =
|
|
||||||
getInitParamsHypothesis( aHypoTypeName, aHypData->ServerLibName );
|
|
||||||
aCreator->create( initParamHyp, myDlg );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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 hypos in the set
|
||||||
} // loop on algo/hypo
|
} // loop on algo/hypo
|
||||||
@ -1162,20 +1109,23 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( anAlgoVar->_is_nil() )
|
|
||||||
{
|
if (anAlgoVar->_is_nil()) {
|
||||||
HypothesisData* aHypData = SMESH::GetHypothesisData( aHypName );
|
HypothesisData* aHypData = SMESH::GetHypothesisData( aHypName );
|
||||||
if ( aHypData )
|
if (aHypData) {
|
||||||
{
|
|
||||||
QString aClientLibName = aHypData->ClientLibName;
|
QString aClientLibName = aHypData->ClientLibName;
|
||||||
if ( aClientLibName == "" )
|
if (aClientLibName == "") {
|
||||||
SMESH::CreateHypothesis( aHypName, aHypData->Label, true );
|
// Call hypothesis creation server method (without GUI)
|
||||||
else
|
SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
|
||||||
{
|
} else {
|
||||||
SMESHGUI_GenericHypothesisCreator* aCreator =
|
// Get hypotheses creator client (GUI)
|
||||||
SMESH::GetHypothesisCreator( aHypName );
|
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName);
|
||||||
if ( aCreator )
|
|
||||||
aCreator->create( true, myDlg );
|
// Create algorithm
|
||||||
|
if (aCreator)
|
||||||
|
aCreator->create(true, myDlg);
|
||||||
|
else
|
||||||
|
SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
|
||||||
}
|
}
|
||||||
QStringList tmpList;
|
QStringList tmpList;
|
||||||
_PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
|
_PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
|
||||||
|
@ -85,6 +85,9 @@ private:
|
|||||||
QStringList& theHyps,
|
QStringList& theHyps,
|
||||||
QValueList<SMESH::SMESH_Hypothesis_var>& theHypVars );
|
QValueList<SMESH::SMESH_Hypothesis_var>& theHypVars );
|
||||||
|
|
||||||
|
void createHypothesis(const int theDim, const int theType,
|
||||||
|
const QString& theTypeName);
|
||||||
|
|
||||||
bool createMesh( QString& );
|
bool createMesh( QString& );
|
||||||
bool createSubMesh( QString& );
|
bool createSubMesh( QString& );
|
||||||
bool editMeshOrSubMesh( QString& );
|
bool editMeshOrSubMesh( QString& );
|
||||||
|
Loading…
Reference in New Issue
Block a user