Salome HOME
Implementation of the issue 0019928: EDF 771 SMESH : Extrusion (Revolution) with...
authorrnv <rnv@opencascade.com>
Thu, 8 Jan 2009 14:23:07 +0000 (14:23 +0000)
committerrnv <rnv@opencascade.com>
Thu, 8 Jan 2009 14:23:07 +0000 (14:23 +0000)
doc/salome/gui/SMESH/images/extrusionalongaline1.png
doc/salome/gui/SMESH/images/extrusionalongaline2.png
doc/salome/gui/SMESH/input/extrusion.doc
src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx
src/SMESHGUI/SMESHGUI_ExtrusionDlg.h
src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx
src/SMESHGUI/SMESHGUI_RevolutionDlg.h
src/SMESHGUI/SMESHGUI_Utils.cxx
src/SMESHGUI/SMESHGUI_Utils.h
src/SMESHGUI/SMESH_msg_en.ts

index 7d68ecfbea12f142d165a52189001d9ed7fb79e6..5458adb5f0441e401dedcfcd9554b4997902c353 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/extrusionalongaline1.png and b/doc/salome/gui/SMESH/images/extrusionalongaline1.png differ
index 797fe96976d7862f58b730ffdc018673845e6995..b98b6d2793a24fd71c4701509879420560b4dfac 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/extrusionalongaline2.png and b/doc/salome/gui/SMESH/images/extrusionalongaline2.png differ
index 674a9d9b4ce77c3a92ddc9e15d2c65f1fdfa3f50..eb4b2b98cb9873caa310fae8b2c646207a8cb0fa 100644 (file)
@@ -29,6 +29,7 @@ The following dialog box will appear:
 <li>specify the IDs of the elements which will be extruded by
 selecting them in the 3D viewer or select the whole mesh or
 submesh,</li>
+<li>specify the distance at which the elements will be extruded,</li>
 <li>specify the vector along which the elements will be extruded,</li>
 <li>number of steps.</li>
 </ul>
index e09419d7ada986b2431cdde66baeda1fed354fd4..196720eb25a7b625d1a9427b51332ed0c1564198 100644 (file)
@@ -55,6 +55,7 @@
 // OCCT includes
 #include <TColStd_MapOfInteger.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
+#include <gp_XYZ.hxx>
 
 // Qt includes
 #include <QApplication>
@@ -163,18 +164,33 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
   // Control for the whole mesh selection
   CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
 
-  // Controls for vector selection
+  //Control for the Distance selection
+  TextLabelDistance = new QLabel(tr("SMESH_DISTANCE"), GroupArguments);
+  
   TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupArguments);
-
-  TextLabelDx = new QLabel(tr("SMESH_DX"), GroupArguments);
+  TextLabelDx = new QLabel(tr("SMESH_X"), GroupArguments);
   SpinBox_Dx = new SMESHGUI_SpinBox(GroupArguments);
-
-  TextLabelDy = new QLabel(tr("SMESH_DY"), GroupArguments);
+  
+  TextLabelDy = new QLabel(tr("SMESH_Y"), GroupArguments);
   SpinBox_Dy = new SMESHGUI_SpinBox(GroupArguments);
 
-  TextLabelDz = new QLabel(tr("SMESH_DZ"), GroupArguments);
+  TextLabelDz = new QLabel(tr("SMESH_Z"), GroupArguments);
   SpinBox_Dz = new SMESHGUI_SpinBox(GroupArguments);
 
+  // Controls for vector selection
+
+  SelectVectorButton = new QPushButton(GroupArguments);
+  SelectVectorButton->setIcon(image2);
+
+  TextLabelVx = new QLabel(tr("SMESH_DX"), GroupArguments);
+  SpinBox_Vx = new SMESHGUI_SpinBox(GroupArguments);
+
+  TextLabelVy = new QLabel(tr("SMESH_DY"), GroupArguments);
+  SpinBox_Vy = new SMESHGUI_SpinBox(GroupArguments);
+
+  TextLabelVz = new QLabel(tr("SMESH_DZ"), GroupArguments);
+  SpinBox_Vz = new SMESHGUI_SpinBox(GroupArguments);
+
   // Controls for nb. steps defining
   TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments);
   SpinBox_NbSteps = new QSpinBox(GroupArguments);
