X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_ExtrusionAlongPathDlg.cxx;h=513205ced9ac78179486d17655053e4136292a06;hp=989518fe02b671162ec32071a150deb6d87dbf72;hb=6d32f944a0a115b6419184c50b57bf7c4eef5786;hpb=4f7811fdb1e758270519988f66fcb79aa65322ea diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx index 989518fe0..513205ced 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx @@ -1,1167 +1,1262 @@ -// SMESH SMESHGUI : GUI for SMESH component +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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. -// -// 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. -// -// 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 -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // +// 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, or (at your option) any later version. // +// 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. // -// File : SMESHGUI_ExtrusionAlongPathDlg.cxx -// Author : Vadim SANDLER -// Module : SMESH -// $Header: +// 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// SMESH SMESHGUI : GUI for SMESH component +// File : SMESHGUI_ExtrusionAlongPathDlg.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. +// SMESH includes #include "SMESHGUI_ExtrusionAlongPathDlg.h" + #include "SMESHGUI.h" +#include "SMESHGUI_ExtrusionDlg.h" // for SMESHGUI_3TypesSelector +#include "SMESHGUI_FilterDlg.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_MeshEditPreview.h" +#include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_SpinBox.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" -#include "SMESHGUI_MeshUtils.h" -#include "SMESHGUI_IdValidator.h" -#include "SMESH_Actor.h" -#include "SMESH_NumberFilter.hxx" -#include "SMDS_Mesh.hxx" -#include "GEOM_ShapeTypeFilter.hxx" -#include "GEOMBase.h" - -#include "QAD_Application.h" -#include "QAD_WaitCursor.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" -#include "utilities.h" +#include +#include +#include +#include + +#include + +// SALOME GEOM includes +#include + +// SALOME GUI includes +#include +#include +#include +#include +#include +#include +#include +#include + +// OCCT includes #include -#include -#include #include #include - -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// IDL Headers -#include "SALOMEconfig.h" +#include + +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// IDL includes +#include #include CORBA_SERVER_HEADER(SMESH_Group) +#include CORBA_SERVER_HEADER(SMESH_MeshEditor) -using namespace std; +#define SPACING 6 +#define MARGIN 11 + +class SMESHGUI_ExtrusionAlongPathDlg::SetBusy +{ +public: + SetBusy( SMESHGUI_ExtrusionAlongPathDlg* _dlg ) + { + myDlg = _dlg; + myDlg->myBusy = true; + } + + ~SetBusy() + { + myDlg->myBusy = false; + } + +private: + SMESHGUI_ExtrusionAlongPathDlg* myDlg; +}; //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg() +// function : SMESHGUI_ExtrusionAlongPathDlg() // purpose : constructor //================================================================================= -SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( QWidget* parent, SALOME_Selection* Sel, bool modal ) - : QDialog( parent, "SMESHGUI_ExtrusionAlongPathDlg", modal, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose ) +SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theModule ) + : SMESHGUI_PreviewDlg( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg"); - myType = -1; - QPixmap edgeImage ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_DLG_EDGE" ) ) ); - QPixmap faceImage ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_DLG_TRIANGLE" ) ) ); - QPixmap selectImage( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) ); - QPixmap addImage ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_APPEND" ) ) ); - QPixmap removeImage( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_REMOVE" ) ) ); + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); + QPixmap selectImage ( mgr->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap addImage ( mgr->loadPixmap("SMESH", tr("ICON_APPEND"))); + QPixmap removeImage ( mgr->loadPixmap("SMESH", tr("ICON_REMOVE"))); - setCaption( tr( "EXTRUSION_ALONG_PATH" ) ); - setSizeGripEnabled( TRUE ); + setModal( false ); + setAttribute( Qt::WA_DeleteOnClose, true ); + setWindowTitle(tr("EXTRUSION_ALONG_PATH")); + setSizeGripEnabled(true); - QGridLayout* topLayout = new QGridLayout( this ); - topLayout->setSpacing( 6 ); topLayout->setMargin( 11 ); + QVBoxLayout* topLayout = new QVBoxLayout(this); + topLayout->setSpacing(SPACING); + topLayout->setMargin(MARGIN); - /***************************************************************/ - // Elements type group box (1d / 2d elements) - ElementsTypeGrp = new QButtonGroup( tr( "SMESH_EXTRUSION" ), this ); - ElementsTypeGrp->setColumnLayout( 0, Qt::Vertical ); - ElementsTypeGrp->layout()->setSpacing( 0 ); ElementsTypeGrp->layout()->setMargin( 0 ); - QGridLayout* ElementsTypeGrpLayout = new QGridLayout( ElementsTypeGrp->layout() ); - ElementsTypeGrpLayout->setAlignment( Qt::AlignTop ); - ElementsTypeGrpLayout->setSpacing( 6 ); ElementsTypeGrpLayout->setMargin( 11 ); - - Elements1dRB = new QRadioButton( ElementsTypeGrp ); - Elements1dRB->setPixmap( edgeImage ); - Elements2dRB = new QRadioButton( ElementsTypeGrp ); - Elements2dRB->setPixmap( faceImage ); - Elements1dRB->setChecked( true ); - - // layouting - ElementsTypeGrpLayout->addWidget( Elements1dRB, 0, 0 ); - ElementsTypeGrpLayout->addWidget( Elements2dRB, 0, 2 ); - /***************************************************************/ // Arguments group box - ArgumentsGrp = new QGroupBox( tr( "EXTRUSION_1D" ), this ); - ArgumentsGrp->setColumnLayout( 0, Qt::Vertical ); - ArgumentsGrp->layout()->setSpacing( 0 ); ArgumentsGrp->layout()->setMargin( 0 ); - QGridLayout* ArgumentsGrpLayout = new QGridLayout( ArgumentsGrp->layout() ); - ArgumentsGrpLayout->setAlignment( Qt::AlignTop ); - ArgumentsGrpLayout->setSpacing( 6 ); ArgumentsGrpLayout->setMargin( 11 ); + GroupArguments = new QGroupBox(tr("SMESH_EXTRUSION"), this); + QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments); + GroupArgumentsLayout->setSpacing(SPACING); GroupArgumentsLayout->setMargin(MARGIN); + + myIdValidator = new SMESHGUI_IdValidator(this); // Controls for elements selection - ElementsLab = new QLabel( tr( "SMESH_ID_ELEMENTS" ), ArgumentsGrp ); + SelectorWdg = new SMESHGUI_3TypesSelector( GroupArguments ); + + // Controls for path selection + PathGrp = new QGroupBox(tr("SMESH_PATH"), GroupArguments); + QGridLayout* PathGrpLayout = new QGridLayout(PathGrp); + PathGrpLayout->setSpacing(SPACING); PathGrpLayout->setMargin(MARGIN); - SelectElementsButton = new QToolButton( ArgumentsGrp ); - SelectElementsButton->setPixmap( selectImage ); + // Controls for path mesh selection + QLabel* PathMeshLab = new QLabel(tr("SMESH_PATH_MESH"), PathGrp); - ElementsLineEdit = new QLineEdit( ArgumentsGrp ); - ElementsLineEdit->setValidator( new SMESHGUI_IdValidator( this ) ); + SelectPathMeshButton = new QPushButton(PathGrp); + SelectPathMeshButton->setIcon(selectImage); + SelectPathMeshButton->setCheckable(true); - // Controls for the whole mesh selection - MeshCheck = new QCheckBox( tr( "SMESH_SELECT_WHOLE_MESH" ), ArgumentsGrp ); + PathMeshLineEdit = new QLineEdit(PathGrp); + PathMeshLineEdit->setReadOnly(true); - // Controls for path selection - PathGrp = new QGroupBox( tr( "SMESH_PATH" ), ArgumentsGrp ); - PathGrp->setColumnLayout( 0, Qt::Vertical ); - PathGrp->layout()->setSpacing( 0 ); PathGrp->layout()->setMargin( 0 ); - QGridLayout* PathGrpLayout = new QGridLayout( PathGrp->layout() ); - PathGrpLayout->setAlignment( Qt::AlignTop ); - PathGrpLayout->setSpacing( 6 ); PathGrpLayout->setMargin( 11 ); - - // Controls for path mesh selection - PathMeshLab = new QLabel( tr( "SMESH_PATH_MESH" ), PathGrp ); + // Controls for path starting point selection + QLabel* StartPointLab = new QLabel(tr("SMESH_PATH_START"), PathGrp); - SelectPathMeshButton = new QToolButton( PathGrp ); - SelectPathMeshButton->setPixmap( selectImage ); + SelectStartPointButton = new QPushButton(PathGrp); + SelectStartPointButton->setIcon(selectImage); + SelectStartPointButton->setCheckable(true); - PathMeshLineEdit = new QLineEdit( PathGrp ); - PathMeshLineEdit->setReadOnly( true ); + StartPointLineEdit = new QLineEdit(PathGrp); + StartPointLineEdit->setValidator(new QIntValidator(this)); - // Controls for path shape selection - PathShapeLab = new QLabel( tr( "SMESH_PATH_SHAPE" ), PathGrp ); + // layouting + PathGrpLayout->addWidget(PathMeshLab, 0, 0); + PathGrpLayout->addWidget(SelectPathMeshButton, 0, 1); + PathGrpLayout->addWidget(PathMeshLineEdit, 0, 2); + PathGrpLayout->addWidget(StartPointLab, 1, 0); + PathGrpLayout->addWidget(SelectStartPointButton, 1, 1); + PathGrpLayout->addWidget(StartPointLineEdit, 1, 2); + + BasePointGrp = new QGroupBox(tr("SMESH_BASE_POINT"), GroupArguments); + BasePointGrp->setCheckable(true); + BasePointGrp->setChecked(false); + QHBoxLayout* BasePointGrpLayout = new QHBoxLayout(BasePointGrp); + BasePointGrpLayout->setSpacing(SPACING); BasePointGrpLayout->setMargin(MARGIN); + + SelectBasePointButton = new QPushButton(BasePointGrp); + SelectBasePointButton->setIcon(selectImage); + SelectBasePointButton->setCheckable(true); + + SelectorWdg->GetButtonGroup()->addButton( SelectPathMeshButton ); + SelectorWdg->GetButtonGroup()->addButton( SelectStartPointButton ); + SelectorWdg->GetButtonGroup()->addButton( SelectBasePointButton ); + + QLabel* XLab = new QLabel(tr("SMESH_X"), BasePointGrp); + XSpin = new SMESHGUI_SpinBox(BasePointGrp); + QLabel* YLab = new QLabel(tr("SMESH_Y"), BasePointGrp); + YSpin = new SMESHGUI_SpinBox(BasePointGrp); + QLabel* ZLab = new QLabel(tr("SMESH_Z"), BasePointGrp); + ZSpin = new SMESHGUI_SpinBox(BasePointGrp); - SelectPathShapeButton = new QToolButton( PathGrp ); - SelectPathShapeButton->setPixmap( selectImage ); + // layouting + BasePointGrpLayout->addWidget(SelectBasePointButton); + BasePointGrpLayout->addWidget(XLab); + BasePointGrpLayout->addWidget(XSpin); + BasePointGrpLayout->addWidget(YLab); + BasePointGrpLayout->addWidget(YSpin); + BasePointGrpLayout->addWidget(ZLab); + BasePointGrpLayout->addWidget(ZSpin); - PathShapeLineEdit = new QLineEdit( PathGrp ); - PathShapeLineEdit->setReadOnly( true ); + // Angles + AnglesGrp = new QGroupBox(tr("SMESH_ANGLES"), GroupArguments); + AnglesGrp->setCheckable(true); + AnglesGrp->setChecked(false); + QGridLayout* AnglesGrpLayout = new QGridLayout(AnglesGrp); + AnglesGrpLayout->setSpacing(SPACING); AnglesGrpLayout->setMargin(MARGIN); - // Controls for path starting point selection - StartPointLab = new QLabel( tr( "SMESH_PATH_START" ), PathGrp ); + AnglesList = new QListWidget(AnglesGrp); + AnglesList->setSelectionMode(QListWidget::ExtendedSelection); - SelectStartPointButton = new QToolButton( PathGrp ); - SelectStartPointButton->setPixmap( selectImage ); + AddAngleButton = new QToolButton(AnglesGrp); + AddAngleButton->setIcon(addImage); - StartPointLineEdit = new QLineEdit( PathGrp ); - StartPointLineEdit->setValidator( new QIntValidator( this ) ); + RemoveAngleButton = new QToolButton(AnglesGrp); + RemoveAngleButton->setIcon(removeImage); - // layouting - PathGrpLayout->addWidget( PathMeshLab, 0, 0 ); - PathGrpLayout->addWidget( SelectPathMeshButton, 0, 1 ); - PathGrpLayout->addWidget( PathMeshLineEdit, 0, 2 ); - PathGrpLayout->addWidget( PathShapeLab, 1, 0 ); - PathGrpLayout->addWidget( SelectPathShapeButton, 1, 1 ); - PathGrpLayout->addWidget( PathShapeLineEdit, 1, 2 ); - PathGrpLayout->addWidget( StartPointLab, 2, 0 ); - PathGrpLayout->addWidget( SelectStartPointButton, 2, 1 ); - PathGrpLayout->addWidget( StartPointLineEdit, 2, 2 ); - - // Controls for base point defining - BasePointCheck = new QCheckBox( tr( "SMESH_USE_BASE_POINT" ), ArgumentsGrp ); - - BasePointGrp = new QGroupBox( tr( "SMESH_BASE_POINT" ), ArgumentsGrp ); - BasePointGrp->setColumnLayout( 0, Qt::Vertical ); - BasePointGrp->layout()->setSpacing( 0 ); BasePointGrp->layout()->setMargin( 0 ); - QGridLayout* BasePointGrpLayout = new QGridLayout( BasePointGrp->layout() ); - BasePointGrpLayout->setAlignment( Qt::AlignTop ); - BasePointGrpLayout->setSpacing( 6 ); BasePointGrpLayout->setMargin( 11 ); - - SelectBasePointButton = new QToolButton( BasePointGrp ); - SelectBasePointButton->setPixmap( selectImage ); + AngleSpin = new SMESHGUI_SpinBox(AnglesGrp); - XLab = new QLabel( tr( "SMESH_X" ), BasePointGrp ); - XSpin = new SMESHGUI_SpinBox( BasePointGrp ); - YLab = new QLabel( tr( "SMESH_Y" ), BasePointGrp ); - YSpin = new SMESHGUI_SpinBox( BasePointGrp ); - ZLab = new QLabel( tr( "SMESH_Z" ), BasePointGrp ); - ZSpin = new SMESHGUI_SpinBox( BasePointGrp ); + LinearAnglesCheck = new QCheckBox(tr("LINEAR_ANGLES"), AnglesGrp); - // layouting - BasePointGrpLayout->addWidget( SelectBasePointButton, 0, 0 ); - BasePointGrpLayout->addWidget( XLab, 0, 1 ); - BasePointGrpLayout->addWidget( XSpin, 0, 2 ); - BasePointGrpLayout->addWidget( YLab, 0, 3 ); - BasePointGrpLayout->addWidget( YSpin, 0, 4 ); - BasePointGrpLayout->addWidget( ZLab, 0, 5 ); - BasePointGrpLayout->addWidget( ZSpin, 0, 6 ); - - // Controls for angles defining - AnglesCheck = new QCheckBox( tr( "SMESH_USE_ANGLES" ), ArgumentsGrp ); - - AnglesGrp = new QGroupBox( tr( "SMESH_ANGLES" ), ArgumentsGrp ); - AnglesGrp->setColumnLayout( 0, Qt::Vertical ); - AnglesGrp->layout()->setSpacing( 0 ); AnglesGrp->layout()->setMargin( 0 ); - QGridLayout* AnglesGrpLayout = new QGridLayout( AnglesGrp->layout() ); - AnglesGrpLayout->setAlignment( Qt::AlignTop ); - AnglesGrpLayout->setSpacing( 6 ); AnglesGrpLayout->setMargin( 11 ); - - AnglesList = new QListBox( AnglesGrp ); - AnglesList->setSelectionMode( QListBox::Extended ); + AnglesGrpLayout->addWidget(AnglesList, 0, 0, 4, 1); + AnglesGrpLayout->addWidget(AddAngleButton, 0, 1); + AnglesGrpLayout->addWidget(RemoveAngleButton, 2, 1); + AnglesGrpLayout->addWidget(AngleSpin, 0, 2); + AnglesGrpLayout->addWidget(LinearAnglesCheck, 4, 0, 1, 3); + AnglesGrpLayout->setRowMinimumHeight(1, 10); + AnglesGrpLayout->setRowStretch(3, 10); - AddAngleButton = new QToolButton( AnglesGrp ); - AddAngleButton->setPixmap( addImage ); + // Scales + ScalesGrp = new QGroupBox(tr("SMESH_SCALES"), GroupArguments); + ScalesGrp->setCheckable(true); + ScalesGrp->setChecked(false); + QGridLayout* ScalesGrpLayout = new QGridLayout(ScalesGrp); + ScalesGrpLayout->setSpacing(SPACING); ScalesGrpLayout->setMargin(MARGIN); - RemoveAngleButton = new QToolButton( AnglesGrp ); - RemoveAngleButton->setPixmap( removeImage ); + ScalesList = new QListWidget(ScalesGrp); + ScalesList->setSelectionMode(QListWidget::ExtendedSelection); - AngleSpin = new SMESHGUI_SpinBox( AnglesGrp ); + AddScaleButton = new QToolButton(ScalesGrp); + AddScaleButton->setIcon(addImage); + + RemoveScaleButton = new QToolButton(ScalesGrp); + RemoveScaleButton->setIcon(removeImage); + + ScaleSpin = new SMESHGUI_SpinBox(ScalesGrp); + + LinearScalesCheck = new QCheckBox(tr("LINEAR_SCALES"), ScalesGrp); + + ScalesGrpLayout->addWidget(ScalesList, 0, 0, 4, 1); + ScalesGrpLayout->addWidget(AddScaleButton, 0, 1); + ScalesGrpLayout->addWidget(RemoveScaleButton, 2, 1); + ScalesGrpLayout->addWidget(ScaleSpin, 0, 2); + ScalesGrpLayout->addWidget(LinearScalesCheck, 4, 0, 1, 3); + ScalesGrpLayout->setRowMinimumHeight(1, 10); + ScalesGrpLayout->setRowStretch(3, 10); + + // CheckBox for groups generation + MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments); + MakeGroupsCheck->setChecked(true); + + //Preview check box + myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments); // layouting - QVBoxLayout* bLayout = new QVBoxLayout(); - bLayout->addWidget( AddAngleButton ); - bLayout->addSpacing( 6 ); - bLayout->addWidget( RemoveAngleButton ); - bLayout->addStretch(); - AnglesGrpLayout->addMultiCellWidget( AnglesList, 0, 1, 0, 0 ); - AnglesGrpLayout->addMultiCellLayout( bLayout, 0, 1, 1, 1 ); - AnglesGrpLayout->addWidget( AngleSpin, 0, 2 ); - AnglesGrpLayout->setRowStretch( 1, 10 ); - - // layouting - ArgumentsGrpLayout->addWidget( ElementsLab, 0, 0 ); - ArgumentsGrpLayout->addWidget( SelectElementsButton, 0, 1 ); - ArgumentsGrpLayout->addWidget( ElementsLineEdit, 0, 2 ); - ArgumentsGrpLayout->addMultiCellWidget( MeshCheck, 1, 1, 0, 2 ); - ArgumentsGrpLayout->addMultiCellWidget( PathGrp, 2, 2, 0, 2 ); - ArgumentsGrpLayout->addWidget( BasePointCheck, 3, 0 ); - ArgumentsGrpLayout->addMultiCellWidget( BasePointGrp, 3, 4, 1, 2 ); - ArgumentsGrpLayout->addWidget( AnglesCheck, 5, 0 ); - ArgumentsGrpLayout->addMultiCellWidget( AnglesGrp, 5, 6, 1, 2 ); - ArgumentsGrpLayout->setRowStretch( 6, 10 ); + GroupArgumentsLayout->addWidget(SelectorWdg, 0, 0, 1, 2); + GroupArgumentsLayout->addWidget(PathGrp, 1, 0, 1, 2); + GroupArgumentsLayout->addWidget(BasePointGrp, 2, 0, 1, 2); + GroupArgumentsLayout->addWidget(AnglesGrp, 3, 0); + GroupArgumentsLayout->addWidget(ScalesGrp, 3, 1); + GroupArgumentsLayout->addWidget(myPreviewCheckBox, 4, 0); + GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 0); /***************************************************************/ // common buttons group box - ButtonsGrp = new QGroupBox( this ); - ButtonsGrp->setColumnLayout( 0, Qt::Vertical ); - ButtonsGrp->layout()->setSpacing( 0 ); ButtonsGrp->layout()->setMargin( 0 ); - QGridLayout* ButtonsGrpLayout = new QGridLayout( ButtonsGrp->layout() ); - ButtonsGrpLayout->setAlignment( Qt::AlignTop ); - ButtonsGrpLayout->setSpacing( 6 ); ButtonsGrpLayout->setMargin( 11 ); + GroupButtons = new QGroupBox(this); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons); + GroupButtonsLayout->setSpacing(SPACING); GroupButtonsLayout->setMargin(MARGIN); - OkButton = new QPushButton( tr( "SMESH_BUT_OK" ), ButtonsGrp ); - OkButton->setAutoDefault( true ); - OkButton->setDefault( true ); + OkButton = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons); + OkButton->setAutoDefault(true); + OkButton->setDefault(true); - ApplyButton = new QPushButton( tr( "SMESH_BUT_APPLY" ), ButtonsGrp ); - ApplyButton->setAutoDefault( true ); + ApplyButton = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons); + ApplyButton->setAutoDefault(true); - CloseButton = new QPushButton( tr( "SMESH_BUT_CLOSE" ), ButtonsGrp ); - CloseButton->setAutoDefault( true ); + CloseButton = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons); + CloseButton->setAutoDefault(true); + + HelpButton = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons); + HelpButton->setAutoDefault(true); // layouting - ButtonsGrpLayout->addWidget( OkButton, 0, 0 ); - ButtonsGrpLayout->addWidget( ApplyButton, 0, 1 ); - ButtonsGrpLayout->addWidget( CloseButton, 0, 3 ); - ButtonsGrpLayout->addColSpacing( 2, 10 ); - ButtonsGrpLayout->setColStretch( 2, 10 ); + GroupButtonsLayout->addWidget(OkButton); + GroupButtonsLayout->addSpacing(10); + GroupButtonsLayout->addWidget(ApplyButton); + GroupButtonsLayout->addSpacing(10); + GroupButtonsLayout->addStretch(); + GroupButtonsLayout->addWidget(CloseButton); + GroupButtonsLayout->addWidget(HelpButton); /***************************************************************/ // layouting - topLayout->addWidget( ElementsTypeGrp, 0, 0 ); - topLayout->addWidget( ArgumentsGrp, 1, 0 ); - topLayout->addWidget( ButtonsGrp, 2, 0 ); + topLayout->addWidget(GroupArguments); + topLayout->addWidget(GroupButtons); /***************************************************************/ // Initialisations - XSpin->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - YSpin->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - ZSpin->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); - AngleSpin->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 ); - - mySelection = Sel; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( this ) ; - - // Costruction of the logical filter for the elements: mesh/sub-mesh/group - SMESH_ListOfFilter aListOfFilters; - Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - if ( !aMeshOrSubMeshFilter.IsNull() ) - aListOfFilters.Append( aMeshOrSubMeshFilter ); - Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); - if ( !aSmeshGroupFilter.IsNull() ) - aListOfFilters.Append( aSmeshGroupFilter ); - - myElementsFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); - - myPathMeshFilter = new SMESH_TypeFilter( MESH ); - - Init(); + XSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + YSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + ZSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + AngleSpin->RangeStepAndValidator(-180.0, 180.0, 5.0, "angle_precision"); + ScaleSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 1.0, "length_precision"); - /***************************************************************/ - // signals-slots connections - connect( OkButton, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( CloseButton, SIGNAL( clicked() ), this, SLOT( reject() ) ) ; - connect( ApplyButton, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector(); - connect( AddAngleButton, SIGNAL( clicked() ), this, SLOT( OnAngleAdded() ) ); - connect( RemoveAngleButton, SIGNAL( clicked() ), this, SLOT( OnAngleRemoved() ) ); + mySMESHGUI->SetActiveDialogBox(this); - connect( ElementsTypeGrp, SIGNAL( clicked( int ) ), SLOT( TypeChanged( int ) ) ); - - connect( SelectElementsButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectPathMeshButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectPathShapeButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectStartPointButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectBasePointButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - - connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( reject() ) ) ; - - connect( ElementsLineEdit, SIGNAL( textChanged( const QString& ) ), - SLOT( onTextChange( const QString& ) ) ); - connect( StartPointLineEdit, SIGNAL( textChanged( const QString& ) ), - SLOT( onTextChange( const QString& ) ) ); - - connect( MeshCheck, SIGNAL( toggled( bool ) ), SLOT( onSelectMesh() ) ); - connect( AnglesCheck, SIGNAL( toggled( bool ) ), SLOT( onAnglesCheck() ) ); - connect( BasePointCheck, SIGNAL( toggled( bool ) ), SLOT( onBasePointCheck() ) ); - - AnglesList->installEventFilter( this ); - ElementsLineEdit->installEventFilter( this ); - StartPointLineEdit->installEventFilter( this ); - XSpin->editor()->installEventFilter( this ); - YSpin->editor()->installEventFilter( this ); - ZSpin->editor()->installEventFilter( this ); + myPathMeshFilter = new SMESH_TypeFilter(SMESH::IDSOURCE_EDGE); + + myHelpFileName = "extrusion_along_path.html"; + + Init(); /***************************************************************/ - // set position and show dialog box - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; // displays Dialog + // signals-slots connections + connect(OkButton, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(CloseButton, SIGNAL(clicked()), this, SLOT(reject())); + connect(ApplyButton, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(HelpButton, SIGNAL(clicked()), this, SLOT(ClickOnHelp())); + + connect(AddAngleButton, SIGNAL(clicked()), this, SLOT(OnAngleAdded())); + connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(OnAngleRemoved())); + connect(AddScaleButton, SIGNAL(clicked()), this, SLOT(OnAngleAdded())); + connect(RemoveScaleButton, SIGNAL(clicked()), this, SLOT(OnAngleRemoved())); + + connect(SelectPathMeshButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectStartPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(SelectBasePointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(BasePointGrp, SIGNAL(toggled(bool)), this, SLOT(SetEditCurrentArgument())); + + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject())); + connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), SLOT(onOpenView())); + connect(mySMESHGUI, SIGNAL(SignalCloseView()), SLOT(onCloseView())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument())); + connect(SelectorWdg, SIGNAL(selectionChanged()), this, SLOT(toDisplaySimulation())); + connect(SelectorWdg, SIGNAL(selectionChanged()), this, SLOT(CheckIsEnable())); + + connect(StartPointLineEdit, SIGNAL(textChanged(const QString&)), + SLOT(onTextChange(const QString&))); + + connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); + connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); + connect(ZSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); + connect(AddAngleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation())); + connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation())); + connect(AddScaleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation())); + connect(RemoveScaleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation())); + connect(LinearScalesCheck, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation())); + connect(LinearAnglesCheck, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation())); + connect(ScalesGrp, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation())); + connect(AnglesGrp, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation())); + + + //To Connect preview check box + connectPreviewControl(); + + AnglesList ->installEventFilter(this); + ScalesList ->installEventFilter(this); + StartPointLineEdit->installEventFilter(this); + XSpin->editor() ->installEventFilter(this); + YSpin->editor() ->installEventFilter(this); + ZSpin->editor() ->installEventFilter(this); + + CheckIsEnable(); + + resize( minimumSizeHint() ); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg() +// function : ~SMESHGUI_ExtrusionAlongPathDlg() // purpose : destructor //================================================================================= SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg"); // no need to delete child widgets, Qt does it all for us } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::eventFilter -// purpose : event filter -//================================================================================= -bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter( QObject* object, QEvent* event ) -{ - if ( event->type() == QEvent::KeyPress ) { - QKeyEvent* ke = ( QKeyEvent* )event; - if ( object == AnglesList ) { - if ( ke->key() == Key_Delete ) - OnAngleRemoved(); - } - } - else if ( event->type() == QEvent::FocusIn ) { - if ( object == ElementsLineEdit ) { - if ( myEditCurrentArgument != ElementsLineEdit ) - SetEditCurrentArgument( SelectElementsButton ); - } - else if ( object == StartPointLineEdit ) { - if ( myEditCurrentArgument != StartPointLineEdit ) - SetEditCurrentArgument( SelectStartPointButton ); - } - else if ( object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor() ) { - if ( myEditCurrentArgument != XSpin ) - SetEditCurrentArgument( SelectBasePointButton ); - } - } - return QDialog::eventFilter( object, event ); -} - -//================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::Init() +// function : Init() // purpose : initialization //================================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::Init( bool ResetControls ) +void SMESHGUI_ExtrusionAlongPathDlg::Init (bool ResetControls) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::Init"); myBusy = false; myEditCurrentArgument = 0; - - myMesh = SMESH::SMESH_Mesh::_nil(); - myIDSource = SMESH::SMESH_IDSource::_nil(); - myMeshActor = 0; - myPathMesh = SMESH::SMESH_Mesh::_nil(); - myPathShape = GEOM::GEOM_Object::_nil(); - - ElementsLineEdit->clear(); + + myPath = SMESH::SMESH_IDSource::_nil(); + + SelectorWdg->Clear(); PathMeshLineEdit->clear(); - PathShapeLineEdit->clear(); StartPointLineEdit->clear(); - if( ResetControls ) { - XSpin->SetValue( 0.0 ); - YSpin->SetValue( 0.0 ); - ZSpin->SetValue( 0.0 ); - - AngleSpin->SetValue( 45 ); - MeshCheck->setChecked( false ); - TypeChanged( 0 ); - onSelectMesh(); - onAnglesCheck(); - onBasePointCheck(); + if (ResetControls) { + XSpin->SetValue(0.0); + YSpin->SetValue(0.0); + ZSpin->SetValue(0.0); + + AngleSpin->SetValue(45); + ScaleSpin->SetValue(2); + myPreviewCheckBox->setChecked(false); + onDisplaySimulation(false); } - SetEditCurrentArgument( 0 ); + SetEditCurrentArgument(0); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::TypeChanged() -// purpose : Called when user changes type of elements ( 1d / 2d ) +// function : CheckIsEnable() +// purpose : Check whether the Ok and Apply buttons should be enabled or not //================================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::TypeChanged( int type ) -{ - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::TypeChanged"); - if ( myType != type ) { - disconnect( mySelection, 0, this, 0 ); - - if ( type == 0 ) - ArgumentsGrp->setTitle( tr( "EXTRUSION_1D" ) ); - else if ( type == 1 ) - ArgumentsGrp->setTitle( tr( "EXTRUSION_2D" ) ); - - // clear elements ID list - if ( !MeshCheck->isChecked() ) { - ElementsLineEdit->clear(); - } - // set selection mode if necessary - if( myEditCurrentArgument == ElementsLineEdit ) { - mySelection->ClearIObjects(); - mySelection->ClearFilters(); - SMESH::SetPickable(); - - SMESH::SetPointRepresentation( false ); - if ( MeshCheck->isChecked() ) { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter( myElementsFilter ); - } - else { - if ( type == 0 ) - QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); - if ( type == 1 ) - QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); - } - } - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - } - myType = type; -} +void SMESHGUI_ExtrusionAlongPathDlg::CheckIsEnable() +{ + bool anIsEnable = SelectorWdg->IsAnythingSelected() && isValuesValid(); + + OkButton->setEnabled(anIsEnable); + ApplyButton->setEnabled(anIsEnable); +} //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() +// function : ClickOnApply() // purpose : Called when user presses button //================================================================================= bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply"); - if ( mySMESHGUI->ActiveStudyLocked() ) { + if (SMESHGUI::isStudyLocked()) return false; - } - - if( myMesh->_is_nil() || MeshCheck->isChecked() && myIDSource->_is_nil() || !myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil() ) { + + if ( !SelectorWdg->IsAnythingSelected() || myPath->_is_nil() ) return false; - } - SMESH::long_array_var anElementsId = new SMESH::long_array; - - if ( MeshCheck->isChecked() ) { - // If "Select whole mesh, submesh or group" check box is on -> - // get all elements of the required type from the object selected - - // if MESH object is selected - if ( !CORBA::is_nil( SMESH::SMESH_Mesh::_narrow( myIDSource ) ) ) { - // get mesh - SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( myIDSource ); - // get IDs from mesh... - if ( Elements1dRB->isChecked() ) - // 1d elements - anElementsId = aMesh->GetElementsByType( SMESH::EDGE ); - else if ( Elements2dRB->isChecked() ) { - anElementsId = aMesh->GetElementsByType( SMESH::FACE ); - } - } - // SUBMESH is selected - if ( !CORBA::is_nil( SMESH::SMESH_subMesh::_narrow( myIDSource ) ) ) { - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( myIDSource ); - // get IDs from submesh - if ( Elements1dRB->isChecked() ) - // 1d elements - anElementsId = aSubMesh->GetElementsByType( SMESH::EDGE ); - else if ( Elements2dRB->isChecked() ) - // 2d elements - anElementsId = aSubMesh->GetElementsByType( SMESH::FACE ); - } - // GROUP is selected - if ( !CORBA::is_nil( SMESH::SMESH_GroupBase::_narrow( myIDSource ) ) ) { - // get smesh group - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( myIDSource ); - // get IDs from group - // 1d elements or 2d elements - if ( Elements1dRB->isChecked() && aGroup->GetType() == SMESH::EDGE || - Elements2dRB->isChecked() && aGroup->GetType() == SMESH::FACE ) - anElementsId = aGroup->GetListOfID(); - } - } - else { - // If "Select whole mesh, submesh or group" check box is off -> - // use only elements of given type selected by user - - SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh(); - if ( aMesh ) { - QStringList aListElementsId = QStringList::split( " ", ElementsLineEdit->text(), false ); - anElementsId = new SMESH::long_array; - anElementsId->length( aListElementsId.count() ); - bool bOk; - int j = 0; - for ( int i = 0; i < aListElementsId.count(); i++ ) { - long ind = aListElementsId[ i ].toLong( &bOk ); - if ( bOk ) { - const SMDS_MeshElement* e = aMesh->FindElement( ind ); - if ( e ) { - bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || - Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face; - if ( typeMatch ) - anElementsId[ j++ ] = ind; - } - } - } - anElementsId->length( j ); - } - } - - if ( anElementsId->length() <= 0 ) { + if (!isValid()) return false; - } - if ( StartPointLineEdit->text().stripWhiteSpace().isEmpty() ) { + if (StartPointLineEdit->text().trimmed().isEmpty()) { return false; } bool bOk; - long aNodeStart = StartPointLineEdit->text().toLong( &bOk ); - if ( !bOk ) { + long aNodeStart = StartPointLineEdit->text().toLong(&bOk); + if (!bOk) { return false; } + + QStringList aParameters; - // get angles - SMESH::double_array_var anAngles = new SMESH::double_array; - if ( AnglesCheck->isChecked() ) { - anAngles->length( AnglesList->count() ); - int j = 0; - bool bOk; - for ( int i = 0; i < AnglesList->count(); i++ ) { - double angle = AnglesList->text( i ).toDouble( &bOk ); - if ( bOk ) - anAngles[ j++ ] = angle*PI/180; - } - anAngles->length( j ); - } + //get angles + SMESH::double_array_var anAngles = getAngles(); + for (int i = 0; i < myAnglesList.count(); i++) + aParameters << AnglesList->item(i)->text(); // get base point SMESH::PointStruct aBasePoint; - if ( BasePointCheck->isChecked() ) { + if (BasePointGrp->isChecked()) { aBasePoint.x = XSpin->GetValue(); aBasePoint.y = YSpin->GetValue(); aBasePoint.z = ZSpin->GetValue(); } - + aParameters << XSpin->text(); + aParameters << YSpin->text(); + aParameters << ZSpin->text(); + + //get scales + SMESH::double_array_var aScales = getScales(); + for (int i = 0; i < myScalesList.count(); i++) + aParameters << ScalesList->item(i)->text(); + + bool meshHadNewTypeBefore = true; + int maxSelType = 0; + const bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ); + try { - QAD_WaitCursor wc; - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - SMESH::SMESH_MeshEditor::Extrusion_Error retVal = - aMeshEditor->ExtrusionAlongPath( anElementsId.inout(), myPathMesh, myPathShape, aNodeStart, - AnglesCheck->isChecked(), anAngles.inout(), - BasePointCheck->isChecked(), aBasePoint ); - - wc.stop(); - switch ( retVal ) { + SUIT_OverrideCursor wc; + + SMESH::SMESH_Mesh_var mesh = SelectorWdg->GetMesh(); + + mesh->SetParameters( aParameters.join(":").toUtf8().constData() ); + + SMESH::ListOfIDSources_var nodes = new SMESH::ListOfIDSources(); + SMESH::ListOfIDSources_var edges = new SMESH::ListOfIDSources(); + SMESH::ListOfIDSources_var faces = new SMESH::ListOfIDSources(); + maxSelType = SelectorWdg->GetSelected( nodes, edges, faces ); + + // is it necessary to switch on the next Display Mode? + SMESH::ElementType newType = (SMESH::ElementType)( maxSelType + 1 ); + SMESH::array_of_ElementType_var oldTypes = mesh->GetTypes(); + meshHadNewTypeBefore = false; + for ( size_t i = 0; i < oldTypes->length() && !meshHadNewTypeBefore; ++i ) + meshHadNewTypeBefore = ( oldTypes[i] >= newType ); + + SMESH::SMESH_MeshEditor_var aMeshEditor = mesh->GetMeshEditor(); + SMESH::SMESH_MeshEditor::Extrusion_Error retVal; + + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathObjects( nodes, edges, faces, myPath, + GEOM::GEOM_Object::_nil(), + aNodeStart, AnglesGrp->isChecked(), + anAngles, LinearAnglesCheck->isChecked(), + BasePointGrp->isChecked(), aBasePoint, makeGroups, + aScales, LinearScalesCheck->isChecked(), retVal ); + + wc.suspend(); + switch (retVal) { case SMESH::SMESH_MeshEditor::EXTR_NO_ELEMENTS: - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_ERROR" ), - tr( "NO_ELEMENTS_SELECTED" ), - tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warning(this, + tr("SMESH_ERROR"), + tr("NO_ELEMENTS_SELECTED")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_PATH_NOT_EDGE: - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_ERROR" ), - tr( "SELECTED_PATH_IS_NOT_EDGE" ), - tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warning(this, + tr("SMESH_ERROR"), + tr("SELECTED_PATH_IS_NOT_EDGE")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE: - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_ERROR" ), - tr( "BAD_SHAPE_TYPE" ), - tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warning(this, + tr("SMESH_ERROR"), + tr("BAD_SHAPE_TYPE")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE: - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_ERROR" ), - tr( "EXTR_BAD_STARTING_NODE" ), - tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warning(this, + tr("SMESH_ERROR"), + tr("EXTR_BAD_STARTING_NODE")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_BAD_ANGLES_NUMBER: - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_ERROR" ), - tr( "WRONG_ANGLES_NUMBER" ), - tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warning(this, + tr("SMESH_ERROR"), + tr("WRONG_ANGLES_NUMBER")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_CANT_GET_TANGENT: - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_ERROR" ), - tr( "CANT_GET_TANGENT" ), - tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warning(this, + tr("SMESH_ERROR"), + tr("CANT_GET_TANGENT")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_OK: break; } - } - catch( ... ) { + } catch (...) { return false; } - - mySelection->ClearIObjects(); - SMESH::UpdateView(); - Init( false ); - TypeChanged( GetConstructorId() ); + + SMESH_Actor* actor = SelectorWdg->GetActor(); + if ( actor && !meshHadNewTypeBefore ) + { + unsigned int aMode = actor->GetEntityMode(); + switch ( maxSelType ) { + case SMESH::NODE: // extrude node -> edges + actor->SetRepresentation(SMESH_Actor::eEdge); + actor->SetEntityMode( aMode |= SMESH_Actor::eEdges ); break; + case SMESH::EDGE: // edge -> faces + actor->SetRepresentation(SMESH_Actor::eSurface); + actor->SetEntityMode( aMode |= SMESH_Actor::eFaces ); break; + case SMESH::FACE: // faces -> volumes + actor->SetRepresentation(SMESH_Actor::eSurface); + actor->SetEntityMode( aMode |= SMESH_Actor::eVolumes ); break; + } + } + if ( actor ) + SMESH::Update( actor->getIO(), actor->GetVisibility() ); + if ( makeGroups ) + mySMESHGUI->updateObjBrowser(true); // new groups may appear + Init(false); + mySelectionMgr->clearSelected(); + SelectorWdg->Clear(); + + SMESHGUI::Modified(); return true; } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk() +// function : ClickOnOk() // purpose : Called when user presses button //================================================================================= void SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk"); - if ( !ClickOnApply() ) - return; - reject(); + if (ClickOnApply()) + reject(); +} + +//================================================================================= +// function : ClickOnHelp() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionAlongPathDlg::ClickOnHelp() +{ + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) + app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warning(this, tr("WRN_WARNING"), + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", + platform)). + arg(myHelpFileName)); + } +} + +//================================================================================= +// function : reject() +// purpose : Called when dialog box is closed +//================================================================================= +void SMESHGUI_ExtrusionAlongPathDlg::reject() +{ + 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(); +} + +//================================================================================= +// function : onOpenView() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionAlongPathDlg::onOpenView() +{ + if ( mySelector ) { + SMESH::SetPointRepresentation(false); + } + else { + mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector(); + ActivateThisDialog(); + } +} + +//================================================================================= +// function : onCloseView() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionAlongPathDlg::onCloseView() +{ + DeactivateActiveDialog(); + mySelector = 0; } //======================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::onTextChange -// purpose : +// function : onTextChange() +// purpose : //======================================================================= - -void SMESHGUI_ExtrusionAlongPathDlg::onTextChange(const QString& theNewText) +void SMESHGUI_ExtrusionAlongPathDlg::onTextChange (const QString& theNewText) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onTextChange"); QLineEdit* send = (QLineEdit*)sender(); - if ( send != StartPointLineEdit && send != ElementsLineEdit ) - send = ElementsLineEdit; // return if busy - if ( myBusy ) - return; + if (myBusy) return; // set busy flag - SetBusy sb( this ); - - if ( send == ElementsLineEdit && myEditCurrentArgument == ElementsLineEdit ) { - // hilight entered elements - SMDS_Mesh* aMesh = 0; - if ( myMeshActor ) - aMesh = myMeshActor->GetObject()->GetMesh(); - if ( aMesh ) { - mySelection->ClearIObjects(); - mySelection->AddIObject( myMeshActor->getIO() ); - - QStringList aListId = QStringList::split( " ", theNewText, false ); - bool bOk; - for ( int i = 0; i < aListId.count(); i++ ) { - long ind = aListId[ i ].toLong( &bOk ); - if ( bOk ) { - const SMDS_MeshElement* e = aMesh->FindElement( ind ); - if ( e ) { - // check also type of element - bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || - Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face; - if ( typeMatch ) { - if ( !mySelection->IsIndexSelected( myMeshActor->getIO(), e->GetID() ) ) - mySelection->AddOrRemoveIndex( myMeshActor->getIO(), e->GetID(), true ); - } - } - } - } - } - } - else if ( send == StartPointLineEdit && myEditCurrentArgument == StartPointLineEdit ) { - if ( !myPathMesh->_is_nil() ) { - SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh ); - SMDS_Mesh* aMesh = 0; - if ( aPathActor ) - aMesh = aPathActor->GetObject()->GetMesh(); - if ( aMesh ) { - mySelection->ClearIObjects(); - mySelection->AddIObject( aPathActor->getIO() ); - - bool bOk; - long ind = theNewText.toLong( &bOk ); - if ( bOk ) { - const SMDS_MeshNode* n = aMesh->FindNode( ind ); - if ( n ) { - if ( !mySelection->IsIndexSelected( aPathActor->getIO(), n->GetID() ) ) { - mySelection->AddOrRemoveIndex( aPathActor->getIO(), n->GetID(), true ); - } - } - } + SetBusy sb (this); + + if (send == StartPointLineEdit && + myEditCurrentArgument == StartPointLineEdit) + { + if (!myPath->_is_nil()) { + SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath); + SMDS_Mesh* aMesh = aPathActor ? aPathActor->GetObject()->GetMesh() : 0; + if (aMesh) { + SALOME_ListIO aList; + aList.Append(aPathActor->getIO()); + mySelectionMgr->setSelectedObjects(aList, false); + + bool bOk; + long ind = theNewText.toLong(&bOk); + if (bOk) { + const SMDS_MeshNode* n = aMesh->FindNode(ind); + if (n) { + TColStd_MapOfInteger newIndices; + newIndices.Add(n->GetID()); + mySelector->AddOrRemoveIndex( aPathActor->getIO(), newIndices, false ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight( aPathActor->getIO(), true, true ); + } + } } } } + CheckIsEnable(); + onDisplaySimulation(true); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument() +// function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument"); - // return if busy - if ( myBusy ) - return; - + if (myBusy) return; + // return if dialog box is inactive - if ( !ButtonsGrp->isEnabled() ) + if (!GroupButtons->isEnabled()) return; // selected objects count - int nbSel = mySelection->IObjectCount(); + const SALOME_ListIO& aList = mySelector->StoredIObjects(); + int nbSel = aList.Extent(); + if (nbSel != 1) + return; // set busy flag - SetBusy sb( this ); - - if ( myEditCurrentArgument == ElementsLineEdit ) { - // we are now selecting mesh elements (or whole mesh/submesh/group) - // reset - ElementsLineEdit->clear(); - myMesh = SMESH::SMESH_Mesh::_nil(); - myIDSource = SMESH::SMESH_IDSource::_nil(); - myMeshActor = 0; - - // only one object is acceptable - if( nbSel != 1 ) - return; - - // try to get mesh from selection - Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject(); - myMesh = SMESH::GetMeshByIO( IO ); - if( myMesh->_is_nil() ) - return; - // find actor - myMeshActor = SMESH::FindActorByObject( myMesh ); - if ( !myMeshActor ) - return; + SetBusy sb (this); - if ( MeshCheck->isChecked() ) { - // If "Select whole mesh, submesh or group" check box is on -> - // get ID source and put it's name to the edit box - QString aString; - SMESH::GetNameOfSelectedIObjects( mySelection, aString ); + const bool isPathDef = ( SelectPathMeshButton->isChecked() || + SelectStartPointButton->isChecked() ); - myIDSource = SMESH::IObjectToInterface( IO ); - ElementsLineEdit->setText( aString ); - } - else { - // If "Select whole mesh, submesh or group" check box is off -> - // try to get selected elements IDs - QString aString; - int aNbUnits = SMESH::GetNameOfSelectedElements( mySelection, aString ); - ElementsLineEdit->setText( aString ); - } - } - else if ( myEditCurrentArgument == PathMeshLineEdit ) { + if (myEditCurrentArgument == PathMeshLineEdit && isPathDef) + { // we are now selecting path mesh // reset PathMeshLineEdit->clear(); - myPathMesh = SMESH::SMESH_Mesh::_nil(); - PathShapeLineEdit->clear(); - myPathShape = GEOM::GEOM_Object::_nil(); + myPath = SMESH::SMESH_IDSource::_nil(); StartPointLineEdit->clear(); - // only one object is acceptable - if( nbSel != 1 ) - return; - // try to get mesh from selection - Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject(); - myPathMesh = SMESH::IObjectToInterface( IO ); - if( myPathMesh->_is_nil() ) + Handle(SALOME_InteractiveObject) IO = aList.First(); + myPath = SMESH::IObjectToInterface(IO); + if( myPath->_is_nil() ) return; QString aString; - SMESH::GetNameOfSelectedIObjects( mySelection, aString ); - PathMeshLineEdit->setText( aString ); + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); + PathMeshLineEdit->setText(aString); } - else if ( myEditCurrentArgument == PathShapeLineEdit ) { - // we are now selecting path mesh - // reset - PathShapeLineEdit->clear(); - myPathShape = GEOM::GEOM_Object::_nil(); - StartPointLineEdit->clear(); - - // return if path mesh is not yet selected - if ( myPathMesh->_is_nil() ) - return; - - // only one object is acceptable - if( nbSel != 1 ) - return; - - // try to get shape from selection - Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject(); - myPathShape = SMESH::IObjectToInterface( IO ); - if ( myPathShape->_is_nil() ) - return; - - QString aString; - SMESH::GetNameOfSelectedIObjects( mySelection, aString ); - PathShapeLineEdit->setText( aString ); - } - else if ( myEditCurrentArgument == StartPointLineEdit ) { + else if (myEditCurrentArgument == StartPointLineEdit && isPathDef ) + { // we are now selecting start point of path // reset StartPointLineEdit->clear(); // return if path mesh or path shape is not yet selected - if ( myPathMesh->_is_nil() || myPathShape->_is_nil() ) + if( myPath->_is_nil() ) return; - // only one object is acceptable - if( nbSel != 1 ) + // try to get shape from selection + Handle(SALOME_InteractiveObject) IO = aList.First(); + + SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath); + if ( !aPathActor ) return; - // try to get shape from selection - Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject(); - QString aString; - int aNbUnits = SMESH::GetNameOfSelectedElements( mySelection, aString ); - if ( aNbUnits == 1 ) - StartPointLineEdit->setText( aString.stripWhiteSpace() ); + int aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aPathActor->getIO(), aString); + if (aNbUnits == 1) + StartPointLineEdit->setText(aString.trimmed()); } - else if ( myEditCurrentArgument == XSpin ) { + else if ( myEditCurrentArgument == XSpin && + SelectBasePointButton->isChecked() ) + { // we are now selecting base point // reset is not performed here! // return if is not enabled - if ( !BasePointGrp->isEnabled() ) + if (!BasePointGrp->isChecked()) return; - // only one object is acceptable - if( nbSel != 1 ) - return; - // try to get shape from selection - Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject(); - + Handle(SALOME_InteractiveObject) IO = aList.First(); + // check if geom vertex is selected - GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface( IO ); + GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface(IO); TopoDS_Vertex aVertex; - if( !aGeomObj->_is_nil() ) { - if( aGeomObj->IsShape() && GEOMBase::GetShape( aGeomObj, aVertex ) && !aVertex.IsNull() ) { - gp_Pnt aPnt = BRep_Tool::Pnt( aVertex ); - XSpin->SetValue( aPnt.X() ); - YSpin->SetValue( aPnt.Y() ); - ZSpin->SetValue( aPnt.Z() ); + if (!aGeomObj->_is_nil()) { + if (aGeomObj->IsShape() && GEOMBase::GetShape(aGeomObj, aVertex) && !aVertex.IsNull()) { + gp_Pnt aPnt = BRep_Tool::Pnt(aVertex); + XSpin->SetValue(aPnt.X()); + YSpin->SetValue(aPnt.Y()); + ZSpin->SetValue(aPnt.Z()); } return; } // check if smesh node is selected - SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO ); - if( aMesh->_is_nil() ) + SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(IO); + if (aMesh->_is_nil()) return; QString aString; - int aNbUnits = SMESH::GetNameOfSelectedNodes( mySelection, aString ); + int aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString); // return if more than one node is selected - if( aNbUnits != 1 ) + if (aNbUnits != 1) return; - - SMESH_Actor* aMeshActor = SMESH::FindActorByObject( aMesh ); - if ( !aMeshActor ) + + SMESH_Actor* aMeshActor = SMESH::FindActorByObject(aMesh); + if (!aMeshActor) return; SMDS_Mesh* mesh = aMeshActor->GetObject()->GetMesh(); if (!mesh) return; - const SMDS_MeshNode* n = mesh->FindNode( aString.toLong() ); - if ( !n ) + const SMDS_MeshNode* n = mesh->FindNode(aString.toLong()); + if (!n) return; - XSpin->SetValue( n->X() ); - YSpin->SetValue( n->Y() ); - ZSpin->SetValue( n->Z() ); + XSpin->SetValue(n->X()); + YSpin->SetValue(n->Y()); + ZSpin->SetValue(n->Z()); } + else + { + return; + } + + onDisplaySimulation(true); + CheckIsEnable(); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument() +// function : SetEditCurrentArgument() // purpose : //================================================================================= void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument"); - QToolButton* send = (QToolButton*)sender(); - if ( send != SelectElementsButton && - send != SelectPathMeshButton && - send != SelectPathShapeButton && - send != SelectStartPointButton && - send != SelectBasePointButton ) + QPushButton* send = (QPushButton*)sender(); + if ( sender() == BasePointGrp ) + send = SelectBasePointButton; + if (send != SelectPathMeshButton && + send != SelectStartPointButton && + send != SelectBasePointButton) return; - SetEditCurrentArgument( send ); + SetEditCurrentArgument(send); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument() +// function : SetEditCurrentArgument() // purpose : //================================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument( QToolButton* button ) +void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QPushButton* button) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument(button)"); - disconnect( mySelection, 0, this, 0 ); - mySelection->ClearIObjects(); - mySelection->ClearFilters(); + disconnect(mySelectionMgr, 0, this, 0); + // mySelectionMgr->clearSelected(); + mySelectionMgr->clearFilters(); SMESH::SetPickable(); - - if( button == SelectElementsButton ) { - myEditCurrentArgument = ElementsLineEdit; - SMESH::SetPointRepresentation( false ); - if ( MeshCheck->isChecked() ) { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter( myElementsFilter ); - } - else { - if ( Elements1dRB->isChecked() ) - QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); - else if ( Elements2dRB->isChecked() ) - QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); - } - } - else if ( button == SelectPathMeshButton ) { + + myEditCurrentArgument = 0; + if (button == SelectPathMeshButton) + { myEditCurrentArgument = PathMeshLineEdit; - SMESH::SetPointRepresentation( false ); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySelection->AddFilter( myPathMeshFilter ); - } - else if ( button == SelectPathShapeButton ) { - myEditCurrentArgument = PathShapeLineEdit; - SMESH::SetPointRepresentation( false ); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - - if ( !myPathMesh->_is_nil() ) { - GEOM::GEOM_Object_var aMainShape = myPathMesh->GetShapeToMesh(); - SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh ); - - if ( !aMainShape->_is_nil() && aPathActor ) - mySelection->AddFilter( new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, -1, TopAbs_EDGE, aMainShape ) ); - //SMESH::SetPickable( aPathActor ); - } + SMESH::SetPointRepresentation(false); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myPathMeshFilter); } - else if ( button == SelectStartPointButton ) { + else if (button == SelectStartPointButton) + { myEditCurrentArgument = StartPointLineEdit; - if ( !myPathMesh->_is_nil() ) { - SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh ); - if ( aPathActor ) { - SMESH::SetPointRepresentation( true ); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - SMESH::SetPickable( aPathActor ); + if (!myPath->_is_nil()) { + SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath); + if (aPathActor) { + aPathActor->SetPointRepresentation( true ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(NodeSelection); + SMESH::SetPickable(aPathActor); } } } - else if ( button == SelectBasePointButton ) { + else if (button == SelectBasePointButton) + { myEditCurrentArgument = XSpin; - SMESH::SetPointRepresentation( true ); - QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); - - SMESH_ListOfFilter aListOfFilters; - Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - if ( !aMeshOrSubMeshFilter.IsNull() ) - aListOfFilters.Append( aMeshOrSubMeshFilter ); - Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); - if ( !aSmeshGroupFilter.IsNull() ) - aListOfFilters.Append( aSmeshGroupFilter ); - //Handle(GEOM_ShapeTypeFilter) aVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX ); - Handle(SMESH_NumberFilter) aVertexFilter = new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, -1, TopAbs_VERTEX, GEOM::GEOM_Object::_nil() ); - if ( !aVertexFilter.IsNull() ) - aListOfFilters.Append( aVertexFilter ); - - mySelection->AddFilter( new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ) ); + SMESH::SetPointRepresentation(true); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(NodeSelection); + + SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter(SMESH::IDSOURCE); + SMESH_NumberFilter* aVertexFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, + -1, TopAbs_VERTEX); + QList aListOfFilters; + if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter); + if (aVertexFilter) aListOfFilters.append(aVertexFilter); + + mySelectionMgr->installFilter(new SMESH_LogicalFilter + (aListOfFilters, SMESH_LogicalFilter::LO_OR, true)); } - if ( myEditCurrentArgument && !myEditCurrentArgument->hasFocus() ) + if (myEditCurrentArgument && !myEditCurrentArgument->hasFocus()) myEditCurrentArgument->setFocus(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); SelectionIntoArgument(); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog() +// function : DeactivateActiveDialog() // purpose : Deactivates this dialog //================================================================================= void SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog"); - if ( ElementsTypeGrp->isEnabled() ) { - ElementsTypeGrp->setEnabled( false ); - ArgumentsGrp->setEnabled( false ); - ButtonsGrp->setEnabled( false ); - mySMESHGUI->ResetState(); - mySMESHGUI->SetActiveDialogBox( 0 ); + if (GroupButtons->isEnabled()) + { + GroupArguments->setEnabled(false); + GroupButtons->setEnabled(false); + SelectorWdg->setEnabled(false); + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog() +// function : ActivateThisDialog() // purpose : Activates this dialog //================================================================================= void SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog"); // Emit a signal to deactivate the active dialog - mySMESHGUI->EmitSignalDeactivateDialog(); - ElementsTypeGrp->setEnabled( true ); - ArgumentsGrp->setEnabled( true ); - ButtonsGrp->setEnabled( true ); - - mySMESHGUI->SetActiveDialogBox( this ); + mySMESHGUI->EmitSignalDeactivateDialog(); + GroupArguments->setEnabled(true); + GroupButtons->setEnabled(true); + SelectorWdg->setEnabled(true); - TypeChanged( GetConstructorId() ); + mySMESHGUI->SetActiveDialogBox(this); SelectionIntoArgument(); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::enterEvent() -// purpose : Mouse enter event +// function : enterEvent() +// purpose : //================================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::enterEvent(QEvent* e) +void SMESHGUI_ExtrusionAlongPathDlg::enterEvent (QEvent*) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::enterEvent"); - if ( ElementsTypeGrp->isEnabled() ) - return; - ActivateThisDialog(); + if ( !GroupButtons->isEnabled() ) { + SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ); + if ( aViewWindow && !mySelector) { + mySelector = aViewWindow->GetSelector(); + } + ActivateThisDialog(); + } +} + +//======================================================================= +// function : OnAngleAdded() +// purpose : Called when user adds angle to the list +//======================================================================= +void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded() +{ + if ( sender() == AddAngleButton ) + { + QString msg; + if( !AngleSpin->isValid( msg, true ) ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return; + } + AnglesList->addItem(AngleSpin->text()); + myAnglesList.append(AngleSpin->GetValue()); + } + + if ( sender() == AddScaleButton ) + { + QString msg; + if( !ScaleSpin->isValid( msg, true ) ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return; + } + ScalesList->addItem(ScaleSpin->text()); + myScalesList.append(ScaleSpin->GetValue()); + } + + updateLinearAngles(); +} + +//======================================================================= +// function : OnAngleRemoved() +// purpose : Called when user removes angle(s) from the list +//======================================================================= +void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved() +{ + QListWidget* widget; + QList* list; + if ( sender() == RemoveScaleButton ) + { + widget = ScalesList; + list = & myScalesList; + } + else + { + widget = AnglesList; + list = & myAnglesList; + } + + QList aList = widget->selectedItems(); + QListWidgetItem* anItem; + foreach(anItem, aList) { + list->removeAt( widget->row( anItem )); + delete anItem; + } + + updateLinearAngles(); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::reject() -// purpose : Called when dialog box is closed +// function : eventFilter() +// purpose : event filter ??? //================================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::reject() +bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter (QObject* object, QEvent* event) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::reject"); - disconnect( mySelection, 0, this, 0 ); - mySelection->ClearFilters(); - mySelection->ClearIObjects(); - SMESH::SetPickable(); - SMESH::SetPointRepresentation( false ); - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - mySMESHGUI->ResetState() ; - QDialog::reject(); + if (event->type() == QEvent::KeyPress) { + QKeyEvent* ke = (QKeyEvent*)event; + if (object == AnglesList) { + if (ke->key() == Qt::Key_Delete) + RemoveAngleButton->click(); + } + if (object == ScalesList) { + if (ke->key() == Qt::Key_Delete) + RemoveScaleButton->click(); + } + } + else if (event->type() == QEvent::FocusIn) { + if (object == StartPointLineEdit) { + if (myEditCurrentArgument != StartPointLineEdit) + SetEditCurrentArgument(SelectStartPointButton); + } + else if (object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor()) { + if (myEditCurrentArgument != XSpin) + SetEditCurrentArgument(SelectBasePointButton); + } + } + return QDialog::eventFilter(object, event); } //================================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId() -// purpose : +// function : keyPressEvent() +// purpose : //================================================================================= -int SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId() -{ - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId"); - if ( ElementsTypeGrp != NULL && ElementsTypeGrp->selected() != NULL ) - return ElementsTypeGrp->id( ElementsTypeGrp->selected() ); - return -1; +void SMESHGUI_ExtrusionAlongPathDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Qt::Key_F1 ) { + e->accept(); + ClickOnHelp(); + } } -//======================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh +//================================================================================= +// function : isValid // purpose : -//======================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh() +//================================================================================= +bool SMESHGUI_ExtrusionAlongPathDlg::isValid() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh"); - bool toSelectMesh = MeshCheck->isChecked(); - - ElementsLineEdit->setReadOnly( toSelectMesh ); - ElementsLab->setText( toSelectMesh ? tr( "SMESH_NAME" ) : tr( "SMESH_ID_ELEMENTS" ) ); - ElementsLineEdit->clear(); - - SetEditCurrentArgument( SelectElementsButton ); + QString msg; + bool ok = true; + ok = XSpin->isValid( msg, true ) && ok; + ok = YSpin->isValid( msg, true ) && ok; + ok = ZSpin->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; } -//======================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck -// purpose : called when "Use Angles" check box is switched -//======================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck() +//================================================================================= +// function : updateLinearAngles +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionAlongPathDlg::updateLinearAngles() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck"); - AnglesGrp->setEnabled( AnglesCheck->isChecked() ); + bool enableLinear = true; + for( int row = 0, nbRows = AnglesList->count(); row < nbRows; row++ ) { + if( QListWidgetItem* anItem = AnglesList->item( row ) ) { + enableLinear = false; + anItem->text().toDouble(&enableLinear); + if( !enableLinear ) + break; + } + } + if( !enableLinear ) + LinearAnglesCheck->setChecked( false ); + LinearAnglesCheck->setEnabled( enableLinear ); + + enableLinear = true; + for( int row = 0, nbRows = ScalesList->count(); row < nbRows; row++ ) { + if( QListWidgetItem* anItem = ScalesList->item( row ) ) { + enableLinear = false; + anItem->text().toDouble(&enableLinear); + if( !enableLinear ) + break; + } + } + if( !enableLinear ) + LinearScalesCheck->setChecked( false ); + LinearScalesCheck->setEnabled( enableLinear ); } -//======================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck -// purpose : called when "Use Base Point" check box is switched -//======================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck() +//================================================================================= +// function : isValuesValid() +// purpose : Return true in case if values entered into dialog are valid +//================================================================================= + +bool SMESHGUI_ExtrusionAlongPathDlg::isValuesValid() +{ + if ( myPath->_is_nil() ) + return false; + + bool bOk; + long aNodeStart = StartPointLineEdit->text().toLong(&bOk); + if ( !bOk || aNodeStart < 1 ) + return false; + + SMESH::SMESH_Mesh_var mesh = myPath->GetMesh(); + if ( mesh->_is_nil() ) + return false; + + SMESH::ElementType type = mesh->GetElementType( aNodeStart, false ); + if ( type != SMESH::NODE ) + return false; + + if ( mesh->HasShapeToMesh() ) + { + SMESH::NodePosition_var pos = mesh->GetNodePosition( aNodeStart ); + if ( pos->shapeType != GEOM::VERTEX ) + return false; + } + else + { + SMESH::long_array_var elems = mesh->GetNodeInverseElements( aNodeStart, SMESH::ALL ); + if ( elems->length() != 1 || + mesh->GetElementType( elems[0], true ) != SMESH::EDGE ) + return false; + } + return true; +} + +//================================================================================= +// function : onDisplaySimulation +// purpose : Show/Hide preview +//================================================================================= + +void SMESHGUI_ExtrusionAlongPathDlg::onDisplaySimulation( bool toDisplayPreview ) { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck"); - BasePointGrp->setEnabled( BasePointCheck->isChecked() ); + if ( myPreviewCheckBox->isChecked() && toDisplayPreview ) { + if ( SelectorWdg->IsAnythingSelected() && isValid() && isValuesValid()) + { + // get angles and scales + SMESH::double_array_var anAngles = getAngles(); + SMESH::double_array_var aScales = getScales(); + + // get base point + SMESH::PointStruct aBasePoint; + if (BasePointGrp->isChecked()) { + aBasePoint.x = XSpin->GetValue(); + aBasePoint.y = YSpin->GetValue(); + aBasePoint.z = ZSpin->GetValue(); + } + bool bOk; + long aNodeStart = StartPointLineEdit->text().toLong(&bOk); + if (bOk) { + + try { + SUIT_OverrideCursor wc; + + SMESH::SMESH_MeshEditor::Extrusion_Error retVal; + SMESH::SMESH_Mesh_var mesh = SelectorWdg->GetMesh(); + SMESH::SMESH_MeshEditor_var meshEditor = mesh->GetMeshEditPreviewer(); + + SMESH::ListOfIDSources_var nodes = new SMESH::ListOfIDSources(); + SMESH::ListOfIDSources_var edges = new SMESH::ListOfIDSources(); + SMESH::ListOfIDSources_var faces = new SMESH::ListOfIDSources(); + SelectorWdg->GetSelected( nodes, edges, faces ); + const bool makeGroups = false; + + SMESH::ListOfGroups_var groups = + meshEditor->ExtrusionAlongPathObjects( nodes, edges, faces, myPath, + GEOM::GEOM_Object::_nil(), + aNodeStart, AnglesGrp->isChecked(), + anAngles, LinearAnglesCheck->isChecked(), + BasePointGrp->isChecked(), aBasePoint, + makeGroups, + aScales, LinearScalesCheck->isChecked(), + retVal); + + if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK ) + { + SMESH::MeshPreviewStruct_var aMeshPreviewStruct = meshEditor->GetPreviewData(); + mySimulation->SetData( aMeshPreviewStruct.in() ); + } + else { + hidePreview(); + } + + } catch (...) { + hidePreview(); + } + } else { + hidePreview(); + } + + } else { + hidePreview(); + } + } else { + hidePreview(); + } } //======================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded -// purpose : Called when user adds angle to the list +//function : getAngles +//purpose : return CORBA array of angles //======================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded() + +SMESH::double_array_var SMESHGUI_ExtrusionAlongPathDlg::getAngles() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded"); - AnglesList->insertItem( QString::number( AngleSpin->GetValue() ) ); + SMESH::double_array_var anAngles = new SMESH::double_array; + if ( AnglesGrp->isChecked() ) + { + anAngles->length( myAnglesList.count() ); + for (int i = 0; i < myAnglesList.count(); i++) + anAngles[ i ] = myAnglesList[ i ] * M_PI / 180.; + } + return anAngles; } //======================================================================= -// function : SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved -// purpose : Called when user removes angle(s) from the list +//function : getScales +//purpose : return CORBA array of scale factors //======================================================================= -void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved() + +SMESH::double_array_var SMESHGUI_ExtrusionAlongPathDlg::getScales() { - MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved"); - QList aList; - aList.setAutoDelete( false ); - for ( int i = 0; i < AnglesList->count(); i++ ) - if ( AnglesList->isSelected( i ) ) - aList.append( AnglesList->item( i ) ); - - for ( int i = 0; i < aList.count(); i++ ) - delete aList.at( i ); + SMESH::double_array_var anScales = new SMESH::double_array; + if ( ScalesGrp->isChecked() ) + { + anScales->length( myScalesList.count() ); + for (int i = 0; i < myScalesList.count(); i++) + anScales[ i ] = myScalesList[ i ]; + } + return anScales; } -