// OCCT includes
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
+#include <gp_XYZ.hxx>
// Qt includes
#include <QApplication>
// 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);
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);
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);
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 */
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);
//=================================================================================
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;
}
}
- myEditCurrentArgument = LineEditElements;
+ myEditCurrentArgument = (QWidget*)LineEditElements;
LineEditElements->setFocus();
if (CheckBoxMesh->isChecked())
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();
// 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());
myIO = IO;
myActor = SMESH::FindActorByObject(myMesh);
- if (myEditCurrentArgument == LineEditElements) {
+ if (myEditCurrentArgument == (QWidget*)LineEditElements) {
int aNbElements = 0;
// MakeGroups is available if there are groups
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();
}
mySelectionMgr->clearFilters();
if (send == SelectElementsButton) {
- myEditCurrentArgument = LineEditElements;
+ myEditCurrentArgument = (QWidget*)LineEditElements;
if (CheckBoxMesh->isChecked()) {
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
}
}
}
-
+ 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();
#include <QGridLayout>
#include <QSpinBox>
#include <QKeyEvent>
+#include <QMenu>
// IDL includes
#include <SALOMEconfig.h>
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 ));
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()));
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()));
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());
+
}
}
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();
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();
+}