0021308: Remove hard-coded dependency of the external mesh plugins from the SMESH module

Now it's necessary to call myMesh->SetParameters() just before
  calling a method using parameters that can be defined via notebook variables
This commit is contained in:
eap 2012-03-07 15:13:29 +00:00
parent 4a78d582ba
commit d4675122f5
15 changed files with 78 additions and 121 deletions

View File

@ -295,13 +295,17 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
SMESH::SMESH_Mesh_var aCompoundMesh;
if (!myMesh->_is_nil()) {
if (!myMesh->_is_nil())
{
QStringList aParameters;
aParameters << (CheckBoxMerge->isChecked() ? SpinBoxTol->text() : QString(" "));
QStringList anEntryList;
try {
SUIT_OverrideCursor aWaitCursor;
myMeshArray[0]->SetParameters( aParameters.join(":").toLatin1().constData() );
SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
// concatenate meshes
if(CheckBoxCommon->isChecked())
@ -315,8 +319,6 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
CheckBoxMerge->isChecked(),
SpinBoxTol->GetValue());
aCompoundMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
_PTR(SObject) aSO = SMESH::FindSObject( aCompoundMesh );
if( aSO ) {
SMESH::SetName( aSO, LineEditName->text() );

View File

@ -533,55 +533,11 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
try {
SUIT_OverrideCursor wc;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
//if ( LinearAnglesCheck->isChecked() ) {
// anAngles = aMeshEditor->LinearAnglesVariation( myPathMesh, myPathShape, anAngles );
//}
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
/*
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
if( MeshCheck->isChecked() ) {
if( GetConstructorId() == 0 )
SMESH::ListOfGroups_var groups =
aMeshEditor->ExtrusionAlongPathObject1DMakeGroups(myIDSource, myPathMesh,
myPathShape, aNodeStart,
AnglesGrp->isChecked(), anAngles,
BasePointGrp->isChecked(), aBasePoint, retVal);
else
SMESH::ListOfGroups_var groups =
aMeshEditor->ExtrusionAlongPathObject2DMakeGroups(myIDSource, myPathMesh,
myPathShape, aNodeStart,
AnglesGrp->isChecked(), anAngles,
BasePointGrp->isChecked(), aBasePoint, retVal);
}
else
SMESH::ListOfGroups_var groups =
aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh,
myPathShape, aNodeStart,
AnglesGrp->isChecked(), anAngles,
BasePointGrp->isChecked(), aBasePoint, retVal);
}
else {
if( MeshCheck->isChecked() ) {
if( GetConstructorId() == 0 )
retVal = aMeshEditor->ExtrusionAlongPathObject1D(myIDSource, myPathMesh,
myPathShape, aNodeStart,
AnglesGrp->isChecked(), anAngles,
BasePointGrp->isChecked(), aBasePoint);
else
retVal = aMeshEditor->ExtrusionAlongPathObject2D(myIDSource, myPathMesh,
myPathShape, aNodeStart,
AnglesGrp->isChecked(), anAngles,
BasePointGrp->isChecked(), aBasePoint);
}
else
retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh,
myPathShape, aNodeStart,
AnglesGrp->isChecked(), anAngles,
BasePointGrp->isChecked(), aBasePoint);
}
*/
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
bool NeedGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
SMESH::ElementType ElemType = SMESH::FACE;
@ -603,10 +559,6 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
}
if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK )
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
//wc.stop();
wc.suspend();
switch (retVal) {
case SMESH::SMESH_MeshEditor::EXTR_NO_ELEMENTS:

View File

@ -552,10 +552,11 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
aParameters << SpinBox_Dy->text();
aParameters << SpinBox_Dz->text();
} else if ( RadioButton4->isChecked() ) {
aParameters << SpinBox_Vx->text();
aParameters << SpinBox_Vy->text();
aParameters << SpinBox_Vz->text();
aParameters << SpinBox_VDist->text();
// only 3 coords in a python dump command :(
// aParameters << SpinBox_Vx->text();
// aParameters << SpinBox_Vy->text();
// aParameters << SpinBox_Vz->text();
// aParameters << SpinBox_VDist->text();
}
long aNbSteps = (long)SpinBox_NbSteps->value();
@ -566,6 +567,8 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
if( CheckBoxMesh->isChecked() )
switch (GetConstructorId() ) {
@ -624,8 +627,6 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps);
}
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
} catch (...) {
}

View File

