2004-12-01 15:48:31 +05:00
|
|
|
// SMESH SMESHGUI : GUI for SMESH component
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 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
|
|
|
|
//
|
|
|
|
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : SMESHGUI_MergeNodesDlg.cxx
|
|
|
|
// Author : Michael ZORIN
|
|
|
|
// Module : SMESH
|
2005-06-07 19:22:20 +06:00
|
|
|
// $Header:
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
#include "SMESHGUI_MergeNodesDlg.h"
|
|
|
|
|
|
|
|
#include "SMESHGUI.h"
|
|
|
|
#include "SMESHGUI_Utils.h"
|
|
|
|
#include "SMESHGUI_VTKUtils.h"
|
|
|
|
#include "SMESHGUI_IdValidator.h"
|
|
|
|
#include "SMESHGUI_SpinBox.h"
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SMESH_Actor.h"
|
2005-06-07 19:22:20 +06:00
|
|
|
#include "SMESH_TypeFilter.hxx"
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SMDS_Mesh.hxx"
|
|
|
|
|
|
|
|
#include "GEOMBase.h"
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
#include "SUIT_ResourceMgr.h"
|
|
|
|
|
|
|
|
#include "SVTK_ViewModel.h"
|
|
|
|
#include "SVTK_ViewWindow.h"
|
|
|
|
#include "SVTK_Selector.h"
|
|
|
|
#include "SVTK_Selection.h"
|
|
|
|
#include "SALOME_ListIO.hxx"
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "utilities.h"
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
// OCCT Includes
|
|
|
|
#include <TColStd_MapOfInteger.hxx>
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
// QT Includes
|
|
|
|
#include <qapplication.h>
|
|
|
|
#include <qbuttongroup.h>
|
|
|
|
#include <qgroupbox.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qlistbox.h>
|
|
|
|
#include <qlistview.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qradiobutton.h>
|
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qpixmap.h>
|
|
|
|
#include <qheader.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// class : SMESHGUI_MergeNodesDlg()
|
2005-06-07 19:22:20 +06:00
|
|
|
// purpose :
|
2004-12-01 15:48:31 +05:00
|
|
|
//=================================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESHGUI_MergeNodesDlg::SMESHGUI_MergeNodesDlg( SMESHGUI* theModule, const char* name,
|
|
|
|
bool modal, WFlags fl)
|
|
|
|
: QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
|
|
|
|
WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
|
|
|
|
mySMESHGUI( theModule ),
|
2005-07-01 16:42:32 +06:00
|
|
|
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-08 16:45:19 +06:00
|
|
|
QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_MERGE_NODES")));
|
|
|
|
QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
if (!name)
|
|
|
|
setName("SMESHGUI_MergeNodesDlg");
|
|
|
|
resize(303, 185);
|
|
|
|
setCaption(tr("SMESH_MERGE_NODES"));
|
|
|
|
setSizeGripEnabled(TRUE);
|
|
|
|
SMESHGUI_MergeNodesDlgLayout = new QGridLayout(this);
|
|
|
|
SMESHGUI_MergeNodesDlgLayout->setSpacing(6);
|
|
|
|
SMESHGUI_MergeNodesDlgLayout->setMargin(11);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
/***************************************************************/
|
2005-06-07 19:22:20 +06:00
|
|
|
GroupConstructors = new QButtonGroup(this, "GroupConstructors");
|
|
|
|
GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
|
|
|
|
(QSizePolicy::SizeType)0, 0, 0,
|
|
|
|
GroupConstructors->sizePolicy().hasHeightForWidth()));
|
|
|
|
GroupConstructors->setTitle(tr("SMESH_MERGE_NODES" ));
|
|
|
|
GroupConstructors->setExclusive(TRUE);
|
|
|
|
GroupConstructors->setColumnLayout(0, Qt::Vertical);
|
|
|
|
GroupConstructors->layout()->setSpacing(0);
|
|
|
|
GroupConstructors->layout()->setMargin(0);
|
|
|
|
GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
|
|
|
|
GroupConstructorsLayout->setAlignment(Qt::AlignTop);
|
|
|
|
GroupConstructorsLayout->setSpacing(6);
|
|
|
|
GroupConstructorsLayout->setMargin(11);
|
|
|
|
QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2");
|
|
|
|
RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
|
|
|
|
RadioButton1->setText(tr("" ));
|
|
|
|
RadioButton1->setPixmap(image0);
|
|
|
|
RBLayout->addWidget(RadioButton1);
|
|
|
|
GroupConstructorsLayout->addLayout(RBLayout, 0, 0);
|
|
|
|
SMESHGUI_MergeNodesDlgLayout->addWidget(GroupConstructors, 0, 0);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
/***************************************************************/
|
2005-06-07 19:22:20 +06:00
|
|
|
GroupButtons = new QGroupBox(this, "GroupButtons");
|
|
|
|
GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
|
|
|
|
(QSizePolicy::SizeType)0, 0, 0,
|
|
|
|
GroupButtons->sizePolicy().hasHeightForWidth()));
|
|
|
|
GroupButtons->setGeometry(QRect(10, 10, 281, 48));
|
|
|
|
GroupButtons->setTitle(tr("" ));
|
|
|
|
GroupButtons->setColumnLayout(0, Qt::Vertical);
|
|
|
|
GroupButtons->layout()->setSpacing(0);
|
|
|
|
GroupButtons->layout()->setMargin(0);
|
|
|
|
GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
|
|
|
|
GroupButtonsLayout->setAlignment(Qt::AlignTop);
|
|
|
|
GroupButtonsLayout->setSpacing(6);
|
|
|
|
GroupButtonsLayout->setMargin(11);
|
|
|
|
buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
|
|
|
|
buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
|
|
|
|
buttonCancel->setAutoDefault(TRUE);
|
|
|
|
GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
|
|
|
|
buttonApply = new QPushButton(GroupButtons, "buttonApply");
|
|
|
|
buttonApply->setText(tr("SMESH_BUT_APPLY" ));
|
|
|
|
buttonApply->setAutoDefault(TRUE);
|
|
|
|
GroupButtonsLayout->addWidget(buttonApply, 0, 1);
|
|
|
|
QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
|
|
GroupButtonsLayout->addItem(spacer_9, 0, 2);
|
|
|
|
buttonOk = new QPushButton(GroupButtons, "buttonOk");
|
|
|
|
buttonOk->setText(tr("SMESH_BUT_OK" ));
|
|
|
|
buttonOk->setAutoDefault(TRUE);
|
|
|
|
buttonOk->setDefault(TRUE);
|
|
|
|
GroupButtonsLayout->addWidget(buttonOk, 0, 0);
|
|
|
|
SMESHGUI_MergeNodesDlgLayout->addWidget(GroupButtons, 4, 0);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
/***************************************************************/
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
// Controls for mesh defining
|
2005-06-07 19:22:20 +06:00
|
|
|
GroupMesh = new QGroupBox(this, "GroupMesh");
|
|
|
|
GroupMesh->setTitle(tr("SMESH_MESH"));
|
|
|
|
GroupMesh->setColumnLayout(0, Qt::Vertical);
|
|
|
|
GroupMesh->layout()->setSpacing(0);
|
|
|
|
GroupMesh->layout()->setMargin(0);
|
|
|
|
GroupMeshLayout = new QGridLayout(GroupMesh->layout());
|
|
|
|
GroupMeshLayout->setAlignment(Qt::AlignTop);
|
|
|
|
GroupMeshLayout->setSpacing(6);
|
|
|
|
GroupMeshLayout->setMargin(11);
|
|
|
|
|
|
|
|
TextLabelName = new QLabel(GroupMesh, "TextLabelName");
|
|
|
|
TextLabelName->setText(tr("SMESH_NAME"));
|
|
|
|
GroupMeshLayout->addWidget(TextLabelName, 0, 0);
|
|
|
|
|
|
|
|
SelectMeshButton = new QPushButton(GroupMesh, "SelectMeshButton");
|
|
|
|
SelectMeshButton->setPixmap(image1);
|
|
|
|
GroupMeshLayout->addWidget(SelectMeshButton, 0, 1);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
LineEditMesh = new QLineEdit(GroupMesh, "LineEditMesh");
|
|
|
|
LineEditMesh->setReadOnly(true);
|
2005-06-07 19:22:20 +06:00
|
|
|
GroupMeshLayout->addWidget(LineEditMesh, 0, 2);
|
|
|
|
|
|
|
|
SMESHGUI_MergeNodesDlgLayout->addWidget(GroupMesh, 1, 0);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
// Controls for coincident nodes detecting
|
2005-06-07 19:22:20 +06:00
|
|
|
GroupCoincident = new QGroupBox(this, "GroupCoincident");
|
|
|
|
GroupCoincident->setTitle(tr("COINCIDENT_NODES"));
|
|
|
|
GroupCoincident->setColumnLayout(0, Qt::Vertical);
|
|
|
|
GroupCoincident->layout()->setSpacing(0);
|
|
|
|
GroupCoincident->layout()->setMargin(0);
|
|
|
|
QGridLayout* GroupCoincidentLayout = new QGridLayout(GroupCoincident->layout());
|
|
|
|
GroupCoincidentLayout->setAlignment(Qt::AlignTop);
|
|
|
|
GroupCoincidentLayout->setSpacing(6);
|
|
|
|
GroupCoincidentLayout->setMargin(11);
|
|
|
|
|
|
|
|
TextLabelTolerance = new QLabel(GroupCoincident, "TextLabelTolerance");
|
|
|
|
TextLabelTolerance->setText(tr("SMESH_TOLERANCE"));
|
|
|
|
GroupCoincidentLayout->addWidget(TextLabelTolerance, 0, 0);
|
|
|
|
|
|
|
|
SpinBoxTolerance = new SMESHGUI_SpinBox(GroupCoincident, "SpinBoxTolerance");
|
|
|
|
GroupCoincidentLayout->addWidget(SpinBoxTolerance, 0, 1);
|
|
|
|
|
|
|
|
QPushButton* DetectButton = new QPushButton(GroupCoincident, "DetectButton");
|
|
|
|
DetectButton->setText(tr("DETECT"));
|
|
|
|
GroupCoincidentLayout->addWidget(DetectButton, 0, 2);
|
|
|
|
|
|
|
|
ListCoincident = new QListView(GroupCoincident);
|
|
|
|
ListCoincident->setSorting(-1);
|
|
|
|
ListCoincident->addColumn("Nodes");
|
2004-12-01 15:48:31 +05:00
|
|
|
ListCoincident->header()->hide();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
GroupCoincidentLayout->addMultiCellWidget(ListCoincident, 1, 1, 0, 1);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
SelectAllCB = new QCheckBox(GroupCoincident, "SelectAllCB");
|
|
|
|
SelectAllCB->setText(tr("SELECT_ALL"));
|
2005-06-07 19:22:20 +06:00
|
|
|
GroupCoincidentLayout->addWidget(SelectAllCB, 2, 0);
|
|
|
|
|
|
|
|
SMESHGUI_MergeNodesDlgLayout->addWidget(GroupCoincident, 2, 0);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// Controls for editing group of nodes
|
2005-06-07 19:22:20 +06:00
|
|
|
GroupEdit = new QGroupBox(this, "GroupEdit");
|
|
|
|
GroupEdit->setTitle(tr("EDIT_GROUP_OF_NODES"));
|
|
|
|
GroupEdit->setColumnLayout(0, Qt::Vertical);
|
|
|
|
GroupEdit->layout()->setSpacing(0);
|
|
|
|
GroupEdit->layout()->setMargin(0);
|
|
|
|
QGridLayout* GroupEditLayout = new QGridLayout(GroupEdit->layout());
|
|
|
|
GroupEditLayout->setAlignment(Qt::AlignTop);
|
|
|
|
GroupEditLayout->setSpacing(6);
|
|
|
|
GroupEditLayout->setMargin(11);
|
|
|
|
|
|
|
|
ListEdit = new QListBox(GroupEdit, "ListEdit");
|
2004-12-01 15:48:31 +05:00
|
|
|
ListEdit->setColumnMode(QListBox::FitToHeight);
|
2005-06-07 19:22:20 +06:00
|
|
|
ListEdit->setSelectionMode(QListBox::Extended);
|
|
|
|
GroupEditLayout->addMultiCellWidget(ListEdit, 0, 2, 0, 0);
|
|
|
|
|
|
|
|
QPushButton* AddButton = new QPushButton(GroupEdit, "AddButton");
|
|
|
|
AddButton->setText(tr("SMESH_BUT_ADD"));
|
|
|
|
GroupEditLayout->addWidget(AddButton, 0, 1);
|
|
|
|
|
|
|
|
QPushButton* RemoveButton = new QPushButton(GroupEdit, "RemoveButton");
|
|
|
|
RemoveButton->setText(tr("SMESH_BUT_REMOVE"));
|
|
|
|
GroupEditLayout->addWidget(RemoveButton, 1, 1);
|
|
|
|
|
|
|
|
QSpacerItem* spacer = new QSpacerItem(20, 200, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
|
|
|
GroupEditLayout->addItem(spacer, 2, 1);
|
|
|
|
|
|
|
|
SMESHGUI_MergeNodesDlgLayout->addWidget(GroupEdit, 3, 0);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
/* Initialisations */
|
2005-06-07 19:22:20 +06:00
|
|
|
SpinBoxTolerance->RangeStepAndValidator(0.0, 999999.999, 0.1, 3);
|
2004-12-01 15:48:31 +05:00
|
|
|
SpinBoxTolerance->SetValue(1e-05);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
RadioButton1->setChecked(TRUE);
|
|
|
|
|
2005-03-01 14:53:20 +05:00
|
|
|
myActor = 0;
|
|
|
|
|
2005-07-01 16:42:32 +06:00
|
|
|
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
|
|
|
|
|
|
|
|
myMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
/* signals and slots connections */
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
|
|
|
|
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
|
|
|
|
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
|
|
|
|
|
|
|
connect(SelectMeshButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
|
|
|
|
connect(DetectButton, SIGNAL (clicked()), this, SLOT(onDetect()));
|
|
|
|
connect(ListCoincident, SIGNAL (selectionChanged()), this, SLOT(onSelectNodesGroup()));
|
|
|
|
connect(ListCoincident, SIGNAL (pressed(QListViewItem*)), this, SLOT(updateControls()));
|
|
|
|
connect(ListCoincident, SIGNAL (currentChanged(QListViewItem*)), this, SLOT(updateControls()));
|
|
|
|
connect(SelectAllCB, SIGNAL(toggled(bool)), this, SLOT(onSelectAll(bool)));
|
|
|
|
connect(ListEdit, SIGNAL (selectionChanged()), this, SLOT(onSelectNodesFromGroup()));
|
|
|
|
connect(AddButton, SIGNAL (clicked()), this, SLOT(onAdd()));
|
|
|
|
connect(RemoveButton, SIGNAL (clicked()), this, SLOT(onRemove()));
|
|
|
|
|
|
|
|
connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
|
|
|
|
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
|
2004-12-01 15:48:31 +05:00
|
|
|
/* to close dialog if study change */
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
/* Move widget on the botton right corner of main widget */
|
2005-06-07 19:22:20 +06:00
|
|
|
int x, y;
|
|
|
|
mySMESHGUI->DefineDlgPosition(this, x, y);
|
|
|
|
this->move(x, y);
|
|
|
|
this->show(); /* displays Dialog */
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
resize(0,0);
|
|
|
|
buttonOk->setEnabled(false);
|
|
|
|
buttonApply->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ~SMESHGUI_MergeNodesDlg()
|
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//=================================================================================
|
|
|
|
SMESHGUI_MergeNodesDlg::~SMESHGUI_MergeNodesDlg()
|
|
|
|
{
|
|
|
|
// no need to delete child widgets, Qt does it all for us
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnApply()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
bool SMESHGUI_MergeNodesDlg::ClickOnApply()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (mySMESHGUI->isActiveStudyLocked() || myMesh->_is_nil())
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
try {
|
|
|
|
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
|
|
|
|
|
|
|
|
QApplication::setOverrideCursor(Qt::waitCursor);
|
|
|
|
SMESH::array_of_long_array_var aGroupsOfNodes = new SMESH::array_of_long_array;
|
|
|
|
aGroupsOfNodes->length(ListCoincident->childCount());
|
|
|
|
QListViewItem* item = ListCoincident->firstChild();
|
|
|
|
|
|
|
|
int anArrayNum = 0;
|
|
|
|
while (item) {
|
|
|
|
QStringList aListIds = QStringList("");
|
|
|
|
if (((QCheckListItem*) item)->isOn())
|
|
|
|
aListIds = QStringList::split(" ", item->text(0), false);
|
|
|
|
|
|
|
|
SMESH::long_array_var anIds = new SMESH::long_array;
|
|
|
|
anIds->length(aListIds.count());
|
|
|
|
|
|
|
|
for (int i = 0; i < aListIds.count(); i++)
|
|
|
|
anIds[i] = aListIds[i].toInt();
|
|
|
|
|
|
|
|
aGroupsOfNodes[anArrayNum++] = anIds.inout();
|
|
|
|
|
|
|
|
item = item->itemBelow();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aMeshEditor->MergeNodes (aGroupsOfNodes.inout());
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
} catch(...) {
|
|
|
|
}
|
|
|
|
|
|
|
|
mySelectionMgr->clearSelected();
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::UpdateView();
|
|
|
|
|
|
|
|
onDetect();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnOk()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::ClickOnOk()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (ClickOnApply())
|
|
|
|
ClickOnCancel();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnCancel()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::ClickOnCancel()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelectionMgr->clearFilters();
|
|
|
|
mySelectionMgr->clearSelected();
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::SetPointRepresentation(false);
|
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);
|
|
|
|
mySMESHGUI->ResetState();
|
|
|
|
reject();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onEditNodesGroup()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::onEditNodesGroup()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (ListCoincident->childCount() < 1)
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
|
|
|
|
|
|
|
QString aNewIds = "";
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
QListBoxItem* anItem;
|
|
|
|
for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next())
|
|
|
|
aNewIds+=QString(" %1").arg(anItem->text());
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
ListCoincident->currentItem()->setText(0, aNewIds);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : updateControls()
|
2005-06-07 19:22:20 +06:00
|
|
|
// purpose :
|
2004-12-01 15:48:31 +05:00
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::updateControls()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (ListCoincident->childCount() < 1) {
|
|
|
|
SMESH::SetPointRepresentation(false);
|
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
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
bool hasChecked = false, hasUnchecked = false;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
QListViewItem* item = ListCoincident->firstChild();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
while (item && (!hasChecked || !hasUnchecked)) {
|
|
|
|
if (((QCheckListItem*) item)->isOn())
|
|
|
|
hasChecked = true;
|
|
|
|
else
|
|
|
|
hasUnchecked = true;
|
|
|
|
|
|
|
|
item = item->itemBelow();
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
if (hasUnchecked)
|
|
|
|
SelectAllCB->setChecked(false);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
bool enable = !(myMesh->_is_nil()) && hasChecked;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
buttonOk->setEnabled(enable);
|
|
|
|
buttonApply->setEnabled(enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onDetect()
|
2005-06-07 19:22:20 +06:00
|
|
|
// purpose :
|
2004-12-01 15:48:31 +05:00
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::onDetect()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myMesh->_is_nil())
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
try {
|
|
|
|
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
|
|
|
|
|
|
|
|
QApplication::setOverrideCursor(Qt::waitCursor);
|
|
|
|
ListCoincident->clear();
|
|
|
|
ListEdit->clear();
|
|
|
|
|
|
|
|
SMESH::array_of_long_array_var aNodeGroups;
|
|
|
|
aMeshEditor->FindCoincidentNodes(SpinBoxTolerance->GetValue(), aNodeGroups);
|
|
|
|
|
|
|
|
for (int i = 0; i < aNodeGroups->length(); i++) {
|
|
|
|
SMESH::long_array& aGroup = aNodeGroups[i];
|
|
|
|
|
|
|
|
QString aNodeIds;
|
|
|
|
for (int j = 0; j < aGroup.length(); j++)
|
|
|
|
aNodeIds+=QString(" %1").arg(aGroup[j]);
|
|
|
|
|
|
|
|
new QCheckListItem (ListCoincident, aNodeIds, QCheckListItem::CheckBox);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
} catch(...) {
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
updateControls();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onSelectNodesGroup()
|
2005-06-07 19:22:20 +06:00
|
|
|
// purpose :
|
2004-12-01 15:48:31 +05:00
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::onSelectNodesGroup()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!myActor)
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
myEditCurrentArgument = (QWidget*)ListCoincident;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
QListViewItem* aSelectedItem = ListCoincident->selectedItem();
|
|
|
|
if (!aSelectedItem)
|
|
|
|
return;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
QStringList aListId = QStringList::split(" ", aSelectedItem->text(0), false);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
ListEdit->clear();
|
|
|
|
ListEdit->insertStringList(aListId);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
//mySelectionMgr->clearSelected();
|
|
|
|
//mySelectionMgr->AddIObject(myActor->getIO());
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
aList.Append(myActor->getIO());
|
|
|
|
mySelectionMgr->setSelectedObjects(aList, false);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::SetPointRepresentation(true);
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(NodeSelection);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
ListEdit->selectAll(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onSelectAll()
|
2005-06-07 19:22:20 +06:00
|
|
|
// purpose :
|
2004-12-01 15:48:31 +05:00
|
|
|
//=================================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_MergeNodesDlg::onSelectAll (bool isToggled)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (isToggled) {
|
|
|
|
int aNbItems = 0;
|
|
|
|
QListViewItem* item = ListCoincident->firstChild();
|
|
|
|
while (item) {
|
|
|
|
aNbItems++;
|
|
|
|
if (!((QCheckListItem*) item)->isOn())
|
|
|
|
((QCheckListItem*) item)->setOn(true);
|
|
|
|
item = item->itemBelow();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if (aNbItems) {
|
|
|
|
buttonOk->setEnabled(true);
|
|
|
|
buttonApply->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onSelectNodesFromGroup()
|
2005-06-07 19:22:20 +06:00
|
|
|
// purpose :
|
2004-12-01 15:48:31 +05:00
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::onSelectNodesFromGroup()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!myActor)
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
TColStd_MapOfInteger aIndexes;
|
|
|
|
QListBoxItem* anItem;
|
|
|
|
for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next()) {
|
|
|
|
if (anItem->isSelected()) {
|
|
|
|
int anId = anItem->text().toInt();
|
|
|
|
aIndexes.Add(anId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
aList.Append(myActor->getIO());
|
|
|
|
mySelectionMgr->setSelectedObjects(aList);
|
|
|
|
}
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onAdd()
|
2005-06-07 19:22:20 +06:00
|
|
|
// purpose :
|
2004-12-01 15:48:31 +05:00
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::onAdd()
|
|
|
|
{
|
|
|
|
if (!myActor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
QString aListStr = "";
|
|
|
|
int aNbNnodes = 0;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
aNbNnodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
|
2004-12-01 15:48:31 +05:00
|
|
|
if (aNbNnodes < 1)
|
|
|
|
return;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
QStringList aNodes = QStringList::split(" ", aListStr);
|
|
|
|
QListBoxItem* anItem = 0;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
for (QStringList::iterator it = aNodes.begin(); it != aNodes.end(); ++it) {
|
|
|
|
anItem = ListEdit->findItem(*it, Qt::ExactMatch);
|
|
|
|
if (!anItem) {
|
|
|
|
anItem = new QListBoxText(*it);
|
|
|
|
ListEdit->insertItem(anItem);
|
|
|
|
}
|
|
|
|
ListEdit->setSelected(anItem, true);
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
onEditNodesGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onRemove()
|
2005-06-07 19:22:20 +06:00
|
|
|
// purpose :
|
2004-12-01 15:48:31 +05:00
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::onRemove()
|
|
|
|
{
|
|
|
|
if (myEditCurrentArgument != (QWidget*)ListCoincident)
|
|
|
|
return;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
for (int i = ListEdit->count(); i > 0; i--) {
|
|
|
|
if (ListEdit->isSelected(i-1))
|
|
|
|
ListEdit->removeItem(i-1);
|
|
|
|
}
|
2004-12-01 15:48:31 +05:00
|
|
|
onEditNodesGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SetEditCurrentArgument()
|
2005-06-07 19:22:20 +06:00
|
|
|
// purpose :
|
2004-12-01 15:48:31 +05:00
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::SetEditCurrentArgument()
|
|
|
|
{
|
|
|
|
QPushButton* send = (QPushButton*)sender();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
disconnect(mySelectionMgr, 0, this, 0);
|
|
|
|
mySelectionMgr->clearSelected();
|
|
|
|
mySelectionMgr->clearFilters();
|
|
|
|
|
|
|
|
if (send == SelectMeshButton) {
|
|
|
|
myEditCurrentArgument = (QWidget*)LineEditMesh;
|
|
|
|
SMESH::SetPointRepresentation(false);
|
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(myMeshOrSubMeshFilter);
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
myEditCurrentArgument->setFocus();
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
|
|
|
|
SelectionIntoArgument();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SelectionIntoArgument()
|
|
|
|
// purpose : Called when selection as changed or other case
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::SelectionIntoArgument()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myEditCurrentArgument == (QWidget*)LineEditMesh) {
|
|
|
|
QString aString = "";
|
|
|
|
LineEditMesh->setText(aString);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
ListCoincident->clear();
|
|
|
|
ListEdit->clear();
|
|
|
|
|
|
|
|
int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
|
|
|
|
if (nbSel != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
|
|
|
|
|
|
|
|
Handle(SALOME_InteractiveObject) IO = aList.First();
|
|
|
|
myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
|
|
|
|
myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
|
|
|
|
if (myMesh->_is_nil() || !myActor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
LineEditMesh->setText(aString);
|
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : DeactivateActiveDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::DeactivateActiveDialog()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (GroupConstructors->isEnabled()) {
|
|
|
|
GroupConstructors->setEnabled(false);
|
2004-12-01 15:48:31 +05:00
|
|
|
GroupMesh->setEnabled(false);
|
|
|
|
GroupCoincident->setEnabled(false);
|
|
|
|
GroupEdit->setEnabled(false);
|
2005-06-07 19:22:20 +06:00
|
|
|
GroupButtons->setEnabled(false);
|
|
|
|
mySMESHGUI->ResetState();
|
|
|
|
mySMESHGUI->SetActiveDialogBox(0);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ActivateThisDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeNodesDlg::ActivateThisDialog()
|
|
|
|
{
|
|
|
|
/* Emit a signal to deactivate the active dialog */
|
2005-06-07 19:22:20 +06:00
|
|
|
mySMESHGUI->EmitSignalDeactivateDialog();
|
|
|
|
GroupConstructors->setEnabled(true);
|
2004-12-01 15:48:31 +05:00
|
|
|
GroupMesh->setEnabled(true);
|
|
|
|
GroupCoincident->setEnabled(true);
|
|
|
|
GroupEdit->setEnabled(true);
|
2005-06-07 19:22:20 +06:00
|
|
|
GroupButtons->setEnabled(true);
|
|
|
|
|
|
|
|
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
SelectionIntoArgument();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_MergeNodesDlg::enterEvent (QEvent*)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!GroupConstructors->isEnabled())
|
|
|
|
ActivateThisDialog();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : closeEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_MergeNodesDlg::closeEvent (QCloseEvent*)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
/* same than click on cancel button */
|
2005-06-07 19:22:20 +06:00
|
|
|
ClickOnCancel();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
//function : hideEvent()
|
2004-12-01 15:48:31 +05:00
|
|
|
//purpose : caused by ESC key
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_MergeNodesDlg::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
|
|
|
ClickOnCancel();
|
|
|
|
}
|