smesh/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx

1260 lines
43 KiB
C++
Raw Normal View History

2012-08-09 16:03:55 +06:00
// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
2004-12-01 15:48:31 +05:00
//
2012-08-09 16:03:55 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
2012-08-09 16:03:55 +06:00
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
2012-08-09 16:03:55 +06:00
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
2012-08-09 16:03:55 +06:00
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
2012-08-09 16:03:55 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2004-12-01 15:48:31 +05:00
//
2012-08-09 16:03:55 +06:00
2009-02-17 10:27:49 +05:00
// SMESH SMESHGUI : GUI for SMESH component
// File : SMESHGUI_ExtrusionDlg.cxx
// Author : Michael ZORIN, Open CASCADE S.A.S.
// SMESH includes
2004-12-01 15:48:31 +05:00
//
#include "SMESHGUI_ExtrusionDlg.h"
2004-12-01 15:48:31 +05:00
#include "SMESHGUI.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_SpinBox.h"
2004-12-01 15:48:31 +05:00
#include "SMESHGUI_IdValidator.h"
2009-02-17 10:27:49 +05:00
#include "SMESHGUI_FilterDlg.h"
2012-08-09 16:03:55 +06:00
#include "SMESHGUI_MeshEditPreview.h"
2009-02-17 10:27:49 +05:00
#include <SMESH_Actor.h>
#include <SMESH_TypeFilter.hxx>
#include <SMESH_LogicalFilter.hxx>
2009-02-17 10:27:49 +05:00
#include <SMDS_Mesh.hxx>
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
// SALOME GUI includes
#include <SUIT_ResourceMgr.h>
#include <SUIT_Desktop.h>
#include <SUIT_MessageBox.h>
#include <SUIT_Session.h>
#include <SUIT_OverrideCursor.h>
2009-02-17 10:27:49 +05:00
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
2009-02-17 10:27:49 +05:00
#include <SVTK_ViewModel.h>
#include <SVTK_ViewWindow.h>
2009-02-17 10:27:49 +05:00
#include <SalomeApp_IntSpinBox.h>
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
// OCCT includes
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
2009-02-17 10:27:49 +05:00
#include <gp_XYZ.hxx>
// Qt includes
#include <QApplication>
#include <QButtonGroup>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QRadioButton>
#include <QCheckBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QKeyEvent>
// IDL includes
#include <SALOMEconfig.h>
2005-01-20 11:25:54 +05:00
#include CORBA_SERVER_HEADER(SMESH_Group)
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
2005-01-20 11:25:54 +05:00
2009-02-17 10:27:49 +05:00
#define SPACING 6
#define MARGIN 11
2004-12-01 15:48:31 +05:00
//=================================================================================
// function : SMESHGUI_ExtrusionDlg()
// purpose : constructor
2004-12-01 15:48:31 +05:00
//=================================================================================
2009-02-17 10:27:49 +05:00
SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
2012-08-09 16:03:55 +06:00
: SMESHGUI_PreviewDlg( theModule ),
2009-02-17 10:27:49 +05:00
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
2012-12-13 17:41:29 +06:00
myEditCurrentArgument(0),
2009-02-17 10:27:49 +05:00
myFilterDlg( 0 ),
mySelectedObject(SMESH::SMESH_IDSource::_nil())
2004-12-01 15:48:31 +05:00
{
2005-06-08 16:45:19 +06:00
QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
2012-08-09 16:03:55 +06:00
QPixmap image3 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_NODE")));
2009-02-17 10:27:49 +05:00
setModal( false );
setAttribute( Qt::WA_DeleteOnClose, true );
setWindowTitle(tr("EXTRUSION_ALONG_LINE"));
setSizeGripEnabled(true);
2009-02-17 10:27:49 +05:00
QVBoxLayout* SMESHGUI_ExtrusionDlgLayout = new QVBoxLayout(this);
SMESHGUI_ExtrusionDlgLayout->setSpacing(SPACING);
SMESHGUI_ExtrusionDlgLayout->setMargin(MARGIN);
2004-12-01 15:48:31 +05:00
/***************************************************************/
2009-02-17 10:27:49 +05:00
ConstructorsBox = new QGroupBox(tr("SMESH_EXTRUSION"), this);
GroupConstructors = new QButtonGroup(this);
QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
ConstructorsBoxLayout->setSpacing(SPACING);
ConstructorsBoxLayout->setMargin(MARGIN);
2012-08-09 16:03:55 +06:00
RadioButton0= new QRadioButton(ConstructorsBox);
RadioButton0->setIcon(image3);
2009-02-17 10:27:49 +05:00
RadioButton1= new QRadioButton(ConstructorsBox);
RadioButton1->setIcon(image0);
RadioButton2= new QRadioButton(ConstructorsBox);
RadioButton2->setIcon(image1);
2012-08-09 16:03:55 +06:00
ConstructorsBoxLayout->addWidget(RadioButton0);
2009-02-17 10:27:49 +05:00
ConstructorsBoxLayout->addWidget(RadioButton1);
ConstructorsBoxLayout->addWidget(RadioButton2);
2012-08-09 16:03:55 +06:00
GroupConstructors->addButton(RadioButton0, 0);
GroupConstructors->addButton(RadioButton1, 1);
GroupConstructors->addButton(RadioButton2, 2);
2004-12-01 15:48:31 +05:00
/***************************************************************/
2009-02-17 10:27:49 +05:00
GroupButtons = new QGroupBox(this);
QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
GroupButtonsLayout->setSpacing(SPACING);
GroupButtonsLayout->setMargin(MARGIN);
buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
buttonOk->setAutoDefault(true);
buttonOk->setDefault(true);
buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
buttonApply->setAutoDefault(true);
buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
buttonCancel->setAutoDefault(true);
buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
buttonHelp->setAutoDefault(true);
GroupButtonsLayout->addWidget(buttonOk);
GroupButtonsLayout->addSpacing(10);
GroupButtonsLayout->addWidget(buttonApply);
GroupButtonsLayout->addSpacing(10);
GroupButtonsLayout->addStretch();
GroupButtonsLayout->addWidget(buttonCancel);
GroupButtonsLayout->addWidget(buttonHelp);
2004-12-01 15:48:31 +05:00
/***************************************************************/
2012-08-09 16:03:55 +06:00
GroupArguments = new QGroupBox(tr("EXTRUSION_0D"), this);
2009-02-17 10:27:49 +05:00
QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
GroupArgumentsLayout->setSpacing(SPACING);
GroupArgumentsLayout->setMargin(MARGIN);
myIdValidator = new SMESHGUI_IdValidator(this);
2004-12-01 15:48:31 +05:00
// Controls for elements selection
2009-02-17 10:27:49 +05:00
TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
SelectElementsButton = new QPushButton(GroupArguments);
SelectElementsButton->setIcon(image2);
2009-02-17 10:27:49 +05:00
LineEditElements = new QLineEdit(GroupArguments);
LineEditElements->setValidator(myIdValidator);
2012-08-09 16:03:55 +06:00
LineEditElements->setMaxLength(-1);
myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
2004-12-01 15:48:31 +05:00
// Control for the whole mesh selection
2009-02-17 10:27:49 +05:00
CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
2004-12-01 15:48:31 +05:00
2012-08-09 16:03:55 +06:00
RadioButton3 = new QRadioButton(GroupArguments);
RadioButton3->setText( tr("SMESH_EXTRUSION_TO_DISTANCE") );
RadioButton4 = new QRadioButton(GroupArguments);
RadioButton4->setText( tr("SMESH_EXTRUSION_ALONG_VECTOR") );
2009-02-17 10:27:49 +05:00
//Control for the Distance selection
TextLabelDistance = new QLabel(tr("SMESH_DISTANCE"), GroupArguments);
TextLabelDx = new QLabel(tr("SMESH_X"), GroupArguments);
SpinBox_Dx = new SMESHGUI_SpinBox(GroupArguments);
TextLabelDy = new QLabel(tr("SMESH_Y"), GroupArguments);
SpinBox_Dy = new SMESHGUI_SpinBox(GroupArguments);
2009-02-17 10:27:49 +05:00
TextLabelDz = new QLabel(tr("SMESH_Z"), GroupArguments);
SpinBox_Dz = new SMESHGUI_SpinBox(GroupArguments);
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
// Controls for vector selection
2004-12-01 15:48:31 +05:00
2012-08-09 16:03:55 +06:00
TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupArguments);
2009-02-17 10:27:49 +05:00
SelectVectorButton = new QPushButton(GroupArguments);
SelectVectorButton->setIcon(image2);
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
TextLabelVx = new QLabel(tr("SMESH_DX"), GroupArguments);
SpinBox_Vx = new SMESHGUI_SpinBox(GroupArguments);
2009-02-17 10:27:49 +05:00
TextLabelVy = new QLabel(tr("SMESH_DY"), GroupArguments);
SpinBox_Vy = new SMESHGUI_SpinBox(GroupArguments);
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
TextLabelVz = new QLabel(tr("SMESH_DZ"), GroupArguments);
SpinBox_Vz = new SMESHGUI_SpinBox(GroupArguments);
2012-08-09 16:03:55 +06:00
TextLabelDist = new QLabel(tr("SMESH_DISTANCE"), GroupArguments);
SpinBox_VDist = new SMESHGUI_SpinBox(GroupArguments);
2004-12-01 15:48:31 +05:00
// Controls for nb. steps defining
2009-02-17 10:27:49 +05:00
TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments);
SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupArguments);
// CheckBox for groups generation
MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
2012-08-09 16:03:55 +06:00
//Preview check box
myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments);
2009-02-17 10:27:49 +05:00
GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 5);
2012-08-09 16:03:55 +06:00
GroupArgumentsLayout->addWidget(myFilterBtn, 0, 7);
2009-02-17 10:27:49 +05:00
GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 8);
2012-08-09 16:03:55 +06:00
GroupArgumentsLayout->addWidget(RadioButton3, 2, 1, 1, 3);
GroupArgumentsLayout->addWidget(RadioButton4, 2, 5, 1, 3);
GroupArgumentsLayout->addWidget(TextLabelDistance, 3, 0);
GroupArgumentsLayout->addWidget(TextLabelDx, 3, 2);
GroupArgumentsLayout->addWidget(SpinBox_Dx, 3, 3);
GroupArgumentsLayout->addWidget(TextLabelDy, 3, 4);
GroupArgumentsLayout->addWidget(SpinBox_Dy, 3, 5);
GroupArgumentsLayout->addWidget(TextLabelDz, 3, 6);
GroupArgumentsLayout->addWidget(SpinBox_Dz, 3, 7);
GroupArgumentsLayout->addWidget(TextLabelVector, 4, 0);
GroupArgumentsLayout->addWidget(SelectVectorButton, 4, 1);
GroupArgumentsLayout->addWidget(TextLabelVx, 4, 2);
GroupArgumentsLayout->addWidget(SpinBox_Vx, 4, 3);
GroupArgumentsLayout->addWidget(TextLabelVy, 4, 4);
GroupArgumentsLayout->addWidget(SpinBox_Vy, 4, 5);
GroupArgumentsLayout->addWidget(TextLabelVz, 4, 6);
GroupArgumentsLayout->addWidget(SpinBox_Vz, 4, 7);
GroupArgumentsLayout->addWidget(TextLabelDist, 5, 0);
GroupArgumentsLayout->addWidget(SpinBox_VDist, 5, 3);
GroupArgumentsLayout->addWidget(TextLabelNbSteps, 6, 0, 1, 3);
GroupArgumentsLayout->addWidget(SpinBox_NbSteps, 6, 3);
GroupArgumentsLayout->addWidget(myPreviewCheckBox, 7, 0, 1, 8);
GroupArgumentsLayout->addWidget(MakeGroupsCheck, 8, 0, 1, 8);
GroupArgumentsLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), 8, 0);
2009-02-17 10:27:49 +05:00
/***************************************************************/
SMESHGUI_ExtrusionDlgLayout->addWidget(ConstructorsBox);
SMESHGUI_ExtrusionDlgLayout->addWidget(GroupArguments);
SMESHGUI_ExtrusionDlgLayout->addWidget(GroupButtons);
2004-12-01 15:48:31 +05:00
/* Initialisations */
2012-08-09 16:03:55 +06:00
SpinBox_Vx->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.01, "length_precision");
SpinBox_Vy->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.01, "length_precision");
SpinBox_Vz->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.01, "length_precision");
2009-02-17 10:27:49 +05:00
2012-08-09 16:03:55 +06:00
SpinBox_Dx->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
SpinBox_Dy->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
SpinBox_Dz->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
2009-02-17 10:27:49 +05:00
SpinBox_NbSteps->setRange(1, 999999);
2012-08-09 16:03:55 +06:00
SpinBox_VDist->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
2012-08-09 16:03:55 +06:00
RadioButton0->setChecked(true);
RadioButton3->setChecked(true);
2009-02-17 10:27:49 +05:00
MakeGroupsCheck->setChecked(true);
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
mySMESHGUI->SetActiveDialogBox(this);
// Costruction of the logical filter for the elements: mesh/sub-mesh/group
2009-02-17 10:27:49 +05:00
QList<SUIT_SelectionFilter*> aListOfFilters;
2012-12-13 17:41:29 +06:00
aListOfFilters.append(new SMESH_TypeFilter (SMESH::MESH));
aListOfFilters.append(new SMESH_TypeFilter (SMESH::SUBMESH_VERTEX));
aListOfFilters.append(new SMESH_TypeFilter (SMESH::GROUP_NODE));
2012-10-08 17:56:59 +06:00
myMeshOrSubMeshOrGroupFilter0D =
new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR, /*takeOwnership=*/true);
2012-12-13 17:41:29 +06:00
aListOfFilters[0] = new SMESH_TypeFilter (SMESH::MESH);
aListOfFilters[1] = new SMESH_TypeFilter (SMESH::SUBMESH_EDGE);
aListOfFilters[2] = new SMESH_TypeFilter (SMESH::GROUP_EDGE);
2012-10-08 17:56:59 +06:00
myMeshOrSubMeshOrGroupFilter1D =
new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR, /*takeOwnership=*/true);
2012-12-13 17:41:29 +06:00
aListOfFilters[0] = new SMESH_TypeFilter (SMESH::MESH);
aListOfFilters[1] = new SMESH_TypeFilter (SMESH::SUBMESH_FACE);
aListOfFilters[2] = new SMESH_TypeFilter (SMESH::GROUP_FACE);
2012-10-08 17:56:59 +06:00
myMeshOrSubMeshOrGroupFilter2D =
new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR, /*takeOwnership=*/true);
myHelpFileName = "extrusion_page.html";
2004-12-01 15:48:31 +05:00
Init();
/***************************************************************/
// signals and slots connections
2009-02-17 10:27:49 +05:00
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
2013-02-28 21:07:35 +06:00
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
2009-02-17 10:27:49 +05:00
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
2012-08-09 16:03:55 +06:00
connect(RadioButton3, SIGNAL(clicked()), this, SLOT(ClickOnRadio()));
connect(RadioButton4, SIGNAL(clicked()), this, SLOT(ClickOnRadio()));
// to update state of the Ok & Apply buttons
2009-02-17 10:27:49 +05:00
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()));
2009-02-17 10:27:49 +05:00
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()));
2004-12-01 15:48:31 +05:00
/* to close dialog if study change */
2013-02-28 21:07:35 +06:00
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject()));
2009-02-17 10:27:49 +05:00
connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
2004-12-01 15:48:31 +05:00
2012-08-09 16:03:55 +06:00
connect(SpinBox_Dx, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_Dy, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_Dz, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_Vx, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_Vy, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_Vz, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_VDist, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_NbSteps, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
//To Connect preview check box
connectPreviewControl();
/***************************************************************/
2004-12-01 15:48:31 +05:00
ConstructorsClicked(0);
2012-08-09 16:03:55 +06:00
ClickOnRadio();
SelectionIntoArgument();
2004-12-01 15:48:31 +05:00
}
//=================================================================================
// function : ~SMESHGUI_ExtrusionDlg()
// purpose : destructor
2004-12-01 15:48:31 +05:00
//=================================================================================
SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg()
{
2009-02-17 10:27:49 +05:00
if ( myFilterDlg != 0 ) {
myFilterDlg->setParent( 0 );
delete myFilterDlg;
}
2012-10-08 17:56:59 +06:00
if ( myMeshOrSubMeshOrGroupFilter0D ) delete myMeshOrSubMeshOrGroupFilter0D;
if ( myMeshOrSubMeshOrGroupFilter1D ) delete myMeshOrSubMeshOrGroupFilter1D;
if ( myMeshOrSubMeshOrGroupFilter2D ) delete myMeshOrSubMeshOrGroupFilter2D;
2004-12-01 15:48:31 +05:00
}
//=================================================================================
// function : Init()
// purpose : initialization
2004-12-01 15:48:31 +05:00
//=================================================================================
void SMESHGUI_ExtrusionDlg::Init (bool ResetControls)
2004-12-01 15:48:31 +05:00
{
myBusy = false;
2012-08-09 16:03:55 +06:00
myIDs.clear();
2004-12-01 15:48:31 +05:00
LineEditElements->clear();
myNbOkElements = 0;
2004-12-01 15:48:31 +05:00
myActor = 0;
2004-12-01 15:48:31 +05:00
myMesh = SMESH::SMESH_Mesh::_nil();
if (ResetControls) {
SpinBox_NbSteps->setValue(1);
2012-08-09 16:03:55 +06:00
SpinBox_VDist->setValue(10);
SpinBox_Dx->SetValue(0);
SpinBox_Dy->SetValue(0);
SpinBox_Dz->SetValue(0);
2009-02-17 10:27:49 +05:00
SpinBox_Vx->SetValue(0);
SpinBox_Vy->SetValue(0);
SpinBox_Vz->SetValue(0);
CheckBoxMesh->setChecked(false);
onSelectMesh(false);
2012-08-09 16:03:55 +06:00
myPreviewCheckBox->setChecked(false);
onDisplaySimulation(false);
}
CheckIsEnable();
}
//=================================================================================
// function : CheckIsEnable()
// purpose : Check whether the Ok and Apply buttons should be enabled or not
//=================================================================================
void SMESHGUI_ExtrusionDlg::CheckIsEnable()
2012-08-09 16:03:55 +06:00
{
bool anIsEnable = myNbOkElements > 0 && isValuesValid();
buttonOk->setEnabled(anIsEnable);
buttonApply->setEnabled(anIsEnable);
}
2004-12-01 15:48:31 +05:00
2012-08-09 16:03:55 +06:00
//=================================================================================
// function : isValuesValid()
// purpose : Return true in case if values entered into dialog are valid
//=================================================================================
bool SMESHGUI_ExtrusionDlg::isValuesValid() {
double aX, aY, aZ, aModule = 0;
if ( RadioButton3->isChecked() ) {
aX = SpinBox_Dx->GetValue();
aY = SpinBox_Dy->GetValue();
aZ = SpinBox_Dz->GetValue();
aModule = sqrt(aX*aX + aY*aY + aZ*aZ);
} else if ( RadioButton4->isChecked() ) {
aX = SpinBox_Vx->GetValue();
aY = SpinBox_Vy->GetValue();
aZ = SpinBox_Vz->GetValue();
aModule = sqrt(aX*aX + aY*aY + aZ*aZ);
}
return aModule > 1.0E-38;
}
2004-12-01 15:48:31 +05:00
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_ExtrusionDlg::ConstructorsClicked (int constructorId)
2004-12-01 15:48:31 +05:00
{
disconnect(mySelectionMgr, 0, this, 0);
2012-08-09 16:03:55 +06:00
hidePreview();
TextLabelElements->setText(tr( constructorId ? "SMESH_ID_ELEMENTS" : "SMESH_ID_NODES"));
switch (constructorId) {
case 0:
{
2012-08-09 16:03:55 +06:00
GroupArguments->setTitle(tr("EXTRUSION_0D"));
if (!CheckBoxMesh->isChecked())
2012-08-09 16:03:55 +06:00
{
LineEditElements->clear();
myIDs.clear();
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(NodeSelection);
}
break;
2004-12-01 15:48:31 +05:00
}
case 1:
2012-08-09 16:03:55 +06:00
{
GroupArguments->setTitle(tr("EXTRUSION_1D"));
if (!CheckBoxMesh->isChecked())
{
LineEditElements->clear();
myIDs.clear();
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(EdgeSelection);
}
break;
}
case 2:
{
GroupArguments->setTitle(tr("EXTRUSION_2D"));
if (!CheckBoxMesh->isChecked())
2012-08-09 16:03:55 +06:00
{
LineEditElements->clear();
myIDs.clear();
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(FaceSelection);
}
break;
}
}
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
myEditCurrentArgument = (QWidget*)LineEditElements;
2004-12-01 15:48:31 +05:00
LineEditElements->setFocus();
2004-12-01 15:48:31 +05:00
if (CheckBoxMesh->isChecked())
onSelectMesh(true);
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
}
2004-12-01 15:48:31 +05:00
2012-08-09 16:03:55 +06:00
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_ExtrusionDlg::ClickOnRadio()
{
if ( RadioButton3->isChecked() ) {
TextLabelDistance->show();
TextLabelDx->show();
SpinBox_Dx->show();
TextLabelDy->show();
SpinBox_Dy->show();
TextLabelDz->show();
SpinBox_Dz->show();
TextLabelVector->hide();
TextLabelVx->hide();
SpinBox_Vx->hide();
TextLabelVy->hide();
SpinBox_Vy->hide();
TextLabelVz->hide();
SpinBox_Vz->hide();
TextLabelDist->hide();
SpinBox_VDist->hide();
SelectVectorButton->hide();
} else if ( RadioButton4->isChecked() ) {
TextLabelDistance->hide();
TextLabelDx->hide();
SpinBox_Dx->hide();
TextLabelDy->hide();
SpinBox_Dy->hide();
TextLabelDz->hide();
SpinBox_Dz->hide();
TextLabelVector->show();
TextLabelVx->show();
SpinBox_Vx->show();
TextLabelVy->show();
SpinBox_Vy->show();
TextLabelVz->show();
SpinBox_Vz->show();
TextLabelDist->show();
SpinBox_VDist->show();
SelectVectorButton->show();
}
onDisplaySimulation(true);
// AdjustSize
qApp->processEvents();
updateGeometry();
resize( minimumSizeHint() );
}
2004-12-01 15:48:31 +05:00
//=================================================================================
// function : ClickOnApply()
// purpose : Called when user presses <Apply> button
2004-12-01 15:48:31 +05:00
//=================================================================================
bool SMESHGUI_ExtrusionDlg::ClickOnApply()
2004-12-01 15:48:31 +05:00
{
if (mySMESHGUI->isActiveStudyLocked())
return false;
2009-02-17 10:27:49 +05:00
if (!isValid())
return false;
2009-02-17 10:27:49 +05:00
if (myNbOkElements) {
2012-08-09 16:03:55 +06:00
SMESH::DirStruct aVector;
2012-08-09 16:03:55 +06:00
getExtrusionVector(aVector);
QStringList aParameters;
if ( RadioButton3->isChecked() ) {
aParameters << SpinBox_Dx->text();
aParameters << SpinBox_Dy->text();
aParameters << SpinBox_Dz->text();
} else if ( RadioButton4->isChecked() ) {
// only 3 coords in a python dump command :(
// aParameters << SpinBox_Vx->text();
// aParameters << SpinBox_Vy->text();
// aParameters << SpinBox_Vz->text();
// aParameters << SpinBox_VDist->text();
}
long aNbSteps = (long)SpinBox_NbSteps->value();
2009-02-17 10:27:49 +05:00
aParameters << SpinBox_NbSteps->text();
try {
2009-02-17 10:27:49 +05:00
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
2012-08-09 16:03:55 +06:00
myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
2009-02-17 10:27:49 +05:00
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
2012-08-09 16:03:55 +06:00
if( CheckBoxMesh->isChecked() )
switch (GetConstructorId() ) {
case 0:
{
SMESH::ListOfGroups_var groups =
aMeshEditor->ExtrusionSweepObject0DMakeGroups(mySelectedObject, aVector, aNbSteps);
break;
}
case 1:
{
SMESH::ListOfGroups_var groups =
aMeshEditor->ExtrusionSweepObject1DMakeGroups(mySelectedObject, aVector, aNbSteps);
break;
}
case 2:
{
SMESH::ListOfGroups_var groups =
aMeshEditor->ExtrusionSweepObject2DMakeGroups(mySelectedObject, aVector, aNbSteps);
break;
}
}
else
{
SMESH::ListOfGroups_var groups;
if (GetConstructorId() == 0)
groups = aMeshEditor->ExtrusionSweepMakeGroups0D(myElementsId.inout(), aVector, aNbSteps);
else
groups = aMeshEditor->ExtrusionSweepMakeGroups(myElementsId.inout(), aVector, aNbSteps);
}
2009-02-17 10:27:49 +05:00
}
else {
2012-08-09 16:03:55 +06:00
if( CheckBoxMesh->isChecked() )
switch( GetConstructorId() ) {
case 0:
{
aMeshEditor->ExtrusionSweepObject0D(mySelectedObject, aVector, aNbSteps);
break;
}
case 1:
{
aMeshEditor->ExtrusionSweepObject1D(mySelectedObject, aVector, aNbSteps);
break;
}
case 2:
{
aMeshEditor->ExtrusionSweepObject2D(mySelectedObject, aVector, aNbSteps);
break;
}
}
else
if (GetConstructorId() == 0)
aMeshEditor->ExtrusionSweep0D(myElementsId.inout(), aVector, aNbSteps);
else
aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps);
2009-02-17 10:27:49 +05:00
}
} catch (...) {
2004-12-01 15:48:31 +05:00
}
2012-08-09 16:03:55 +06:00
SMESH::Update(myIO, SMESH::eDisplay);
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
mySMESHGUI->updateObjBrowser(true); // new groups may appear
Init(false);
ConstructorsClicked(GetConstructorId());
2012-08-09 16:03:55 +06:00
mySelectionMgr->clearSelected();
2009-02-17 10:27:49 +05:00
mySelectedObject = SMESH::SMESH_IDSource::_nil();
SelectionIntoArgument();
2012-08-09 16:03:55 +06:00
SMESHGUI::Modified();
}
return true;
2004-12-01 15:48:31 +05:00
}
//=================================================================================
// function : ClickOnOk()
// purpose : Called when user presses <OK> button
2004-12-01 15:48:31 +05:00
//=================================================================================
void SMESHGUI_ExtrusionDlg::ClickOnOk()
{
if (ClickOnApply())
2013-02-28 21:07:35 +06:00
reject();
2004-12-01 15:48:31 +05:00
}
//=================================================================================
2013-02-28 21:07:35 +06:00
// function : reject()
// purpose : Called when dialog box is closed
2004-12-01 15:48:31 +05:00
//=================================================================================
2013-02-28 21:07:35 +06:00
void SMESHGUI_ExtrusionDlg::reject()
2004-12-01 15:48:31 +05:00
{
2013-02-28 21:07:35 +06:00
disconnect(mySelectionMgr, 0, this, 0);
mySelectionMgr->clearFilters();
//mySelectionMgr->clearSelected();
if (SMESH::GetCurrentVtkView()) {
SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
SMESH::SetPointRepresentation(false);
SMESH::SetPickable();
}
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
mySMESHGUI->ResetState();
QDialog::reject();
2004-12-01 15:48:31 +05:00
}
//=================================================================================
// function : ClickOnHelp()
// purpose :
//=================================================================================
void SMESHGUI_ExtrusionDlg::ClickOnHelp()
{
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
if (app)
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
else {
2009-02-17 10:27:49 +05:00
QString platform;
#ifdef WIN32
2009-02-17 10:27:49 +05:00
platform = "winapplication";
#else
2009-02-17 10:27:49 +05:00
platform = "application";
#endif
2009-02-17 10:27:49 +05:00
SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
2012-08-09 16:03:55 +06:00
tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
arg(app->resourceMgr()->stringValue("ExternalBrowser",
platform)).
arg(myHelpFileName));
}
}
//=================================================================================
// function : onTextChange()
// purpose :
//=================================================================================
void SMESHGUI_ExtrusionDlg::onTextChange (const QString& theNewText)
2004-12-01 15:48:31 +05:00
{
QLineEdit* send = (QLineEdit*)sender();
// return if busy
if (myBusy) return;
// set busy flag
2004-12-01 15:48:31 +05:00
myBusy = true;
2004-12-01 15:48:31 +05:00
if (send == LineEditElements)
myNbOkElements = 0;
2004-12-01 15:48:31 +05:00
// hilight entered elements/nodes
if (!myIO.IsNull()) {
2009-02-17 10:27:49 +05:00
QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
if (send == LineEditElements)
{
SMDS_Mesh* aMesh = myActor ? myActor->GetObject()->GetMesh() : 0;
2012-08-09 16:03:55 +06:00
SMESH::ElementType SMESHType;
SMDSAbs_ElementType SMDSType;
switch (GetConstructorId()) {
case 0:
{
SMESHType = SMESH::NODE;
SMDSType = SMDSAbs_Node;
break;
}
case 1:
{
SMESHType = SMESH::EDGE;
SMDSType = SMDSAbs_Edge;
break;
}
case 2:
{
SMESHType = SMESH::FACE;
SMDSType = SMDSAbs_Face;
break;
}
}
myElementsId = new SMESH::long_array;
myElementsId->length( aListId.count() );
TColStd_MapOfInteger newIndices;
for (int i = 0; i < aListId.count(); i++) {
int id = aListId[ i ].toInt();
bool validId = false;
if ( id > 0 ) {
if ( aMesh ) {
2012-08-09 16:03:55 +06:00
const SMDS_MeshElement * e;
if (SMDSType == SMDSAbs_Node)
e = aMesh->FindNode( id );
else
e = aMesh->FindElement( id );
validId = ( e && e->GetType() == SMDSType );
} else {
validId = ( myMesh->GetElementType( id, true ) == SMESHType );
}
}
if ( validId && newIndices.Add( id ))
myElementsId[ newIndices.Extent()-1 ] = id;
}
myElementsId->length( myNbOkElements = newIndices.Extent() );
mySelector->AddOrRemoveIndex(myIO, newIndices, false);
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
2012-08-09 16:03:55 +06:00
aViewWindow->highlight( myIO, true, true );
2004-12-01 15:48:31 +05:00
}
}
CheckIsEnable();
2012-08-09 16:03:55 +06:00
onDisplaySimulation(true);
2004-12-01 15:48:31 +05:00
myBusy = false;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
{
if (myBusy) return;
// return if dialog box is inactive
if (!GroupButtons->isEnabled())
return;
2004-12-01 15:48:31 +05:00
// clear
2012-08-09 16:03:55 +06:00
if(myEditCurrentArgument != (QWidget*)SpinBox_Vx) {
myActor = 0;
Handle(SALOME_InteractiveObject) resIO = myIO;
myIO.Nullify();
}
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
QString aString = "";
// set busy flag
2009-02-17 10:27:49 +05:00
if(myEditCurrentArgument == (QWidget*)LineEditElements) {
myBusy = true;
LineEditElements->setText(aString);
myNbOkElements = 0;
myBusy = false;
}
2004-12-01 15:48:31 +05:00
// get selected mesh
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
if (nbSel != 1)
2004-12-01 15:48:31 +05:00
return;
Handle(SALOME_InteractiveObject) IO = aList.First();
2012-08-09 16:03:55 +06:00
if(myEditCurrentArgument != (QWidget*)SpinBox_Vx) {
myMesh = SMESH::GetMeshByIO(IO);
if (myMesh->_is_nil())
return;
myIO = IO;
myActor = SMESH::FindActorByObject(myMesh);
}
2009-02-17 10:27:49 +05:00
if (myEditCurrentArgument == (QWidget*)LineEditElements) {
int aNbElements = 0;
// MakeGroups is available if there are groups
if ( myMesh->NbGroups() == 0 ) {
MakeGroupsCheck->setChecked(false);
MakeGroupsCheck->setEnabled(false);
} else {
MakeGroupsCheck->setEnabled(true);
}
if (CheckBoxMesh->isChecked()) {
SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
2009-02-17 10:27:49 +05:00
if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
else
return;
} else {
// get indices of selcted elements
TColStd_IndexedMapOfInteger aMapIndex;
mySelector->GetIndex(IO,aMapIndex);
aNbElements = aMapIndex.Extent();
2009-02-17 10:27:49 +05:00
if (aNbElements < 1)
2012-08-09 16:03:55 +06:00
return;
2009-02-17 10:27:49 +05:00
myElementsId = new SMESH::long_array;
myElementsId->length( aNbElements );
aString = "";
for ( int i = 0; i < aNbElements; ++i )
aString += QString(" %1").arg( myElementsId[ i ] = aMapIndex( i+1 ) );
2004-12-01 15:48:31 +05:00
}
myNbOkElements = true;
2009-02-17 10:27:49 +05:00
myBusy = true;
((QLineEdit*)myEditCurrentArgument)->setText(aString);
myBusy = false;
}
2009-02-17 10:27:49 +05:00
else if(myEditCurrentArgument == (QWidget*)SpinBox_Vx){
TColStd_IndexedMapOfInteger aMapIndex;
mySelector->GetIndex(IO,aMapIndex);
int aNbElements = aMapIndex.Extent();
2012-08-09 16:03:55 +06:00
SMESH::SMESH_Mesh_var aMesh_var = SMESH::GetMeshByIO(IO);
SMESH_Actor* anActor = SMESH::FindActorByObject(aMesh_var);
SMDS_Mesh* aMesh = anActor ? anActor->GetObject()->GetMesh() : 0;
2009-02-17 10:27:49 +05:00
if(aNbElements != 1 || !aMesh)
return;
const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aMapIndex(aNbElements)));
if (!face)
return;
2009-02-17 10:27:49 +05:00
gp_XYZ aNormale = SMESH::getNormale(face);
SpinBox_Vx->SetValue(aNormale.X());
SpinBox_Vy->SetValue(aNormale.Y());
SpinBox_Vz->SetValue(aNormale.Z());
}
2012-08-09 16:03:55 +06:00
onDisplaySimulation(true);
2004-12-01 15:48:31 +05:00
// OK
CheckIsEnable();
2004-12-01 15:48:31 +05:00
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
disconnect(mySelectionMgr, 0, this, 0);
mySelectionMgr->clearSelected();
mySelectionMgr->clearFilters();
if (send == SelectElementsButton) {
2009-02-17 10:27:49 +05:00
myEditCurrentArgument = (QWidget*)LineEditElements;
2012-10-08 17:56:59 +06:00
if (CheckBoxMesh->isChecked())
{
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
2012-08-09 16:03:55 +06:00
aViewWindow->SetSelectionMode(ActorSelection);
2012-10-08 17:56:59 +06:00
switch( GetConstructorId() ) {
case 0: mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter0D); break;
case 1: mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter1D); break;
case 2: mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter2D); break;
}
}
else
{
int aConstructorId = GetConstructorId();
2012-08-09 16:03:55 +06:00
switch(aConstructorId) {
2012-10-08 17:56:59 +06:00
case 0:
{
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(NodeSelection);
break;
}
case 1:
{
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(EdgeSelection);
break;
}
case 2:
{
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
2012-08-09 16:03:55 +06:00
aViewWindow->SetSelectionMode(FaceSelection);
2012-10-08 17:56:59 +06:00
break;
}
2012-08-09 16:03:55 +06:00
}
}
2004-12-01 15:48:31 +05:00
}
2009-02-17 10:27:49 +05:00
else if (send == SelectVectorButton){
myEditCurrentArgument = (QWidget*)SpinBox_Vx;
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(FaceSelection);
}
2004-12-01 15:48:31 +05:00
myEditCurrentArgument->setFocus();
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
SelectionIntoArgument();
2004-12-01 15:48:31 +05:00
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose : Deactivates this dialog
2004-12-01 15:48:31 +05:00
//=================================================================================
void SMESHGUI_ExtrusionDlg::DeactivateActiveDialog()
{
2009-02-17 10:27:49 +05:00
if (ConstructorsBox->isEnabled()) {
ConstructorsBox->setEnabled(false);
GroupArguments->setEnabled(false);
GroupButtons->setEnabled(false);
mySMESHGUI->ResetState();
mySMESHGUI->SetActiveDialogBox(0);
2004-12-01 15:48:31 +05:00
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose : Activates this dialog
2004-12-01 15:48:31 +05:00
//=================================================================================
void SMESHGUI_ExtrusionDlg::ActivateThisDialog()
{
// Emit a signal to deactivate the active dialog
mySMESHGUI->EmitSignalDeactivateDialog();
2009-02-17 10:27:49 +05:00
ConstructorsBox->setEnabled(true);
GroupArguments->setEnabled(true);
GroupButtons->setEnabled(true);
mySMESHGUI->SetActiveDialogBox(this);
2004-12-01 15:48:31 +05:00
ConstructorsClicked(GetConstructorId());
SelectionIntoArgument();
}
//=================================================================================
// function : enterEvent()
// purpose : Mouse enter event
2004-12-01 15:48:31 +05:00
//=================================================================================
void SMESHGUI_ExtrusionDlg::enterEvent (QEvent*)
2004-12-01 15:48:31 +05:00
{
2009-02-17 10:27:49 +05:00
if (!ConstructorsBox->isEnabled())
ActivateThisDialog();
2004-12-01 15:48:31 +05:00
}
//=================================================================================
// function : onSelectMesh()
// purpose :
//=================================================================================
void SMESHGUI_ExtrusionDlg::onSelectMesh (bool toSelectMesh)
2004-12-01 15:48:31 +05:00
{
2012-08-09 16:03:55 +06:00
if (toSelectMesh) {
myIDs = LineEditElements->text();
TextLabelElements->setText(tr("SMESH_NAME"));
2012-08-09 16:03:55 +06:00
}
2004-12-01 15:48:31 +05:00
else
TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
2012-08-09 16:03:55 +06:00
myFilterBtn->setEnabled(!toSelectMesh);
if (myEditCurrentArgument != LineEditElements) {
LineEditElements->clear();
return;
}
mySelectionMgr->clearFilters();
2012-10-08 17:56:59 +06:00
if (toSelectMesh)
{
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
2012-10-08 17:56:59 +06:00
switch( GetConstructorId() ) {
case 0: mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter0D); break;
case 1: mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter1D); break;
case 2: mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter2D); break;
}
LineEditElements->setReadOnly(true);
2009-02-17 10:27:49 +05:00
LineEditElements->setValidator(0);
2012-10-08 17:56:59 +06:00
}
else
{
int aConstructorId = GetConstructorId();
2012-08-09 16:03:55 +06:00
switch(aConstructorId) {
case 0:
{
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(NodeSelection);
break;
}
case 1:
{
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(EdgeSelection);
break;
}
case 2:
{
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(FaceSelection);
break;
}
}
LineEditElements->setReadOnly(false);
2009-02-17 10:27:49 +05:00
LineEditElements->setValidator(myIdValidator);
onTextChange(LineEditElements->text());
}
2004-12-01 15:48:31 +05:00
SelectionIntoArgument();
2012-08-09 16:03:55 +06:00
if (!toSelectMesh)
LineEditElements->setText( myIDs );
2004-12-01 15:48:31 +05:00
}
//=================================================================================
// function : GetConstructorId()
// purpose :
2004-12-01 15:48:31 +05:00
//=================================================================================
int SMESHGUI_ExtrusionDlg::GetConstructorId()
{
2009-02-17 10:27:49 +05:00
return GroupConstructors->checkedId();
2004-12-01 15:48:31 +05:00
}
//=================================================================================
// function : keyPressEvent()
// purpose :
//=================================================================================
void SMESHGUI_ExtrusionDlg::keyPressEvent( QKeyEvent* e )
{
QDialog::keyPressEvent( e );
if ( e->isAccepted() )
return;
2009-02-17 10:27:49 +05:00
if ( e->key() == Qt::Key_F1 ) {
e->accept();
ClickOnHelp();
}
}
//=================================================================================
// function : setFilters()
// purpose : SLOT. Called when "Filter" button pressed.
//=================================================================================
void SMESHGUI_ExtrusionDlg::setFilters()
{
2012-08-09 16:03:55 +06:00
if(myMesh->_is_nil()) {
SUIT_MessageBox::critical(this,
tr("SMESH_ERROR"),
tr("NO_MESH_SELECTED"));
return;
}
2009-02-17 10:27:49 +05:00
if ( !myFilterDlg )
{
QList<int> types;
2012-08-09 16:03:55 +06:00
types.append( SMESH::NODE );
2009-02-17 10:27:49 +05:00
types.append( SMESH::EDGE );
types.append( SMESH::FACE );
myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
}
2012-08-09 16:03:55 +06:00
switch( GetConstructorId() ){
case 0:
{
myFilterDlg->Init( SMESH::NODE );
break;
}
case 1:
{
myFilterDlg->Init( SMESH::EDGE );
break;
}
case 2:
{
myFilterDlg->Init( SMESH::FACE );
break;
}
}
2009-02-17 10:27:49 +05:00
myFilterDlg->SetSelection();
myFilterDlg->SetMesh( myMesh );
myFilterDlg->SetSourceWg( LineEditElements );
myFilterDlg->show();
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool SMESHGUI_ExtrusionDlg::isValid()
{
QString msg;
bool ok = true;
2012-08-09 16:03:55 +06:00
if ( RadioButton3->isChecked() ) {
ok = SpinBox_Dx->isValid( msg, true ) && ok;
ok = SpinBox_Dy->isValid( msg, true ) && ok;
ok = SpinBox_Dz->isValid( msg, true ) && ok;
} else if ( RadioButton4->isChecked() ) {
ok = SpinBox_Vx->isValid( msg, true ) && ok;
ok = SpinBox_Vy->isValid( msg, true ) && ok;
ok = SpinBox_Vz->isValid( msg, true ) && ok;
ok = SpinBox_VDist->isValid( msg, true ) && ok;
}
2009-02-17 10:27:49 +05:00
ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
if( !ok ) {
QString str( tr( "SMESH_INCORRECT_INPUT" ) );
if ( !msg.isEmpty() )
str += "\n" + msg;
SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
return false;
}
return true;
}
2012-08-09 16:03:55 +06:00
//=================================================================================
// function : onDisplaySimulation
// purpose : Show/Hide preview
//=================================================================================
void SMESHGUI_ExtrusionDlg::onDisplaySimulation( bool toDisplayPreview ) {
if (myPreviewCheckBox->isChecked() && toDisplayPreview) {
if (myNbOkElements && isValid() && isValuesValid()) {
//Get input vector
SMESH::DirStruct aVector;
getExtrusionVector(aVector);
//Get Number of the steps
long aNbSteps = (long)SpinBox_NbSteps->value();
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
if( CheckBoxMesh->isChecked() ) {
switch (GetConstructorId()) {
case 0:
{
aMeshEditor->ExtrusionSweepObject0D(mySelectedObject, aVector, aNbSteps);
break;
}
case 1:
{
aMeshEditor->ExtrusionSweepObject1D(mySelectedObject, aVector, aNbSteps);
break;
}
case 2:
{
aMeshEditor->ExtrusionSweepObject2D(mySelectedObject, aVector, aNbSteps);
break;
}
}
}
else
if(GetConstructorId() == 0)
aMeshEditor->ExtrusionSweep0D(myElementsId.inout(), aVector, aNbSteps);
else
aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps);
SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
mySimulation->SetData(aMeshPreviewStruct._retn());
} catch (...) {
hidePreview();
}
} else {
hidePreview();
}
} else {
hidePreview();
}
}
//=================================================================================
// function : getExtrusionVector()
// purpose : get direction of the extrusion
//=================================================================================
void SMESHGUI_ExtrusionDlg::getExtrusionVector(SMESH::DirStruct& aVector) {
if ( RadioButton3->isChecked() ) {
aVector.PS.x = SpinBox_Dx->GetValue();
aVector.PS.y = SpinBox_Dy->GetValue();
aVector.PS.z = SpinBox_Dz->GetValue();
} else if ( RadioButton4->isChecked() ) {
gp_XYZ aNormale(SpinBox_Vx->GetValue(),
SpinBox_Vy->GetValue(),
SpinBox_Vz->GetValue());
aNormale /= aNormale.Modulus();
double aVDist = (double)SpinBox_VDist->value();
aVector.PS.x = aNormale.X()*aVDist;
aVector.PS.y = aNormale.Y()*aVDist;
aVector.PS.z = aNormale.Z()*aVDist;
}
}