@@ -186,16 +202,24 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
   GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
   GroupArgumentsLayout->addWidget(LineEditElements,     0, 2, 1, 6);
   GroupArgumentsLayout->addWidget(CheckBoxMesh,         1, 0, 1, 8);
-  GroupArgumentsLayout->addWidget(TextLabelVector,      2, 0);
+  GroupArgumentsLayout->addWidget(TextLabelDistance,    2, 0);
   GroupArgumentsLayout->addWidget(TextLabelDx,          2, 2);
   GroupArgumentsLayout->addWidget(SpinBox_Dx,           2, 3);
   GroupArgumentsLayout->addWidget(TextLabelDy,          2, 4);
   GroupArgumentsLayout->addWidget(SpinBox_Dy,           2, 5);
   GroupArgumentsLayout->addWidget(TextLabelDz,          2, 6);
   GroupArgumentsLayout->addWidget(SpinBox_Dz,           2, 7);
-  GroupArgumentsLayout->addWidget(TextLabelNbSteps,     3, 0);
-  GroupArgumentsLayout->addWidget(SpinBox_NbSteps,      3, 2, 1, 6);
-  GroupArgumentsLayout->addWidget(MakeGroupsCheck,      4, 0, 1, 8);
+  GroupArgumentsLayout->addWidget(TextLabelVector,      3, 0);
+  GroupArgumentsLayout->addWidget(SelectVectorButton,   3, 1);
+  GroupArgumentsLayout->addWidget(TextLabelVx,          3, 2);
+  GroupArgumentsLayout->addWidget(SpinBox_Vx,           3, 3);
+  GroupArgumentsLayout->addWidget(TextLabelVy,          3, 4);
+  GroupArgumentsLayout->addWidget(SpinBox_Vy,           3, 5);
+  GroupArgumentsLayout->addWidget(TextLabelVz,          3, 6);
+  GroupArgumentsLayout->addWidget(SpinBox_Vz,           3, 7);
+  GroupArgumentsLayout->addWidget(TextLabelNbSteps,     4, 0);
+  GroupArgumentsLayout->addWidget(SpinBox_NbSteps,      4, 2, 1, 6);
+  GroupArgumentsLayout->addWidget(MakeGroupsCheck,      5, 0, 1, 8);
 
   /***************************************************************/
   SMESHGUI_ExtrusionDlgLayout->addWidget(ConstructorsBox);
@@ -203,10 +227,14 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
   SMESHGUI_ExtrusionDlgLayout->addWidget(GroupButtons);
 
   /* Initialisations */
+  SpinBox_Vx->RangeStepAndValidator(-1, 1, 0.01, 3);
+  SpinBox_Vy->RangeStepAndValidator(-1, 1, 0.01, 3);
+  SpinBox_Vz->RangeStepAndValidator(-1, 1, 0.01, 3);
+
   SpinBox_Dx->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
   SpinBox_Dy->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
   SpinBox_Dz->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
-
+  
   SpinBox_NbSteps->setRange(1, 999999);
 
   RadioButton1->setChecked(true);
@@ -239,12 +267,16 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
 
   // to update state of the Ok & Apply buttons
