1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_MultiEditDlg.cxx
24 // Author : Sergey LITONIN
27 #include "SMESHGUI_MultiEditDlg.h"
30 #include "SMESHGUI_Filter.h"
31 #include "SMESHGUI_FilterDlg.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_MeshUtils.h"
35 #include "SMESHGUI_FilterUtils.h"
36 #include "SMESHGUI_SpinBox.h"
38 #include "SMESH_Actor.h"
39 #include "SMESH_TypeFilter.hxx"
40 #include "SMDS_Mesh.hxx"
41 #include "SMDS_MeshElement.hxx"
43 #include "SUIT_ResourceMgr.h"
44 #include "SUIT_Desktop.h"
45 #include "SUIT_Session.h"
46 #include "SUIT_MessageBox.h"
48 #include "LightApp_SelectionMgr.h"
49 #include "LightApp_Application.h"
50 #include "SALOME_ListIO.hxx"
51 #include "SALOME_ListIteratorOfListIO.hxx"
53 #include "SVTK_Selector.h"
54 #include "SVTK_ViewModel.h"
55 #include "SVTK_ViewWindow.h"
56 #include "VTKViewer_CellLocationsArray.h"
59 #include <Precision.hxx>
60 #include <TColStd_IndexedMapOfInteger.hxx>
61 #include <TColStd_DataMapOfIntegerInteger.hxx>
62 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
65 #include <vtkCell3D.h>
67 #include <vtkTriangle.h>
68 #include <vtkPolygon.h>
69 #include <vtkConvexPointSet.h>
70 #include <vtkIdList.h>
71 #include <vtkCellArray.h>
72 #include <vtkUnsignedCharArray.h>
73 #include <vtkUnstructuredGrid.h>
74 #include <vtkDataSetMapper.h>
75 #include <vtkProperty.h>
82 #include <qcheckbox.h>
83 #include <qcombobox.h>
84 #include <qgroupbox.h>
85 #include <qlineedit.h>
86 #include <qpushbutton.h>
87 #include <qapplication.h>
88 #include <qradiobutton.h>
89 #include <qhbuttongroup.h>
92 #include "SALOMEconfig.h"
93 #include CORBA_SERVER_HEADER(SMESH_Group)
99 * Class : SMESHGUI_MultiEditDlg
100 * Description : Description : Inversion of the diagonal of a pseudo-quadrangle formed by
101 * 2 neighboring triangles with 1 common edge
104 //=======================================================================
105 // name : SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg
106 // Purpose : Constructor
107 //=======================================================================
108 SMESHGUI_MultiEditDlg
109 ::SMESHGUI_MultiEditDlg(SMESHGUI* theModule,
112 const char* theName):
113 QDialog(SMESH::GetDesktop(theModule),
116 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
117 mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
118 mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
119 mySMESHGUI(theModule)
124 myFilterType = theMode;
125 QVBoxLayout* aDlgLay = new QVBoxLayout(this, MARGIN, SPACING);
127 QFrame* aMainFrame = createMainFrame (this, the3d2d);
128 QFrame* aBtnFrame = createButtonFrame(this);
130 aDlgLay->addWidget(aMainFrame);
131 aDlgLay->addWidget(aBtnFrame);
133 aDlgLay->setStretchFactor(aMainFrame, 1);
134 aDlgLay->setStretchFactor(aBtnFrame, 0);
138 //=======================================================================
139 // name : SMESHGUI_MultiEditDlg::createMainFrame
140 // Purpose : Create frame containing dialog's input fields
141 //=======================================================================
142 QFrame* SMESHGUI_MultiEditDlg::createMainFrame (QWidget* theParent, const bool the3d2d)
144 QGroupBox* aMainGrp = new QGroupBox(1, Qt::Horizontal, theParent);
145 aMainGrp->setFrameStyle(QFrame::NoFrame);
146 aMainGrp->setInsideMargin(0);
148 QPixmap aPix (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
150 // "Selected cells" group
151 mySelGrp = new QGroupBox(1, Qt::Horizontal, aMainGrp);
155 myEntityTypeGrp = new QHButtonGroup(tr("SMESH_ELEMENTS_TYPE"), mySelGrp);
156 (new QRadioButton(tr("SMESH_FACE"), myEntityTypeGrp))->setChecked(true);
157 (new QRadioButton(tr("SMESH_VOLUME"), myEntityTypeGrp));
158 myEntityType = myEntityTypeGrp->id(myEntityTypeGrp->selected());
161 QFrame* aFrame = new QFrame(mySelGrp);
163 myListBox = new QListBox(aFrame);
164 myListBox->setSelectionMode(QListBox::Extended);
165 myListBox->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
166 myListBox->installEventFilter(this);
168 myFilterBtn = new QPushButton(tr("FILTER") , aFrame);
169 myAddBtn = new QPushButton(tr("ADD") , aFrame);
170 myRemoveBtn = new QPushButton(tr("REMOVE") , aFrame);
171 mySortBtn = new QPushButton(tr("SORT_LIST"), aFrame);
173 QGridLayout* aLay = new QGridLayout(aFrame, 5, 2, 0, 5);
174 aLay->addMultiCellWidget(myListBox, 0, 4, 0, 0);
175 aLay->addWidget(myFilterBtn, 0, 1);
176 aLay->addWidget(myAddBtn, 1, 1);
177 aLay->addWidget(myRemoveBtn, 2, 1);
178 aLay->addWidget(mySortBtn, 3, 1);
180 QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
181 aLay->addItem(aSpacer, 4, 1);
183 myToAllChk = new QCheckBox(tr("TO_ALL"), mySelGrp);
185 // Split/Join criterion group
186 myCriterionGrp = new QGroupBox(3, Qt::Vertical, tr("SPLIT_JOIN_CRITERION"), aMainGrp);
188 myGroupChoice = new QButtonGroup(3, Qt::Vertical, myCriterionGrp);
189 myGroupChoice->setInsideMargin(0);
190 myGroupChoice->setFrameStyle(QFrame::NoFrame);
191 (new QRadioButton(tr("USE_DIAGONAL_1_3"), myGroupChoice))->setChecked(true);
192 (new QRadioButton(tr("USE_DIAGONAL_2_4"), myGroupChoice));
193 (new QRadioButton(tr("USE_NUMERIC_FUNC"), myGroupChoice));
195 myComboBoxFunctor = new QComboBox(myCriterionGrp);
196 myComboBoxFunctor->insertItem(tr("ASPECTRATIO_ELEMENTS"));
197 myComboBoxFunctor->insertItem(tr("MINIMUMANGLE_ELEMENTS"));
198 myComboBoxFunctor->insertItem(tr("SKEW_ELEMENTS"));
199 myComboBoxFunctor->insertItem(tr("AREA_ELEMENTS"));
200 //myComboBoxFunctor->insertItem(tr("LENGTH2D_EDGES")); // for existing elements only
201 //myComboBoxFunctor->insertItem(tr("MULTI2D_BORDERS")); // for existing elements only
202 myComboBoxFunctor->setCurrentItem(0);
204 myCriterionGrp->hide();
205 myGroupChoice->hide();
206 myComboBoxFunctor->setEnabled(false);
208 // "Select from" group
209 QGroupBox* aGrp = new QGroupBox(3, Qt::Horizontal, tr("SELECT_FROM"), aMainGrp);
211 mySubmeshChk = new QCheckBox(tr("SMESH_SUBMESH"), aGrp);
212 mySubmeshBtn = new QPushButton(aGrp);
213 mySubmesh = new QLineEdit(aGrp);
214 mySubmesh->setReadOnly(true);
215 mySubmeshBtn->setPixmap(aPix);
217 myGroupChk = new QCheckBox(tr("SMESH_GROUP"), aGrp);
218 myGroupBtn = new QPushButton(aGrp);
219 myGroup = new QLineEdit(aGrp);
220 myGroup->setReadOnly(true);
221 myGroupBtn->setPixmap(aPix);
226 //=======================================================================
227 // name : SMESHGUI_MultiEditDlg::createButtonFrame
228 // Purpose : Create frame containing buttons
229 //=======================================================================
230 QFrame* SMESHGUI_MultiEditDlg::createButtonFrame (QWidget* theParent)
232 QFrame* aFrame = new QFrame (theParent);
233 aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
235 myApplyBtn = new QPushButton (tr("SMESH_BUT_APPLY"), aFrame);
236 myCloseBtn = new QPushButton (tr("SMESH_BUT_CLOSE"), aFrame);
237 myOkBtn = new QPushButton (tr("SMESH_BUT_APPLY_AND_CLOSE"), aFrame);
238 myHelpBtn = new QPushButton (tr("SMESH_BUT_HELP"), aFrame);
240 QSpacerItem* aSpacer = new QSpacerItem (0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
242 QHBoxLayout* aLay = new QHBoxLayout (aFrame, MARGIN, SPACING);
244 aLay->addWidget(myOkBtn);
245 aLay->addWidget(myApplyBtn);
246 aLay->addItem(aSpacer);
247 aLay->addWidget(myCloseBtn);
248 aLay->addWidget(myHelpBtn);
253 //=======================================================================
254 // name : SMESHGUI_MultiEditDlg::isValid
255 // Purpose : Verify validity of input data
256 //=======================================================================
257 bool SMESHGUI_MultiEditDlg::isValid (const bool /*theMess*/) const
259 return (!myMesh->_is_nil() &&
260 (myListBox->count() > 0 || (myToAllChk->isChecked() && myActor)));
263 //=======================================================================
264 // name : SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg
265 // Purpose : Destructor
266 //=======================================================================
267 SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg()
269 if (myFilterDlg != 0)
271 myFilterDlg->reparent(0, QPoint());
276 //=======================================================================
277 // name : SMESHGUI_MultiEditDlg::eventFilter
278 // Purpose : event filter
279 //=======================================================================
280 bool SMESHGUI_MultiEditDlg::eventFilter (QObject* object, QEvent* event)
282 if (object == myListBox && event->type() == QEvent::KeyPress) {
283 QKeyEvent* ke = (QKeyEvent*)event;
284 if (ke->key() == Key_Delete)
287 return QDialog::eventFilter(object, event);
290 //=======================================================================
291 // name : SMESHGUI_MultiEditDlg::getNumericalFunctor
293 //=======================================================================
294 SMESH::NumericalFunctor_ptr SMESHGUI_MultiEditDlg::getNumericalFunctor()
296 SMESH::NumericalFunctor_var aNF = SMESH::NumericalFunctor::_nil();
298 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
299 if (aFilterMgr->_is_nil())
302 if (myComboBoxFunctor->currentText() == tr("ASPECTRATIO_ELEMENTS"))
303 aNF = aFilterMgr->CreateAspectRatio();
304 else if (myComboBoxFunctor->currentText() == tr("WARP_ELEMENTS"))
305 aNF = aFilterMgr->CreateWarping();
306 else if (myComboBoxFunctor->currentText() == tr("MINIMUMANGLE_ELEMENTS"))
307 aNF = aFilterMgr->CreateMinimumAngle();
308 else if (myComboBoxFunctor->currentText() == tr("TAPER_ELEMENTS"))
309 aNF = aFilterMgr->CreateTaper();
310 else if (myComboBoxFunctor->currentText() == tr("SKEW_ELEMENTS"))
311 aNF = aFilterMgr->CreateSkew();
312 else if (myComboBoxFunctor->currentText() == tr("AREA_ELEMENTS"))
313 aNF = aFilterMgr->CreateArea();
314 else if (myComboBoxFunctor->currentText() == tr("LENGTH2D_EDGES"))
315 aNF = aFilterMgr->CreateLength2D();
316 else if (myComboBoxFunctor->currentText() == tr("MULTI2D_BORDERS"))
317 aNF = aFilterMgr->CreateMultiConnection2D();
323 //=======================================================================
324 // name : SMESHGUI_MultiEditDlg::Init
325 // Purpose : Init dialog fields, connect signals and slots, show dialog
326 //=======================================================================
327 void SMESHGUI_MultiEditDlg::Init()
329 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
334 emit ListContensChanged();
337 connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
338 connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
339 connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
340 connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
342 // selection and SMESHGUI
343 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
344 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
345 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
348 connect(myFilterBtn, SIGNAL(clicked()), SLOT(onFilterBtn() ));
349 connect(myAddBtn , SIGNAL(clicked()), SLOT(onAddBtn() ));
350 connect(myRemoveBtn, SIGNAL(clicked()), SLOT(onRemoveBtn() ));
351 connect(mySortBtn , SIGNAL(clicked()), SLOT(onSortListBtn()));
353 connect(mySubmeshChk, SIGNAL(stateChanged(int)), SLOT(onSubmeshChk()));
354 connect(myGroupChk , SIGNAL(stateChanged(int)), SLOT(onGroupChk() ));
355 connect(myToAllChk , SIGNAL(stateChanged(int)), SLOT(onToAllChk() ));
358 connect(myEntityTypeGrp, SIGNAL(clicked(int)), SLOT(on3d2dChanged(int)));
360 connect(myListBox, SIGNAL(selectionChanged()), SLOT(onListSelectionChanged()));
364 // set selection mode
369 //=======================================================================
370 // name : SMESHGUI_MultiEditDlg::onOk
371 // Purpose : SLOT called when "Ok" button pressed.
372 // Assign filters VTK viewer and close dialog
373 //=======================================================================
374 void SMESHGUI_MultiEditDlg::onOk()
380 //=======================================================================
381 // name : SMESHGUI_MultiEditDlg::getIds
382 // Purpose : Retrive identifiers from list box
383 //=======================================================================
384 SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds()
386 SMESH::long_array_var anIds = new SMESH::long_array;
388 if (myToAllChk->isChecked())
391 SMESH_Actor * anActor = SMESH::FindActorByObject(myMesh);
397 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
398 if( myFilterType == SMESHGUI_TriaFilter ||
399 myFilterType == SMESHGUI_QuadFilter ||
400 myFilterType == SMESHGUI_FaceFilter ) {
401 SMDS_FaceIteratorPtr it = aMesh->facesIterator();
403 const SMDS_MeshFace* f = it->next();
404 if(myFilterType == SMESHGUI_FaceFilter) {
405 myIds.Add(f->GetID());
407 else if( myFilterType==SMESHGUI_TriaFilter &&
408 ( f->NbNodes()==3 || f->NbNodes()==6 ) ) {
409 myIds.Add(f->GetID());
411 else if( myFilterType==SMESHGUI_QuadFilter &&
412 ( f->NbNodes()==4 || f->NbNodes()==8 ) ) {
413 myIds.Add(f->GetID());
417 else if(myFilterType == SMESHGUI_VolumeFilter) {
418 SMDS_VolumeIteratorPtr it = aMesh->volumesIterator();
420 const SMDS_MeshVolume* f = it->next();
421 myIds.Add(f->GetID());
424 /* commented by skl 07.02.2006
425 TVisualObjPtr aVisualObj = anActor->GetObject();
426 vtkUnstructuredGrid* aGrid = aVisualObj->GetUnstructuredGrid();
428 for (int i = 0, n = aGrid->GetNumberOfCells(); i < n; i++) {
429 vtkCell* aCell = aGrid->GetCell(i);
431 vtkTriangle* aTri = vtkTriangle::SafeDownCast(aCell);
432 vtkQuad* aQua = vtkQuad::SafeDownCast(aCell);
433 vtkPolygon* aPG = vtkPolygon::SafeDownCast(aCell);
435 vtkCell3D* a3d = vtkCell3D::SafeDownCast(aCell);
436 vtkConvexPointSet* aPH = vtkConvexPointSet::SafeDownCast(aCell);
438 if (aTri && myFilterType == SMESHGUI_TriaFilter ||
439 aQua && myFilterType == SMESHGUI_QuadFilter ||
440 (aTri || aQua || aPG) && myFilterType == SMESHGUI_FaceFilter ||
441 (a3d || aPH) && myFilterType == SMESHGUI_VolumeFilter) {
442 int anObjId = aVisualObj->GetElemObjId(i);
452 anIds->length(myIds.Extent());
453 TColStd_MapIteratorOfMapOfInteger anIter(myIds);
454 for (int i = 0; anIter.More(); anIter.Next() )
456 anIds[ i++ ] = anIter.Key();
458 return anIds._retn();
461 //=======================================================================
462 // name : SMESHGUI_MultiEditDlg::onClose
463 // Purpose : SLOT called when "Close" button pressed. Close dialog
464 //=======================================================================
465 void SMESHGUI_MultiEditDlg::onClose()
467 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
468 aViewWindow->SetSelectionMode(ActorSelection);
469 disconnect(mySelectionMgr, 0, this, 0);
470 disconnect(mySMESHGUI, 0, this, 0);
471 mySMESHGUI->ResetState();
473 SMESH::RemoveFilters();
474 SMESH::SetPickable();
476 //mySelectionMgr->clearSelected();
477 mySelectionMgr->clearFilters();
482 //=================================================================================
483 // function : onHelp()
485 //=================================================================================
486 void SMESHGUI_MultiEditDlg::onHelp()
488 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
490 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
494 platform = "winapplication";
496 platform = "application";
498 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
499 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
500 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
501 QObject::tr("BUT_OK"));
505 //=======================================================================
506 // name : SMESHGUI_MultiEditDlg::onSelectionDone
507 // Purpose : SLOT called when selection changed
508 //=======================================================================
509 void SMESHGUI_MultiEditDlg::onSelectionDone()
511 if (myBusy || !isEnabled()) return;
514 const SALOME_ListIO& aList = mySelector->StoredIObjects();
516 int nbSel = aList.Extent();
517 myListBox->clearSelection();
519 if (mySubmeshChk->isChecked() || myGroupChk->isChecked()) {
520 QLineEdit* aNameEdit = mySubmeshChk->isChecked() ? mySubmesh : myGroup;
522 Handle(SALOME_InteractiveObject) anIO = aList.First();
524 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
525 anIO.IsNull() ? aNameEdit->clear() : aNameEdit->setText(aName);
527 if (mySubmeshChk->isChecked()) {
528 SMESH::SMESH_subMesh_var aSubMesh =
529 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIO);
530 if (!aSubMesh->_is_nil())
531 myMesh = aSubMesh->GetFather();
533 SMESH::SMESH_GroupBase_var aGroup =
534 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIO);
535 if (!aGroup->_is_nil())
536 myMesh = aGroup->GetMesh();
538 } else if (nbSel > 1) {
539 QString aStr = mySubmeshChk->isChecked() ?
540 tr("SMESH_SUBMESH_SELECTED") : tr("SMESH_GROUP_SELECTED");
541 aNameEdit->setText(aStr.arg(nbSel));
545 } else if (nbSel > 0) {
546 QString aListStr = "";
547 Handle(SALOME_InteractiveObject) anIO = aList.First();
548 int aNbItems = SMESH::GetNameOfSelectedElements(mySelector,anIO,aListStr);
550 QStringList anElements = QStringList::split(" ", aListStr);
551 QListBoxItem* anItem = 0;
552 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
553 anItem = myListBox->findItem(*it, Qt::ExactMatch);
554 if (anItem) myListBox->setSelected(anItem, true);
558 myMesh = SMESH::GetMeshByIO(anIO);
562 myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
564 myActor = SMESH::FindActorByObject(myMesh);
565 SVTK_Selector* aSelector = SMESH::GetSelector();
566 Handle(VTKViewer_Filter) aFilter = aSelector->GetFilter(myFilterType);
567 if (!aFilter.IsNull())
568 aFilter->SetActor(myActor);
575 //=======================================================================
576 // name : SMESHGUI_MultiEditDlg::onDeactivate
577 // Purpose : SLOT called when dialog must be deativated
578 //=======================================================================
579 void SMESHGUI_MultiEditDlg::onDeactivate()
584 //=======================================================================
585 // name : SMESHGUI_MultiEditDlg::enterEvent
586 // Purpose : Event filter
587 //=======================================================================
588 void SMESHGUI_MultiEditDlg::enterEvent (QEvent*)
591 mySMESHGUI->EmitSignalDeactivateDialog();
597 //=======================================================================
598 // name : SMESHGUI_MultiEditDlg::closeEvent
600 //=======================================================================
601 void SMESHGUI_MultiEditDlg::closeEvent (QCloseEvent*)
605 //=======================================================================
606 // name : SMESHGUI_MultiEditDlg::hideEvent
607 // Purpose : caused by ESC key
608 //=======================================================================
609 void SMESHGUI_MultiEditDlg::hideEvent (QHideEvent*)
615 //=======================================================================
616 // name : SMESHGUI_MultiEditDlg::onFilterBtn
617 // Purpose : SLOT. Called when "Filter" button pressed.
618 // Start "Selection filters" dialog
619 //=======================================================================
620 void SMESHGUI_MultiEditDlg::onFilterBtn()
622 if (myFilterDlg == 0) {
623 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, entityType() ? SMESH::VOLUME : SMESH::FACE);
624 connect(myFilterDlg, SIGNAL(Accepted()), SLOT(onFilterAccepted()));
626 myFilterDlg->Init(entityType() ? SMESH::VOLUME : SMESH::FACE);
629 myFilterDlg->SetSelection();
630 myFilterDlg->SetMesh(myMesh);
631 myFilterDlg->SetSourceWg(myListBox);
636 //=======================================================================
637 // name : onFilterAccepted()
638 // Purpose : SLOT. Called when Filter dlg closed with OK button.
639 // Uncheck "Select submesh" and "Select group" checkboxes
640 //=======================================================================
641 void SMESHGUI_MultiEditDlg::onFilterAccepted()
644 for (int i = 0, n = myListBox->count(); i < n; i++)
645 myIds.Add(myListBox->text(i).toInt());
647 emit ListContensChanged();
649 if (mySubmeshChk->isChecked() || myGroupChk->isChecked()) {
650 mySubmeshChk->blockSignals(true);
651 myGroupChk->blockSignals(true);
652 mySubmeshChk->setChecked(false);
653 myGroupChk->setChecked(false);
654 mySubmeshChk->blockSignals(false);
655 myGroupChk->blockSignals(false);
660 //=======================================================================
661 // name : SMESHGUI_MultiEditDlg::isIdValid
662 // Purpose : Verify whether Id of element satisfies to filters from viewer
663 //=======================================================================
664 bool SMESHGUI_MultiEditDlg::isIdValid (const int theId) const
666 SVTK_Selector* aSelector = SMESH::GetSelector();
667 Handle(SMESHGUI_Filter) aFilter =
668 Handle(SMESHGUI_Filter)::DownCast(aSelector->GetFilter(myFilterType));
670 return (!aFilter.IsNull() && aFilter->IsObjValid(theId));
673 //=======================================================================
674 // name : SMESHGUI_MultiEditDlg::onAddBtn
675 // Purpose : SLOT. Called when "Add" button pressed.
676 // Add selected in viewer entities in list box
677 //=======================================================================
678 void SMESHGUI_MultiEditDlg::onAddBtn()
680 const SALOME_ListIO& aList = mySelector->StoredIObjects();
682 int nbSelected = aList.Extent();
686 TColStd_IndexedMapOfInteger toBeAdded;
688 if (!mySubmeshChk->isChecked() && !myGroupChk->isChecked()) {
690 mySelector->GetIndex(aList.First(),toBeAdded);
691 } else if (mySubmeshChk->isChecked()) {
692 SALOME_ListIteratorOfListIO anIter(aList);
693 for (; anIter.More(); anIter.Next()) {
694 SMESH::SMESH_subMesh_var aSubMesh =
695 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIter.Value());
696 if (!aSubMesh->_is_nil()) {
697 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
698 SMESH::long_array_var anIds = aSubMesh->GetElementsId();
699 for (int i = 0, n = anIds->length(); i < n; i++) {
700 if (isIdValid(anIds[ i ]))
701 toBeAdded.Add(anIds[ i ]);
706 } else if (myGroupChk->isChecked()) {
707 SALOME_ListIteratorOfListIO anIter(aList);
708 for (; anIter.More(); anIter.Next()) {
709 SMESH::SMESH_GroupBase_var aGroup =
710 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value());
711 if (!aGroup->_is_nil() && (aGroup->GetType() == SMESH::FACE &&
712 entityType() == 0 || aGroup->GetType() == SMESH::VOLUME &&
713 entityType() == 1)) {
714 if (aGroup->GetMesh()->GetId() == myMesh->GetId()) {
715 SMESH::long_array_var anIds = aGroup->GetListOfID();
716 for (int i = 0, n = anIds->length(); i < n; i++) {
717 if (isIdValid(anIds[ i ]))
718 toBeAdded.Add(anIds[ i ]);
727 bool isGroupOrSubmesh = (mySubmeshChk->isChecked() || myGroupChk->isChecked());
728 mySubmeshChk->setChecked(false);
729 myGroupChk->setChecked(false);
730 for(int i = 1; i <= toBeAdded.Extent(); i++)
731 if (myIds.Add(toBeAdded(i))) {
732 QListBoxItem * item = new QListBoxText(QString("%1").arg(toBeAdded(i)));
733 myListBox->insertItem(item);
734 myListBox->setSelected(item, true);
738 emit ListContensChanged();
740 if (isGroupOrSubmesh)
741 onListSelectionChanged();
746 //=======================================================================
747 // name : SMESHGUI_MultiEditDlg::updateButtons
748 // Purpose : Enable/disable buttons of dialog in accordance with current state
749 //=======================================================================
750 void SMESHGUI_MultiEditDlg::updateButtons()
752 bool isOk = isValid(false);
753 myOkBtn->setEnabled(isOk);
754 myApplyBtn->setEnabled(isOk);
756 bool isListBoxNonEmpty = myListBox->count() > 0;
757 bool isToAll = myToAllChk->isChecked();
758 myFilterBtn->setEnabled(!isToAll);
759 myRemoveBtn->setEnabled(isListBoxNonEmpty && !isToAll);
760 mySortBtn->setEnabled(isListBoxNonEmpty &&!isToAll);
762 const SALOME_ListIO& aList = mySelector->StoredIObjects();
766 aList.Extent() < 1 ||
767 (SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(aList.First())->_is_nil() &&
768 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(aList.First())->_is_nil() &&
769 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(aList.First())->_is_nil()))
770 myAddBtn->setEnabled(false);
772 myAddBtn->setEnabled(true);
774 mySubmeshChk->setEnabled(!isToAll);
775 mySubmeshBtn->setEnabled(mySubmeshChk->isChecked());
776 mySubmesh->setEnabled(mySubmeshChk->isChecked());
778 myGroupChk->setEnabled(!isToAll);
779 myGroupBtn->setEnabled(myGroupChk->isChecked());
780 myGroup->setEnabled(myGroupChk->isChecked());
782 if (!mySubmeshChk->isChecked())
784 if (!myGroupChk->isChecked())
789 //=======================================================================
790 // name : SMESHGUI_MultiEditDlg::onRemoveBtn
791 // Purpose : SLOT. Called when "Remove" button pressed.
792 // Remove selected in list box entities
793 //=======================================================================
794 void SMESHGUI_MultiEditDlg::onRemoveBtn()
798 for (int i = 0, n = myListBox->count(); i < n; i++)
800 for (int i = myListBox->count(); i > 0; i--) {
801 if (myListBox->isSelected(i - 1))
803 int anId = myListBox->text(i - 1).toInt();
806 myListBox->removeItem(i-1);
812 emit ListContensChanged();
816 //=======================================================================
817 // name : SMESHGUI_MultiEditDlg::onSortListBtn
818 // Purpose : SLOT. Called when "Sort list" button pressed.
819 // Sort entities of list box
820 //=======================================================================
821 void SMESHGUI_MultiEditDlg::onSortListBtn()
825 int i, k = myListBox->count();
828 QStringList aSelected;
829 std::vector<int> anArray(k);
830 QListBoxItem* anItem;
831 for (anItem = myListBox->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++)
833 anArray[ i ] = anItem->text().toInt();
834 if (anItem->isSelected())
835 aSelected.append(anItem->text());
838 std::sort(anArray.begin(), anArray.end());
840 for (i = 0; i < k; i++)
841 myListBox->insertItem(QString::number(anArray[ i ]));
843 for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it)
845 anItem = myListBox->findItem(*it, Qt::ExactMatch);
847 myListBox->setSelected(anItem, true);
853 //=======================================================================
854 // name : SMESHGUI_MultiEditDlg::onListSelectionChanged
855 // Purpose : SLOT. Called when selection in list box changed.
856 // Highlight in selected entities
857 //=======================================================================
858 void SMESHGUI_MultiEditDlg::onListSelectionChanged()
860 if (myActor == 0 || myBusy)
863 if (mySubmeshChk->isChecked() || myGroupChk->isChecked())
866 SMESH_Actor * anActor = SMESH::FindActorByObject(myMesh);
869 TVisualObjPtr anObj = anActor->GetObject();
871 TColStd_MapOfInteger anIndexes;
872 for (QListBoxItem* anItem = myListBox->firstItem(); anItem != 0; anItem = anItem->next())
874 if (anItem->isSelected())
876 int anId = anItem->text().toInt();
877 if (anObj->GetElemVTKId(anId) >= 0) // avoid exception in hilight
882 mySelector->AddOrRemoveIndex(anActor->getIO(),anIndexes,false);
883 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
884 aViewWindow->highlight(anActor->getIO(),true,true);
887 //=======================================================================
888 // name : SMESHGUI_MultiEditDlg::onSubmeshChk
889 // Purpose : SLOT. Called when state of "SubMesh" check box changed.
890 // Activate/deactivate selection of submeshes
891 //=======================================================================
892 void SMESHGUI_MultiEditDlg::onSubmeshChk()
894 bool isChecked = mySubmeshChk->isChecked();
895 mySubmeshBtn->setEnabled(isChecked);
896 mySubmesh->setEnabled(isChecked);
899 if (isChecked && myGroupChk->isChecked())
900 myGroupChk->setChecked(false);
905 //=======================================================================
906 // name : SMESHGUI_MultiEditDlg::onGroupChk
907 // Purpose : SLOT. Called when state of "Group" check box changed.
908 // Activate/deactivate selection of groupes
909 //=======================================================================
910 void SMESHGUI_MultiEditDlg::onGroupChk()
912 bool isChecked = myGroupChk->isChecked();
913 myGroupBtn->setEnabled(isChecked);
914 myGroup->setEnabled(isChecked);
917 if (isChecked && mySubmeshChk->isChecked())
918 mySubmeshChk->setChecked(false);
923 //=======================================================================
924 // name : SMESHGUI_MultiEditDlg::onToAllChk
925 // Purpose : SLOT. Called when state of "Apply to all" check box changed.
926 // Activate/deactivate selection
927 //=======================================================================
928 void SMESHGUI_MultiEditDlg::onToAllChk()
930 bool isChecked = myToAllChk->isChecked();
937 emit ListContensChanged();
943 //=======================================================================
944 // name : SMESHGUI_MultiEditDlg::setSelectionMode
945 // Purpose : Set selection mode
946 //=======================================================================
947 void SMESHGUI_MultiEditDlg::setSelectionMode()
949 SMESH::RemoveFilters();
951 mySelectionMgr->clearSelected();
952 mySelectionMgr->clearFilters();
954 if (mySubmeshChk->isChecked()) {
955 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
956 aViewWindow->SetSelectionMode(ActorSelection);
957 mySelectionMgr->installFilter(new SMESH_TypeFilter(SUBMESH));
959 else if (myGroupChk->isChecked()) {
960 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
961 aViewWindow->SetSelectionMode(ActorSelection);
962 mySelectionMgr->installFilter(new SMESH_TypeFilter(GROUP));
966 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
967 aViewWindow->SetSelectionMode(VolumeSelection);
968 SMESH::SetFilter(new SMESHGUI_VolumesFilter());
970 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
971 aViewWindow->SetSelectionMode(FaceSelection);
972 if (myFilterType == SMESHGUI_TriaFilter)
973 SMESH::SetFilter(new SMESHGUI_TriangleFilter());
974 else if (myFilterType == SMESHGUI_QuadFilter)
975 SMESH::SetFilter(new SMESHGUI_QuadrangleFilter());
977 SMESH::SetFilter(new SMESHGUI_FacesFilter());
981 //=======================================================================
982 // name : SMESHGUI_MultiEditDlg::onApply
983 // Purpose : SLOT. Called when "Apply" button clicked.
984 //=======================================================================
985 bool SMESHGUI_MultiEditDlg::onApply()
987 if (mySMESHGUI->isActiveStudyLocked())
992 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
993 if (aMeshEditor->_is_nil())
998 SMESH::long_array_var anIds = getIds();
1000 bool aResult = process(aMeshEditor, anIds.inout());
1004 mySelectionMgr->selectedObjects( sel );
1005 mySelector->ClearIndex();
1006 mySelectionMgr->setSelectedObjects( sel );
1007 SMESH::UpdateView();
1012 emit ListContensChanged();
1021 //=======================================================================
1022 // name : SMESHGUI_MultiEditDlg::on3d2dChanged
1024 //=======================================================================
1025 void SMESHGUI_MultiEditDlg::on3d2dChanged (int type)
1027 if (myEntityType != type) {
1028 myEntityType = type;
1033 emit ListContensChanged();
1036 myFilterType = SMESHGUI_VolumeFilter;
1038 myFilterType = SMESHGUI_FaceFilter;
1045 //=======================================================================
1046 // name : SMESHGUI_MultiEditDlg::entityType
1048 //=======================================================================
1049 int SMESHGUI_MultiEditDlg::entityType()
1051 return myEntityType;
1054 //=================================================================================
1055 // function : keyPressEvent()
1057 //=================================================================================
1058 void SMESHGUI_MultiEditDlg::keyPressEvent( QKeyEvent* e )
1060 QDialog::keyPressEvent( e );
1061 if ( e->isAccepted() )
1064 if ( e->key() == Key_F1 )
1072 * Class : SMESHGUI_ChangeOrientationDlg
1073 * Description : Modification of orientation of faces
1076 SMESHGUI_ChangeOrientationDlg
1077 ::SMESHGUI_ChangeOrientationDlg(SMESHGUI* theModule,
1078 const char* theName):
1079 SMESHGUI_MultiEditDlg(theModule, SMESHGUI_FaceFilter, true, theName)
1081 setCaption(tr("CAPTION"));
1082 myHelpFileName = "changing_orientation_of_elements_page.html";
1085 SMESHGUI_ChangeOrientationDlg::~SMESHGUI_ChangeOrientationDlg()
1089 bool SMESHGUI_ChangeOrientationDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
1090 const SMESH::long_array& theIds)
1092 return theEditor->Reorient(theIds);
1096 * Class : SMESHGUI_UnionOfTrianglesDlg
1097 * Description : Construction of quadrangles by automatic association of triangles
1100 SMESHGUI_UnionOfTrianglesDlg
1101 ::SMESHGUI_UnionOfTrianglesDlg(SMESHGUI* theModule,
1102 const char* theName):
1103 SMESHGUI_MultiEditDlg(theModule, SMESHGUI_TriaFilter, false, theName)
1105 setCaption(tr("CAPTION"));
1107 myComboBoxFunctor->setEnabled(true);
1108 myComboBoxFunctor->insertItem(tr("WARP_ELEMENTS")); // for quadrangles only
1109 myComboBoxFunctor->insertItem(tr("TAPER_ELEMENTS")); // for quadrangles only
1112 QGroupBox* aMaxAngleGrp = new QGroupBox (2, Qt::Horizontal, myCriterionGrp);
1113 aMaxAngleGrp->setInsideMargin(0);
1114 aMaxAngleGrp->setFrameStyle(QFrame::NoFrame);
1115 new QLabel (tr("MAXIMUM_ANGLE"), aMaxAngleGrp);
1116 myMaxAngleSpin = new SMESHGUI_SpinBox (aMaxAngleGrp);
1117 myMaxAngleSpin->RangeStepAndValidator(0, 180.0, 1.0, 3);
1118 myMaxAngleSpin->SetValue(30.0);
1120 myCriterionGrp->show();
1122 myHelpFileName = "uniting_set_of_triangles_page.html";
1125 SMESHGUI_UnionOfTrianglesDlg::~SMESHGUI_UnionOfTrianglesDlg()
1129 bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
1130 const SMESH::long_array& theIds)
1132 SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
1133 double aMaxAngle = myMaxAngleSpin->GetValue() * PI / 180.0;
1134 return theEditor->TriToQuad(theIds, aCriterion, aMaxAngle);
1139 * Class : SMESHGUI_CuttingOfQuadsDlg
1140 * Description : Automatic splitting of quadrangles into triangles
1143 SMESHGUI_CuttingOfQuadsDlg
1144 ::SMESHGUI_CuttingOfQuadsDlg(SMESHGUI* theModule,
1145 const char* theName):
1146 SMESHGUI_MultiEditDlg(theModule, SMESHGUI_QuadFilter, false, theName)
1148 setCaption(tr("CAPTION"));
1151 myPreviewChk = new QCheckBox (tr("PREVIEW"), mySelGrp);
1153 myCriterionGrp->show();
1154 myGroupChoice->show();
1155 myComboBoxFunctor->setEnabled(false);
1157 connect(myPreviewChk , SIGNAL(stateChanged(int)) , this, SLOT(onPreviewChk()));
1158 connect(myGroupChoice , SIGNAL(clicked(int)) , this, SLOT(onCriterionRB()));
1159 connect(myComboBoxFunctor, SIGNAL(activated(int)) , this, SLOT(onPreviewChk()));
1160 connect(this , SIGNAL(ListContensChanged()), this, SLOT(onPreviewChk()));
1162 myHelpFileName = "cutting_quadrangles_page.html";
1165 SMESHGUI_CuttingOfQuadsDlg::~SMESHGUI_CuttingOfQuadsDlg()
1169 void SMESHGUI_CuttingOfQuadsDlg::onClose()
1172 SMESHGUI_MultiEditDlg::onClose();
1175 bool SMESHGUI_CuttingOfQuadsDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
1176 const SMESH::long_array& theIds)
1178 switch (myGroupChoice->id(myGroupChoice->selected())) {
1179 case 0: // use diagonal 1-3
1180 return theEditor->SplitQuad(theIds, true);
1181 case 1: // use diagonal 2-4
1182 return theEditor->SplitQuad(theIds, false);
1183 default: // use numeric functor
1187 SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
1188 return theEditor->QuadToTri(theIds, aCriterion);
1191 void SMESHGUI_CuttingOfQuadsDlg::onCriterionRB()
1193 if (myGroupChoice->id(myGroupChoice->selected()) == 2) // Use numeric functor
1194 myComboBoxFunctor->setEnabled(true);
1196 myComboBoxFunctor->setEnabled(false);
1201 void SMESHGUI_CuttingOfQuadsDlg::onPreviewChk()
1203 myPreviewChk->isChecked() ? displayPreview() : erasePreview();
1206 void SMESHGUI_CuttingOfQuadsDlg::erasePreview()
1208 if (myPreviewActor == 0)
1211 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) {
1212 vf->RemoveActor(myPreviewActor);
1215 myPreviewActor->Delete();
1219 void SMESHGUI_CuttingOfQuadsDlg::displayPreview()
1224 if (myPreviewActor != 0)
1227 // get Ids of elements
1228 SMESH::long_array_var anElemIds = getIds();
1229 if (getIds()->length() == 0)
1232 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
1236 // 0 - use diagonal 1-3, 1 - use diagonal 2-4, 2 - use numerical functor
1237 int aChoice = myGroupChoice->id(myGroupChoice->selected());
1238 SMESH::NumericalFunctor_var aCriterion = SMESH::NumericalFunctor::_nil();
1239 SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH::SMESH_MeshEditor::_nil();
1241 aCriterion = getNumericalFunctor();
1242 aMeshEditor = myMesh->GetMeshEditor();
1243 if (aMeshEditor->_is_nil())
1248 vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
1250 vtkIdType aNbCells = anElemIds->length() * 2;
1251 vtkIdType aCellsSize = 4 * aNbCells;
1252 vtkCellArray* aConnectivity = vtkCellArray::New();
1253 aConnectivity->Allocate(aCellsSize, 0);
1255 vtkPoints* aPoints = vtkPoints::New();
1256 aPoints->SetNumberOfPoints(anElemIds->length() * 4);
1258 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1259 aCellTypesArray->SetNumberOfComponents(1);
1260 aCellTypesArray->Allocate(aNbCells * aCellTypesArray->GetNumberOfComponents());
1262 vtkIdList *anIdList = vtkIdList::New();
1263 anIdList->SetNumberOfIds(3);
1265 TColStd_DataMapOfIntegerInteger anIdToVtk;
1269 for (int i = 0, n = anElemIds->length(); i < n; i++)
1271 const SMDS_MeshElement* anElem = aMesh->FindElement(anElemIds[ i ]);
1272 if (anElem == 0 || anElem->NbNodes() != 4)
1275 SMDS_ElemIteratorPtr anIter = anElem->nodesIterator();
1277 while (anIter->more()) {
1278 const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(anIter->next());
1281 if (!anIdToVtk.IsBound(aNode->GetID()))
1283 aPoints->SetPoint(++nbPoints, aNode->X(), aNode->Y(), aNode->Z());
1284 anIdToVtk.Bind(aNode->GetID(), nbPoints);
1287 aNodes[ k++ ] = aNode->GetID();
1294 bool isDiag13 = true;
1295 if (aChoice == 0) // use diagonal 1-3
1299 else if (aChoice == 1) // use diagonal 2-4
1303 else // use numerical functor
1305 // compare two sets of possible triangles
1306 int diag = aMeshEditor->BestSplit(anElemIds[i], aCriterion);
1307 if (diag == 1) // 1-3
1309 else if (diag == 2) // 2-4
1317 anIdList->SetId(0, anIdToVtk(aNodes[ 0 ]));
1318 anIdList->SetId(1, anIdToVtk(aNodes[ 1 ]));
1319 anIdList->SetId(2, anIdToVtk(aNodes[ 2 ]));
1320 aConnectivity->InsertNextCell(anIdList);
1321 aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1323 anIdList->SetId(0, anIdToVtk(aNodes[ 2 ]));
1324 anIdList->SetId(1, anIdToVtk(aNodes[ 3 ]));
1325 anIdList->SetId(2, anIdToVtk(aNodes[ 0 ]));
1326 aConnectivity->InsertNextCell(anIdList);
1327 aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1331 anIdList->SetId(0, anIdToVtk(aNodes[ 1 ]));
1332 anIdList->SetId(1, anIdToVtk(aNodes[ 2 ]));
1333 anIdList->SetId(2, anIdToVtk(aNodes[ 3 ]));
1334 aConnectivity->InsertNextCell(anIdList);
1335 aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1337 anIdList->SetId(0, anIdToVtk(aNodes[ 3 ]));
1338 anIdList->SetId(1, anIdToVtk(aNodes[ 0 ]));
1339 anIdList->SetId(2, anIdToVtk(aNodes[ 1 ]));
1340 aConnectivity->InsertNextCell(anIdList);
1341 aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1345 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
1346 aCellLocationsArray->SetNumberOfComponents(1);
1347 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1349 aConnectivity->InitTraversal();
1350 for(vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell(npts, pts); idType++)
1351 aCellLocationsArray->SetValue(idType, aConnectivity->GetTraversalLocation(npts));
1353 aGrid->SetPoints(aPoints);
1354 aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aConnectivity);
1356 // Create and display actor
1357 vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
1358 aMapper->SetInput(aGrid);
1360 myPreviewActor = SALOME_Actor::New();
1361 myPreviewActor->PickableOff();
1362 myPreviewActor->SetMapper(aMapper);
1364 vtkProperty* aProp = vtkProperty::New();
1365 aProp->SetRepresentationToWireframe();
1366 aProp->SetColor(250, 0, 250);
1367 aProp->SetLineWidth(myActor->GetLineWidth() + 1);
1368 myPreviewActor->SetProperty(aProp);
1370 SMESH::GetCurrentVtkView()->AddActor(myPreviewActor);
1371 SMESH::GetCurrentVtkView()->Repaint();
1375 aConnectivity->Delete();
1379 aCellTypesArray->Delete();
1380 aCellLocationsArray->Delete();