@ -332,18 +332,20 @@ bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& par
{
SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
item.myValue = sb->value();
item.myText = sb->text();
params.append( item );
}
else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
{
SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
item.myValue = sb->value();
item.myText = sb->text();
params.append( item );
}
else if( (*anIt)->inherits( "QLineEdit" ) )
{
QLineEdit* line = ( QLineEdit* )( *anIt );
item.myValue = line->text();
item.myValue = item.myText = line->text();
params.append( item );
}
else if ( getParamFromCustomWidget( item, *anIt ))
@ -356,6 +358,16 @@ bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& par
return res;
}
QString SMESHGUI_GenericHypothesisCreator::getVariableName(const char* methodName) const
{
SMESH::SMESH_Hypothesis_var h = hypothesis();
if ( !h->_is_nil() )
{
CORBA::String_var aVaribaleName = h->GetVarParameter( methodName );
return QString( aVaribaleName.in() );
}
return QString();
}
QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
{

View File

@ -81,9 +81,11 @@ protected:
QString myName;
QVariant myValue;
bool isVariable;
QString myText;
StdParam(){
isVariable = false;
}
const char* text() const { return myText.toLatin1().constData(); }
};
typedef QList<StdParam> ListOfStdParams;
@ -95,6 +97,7 @@ protected:
const ListOfWidgets& widgets() const;
ListOfWidgets& changeWidgets();
QtxDialog* dlg() const;
QString getVariableName(const char* methodName) const;
virtual QFrame* buildFrame() = 0;
QFrame* buildStdFrame();

View File

@ -429,6 +429,10 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply()
return false;
}
QStringList aParameters;
aParameters << myDlg->myX->text();
aParameters << myDlg->myY->text();
aParameters << myDlg->myZ->text();
try {
SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
@ -441,6 +445,8 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply()
if (aMeshEditor->_is_nil())
return true;
aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
bool ok;
int anId = myDlg->myId->text().toInt( &ok );
if( !ok || anId < 1 )
@ -455,12 +461,6 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply()
if (aResult)
{
QStringList aParameters;
aParameters << myDlg->myX->text();
aParameters << myDlg->myY->text();
aParameters << myDlg->myZ->text();
aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
myDlg->myCurrentX->SetValue(0);
myDlg->myCurrentY->SetValue(0);
myDlg->myCurrentZ->SetValue(0);

View File

@ -468,6 +468,13 @@ bool SMESHGUI_MeshPatternDlg::onApply()
erasePreview();
if (isRefine()) { // Refining existing mesh elements
{
QStringList aParameters;
aParameters << myNode1->text();
if(myType == Type_3d )
aParameters << myNode2->text();
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
}
QList<int> ids;
getIds(ids);
SMESH::long_array_var varIds = new SMESH::long_array();
@ -479,12 +486,6 @@ bool SMESHGUI_MeshPatternDlg::onApply()
? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
: myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
QStringList aParameters;
aParameters << myNode1->text();
if(myType == Type_3d )
aParameters << myNode2->text();
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
} else { // Applying a pattern to geometrical object
if (myType == Type_2d)
myPattern->ApplyToFace(myGeomObj[Object], myGeomObj[Vertex1], myReverseChk->isChecked());

View File

@ -1205,6 +1205,11 @@ bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEdito
const SMESH::long_array& theIds,
SMESH::SMESH_IDSource_ptr obj)
{
{
QStringList aParameters;
aParameters << myMaxAngleSpin->text();
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
}
SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
double aMaxAngle = myMaxAngleSpin->GetValue() * M_PI / 180.0;
bool ok;
@ -1212,11 +1217,6 @@ bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEdito
ok = theEditor->TriToQuad(theIds, aCriterion, aMaxAngle);
else
ok = theEditor->TriToQuadObject(obj, aCriterion, aMaxAngle);
if( ok ) {
QStringList aParameters;
aParameters << myMaxAngleSpin->text();
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
}
return ok;
}

View File

@ -100,8 +100,8 @@ namespace SMESH
try {
_PTR(SObject) aSobj = SMESH::FindSObject( theMesh );
SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
aNodeId = aMeshEditor->AddNode( x, y, z );
theMesh->SetParameters( theParameters.join(":").toLatin1().constData() );
aNodeId = aMeshEditor->AddNode( x, y, z );
_PTR(Study) aStudy = GetActiveStudyDocument();
CORBA::Long anId = aStudy->StudyId();
if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj( anId, aSobj->GetID().c_str() ) ) {

View File

@ -519,6 +519,8 @@ bool SMESHGUI_RevolutionDlg::ClickOnApply()
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
if( CheckBoxMesh->isChecked() ) {
if( GetConstructorId() == 0 )
@ -546,7 +548,6 @@ bool SMESHGUI_RevolutionDlg::ClickOnApply()
aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
}
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
} catch (...) {
}

View File

@ -433,14 +433,15 @@ bool SMESHGUI_RotationDlg::ClickOnApply()
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
myMesh->SetParameters(aParameters.join(":").toLatin1().constData());
switch ( actionButton ) {
case MOVE_ELEMS_BUTTON:
if(CheckBoxMesh->isChecked())
aMeshEditor->RotateObject(mySelectedObject, anAxis, anAngle, false);
else
aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false);
if( !myMesh->_is_nil())
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
break;
case COPY_ELEMS_BUTTON:
if ( makeGroups ) {
@ -456,8 +457,6 @@ bool SMESHGUI_RotationDlg::ClickOnApply()
else
aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true);
}
if( !myMesh->_is_nil())
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
break;
case MAKE_MESH_BUTTON: {
SMESH::SMESH_Mesh_var mesh;
@ -468,7 +467,6 @@ bool SMESHGUI_RotationDlg::ClickOnApply()
mesh = aMeshEditor->RotateMakeMesh(anElementsId, anAxis, anAngle, makeGroups,
LineEditNewMesh->text().toLatin1().data());
if (!mesh->_is_nil()) {
mesh->SetParameters(aParameters.join(":").toLatin1().constData());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ

View File

@ -475,6 +475,9 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
SMESH::SMESH_IDSource_var obj;
if ( CheckBoxMesh->isChecked() )
obj = mySelectedObject;
@ -485,8 +488,6 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
case MOVE_ELEMS_BUTTON:
aMeshEditor->Scale(obj, aPoint, aScaleFact, false);
if( !myMesh->_is_nil())
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
break;
case COPY_ELEMS_BUTTON:
@ -495,8 +496,6 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
aMeshEditor->ScaleMakeGroups(obj, aPoint, aScaleFact);
else
aMeshEditor->Scale(obj, aPoint, aScaleFact, true);
if( !myMesh->_is_nil())
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
break;
case MAKE_MESH_BUTTON: {
@ -504,7 +503,6 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
aMeshEditor->ScaleMakeMesh(obj, aPoint, aScaleFact, makeGroups,
LineEditNewMesh->text().toLatin1().data());
if (!mesh->_is_nil()) {
mesh->SetParameters(aParameters.join(":").toLatin1().constData());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ

View File

@ -380,6 +380,8 @@ bool SMESHGUI_SmoothingDlg::ClickOnApply()
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
if ( CheckBoxParametric->isChecked() ) {
if(CheckBoxMesh->isChecked())
aResult = aMeshEditor->SmoothParametricObject(mySelectedObject, aNodesId.inout(),
@ -397,8 +399,6 @@ bool SMESHGUI_SmoothingDlg::ClickOnApply()
anIterationLimit, aMaxAspectRatio, aMethod);
}
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
} catch (...) {
}

View File

@ -498,6 +498,8 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply()
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
myMesh->SetParameters(aParameters.join(":").toLatin1().constData());
switch ( actionButton ) {
case MOVE_ELEMS_BUTTON: {
if(CheckBoxMesh->isChecked())
@ -505,8 +507,6 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply()
else
aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false );
if( !myMesh->_is_nil())
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
break;
}
case COPY_ELEMS_BUTTON: {
@ -523,8 +523,6 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply()
else
aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true);
}
if( !myMesh->_is_nil())
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
break;
}
case MAKE_MESH_BUTTON: {
@ -535,8 +533,6 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply()
else
mesh = aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups,
LineEditNewMesh->text().toLatin1().data());
if (!mesh->_is_nil()) {
mesh->SetParameters(aParameters.join(":").toLatin1().constData());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
@ -548,7 +544,6 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply()
}
break;
}
}
} catch (...) {
}

