X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_EditMeshDlg.cxx;h=c8aa3710d2feee3cbab5bfc885446167c9a7096b;hp=c53ac988a5638e9836a4b463c69fe75c5b40ac6c;hb=0635c9fc80f67d1e5dc0e94ec85f487286a92070;hpb=79b1ac2b6df9117f16f11d444b1f165d477a1813 diff --git a/src/SMESHGUI/SMESHGUI_EditMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_EditMeshDlg.cxx index c53ac988a..c8aa3710d 100644 --- a/src/SMESHGUI/SMESHGUI_EditMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_EditMeshDlg.cxx @@ -1,62 +1,66 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE // -// 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 +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// SMESH SMESHGUI : GUI for SMESH component +// File : SMESHGUI_EditMeshDlg.cxx +// Author : Open CASCADE S.A.S. +// SMESH includes // - #include "SMESHGUI_EditMeshDlg.h" #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" -#include "SMESHGUI_IdValidator.h" -#include "SMESHGUI_SpinBox.h" - -#include "SMESH_Actor.h" -#include "SMESH_TypeFilter.hxx" -#include "SMESH_LogicalFilter.hxx" #include "SMESHGUI_MeshUtils.h" -#include "SMDS_Mesh.hxx" - -#include "GEOMBase.h" +#include "SMESHGUI_SpinBox.h" -#include "SUIT_ResourceMgr.h" -#include "SUIT_Session.h" -#include "SUIT_MessageBox.h" +#include +#include +#include +#include -#include "LightApp_Application.h" +// SALOME GUI includes +#include +#include +#include +#include +#include -#include "SVTK_ViewModel.h" -#include "SVTK_ViewWindow.h" -#include "SVTK_Selector.h" -#include "SVTK_Selection.h" -#include "SALOME_ListIO.hxx" +#include +#include -#include "utilities.h" +#include +#include +#include -// OCCT Includes -#include +// OCCT includes #include #include -//IDL Headers +// IDL includes +#include #include CORBA_SERVER_HEADER(SMESH_Group) +#include CORBA_SERVER_HEADER(SMESH_MeshEditor) -// VTK Includes +// VTK includes #include #include #include @@ -67,29 +71,31 @@ #include #include #include -#include #include #include -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace SMESH { - class TIdPreview { // to display in the viewer IDs of the selected elements +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SPACING 6 +#define MARGIN 11 + +namespace SMESH +{ + class TIdPreview + { // to display in the viewer IDs of the selected elements SVTK_ViewWindow* myViewWindow; vtkUnstructuredGrid* myIdGrid; @@ -103,7 +109,7 @@ namespace SMESH { bool myIsPointsLabeled; vtkActor2D* myPointLabels; - vector myIDs; + std::vector myIDs; public: TIdPreview(SVTK_ViewWindow* theViewWindow): @@ -184,7 +190,7 @@ namespace SMESH { } void SetElemsData( TColStd_MapOfInteger & theElemsIdMap, - list & aGrCentersXYZ ) + std::list & aGrCentersXYZ ) { vtkPoints* aPoints = vtkPoints::New(); aPoints->SetNumberOfPoints(theElemsIdMap.Extent()); @@ -196,7 +202,7 @@ namespace SMESH { } gp_XYZ aXYZ; - list::iterator coordIt = aGrCentersXYZ.begin(); + std::list::iterator coordIt = aGrCentersXYZ.begin(); for( int i = 0; coordIt != aGrCentersXYZ.end(); coordIt++, i++ ) { aXYZ = *coordIt; aPoints->SetPoint( i, aXYZ.X(), aXYZ.Y(), aXYZ.Z() ); @@ -295,13 +301,14 @@ static const char * IconFirst[] = { //================================================================================= SMESHGUI_EditMeshDlg::SMESHGUI_EditMeshDlg (SMESHGUI* theModule, int theAction) - : QDialog(SMESH::GetDesktop(theModule), "SMESHGUI_EditMeshDlg", false, WStyle_Customize | - WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + : QDialog(SMESH::GetDesktop(theModule)), mySMESHGUI(theModule), mySelectionMgr(SMESH::GetSelectionMgr(theModule)), myAction(theAction) { - setCaption(tr("SMESH_MERGE_NODES")); + setModal(false); + setAttribute(Qt::WA_DeleteOnClose, true); + setWindowTitle(myAction == 1 ? tr("SMESH_MERGE_ELEMENTS") : tr("SMESH_MERGE_NODES")); myIdPreview = new SMESH::TIdPreview(SMESH::GetViewWindow( mySMESHGUI )); @@ -312,175 +319,145 @@ SMESHGUI_EditMeshDlg::SMESHGUI_EditMeshDlg (SMESHGUI* theModule, QPixmap IconAdd (aResMgr->loadPixmap("SMESH", tr("ICON_APPEND"))); QPixmap IconRemove (aResMgr->loadPixmap("SMESH", tr("ICON_REMOVE"))); - setSizeGripEnabled(TRUE); - DlgLayout = new QGridLayout (this); - DlgLayout->setSpacing(6); - DlgLayout->setMargin(11); + setSizeGripEnabled(true); - /***************************************************************/ - GroupConstructors = new QButtonGroup (this, "GroupConstructors"); - 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); - RadioButton = new QRadioButton(GroupConstructors, "RadioButton"); - RadioButton->setPixmap(IconMergeNodes); - if (myAction == 1) RadioButton->setPixmap(IconMergeElems); - RadioButton->setChecked(TRUE); - GroupConstructorsLayout->addWidget(RadioButton, 0, 0); - DlgLayout->addWidget(GroupConstructors, 0, 0); + QVBoxLayout* DlgLayout = new QVBoxLayout(this); + DlgLayout->setSpacing(SPACING); + DlgLayout->setMargin(MARGIN); /***************************************************************/ - GroupButtons = new QGroupBox (this, "GroupButtons"); - 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); - buttonHelp = new QPushButton(GroupButtons, "buttonHelp"); - buttonHelp->setText(tr("SMESH_BUT_HELP" )); - buttonHelp->setAutoDefault(TRUE); - GroupButtonsLayout->addWidget(buttonHelp, 0, 4); - 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* spacer3 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - GroupButtonsLayout->addItem(spacer3, 0, 2); - buttonOk = new QPushButton(GroupButtons, "buttonOk"); - buttonOk->setText(tr("SMESH_BUT_OK" )); - buttonOk->setAutoDefault(TRUE); - buttonOk->setDefault(TRUE); - GroupButtonsLayout->addWidget(buttonOk, 0, 0); - DlgLayout->addWidget(GroupButtons, 4, 0); + GroupConstructors = new QGroupBox(myAction == 1 ? + tr("SMESH_MERGE_ELEMENTS") : + tr("SMESH_MERGE_NODES"), + this); + + QButtonGroup* ButtonGroup = new QButtonGroup(this); + QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout(GroupConstructors); + GroupConstructorsLayout->setSpacing(SPACING); + GroupConstructorsLayout->setMargin(MARGIN); + + RadioButton = new QRadioButton(GroupConstructors); + RadioButton->setIcon(myAction == 1 ? IconMergeElems : IconMergeNodes); + RadioButton->setChecked(true); + GroupConstructorsLayout->addWidget(RadioButton); + ButtonGroup->addButton(RadioButton, 0); /***************************************************************/ - // Controls for mesh defining - GroupMesh = new QGroupBox(this, "GroupMesh"); - GroupMesh->setTitle(tr("SMESH_SELECT_WHOLE_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(IconSelect); - GroupMeshLayout->addWidget(SelectMeshButton, 0, 1); - - LineEditMesh = new QLineEdit(GroupMesh, "LineEditMesh"); + GroupMesh = new QGroupBox(tr("SMESH_SELECT_WHOLE_MESH"), this); + QHBoxLayout* GroupMeshLayout = new QHBoxLayout(GroupMesh); + GroupMeshLayout->setSpacing(SPACING); + GroupMeshLayout->setMargin(MARGIN); + + TextLabelName = new QLabel(tr("SMESH_NAME"), GroupMesh); + SelectMeshButton = new QPushButton(GroupMesh); + SelectMeshButton->setIcon(IconSelect); + LineEditMesh = new QLineEdit(GroupMesh); LineEditMesh->setReadOnly(true); - GroupMeshLayout->addWidget(LineEditMesh, 0, 2); - DlgLayout->addWidget(GroupMesh, 1, 0); + GroupMeshLayout->addWidget(TextLabelName); + GroupMeshLayout->addWidget(SelectMeshButton); + GroupMeshLayout->addWidget(LineEditMesh); /***************************************************************/ - // Controls for coincident elements detecting - GroupCoincident = new QGroupBox(this, "GroupCoincident"); - GroupCoincident->setTitle(tr("COINCIDENT_NODES")); - GroupCoincident->setColumnLayout(0, Qt::Vertical); - GroupCoincident->layout()->setSpacing(0); - GroupCoincident->layout()->setMargin(0); - GroupCoincidentLayout = new QGridLayout(GroupCoincident->layout()); - GroupCoincidentLayout->setAlignment(Qt::AlignTop); - GroupCoincidentLayout->setSpacing(6); - GroupCoincidentLayout->setMargin(11); + GroupCoincident = new QGroupBox(myAction == 1 ? + tr("COINCIDENT_ELEMENTS") : + tr("COINCIDENT_NODES"), + this); + + QGridLayout* GroupCoincidentLayout = new QGridLayout(GroupCoincident); + GroupCoincidentLayout->setSpacing(SPACING); + GroupCoincidentLayout->setMargin(MARGIN); if (myAction == 0) { // case merge nodes - TextLabelTolerance = new QLabel(GroupCoincident, "TextLabelTolerance"); - TextLabelTolerance->setText(tr("SMESH_TOLERANCE")); - TextLabelTolerance->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred)); - GroupCoincidentLayout->addWidget(TextLabelTolerance, 0, 0); + TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupCoincident); + SpinBoxTolerance = new SMESHGUI_SpinBox(GroupCoincident); + SpinBoxTolerance->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - SpinBoxTolerance = new SMESHGUI_SpinBox(GroupCoincident, "SpinBoxTolerance"); - GroupCoincidentLayout->addWidget(SpinBoxTolerance, 0, 1); + GroupCoincidentLayout->addWidget(TextLabelTolerance, 0, 0); + GroupCoincidentLayout->addWidget(SpinBoxTolerance, 0, 1); + } + else { + TextLabelTolerance = 0; + SpinBoxTolerance = 0; } - DetectButton = new QPushButton(GroupCoincident, "DetectButton"); - DetectButton->setText(tr("DETECT")); - DetectButton->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum)); - GroupCoincidentLayout->addWidget(DetectButton, 0, 2); - - ListCoincident = new QListBox(GroupCoincident, "ListCoincident"); - ListCoincident->setSelectionMode(QListBox::Extended); - if (myAction == 0) // case merge nodes - GroupCoincidentLayout->addMultiCellWidget(ListCoincident, 1, 3, 0, 1); - else // case merge elements - GroupCoincidentLayout->addMultiCellWidget(ListCoincident, 0, 3, 0, 1); - - QSpacerItem* spacer1 = new QSpacerItem(20, 21, QSizePolicy::Minimum, QSizePolicy::Expanding); - GroupCoincidentLayout->addItem(spacer1, 1, 2); + int row = GroupCoincidentLayout->rowCount(); - AddGroupButton = new QPushButton(GroupCoincident, "AddGroupButton"); - AddGroupButton->setText(tr("SMESH_BUT_ADD")); - GroupCoincidentLayout->addWidget(AddGroupButton, 2, 2); + ListCoincident = new QListWidget(GroupCoincident); + ListCoincident->setSelectionMode(QListWidget::ExtendedSelection); - RemoveGroupButton = new QPushButton(GroupCoincident, "RemoveGroupButton"); - RemoveGroupButton->setText(tr("SMESH_BUT_REMOVE")); - GroupCoincidentLayout->addWidget(RemoveGroupButton, 3, 2); + DetectButton = new QPushButton(tr("DETECT"), GroupCoincident); + AddGroupButton = new QPushButton(tr("SMESH_BUT_ADD"), GroupCoincident); + RemoveGroupButton = new QPushButton(tr("SMESH_BUT_REMOVE"), GroupCoincident); - SelectAllCB = new QCheckBox(GroupCoincident, "SelectAllCB"); - SelectAllCB->setText(tr("SELECT_ALL")); - GroupCoincidentLayout->addWidget(SelectAllCB, 4, 0); + SelectAllCB = new QCheckBox(tr("SELECT_ALL"), GroupCoincident); - DlgLayout->addWidget(GroupCoincident, 2, 0); + GroupCoincidentLayout->addWidget(ListCoincident, row, 0, 4, 2); + GroupCoincidentLayout->addWidget(DetectButton, row, 2); + GroupCoincidentLayout->addWidget(AddGroupButton, row+2, 2); + GroupCoincidentLayout->addWidget(RemoveGroupButton, row+3, 2); + GroupCoincidentLayout->addWidget(SelectAllCB, row+4, 0, 1, 3); + GroupCoincidentLayout->setRowMinimumHeight(row+1, 10); + GroupCoincidentLayout->setRowStretch(row+1, 5); /***************************************************************/ - // Controls for editing the selected group - GroupEdit = new QGroupBox(this, "GroupEdit"); - GroupEdit->setTitle(tr("EDIT_SELECTED_GROUP")); - GroupEdit->setColumnLayout(0, Qt::Vertical); - GroupEdit->layout()->setSpacing(0); - GroupEdit->layout()->setMargin(0); - GroupEditLayout = new QGridLayout(GroupEdit->layout()); - GroupEditLayout->setAlignment(Qt::AlignTop); - GroupEditLayout->setSpacing(6); - GroupEditLayout->setMargin(11); - - ListEdit = new QListBox(GroupEdit, "ListEdit"); - ListEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred)); - ListEdit->setRowMode(QListBox::FixedNumber); - ListEdit->setMinimumHeight(ListEdit->sizeHint().height()); - ListEdit->setHScrollBarMode(QScrollView::AlwaysOn); - ListEdit->setVScrollBarMode(QScrollView::AlwaysOff); - ListEdit->setSelectionMode(QListBox::Extended); - GroupEditLayout->addMultiCellWidget(ListEdit, 0, 1, 0, 0); - - AddElemButton = new QPushButton(GroupEdit, "AddElemButton"); - AddElemButton->setPixmap(IconAdd); - GroupEditLayout->addWidget(AddElemButton, 0, 1); - - RemoveElemButton = new QPushButton(GroupEdit, "RemoveElemButton"); - RemoveElemButton->setPixmap(IconRemove); + GroupEdit = new QGroupBox(tr("EDIT_SELECTED_GROUP"), this); + QGridLayout* GroupEditLayout = new QGridLayout(GroupEdit); + GroupEditLayout->setSpacing(SPACING); + GroupEditLayout->setMargin(MARGIN); + + ListEdit = new QListWidget(GroupEdit); + //ListEdit->setRowMode(QListBox::FixedNumber); + //ListEdit->setHScrollBarMode(QScrollView::AlwaysOn); + //ListEdit->setVScrollBarMode(QScrollView::AlwaysOff); + ListEdit->setFlow( QListView::LeftToRight ); + ListEdit->setSelectionMode(QListWidget::ExtendedSelection); + + AddElemButton = new QPushButton(GroupEdit); + AddElemButton->setIcon(IconAdd); + RemoveElemButton = new QPushButton(GroupEdit); + RemoveElemButton->setIcon(IconRemove); + SetFirstButton = new QPushButton(GroupEdit); + SetFirstButton->setIcon(QPixmap(IconFirst)); + + GroupEditLayout->addWidget(ListEdit, 0, 0, 2, 1); + GroupEditLayout->addWidget(AddElemButton, 0, 1); GroupEditLayout->addWidget(RemoveElemButton, 0, 2); + GroupEditLayout->addWidget(SetFirstButton, 1, 1, 1, 2); - SetFirstButton = new QPushButton(GroupEdit, "SetFirstButton"); - SetFirstButton->setIconSet(QPixmap(IconFirst)); - SetFirstButton->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); - GroupEditLayout->addMultiCellWidget(SetFirstButton, 1, 1, 1, 2); + /***************************************************************/ + GroupButtons = new QGroupBox(this); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons); + GroupButtonsLayout->setSpacing(SPACING); + GroupButtonsLayout->setMargin(MARGIN); + + buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons); + buttonOk->setAutoDefault(true); + buttonOk->setDefault(true); + buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons); + buttonApply->setAutoDefault(true); + buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons); + buttonCancel->setAutoDefault(true); + buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons); + buttonHelp->setAutoDefault(true); + + GroupButtonsLayout->addWidget(buttonOk); + GroupButtonsLayout->addSpacing(10); + GroupButtonsLayout->addWidget(buttonApply); + GroupButtonsLayout->addSpacing(10); + GroupButtonsLayout->addStretch(); + GroupButtonsLayout->addWidget(buttonCancel); + GroupButtonsLayout->addWidget(buttonHelp); - DlgLayout->addWidget(GroupEdit, 3, 0); + /***************************************************************/ + DlgLayout->addWidget(GroupConstructors); + DlgLayout->addWidget(GroupMesh); + DlgLayout->addWidget(GroupCoincident); + DlgLayout->addWidget(GroupEdit); + DlgLayout->addWidget(GroupButtons); Init(); // Initialisations } @@ -491,7 +468,6 @@ SMESHGUI_EditMeshDlg::SMESHGUI_EditMeshDlg (SMESHGUI* theModule, //================================================================================= SMESHGUI_EditMeshDlg::~SMESHGUI_EditMeshDlg() { - // no need to delete child widgets, Qt does it all for us delete myIdPreview; } @@ -502,11 +478,11 @@ SMESHGUI_EditMeshDlg::~SMESHGUI_EditMeshDlg() void SMESHGUI_EditMeshDlg::Init() { if (myAction == 0) { - SpinBoxTolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.1, 3); + SpinBoxTolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, 5); SpinBoxTolerance->SetValue(1e-05); } - RadioButton->setChecked(TRUE); + RadioButton->setChecked(true); myEditCurrentArgument = (QWidget*)LineEditMesh; @@ -522,7 +498,7 @@ void SMESHGUI_EditMeshDlg::Init() SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP); - QPtrList aListOfFilters; + QList aListOfFilters; if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter); if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter); @@ -537,11 +513,11 @@ void SMESHGUI_EditMeshDlg::Init() connect(SelectMeshButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); connect(DetectButton, SIGNAL (clicked()), this, SLOT(onDetect())); - connect(ListCoincident, SIGNAL (selectionChanged()), this, SLOT(onSelectGroup())); + connect(ListCoincident, SIGNAL (itemSelectionChanged()), this, SLOT(onSelectGroup())); connect(AddGroupButton, SIGNAL (clicked()), this, SLOT(onAddGroup())); connect(RemoveGroupButton, SIGNAL (clicked()), this, SLOT(onRemoveGroup())); connect(SelectAllCB, SIGNAL(toggled(bool)), this, SLOT(onSelectAll(bool))); - connect(ListEdit, SIGNAL (selectionChanged()), this, SLOT(onSelectElementFromGroup())); + connect(ListEdit, SIGNAL (itemSelectionChanged()), this, SLOT(onSelectElementFromGroup())); connect(AddElemButton, SIGNAL (clicked()), this, SLOT(onAddElement())); connect(RemoveElemButton, SIGNAL (clicked()), this, SLOT(onRemoveElement())); connect(SetFirstButton, SIGNAL( clicked() ), this, SLOT( onSetFirst() ) ); @@ -551,8 +527,6 @@ void SMESHGUI_EditMeshDlg::Init() /* to close dialog if study change */ connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - this->show(); /* displays Dialog */ - SetFirstButton->setEnabled(false); buttonOk->setEnabled(false); buttonApply->setEnabled(false); @@ -560,13 +534,6 @@ void SMESHGUI_EditMeshDlg::Init() // Init Mesh field from selection SelectionIntoArgument(); - // dialog customization - if (myAction == 1) { - setCaption(tr("SMESH_MERGE_ELEMENTS")); - GroupConstructors->setTitle(tr("SMESH_MERGE_ELEMENTS")); - GroupCoincident->setTitle(tr("COINCIDENT_ELEMENTS")); - } - myHelpFileName = "merging_elements_page.html"; } @@ -575,7 +542,7 @@ void SMESHGUI_EditMeshDlg::Init() // purpose : //================================================================================= void SMESHGUI_EditMeshDlg::FindGravityCenter(TColStd_MapOfInteger & theElemsIdMap, - list< gp_XYZ > & theGrCentersXYZ) + std::list< gp_XYZ > & theGrCentersXYZ) { if (!myActor) return; @@ -615,27 +582,23 @@ bool SMESHGUI_EditMeshDlg::ClickOnApply() return false; try { + SUIT_OverrideCursor aWaitCursor; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - QApplication::setOverrideCursor(Qt::waitCursor); - SMESH::long_array_var anIds = new SMESH::long_array; SMESH::array_of_long_array_var aGroupsOfElements = new SMESH::array_of_long_array; aGroupsOfElements->length(ListCoincident->count()); - QListBoxItem* item = ListCoincident->firstItem(); int anArrayNum = 0; - while (item) { - QStringList aListIds = QStringList(""); - aListIds = QStringList::split(" ", item->text(), false); + for (int i = 0; i < ListCoincident->count(); i++) { + QStringList aListIds = ListCoincident->item(i)->text().split(" ", QString::SkipEmptyParts); anIds->length(aListIds.count()); for (int i = 0; i < aListIds.count(); i++) anIds[i] = aListIds[i].toInt(); aGroupsOfElements[anArrayNum++] = anIds.inout(); - item = item->next(); } if( myAction == 0 ) @@ -643,7 +606,6 @@ bool SMESHGUI_EditMeshDlg::ClickOnApply() else aMeshEditor->MergeElements (aGroupsOfElements.inout()); - QApplication::restoreOverrideCursor(); } catch(...) { } @@ -690,16 +652,17 @@ void SMESHGUI_EditMeshDlg::ClickOnHelp() if (app) app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); else { - QString platform; + QString platform; #ifdef WIN32 - platform = "winapplication"; + platform = "winapplication"; #else - platform = "application"; + platform = "application"; #endif - SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), - QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName), - QObject::tr("BUT_OK")); + SUIT_MessageBox::warning(this, tr("WRN_WARNING"), + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", + platform)). + arg(myHelpFileName)); } } @@ -709,29 +672,20 @@ void SMESHGUI_EditMeshDlg::ClickOnHelp() //================================================================================= void SMESHGUI_EditMeshDlg::onEditGroup() { - int nbSel = 0; - for (int i = 0; i < ListCoincident->count(); i++) { - if (ListCoincident->isSelected(i)) - nbSel++; - if (nbSel > 1) { - ListEdit->clear(); - return; - } - } - if (nbSel == 0) { + QList selItems = ListCoincident->selectedItems(); + if ( selItems.count() != 1 ) { ListEdit->clear(); return; } - QString aNewIds = ""; + QStringList aNewIds; - QListBoxItem* anItem; - for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next()) - aNewIds+=QString(" %1").arg(anItem->text()); + for (int i = 0; i < ListEdit->count(); i++ ) + aNewIds.append(ListEdit->item(i)->text()); - ListCoincident->changeItem(aNewIds, ListCoincident->currentItem()); - ListCoincident->setSelected(ListCoincident->currentItem(), true); - + ListCoincident->clearSelection(); + selItems.first()->setText(aNewIds.join(" ")); + selItems.first()->setSelected(true); } //================================================================================= @@ -757,9 +711,9 @@ void SMESHGUI_EditMeshDlg::onDetect() return; try { + SUIT_OverrideCursor aWaitCursor; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - QApplication::setOverrideCursor(Qt::waitCursor); ListCoincident->clear(); ListEdit->clear(); @@ -780,22 +734,19 @@ void SMESHGUI_EditMeshDlg::onDetect() break; } - QListBoxItem* anItem = 0; for (int i = 0; i < aGroupsArray->length(); i++) { SMESH::long_array& aGroup = aGroupsArray[i]; - QString anIDs; + QStringList anIDs; for (int j = 0; j < aGroup.length(); j++) - anIDs+=QString(" %1").arg(aGroup[j]); + anIDs.append(QString::number(aGroup[j])); - anItem = new QListBoxText(anIDs); - ListCoincident->insertItem(anItem); + ListCoincident->addItem(anIDs.join(" ")); } - QApplication::restoreOverrideCursor(); - } catch(...) { + } catch(...) { } - ListCoincident->selectAll(true); + ListCoincident->selectAll(); updateControls(); } @@ -812,22 +763,23 @@ void SMESHGUI_EditMeshDlg::onSelectGroup() ListEdit->clear(); TColStd_MapOfInteger anIndices; - QListBoxItem* anItem; - int NbOfSelected = 0; - for (anItem = ListCoincident->firstItem(); anItem != 0; anItem = anItem->next()) { - if (anItem->isSelected()) { - QStringList aListIds = QStringList(""); - aListIds = QStringList::split(" ", anItem->text(), false); - for (int i = 0; i < aListIds.count(); i++) - anIndices.Add(aListIds[i].toInt()); - NbOfSelected++; - ListEdit->clear(); - if (NbOfSelected == 1) { - ListEdit->insertStringList(aListIds); - ListEdit->selectAll(true); - } - } + QList selItems = ListCoincident->selectedItems(); + QListWidgetItem* anItem; + QStringList aListIds; + + ListEdit->clear(); + + foreach(anItem, selItems) { + aListIds = anItem->text().split(" ", QString::SkipEmptyParts); + for (int i = 0; i < aListIds.count(); i++) + anIndices.Add(aListIds[i].toInt()); + } + + if (selItems.count() == 1) { + ListEdit->addItems(aListIds); + ListEdit->selectAll(); } + mySelector->AddOrRemoveIndex(myActor->getIO(), anIndices, false); SALOME_ListIO aList; aList.Append(myActor->getIO()); @@ -838,7 +790,7 @@ void SMESHGUI_EditMeshDlg::onSelectGroup() myIdPreview->SetPointsLabeled(!anIndices.IsEmpty(), myActor->GetVisibility()); } else { - list< gp_XYZ > aGrCentersXYZ; + std::list< gp_XYZ > aGrCentersXYZ; FindGravityCenter(anIndices, aGrCentersXYZ); myIdPreview->SetElemsData( anIndices, aGrCentersXYZ); myIdPreview->SetPointsLabeled(!anIndices.IsEmpty(), myActor->GetVisibility()); @@ -853,7 +805,10 @@ void SMESHGUI_EditMeshDlg::onSelectGroup() //================================================================================= void SMESHGUI_EditMeshDlg::onSelectAll (bool isToggled) { - ListCoincident->selectAll(isToggled); + if ( isToggled ) + ListCoincident->selectAll(); + else + ListCoincident->clearSelection(); } //================================================================================= @@ -865,20 +820,14 @@ void SMESHGUI_EditMeshDlg::onSelectElementFromGroup() if (myIsBusy || !myActor) return; - int nbSel = 0; TColStd_MapOfInteger anIndices; - QListBoxItem* anItem; - for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next()) { - if (anItem->isSelected()) { - int anId = anItem->text().toInt(); - anIndices.Add(anId); - nbSel++; - if (nbSel == 1) - SetFirstButton->setEnabled(true); - } - } - if (nbSel == 0 || nbSel > 1) - SetFirstButton->setEnabled(false); + QList selItems = ListEdit->selectedItems(); + QListWidgetItem* anItem; + + foreach(anItem, selItems) + anIndices.Add(anItem->text().toInt()); + + SetFirstButton->setEnabled(selItems.count() == 1); mySelector->AddOrRemoveIndex(myActor->getIO(), anIndices, false); SALOME_ListIO aList; @@ -890,7 +839,7 @@ void SMESHGUI_EditMeshDlg::onSelectElementFromGroup() myIdPreview->SetPointsLabeled(!anIndices.IsEmpty(), myActor->GetVisibility()); } else { - list< gp_XYZ > aGrCentersXYZ; + std::list< gp_XYZ > aGrCentersXYZ; FindGravityCenter(anIndices, aGrCentersXYZ); myIdPreview->SetElemsData(anIndices, aGrCentersXYZ); myIdPreview->SetPointsLabeled(!anIndices.IsEmpty(), myActor->GetVisibility()); @@ -910,16 +859,16 @@ void SMESHGUI_EditMeshDlg::onAddGroup() SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), anIDs); ListCoincident->clearSelection(); - QListBoxItem* anItem = new QListBoxText(anIDs); - ListCoincident->insertItem(anItem); + ListCoincident->addItem(anIDs); int nbGroups = ListCoincident->count(); if (nbGroups) { - ListCoincident->setCurrentItem(nbGroups-1); - ListCoincident->setSelected(nbGroups-1, true); + ListCoincident->setCurrentRow(nbGroups-1); + ListCoincident->item(nbGroups-1)->setSelected(true); } else { - ListCoincident->setCurrentItem(0); - ListCoincident->setSelected(0, true); + // VSR ? this code seems to be never executed!!! + ListCoincident->setCurrentRow(0); + //ListCoincident->setSelected(0, true); // VSR: no items - no selection } updateControls(); @@ -935,9 +884,11 @@ void SMESHGUI_EditMeshDlg::onRemoveGroup() return; myIsBusy = true; - for (int i = ListCoincident->count(); i > 0; i--) - if (ListCoincident->isSelected(i-1)) - ListCoincident->removeItem(i-1); + QList selItems = ListCoincident->selectedItems(); + QListWidgetItem* anItem; + + foreach(anItem, selItems) + delete anItem; ListEdit->clear(); updateControls(); @@ -962,16 +913,19 @@ void SMESHGUI_EditMeshDlg::onAddElement() if (aNbNnodes < 1) return; - QStringList aNodes = QStringList::split(" ", aListStr); - QListBoxItem* anItem = 0; + QStringList aNodes = aListStr.split(" ", QString::SkipEmptyParts); 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); + QList found = ListEdit->findItems(*it, Qt::MatchExactly); + if ( found.count() == 0 ) { + QListWidgetItem* anItem = new QListWidgetItem(*it); + ListEdit->addItem(anItem); + anItem->setSelected(true); + } + else { + QListWidgetItem* anItem; + foreach(anItem, found) anItem->setSelected(true); } - ListEdit->setSelected(anItem, true); } myIsBusy = false; @@ -988,10 +942,12 @@ void SMESHGUI_EditMeshDlg::onRemoveElement() return; myIsBusy = true; - for (int i = ListEdit->count(); i > 0; i--) - if (ListEdit->isSelected(i-1)) - ListEdit->removeItem(i-1); + QList selItems = ListEdit->selectedItems(); + QListWidgetItem* anItem; + foreach(anItem, selItems) + delete anItem; + myIsBusy = false; onEditGroup(); } @@ -1006,12 +962,12 @@ void SMESHGUI_EditMeshDlg::onSetFirst() return; myIsBusy = true; - QListBoxItem* anItem; - for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next()) { - if (anItem->isSelected()) { - ListEdit->takeItem(anItem); - ListEdit->insertItem(anItem, 0); - } + QList selItems = ListEdit->selectedItems(); + QListWidgetItem* anItem; + + foreach(anItem, selItems) { + ListEdit->takeItem(ListEdit->row(anItem)); + ListEdit->insertItem(0, anItem); } myIsBusy = false; @@ -1111,6 +1067,9 @@ void SMESHGUI_EditMeshDlg::DeactivateActiveDialog() mySMESHGUI->ResetState(); mySMESHGUI->SetActiveDialogBox(0); } + + mySelectionMgr->clearSelected(); + disconnect(mySelectionMgr, 0, this, 0); } //================================================================================= @@ -1127,6 +1086,7 @@ void SMESHGUI_EditMeshDlg::ActivateThisDialog() GroupEdit->setEnabled(true); GroupButtons->setEnabled(true); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); mySMESHGUI->SetActiveDialogBox((QDialog*)this); SelectionIntoArgument(); } @@ -1148,7 +1108,7 @@ void SMESHGUI_EditMeshDlg::enterEvent(QEvent*) void SMESHGUI_EditMeshDlg::closeEvent(QCloseEvent*) { /* same than click on cancel button */ - this->ClickOnCancel(); + ClickOnCancel(); } //======================================================================= @@ -1171,9 +1131,8 @@ void SMESHGUI_EditMeshDlg::keyPressEvent( QKeyEvent* e) if ( e->isAccepted() ) return; - if ( e->key() == Key_F1 ) - { - e->accept(); - ClickOnHelp(); - } + if ( e->key() == Qt::Key_F1 ) { + e->accept(); + ClickOnHelp(); + } }