1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SMESHGUI_MultiEditDlg.cxx
21 // Author : Sergey LITONIN, Open CASCADE S.A.S.
25 #include "SMESHGUI_MultiEditDlg.h"
28 #include "SMESHGUI_Filter.h"
29 #include "SMESHGUI_FilterDlg.h"
30 #include "SMESHGUI_Utils.h"
31 #include "SMESHGUI_VTKUtils.h"
32 #include "SMESHGUI_MeshUtils.h"
33 #include "SMESHGUI_FilterUtils.h"
34 #include "SMESHGUI_SpinBox.h"
36 #include <SMESH_Actor.h>
37 #include <SMESH_TypeFilter.hxx>
38 #include <SMDS_Mesh.hxx>
40 // SALOME GUI includes
41 #include <SUIT_ResourceMgr.h>
42 #include <SUIT_Desktop.h>
43 #include <SUIT_Session.h>
44 #include <SUIT_MessageBox.h>
46 #include <LightApp_SelectionMgr.h>
47 #include <LightApp_Application.h>
48 #include <SALOME_ListIO.hxx>
49 #include <SALOME_ListIteratorOfListIO.hxx>
51 #include <SVTK_Selector.h>
52 #include <SVTK_ViewWindow.h>
53 #include <VTKViewer_CellLocationsArray.h>
56 #include <TColStd_IndexedMapOfInteger.hxx>
57 #include <TColStd_DataMapOfIntegerInteger.hxx>
58 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
61 #include <vtkIdList.h>
62 #include <vtkCellArray.h>
63 #include <vtkUnsignedCharArray.h>
64 #include <vtkUnstructuredGrid.h>
65 #include <vtkDataSetMapper.h>
66 #include <vtkProperty.h>
70 #include <QVBoxLayout>
71 #include <QHBoxLayout>
72 #include <QGridLayout>
73 #include <QListWidget>
78 #include <QPushButton>
79 #include <QButtonGroup>
80 #include <QRadioButton>
84 #include <SALOMEconfig.h>
85 #include CORBA_SERVER_HEADER(SMESH_Group)
91 * Class : SMESHGUI_MultiEditDlg
92 * Description : Description : Inversion of the diagonal of a pseudo-quadrangle formed by
93 * 2 neighboring triangles with 1 common edge
96 //=======================================================================
97 // name : SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg
98 // Purpose : Constructor
99 //=======================================================================
100 SMESHGUI_MultiEditDlg
101 ::SMESHGUI_MultiEditDlg(SMESHGUI* theModule,
104 QDialog(SMESH::GetDesktop(theModule)),
105 mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
106 mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
107 mySMESHGUI(theModule)
110 setAttribute(Qt::WA_DeleteOnClose, true);
115 myFilterType = theMode;
116 QVBoxLayout* aDlgLay = new QVBoxLayout(this);
117 aDlgLay->setMargin(MARGIN);
118 aDlgLay->setSpacing(SPACING);
120 QWidget* aMainFrame = createMainFrame (this, the3d2d);
121 QWidget* aBtnFrame = createButtonFrame(this);
123 aDlgLay->addWidget(aMainFrame);
124 aDlgLay->addWidget(aBtnFrame);
129 //=======================================================================
130 // name : SMESHGUI_MultiEditDlg::createMainFrame
131 // Purpose : Create frame containing dialog's input fields
132 //=======================================================================
133 QWidget* SMESHGUI_MultiEditDlg::createMainFrame (QWidget* theParent, const bool the3d2d)
135 QWidget* aMainGrp = new QWidget(theParent);
136 QVBoxLayout* aMainGrpLayout = new QVBoxLayout(aMainGrp);
137 aMainGrpLayout->setMargin(0);
138 aMainGrpLayout->setSpacing(SPACING);
140 QPixmap aPix (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
142 // "Selected cells" group
143 mySelGrp = new QGroupBox(aMainGrp);
145 QGridLayout* mySelGrpLayout = new QGridLayout(mySelGrp);
146 mySelGrpLayout->setMargin(MARGIN);
147 mySelGrpLayout->setSpacing(SPACING);
151 QGroupBox* aEntityTypeGrp = new QGroupBox(tr("SMESH_ELEMENTS_TYPE"), mySelGrp);
152 myEntityTypeGrp = new QButtonGroup(mySelGrp);
153 QHBoxLayout* aEntityLayout = new QHBoxLayout(aEntityTypeGrp);
154 aEntityLayout->setMargin(MARGIN);
155 aEntityLayout->setSpacing(SPACING);
157 QRadioButton* aFaceRb = new QRadioButton(tr("SMESH_FACE"), aEntityTypeGrp);
158 QRadioButton* aVolumeRb = new QRadioButton(tr("SMESH_VOLUME"), aEntityTypeGrp);
160 aEntityLayout->addWidget(aFaceRb);
161 aEntityLayout->addWidget(aVolumeRb);
163 myEntityTypeGrp->addButton(aFaceRb, 0);
164 myEntityTypeGrp->addButton(aVolumeRb, 1);
165 aFaceRb->setChecked(true);
166 myEntityType = myEntityTypeGrp->checkedId();
168 mySelGrpLayout->addWidget(aEntityTypeGrp, 0, 0, 1, 2);
171 myListBox = new QListWidget(mySelGrp);
172 myListBox->setSelectionMode(QListWidget::ExtendedSelection);
173 myListBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
174 myListBox->installEventFilter(this);
176 myFilterBtn = new QPushButton(tr("FILTER"), mySelGrp);
177 myAddBtn = new QPushButton(tr("ADD"), mySelGrp);
178 myRemoveBtn = new QPushButton(tr("REMOVE"), mySelGrp);
179 mySortBtn = new QPushButton(tr("SORT_LIST"), mySelGrp);
181 int row = mySelGrpLayout->rowCount();
182 mySelGrpLayout->addWidget(myListBox, row, 0, 6, 1);
183 mySelGrpLayout->addWidget(myFilterBtn, row, 1);
184 mySelGrpLayout->addWidget(myAddBtn, row+2, 1);
185 mySelGrpLayout->addWidget(myRemoveBtn, row+3, 1);
186 mySelGrpLayout->addWidget(mySortBtn, row+5, 1);
187 mySelGrpLayout->setRowMinimumHeight(row+1, 10);
188 mySelGrpLayout->setRowMinimumHeight(row+4, 10);
189 mySelGrpLayout->setRowStretch(row+1, 5);
190 mySelGrpLayout->setRowStretch(row+4, 5);
192 myToAllChk = new QCheckBox(tr("TO_ALL"), mySelGrp);
193 mySelGrpLayout->addWidget(myToAllChk, mySelGrpLayout->rowCount(), 0,
194 1, mySelGrpLayout->columnCount());
196 // Split/Join criterion group
197 myCriterionGrp = new QGroupBox(tr("SPLIT_JOIN_CRITERION"), aMainGrp);
198 QVBoxLayout* aCriterionLayout = new QVBoxLayout(myCriterionGrp);
199 aCriterionLayout->setMargin(MARGIN);
200 aCriterionLayout->setSpacing(SPACING);
202 myChoiceWidget = new QWidget(myCriterionGrp);
203 myGroupChoice = new QButtonGroup(myChoiceWidget);
204 QVBoxLayout* aGroupChoiceLayout = new QVBoxLayout(myChoiceWidget);
205 aGroupChoiceLayout->setMargin(0);
206 aGroupChoiceLayout->setSpacing(SPACING);
208 QRadioButton* aDiag13RB = new QRadioButton(tr("USE_DIAGONAL_1_3"), myChoiceWidget);
209 QRadioButton* aDiag24RB = new QRadioButton(tr("USE_DIAGONAL_2_4"), myChoiceWidget);
210 QRadioButton* aNumFuncRB = new QRadioButton(tr("USE_NUMERIC_FUNC"), myChoiceWidget);
212 aGroupChoiceLayout->addWidget(aDiag13RB);
213 aGroupChoiceLayout->addWidget(aDiag24RB);
214 aGroupChoiceLayout->addWidget(aNumFuncRB);
215 myGroupChoice->addButton(aDiag13RB, 0);
216 myGroupChoice->addButton(aDiag24RB, 1);
217 myGroupChoice->addButton(aNumFuncRB, 2);
218 aDiag13RB->setChecked(true);
220 myComboBoxFunctor = new QComboBox(myCriterionGrp);
221 myComboBoxFunctor->addItem(tr("ASPECTRATIO_ELEMENTS"));
222 myComboBoxFunctor->addItem(tr("MINIMUMANGLE_ELEMENTS"));
223 myComboBoxFunctor->addItem(tr("SKEW_ELEMENTS"));
224 myComboBoxFunctor->addItem(tr("AREA_ELEMENTS"));
225 //myComboBoxFunctor->addItem(tr("LENGTH2D_EDGES")); // for existing elements only
226 //myComboBoxFunctor->addItem(tr("MULTI2D_BORDERS")); // for existing elements only
227 myComboBoxFunctor->setCurrentIndex(0);
229 aCriterionLayout->addWidget(myChoiceWidget);
230 aCriterionLayout->addWidget(myComboBoxFunctor);
232 myCriterionGrp->hide();
233 myChoiceWidget->hide();
234 myComboBoxFunctor->setEnabled(false);
236 // "Select from" group
237 QGroupBox* aGrp = new QGroupBox(tr("SELECT_FROM"), aMainGrp);
238 QGridLayout* aGrpLayout = new QGridLayout(aGrp);
239 aGrpLayout->setMargin(MARGIN);
240 aGrpLayout->setSpacing(SPACING);
242 mySubmeshChk = new QCheckBox(tr("SMESH_SUBMESH"), aGrp);
243 mySubmeshBtn = new QPushButton(aGrp);
244 mySubmesh = new QLineEdit(aGrp);
245 mySubmesh->setReadOnly(true);
246 mySubmeshBtn->setIcon(aPix);
248 myGroupChk = new QCheckBox(tr("SMESH_GROUP"), aGrp);
249 myGroupBtn = new QPushButton(aGrp);
250 myGroup = new QLineEdit(aGrp);
251 myGroup->setReadOnly(true);
252 myGroupBtn->setIcon(aPix);
254 aGrpLayout->addWidget(mySubmeshChk);
255 aGrpLayout->addWidget(mySubmeshBtn);
256 aGrpLayout->addWidget(mySubmesh);
257 aGrpLayout->addWidget(myGroupChk);
258 aGrpLayout->addWidget(myGroupBtn);
259 aGrpLayout->addWidget(myGroup);
261 aMainGrpLayout->addWidget(mySelGrp);
262 aMainGrpLayout->addWidget(myCriterionGrp);
263 aMainGrpLayout->addWidget(aGrp);
268 //=======================================================================
269 // name : SMESHGUI_MultiEditDlg::createButtonFrame
270 // Purpose : Create frame containing buttons
271 //=======================================================================
272 QWidget* SMESHGUI_MultiEditDlg::createButtonFrame (QWidget* theParent)
274 QGroupBox* aFrame = new QGroupBox(theParent);
276 myOkBtn = new QPushButton (tr("SMESH_BUT_OK" ), aFrame);
277 myApplyBtn = new QPushButton (tr("SMESH_BUT_APPLY"), aFrame);
278 myCloseBtn = new QPushButton (tr("SMESH_BUT_CLOSE"), aFrame);
279 myHelpBtn = new QPushButton (tr("SMESH_BUT_HELP"), aFrame);
281 QHBoxLayout* aLay = new QHBoxLayout (aFrame);
282 aLay->setMargin(MARGIN);
283 aLay->setSpacing(SPACING);
285 aLay->addWidget(myOkBtn);
286 aLay->addSpacing(10);
287 aLay->addWidget(myApplyBtn);
288 aLay->addSpacing(10);
290 aLay->addWidget(myCloseBtn);
291 aLay->addWidget(myHelpBtn);
296 //=======================================================================
297 // name : SMESHGUI_MultiEditDlg::isValid
298 // Purpose : Verify validity of input data
299 //=======================================================================
300 bool SMESHGUI_MultiEditDlg::isValid (const bool /*theMess*/) const
302 return (!myMesh->_is_nil() &&
303 (myListBox->count() > 0 || (myToAllChk->isChecked() && myActor)));
306 //=======================================================================
307 // name : SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg
308 // Purpose : Destructor
309 //=======================================================================
310 SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg()
312 if (myFilterDlg != 0)
314 myFilterDlg->setParent(0);
319 //=======================================================================
320 // name : SMESHGUI_MultiEditDlg::eventFilter
321 // Purpose : event filter
322 //=======================================================================
323 bool SMESHGUI_MultiEditDlg::eventFilter (QObject* object, QEvent* event)
325 if (object == myListBox && event->type() == QEvent::KeyPress) {
326 QKeyEvent* ke = (QKeyEvent*)event;
327 if (ke->key() == Qt::Key_Delete)
330 return QDialog::eventFilter(object, event);
333 //=======================================================================
334 // name : SMESHGUI_MultiEditDlg::getNumericalFunctor
336 //=======================================================================
337 SMESH::NumericalFunctor_ptr SMESHGUI_MultiEditDlg::getNumericalFunctor()
339 SMESH::NumericalFunctor_var aNF = SMESH::NumericalFunctor::_nil();
341 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
342 if (aFilterMgr->_is_nil())
345 if (myComboBoxFunctor->currentText() == tr("ASPECTRATIO_ELEMENTS"))
346 aNF = aFilterMgr->CreateAspectRatio();
347 else if (myComboBoxFunctor->currentText() == tr("WARP_ELEMENTS"))
348 aNF = aFilterMgr->CreateWarping();
349 else if (myComboBoxFunctor->currentText() == tr("MINIMUMANGLE_ELEMENTS"))
350 aNF = aFilterMgr->CreateMinimumAngle();
351 else if (myComboBoxFunctor->currentText() == tr("TAPER_ELEMENTS"))
352 aNF = aFilterMgr->CreateTaper();
353 else if (myComboBoxFunctor->currentText() == tr("SKEW_ELEMENTS"))
354 aNF = aFilterMgr->CreateSkew();
355 else if (myComboBoxFunctor->currentText() == tr("AREA_ELEMENTS"))
356 aNF = aFilterMgr->CreateArea();
357 else if (myComboBoxFunctor->currentText() == tr("LENGTH2D_EDGES"))
358 aNF = aFilterMgr->CreateLength2D();
359 else if (myComboBoxFunctor->currentText() == tr("MULTI2D_BORDERS"))
360 aNF = aFilterMgr->CreateMultiConnection2D();
366 //=======================================================================
367 // name : SMESHGUI_MultiEditDlg::Init
368 // Purpose : Init dialog fields, connect signals and slots, show dialog
369 //=======================================================================
370 void SMESHGUI_MultiEditDlg::Init()
372 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
377 emit ListContensChanged();
380 connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
381 connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
382 connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
383 connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
385 // selection and SMESHGUI
386 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
387 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
388 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
391 connect(myFilterBtn, SIGNAL(clicked()), SLOT(onFilterBtn() ));
392 connect(myAddBtn, SIGNAL(clicked()), SLOT(onAddBtn() ));
393 connect(myRemoveBtn, SIGNAL(clicked()), SLOT(onRemoveBtn() ));
394 connect(mySortBtn, SIGNAL(clicked()), SLOT(onSortListBtn()));
396 connect(mySubmeshChk, SIGNAL(stateChanged(int)), SLOT(onSubmeshChk()));
397 connect(myGroupChk, SIGNAL(stateChanged(int)), SLOT(onGroupChk() ));
398 connect(myToAllChk, SIGNAL(stateChanged(int)), SLOT(onToAllChk() ));
401 connect(myEntityTypeGrp, SIGNAL(buttonClicked(int)), SLOT(on3d2dChanged(int)));
403 connect(myListBox, SIGNAL(selectionChanged()), SLOT(onListSelectionChanged()));
407 // set selection mode
412 //=======================================================================
413 // name : SMESHGUI_MultiEditDlg::onOk
414 // Purpose : SLOT called when "Ok" button pressed.
415 // Assign filters VTK viewer and close dialog
416 //=======================================================================
417 void SMESHGUI_MultiEditDlg::onOk()
423 //=======================================================================
424 // name : SMESHGUI_MultiEditDlg::getIds
425 // Purpose : Retrive identifiers from list box
426 //=======================================================================
427 SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds()
429 SMESH::long_array_var anIds = new SMESH::long_array;
431 if (myToAllChk->isChecked())
434 SMESH_Actor * anActor = SMESH::FindActorByObject(myMesh);
440 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
441 if( myFilterType == SMESH::TriaFilter ||
442 myFilterType == SMESH::QuadFilter ||
443 myFilterType == SMESH::FaceFilter ) {
444 SMDS_FaceIteratorPtr it = aMesh->facesIterator();
446 const SMDS_MeshFace* f = it->next();
447 if(myFilterType == SMESH::FaceFilter) {
448 myIds.Add(f->GetID());
450 else if( myFilterType==SMESH::TriaFilter &&
451 ( f->NbNodes()==3 || f->NbNodes()==6 ) ) {
452 myIds.Add(f->GetID());
454 else if( myFilterType==SMESH::QuadFilter &&
455 ( f->NbNodes()==4 || f->NbNodes()==8 ) ) {
456 myIds.Add(f->GetID());
460 else if(myFilterType == SMESH::VolumeFilter) {
461 SMDS_VolumeIteratorPtr it = aMesh->volumesIterator();
463 const SMDS_MeshVolume* f = it->next();
464 myIds.Add(f->GetID());
467 /* commented by skl 07.02.2006
468 TVisualObjPtr aVisualObj = anActor->GetObject();
469 vtkUnstructuredGrid* aGrid = aVisualObj->GetUnstructuredGrid();
471 for (int i = 0, n = aGrid->GetNumberOfCells(); i < n; i++) {
472 vtkCell* aCell = aGrid->GetCell(i);
474 vtkTriangle* aTri = vtkTriangle::SafeDownCast(aCell);
475 vtkQuad* aQua = vtkQuad::SafeDownCast(aCell);
476 vtkPolygon* aPG = vtkPolygon::SafeDownCast(aCell);
478 vtkCell3D* a3d = vtkCell3D::SafeDownCast(aCell);
479 vtkConvexPointSet* aPH = vtkConvexPointSet::SafeDownCast(aCell);
481 if (aTri && myFilterType == SMESHGUI_TriaFilter ||
482 aQua && myFilterType == SMESHGUI_QuadFilter ||
483 (aTri || aQua || aPG) && myFilterType == SMESHGUI_FaceFilter ||
484 (a3d || aPH) && myFilterType == SMESHGUI_VolumeFilter) {
485 int anObjId = aVisualObj->GetElemObjId(i);
495 anIds->length(myIds.Extent());
496 TColStd_MapIteratorOfMapOfInteger anIter(myIds);
497 for (int i = 0; anIter.More(); anIter.Next() )
499 anIds[ i++ ] = anIter.Key();
501 return anIds._retn();
504 //=======================================================================
505 // name : SMESHGUI_MultiEditDlg::onClose
506 // Purpose : SLOT called when "Close" button pressed. Close dialog
507 //=======================================================================
508 void SMESHGUI_MultiEditDlg::onClose()
510 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
511 aViewWindow->SetSelectionMode(ActorSelection);
512 disconnect(mySelectionMgr, 0, this, 0);
513 disconnect(mySMESHGUI, 0, this, 0);
514 mySMESHGUI->ResetState();
516 SMESH::RemoveFilters();
517 SMESH::SetPickable();
519 //mySelectionMgr->clearSelected();
520 mySelectionMgr->clearFilters();
525 //=================================================================================
526 // function : onHelp()
528 //=================================================================================
529 void SMESHGUI_MultiEditDlg::onHelp()
531 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
533 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
537 platform = "winapplication";
539 platform = "application";
541 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
542 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
543 arg(app->resourceMgr()->stringValue("ExternalBrowser",
545 arg(myHelpFileName));
549 //=======================================================================
550 // name : SMESHGUI_MultiEditDlg::onSelectionDone
551 // Purpose : SLOT called when selection changed
552 //=======================================================================
553 void SMESHGUI_MultiEditDlg::onSelectionDone()
555 if (myBusy || !isEnabled()) return;
558 const SALOME_ListIO& aList = mySelector->StoredIObjects();
560 int nbSel = aList.Extent();
561 myListBox->clearSelection();
563 if (mySubmeshChk->isChecked() || myGroupChk->isChecked()) {
564 QLineEdit* aNameEdit = mySubmeshChk->isChecked() ? mySubmesh : myGroup;
566 Handle(SALOME_InteractiveObject) anIO = aList.First();
568 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
569 anIO.IsNull() ? aNameEdit->clear() : aNameEdit->setText(aName);
571 if (mySubmeshChk->isChecked()) {
572 SMESH::SMESH_subMesh_var aSubMesh =
573 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIO);
574 if (!aSubMesh->_is_nil())
575 myMesh = aSubMesh->GetFather();
577 SMESH::SMESH_GroupBase_var aGroup =
578 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIO);
579 if (!aGroup->_is_nil())
580 myMesh = aGroup->GetMesh();
582 } else if (nbSel > 1) {
583 QString aStr = mySubmeshChk->isChecked() ?
584 tr("SMESH_SUBMESH_SELECTED") : tr("SMESH_GROUP_SELECTED");
585 aNameEdit->setText(aStr.arg(nbSel));
589 } else if (nbSel == 1) {
590 QString aListStr = "";
591 Handle(SALOME_InteractiveObject) anIO = aList.First();
592 int aNbItems = SMESH::GetNameOfSelectedElements(mySelector,anIO,aListStr);
594 QStringList anElements = aListStr.split(" ", QString::SkipEmptyParts);
595 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
596 QList<QListWidgetItem*> items = myListBox->findItems(*it, Qt::MatchExactly);
597 QListWidgetItem* anItem;
598 foreach(anItem, items)
599 anItem->setSelected(true);
603 myMesh = SMESH::GetMeshByIO(anIO);
607 myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
609 myActor = SMESH::FindActorByObject(myMesh);
610 SVTK_Selector* aSelector = SMESH::GetSelector();
611 Handle(VTKViewer_Filter) aFilter = aSelector->GetFilter(myFilterType);
612 if (!aFilter.IsNull())
613 aFilter->SetActor(myActor);
620 //=======================================================================
621 // name : SMESHGUI_MultiEditDlg::onDeactivate
622 // Purpose : SLOT called when dialog must be deativated
623 //=======================================================================
624 void SMESHGUI_MultiEditDlg::onDeactivate()
629 //=======================================================================
630 // name : SMESHGUI_MultiEditDlg::enterEvent
631 // Purpose : Event filter
632 //=======================================================================
633 void SMESHGUI_MultiEditDlg::enterEvent (QEvent*)
636 mySMESHGUI->EmitSignalDeactivateDialog();
642 //=======================================================================
643 // name : SMESHGUI_MultiEditDlg::closeEvent
645 //=======================================================================
646 void SMESHGUI_MultiEditDlg::closeEvent (QCloseEvent*)
650 //=======================================================================
651 // name : SMESHGUI_MultiEditDlg::hideEvent
652 // Purpose : caused by ESC key
653 //=======================================================================
654 void SMESHGUI_MultiEditDlg::hideEvent (QHideEvent*)
660 //=======================================================================
661 // name : SMESHGUI_MultiEditDlg::onFilterBtn
662 // Purpose : SLOT. Called when "Filter" button pressed.
663 // Start "Selection filters" dialog
664 //=======================================================================
665 void SMESHGUI_MultiEditDlg::onFilterBtn()
667 if (myFilterDlg == 0) {
668 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, entityType() ? SMESH::VOLUME : SMESH::FACE);
669 connect(myFilterDlg, SIGNAL(Accepted()), SLOT(onFilterAccepted()));
671 myFilterDlg->Init(entityType() ? SMESH::VOLUME : SMESH::FACE);
674 myFilterDlg->SetSelection();
675 myFilterDlg->SetMesh(myMesh);
676 myFilterDlg->SetSourceWg(myListBox);
681 //=======================================================================
682 // name : onFilterAccepted()
683 // Purpose : SLOT. Called when Filter dlg closed with OK button.
684 // Uncheck "Select submesh" and "Select group" checkboxes
685 //=======================================================================
686 void SMESHGUI_MultiEditDlg::onFilterAccepted()
689 for (int i = 0, n = myListBox->count(); i < n; i++)
690 myIds.Add(myListBox->item(i)->text().toInt());
692 emit ListContensChanged();
694 if (mySubmeshChk->isChecked() || myGroupChk->isChecked()) {
695 mySubmeshChk->blockSignals(true);
696 myGroupChk->blockSignals(true);
697 mySubmeshChk->setChecked(false);
698 myGroupChk->setChecked(false);
699 mySubmeshChk->blockSignals(false);
700 myGroupChk->blockSignals(false);
705 //=======================================================================
706 // name : SMESHGUI_MultiEditDlg::isIdValid
707 // Purpose : Verify whether Id of element satisfies to filters from viewer
708 //=======================================================================
709 bool SMESHGUI_MultiEditDlg::isIdValid (const int theId) const
711 SVTK_Selector* aSelector = SMESH::GetSelector();
712 Handle(SMESHGUI_Filter) aFilter =
713 Handle(SMESHGUI_Filter)::DownCast(aSelector->GetFilter(myFilterType));
715 return (!aFilter.IsNull() && aFilter->IsObjValid(theId));
718 //=======================================================================
719 // name : SMESHGUI_MultiEditDlg::onAddBtn
720 // Purpose : SLOT. Called when "Add" button pressed.
721 // Add selected in viewer entities in list box
722 //=======================================================================
723 void SMESHGUI_MultiEditDlg::onAddBtn()
725 const SALOME_ListIO& aList = mySelector->StoredIObjects();
727 int nbSelected = aList.Extent();
731 TColStd_IndexedMapOfInteger toBeAdded;
733 if (!mySubmeshChk->isChecked() && !myGroupChk->isChecked()) {
735 mySelector->GetIndex(aList.First(),toBeAdded);
736 } else if (mySubmeshChk->isChecked()) {
737 SALOME_ListIteratorOfListIO anIter(aList);
738 for ( ; anIter.More(); anIter.Next()) {
739 SMESH::SMESH_subMesh_var aSubMesh =
740 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIter.Value());
741 if (!aSubMesh->_is_nil()) {
742 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
743 SMESH::long_array_var anIds = aSubMesh->GetElementsId();
744 for (int i = 0, n = anIds->length(); i < n; i++) {
745 if (isIdValid(anIds[ i ]))
746 toBeAdded.Add(anIds[ i ]);
751 } else if (myGroupChk->isChecked()) {
752 SALOME_ListIteratorOfListIO anIter(aList);
753 for ( ; anIter.More(); anIter.Next()) {
754 SMESH::SMESH_GroupBase_var aGroup =
755 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value());
756 if (!aGroup->_is_nil() && (aGroup->GetType() == SMESH::FACE &&
757 entityType() == 0 || aGroup->GetType() == SMESH::VOLUME &&
758 entityType() == 1)) {
759 if (aGroup->GetMesh()->GetId() == myMesh->GetId()) {
760 SMESH::long_array_var anIds = aGroup->GetListOfID();
761 for (int i = 0, n = anIds->length(); i < n; i++) {
762 if (isIdValid(anIds[ i ]))
763 toBeAdded.Add(anIds[ i ]);
772 bool isGroupOrSubmesh = (mySubmeshChk->isChecked() || myGroupChk->isChecked());
773 mySubmeshChk->setChecked(false);
774 myGroupChk->setChecked(false);
775 for(int i = 1; i <= toBeAdded.Extent(); i++)
776 if (myIds.Add(toBeAdded(i))) {
777 QListWidgetItem* item = new QListWidgetItem(QString("%1").arg(toBeAdded(i)));
778 myListBox->addItem(item);
779 item->setSelected(true);
783 emit ListContensChanged();
785 if (isGroupOrSubmesh)
786 onListSelectionChanged();
791 //=======================================================================
792 // name : SMESHGUI_MultiEditDlg::updateButtons
793 // Purpose : Enable/disable buttons of dialog in accordance with current state
794 //=======================================================================
795 void SMESHGUI_MultiEditDlg::updateButtons()
797 bool isOk = isValid(false);
798 myOkBtn->setEnabled(isOk);
799 myApplyBtn->setEnabled(isOk);
801 bool isListBoxNonEmpty = myListBox->count() > 0;
802 bool isToAll = myToAllChk->isChecked();
803 myFilterBtn->setEnabled(!isToAll);
804 myRemoveBtn->setEnabled(isListBoxNonEmpty && !isToAll);
805 mySortBtn->setEnabled(isListBoxNonEmpty &&!isToAll);
807 const SALOME_ListIO& aList = mySelector->StoredIObjects();
811 aList.Extent() != 1 ||
812 (SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(aList.First())->_is_nil() &&
813 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(aList.First())->_is_nil() &&
814 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(aList.First())->_is_nil()))
815 myAddBtn->setEnabled(false);
817 myAddBtn->setEnabled(true);
819 mySubmeshChk->setEnabled(!isToAll);
820 mySubmeshBtn->setEnabled(mySubmeshChk->isChecked());
821 mySubmesh->setEnabled(mySubmeshChk->isChecked());
823 myGroupChk->setEnabled(!isToAll);
824 myGroupBtn->setEnabled(myGroupChk->isChecked());
825 myGroup->setEnabled(myGroupChk->isChecked());
827 if (!mySubmeshChk->isChecked())
829 if (!myGroupChk->isChecked())
834 //=======================================================================
835 // name : SMESHGUI_MultiEditDlg::onRemoveBtn
836 // Purpose : SLOT. Called when "Remove" button pressed.
837 // Remove selected in list box entities
838 //=======================================================================
839 void SMESHGUI_MultiEditDlg::onRemoveBtn()
843 QList<QListWidgetItem*> selItems = myListBox->selectedItems();
844 QListWidgetItem* item;
845 foreach(item, selItems)
847 myIds.Remove(item->text().toInt());
853 emit ListContensChanged();
857 //=======================================================================
858 // name : SMESHGUI_MultiEditDlg::onSortListBtn
859 // Purpose : SLOT. Called when "Sort list" button pressed.
860 // Sort entities of list box
861 //=======================================================================
862 void SMESHGUI_MultiEditDlg::onSortListBtn()
866 int i, k = myListBox->count();
869 QList<int> aSelected;
870 std::vector<int> anArray(k);
871 for (i = 0; i < k; i++)
873 int id = myListBox->item(i)->text().toInt();
875 if (myListBox->item(i)->isSelected())
876 aSelected.append(id);
879 std::sort(anArray.begin(), anArray.end());
882 for (i = 0; i < k; i++) {
883 QListWidgetItem* item = new QListWidgetItem(QString::number(anArray[i]));
884 myListBox->addItem(item);
885 item->setSelected(aSelected.contains(anArray[i]));
891 //=======================================================================
892 // name : SMESHGUI_MultiEditDlg::onListSelectionChanged
893 // Purpose : SLOT. Called when selection in list box changed.
894 // Highlight in selected entities
895 //=======================================================================
896 void SMESHGUI_MultiEditDlg::onListSelectionChanged()
898 if (myActor == 0 || myBusy)
901 if (mySubmeshChk->isChecked() || myGroupChk->isChecked())
904 SMESH_Actor * anActor = SMESH::FindActorByObject(myMesh);
907 TVisualObjPtr anObj = anActor->GetObject();
909 TColStd_MapOfInteger anIndexes;
910 int total = myListBox->count();
911 for (int i = 0; i < total; i++)
913 if (myListBox->item(i)->isSelected())
915 int anId = myListBox->item(i)->text().toInt();
916 if (anObj->GetElemVTKId(anId) >= 0) // avoid exception in hilight
921 mySelector->AddOrRemoveIndex(anActor->getIO(),anIndexes,false);
922 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
923 aViewWindow->highlight(anActor->getIO(),true,true);
926 //=======================================================================
927 // name : SMESHGUI_MultiEditDlg::onSubmeshChk
928 // Purpose : SLOT. Called when state of "SubMesh" check box changed.
929 // Activate/deactivate selection of submeshes
930 //=======================================================================
931 void SMESHGUI_MultiEditDlg::onSubmeshChk()
933 bool isChecked = mySubmeshChk->isChecked();
934 mySubmeshBtn->setEnabled(isChecked);
935 mySubmesh->setEnabled(isChecked);
938 if (isChecked && myGroupChk->isChecked())
939 myGroupChk->setChecked(false);
944 //=======================================================================
945 // name : SMESHGUI_MultiEditDlg::onGroupChk
946 // Purpose : SLOT. Called when state of "Group" check box changed.
947 // Activate/deactivate selection of groupes
948 //=======================================================================
949 void SMESHGUI_MultiEditDlg::onGroupChk()
951 bool isChecked = myGroupChk->isChecked();
952 myGroupBtn->setEnabled(isChecked);
953 myGroup->setEnabled(isChecked);
956 if (isChecked && mySubmeshChk->isChecked())
957 mySubmeshChk->setChecked(false);
962 //=======================================================================
963 // name : SMESHGUI_MultiEditDlg::onToAllChk
964 // Purpose : SLOT. Called when state of "Apply to all" check box changed.
965 // Activate/deactivate selection
966 //=======================================================================
967 void SMESHGUI_MultiEditDlg::onToAllChk()
969 bool isChecked = myToAllChk->isChecked();
976 emit ListContensChanged();
982 //=======================================================================
983 // name : SMESHGUI_MultiEditDlg::setSelectionMode
984 // Purpose : Set selection mode
985 //=======================================================================
986 void SMESHGUI_MultiEditDlg::setSelectionMode()
988 SMESH::RemoveFilters();
990 mySelectionMgr->clearSelected();
991 mySelectionMgr->clearFilters();
993 if (mySubmeshChk->isChecked()) {
994 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
995 aViewWindow->SetSelectionMode(ActorSelection);
996 mySelectionMgr->installFilter(new SMESH_TypeFilter(SUBMESH));
998 else if (myGroupChk->isChecked()) {
999 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1000 aViewWindow->SetSelectionMode(ActorSelection);
1001 mySelectionMgr->installFilter(new SMESH_TypeFilter(GROUP));
1005 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1006 aViewWindow->SetSelectionMode(VolumeSelection);
1007 SMESH::SetFilter(new SMESHGUI_VolumesFilter());
1009 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1010 aViewWindow->SetSelectionMode(FaceSelection);
1011 if (myFilterType == SMESH::TriaFilter)
1012 SMESH::SetFilter(new SMESHGUI_TriangleFilter());
1013 else if (myFilterType == SMESH::QuadFilter)
1014 SMESH::SetFilter(new SMESHGUI_QuadrangleFilter());
1016 SMESH::SetFilter(new SMESHGUI_FacesFilter());
1020 //=======================================================================
1021 // name : SMESHGUI_MultiEditDlg::onApply
1022 // Purpose : SLOT. Called when "Apply" button clicked.
1023 //=======================================================================
1024 bool SMESHGUI_MultiEditDlg::onApply()
1026 if (mySMESHGUI->isActiveStudyLocked())
1031 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
1032 if (aMeshEditor->_is_nil())
1037 SMESH::long_array_var anIds = getIds();
1039 bool aResult = process(aMeshEditor, anIds.inout());
1043 mySelectionMgr->selectedObjects( sel );
1044 mySelector->ClearIndex();
1045 mySelectionMgr->setSelectedObjects( sel );
1046 SMESH::UpdateView();
1051 emit ListContensChanged();
1060 //=======================================================================
1061 // name : SMESHGUI_MultiEditDlg::on3d2dChanged
1063 //=======================================================================
1064 void SMESHGUI_MultiEditDlg::on3d2dChanged (int type)
1066 if (myEntityType != type) {
1067 myEntityType = type;
1072 emit ListContensChanged();
1075 myFilterType = SMESH::VolumeFilter;
1077 myFilterType = SMESH::FaceFilter;
1084 //=======================================================================
1085 // name : SMESHGUI_MultiEditDlg::entityType
1087 //=======================================================================
1088 int SMESHGUI_MultiEditDlg::entityType()
1090 return myEntityType;
1093 //=================================================================================
1094 // function : keyPressEvent()
1096 //=================================================================================
1097 void SMESHGUI_MultiEditDlg::keyPressEvent( QKeyEvent* e )
1099 QDialog::keyPressEvent( e );
1100 if ( e->isAccepted() )
1103 if ( e->key() == Qt::Key_F1 ) {
1110 * Class : SMESHGUI_ChangeOrientationDlg
1111 * Description : Modification of orientation of faces
1114 SMESHGUI_ChangeOrientationDlg
1115 ::SMESHGUI_ChangeOrientationDlg(SMESHGUI* theModule):
1116 SMESHGUI_MultiEditDlg(theModule, SMESH::FaceFilter, true)
1118 setWindowTitle(tr("CAPTION"));
1119 myHelpFileName = "changing_orientation_of_elements_page.html";
1122 SMESHGUI_ChangeOrientationDlg::~SMESHGUI_ChangeOrientationDlg()
1126 bool SMESHGUI_ChangeOrientationDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
1127 const SMESH::long_array& theIds)
1129 return theEditor->Reorient(theIds);
1133 * Class : SMESHGUI_UnionOfTrianglesDlg
1134 * Description : Construction of quadrangles by automatic association of triangles
1137 SMESHGUI_UnionOfTrianglesDlg
1138 ::SMESHGUI_UnionOfTrianglesDlg(SMESHGUI* theModule):
1139 SMESHGUI_MultiEditDlg(theModule, SMESH::TriaFilter, false)
1141 setWindowTitle(tr("CAPTION"));
1143 myComboBoxFunctor->setEnabled(true);
1144 myComboBoxFunctor->addItem(tr("WARP_ELEMENTS")); // for quadrangles only
1145 myComboBoxFunctor->addItem(tr("TAPER_ELEMENTS")); // for quadrangles only
1148 QWidget* aMaxAngleGrp = new QWidget(myCriterionGrp);
1149 QHBoxLayout* aMaxAngleGrpLayout = new QHBoxLayout(aMaxAngleGrp);
1150 aMaxAngleGrpLayout->setMargin(0);
1151 aMaxAngleGrpLayout->setSpacing(SPACING);
1153 QLabel* aLab = new QLabel (tr("MAXIMUM_ANGLE"), aMaxAngleGrp);
1154 myMaxAngleSpin = new SMESHGUI_SpinBox (aMaxAngleGrp);
1155 myMaxAngleSpin->RangeStepAndValidator(0, 180.0, 1.0, 3);
1156 myMaxAngleSpin->SetValue(30.0);
1158 aMaxAngleGrpLayout->addWidget(aLab);
1159 aMaxAngleGrpLayout->addWidget(myMaxAngleSpin);
1161 ((QVBoxLayout*)aMaxAngleGrpLayout->layout())->addWidget(aMaxAngleGrp);
1162 myCriterionGrp->show();
1164 myHelpFileName = "uniting_set_of_triangles_page.html";
1167 SMESHGUI_UnionOfTrianglesDlg::~SMESHGUI_UnionOfTrianglesDlg()
1171 bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
1172 const SMESH::long_array& theIds)
1174 SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
1175 double aMaxAngle = myMaxAngleSpin->GetValue() * PI / 180.0;
1176 return theEditor->TriToQuad(theIds, aCriterion, aMaxAngle);
1181 * Class : SMESHGUI_CuttingOfQuadsDlg
1182 * Description : Automatic splitting of quadrangles into triangles
1185 SMESHGUI_CuttingOfQuadsDlg
1186 ::SMESHGUI_CuttingOfQuadsDlg(SMESHGUI* theModule):
1187 SMESHGUI_MultiEditDlg(theModule, SMESH::QuadFilter, false)
1189 setWindowTitle(tr("CAPTION"));
1192 myPreviewChk = new QCheckBox (tr("PREVIEW"), mySelGrp);
1193 QGridLayout* aLay = (QGridLayout*)(mySelGrp->layout());
1194 aLay->addWidget(myPreviewChk, aLay->rowCount(), 0, 1, aLay->columnCount());
1196 myCriterionGrp->show();
1197 myChoiceWidget->show();
1198 myComboBoxFunctor->setEnabled(false);
1200 connect(myPreviewChk, SIGNAL(stateChanged(int)), this, SLOT(onPreviewChk()));
1201 connect(myGroupChoice, SIGNAL(buttonClicked(int)), this, SLOT(onCriterionRB()));
1202 connect(myComboBoxFunctor, SIGNAL(activated(int)), this, SLOT(onPreviewChk()));
1203 connect(this, SIGNAL(ListContensChanged()), this, SLOT(onPreviewChk()));
1205 myHelpFileName = "cutting_quadrangles_page.html";
1208 SMESHGUI_CuttingOfQuadsDlg::~SMESHGUI_CuttingOfQuadsDlg()
1212 void SMESHGUI_CuttingOfQuadsDlg::onClose()
1215 SMESHGUI_MultiEditDlg::onClose();
1218 bool SMESHGUI_CuttingOfQuadsDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
1219 const SMESH::long_array& theIds)
1221 switch (myGroupChoice->checkedId()) {
1222 case 0: // use diagonal 1-3
1223 return theEditor->SplitQuad(theIds, true);
1224 case 1: // use diagonal 2-4
1225 return theEditor->SplitQuad(theIds, false);
1226 default: // use numeric functor
1230 SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
1231 return theEditor->QuadToTri(theIds, aCriterion);
1234 void SMESHGUI_CuttingOfQuadsDlg::onCriterionRB()
1236 if (myGroupChoice->checkedId() == 2) // Use numeric functor
1237 myComboBoxFunctor->setEnabled(true);
1239 myComboBoxFunctor->setEnabled(false);
1244 void SMESHGUI_CuttingOfQuadsDlg::onPreviewChk()
1246 myPreviewChk->isChecked() ? displayPreview() : erasePreview();
1249 void SMESHGUI_CuttingOfQuadsDlg::erasePreview()
1251 if (myPreviewActor == 0)
1254 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) {
1255 vf->RemoveActor(myPreviewActor);
1258 myPreviewActor->Delete();
1262 void SMESHGUI_CuttingOfQuadsDlg::displayPreview()
1267 if (myPreviewActor != 0)
1270 // get Ids of elements
1271 SMESH::long_array_var anElemIds = getIds();
1272 if (getIds()->length() == 0)
1275 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
1279 // 0 - use diagonal 1-3, 1 - use diagonal 2-4, 2 - use numerical functor
1280 int aChoice = myGroupChoice->checkedId();
1281 SMESH::NumericalFunctor_var aCriterion = SMESH::NumericalFunctor::_nil();
1282 SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH::SMESH_MeshEditor::_nil();
1284 aCriterion = getNumericalFunctor();
1285 aMeshEditor = myMesh->GetMeshEditor();
1286 if (aMeshEditor->_is_nil())
1291 vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
1293 vtkIdType aNbCells = anElemIds->length() * 2;
1294 vtkIdType aCellsSize = 4 * aNbCells;
1295 vtkCellArray* aConnectivity = vtkCellArray::New();
1296 aConnectivity->Allocate(aCellsSize, 0);
1298 vtkPoints* aPoints = vtkPoints::New();
1299 aPoints->SetNumberOfPoints(anElemIds->length() * 4);
1301 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1302 aCellTypesArray->SetNumberOfComponents(1);
1303 aCellTypesArray->Allocate(aNbCells * aCellTypesArray->GetNumberOfComponents());
1305 vtkIdList *anIdList = vtkIdList::New();
1306 anIdList->SetNumberOfIds(3);
1308 TColStd_DataMapOfIntegerInteger anIdToVtk;
1312 for (int i = 0, n = anElemIds->length(); i < n; i++)
1314 const SMDS_MeshElement* anElem = aMesh->FindElement(anElemIds[ i ]);
1315 if (anElem == 0 || anElem->NbNodes() != 4)
1318 SMDS_ElemIteratorPtr anIter = anElem->nodesIterator();
1320 while (anIter->more()) {
1321 const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(anIter->next());
1324 if (!anIdToVtk.IsBound(aNode->GetID()))
1326 aPoints->SetPoint(++nbPoints, aNode->X(), aNode->Y(), aNode->Z());
1327 anIdToVtk.Bind(aNode->GetID(), nbPoints);
1330 aNodes[ k++ ] = aNode->GetID();
1337 bool isDiag13 = true;
1338 if (aChoice == 0) // use diagonal 1-3
1342 else if (aChoice == 1) // use diagonal 2-4
1346 else // use numerical functor
1348 // compare two sets of possible triangles
1349 int diag = aMeshEditor->BestSplit(anElemIds[i], aCriterion);
1350 if (diag == 1) // 1-3
1352 else if (diag == 2) // 2-4
1360 anIdList->SetId(0, anIdToVtk(aNodes[ 0 ]));
1361 anIdList->SetId(1, anIdToVtk(aNodes[ 1 ]));
1362 anIdList->SetId(2, anIdToVtk(aNodes[ 2 ]));
1363 aConnectivity->InsertNextCell(anIdList);
1364 aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1366 anIdList->SetId(0, anIdToVtk(aNodes[ 2 ]));
1367 anIdList->SetId(1, anIdToVtk(aNodes[ 3 ]));
1368 anIdList->SetId(2, anIdToVtk(aNodes[ 0 ]));
1369 aConnectivity->InsertNextCell(anIdList);
1370 aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1374 anIdList->SetId(0, anIdToVtk(aNodes[ 1 ]));
1375 anIdList->SetId(1, anIdToVtk(aNodes[ 2 ]));
1376 anIdList->SetId(2, anIdToVtk(aNodes[ 3 ]));
1377 aConnectivity->InsertNextCell(anIdList);
1378 aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1380 anIdList->SetId(0, anIdToVtk(aNodes[ 3 ]));
1381 anIdList->SetId(1, anIdToVtk(aNodes[ 0 ]));
1382 anIdList->SetId(2, anIdToVtk(aNodes[ 1 ]));
1383 aConnectivity->InsertNextCell(anIdList);
1384 aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1388 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
1389 aCellLocationsArray->SetNumberOfComponents(1);
1390 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1392 aConnectivity->InitTraversal();
1393 for(vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell(npts, pts); idType++)
1394 aCellLocationsArray->SetValue(idType, aConnectivity->GetTraversalLocation(npts));
1396 aGrid->SetPoints(aPoints);
1397 aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aConnectivity);
1399 // Create and display actor
1400 vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
1401 aMapper->SetInput(aGrid);
1403 myPreviewActor = SALOME_Actor::New();
1404 myPreviewActor->PickableOff();
1405 myPreviewActor->SetMapper(aMapper);
1407 vtkProperty* aProp = vtkProperty::New();
1408 aProp->SetRepresentationToWireframe();
1409 aProp->SetColor(250, 0, 250);
1410 aProp->SetLineWidth(myActor->GetLineWidth() + 1);
1411 myPreviewActor->SetProperty(aProp);
1413 SMESH::GetCurrentVtkView()->AddActor(myPreviewActor);
1414 SMESH::GetCurrentVtkView()->Repaint();
1418 aConnectivity->Delete();
1422 aCellTypesArray->Delete();
1423 aCellLocationsArray->Delete();