View File

@ -480,26 +480,23 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
anElementsId[i] = aListElementsId[i].toInt();
SMESH::DirStruct aVector;
QStringList aParameters;
if (GetConstructorId() == 0) {
aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue();
aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue();
aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue();
// not supported so far
// aParameters << QString("%1 - %2").arg( SpinBox2_1->text() ).arg( SpinBox1_1->text() );
// aParameters << QString("%1 - %2").arg( SpinBox2_2->text() ).arg( SpinBox1_2->text() );
// aParameters << QString("%1 - %2").arg( SpinBox2_3->text() ).arg( SpinBox1_3->text() );
} else if (GetConstructorId() == 1) {
aVector.PS.x = SpinBox1_1->GetValue();
aVector.PS.y = SpinBox1_2->GetValue();
aVector.PS.z = SpinBox1_3->GetValue();
}
QStringList aParameters;
aParameters << SpinBox1_1->text();
if (GetConstructorId() == 0)
aParameters << SpinBox2_1->text();
aParameters << SpinBox1_2->text();
if (GetConstructorId() == 0)
aParameters << SpinBox2_2->text();
aParameters << SpinBox1_3->text();
if (GetConstructorId() == 0)
aParameters << SpinBox2_3->text();
}
int actionButton = ActionGroup->checkedId();
bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
@ -507,14 +504,15 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
myMesh->SetParameters(aParameters.join(":").toLatin1().constData());
switch ( actionButton ) {
case MOVE_ELEMS_BUTTON:
if(CheckBoxMesh->isChecked())
aMeshEditor->TranslateObject(mySelectedObject, aVector, false);
else
aMeshEditor->Translate(anElementsId, aVector, false);
if( !myMesh->_is_nil())
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
break;
case COPY_ELEMS_BUTTON:
if ( makeGroups ) {
@ -530,10 +528,8 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
else
aMeshEditor->Translate(anElementsId, aVector, true);
}
if( !myMesh->_is_nil())
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
break;
case MAKE_MESH_BUTTON:
case MAKE_MESH_BUTTON: {
SMESH::SMESH_Mesh_var mesh;
if (CheckBoxMesh->isChecked())
mesh = aMeshEditor->TranslateObjectMakeMesh(mySelectedObject, aVector, makeGroups,
@ -541,8 +537,6 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
else
mesh = aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups,
LineEditNewMesh->text().toLatin1().data());
if (!mesh->_is_nil()) {
mesh->SetParameters(aParameters.join(":").toLatin1().constData());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