PAL13899 : Revolution tool ambigous for the user (No Preview)

This commit is contained in:
eap 2008-03-05 10:43:09 +00:00
parent 7938a9e589
commit defefb9357
3 changed files with 163 additions and 18 deletions

View File

@ -34,6 +34,7 @@
#include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_IdValidator.h" #include "SMESHGUI_IdValidator.h"
#include "SMESHGUI_MeshEditPreview.h"
#include "SMESH_Actor.h" #include "SMESH_Actor.h"
#include "SMESH_TypeFilter.hxx" #include "SMESH_TypeFilter.hxx"
@ -43,20 +44,22 @@
#include "SUIT_ResourceMgr.h" #include "SUIT_ResourceMgr.h"
#include "SUIT_Session.h" #include "SUIT_Session.h"
#include "SUIT_MessageBox.h" #include "SUIT_MessageBox.h"
#include "SUIT_OverrideCursor.h"
#include "LightApp_Application.h" #include "LightApp_Application.h"
#include "SalomeApp_Application.h"
#include "SVTK_ViewModel.h" #include "SVTK_ViewModel.h"
#include "SVTK_ViewWindow.h" #include "SVTK_ViewWindow.h"
#include "SVTK_Selector.h" #include "SVTK_Selector.h"
#include "SVTK_Selection.h" #include "SVTK_Selection.h"
#include "SALOME_ListIO.hxx" #include "SALOME_ListIO.hxx"
#include "VTKViewer_CellLocationsArray.h"
#include "utilities.h" #include "utilities.h"
// OCCT Includes // OCCT Includes
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
// QT Includes // QT Includes
#include <qapplication.h> #include <qapplication.h>
@ -83,6 +86,7 @@ using namespace std;
// class : SMESHGUI_RevolutionDlg() // class : SMESHGUI_RevolutionDlg()
// purpose : // purpose :
//================================================================================= //=================================================================================
SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char* name, SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char* name,
bool modal, WFlags fl) bool modal, WFlags fl)
: QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
@ -90,6 +94,8 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char*
mySMESHGUI( theModule ), mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
{ {
mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
@ -267,34 +273,60 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char*
GroupArgumentsLayout->addMultiCellWidget(GroupAxis, 2, 2, 0, 3); GroupArgumentsLayout->addMultiCellWidget(GroupAxis, 2, 2, 0, 3);
// Controls for angle defining // Controls for angle defining
TextLabelAngle = new QLabel(GroupArguments, "TextLabelAngle"); GroupAngle = new QButtonGroup(GroupArguments, "GroupAngle");
GroupAngle->setTitle(tr("SMESH_ANGLE"));
GroupAngle->setExclusive(TRUE);
GroupAngle->setColumnLayout(0, Qt::Horizontal);
GroupAngle->layout()->setSpacing(0);
GroupAngle->layout()->setMargin(0);
QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngle->layout());
GroupAngleLayout->setAlignment(Qt::AlignTop);
GroupAngleLayout->setSpacing(6);
GroupAngleLayout->setMargin(11);
RadioButton3 = new QRadioButton(GroupAngle, "RadioButton3");
RadioButton3->setText(tr("ANGLE_BY_STEP"));
GroupAngleLayout->addMultiCellWidget(RadioButton3, 0, 0, 0, 1);
RadioButton4 = new QRadioButton(GroupAngle, "RadioButton4");
RadioButton4->setText(tr("TOTAL_ANGLE"));
GroupAngleLayout->addWidget(RadioButton4, 0, 2);
TextLabelAngle = new QLabel(GroupAngle, "TextLabelAngle");
TextLabelAngle->setText(tr("SMESH_ANGLE")); TextLabelAngle->setText(tr("SMESH_ANGLE"));
GroupArgumentsLayout->addMultiCellWidget(TextLabelAngle, 3, 3, 0, 1); GroupAngleLayout->addWidget(TextLabelAngle, 1, 0);
SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle"); SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngle, "SpinBox_Angle");
GroupArgumentsLayout->addWidget(SpinBox_Angle, 3, 2); GroupAngleLayout->addMultiCellWidget(SpinBox_Angle, 1, 1, 1, 2);
// Controls for nb. steps defining // Controls for number of steps defining
TextLabelNbSteps = new QLabel(GroupArguments, "TextLabelNbSteps"); TextLabelNbSteps = new QLabel(GroupAngle, "TextLabelNbSteps");
TextLabelNbSteps->setText(tr("SMESH_NUMBEROFSTEPS" )); TextLabelNbSteps->setText(tr("SMESH_NUMBEROFSTEPS" ));
GroupArgumentsLayout->addMultiCellWidget(TextLabelNbSteps, 4, 4, 0, 1); TextLabelNbSteps->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps"); SpinBox_NbSteps = new QSpinBox(GroupAngle, "SpinBox_NbSteps");
GroupArgumentsLayout->addWidget(SpinBox_NbSteps, 4, 2); GroupAngleLayout->addMultiCellWidget(SpinBox_NbSteps, 2, 2, 1, 2);
GroupArgumentsLayout->addMultiCellWidget(GroupAngle, 3, 3, 0, 3);
// Controls for tolerance defining // Controls for tolerance defining
TextLabelTolerance = new QLabel(GroupArguments, "TextLabelTolerance"); TextLabelTolerance = new QLabel(GroupArguments, "TextLabelTolerance");
TextLabelTolerance->setText(tr("SMESH_TOLERANCE")); TextLabelTolerance->setText(tr("SMESH_TOLERANCE"));
GroupArgumentsLayout->addMultiCellWidget(TextLabelTolerance, 5, 5, 0, 1); GroupArgumentsLayout->addWidget(TextLabelTolerance, 4, 0);
SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Tolerance"); SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Tolerance");
GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 5, 2); GroupArgumentsLayout->addMultiCellWidget(SpinBox_Tolerance, 4, 4, 1, 3);
// CheckBox for groups generation // CheckBox for groups generation
MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments); MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
MakeGroupsCheck->setChecked(true); MakeGroupsCheck->setChecked(true);
GroupArgumentsLayout->addMultiCellWidget(MakeGroupsCheck, 6, 6, 0, 3); GroupArgumentsLayout->addMultiCellWidget(MakeGroupsCheck, 6, 6, 0, 3);
// Control for mesh preview
CheckBoxPreview = new QCheckBox(GroupArguments, "CheckBoxPreview");
CheckBoxPreview->setText(tr("PREVIEW" ));
GroupArgumentsLayout->addMultiCellWidget(CheckBoxPreview, 5, 5, 0, 3);
SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments, 1, 0); SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments, 1, 0);
@ -306,6 +338,8 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char*
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);
RadioButton3->setChecked(TRUE);
SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3); SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps); QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
@ -347,6 +381,10 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char*
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(SetEditCurrentArgument()));
connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged())); connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged())); connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged())); connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
@ -358,6 +396,12 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char*
connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool))); connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
connect(GroupAngle, SIGNAL(clicked(int)), SLOT(toDisplaySimulation()));
connect(SpinBox_Angle, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_NbSteps, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(CheckBoxPreview, SIGNAL(toggled(bool)), SLOT(onDisplaySimulation(bool)));
this->show(); /* displays Dialog */ this->show(); /* displays Dialog */
ConstructorsClicked(0); ConstructorsClicked(0);
@ -371,6 +415,7 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char*
//================================================================================= //=================================================================================
SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg() SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
{ {
delete mySimulation;
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
@ -404,6 +449,8 @@ void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
CheckBoxMesh->setChecked(false); CheckBoxMesh->setChecked(false);
onSelectMesh(false); onSelectMesh(false);
CheckBoxPreview->setChecked(false);
onDisplaySimulation(false);
} }
} }
@ -413,7 +460,17 @@ void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
//================================================================================= //=================================================================================
void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId) void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
{ {
disconnect(mySelectionMgr, 0, this, 0); //disconnect(mySelectionMgr, 0, this, 0);
SALOME_ListIO io;
mySelectionMgr->selectedObjects( io );
SALOME_ListIO aList;
mySelectionMgr->setSelectedObjects( aList );
// LineEditElements->clear();
myNbOkElements = 0;
buttonApply->setEnabled(false);
buttonOk->setEnabled(false);
mySimulation->SetVisibility(false);
Selection_Mode aSelMode = ActorSelection; Selection_Mode aSelMode = ActorSelection;
@ -448,7 +505,8 @@ void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
if (CheckBoxMesh->isChecked()) if (CheckBoxMesh->isChecked())
onSelectMesh(true); onSelectMesh(true);
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
mySelectionMgr->setSelectedObjects( io );
} }
//================================================================================= //=================================================================================
@ -482,6 +540,9 @@ void SMESHGUI_RevolutionDlg::ClickOnApply()
long aNbSteps = (long)SpinBox_NbSteps->value(); long aNbSteps = (long)SpinBox_NbSteps->value();
double aTolerance = SpinBox_Tolerance->GetValue(); double aTolerance = SpinBox_Tolerance->GetValue();
if (GroupAngle->selectedId() == 1)
anAngle = anAngle/aNbSteps;
try { try {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
QApplication::setOverrideCursor(Qt::waitCursor); QApplication::setOverrideCursor(Qt::waitCursor);
@ -604,6 +665,7 @@ void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
buttonOk->setEnabled(true); buttonOk->setEnabled(true);
buttonApply->setEnabled(true); buttonApply->setEnabled(true);
} }
onDisplaySimulation(true);
myBusy = false; myBusy = false;
} }
@ -774,6 +836,8 @@ void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
buttonOk->setEnabled(true); buttonOk->setEnabled(true);
buttonApply->setEnabled(true); buttonApply->setEnabled(true);
} }
onDisplaySimulation(true);
} }
//================================================================================= //=================================================================================
@ -789,6 +853,7 @@ void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
mySelectionMgr->clearFilters(); mySelectionMgr->clearFilters();
if (send == SelectElementsButton) { if (send == SelectElementsButton) {
mySimulation->SetVisibility(false);
myEditCurrentArgument = (QWidget*)LineEditElements; myEditCurrentArgument = (QWidget*)LineEditElements;
SMESH::SetPointRepresentation(false); SMESH::SetPointRepresentation(false);
if (CheckBoxMesh->isChecked()) { if (CheckBoxMesh->isChecked()) {
@ -808,6 +873,7 @@ void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
aViewWindow->SetSelectionMode(FaceSelection); aViewWindow->SetSelectionMode(FaceSelection);
} }
} }
} else if (send == SelectPointButton) { } else if (send == SelectPointButton) {
myEditCurrentArgument = (QWidget*)SpinBox_X; myEditCurrentArgument = (QWidget*)SpinBox_X;
SMESH::SetPointRepresentation(true); SMESH::SetPointRepresentation(true);
@ -902,6 +968,7 @@ void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
if (myEditCurrentArgument != LineEditElements) { if (myEditCurrentArgument != LineEditElements) {
LineEditElements->clear(); LineEditElements->clear();
mySimulation->SetVisibility(false);
return; return;
} }
@ -928,6 +995,7 @@ void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
LineEditElements->setReadOnly(false); LineEditElements->setReadOnly(false);
onTextChange(LineEditElements->text()); onTextChange(LineEditElements->text());
mySimulation->SetVisibility(false);
} }
SelectionIntoArgument(); SelectionIntoArgument();
@ -968,6 +1036,7 @@ void SMESHGUI_RevolutionDlg::onVectorChanged()
buttonOk->setEnabled(false); buttonOk->setEnabled(false);
buttonApply->setEnabled(false); buttonApply->setEnabled(false);
} }
onDisplaySimulation(true);
} }
//================================================================================= //=================================================================================
@ -986,3 +1055,70 @@ void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
ClickOnHelp(); ClickOnHelp();
} }
} }
//=================================================================================
// function : toDisplaySimulation()
// purpose :
//=================================================================================
void SMESHGUI_RevolutionDlg::toDisplaySimulation()
{
onDisplaySimulation(true);
}
//=================================================================================
// function : onDisplaySimulation()
// purpose :
//=================================================================================
void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
{
if (CheckBoxPreview->isChecked() && toDisplayPreview)
{
//display preview
if (myNbOkElements && IsAxisOk()) {
QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
SMESH::long_array_var anElementsId = new SMESH::long_array;
anElementsId->length(aListElementsId.count());
for (int i = 0; i < aListElementsId.count(); i++)
anElementsId[i] = aListElementsId[i].toInt();
SMESH::AxisStruct anAxis;
anAxis.x = SpinBox_X->GetValue();
anAxis.y = SpinBox_Y->GetValue();
anAxis.z = SpinBox_Z->GetValue();
anAxis.vx = SpinBox_DX->GetValue();
anAxis.vy = SpinBox_DY->GetValue();
anAxis.vz = SpinBox_DZ->GetValue();
double anAngle = (SpinBox_Angle->GetValue())*PI/180;
long aNbSteps = (long)SpinBox_NbSteps->value();
double aTolerance = SpinBox_Tolerance->GetValue();
if (GroupAngle->selectedId() == 1)
anAngle = anAngle/aNbSteps;
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
aMeshEditor->RotationSweep(anElementsId.inout(),
anAxis,
anAngle,
aNbSteps,
aTolerance);
SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
mySimulation->SetData(aMeshPreviewStruct._retn());
} catch (...) {}
}
else
{
mySimulation->SetVisibility(false);
}
}
else
{
//erase preview
mySimulation->SetVisibility(false);
}
}

