Salome HOME
Dump Puthon extension
authorouv <ouv@opencascade.com>
Fri, 5 Dec 2008 09:25:04 +0000 (09:25 +0000)
committerouv <ouv@opencascade.com>
Fri, 5 Dec 2008 09:25:04 +0000 (09:25 +0000)
src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx
src/SMESHGUI/SMESHGUI_MeshPatternDlg.h
src/SMESH_I/SMESH_NoteBook.cxx
src/SMESH_SWIG/smeshDC.py

index dff58aebe846f4800641744f3151ccceff3d1870..81217d1a45a2f558e6ce516d973831e062cdd211 100755 (executable)
@@ -51,6 +51,7 @@
 #include <LightApp_SelectionMgr.h>
 #include <SalomeApp_Tools.h>
 #include <LightApp_Application.h>
+#include <SalomeApp_IntSpinBox.h>
 
 #include <SALOME_ListIO.hxx>
 
@@ -76,7 +77,6 @@
 #include <QRadioButton>
 #include <QCheckBox>
 #include <QButtonGroup>
-#include <QSpinBox>
 #include <QList>
 #include <QDir>
 #include <QFileDialog>
@@ -246,9 +246,9 @@ QWidget* SMESHGUI_MeshPatternDlg::createMainFrame (QWidget* theParent)
   mySelEdit[ Ids ] = new QLineEdit( 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 );
-  myNode2          = new QSpinBox( myRefineGrp );
+  myNode2          = new SalomeApp_IntSpinBox( myRefineGrp );
 
   myRefineGrpLayout->addWidget( mySelLbl[ Ids ],  0, 0 );
   myRefineGrpLayout->addWidget( mySelBtn[ Ids ],  0, 1 );
@@ -411,6 +411,24 @@ void SMESHGUI_MeshPatternDlg::Init()
 //=======================================================================
 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;
   if ((isRefine() &&
        (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->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
       if (myType == Type_2d)
         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)
 {
   if (myType == Type_3d) {
-    QSpinBox* first = (QSpinBox*)sender();
-    QSpinBox* second = first == myNode1 ? myNode2 : myNode1;
+    SalomeApp_IntSpinBox* first = (SalomeApp_IntSpinBox*)sender();
+    SalomeApp_IntSpinBox* second = first == myNode1 ? myNode2 : myNode1;
     int secondVal = second->value();
     if (secondVal == value) {
       secondVal = value == second->maximum() ? second->minimum() : value + 1;
index d74249b0e69c47b0791edac24e07b54096844afe..e24fb32d04dc6fe27ab3c5188c2ec1c4784a1476 100755 (executable)
@@ -43,7 +43,7 @@ class QRadioButton;
 class QCheckBox;
 class QButtonGroup;
 class QLabel;
-class QSpinBox;
+class SalomeApp_IntSpinBox;
 class vtkUnstructuredGrid;
 class SALOME_Actor;
 class SVTK_Selector;
@@ -129,8 +129,8 @@ private:
   QCheckBox*                          myRefine;
 
   QFrame*                             myRefineGrp;
-  QSpinBox*                           myNode1;
-  QSpinBox*                           myNode2;
+  SalomeApp_IntSpinBox*               myNode1;
+  SalomeApp_IntSpinBox*               myNode2;
   QLabel*                             myNode2Lbl;
 
   QFrame*                             myGeomGrp;
index 91ae27deff7e793c876943e25cb3098dcb941de2..e03cc0a9eaf629bd37ea6bf19bb7fb0b404adb3e 100644 (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(MYDEBUG)
+       cout << "Found object : " << (*it).first << endl;
       ObjectStates *aStates = (*it).second;
       // Case for LocalLength hypothesis
       if(aStates->GetObjectType().IsEqual("LocalLength") && aStates->GetCurrectState().size() >= 2) {
@@ -570,8 +578,20 @@ void SMESH_NoteBook::ReplaceVariables()
          }
          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) {
       cout<<"Command after: "<< aCmd->GetString()<<endl;
     }
index ff5a6c35f2a07987c245bc3c9d5698db01c3b756..a8ce37adaa334faa4d055765143dfe7929687cc6 100644 (file)
@@ -4588,3 +4588,33 @@ class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref
         
 #Registering the new proxy for 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)