Dump Puthon extension

This commit is contained in:
ouv 2008-12-05 09:25:04 +00:00
parent 0443165620
commit 60bd71d998
4 changed files with 82 additions and 8 deletions

View File

@ -51,6 +51,7 @@
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <SalomeApp_Tools.h> #include <SalomeApp_Tools.h>
#include <LightApp_Application.h> #include <LightApp_Application.h>
#include <SalomeApp_IntSpinBox.h>
#include <SALOME_ListIO.hxx> #include <SALOME_ListIO.hxx>
@ -76,7 +77,6 @@
#include <QRadioButton> #include <QRadioButton>
#include <QCheckBox> #include <QCheckBox>
#include <QButtonGroup> #include <QButtonGroup>
#include <QSpinBox>
#include <QList> #include <QList>
#include <QDir> #include <QDir>
#include <QFileDialog> #include <QFileDialog>
@ -246,9 +246,9 @@ QWidget* SMESHGUI_MeshPatternDlg::createMainFrame (QWidget* theParent)
mySelEdit[ Ids ] = new QLineEdit( myRefineGrp ); mySelEdit[ Ids ] = new QLineEdit( myRefineGrp );
QLabel* aNodeLbl = new QLabel( tr( "NODE_1" ), myRefineGrp ); QLabel* aNodeLbl = new QLabel( tr( "NODE_1" ), myRefineGrp );
myNode1 = new QSpinBox( myRefineGrp ); myNode1 = new SalomeApp_IntSpinBox( myRefineGrp );
myNode2Lbl = new QLabel( tr( "NODE_2" ), myRefineGrp ); myNode2Lbl = new QLabel( tr( "NODE_2" ), myRefineGrp );
myNode2 = new QSpinBox( myRefineGrp ); myNode2 = new SalomeApp_IntSpinBox( myRefineGrp );
myRefineGrpLayout->addWidget( mySelLbl[ Ids ], 0, 0 ); myRefineGrpLayout->addWidget( mySelLbl[ Ids ], 0, 0 );
myRefineGrpLayout->addWidget( mySelBtn[ Ids ], 0, 1 ); myRefineGrpLayout->addWidget( mySelBtn[ Ids ], 0, 1 );
@ -411,6 +411,24 @@ void SMESHGUI_MeshPatternDlg::Init()
//======================================================================= //=======================================================================
bool SMESHGUI_MeshPatternDlg::isValid (const bool theMess) bool SMESHGUI_MeshPatternDlg::isValid (const bool theMess)
{ {
if (isRefine())
{
QString msg;
bool ok = true;
ok = myNode1->isValid( msg, theMess ) && ok;
if (myType == Type_3d)
ok = myNode2->isValid( msg, theMess ) && ok;
if( !ok ) {
if( theMess ) {
QString str( tr( "SMESH_INCORRECT_INPUT" ) );
if ( !msg.isEmpty() )
str += "\n" + msg;
SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
}
return false;
}
}
QList<int> ids; QList<int> ids;
if ((isRefine() && if ((isRefine() &&
(myMesh->_is_nil() || !getIds(ids) || getNode(false) < 0 || (myMesh->_is_nil() || !getIds(ids) || getNode(false) < 0 ||
@ -460,6 +478,12 @@ bool SMESHGUI_MeshPatternDlg::onApply()
? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked()) ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
: myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true)); : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
QStringList aParameters;
aParameters << myNode1->text();
if(myType == Type_3d )
aParameters << myNode2->text();
myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
} else { // Applying a pattern to geometrical object } else { // Applying a pattern to geometrical object
if (myType == Type_2d) if (myType == Type_2d)
myPattern->ApplyToFace(myGeomObj[Object], myGeomObj[Vertex1], myReverseChk->isChecked()); myPattern->ApplyToFace(myGeomObj[Object], myGeomObj[Vertex1], myReverseChk->isChecked());
@ -1375,8 +1399,8 @@ void SMESHGUI_MeshPatternDlg::onTextChanged (const QString& theNewText)
void SMESHGUI_MeshPatternDlg::onNodeChanged (int value) void SMESHGUI_MeshPatternDlg::onNodeChanged (int value)
{ {
if (myType == Type_3d) { if (myType == Type_3d) {
QSpinBox* first = (QSpinBox*)sender(); SalomeApp_IntSpinBox* first = (SalomeApp_IntSpinBox*)sender();
QSpinBox* second = first == myNode1 ? myNode2 : myNode1; SalomeApp_IntSpinBox* second = first == myNode1 ? myNode2 : myNode1;
int secondVal = second->value(); int secondVal = second->value();
if (secondVal == value) { if (secondVal == value) {
secondVal = value == second->maximum() ? second->minimum() : value + 1; secondVal = value == second->maximum() ? second->minimum() : value + 1;

View File

@ -43,7 +43,7 @@ class QRadioButton;
class QCheckBox; class QCheckBox;
class QButtonGroup; class QButtonGroup;
class QLabel; class QLabel;
class QSpinBox; class SalomeApp_IntSpinBox;
class vtkUnstructuredGrid; class vtkUnstructuredGrid;
class SALOME_Actor; class SALOME_Actor;
class SVTK_Selector; class SVTK_Selector;
@ -129,8 +129,8 @@ private:
QCheckBox* myRefine; QCheckBox* myRefine;
QFrame* myRefineGrp; QFrame* myRefineGrp;
QSpinBox* myNode1; SalomeApp_IntSpinBox* myNode1;
QSpinBox* myNode2; SalomeApp_IntSpinBox* myNode2;
QLabel* myNode2Lbl; QLabel* myNode2Lbl;
QFrame* myGeomGrp; QFrame* myGeomGrp;

View File

@ -243,7 +243,15 @@ void SMESH_NoteBook::ReplaceVariables()
} }
} }
if(it == _objectMap.end()) { // additional check for pattern mapping
if(aMethod.IsEqual("ApplyToMeshFaces") ||
aMethod.IsEqual("ApplyToHexahedrons"))
it = _objectMap.find(aCmd->GetArg(1));
}
if(it != _objectMap.end()) { if(it != _objectMap.end()) {
if(MYDEBUG)
cout << "Found object : " << (*it).first << endl;
ObjectStates *aStates = (*it).second; ObjectStates *aStates = (*it).second;
// Case for LocalLength hypothesis // Case for LocalLength hypothesis
if(aStates->GetObjectType().IsEqual("LocalLength") && aStates->GetCurrectState().size() >= 2) { if(aStates->GetObjectType().IsEqual("LocalLength") && aStates->GetCurrectState().size() >= 2) {
@ -570,8 +578,20 @@ void SMESH_NoteBook::ReplaceVariables()
} }
aStates->IncrementState(); aStates->IncrementState();
} }
else if(aMethod.IsEqual("ApplyToMeshFaces") ||
aMethod.IsEqual("ApplyToHexahedrons")) {
int anArgIndex = aCmd->GetNbArgs()-1;
for(int j = 0; j < aCurrentStateSize; j++)
if(!aCurrentState.at(j).IsEmpty())
aCmd->SetArg(anArgIndex+j, aCurrentState.at(j));
aStates->IncrementState();
} }
} }
}
else {
if(MYDEBUG)
cout << "Object not found" << endl;
}
if(MYDEBUG) { if(MYDEBUG) {
cout<<"Command after: "<< aCmd->GetString()<<endl; cout<<"Command after: "<< aCmd->GetString()<<endl;
} }

View File

@ -4588,3 +4588,33 @@ class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref
#Registering the new proxy for NETGEN_SimpleParameters_3D #Registering the new proxy for NETGEN_SimpleParameters_3D
omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D) omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
class Pattern(SMESH._objref_SMESH_Pattern):
def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
flag = False
if isinstance(theNodeIndexOnKeyPoint1,str):
flag = True
theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
if flag:
theNodeIndexOnKeyPoint1 -= 1
theMesh.SetParameters(Parameters)
return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
flag0 = False
flag1 = False
if isinstance(theNode000Index,str):
flag0 = True
if isinstance(theNode001Index,str):
flag1 = True
theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
if flag0:
theNode000Index -= 1
if flag1:
theNode001Index -= 1
theMesh.SetParameters(Parameters)
return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
#Registering the new proxy for Pattern
omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)