View File

@ -53,7 +53,8 @@ class SMESH_Actor;
class SMESHGUI_SpinBox; class SMESHGUI_SpinBox;
class SVTK_ViewWindow; class SVTK_ViewWindow;
class SVTK_Selector; class SVTK_Selector;
class SALOME_Actor;
class SMESHGUI_MeshEditPreview;
// IDL Headers // IDL Headers
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
@ -95,6 +96,8 @@ private:
SMESH::SMESH_Mesh_var myMesh; SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor; SMESH_Actor* myActor;
SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter;
SMESHGUI_MeshEditPreview* mySimulation;
SALOME_Actor* myPreviewActor;
QButtonGroup* GroupConstructors; QButtonGroup* GroupConstructors;
QRadioButton* RadioButton1; QRadioButton* RadioButton1;
@ -111,6 +114,10 @@ private:
QLineEdit* LineEditElements; QLineEdit* LineEditElements;
QCheckBox* CheckBoxMesh; QCheckBox* CheckBoxMesh;
QCheckBox* MakeGroupsCheck; QCheckBox* MakeGroupsCheck;
QButtonGroup* GroupAngle;
QRadioButton* RadioButton3;
QRadioButton* RadioButton4;
QCheckBox* CheckBoxPreview;
QLabel* TextLabelPoint; QLabel* TextLabelPoint;
QPushButton* SelectPointButton; QPushButton* SelectPointButton;
@ -152,6 +159,8 @@ private slots:
void onTextChange (const QString&); void onTextChange (const QString&);
void onSelectMesh (bool toSelectMesh); void onSelectMesh (bool toSelectMesh);
void onVectorChanged(); void onVectorChanged();
void toDisplaySimulation();
void onDisplaySimulation(bool toDisplayPreview);
protected: protected:
QGridLayout* SMESHGUI_RevolutionDlgLayout; QGridLayout* SMESHGUI_RevolutionDlgLayout;

View File

@ -1871,10 +1871,10 @@ msgid "SMESHGUI_RevolutionDlg::REVOLUTION_2D"
msgstr "Revolution of 2D elements" msgstr "Revolution of 2D elements"
msgid "SMESHGUI_RevolutionDlg::ANGLE_BY_STEP" msgid "SMESHGUI_RevolutionDlg::ANGLE_BY_STEP"
msgstr "Use Angle by Step" msgstr "Angle by Step"
msgid "SMESHGUI_RevolutionDlg::TOTAL_ANGLE" msgid "SMESHGUI_RevolutionDlg::TOTAL_ANGLE"
msgstr "Use Total Angle" msgstr "Total Angle"
msgid "SMESHGUI_RevolutionDlg::PREVIEW" msgid "SMESHGUI_RevolutionDlg::PREVIEW"
msgstr "Preview" msgstr "Preview"