Implementation of the issue 0019928: EDF 771 SMESH : Extrusion (Revolution) with normal to a face.

This commit is contained in:
rnv 2009-01-08 14:23:07 +00:00
parent a725790c5c
commit a073e49467
10 changed files with 273 additions and 58 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -29,6 +29,7 @@ The following dialog box will appear:
<li>specify the IDs of the elements which will be extruded by <li>specify the IDs of the elements which will be extruded by
selecting them in the 3D viewer or select the whole mesh or selecting them in the 3D viewer or select the whole mesh or
submesh,</li> 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>specify the vector along which the elements will be extruded,</li>
<li>number of steps.</li> <li>number of steps.</li>
</ul> </ul>

View File

@ -55,6 +55,7 @@
// OCCT includes // OCCT includes
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
#include <gp_XYZ.hxx>
// Qt includes // Qt includes
#include <QApplication> #include <QApplication>
@ -163,18 +164,33 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
// Control for the whole mesh selection // Control for the whole mesh selection
CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments); 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); TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupArguments);
TextLabelDx = new QLabel(tr("SMESH_X"), GroupArguments);
TextLabelDx = new QLabel(tr("SMESH_DX"), GroupArguments);
SpinBox_Dx = new SMESHGUI_SpinBox(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); 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); 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 // Controls for nb. steps defining
TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments); TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments);
SpinBox_NbSteps = new QSpinBox(GroupArguments); SpinBox_NbSteps = new QSpinBox(GroupArguments);
@ -186,16 +202,24 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 6); GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 6);
GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 8); GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 8);
GroupArgumentsLayout->addWidget(TextLabelVector, 2, 0); GroupArgumentsLayout->addWidget(TextLabelDistance, 2, 0);
GroupArgumentsLayout->addWidget(TextLabelDx, 2, 2); GroupArgumentsLayout->addWidget(TextLabelDx, 2, 2);
GroupArgumentsLayout->addWidget(SpinBox_Dx, 2, 3); GroupArgumentsLayout->addWidget(SpinBox_Dx, 2, 3);
GroupArgumentsLayout->addWidget(TextLabelDy, 2, 4); GroupArgumentsLayout->addWidget(TextLabelDy, 2, 4);
GroupArgumentsLayout->addWidget(SpinBox_Dy, 2, 5); GroupArgumentsLayout->addWidget(SpinBox_Dy, 2, 5);
GroupArgumentsLayout->addWidget(TextLabelDz, 2, 6); GroupArgumentsLayout->addWidget(TextLabelDz, 2, 6);
GroupArgumentsLayout->addWidget(SpinBox_Dz, 2, 7); GroupArgumentsLayout->addWidget(SpinBox_Dz, 2, 7);
GroupArgumentsLayout->addWidget(TextLabelNbSteps, 3, 0); GroupArgumentsLayout->addWidget(TextLabelVector, 3, 0);
GroupArgumentsLayout->addWidget(SpinBox_NbSteps, 3, 2, 1, 6); GroupArgumentsLayout->addWidget(SelectVectorButton, 3, 1);
GroupArgumentsLayout->addWidget(MakeGroupsCheck, 4, 0, 1, 8); 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); SMESHGUI_ExtrusionDlgLayout->addWidget(ConstructorsBox);
@ -203,10 +227,14 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
SMESHGUI_ExtrusionDlgLayout->addWidget(GroupButtons); SMESHGUI_ExtrusionDlgLayout->addWidget(GroupButtons);
/* Initialisations */ /* 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_Dx->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
SpinBox_Dy->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_Dz->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
SpinBox_NbSteps->setRange(1, 999999); SpinBox_NbSteps->setRange(1, 999999);
RadioButton1->setChecked(true); RadioButton1->setChecked(true);
@ -239,12 +267,16 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp())); connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
// to update state of the Ok & Apply buttons // 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_Dx, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
connect(SpinBox_Dy, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable())); connect(SpinBox_Dy, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
connect(SpinBox_Dz, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable())); connect(SpinBox_Dz, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int))); connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
/* to close dialog if study change */ /* to close dialog if study change */
@ -285,6 +317,9 @@ void SMESHGUI_ExtrusionDlg::Init (bool ResetControls)
SpinBox_Dx->SetValue(0); SpinBox_Dx->SetValue(0);
SpinBox_Dy->SetValue(0); SpinBox_Dy->SetValue(0);
SpinBox_Dz->SetValue(0); SpinBox_Dz->SetValue(0);
SpinBox_Vx->SetValue(0);
SpinBox_Vy->SetValue(0);
SpinBox_Vz->SetValue(0);
CheckBoxMesh->setChecked(false); CheckBoxMesh->setChecked(false);
onSelectMesh(false); onSelectMesh(false);
@ -299,9 +334,10 @@ void SMESHGUI_ExtrusionDlg::Init (bool ResetControls)
//================================================================================= //=================================================================================
void SMESHGUI_ExtrusionDlg::CheckIsEnable() void SMESHGUI_ExtrusionDlg::CheckIsEnable()
{ {
double aX = SpinBox_Dx->GetValue();
double aY = SpinBox_Dy->GetValue(); double aX = SpinBox_Vx->GetValue()*SpinBox_Dx->GetValue();
double aZ = SpinBox_Dz->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); double aModule = sqrt(aX*aX + aY*aY + aZ*aZ);
bool anIsEnable = myNbOkElements > 0 && aModule > 1.0E-38; 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(); LineEditElements->setFocus();
if (CheckBoxMesh->isChecked()) if (CheckBoxMesh->isChecked())
@ -360,11 +396,17 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
return false; return false;
if (myNbOkElements) { if (myNbOkElements) {
gp_XYZ aNormale(SpinBox_Vx->GetValue(),
SpinBox_Vy->GetValue(),
SpinBox_Vz->GetValue());
aNormale /= aNormale.Modulus();
SMESH::DirStruct aVector; SMESH::DirStruct aVector;
aVector.PS.x = SpinBox_Dx->GetValue(); aVector.PS.x = SpinBox_Dx->GetValue()*aNormale.X();
aVector.PS.y = SpinBox_Dy->GetValue(); aVector.PS.y = SpinBox_Dy->GetValue()*aNormale.Y();
aVector.PS.z = SpinBox_Dz->GetValue(); aVector.PS.z = SpinBox_Dz->GetValue()*aNormale.Z();
long aNbSteps = (long)SpinBox_NbSteps->value(); long aNbSteps = (long)SpinBox_NbSteps->value();
@ -514,15 +556,15 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
// clear // clear
myActor = 0; myActor = 0;
myIO.Nullify(); myIO.Nullify();
QString aString = ""; QString aString = "";
// set busy flag // set busy flag
myBusy = true; if(myEditCurrentArgument == (QWidget*)LineEditElements) {
myBusy = true;
myEditCurrentArgument->setText(aString); LineEditElements->setText(aString);
myNbOkElements = 0; myNbOkElements = 0;
myBusy = false; myBusy = false;
}
// get selected mesh // get selected mesh
SALOME_ListIO aList; SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type()); mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
@ -537,7 +579,7 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
myIO = IO; myIO = IO;
myActor = SMESH::FindActorByObject(myMesh); myActor = SMESH::FindActorByObject(myMesh);
if (myEditCurrentArgument == LineEditElements) { if (myEditCurrentArgument == (QWidget*)LineEditElements) {
int aNbElements = 0; int aNbElements = 0;
// MakeGroups is available if there are groups // MakeGroups is available if there are groups
@ -595,12 +637,32 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
return; return;
myNbOkElements = true; 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; if(aNbElements != 1 || !aMesh)
myEditCurrentArgument->setText(aString); return;
myBusy = false;
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 // OK
CheckIsEnable(); CheckIsEnable();
} }
@ -618,7 +680,7 @@ void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument()
mySelectionMgr->clearFilters(); mySelectionMgr->clearFilters();
if (send == SelectElementsButton) { if (send == SelectElementsButton) {
myEditCurrentArgument = LineEditElements; myEditCurrentArgument = (QWidget*)LineEditElements;
if (CheckBoxMesh->isChecked()) { if (CheckBoxMesh->isChecked()) {
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection); 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(); myEditCurrentArgument->setFocus();
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
SelectionIntoArgument(); SelectionIntoArgument();

View File

@ -77,7 +77,7 @@ private:
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator; SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */ QWidget* myEditCurrentArgument; /* Current argument editor */
int myNbOkElements; /* to check when elements are defined */ int myNbOkElements; /* to check when elements are defined */
SVTK_Selector* mySelector; SVTK_Selector* mySelector;
@ -100,12 +100,20 @@ private:
QLineEdit* LineEditElements; QLineEdit* LineEditElements;
QCheckBox* CheckBoxMesh; QCheckBox* CheckBoxMesh;
QLabel* TextLabelVector; QLabel* TextLabelVector;
QLabel* TextLabelDistance;
QPushButton* SelectVectorButton;
QLabel* TextLabelDx; QLabel* TextLabelDx;
SMESHGUI_SpinBox* SpinBox_Dx; SMESHGUI_SpinBox* SpinBox_Dx;
QLabel* TextLabelDy; QLabel* TextLabelDy;
SMESHGUI_SpinBox* SpinBox_Dy; SMESHGUI_SpinBox* SpinBox_Dy;
QLabel* TextLabelDz; QLabel* TextLabelDz;
SMESHGUI_SpinBox* SpinBox_Dz; SMESHGUI_SpinBox* SpinBox_Dz;
QLabel* TextLabelVx;
SMESHGUI_SpinBox* SpinBox_Vx;
QLabel* TextLabelVy;
SMESHGUI_SpinBox* SpinBox_Vy;
QLabel* TextLabelVz;
SMESHGUI_SpinBox* SpinBox_Vz;
QLabel* TextLabelNbSteps; QLabel* TextLabelNbSteps;
QSpinBox* SpinBox_NbSteps; QSpinBox* SpinBox_NbSteps;
QCheckBox* MakeGroupsCheck; QCheckBox* MakeGroupsCheck;

View File

@ -72,6 +72,7 @@
#include <QGridLayout> #include <QGridLayout>
#include <QSpinBox> #include <QSpinBox>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMenu>
// IDL includes // IDL includes
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
@ -88,7 +89,8 @@
SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule ) SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
: QDialog( SMESH::GetDesktop( theModule ) ), : QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ), mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
myVectorDefinition(NONE_SELECT)
{ {
mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI )); mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
@ -305,6 +307,12 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
Init(); 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 */ /* signals and slots connections */
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); 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(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(SelectPointButton, 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_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_Y, 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; myNbOkElements = true;
} else { } else {
aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
if (aNbUnits != 1)
return;
SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
if (!aMesh) if (!aMesh)
return; return;
const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt()); bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
if (!n) (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; return;
double x = n->X(); if(isNodeSelected) {
double y = n->Y(); const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
double z = n->Z(); if (!n)
return;
if (myEditCurrentArgument == (QWidget*)SpinBox_X) { double x = n->X();
SpinBox_X->SetValue(x); double y = n->Y();
SpinBox_Y->SetValue(y); double z = n->Z();
SpinBox_Z->SetValue(z);
} else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) { if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
SpinBox_DX->SetValue(x - SpinBox_X->GetValue()); SpinBox_X->SetValue(x);
SpinBox_DY->SetValue(y - SpinBox_Y->GetValue()); SpinBox_Y->SetValue(y);
SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue()); 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); SMESH::SetPointRepresentation(true);
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(NodeSelection); 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(); myEditCurrentArgument->setFocus();
@ -1051,3 +1080,42 @@ void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
mySimulation->SetVisibility(false); 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();
}

View File

@ -31,6 +31,7 @@
// Qt includes // Qt includes
#include <QDialog> #include <QDialog>
#include <QMap>
// IDL includes // IDL includes
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
@ -53,6 +54,8 @@ class LightApp_SelectionMgr;
class SMESH_LogicalFilter; class SMESH_LogicalFilter;
class SALOME_Actor; class SALOME_Actor;
class SMESHGUI_MeshEditPreview; class SMESHGUI_MeshEditPreview;
class QMenu;
class QAction;
//================================================================================= //=================================================================================
// class : SMESHGUI_RevolutionDlg // class : SMESHGUI_RevolutionDlg
@ -67,6 +70,8 @@ public:
~SMESHGUI_RevolutionDlg(); ~SMESHGUI_RevolutionDlg();
private: private:
enum {NONE_SELECT, POINT_SELECT, FACE_SELECT};
void Init( bool = true); void Init( bool = true);
void closeEvent( QCloseEvent* ); void closeEvent( QCloseEvent* );
void enterEvent( QEvent* ); /* mouse enter the QWidget */ void enterEvent( QEvent* ); /* mouse enter the QWidget */
@ -135,6 +140,11 @@ private:
QSpinBox* SpinBox_NbSteps; QSpinBox* SpinBox_NbSteps;
QLabel* TextLabelTolerance; QLabel* TextLabelTolerance;
SMESHGUI_SpinBox* SpinBox_Tolerance; SMESHGUI_SpinBox* SpinBox_Tolerance;
QMenu* SelectVectorMenu;
QMap<QAction*,int> myMenuActions;
int myVectorDefinition;
QString myHelpFileName; QString myHelpFileName;
@ -153,6 +163,8 @@ private slots:
void onVectorChanged(); void onVectorChanged();
void toDisplaySimulation(); void toDisplaySimulation();
void onDisplaySimulation( bool ); void onDisplaySimulation( bool );
void onSelectVectorMenu( QAction* );
void onSelectVectorButton();
}; };
#endif // SMESHGUI_REVOLUTIONDLG_H #endif // SMESHGUI_REVOLUTIONDLG_H

