From: rnv Date: Thu, 8 Jan 2009 14:23:07 +0000 (+0000) Subject: Implementation of the issue 0019928: EDF 771 SMESH : Extrusion (Revolution) with... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a073e494679045b2f871ca7a6c966fd7bbdddcf1;p=modules%2Fsmesh.git Implementation of the issue 0019928: EDF 771 SMESH : Extrusion (Revolution) with normal to a face. --- diff --git a/doc/salome/gui/SMESH/images/extrusionalongaline1.png b/doc/salome/gui/SMESH/images/extrusionalongaline1.png index 7d68ecfbe..5458adb5f 100755 Binary files a/doc/salome/gui/SMESH/images/extrusionalongaline1.png and b/doc/salome/gui/SMESH/images/extrusionalongaline1.png differ diff --git a/doc/salome/gui/SMESH/images/extrusionalongaline2.png b/doc/salome/gui/SMESH/images/extrusionalongaline2.png index 797fe9697..b98b6d279 100755 Binary files a/doc/salome/gui/SMESH/images/extrusionalongaline2.png and b/doc/salome/gui/SMESH/images/extrusionalongaline2.png differ diff --git a/doc/salome/gui/SMESH/input/extrusion.doc b/doc/salome/gui/SMESH/input/extrusion.doc index 674a9d9b4..eb4b2b98c 100644 --- a/doc/salome/gui/SMESH/input/extrusion.doc +++ b/doc/salome/gui/SMESH/input/extrusion.doc @@ -29,6 +29,7 @@ The following dialog box will appear:
  • specify the IDs of the elements which will be extruded by selecting them in the 3D viewer or select the whole mesh or submesh,
  • +
  • specify the distance at which the elements will be extruded,
  • specify the vector along which the elements will be extruded,
  • number of steps.
  • diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx index e09419d7a..196720eb2 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx @@ -55,6 +55,7 @@ // OCCT includes #include #include +#include // Qt includes #include @@ -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(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(); diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h index f9cffd5d2..252ac0274 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h @@ -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; diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx index b780afd4a..a8a49d119 100644 --- a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx @@ -72,6 +72,7 @@ #include #include #include +#include // IDL includes #include @@ -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(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(); +} diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.h b/src/SMESHGUI/SMESHGUI_RevolutionDlg.h index 206d737eb..0395e21a0 100644 --- a/src/SMESHGUI/SMESHGUI_RevolutionDlg.h +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.h @@ -31,6 +31,7 @@ // Qt includes #include +#include // IDL includes #include @@ -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 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 diff --git a/src/SMESHGUI/SMESHGUI_Utils.cxx b/src/SMESHGUI/SMESHGUI_Utils.cxx index 5a8866a66..fdc83bb2a 100644 --- a/src/SMESHGUI/SMESHGUI_Utils.cxx +++ b/src/SMESHGUI/SMESHGUI_Utils.cxx @@ -25,9 +25,11 @@ // SMESH includes #include "SMESHGUI_Utils.h" - #include "SMESHGUI.h" +#include +#include + // SALOME GUI includes #include #include @@ -41,6 +43,10 @@ #include +// OCC includes +#include +#include + 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 diff --git a/src/SMESHGUI/SMESHGUI_Utils.h b/src/SMESHGUI/SMESHGUI_Utils.h index d34944d03..b4f150ac5 100644 --- a/src/SMESHGUI/SMESHGUI_Utils.h +++ b/src/SMESHGUI/SMESHGUI_Utils.h @@ -39,6 +39,9 @@ #include #include +//OCC includes +#include + 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 diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 31bd404ce..baa4a1232 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -4366,6 +4366,14 @@ It is impossible to read point coordinates from file TOTAL_ANGLE Total Angle + + MEN_POINT_SELECT + Select Point + + + MEN_FACE_SELECT + Select Plane + SMESHGUI_SewingDlg