+  connect(SpinBox_Vx, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
+  connect(SpinBox_Vy, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
+  connect(SpinBox_Vz, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
   connect(SpinBox_Dx, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
   connect(SpinBox_Dy, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
   connect(SpinBox_Dz, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
 
   connect(GroupConstructors,    SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
   connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+  connect(SelectVectorButton,   SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(mySMESHGUI,           SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
   connect(mySelectionMgr,       SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
   /* to close dialog if study change */
@@ -285,6 +317,9 @@ void SMESHGUI_ExtrusionDlg::Init (bool ResetControls)
     SpinBox_Dx->SetValue(0);
     SpinBox_Dy->SetValue(0);
     SpinBox_Dz->SetValue(0);
+    SpinBox_Vx->SetValue(0);
+    SpinBox_Vy->SetValue(0);
+    SpinBox_Vz->SetValue(0);
 
     CheckBoxMesh->setChecked(false);
     onSelectMesh(false);
@@ -299,9 +334,10 @@ void SMESHGUI_ExtrusionDlg::Init (bool ResetControls)
 //=================================================================================
 void SMESHGUI_ExtrusionDlg::CheckIsEnable()
 {
-  double aX = SpinBox_Dx->GetValue();
-  double aY = SpinBox_Dy->GetValue();
-  double aZ = SpinBox_Dz->GetValue();
+  
+  double aX = SpinBox_Vx->GetValue()*SpinBox_Dx->GetValue();
+  double aY = SpinBox_Vy->GetValue()*SpinBox_Dy->GetValue();
+  double aZ = SpinBox_Vz->GetValue()*SpinBox_Dz->GetValue();
   double aModule = sqrt(aX*aX + aY*aY + aZ*aZ);
   
   bool anIsEnable = myNbOkElements > 0 && aModule > 1.0E-38;
@@ -341,7 +377,7 @@ void SMESHGUI_ExtrusionDlg::ConstructorsClicked (int constructorId)
     }
   }
 
-  myEditCurrentArgument = LineEditElements;
+  myEditCurrentArgument = (QWidget*)LineEditElements;
   LineEditElements->setFocus();
 
   if (CheckBoxMesh->isChecked())
@@ -360,11 +396,17 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
     return false;
 
   if (myNbOkElements) {
-
+    
+    gp_XYZ aNormale(SpinBox_Vx->GetValue(),
+                    SpinBox_Vy->GetValue(),
+                    SpinBox_Vz->GetValue());
+    
+    aNormale /= aNormale.Modulus();
+    
     SMESH::DirStruct aVector;
-    aVector.PS.x = SpinBox_Dx->GetValue();
-    aVector.PS.y = SpinBox_Dy->GetValue();
-    aVector.PS.z = SpinBox_Dz->GetValue();
+    aVector.PS.x = SpinBox_Dx->GetValue()*aNormale.X();
+    aVector.PS.y = SpinBox_Dy->GetValue()*aNormale.Y();
+    aVector.PS.z = SpinBox_Dz->GetValue()*aNormale.Z();
 
     long aNbSteps = (long)SpinBox_NbSteps->value();
 
@@ -514,15 +556,15 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
   // clear
   myActor = 0;
   myIO.Nullify();
-  QString aString = "";
 
+  QString aString = "";
   // set busy flag
-  myBusy = true;
-
-  myEditCurrentArgument->setText(aString);
-  myNbOkElements = 0;
-  myBusy = false;
-
+  if(myEditCurrentArgument == (QWidget*)LineEditElements) {
+    myBusy = true;
+    LineEditElements->setText(aString);
+    myNbOkElements = 0;
+    myBusy = false;
+  }
   // get selected mesh
   SALOME_ListIO aList;
   mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
@@ -537,7 +579,7 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
   myIO = IO;
   myActor = SMESH::FindActorByObject(myMesh);
 
-  if (myEditCurrentArgument == LineEditElements) {
+  if (myEditCurrentArgument == (QWidget*)LineEditElements) {    
     int aNbElements = 0;
 
     // MakeGroups is available if there are groups
@@ -595,12 +637,32 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
       return;
 
     myNbOkElements = true;
+
+    myBusy = true;
+    ((QLineEdit*)myEditCurrentArgument)->setText(aString);
+    myBusy = false;
   }
+  else if(myEditCurrentArgument == (QWidget*)SpinBox_Vx){
+    TColStd_IndexedMapOfInteger aMapIndex;
+    mySelector->GetIndex(IO,aMapIndex);
+    int aNbElements = aMapIndex.Extent();
+    SMDS_Mesh* aMesh =  myActor ? myActor->GetObject()->GetMesh() : 0;
 
-  myBusy = true;
-  myEditCurrentArgument->setText(aString);
-  myBusy = false;
+    if(aNbElements != 1 || !aMesh)
+      return;
+    
+    const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aMapIndex(aNbElements)));
+
+    if (!face)
+      return;
 
+    gp_XYZ aNormale = SMESH::getNormale(face);
+    SpinBox_Vx->SetValue(aNormale.X());
+    SpinBox_Vy->SetValue(aNormale.Y());
+    SpinBox_Vz->SetValue(aNormale.Z());
+    
+  }
+  
   // OK
   CheckIsEnable();
 }
@@ -618,7 +680,7 @@ void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument()
   mySelectionMgr->clearFilters();
 
   if (send == SelectElementsButton) {
-    myEditCurrentArgument = LineEditElements;
+    myEditCurrentArgument = (QWidget*)LineEditElements;
     if (CheckBoxMesh->isChecked()) {
       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
        aViewWindow->SetSelectionMode(ActorSelection);
@@ -637,7 +699,12 @@ void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument()
        }
     }
   }
-
+  else if (send == SelectVectorButton){
+    myEditCurrentArgument = (QWidget*)SpinBox_Vx;
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->SetSelectionMode(FaceSelection);
+  }
+  
   myEditCurrentArgument->setFocus();
   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
   SelectionIntoArgument();
index f9cffd5d292322a647bf262a806274391721ff17..252ac02749d291f71d08032484f1472d5c546d11 100644 (file)
@@ -77,7 +77,7 @@ private:
   SMESHGUI*                        mySMESHGUI;            /* Current SMESHGUI object */
   SMESHGUI_IdValidator*            myIdValidator;
   LightApp_SelectionMgr*           mySelectionMgr;        /* User shape selection */
-  QLineEdit*                       myEditCurrentArgument; /* Current  LineEdit */
+  QWidget*                         myEditCurrentArgument; /* Current  argument editor */
   int                              myNbOkElements;        /* to check when elements are defined */
   SVTK_Selector*                   mySelector;
 
@@ -100,12 +100,20 @@ private:
   QLineEdit*                       LineEditElements;
   QCheckBox*                       CheckBoxMesh;
   QLabel*                          TextLabelVector;
+  QLabel*                          TextLabelDistance;
+  QPushButton*                     SelectVectorButton;
   QLabel*                          TextLabelDx;
   SMESHGUI_SpinBox*                SpinBox_Dx;
   QLabel*                          TextLabelDy;
   SMESHGUI_SpinBox*                SpinBox_Dy;
   QLabel*                          TextLabelDz;
   SMESHGUI_SpinBox*                SpinBox_Dz;
+  QLabel*                          TextLabelVx;
+  SMESHGUI_SpinBox*                SpinBox_Vx;
+  QLabel*                          TextLabelVy;
+  SMESHGUI_SpinBox*                SpinBox_Vy;
+  QLabel*                          TextLabelVz;
+  SMESHGUI_SpinBox*                SpinBox_Vz;
   QLabel*                          TextLabelNbSteps;
   QSpinBox*                        SpinBox_NbSteps;
   QCheckBox*                       MakeGroupsCheck;
index b780afd4a4e11bf3f18b2a56ea05017a96f1e050..a8a49d119bc5d613df66e0bfadf6788d18bec299 100644 (file)
@@ -72,6 +72,7 @@
 #include <QGridLayout>
 #include <QSpinBox>
 #include <QKeyEvent>
+#include <QMenu>
 
 // IDL includes
 #include <SALOMEconfig.h>
@@ -88,7 +89,8 @@
 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
   : QDialog( SMESH::GetDesktop( theModule ) ),
     mySMESHGUI( theModule ),
-    mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+    mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+    myVectorDefinition(NONE_SELECT)
 {
   mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
 
@@ -305,6 +307,12 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
 
   Init();
 
+  /*Create menu to vector selection*/
+  SelectVectorMenu = new QMenu(this);
+  myMenuActions[SelectVectorMenu->addAction( tr( "MEN_POINT_SELECT" ) )] = POINT_SELECT;
+  myMenuActions[SelectVectorMenu->addAction( tr( "MEN_FACE_SELECT" ) )] = FACE_SELECT;
+  connect( SelectVectorMenu, SIGNAL( triggered( QAction* ) ), SLOT( onSelectVectorMenu( QAction* ) ) );
+
   /* signals and slots connections */
   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
@@ -314,7 +322,7 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
 
   connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(SelectPointButton,    SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-  connect(SelectVectorButton,   SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+  connect(SelectVectorButton,   SIGNAL(clicked()), this, SLOT(onSelectVectorButton()));
 
   connect(SpinBox_X,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
   connect(SpinBox_Y,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
@@ -729,30 +737,57 @@ void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
 
     myNbOkElements = true;
   } else {
-    aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
-    if (aNbUnits != 1)
-      return;
 
     SMDS_Mesh* aMesh =  myActor->GetObject()->GetMesh();
     if (!aMesh)
       return;
 
-    const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
-    if (!n)
+    bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
+                           (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
+                            myVectorDefinition==POINT_SELECT));
+
+    bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
+                           myVectorDefinition==FACE_SELECT);
+
+    if(isNodeSelected) {
+      aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
+    }
+    else if(isFaceSelected){
+      aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
+    }
+    
+    if (aNbUnits != 1)
       return;
 
-    double x = n->X();
-    double y = n->Y();
-    double z = n->Z();
-
-    if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
-      SpinBox_X->SetValue(x);
-      SpinBox_Y->SetValue(y);
-      SpinBox_Z->SetValue(z);
-    } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
-      SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
-      SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
-      SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
+    if(isNodeSelected) {
+      const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
+      if (!n)
+        return;
+
+      double x = n->X();
+      double y = n->Y();
+      double z = n->Z();
+
+      if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
+        SpinBox_X->SetValue(x);
+        SpinBox_Y->SetValue(y);
+        SpinBox_Z->SetValue(z);
+      } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
+        SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
+        SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
+        SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
+      }
+    }
+    else if(isFaceSelected){
+      const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
+      if (!face)
+        return;
+      
+      gp_XYZ aNormale = SMESH::getNormale(face);
+      SpinBox_DX->SetValue(aNormale.X());
+      SpinBox_DY->SetValue(aNormale.Y());
+      SpinBox_DZ->SetValue(aNormale.Z());
+      
     }
   }
 
@@ -808,12 +843,6 @@ void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
     SMESH::SetPointRepresentation(true);
     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
       aViewWindow->SetSelectionMode(NodeSelection);
-  } else if (send == SelectVectorButton) {
-    myEditCurrentArgument = (QWidget*)SpinBox_DX;
-    SMESH::SetPointRepresentation(true);
-    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-      aViewWindow->SetSelectionMode(NodeSelection);
-  } else {
   }
 
   myEditCurrentArgument->setFocus();
@@ -1051,3 +1080,42 @@ void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
     mySimulation->SetVisibility(false);
   }
 }
+
+//=================================================================================
+// function : onSelectVectorButton()
+// purpose  : [slot]
+//=================================================================================
+void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
+  if(SelectVectorMenu) {
+    SelectVectorMenu->exec( QCursor::pos() );
+  }
+}
+
+//=================================================================================
+// function : onSelectVectorMenu()
+// purpose  : [slot]
+//=================================================================================
+void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
+  if(!action)
+    return;
+
+  switch(myMenuActions[action]) {
+  case POINT_SELECT: 
+    SMESH::SetPointRepresentation(true);
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->SetSelectionMode(NodeSelection);
+    break;
+    
+  case FACE_SELECT: 
+    SMESH::SetPointRepresentation(false);
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->SetSelectionMode(FaceSelection);
+    break;
+  }
+
+  myVectorDefinition = myMenuActions[action];
+  myEditCurrentArgument = (QWidget*)SpinBox_DX;
+  myEditCurrentArgument->setFocus();
+  connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  SelectionIntoArgument();
+}
index 206d737ebdc049adf882c840b8e70f9edc7e0643..0395e21a02eff645d36c608c44d2cf8dee1c5623 100644 (file)
@@ -31,6 +31,7 @@
 
 // Qt includes
 #include <QDialog>
+#include <QMap>
 
 // IDL includes
 #include <SALOMEconfig.h>
@@ -53,6 +54,8 @@ class LightApp_SelectionMgr;
 class SMESH_LogicalFilter;
 class SALOME_Actor;
 class SMESHGUI_MeshEditPreview;
+class QMenu;
+class QAction;
 
 //=================================================================================
 // class    : SMESHGUI_RevolutionDlg
@@ -67,6 +70,8 @@ public:
   ~SMESHGUI_RevolutionDlg();
 
 private:
+  enum {NONE_SELECT, POINT_SELECT, FACE_SELECT};
+  
   void                      Init( bool = true);
   void                      closeEvent( QCloseEvent* );
   void                      enterEvent( QEvent* );           /* mouse enter the QWidget */
@@ -135,6 +140,11 @@ private:
   QSpinBox*                 SpinBox_NbSteps;
   QLabel*                   TextLabelTolerance;
   SMESHGUI_SpinBox*         SpinBox_Tolerance;
+
+  QMenu*                    SelectVectorMenu;
+  QMap<QAction*,int>        myMenuActions;
+  int                       myVectorDefinition;
+
   
   QString                   myHelpFileName;
   
@@ -153,6 +163,8 @@ private slots:
   void                      onVectorChanged();
   void                      toDisplaySimulation();
   void                      onDisplaySimulation( bool );
+  void                      onSelectVectorMenu( QAction* );
+  void                      onSelectVectorButton();
 };
 
 #endif // SMESHGUI_REVOLUTIONDLG_H
