2009-02-17 10:27:49 +05:00
|
|
|
// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
2009-02-17 10:27:49 +05:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
2005-06-07 19:22:20 +06:00
|
|
|
// 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
|
|
|
|
//
|
2009-02-17 10:27:49 +05:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
2009-02-17 10:27:49 +05:00
|
|
|
// File : SMESHGUI_MultiEditDlg.cxx
|
|
|
|
// Author : Sergey LITONIN, Open CASCADE S.A.S.
|
|
|
|
// SMESH includes
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
|
|
|
#include "SMESHGUI_MultiEditDlg.h"
|
|
|
|
|
|
|
|
#include "SMESHGUI.h"
|
2005-08-11 14:06:39 +06:00
|
|
|
#include "SMESHGUI_Filter.h"
|
|
|
|
#include "SMESHGUI_FilterDlg.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SMESHGUI_Utils.h"
|
|
|
|
#include "SMESHGUI_VTKUtils.h"
|
|
|
|
#include "SMESHGUI_MeshUtils.h"
|
2005-08-11 14:06:39 +06:00
|
|
|
#include "SMESHGUI_FilterUtils.h"
|
|
|
|
#include "SMESHGUI_SpinBox.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#include <SMESH_Actor.h>
|
|
|
|
#include <SMESH_TypeFilter.hxx>
|
|
|
|
#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_Session.h>
|
|
|
|
#include <SUIT_MessageBox.h>
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#include <LightApp_SelectionMgr.h>
|
|
|
|
#include <LightApp_Application.h>
|
|
|
|
#include <SALOME_ListIO.hxx>
|
|
|
|
#include <SALOME_ListIteratorOfListIO.hxx>
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#include <SVTK_Selector.h>
|
|
|
|
#include <SVTK_ViewWindow.h>
|
|
|
|
#include <VTKViewer_CellLocationsArray.h>
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// OCCT includes
|
2005-06-07 19:22:20 +06:00
|
|
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
|
|
|
#include <TColStd_DataMapOfIntegerInteger.hxx>
|
|
|
|
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// VTK includes
|
2004-12-01 15:48:31 +05:00
|
|
|
#include <vtkIdList.h>
|
|
|
|
#include <vtkCellArray.h>
|
|
|
|
#include <vtkUnsignedCharArray.h>
|
|
|
|
#include <vtkUnstructuredGrid.h>
|
|
|
|
#include <vtkDataSetMapper.h>
|
2006-02-07 20:01:11 +05:00
|
|
|
#include <vtkProperty.h>
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// Qt includes
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QButtonGroup>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
|
|
|
|
// IDL includes
|
|
|
|
#include <SALOMEconfig.h>
|
2005-01-20 11:25:54 +05:00
|
|
|
#include CORBA_SERVER_HEADER(SMESH_Group)
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#define SPACING 6
|
|
|
|
#define MARGIN 11
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
/*!
|
|
|
|
* Class : SMESHGUI_MultiEditDlg
|
|
|
|
* Description : Description : Inversion of the diagonal of a pseudo-quadrangle formed by
|
|
|
|
* 2 neighboring triangles with 1 common edge
|
|
|
|
*/
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg
|
|
|
|
// Purpose : Constructor
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESHGUI_MultiEditDlg
|
|
|
|
::SMESHGUI_MultiEditDlg(SMESHGUI* theModule,
|
|
|
|
const int theMode,
|
2009-02-17 10:27:49 +05:00
|
|
|
const bool the3d2d):
|
|
|
|
QDialog(SMESH::GetDesktop(theModule)),
|
|
|
|
mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
|
|
|
|
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
|
|
|
|
mySMESHGUI(theModule)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
setModal(false);
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
myFilterDlg = 0;
|
2005-01-25 20:51:15 +05:00
|
|
|
myEntityType = 0;
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
myFilterType = theMode;
|
2009-02-17 10:27:49 +05:00
|
|
|
QVBoxLayout* aDlgLay = new QVBoxLayout(this);
|
|
|
|
aDlgLay->setMargin(MARGIN);
|
|
|
|
aDlgLay->setSpacing(SPACING);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QWidget* aMainFrame = createMainFrame (this, the3d2d);
|
|
|
|
QWidget* aBtnFrame = createButtonFrame(this);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aDlgLay->addWidget(aMainFrame);
|
|
|
|
aDlgLay->addWidget(aBtnFrame);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
Init();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::createMainFrame
|
|
|
|
// Purpose : Create frame containing dialog's input fields
|
|
|
|
//=======================================================================
|
2009-02-17 10:27:49 +05:00
|
|
|
QWidget* SMESHGUI_MultiEditDlg::createMainFrame (QWidget* theParent, const bool the3d2d)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
QWidget* aMainGrp = new QWidget(theParent);
|
|
|
|
QVBoxLayout* aMainGrpLayout = new QVBoxLayout(aMainGrp);
|
|
|
|
aMainGrpLayout->setMargin(0);
|
|
|
|
aMainGrpLayout->setSpacing(SPACING);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2005-06-08 16:45:19 +06:00
|
|
|
QPixmap aPix (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// "Selected cells" group
|
2009-02-17 10:27:49 +05:00
|
|
|
mySelGrp = new QGroupBox(aMainGrp);
|
|
|
|
|
|
|
|
QGridLayout* mySelGrpLayout = new QGridLayout(mySelGrp);
|
|
|
|
mySelGrpLayout->setMargin(MARGIN);
|
|
|
|
mySelGrpLayout->setSpacing(SPACING);
|
2005-01-25 20:51:15 +05:00
|
|
|
|
|
|
|
myEntityTypeGrp = 0;
|
2005-06-07 19:22:20 +06:00
|
|
|
if (the3d2d) {
|
2009-02-17 10:27:49 +05:00
|
|
|
QGroupBox* aEntityTypeGrp = new QGroupBox(tr("SMESH_ELEMENTS_TYPE"), mySelGrp);
|
|
|
|
myEntityTypeGrp = new QButtonGroup(mySelGrp);
|
|
|
|
QHBoxLayout* aEntityLayout = new QHBoxLayout(aEntityTypeGrp);
|
|
|
|
aEntityLayout->setMargin(MARGIN);
|
|
|
|
aEntityLayout->setSpacing(SPACING);
|
2005-01-25 20:51:15 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QRadioButton* aFaceRb = new QRadioButton(tr("SMESH_FACE"), aEntityTypeGrp);
|
|
|
|
QRadioButton* aVolumeRb = new QRadioButton(tr("SMESH_VOLUME"), aEntityTypeGrp);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
aEntityLayout->addWidget(aFaceRb);
|
|
|
|
aEntityLayout->addWidget(aVolumeRb);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
myEntityTypeGrp->addButton(aFaceRb, 0);
|
|
|
|
myEntityTypeGrp->addButton(aVolumeRb, 1);
|
|
|
|
aFaceRb->setChecked(true);
|
|
|
|
myEntityType = myEntityTypeGrp->checkedId();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
mySelGrpLayout->addWidget(aEntityTypeGrp, 0, 0, 1, 2);
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
myListBox = new QListWidget(mySelGrp);
|
|
|
|
myListBox->setSelectionMode(QListWidget::ExtendedSelection);
|
|
|
|
myListBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
|
|
|
myListBox->installEventFilter(this);
|
|
|
|
|
|
|
|
myFilterBtn = new QPushButton(tr("FILTER"), mySelGrp);
|
|
|
|
myAddBtn = new QPushButton(tr("ADD"), mySelGrp);
|
|
|
|
myRemoveBtn = new QPushButton(tr("REMOVE"), mySelGrp);
|
|
|
|
mySortBtn = new QPushButton(tr("SORT_LIST"), mySelGrp);
|
|
|
|
|
|
|
|
int row = mySelGrpLayout->rowCount();
|
|
|
|
mySelGrpLayout->addWidget(myListBox, row, 0, 6, 1);
|
|
|
|
mySelGrpLayout->addWidget(myFilterBtn, row, 1);
|
|
|
|
mySelGrpLayout->addWidget(myAddBtn, row+2, 1);
|
|
|
|
mySelGrpLayout->addWidget(myRemoveBtn, row+3, 1);
|
|
|
|
mySelGrpLayout->addWidget(mySortBtn, row+5, 1);
|
|
|
|
mySelGrpLayout->setRowMinimumHeight(row+1, 10);
|
|
|
|
mySelGrpLayout->setRowMinimumHeight(row+4, 10);
|
|
|
|
mySelGrpLayout->setRowStretch(row+1, 5);
|
|
|
|
mySelGrpLayout->setRowStretch(row+4, 5);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
myToAllChk = new QCheckBox(tr("TO_ALL"), mySelGrp);
|
2009-02-17 10:27:49 +05:00
|
|
|
mySelGrpLayout->addWidget(myToAllChk, mySelGrpLayout->rowCount(), 0,
|
|
|
|
1, mySelGrpLayout->columnCount());
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-08-11 14:06:39 +06:00
|
|
|
// Split/Join criterion group
|
2009-02-17 10:27:49 +05:00
|
|
|
myCriterionGrp = new QGroupBox(tr("SPLIT_JOIN_CRITERION"), aMainGrp);
|
|
|
|
QVBoxLayout* aCriterionLayout = new QVBoxLayout(myCriterionGrp);
|
|
|
|
aCriterionLayout->setMargin(MARGIN);
|
|
|
|
aCriterionLayout->setSpacing(SPACING);
|
|
|
|
|
|
|
|
myChoiceWidget = new QWidget(myCriterionGrp);
|
|
|
|
myGroupChoice = new QButtonGroup(myChoiceWidget);
|
|
|
|
QVBoxLayout* aGroupChoiceLayout = new QVBoxLayout(myChoiceWidget);
|
|
|
|
aGroupChoiceLayout->setMargin(0);
|
|
|
|
aGroupChoiceLayout->setSpacing(SPACING);
|
|
|
|
|
|
|
|
QRadioButton* aDiag13RB = new QRadioButton(tr("USE_DIAGONAL_1_3"), myChoiceWidget);
|
|
|
|
QRadioButton* aDiag24RB = new QRadioButton(tr("USE_DIAGONAL_2_4"), myChoiceWidget);
|
|
|
|
QRadioButton* aNumFuncRB = new QRadioButton(tr("USE_NUMERIC_FUNC"), myChoiceWidget);
|
|
|
|
|
|
|
|
aGroupChoiceLayout->addWidget(aDiag13RB);
|
|
|
|
aGroupChoiceLayout->addWidget(aDiag24RB);
|
|
|
|
aGroupChoiceLayout->addWidget(aNumFuncRB);
|
|
|
|
myGroupChoice->addButton(aDiag13RB, 0);
|
|
|
|
myGroupChoice->addButton(aDiag24RB, 1);
|
|
|
|
myGroupChoice->addButton(aNumFuncRB, 2);
|
|
|
|
aDiag13RB->setChecked(true);
|
2005-08-11 14:06:39 +06:00
|
|
|
|
|
|
|
myComboBoxFunctor = new QComboBox(myCriterionGrp);
|
2009-02-17 10:27:49 +05:00
|
|
|
myComboBoxFunctor->addItem(tr("ASPECTRATIO_ELEMENTS"));
|
|
|
|
myComboBoxFunctor->addItem(tr("MINIMUMANGLE_ELEMENTS"));
|
|
|
|
myComboBoxFunctor->addItem(tr("SKEW_ELEMENTS"));
|
|
|
|
myComboBoxFunctor->addItem(tr("AREA_ELEMENTS"));
|
|
|
|
//myComboBoxFunctor->addItem(tr("LENGTH2D_EDGES")); // for existing elements only
|
|
|
|
//myComboBoxFunctor->addItem(tr("MULTI2D_BORDERS")); // for existing elements only
|
|
|
|
myComboBoxFunctor->setCurrentIndex(0);
|
|
|
|
|
|
|
|
aCriterionLayout->addWidget(myChoiceWidget);
|
|
|
|
aCriterionLayout->addWidget(myComboBoxFunctor);
|
2005-08-11 14:06:39 +06:00
|
|
|
|
|
|
|
myCriterionGrp->hide();
|
2009-02-17 10:27:49 +05:00
|
|
|
myChoiceWidget->hide();
|
2005-08-11 14:06:39 +06:00
|
|
|
myComboBoxFunctor->setEnabled(false);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
// "Select from" group
|
2009-02-17 10:27:49 +05:00
|
|
|
QGroupBox* aGrp = new QGroupBox(tr("SELECT_FROM"), aMainGrp);
|
|
|
|
QGridLayout* aGrpLayout = new QGridLayout(aGrp);
|
|
|
|
aGrpLayout->setMargin(MARGIN);
|
|
|
|
aGrpLayout->setSpacing(SPACING);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
mySubmeshChk = new QCheckBox(tr("SMESH_SUBMESH"), aGrp);
|
|
|
|
mySubmeshBtn = new QPushButton(aGrp);
|
|
|
|
mySubmesh = new QLineEdit(aGrp);
|
|
|
|
mySubmesh->setReadOnly(true);
|
2009-02-17 10:27:49 +05:00
|
|
|
mySubmeshBtn->setIcon(aPix);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2005-08-11 14:06:39 +06:00
|
|
|
myGroupChk = new QCheckBox(tr("SMESH_GROUP"), aGrp);
|
2005-06-07 19:22:20 +06:00
|
|
|
myGroupBtn = new QPushButton(aGrp);
|
|
|
|
myGroup = new QLineEdit(aGrp);
|
|
|
|
myGroup->setReadOnly(true);
|
2009-02-17 10:27:49 +05:00
|
|
|
myGroupBtn->setIcon(aPix);
|
|
|
|
|
|
|
|
aGrpLayout->addWidget(mySubmeshChk,0,0);
|
|
|
|
aGrpLayout->addWidget(mySubmeshBtn,0,1);
|
|
|
|
aGrpLayout->addWidget(mySubmesh,0,2);
|
|
|
|
aGrpLayout->addWidget(myGroupChk,1,0);
|
|
|
|
aGrpLayout->addWidget(myGroupBtn,1,1);
|
|
|
|
aGrpLayout->addWidget(myGroup,1,2);
|
|
|
|
|
|
|
|
aMainGrpLayout->addWidget(mySelGrp);
|
|
|
|
aMainGrpLayout->addWidget(myCriterionGrp);
|
|
|
|
aMainGrpLayout->addWidget(aGrp);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
return aMainGrp;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::createButtonFrame
|
|
|
|
// Purpose : Create frame containing buttons
|
|
|
|
//=======================================================================
|
2009-02-17 10:27:49 +05:00
|
|
|
QWidget* SMESHGUI_MultiEditDlg::createButtonFrame (QWidget* theParent)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
QGroupBox* aFrame = new QGroupBox(theParent);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
myOkBtn = new QPushButton (tr("SMESH_BUT_APPLY_AND_CLOSE"), aFrame);
|
2005-06-07 19:22:20 +06:00
|
|
|
myApplyBtn = new QPushButton (tr("SMESH_BUT_APPLY"), aFrame);
|
|
|
|
myCloseBtn = new QPushButton (tr("SMESH_BUT_CLOSE"), aFrame);
|
2009-02-17 10:27:49 +05:00
|
|
|
myHelpBtn = new QPushButton (tr("SMESH_BUT_HELP"), aFrame);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QHBoxLayout* aLay = new QHBoxLayout (aFrame);
|
|
|
|
aLay->setMargin(MARGIN);
|
|
|
|
aLay->setSpacing(SPACING);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aLay->addWidget(myOkBtn);
|
2009-02-17 10:27:49 +05:00
|
|
|
aLay->addSpacing(10);
|
2005-06-07 19:22:20 +06:00
|
|
|
aLay->addWidget(myApplyBtn);
|
2009-02-17 10:27:49 +05:00
|
|
|
aLay->addSpacing(10);
|
|
|
|
aLay->addStretch();
|
2005-06-07 19:22:20 +06:00
|
|
|
aLay->addWidget(myCloseBtn);
|
2006-05-06 14:51:48 +06:00
|
|
|
aLay->addWidget(myHelpBtn);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
return aFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::isValid
|
|
|
|
// Purpose : Verify validity of input data
|
|
|
|
//=======================================================================
|
2009-02-17 10:27:49 +05:00
|
|
|
bool SMESHGUI_MultiEditDlg::isValid (const bool /*theMess*/)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
return (!myMesh->_is_nil() &&
|
2005-02-03 17:31:13 +05:00
|
|
|
(myListBox->count() > 0 || (myToAllChk->isChecked() && myActor)));
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg
|
|
|
|
// Purpose : Destructor
|
|
|
|
//=======================================================================
|
|
|
|
SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myFilterDlg != 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
myFilterDlg->setParent(0);
|
2004-12-01 15:48:31 +05:00
|
|
|
delete myFilterDlg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-01 19:55:30 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::eventFilter
|
|
|
|
// Purpose : event filter
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_MultiEditDlg::eventFilter (QObject* object, QEvent* event)
|
2005-02-01 19:55:30 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (object == myListBox && event->type() == QEvent::KeyPress) {
|
2005-02-01 19:55:30 +05:00
|
|
|
QKeyEvent* ke = (QKeyEvent*)event;
|
2009-02-17 10:27:49 +05:00
|
|
|
if (ke->key() == Qt::Key_Delete)
|
2005-02-01 19:55:30 +05:00
|
|
|
onRemoveBtn();
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
return QDialog::eventFilter(object, event);
|
2005-02-01 19:55:30 +05:00
|
|
|
}
|
|
|
|
|
2005-08-11 14:06:39 +06:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::getNumericalFunctor
|
|
|
|
// Purpose :
|
|
|
|
//=======================================================================
|
|
|
|
SMESH::NumericalFunctor_ptr SMESHGUI_MultiEditDlg::getNumericalFunctor()
|
|
|
|
{
|
|
|
|
SMESH::NumericalFunctor_var aNF = SMESH::NumericalFunctor::_nil();
|
|
|
|
|
|
|
|
SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
|
|
|
|
if (aFilterMgr->_is_nil())
|
|
|
|
return aNF._retn();
|
|
|
|
|
|
|
|
if (myComboBoxFunctor->currentText() == tr("ASPECTRATIO_ELEMENTS"))
|
|
|
|
aNF = aFilterMgr->CreateAspectRatio();
|
|
|
|
else if (myComboBoxFunctor->currentText() == tr("WARP_ELEMENTS"))
|
|
|
|
aNF = aFilterMgr->CreateWarping();
|
|
|
|
else if (myComboBoxFunctor->currentText() == tr("MINIMUMANGLE_ELEMENTS"))
|
|
|
|
aNF = aFilterMgr->CreateMinimumAngle();
|
|
|
|
else if (myComboBoxFunctor->currentText() == tr("TAPER_ELEMENTS"))
|
|
|
|
aNF = aFilterMgr->CreateTaper();
|
|
|
|
else if (myComboBoxFunctor->currentText() == tr("SKEW_ELEMENTS"))
|
|
|
|
aNF = aFilterMgr->CreateSkew();
|
|
|
|
else if (myComboBoxFunctor->currentText() == tr("AREA_ELEMENTS"))
|
|
|
|
aNF = aFilterMgr->CreateArea();
|
|
|
|
else if (myComboBoxFunctor->currentText() == tr("LENGTH2D_EDGES"))
|
|
|
|
aNF = aFilterMgr->CreateLength2D();
|
|
|
|
else if (myComboBoxFunctor->currentText() == tr("MULTI2D_BORDERS"))
|
|
|
|
aNF = aFilterMgr->CreateMultiConnection2D();
|
2009-02-17 10:27:49 +05:00
|
|
|
else;
|
2005-08-11 14:06:39 +06:00
|
|
|
|
|
|
|
return aNF._retn();
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::Init
|
|
|
|
// Purpose : Init dialog fields, connect signals and slots, show dialog
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_MultiEditDlg::Init()
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
|
2004-12-01 15:48:31 +05:00
|
|
|
myListBox->clear();
|
|
|
|
myIds.Clear();
|
|
|
|
myBusy = false;
|
|
|
|
myActor = 0;
|
|
|
|
emit ListContensChanged();
|
|
|
|
|
|
|
|
// main buttons
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
|
|
|
|
connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
|
|
|
|
connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
|
2006-05-06 14:51:48 +06:00
|
|
|
connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// selection and SMESHGUI
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
|
|
|
|
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
|
|
|
|
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// dialog controls
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(myFilterBtn, SIGNAL(clicked()), SLOT(onFilterBtn() ));
|
2009-02-17 10:27:49 +05:00
|
|
|
connect(myAddBtn, SIGNAL(clicked()), SLOT(onAddBtn() ));
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(myRemoveBtn, SIGNAL(clicked()), SLOT(onRemoveBtn() ));
|
2009-02-17 10:27:49 +05:00
|
|
|
connect(mySortBtn, SIGNAL(clicked()), SLOT(onSortListBtn()));
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(mySubmeshChk, SIGNAL(stateChanged(int)), SLOT(onSubmeshChk()));
|
2009-02-17 10:27:49 +05:00
|
|
|
connect(myGroupChk, SIGNAL(stateChanged(int)), SLOT(onGroupChk() ));
|
|
|
|
connect(myToAllChk, SIGNAL(stateChanged(int)), SLOT(onToAllChk() ));
|
2005-01-25 20:51:15 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myEntityTypeGrp)
|
2009-02-17 10:27:49 +05:00
|
|
|
connect(myEntityTypeGrp, SIGNAL(buttonClicked(int)), SLOT(on3d2dChanged(int)));
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
connect(myListBox, SIGNAL(itemSelectionChanged()), SLOT(onListSelectionChanged()));
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-02-03 17:31:13 +05:00
|
|
|
onSelectionDone();
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// set selection mode
|
|
|
|
setSelectionMode();
|
|
|
|
updateButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onOk
|
2005-06-07 19:22:20 +06:00
|
|
|
// Purpose : SLOT called when "Ok" button pressed.
|
2004-12-01 15:48:31 +05:00
|
|
|
// Assign filters VTK viewer and close dialog
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onOk()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (onApply())
|
2004-12-01 15:48:31 +05:00
|
|
|
onClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::getIds
|
|
|
|
// Purpose : Retrive identifiers from list box
|
|
|
|
//=======================================================================
|
|
|
|
SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds()
|
|
|
|
{
|
|
|
|
SMESH::long_array_var anIds = new SMESH::long_array;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
if (myToAllChk->isChecked())
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
myIds.Clear();
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH_Actor * anActor = SMESH::FindActorByObject(myMesh);
|
|
|
|
if (!anActor)
|
2005-02-03 17:31:13 +05:00
|
|
|
anActor = myActor;
|
2005-06-07 19:22:20 +06:00
|
|
|
if (anActor != 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2006-03-13 20:29:49 +05:00
|
|
|
// skl 07.02.2006
|
|
|
|
SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
|
2009-02-17 10:27:49 +05:00
|
|
|
if( myFilterType == SMESH::TriaFilter ||
|
|
|
|
myFilterType == SMESH::QuadFilter ||
|
|
|
|
myFilterType == SMESH::FaceFilter ) {
|
2006-03-13 20:29:49 +05:00
|
|
|
SMDS_FaceIteratorPtr it = aMesh->facesIterator();
|
|
|
|
while(it->more()) {
|
|
|
|
const SMDS_MeshFace* f = it->next();
|
2009-02-17 10:27:49 +05:00
|
|
|
if(myFilterType == SMESH::FaceFilter) {
|
2006-03-13 20:29:49 +05:00
|
|
|
myIds.Add(f->GetID());
|
|
|
|
}
|
2009-02-17 10:27:49 +05:00
|
|
|
else if( myFilterType==SMESH::TriaFilter &&
|
2006-03-13 20:29:49 +05:00
|
|
|
( f->NbNodes()==3 || f->NbNodes()==6 ) ) {
|
|
|
|
myIds.Add(f->GetID());
|
|
|
|
}
|
2009-02-17 10:27:49 +05:00
|
|
|
else if( myFilterType==SMESH::QuadFilter &&
|
2006-03-13 20:29:49 +05:00
|
|
|
( f->NbNodes()==4 || f->NbNodes()==8 ) ) {
|
|
|
|
myIds.Add(f->GetID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-17 10:27:49 +05:00
|
|
|
else if(myFilterType == SMESH::VolumeFilter) {
|
2006-03-13 20:29:49 +05:00
|
|
|
SMDS_VolumeIteratorPtr it = aMesh->volumesIterator();
|
|
|
|
while(it->more()) {
|
|
|
|
const SMDS_MeshVolume* f = it->next();
|
|
|
|
myIds.Add(f->GetID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* commented by skl 07.02.2006
|
2005-02-03 17:31:13 +05:00
|
|
|
TVisualObjPtr aVisualObj = anActor->GetObject();
|
2004-12-01 15:48:31 +05:00
|
|
|
vtkUnstructuredGrid* aGrid = aVisualObj->GetUnstructuredGrid();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (aGrid != 0) {
|
|
|
|
for (int i = 0, n = aGrid->GetNumberOfCells(); i < n; i++) {
|
|
|
|
vtkCell* aCell = aGrid->GetCell(i);
|
|
|
|
if (aCell != 0) {
|
2005-01-25 20:51:15 +05:00
|
|
|
vtkTriangle* aTri = vtkTriangle::SafeDownCast(aCell);
|
|
|
|
vtkQuad* aQua = vtkQuad::SafeDownCast(aCell);
|
2005-06-07 19:22:20 +06:00
|
|
|
vtkPolygon* aPG = vtkPolygon::SafeDownCast(aCell);
|
2005-01-25 20:51:15 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
vtkCell3D* a3d = vtkCell3D::SafeDownCast(aCell);
|
|
|
|
vtkConvexPointSet* aPH = vtkConvexPointSet::SafeDownCast(aCell);
|
|
|
|
|
|
|
|
if (aTri && myFilterType == SMESHGUI_TriaFilter ||
|
|
|
|
aQua && myFilterType == SMESHGUI_QuadFilter ||
|
|
|
|
(aTri || aQua || aPG) && myFilterType == SMESHGUI_FaceFilter ||
|
|
|
|
(a3d || aPH) && myFilterType == SMESHGUI_VolumeFilter) {
|
|
|
|
int anObjId = aVisualObj->GetElemObjId(i);
|
|
|
|
myIds.Add(anObjId);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-03-13 20:29:49 +05:00
|
|
|
*/
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
anIds->length(myIds.Extent());
|
|
|
|
TColStd_MapIteratorOfMapOfInteger anIter(myIds);
|
|
|
|
for (int i = 0; anIter.More(); anIter.Next() )
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
anIds[ i++ ] = anIter.Key();
|
|
|
|
}
|
|
|
|
return anIds._retn();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onClose
|
|
|
|
// Purpose : SLOT called when "Close" button pressed. Close dialog
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onClose()
|
|
|
|
{
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(ActorSelection);
|
2005-06-07 19:22:20 +06:00
|
|
|
disconnect(mySelectionMgr, 0, this, 0);
|
|
|
|
disconnect(mySMESHGUI, 0, this, 0);
|
|
|
|
mySMESHGUI->ResetState();
|
|
|
|
|
2005-02-03 17:31:13 +05:00
|
|
|
SMESH::RemoveFilters();
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::SetPickable();
|
|
|
|
|
2005-11-23 17:08:49 +05:00
|
|
|
//mySelectionMgr->clearSelected();
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelectionMgr->clearFilters();
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
reject();
|
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : onHelp()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onHelp()
|
|
|
|
{
|
|
|
|
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;
|
2008-03-07 12:47:05 +05:00
|
|
|
#ifdef WIN32
|
2009-02-17 10:27:49 +05:00
|
|
|
platform = "winapplication";
|
2008-03-07 12:47:05 +05:00
|
|
|
#else
|
2009-02-17 10:27:49 +05:00
|
|
|
platform = "application";
|
2008-03-07 12:47:05 +05:00
|
|
|
#endif
|
2009-02-17 10:27:49 +05:00
|
|
|
SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
|
|
|
|
tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
|
|
|
|
arg(app->resourceMgr()->stringValue("ExternalBrowser",
|
|
|
|
platform)).
|
|
|
|
arg(myHelpFileName));
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onSelectionDone
|
|
|
|
// Purpose : SLOT called when selection changed
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onSelectionDone()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myBusy || !isEnabled()) return;
|
2004-12-01 15:48:31 +05:00
|
|
|
myBusy = true;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
const SALOME_ListIO& aList = mySelector->StoredIObjects();
|
|
|
|
|
|
|
|
int nbSel = aList.Extent();
|
2004-12-01 15:48:31 +05:00
|
|
|
myListBox->clearSelection();
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if (mySubmeshChk->isChecked() || myGroupChk->isChecked()) {
|
2004-12-01 15:48:31 +05:00
|
|
|
QLineEdit* aNameEdit = mySubmeshChk->isChecked() ? mySubmesh : myGroup;
|
2005-06-07 19:22:20 +06:00
|
|
|
if (nbSel == 1) {
|
|
|
|
Handle(SALOME_InteractiveObject) anIO = aList.First();
|
2005-07-28 17:03:00 +06:00
|
|
|
QString aName = "";
|
|
|
|
SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
|
|
|
|
anIO.IsNull() ? aNameEdit->clear() : aNameEdit->setText(aName);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if (mySubmeshChk->isChecked()) {
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::SMESH_subMesh_var aSubMesh =
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIO);
|
|
|
|
if (!aSubMesh->_is_nil())
|
2004-12-01 15:48:31 +05:00
|
|
|
myMesh = aSubMesh->GetFather();
|
2005-06-07 19:22:20 +06:00
|
|
|
} else {
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::SMESH_GroupBase_var aGroup =
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIO);
|
|
|
|
if (!aGroup->_is_nil())
|
2004-12-01 15:48:31 +05:00
|
|
|
myMesh = aGroup->GetMesh();
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
} else if (nbSel > 1) {
|
|
|
|
QString aStr = mySubmeshChk->isChecked() ?
|
|
|
|
tr("SMESH_SUBMESH_SELECTED") : tr("SMESH_GROUP_SELECTED");
|
|
|
|
aNameEdit->setText(aStr.arg(nbSel));
|
|
|
|
} else {
|
2004-12-01 15:48:31 +05:00
|
|
|
aNameEdit->clear();
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
2009-02-17 10:27:49 +05:00
|
|
|
} else if (nbSel > 0) {
|
2004-12-01 15:48:31 +05:00
|
|
|
QString aListStr = "";
|
2005-06-07 19:22:20 +06:00
|
|
|
Handle(SALOME_InteractiveObject) anIO = aList.First();
|
|
|
|
int aNbItems = SMESH::GetNameOfSelectedElements(mySelector,anIO,aListStr);
|
|
|
|
if (aNbItems > 0) {
|
2009-02-17 10:27:49 +05:00
|
|
|
QStringList anElements = aListStr.split(" ", QString::SkipEmptyParts);
|
2005-06-07 19:22:20 +06:00
|
|
|
for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
|
2009-02-17 10:27:49 +05:00
|
|
|
QList<QListWidgetItem*> items = myListBox->findItems(*it, Qt::MatchExactly);
|
|
|
|
QListWidgetItem* anItem;
|
|
|
|
foreach(anItem, items)
|
|
|
|
anItem->setSelected(true);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
myMesh = SMESH::GetMeshByIO(anIO);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
if (nbSel > 0) {
|
2005-06-07 19:22:20 +06:00
|
|
|
myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
|
2005-02-03 17:31:13 +05:00
|
|
|
if (!myActor)
|
2005-06-07 19:22:20 +06:00
|
|
|
myActor = SMESH::FindActorByObject(myMesh);
|
2006-02-07 20:01:11 +05:00
|
|
|
SVTK_Selector* aSelector = SMESH::GetSelector();
|
|
|
|
Handle(VTKViewer_Filter) aFilter = aSelector->GetFilter(myFilterType);
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!aFilter.IsNull())
|
|
|
|
aFilter->SetActor(myActor);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
myBusy = false;
|
|
|
|
|
|
|
|
updateButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onDeactivate
|
|
|
|
// Purpose : SLOT called when dialog must be deativated
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onDeactivate()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
setEnabled(false);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::enterEvent
|
|
|
|
// Purpose : Event filter
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_MultiEditDlg::enterEvent (QEvent*)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!isEnabled()) {
|
|
|
|
mySMESHGUI->EmitSignalDeactivateDialog();
|
|
|
|
setEnabled(true);
|
2004-12-01 15:48:31 +05:00
|
|
|
setSelectionMode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::closeEvent
|
|
|
|
// Purpose :
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::closeEvent (QCloseEvent*)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
onClose();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : SMESHGUI_MultiEditDlg::hideEvent
|
|
|
|
// Purpose : caused by ESC key
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_MultiEditDlg::hideEvent (QHideEvent*)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!isMinimized())
|
2004-12-01 15:48:31 +05:00
|
|
|
onClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onFilterBtn
|
|
|
|
// Purpose : SLOT. Called when "Filter" button pressed.
|
|
|
|
// Start "Selection filters" dialog
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onFilterBtn()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myFilterDlg == 0) {
|
|
|
|
myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, entityType() ? SMESH::VOLUME : SMESH::FACE);
|
|
|
|
connect(myFilterDlg, SIGNAL(Accepted()), SLOT(onFilterAccepted()));
|
|
|
|
} else {
|
|
|
|
myFilterDlg->Init(entityType() ? SMESH::VOLUME : SMESH::FACE);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
myFilterDlg->SetSelection();
|
|
|
|
myFilterDlg->SetMesh(myMesh);
|
|
|
|
myFilterDlg->SetSourceWg(myListBox);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
myFilterDlg->show();
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=======================================================================
|
|
|
|
// name : onFilterAccepted()
|
|
|
|
// Purpose : SLOT. Called when Filter dlg closed with OK button.
|
2004-12-01 15:48:31 +05:00
|
|
|
// Uncheck "Select submesh" and "Select group" checkboxes
|
2005-06-07 19:22:20 +06:00
|
|
|
//=======================================================================
|
2004-12-01 15:48:31 +05:00
|
|
|
void SMESHGUI_MultiEditDlg::onFilterAccepted()
|
|
|
|
{
|
|
|
|
myIds.Clear();
|
2005-06-07 19:22:20 +06:00
|
|
|
for (int i = 0, n = myListBox->count(); i < n; i++)
|
2009-02-17 10:27:49 +05:00
|
|
|
myIds.Add(myListBox->item(i)->text().toInt());
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
emit ListContensChanged();
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if (mySubmeshChk->isChecked() || myGroupChk->isChecked()) {
|
|
|
|
mySubmeshChk->blockSignals(true);
|
|
|
|
myGroupChk->blockSignals(true);
|
|
|
|
mySubmeshChk->setChecked(false);
|
|
|
|
myGroupChk->setChecked(false);
|
|
|
|
mySubmeshChk->blockSignals(false);
|
|
|
|
myGroupChk->blockSignals(false);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
updateButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2005-01-28 16:46:31 +05:00
|
|
|
// name : SMESHGUI_MultiEditDlg::isIdValid
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : Verify whether Id of element satisfies to filters from viewer
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_MultiEditDlg::isIdValid (const int theId) const
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2006-02-07 20:01:11 +05:00
|
|
|
SVTK_Selector* aSelector = SMESH::GetSelector();
|
2005-01-28 16:46:31 +05:00
|
|
|
Handle(SMESHGUI_Filter) aFilter =
|
2006-02-07 20:01:11 +05:00
|
|
|
Handle(SMESHGUI_Filter)::DownCast(aSelector->GetFilter(myFilterType));
|
2005-02-03 17:31:13 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
return (!aFilter.IsNull() && aFilter->IsObjValid(theId));
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onAddBtn
|
|
|
|
// Purpose : SLOT. Called when "Add" button pressed.
|
|
|
|
// Add selected in viewer entities in list box
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onAddBtn()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
const SALOME_ListIO& aList = mySelector->StoredIObjects();
|
|
|
|
|
|
|
|
int nbSelected = aList.Extent();
|
|
|
|
if (nbSelected == 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
|
|
|
|
|
|
|
TColStd_IndexedMapOfInteger toBeAdded;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
if (!mySubmeshChk->isChecked() && !myGroupChk->isChecked()) {
|
2009-02-17 10:27:49 +05:00
|
|
|
if (nbSelected > 0)
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelector->GetIndex(aList.First(),toBeAdded);
|
|
|
|
} else if (mySubmeshChk->isChecked()) {
|
|
|
|
SALOME_ListIteratorOfListIO anIter(aList);
|
2009-02-17 10:27:49 +05:00
|
|
|
for ( ; anIter.More(); anIter.Next()) {
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH::SMESH_subMesh_var aSubMesh =
|
|
|
|
SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIter.Value());
|
|
|
|
if (!aSubMesh->_is_nil()) {
|
|
|
|
if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::long_array_var anIds = aSubMesh->GetElementsId();
|
2005-06-07 19:22:20 +06:00
|
|
|
for (int i = 0, n = anIds->length(); i < n; i++) {
|
|
|
|
if (isIdValid(anIds[ i ]))
|
|
|
|
toBeAdded.Add(anIds[ i ]);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
} else if (myGroupChk->isChecked()) {
|
|
|
|
SALOME_ListIteratorOfListIO anIter(aList);
|
2009-02-17 10:27:49 +05:00
|
|
|
for ( ; anIter.More(); anIter.Next()) {
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::SMESH_GroupBase_var aGroup =
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value());
|
|
|
|
if (!aGroup->_is_nil() && (aGroup->GetType() == SMESH::FACE &&
|
|
|
|
entityType() == 0 || aGroup->GetType() == SMESH::VOLUME &&
|
|
|
|
entityType() == 1)) {
|
|
|
|
if (aGroup->GetMesh()->GetId() == myMesh->GetId()) {
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::long_array_var anIds = aGroup->GetListOfID();
|
2005-06-07 19:22:20 +06:00
|
|
|
for (int i = 0, n = anIds->length(); i < n; i++) {
|
|
|
|
if (isIdValid(anIds[ i ]))
|
|
|
|
toBeAdded.Add(anIds[ i ]);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
} else {
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
myBusy = true;
|
2005-06-07 19:22:20 +06:00
|
|
|
bool isGroupOrSubmesh = (mySubmeshChk->isChecked() || myGroupChk->isChecked());
|
|
|
|
mySubmeshChk->setChecked(false);
|
|
|
|
myGroupChk->setChecked(false);
|
|
|
|
for(int i = 1; i <= toBeAdded.Extent(); i++)
|
|
|
|
if (myIds.Add(toBeAdded(i))) {
|
2009-02-17 10:27:49 +05:00
|
|
|
QListWidgetItem* item = new QListWidgetItem(QString("%1").arg(toBeAdded(i)));
|
|
|
|
myListBox->addItem(item);
|
|
|
|
item->setSelected(true);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
myBusy = false;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
emit ListContensChanged();
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if (isGroupOrSubmesh)
|
2004-12-01 15:48:31 +05:00
|
|
|
onListSelectionChanged();
|
|
|
|
|
|
|
|
updateButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::updateButtons
|
|
|
|
// Purpose : Enable/disable buttons of dialog in accordance with current state
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::updateButtons()
|
|
|
|
{
|
|
|
|
bool isOk = isValid(false);
|
2005-06-07 19:22:20 +06:00
|
|
|
myOkBtn->setEnabled(isOk);
|
|
|
|
myApplyBtn->setEnabled(isOk);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
bool isListBoxNonEmpty = myListBox->count() > 0;
|
|
|
|
bool isToAll = myToAllChk->isChecked();
|
2005-06-07 19:22:20 +06:00
|
|
|
myFilterBtn->setEnabled(!isToAll);
|
|
|
|
myRemoveBtn->setEnabled(isListBoxNonEmpty && !isToAll);
|
|
|
|
mySortBtn->setEnabled(isListBoxNonEmpty &&!isToAll);
|
|
|
|
|
|
|
|
const SALOME_ListIO& aList = mySelector->StoredIObjects();
|
|
|
|
|
|
|
|
if (isToAll ||
|
|
|
|
myMesh->_is_nil() ||
|
2009-02-17 10:27:49 +05:00
|
|
|
aList.Extent() < 1 ||
|
2005-06-07 19:22:20 +06:00
|
|
|
(SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(aList.First())->_is_nil() &&
|
|
|
|
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(aList.First())->_is_nil() &&
|
|
|
|
SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(aList.First())->_is_nil()))
|
|
|
|
myAddBtn->setEnabled(false);
|
2004-12-01 15:48:31 +05:00
|
|
|
else
|
2005-06-07 19:22:20 +06:00
|
|
|
myAddBtn->setEnabled(true);
|
|
|
|
|
|
|
|
mySubmeshChk->setEnabled(!isToAll);
|
|
|
|
mySubmeshBtn->setEnabled(mySubmeshChk->isChecked());
|
|
|
|
mySubmesh->setEnabled(mySubmeshChk->isChecked());
|
|
|
|
|
|
|
|
myGroupChk->setEnabled(!isToAll);
|
|
|
|
myGroupBtn->setEnabled(myGroupChk->isChecked());
|
|
|
|
myGroup->setEnabled(myGroupChk->isChecked());
|
|
|
|
|
|
|
|
if (!mySubmeshChk->isChecked())
|
2004-12-01 15:48:31 +05:00
|
|
|
mySubmesh->clear();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!myGroupChk->isChecked())
|
2004-12-01 15:48:31 +05:00
|
|
|
myGroup->clear();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onRemoveBtn
|
|
|
|
// Purpose : SLOT. Called when "Remove" button pressed.
|
|
|
|
// Remove selected in list box entities
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onRemoveBtn()
|
|
|
|
{
|
|
|
|
myBusy = true;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QList<QListWidgetItem*> selItems = myListBox->selectedItems();
|
|
|
|
QListWidgetItem* item;
|
|
|
|
foreach(item, selItems)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
myIds.Remove(item->text().toInt());
|
|
|
|
delete item;
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
2009-02-17 10:27:49 +05:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
myBusy = false;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
emit ListContensChanged();
|
2004-12-01 15:48:31 +05:00
|
|
|
updateButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onSortListBtn
|
|
|
|
// Purpose : SLOT. Called when "Sort list" button pressed.
|
|
|
|
// Sort entities of list box
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onSortListBtn()
|
|
|
|
{
|
|
|
|
myBusy = true;
|
|
|
|
|
|
|
|
int i, k = myListBox->count();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (k > 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
QList<int> aSelected;
|
2005-06-07 19:22:20 +06:00
|
|
|
std::vector<int> anArray(k);
|
2009-02-17 10:27:49 +05:00
|
|
|
for (i = 0; i < k; i++)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
int id = myListBox->item(i)->text().toInt();
|
|
|
|
anArray[ i ] = id;
|
|
|
|
if (myListBox->item(i)->isSelected())
|
|
|
|
aSelected.append(id);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
std::sort(anArray.begin(), anArray.end());
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
myListBox->clear();
|
|
|
|
for (i = 0; i < k; i++) {
|
|
|
|
QListWidgetItem* item = new QListWidgetItem(QString::number(anArray[i]));
|
|
|
|
myListBox->addItem(item);
|
|
|
|
item->setSelected(aSelected.contains(anArray[i]));
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
myBusy = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onListSelectionChanged
|
|
|
|
// Purpose : SLOT. Called when selection in list box changed.
|
|
|
|
// Highlight in selected entities
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onListSelectionChanged()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myActor == 0 || myBusy)
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
if (mySubmeshChk->isChecked() || myGroupChk->isChecked())
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH_Actor * anActor = SMESH::FindActorByObject(myMesh);
|
|
|
|
if (!anActor)
|
2004-12-01 15:48:31 +05:00
|
|
|
anActor = myActor;
|
|
|
|
TVisualObjPtr anObj = anActor->GetObject();
|
|
|
|
|
|
|
|
TColStd_MapOfInteger anIndexes;
|
2009-02-17 10:27:49 +05:00
|
|
|
int total = myListBox->count();
|
|
|
|
for (int i = 0; i < total; i++)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
if (myListBox->item(i)->isSelected())
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
int anId = myListBox->item(i)->text().toInt();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (anObj->GetElemVTKId(anId) >= 0) // avoid exception in hilight
|
2004-12-01 15:48:31 +05:00
|
|
|
anIndexes.Add(anId);
|
|
|
|
}
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
mySelector->AddOrRemoveIndex(anActor->getIO(),anIndexes,false);
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->highlight(anActor->getIO(),true,true);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onSubmeshChk
|
|
|
|
// Purpose : SLOT. Called when state of "SubMesh" check box changed.
|
|
|
|
// Activate/deactivate selection of submeshes
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onSubmeshChk()
|
|
|
|
{
|
|
|
|
bool isChecked = mySubmeshChk->isChecked();
|
2005-06-07 19:22:20 +06:00
|
|
|
mySubmeshBtn->setEnabled(isChecked);
|
|
|
|
mySubmesh->setEnabled(isChecked);
|
|
|
|
if (!isChecked)
|
2004-12-01 15:48:31 +05:00
|
|
|
mySubmesh->clear();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (isChecked && myGroupChk->isChecked())
|
|
|
|
myGroupChk->setChecked(false);
|
|
|
|
|
|
|
|
setSelectionMode();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onGroupChk
|
|
|
|
// Purpose : SLOT. Called when state of "Group" check box changed.
|
|
|
|
// Activate/deactivate selection of groupes
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onGroupChk()
|
|
|
|
{
|
|
|
|
bool isChecked = myGroupChk->isChecked();
|
2005-06-07 19:22:20 +06:00
|
|
|
myGroupBtn->setEnabled(isChecked);
|
|
|
|
myGroup->setEnabled(isChecked);
|
|
|
|
if (!isChecked)
|
2004-12-01 15:48:31 +05:00
|
|
|
myGroup->clear();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (isChecked && mySubmeshChk->isChecked())
|
|
|
|
mySubmeshChk->setChecked(false);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
setSelectionMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onToAllChk
|
|
|
|
// Purpose : SLOT. Called when state of "Apply to all" check box changed.
|
2005-06-07 19:22:20 +06:00
|
|
|
// Activate/deactivate selection
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::onToAllChk()
|
|
|
|
{
|
|
|
|
bool isChecked = myToAllChk->isChecked();
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if (isChecked)
|
2004-12-01 15:48:31 +05:00
|
|
|
myListBox->clear();
|
|
|
|
|
|
|
|
myIds.Clear();
|
|
|
|
|
|
|
|
emit ListContensChanged();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2005-02-03 17:31:13 +05:00
|
|
|
updateButtons();
|
2004-12-01 15:48:31 +05:00
|
|
|
setSelectionMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::setSelectionMode
|
|
|
|
// Purpose : Set selection mode
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::setSelectionMode()
|
|
|
|
{
|
2005-02-03 17:31:13 +05:00
|
|
|
SMESH::RemoveFilters();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
mySelectionMgr->clearSelected();
|
|
|
|
mySelectionMgr->clearFilters();
|
|
|
|
|
|
|
|
if (mySubmeshChk->isChecked()) {
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(ActorSelection);
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelectionMgr->installFilter(new SMESH_TypeFilter(SUBMESH));
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
else if (myGroupChk->isChecked()) {
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(ActorSelection);
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelectionMgr->installFilter(new SMESH_TypeFilter(GROUP));
|
2005-01-28 16:46:31 +05:00
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
if (entityType()) {
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(VolumeSelection);
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH::SetFilter(new SMESHGUI_VolumesFilter());
|
|
|
|
} else {
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(FaceSelection);
|
2009-02-17 10:27:49 +05:00
|
|
|
if (myFilterType == SMESH::TriaFilter)
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH::SetFilter(new SMESHGUI_TriangleFilter());
|
2009-02-17 10:27:49 +05:00
|
|
|
else if (myFilterType == SMESH::QuadFilter)
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH::SetFilter(new SMESHGUI_QuadrangleFilter());
|
2005-01-28 16:46:31 +05:00
|
|
|
else
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH::SetFilter(new SMESHGUI_FacesFilter());
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::onApply
|
2005-06-07 19:22:20 +06:00
|
|
|
// Purpose : SLOT. Called when "Apply" button clicked.
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
bool SMESHGUI_MultiEditDlg::onApply()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (mySMESHGUI->isActiveStudyLocked())
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!isValid(true))
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
|
|
|
|
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (aMeshEditor->_is_nil())
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
|
2005-01-28 16:46:31 +05:00
|
|
|
myBusy = true;
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::long_array_var anIds = getIds();
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
bool aResult = process(aMeshEditor, anIds.inout());
|
|
|
|
if (aResult) {
|
|
|
|
if (myActor) {
|
2005-12-14 12:11:48 +05:00
|
|
|
SALOME_ListIO sel;
|
|
|
|
mySelectionMgr->selectedObjects( sel );
|
|
|
|
mySelector->ClearIndex();
|
|
|
|
mySelectionMgr->setSelectedObjects( sel );
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::UpdateView();
|
|
|
|
}
|
|
|
|
|
|
|
|
myListBox->clear();
|
|
|
|
myIds.Clear();
|
|
|
|
emit ListContensChanged();
|
|
|
|
|
|
|
|
updateButtons();
|
|
|
|
}
|
|
|
|
|
2005-01-28 16:46:31 +05:00
|
|
|
myBusy = false;
|
2004-12-01 15:48:31 +05:00
|
|
|
return aResult;
|
|
|
|
}
|
|
|
|
|
2005-01-25 20:51:15 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::on3d2dChanged
|
2005-06-07 19:22:20 +06:00
|
|
|
// Purpose :
|
2005-01-25 20:51:15 +05:00
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_MultiEditDlg::on3d2dChanged (int type)
|
2005-01-25 20:51:15 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myEntityType != type) {
|
2005-01-25 20:51:15 +05:00
|
|
|
myEntityType = type;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2005-01-25 20:51:15 +05:00
|
|
|
myListBox->clear();
|
|
|
|
myIds.Clear();
|
|
|
|
|
|
|
|
emit ListContensChanged();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
if (type)
|
2009-02-17 10:27:49 +05:00
|
|
|
myFilterType = SMESH::VolumeFilter;
|
2005-06-07 19:22:20 +06:00
|
|
|
else
|
2009-02-17 10:27:49 +05:00
|
|
|
myFilterType = SMESH::FaceFilter;
|
2005-01-25 20:51:15 +05:00
|
|
|
|
2005-02-01 19:55:30 +05:00
|
|
|
updateButtons();
|
2005-02-03 17:31:13 +05:00
|
|
|
setSelectionMode();
|
2005-01-25 20:51:15 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MultiEditDlg::entityType
|
2005-06-07 19:22:20 +06:00
|
|
|
// Purpose :
|
2005-01-25 20:51:15 +05:00
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
int SMESHGUI_MultiEditDlg::entityType()
|
2005-01-25 20:51:15 +05:00
|
|
|
{
|
|
|
|
return myEntityType;
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : keyPressEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MultiEditDlg::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();
|
|
|
|
onHelp();
|
|
|
|
}
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
|
2005-08-11 14:06:39 +06:00
|
|
|
/*!
|
2005-06-07 19:22:20 +06:00
|
|
|
* Class : SMESHGUI_ChangeOrientationDlg
|
|
|
|
* Description : Modification of orientation of faces
|
|
|
|
*/
|
|
|
|
|
|
|
|
SMESHGUI_ChangeOrientationDlg
|
2009-02-17 10:27:49 +05:00
|
|
|
::SMESHGUI_ChangeOrientationDlg(SMESHGUI* theModule):
|
|
|
|
SMESHGUI_MultiEditDlg(theModule, SMESH::FaceFilter, true)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
setWindowTitle(tr("CAPTION"));
|
2008-03-07 12:47:05 +05:00
|
|
|
myHelpFileName = "changing_orientation_of_elements_page.html";
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
SMESHGUI_ChangeOrientationDlg::~SMESHGUI_ChangeOrientationDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_ChangeOrientationDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
|
|
|
|
const SMESH::long_array& theIds)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
return theEditor->Reorient(theIds);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
/*!
|
|
|
|
* Class : SMESHGUI_UnionOfTrianglesDlg
|
|
|
|
* Description : Construction of quadrangles by automatic association of triangles
|
|
|
|
*/
|
|
|
|
|
|
|
|
SMESHGUI_UnionOfTrianglesDlg
|
2009-02-17 10:27:49 +05:00
|
|
|
::SMESHGUI_UnionOfTrianglesDlg(SMESHGUI* theModule):
|
|
|
|
SMESHGUI_MultiEditDlg(theModule, SMESH::TriaFilter, false)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
setWindowTitle(tr("CAPTION"));
|
2005-08-11 14:06:39 +06:00
|
|
|
|
|
|
|
myComboBoxFunctor->setEnabled(true);
|
2009-02-17 10:27:49 +05:00
|
|
|
myComboBoxFunctor->addItem(tr("WARP_ELEMENTS")); // for quadrangles only
|
|
|
|
myComboBoxFunctor->addItem(tr("TAPER_ELEMENTS")); // for quadrangles only
|
2005-08-11 14:06:39 +06:00
|
|
|
|
|
|
|
// Maximum angle
|
2009-02-17 10:27:49 +05:00
|
|
|
QWidget* aMaxAngleGrp = new QWidget(myCriterionGrp);
|
|
|
|
QHBoxLayout* aMaxAngleGrpLayout = new QHBoxLayout(aMaxAngleGrp);
|
|
|
|
aMaxAngleGrpLayout->setMargin(0);
|
|
|
|
aMaxAngleGrpLayout->setSpacing(SPACING);
|
|
|
|
|
|
|
|
QLabel* aLab = new QLabel (tr("MAXIMUM_ANGLE"), aMaxAngleGrp);
|
2005-08-11 14:06:39 +06:00
|
|
|
myMaxAngleSpin = new SMESHGUI_SpinBox (aMaxAngleGrp);
|
|
|
|
myMaxAngleSpin->RangeStepAndValidator(0, 180.0, 1.0, 3);
|
|
|
|
myMaxAngleSpin->SetValue(30.0);
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
aMaxAngleGrpLayout->addWidget(aLab);
|
|
|
|
aMaxAngleGrpLayout->addWidget(myMaxAngleSpin);
|
|
|
|
|
|
|
|
((QVBoxLayout*)(myCriterionGrp->layout()))->addWidget(aMaxAngleGrp);
|
2005-08-11 14:06:39 +06:00
|
|
|
myCriterionGrp->show();
|
2006-05-06 14:51:48 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
myHelpFileName = "uniting_set_of_triangles_page.html";
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
SMESHGUI_UnionOfTrianglesDlg::~SMESHGUI_UnionOfTrianglesDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
bool SMESHGUI_UnionOfTrianglesDlg::isValid (const bool theMess)
|
|
|
|
{
|
|
|
|
bool ok = SMESHGUI_MultiEditDlg::isValid( theMess );
|
|
|
|
if( !ok )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QString msg;
|
|
|
|
ok = myMaxAngleSpin->isValid( msg, theMess );
|
|
|
|
if( !ok ) {
|
|
|
|
if( theMess ) {
|
|
|
|
QString str( tr( "SMESH_INCORRECT_INPUT" ) );
|
|
|
|
if ( !msg.isEmpty() )
|
|
|
|
str += "\n" + msg;
|
|
|
|
SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
|
|
|
|
const SMESH::long_array& theIds)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-08-11 14:06:39 +06:00
|
|
|
SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
|
|
|
|
double aMaxAngle = myMaxAngleSpin->GetValue() * PI / 180.0;
|
2009-02-17 10:27:49 +05:00
|
|
|
bool ok = theEditor->TriToQuad(theIds, aCriterion, aMaxAngle);
|
|
|
|
if( ok ) {
|
|
|
|
QStringList aParameters;
|
|
|
|
aParameters << myMaxAngleSpin->text();
|
|
|
|
myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
|
|
|
|
}
|
|
|
|
return ok;
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2005-08-11 14:06:39 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
/*!
|
|
|
|
* Class : SMESHGUI_CuttingOfQuadsDlg
|
2005-08-11 14:06:39 +06:00
|
|
|
* Description : Automatic splitting of quadrangles into triangles
|
2005-06-07 19:22:20 +06:00
|
|
|
*/
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESHGUI_CuttingOfQuadsDlg
|
2009-02-17 10:27:49 +05:00
|
|
|
::SMESHGUI_CuttingOfQuadsDlg(SMESHGUI* theModule):
|
|
|
|
SMESHGUI_MultiEditDlg(theModule, SMESH::QuadFilter, false)
|
2005-06-07 19:22:20 +06:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
setWindowTitle(tr("CAPTION"));
|
2004-12-01 15:48:31 +05:00
|
|
|
myPreviewActor = 0;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
myPreviewChk = new QCheckBox (tr("PREVIEW"), mySelGrp);
|
2009-02-17 10:27:49 +05:00
|
|
|
QGridLayout* aLay = (QGridLayout*)(mySelGrp->layout());
|
|
|
|
aLay->addWidget(myPreviewChk, aLay->rowCount(), 0, 1, aLay->columnCount());
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-08-11 14:06:39 +06:00
|
|
|
myCriterionGrp->show();
|
2009-02-17 10:27:49 +05:00
|
|
|
myChoiceWidget->show();
|
2005-08-11 14:06:39 +06:00
|
|
|
myComboBoxFunctor->setEnabled(false);
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
connect(myPreviewChk, SIGNAL(stateChanged(int)), this, SLOT(onPreviewChk()));
|
|
|
|
connect(myGroupChoice, SIGNAL(buttonClicked(int)), this, SLOT(onCriterionRB()));
|
|
|
|
connect(myComboBoxFunctor, SIGNAL(activated(int)), this, SLOT(onPreviewChk()));
|
|
|
|
connect(this, SIGNAL(ListContensChanged()), this, SLOT(onPreviewChk()));
|
2006-05-06 14:51:48 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
myHelpFileName = "cutting_quadrangles_page.html";
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
SMESHGUI_CuttingOfQuadsDlg::~SMESHGUI_CuttingOfQuadsDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SMESHGUI_CuttingOfQuadsDlg::onClose()
|
|
|
|
{
|
|
|
|
erasePreview();
|
|
|
|
SMESHGUI_MultiEditDlg::onClose();
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_CuttingOfQuadsDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
|
|
|
|
const SMESH::long_array& theIds)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
switch (myGroupChoice->checkedId()) {
|
2005-08-11 14:06:39 +06:00
|
|
|
case 0: // use diagonal 1-3
|
|
|
|
return theEditor->SplitQuad(theIds, true);
|
|
|
|
case 1: // use diagonal 2-4
|
|
|
|
return theEditor->SplitQuad(theIds, false);
|
|
|
|
default: // use numeric functor
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
|
|
|
|
return theEditor->QuadToTri(theIds, aCriterion);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SMESHGUI_CuttingOfQuadsDlg::onCriterionRB()
|
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
if (myGroupChoice->checkedId() == 2) // Use numeric functor
|
2005-08-11 14:06:39 +06:00
|
|
|
myComboBoxFunctor->setEnabled(true);
|
|
|
|
else
|
|
|
|
myComboBoxFunctor->setEnabled(false);
|
|
|
|
|
|
|
|
onPreviewChk();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
void SMESHGUI_CuttingOfQuadsDlg::onPreviewChk()
|
|
|
|
{
|
|
|
|
myPreviewChk->isChecked() ? displayPreview() : erasePreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SMESHGUI_CuttingOfQuadsDlg::erasePreview()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myPreviewActor == 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) {
|
2004-12-01 15:48:31 +05:00
|
|
|
vf->RemoveActor(myPreviewActor);
|
|
|
|
vf->Repaint();
|
|
|
|
}
|
|
|
|
myPreviewActor->Delete();
|
|
|
|
myPreviewActor = 0;
|
|
|
|
}
|
2005-08-11 14:06:39 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
void SMESHGUI_CuttingOfQuadsDlg::displayPreview()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myActor == 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myPreviewActor != 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
erasePreview();
|
|
|
|
|
|
|
|
// get Ids of elements
|
|
|
|
SMESH::long_array_var anElemIds = getIds();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (getIds()->length() == 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
|
|
|
|
|
|
|
SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (aMesh == 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
|
|
|
|
2005-08-11 14:06:39 +06:00
|
|
|
// 0 - use diagonal 1-3, 1 - use diagonal 2-4, 2 - use numerical functor
|
2009-02-17 10:27:49 +05:00
|
|
|
int aChoice = myGroupChoice->checkedId();
|
2005-08-11 14:06:39 +06:00
|
|
|
SMESH::NumericalFunctor_var aCriterion = SMESH::NumericalFunctor::_nil();
|
|
|
|
SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH::SMESH_MeshEditor::_nil();
|
|
|
|
if (aChoice == 2) {
|
|
|
|
aCriterion = getNumericalFunctor();
|
|
|
|
aMeshEditor = myMesh->GetMeshEditor();
|
|
|
|
if (aMeshEditor->_is_nil())
|
|
|
|
return;
|
|
|
|
}
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
//Create grid
|
|
|
|
vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
vtkIdType aNbCells = anElemIds->length() * 2;
|
|
|
|
vtkIdType aCellsSize = 4 * aNbCells;
|
|
|
|
vtkCellArray* aConnectivity = vtkCellArray::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
aConnectivity->Allocate(aCellsSize, 0);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
vtkPoints* aPoints = vtkPoints::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
aPoints->SetNumberOfPoints(anElemIds->length() * 4);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
aCellTypesArray->SetNumberOfComponents(1);
|
|
|
|
aCellTypesArray->Allocate(aNbCells * aCellTypesArray->GetNumberOfComponents());
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
vtkIdList *anIdList = vtkIdList::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
anIdList->SetNumberOfIds(3);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
TColStd_DataMapOfIntegerInteger anIdToVtk;
|
|
|
|
|
|
|
|
int aNodes[ 4 ];
|
|
|
|
int nbPoints = -1;
|
2005-06-07 19:22:20 +06:00
|
|
|
for (int i = 0, n = anElemIds->length(); i < n; i++)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
const SMDS_MeshElement* anElem = aMesh->FindElement(anElemIds[ i ]);
|
|
|
|
if (anElem == 0 || anElem->NbNodes() != 4)
|
2004-12-01 15:48:31 +05:00
|
|
|
continue;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
SMDS_ElemIteratorPtr anIter = anElem->nodesIterator();
|
|
|
|
int k = 0;
|
2005-08-11 14:06:39 +06:00
|
|
|
while (anIter->more()) {
|
|
|
|
const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(anIter->next());
|
|
|
|
if (aNode)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!anIdToVtk.IsBound(aNode->GetID()))
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
aPoints->SetPoint(++nbPoints, aNode->X(), aNode->Y(), aNode->Z());
|
|
|
|
anIdToVtk.Bind(aNode->GetID(), nbPoints);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
aNodes[ k++ ] = aNode->GetID();
|
|
|
|
}
|
2005-08-11 14:06:39 +06:00
|
|
|
}
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if (k != 4)
|
2004-12-01 15:48:31 +05:00
|
|
|
continue;
|
|
|
|
|
2005-08-11 14:06:39 +06:00
|
|
|
bool isDiag13 = true;
|
|
|
|
if (aChoice == 0) // use diagonal 1-3
|
|
|
|
{
|
|
|
|
isDiag13 = true;
|
|
|
|
}
|
|
|
|
else if (aChoice == 1) // use diagonal 2-4
|
|
|
|
{
|
|
|
|
isDiag13 = false;
|
|
|
|
}
|
|
|
|
else // use numerical functor
|
|
|
|
{
|
|
|
|
// compare two sets of possible triangles
|
|
|
|
int diag = aMeshEditor->BestSplit(anElemIds[i], aCriterion);
|
|
|
|
if (diag == 1) // 1-3
|
|
|
|
isDiag13 = true;
|
|
|
|
else if (diag == 2) // 2-4
|
|
|
|
isDiag13 = false;
|
|
|
|
else // error
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isDiag13)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
anIdList->SetId(0, anIdToVtk(aNodes[ 0 ]));
|
|
|
|
anIdList->SetId(1, anIdToVtk(aNodes[ 1 ]));
|
|
|
|
anIdList->SetId(2, anIdToVtk(aNodes[ 2 ]));
|
|
|
|
aConnectivity->InsertNextCell(anIdList);
|
|
|
|
aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
|
|
|
|
|
|
|
|
anIdList->SetId(0, anIdToVtk(aNodes[ 2 ]));
|
|
|
|
anIdList->SetId(1, anIdToVtk(aNodes[ 3 ]));
|
|
|
|
anIdList->SetId(2, anIdToVtk(aNodes[ 0 ]));
|
|
|
|
aConnectivity->InsertNextCell(anIdList);
|
|
|
|
aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
anIdList->SetId(0, anIdToVtk(aNodes[ 1 ]));
|
|
|
|
anIdList->SetId(1, anIdToVtk(aNodes[ 2 ]));
|
|
|
|
anIdList->SetId(2, anIdToVtk(aNodes[ 3 ]));
|
|
|
|
aConnectivity->InsertNextCell(anIdList);
|
|
|
|
aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
|
|
|
|
|
|
|
|
anIdList->SetId(0, anIdToVtk(aNodes[ 3 ]));
|
|
|
|
anIdList->SetId(1, anIdToVtk(aNodes[ 0 ]));
|
|
|
|
anIdList->SetId(2, anIdToVtk(aNodes[ 1 ]));
|
|
|
|
aConnectivity->InsertNextCell(anIdList);
|
|
|
|
aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
aCellLocationsArray->SetNumberOfComponents(1);
|
|
|
|
aCellLocationsArray->SetNumberOfTuples(aNbCells);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
aConnectivity->InitTraversal();
|
2005-06-07 19:22:20 +06:00
|
|
|
for(vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell(npts, pts); idType++)
|
|
|
|
aCellLocationsArray->SetValue(idType, aConnectivity->GetTraversalLocation(npts));
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aGrid->SetPoints(aPoints);
|
|
|
|
aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aConnectivity);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// Create and display actor
|
|
|
|
vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
aMapper->SetInput(aGrid);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
myPreviewActor = SALOME_Actor::New();
|
|
|
|
myPreviewActor->PickableOff();
|
2005-06-07 19:22:20 +06:00
|
|
|
myPreviewActor->SetMapper(aMapper);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
vtkProperty* aProp = vtkProperty::New();
|
|
|
|
aProp->SetRepresentationToWireframe();
|
2005-06-07 19:22:20 +06:00
|
|
|
aProp->SetColor(250, 0, 250);
|
|
|
|
aProp->SetLineWidth(myActor->GetLineWidth() + 1);
|
|
|
|
myPreviewActor->SetProperty(aProp);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH::GetCurrentVtkView()->AddActor(myPreviewActor);
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::GetCurrentVtkView()->Repaint();
|
|
|
|
|
|
|
|
aProp->Delete();
|
|
|
|
aPoints->Delete();
|
|
|
|
aConnectivity->Delete();
|
|
|
|
aGrid->Delete();
|
|
|
|
aMapper->Delete();
|
|
|
|
anIdList->Delete();
|
|
|
|
aCellTypesArray->Delete();
|
|
|
|
aCellLocationsArray->Delete();
|
|
|
|
}
|