View File

@ -25,9 +25,11 @@
// SMESH includes // SMESH includes
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include <SMDS_MeshNode.hxx>
#include <SMDS_MeshFace.hxx>
// SALOME GUI includes // SALOME GUI includes
#include <SUIT_Desktop.h> #include <SUIT_Desktop.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
@ -41,6 +43,10 @@
#include <SALOME_ListIO.hxx> #include <SALOME_ListIO.hxx>
// OCC includes
#include <gp_XYZ.hxx>
#include <TColgp_Array1OfXYZ.hxx>
namespace SMESH namespace SMESH
{ {
SUIT_Desktop* SUIT_Desktop*
@ -300,4 +306,35 @@ namespace SMESH
arg(theHelpFileName)); 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 } // end of namespace SMESH

View File

@ -39,6 +39,9 @@
#include <SALOME_InteractiveObject.hxx> #include <SALOME_InteractiveObject.hxx>
#include <LightApp_DataOwner.h> #include <LightApp_DataOwner.h>
//OCC includes
#include <gp_XYZ.hxx>
class SUIT_ViewWindow; class SUIT_ViewWindow;
class SUIT_Desktop; class SUIT_Desktop;
class SUIT_Study; class SUIT_Study;
@ -53,6 +56,8 @@ class SalomeApp_Study;
class SalomeApp_Module; class SalomeApp_Module;
class LightApp_SelectionMgr; class LightApp_SelectionMgr;
class SMDS_MeshFace;
namespace SMESH namespace SMESH
{ {
SMESHGUI_EXPORT SMESHGUI_EXPORT
@ -158,6 +163,15 @@ SMESHGUI_EXPORT
SMESHGUI_EXPORT SMESHGUI_EXPORT
void ShowHelpFile( const QString& ); 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 #endif // SMESHGUI_UTILS_H

View File

@ -4366,6 +4366,14 @@ It is impossible to read point coordinates from file</translation>
<source>TOTAL_ANGLE</source> <source>TOTAL_ANGLE</source>
<translation>Total Angle</translation> <translation>Total Angle</translation>
</message> </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>
<context> <context>
<name>SMESHGUI_SewingDlg</name> <name>SMESHGUI_SewingDlg</name>