index 5a8866a665d672b28fdfdf95a7af6fcbfa3d81fb..fdc83bb2a718caf2412608feeb69c37b0f127086 100644 (file)
 
 // SMESH includes
 #include "SMESHGUI_Utils.h"
-
 #include "SMESHGUI.h"
 
+#include <SMDS_MeshNode.hxx>
+#include <SMDS_MeshFace.hxx>
+
 // SALOME GUI includes
 #include <SUIT_Desktop.h>
 #include <SUIT_Session.h>
 
 #include <SALOME_ListIO.hxx>
 
+// OCC includes
+#include <gp_XYZ.hxx>
+#include <TColgp_Array1OfXYZ.hxx>
+
 namespace SMESH
 {
   SUIT_Desktop*
@@ -300,4 +306,35 @@ namespace SMESH
                               arg(theHelpFileName));
     }
   }
+
+  //=======================================================================
+  /**
+     Return normale to a given face
+  */
+  //=======================================================================
+  gp_XYZ getNormale( const SMDS_MeshFace* theFace )
+  {
+    gp_XYZ n;
+    int aNbNode = theFace->NbNodes();
+    TColgp_Array1OfXYZ anArrOfXYZ(1,4);
+    SMDS_ElemIteratorPtr aNodeItr = theFace->nodesIterator();
+    int i = 1;
+    for ( ; aNodeItr->more() && i <= 4; i++ ) {
+      SMDS_MeshNode* aNode = (SMDS_MeshNode*)aNodeItr->next();
+      anArrOfXYZ.SetValue(i, gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) );
+    }
+    
+    gp_XYZ q1 = anArrOfXYZ.Value(2) - anArrOfXYZ.Value(1);
+    gp_XYZ q2 = anArrOfXYZ.Value(3) - anArrOfXYZ.Value(1);
+    n  = q1 ^ q2;
+    if ( aNbNode > 3 ) {
+      gp_XYZ q3 = anArrOfXYZ.Value(4) - anArrOfXYZ.Value(1);
+      n += q2 ^ q3;
+    }
+    double len = n.Modulus();
+    if ( len > 0 )
+      n /= len;
+    return n;
+  }
+  
 } // end of namespace SMESH
index d34944d0301f6975827f84b5f53f8dc4d962f629..b4f150ac52c0bdce1dc3d41765b2cc24f6438316 100644 (file)
@@ -39,6 +39,9 @@
 #include <SALOME_InteractiveObject.hxx>
 #include <LightApp_DataOwner.h>
 
+//OCC includes
+#include <gp_XYZ.hxx>
+
 class SUIT_ViewWindow;
 class SUIT_Desktop;
 class SUIT_Study;
@@ -53,6 +56,8 @@ class SalomeApp_Study;
 class SalomeApp_Module;
 class LightApp_SelectionMgr;
 
+class SMDS_MeshFace;
+
 namespace SMESH
 {
 SMESHGUI_EXPORT
@@ -158,6 +163,15 @@ SMESHGUI_EXPORT
 
 SMESHGUI_EXPORT
   void ShowHelpFile( const QString& );
+
+  /*!
+   * \brief Return the normal to a face
+    * \param theFace - input face
+    * \retval gp_XYZ - normal to a face 
+   */
+SMESHGUI_EXPORT
+  gp_XYZ getNormale( const SMDS_MeshFace* theFace );
+
 }
 
 #endif // SMESHGUI_UTILS_H
index 31bd404cec2c30697d38c008162cc945e1c2cf25..baa4a12323794de54b303f86aeb7716a8712315e 100644 (file)
@@ -4366,6 +4366,14 @@ It is impossible to read point coordinates from file</translation>
             <source>TOTAL_ANGLE</source>
             <translation>Total Angle</translation>
         </message>
+       <message>
+           <source>MEN_POINT_SELECT</source>
+            <translation>Select Point</translation>
+        </message>
+       <message>
+           <source>MEN_FACE_SELECT</source>
+            <translation>Select Plane</translation>
+        </message>     
     </context>
     <context>
         <name>SMESHGUI_SewingDlg</name>