1 // Copyright (C) 2007-2020 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, or (at your option) any later version.
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
23 // File : SMESHGUI_MultiEditDlg.cxx
24 // Author : Sergey LITONIN, Open CASCADE S.A.S.
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"
37 #include "SMESHGUI_MeshEditPreview.h"
39 #include "SMDS_Mesh.hxx"
40 #include "SMDS_MeshNode.hxx"
41 #include "SMDS_VolumeTool.hxx"
42 #include "SMESH_Actor.h"
43 #include "SMESH_MeshAlgos.hxx"
44 #include "SMESH_TypeFilter.hxx"
46 // SALOME GUI includes
47 #include <SUIT_Desktop.h>
48 #include <SUIT_MessageBox.h>
49 #include <SUIT_OverrideCursor.h>
50 #include <SUIT_ResourceMgr.h>
51 #include <SUIT_Session.h>
53 #include <LightApp_SelectionMgr.h>
54 #include <LightApp_Application.h>
55 #include <SALOME_ListIO.hxx>
56 #include <SalomeApp_Tools.h>
58 #include <SVTK_Selector.h>
59 #include <SVTK_ViewWindow.h>
60 #include <VTKViewer_CellLocationsArray.h>
63 #include <Bnd_B3d.hxx>
64 #include <TColStd_DataMapOfIntegerInteger.hxx>
65 #include <TColStd_IndexedMapOfInteger.hxx>
66 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
70 #include <vtkIdList.h>
71 #include <vtkCellArray.h>
72 #include <vtkUnsignedCharArray.h>
73 #include <vtkUnstructuredGrid.h>
74 #include <vtkDataSetMapper.h>
75 #include <vtkProperty.h>
79 #include <QVBoxLayout>
80 #include <QHBoxLayout>
81 #include <QGridLayout>
82 #include <QListWidget>
87 #include <QPushButton>
88 #include <QButtonGroup>
89 #include <QRadioButton>
93 #include <SALOMEconfig.h>
94 #include CORBA_SERVER_HEADER(SMESH_Group)
100 * Class : SMESHGUI_MultiEditDlg
101 * Description : Description : Inversion of the diagonal of a pseudo-quadrangle formed by
102 * 2 neighboring triangles with 1 common edge
105 //=======================================================================
106 // name : SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg
107 // Purpose : Constructor
108 //=======================================================================
109 SMESHGUI_MultiEditDlg
110 ::SMESHGUI_MultiEditDlg(SMESHGUI* theModule,
114 SMESHGUI_PreviewDlg(theModule),
115 mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
116 mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
117 mySMESHGUI(theModule)
120 setAttribute(Qt::WA_DeleteOnClose, true);
125 myFilterType = theMode;
126 QVBoxLayout* aDlgLay = new QVBoxLayout(this);
127 aDlgLay->setMargin(MARGIN);
128 aDlgLay->setSpacing(SPACING);
130 QWidget* aMainFrame = createMainFrame (this, the3d2d);
131 QWidget* aBtnFrame = createButtonFrame(this);
133 aDlgLay->addWidget(aMainFrame);
134 aDlgLay->addWidget(aBtnFrame);
140 //=======================================================================
141 // name : SMESHGUI_MultiEditDlg::createMainFrame
142 // Purpose : Create frame containing dialog's input fields
143 //=======================================================================
144 QWidget* SMESHGUI_MultiEditDlg::createMainFrame (QWidget* theParent, const bool the3d2d)
146 QWidget* aMainGrp = new QWidget(theParent);
147 QVBoxLayout* aMainGrpLayout = new QVBoxLayout(aMainGrp);
148 aMainGrpLayout->setMargin(0);
149 aMainGrpLayout->setSpacing(SPACING);
151 QPixmap aPix (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
153 // "Selected cells" group
154 mySelGrp = new QGroupBox(aMainGrp);
156 QGridLayout* mySelGrpLayout = new QGridLayout(mySelGrp);
157 mySelGrpLayout->setMargin(MARGIN);
158 mySelGrpLayout->setSpacing(SPACING);
162 QGroupBox* aEntityTypeGrp = new QGroupBox(tr("SMESH_ELEMENTS_TYPE"), mySelGrp);
163 myEntityTypeGrp = new QButtonGroup(mySelGrp);
164 QHBoxLayout* aEntityLayout = new QHBoxLayout(aEntityTypeGrp);
165 aEntityLayout->setMargin(MARGIN);
166 aEntityLayout->setSpacing(SPACING);
168 QRadioButton* aFaceRb = new QRadioButton(tr("SMESH_FACE"), aEntityTypeGrp);
169 QRadioButton* aVolumeRb = new QRadioButton(tr("SMESH_VOLUME"), aEntityTypeGrp);
172 aEntityLayout->addWidget(aFaceRb);
173 aEntityLayout->addWidget(aVolumeRb);
175 myEntityTypeGrp->addButton(aFaceRb, 0);
176 myEntityTypeGrp->addButton(aVolumeRb, 1);
177 aFaceRb->setChecked(true);
178 myEntityType = myEntityTypeGrp->checkedId();
180 mySelGrpLayout->addWidget(aEntityTypeGrp, 0, 0, 1, 2);
183 myListBox = new QListWidget(mySelGrp);
184 myListBox->setSelectionMode(QListWidget::ExtendedSelection);
185 myListBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
186 myListBox->installEventFilter(this);
188 myFilterBtn = new QPushButton(tr("FILTER"), mySelGrp);
189 myAddBtn = new QPushButton(tr("ADD"), mySelGrp);
190 myRemoveBtn = new QPushButton(tr("REMOVE"), mySelGrp);
191 mySortBtn = new QPushButton(tr("SORT_LIST"), mySelGrp);
193 int row = mySelGrpLayout->rowCount();
194 mySelGrpLayout->addWidget(myListBox, row, 0, 6, 1);
195 mySelGrpLayout->addWidget(myFilterBtn, row, 1);
196 mySelGrpLayout->addWidget(myAddBtn, row+2, 1);
197 mySelGrpLayout->addWidget(myRemoveBtn, row+3, 1);
198 mySelGrpLayout->addWidget(mySortBtn, row+5, 1);
199 mySelGrpLayout->setRowMinimumHeight(row+1, 10);
200 mySelGrpLayout->setRowMinimumHeight(row+4, 10);
201 mySelGrpLayout->setRowStretch(row+1, 5);
202 mySelGrpLayout->setRowStretch(row+4, 5);
204 myToAllChk = new QCheckBox(tr("TO_ALL"), mySelGrp);
205 mySelGrpLayout->addWidget(myToAllChk, mySelGrpLayout->rowCount(), 0,
206 1, mySelGrpLayout->columnCount());
208 // Split/Join criterion group
209 myCriterionGrp = new QGroupBox(tr("SPLIT_JOIN_CRITERION"), aMainGrp);
210 QVBoxLayout* aCriterionLayout = new QVBoxLayout(myCriterionGrp);
211 aCriterionLayout->setMargin(MARGIN);
212 aCriterionLayout->setSpacing(SPACING);
214 myChoiceWidget = new QWidget(myCriterionGrp);
215 myGroupChoice = new QButtonGroup(myChoiceWidget);
216 QVBoxLayout* aGroupChoiceLayout = new QVBoxLayout(myChoiceWidget);
217 aGroupChoiceLayout->setMargin(0);
218 aGroupChoiceLayout->setSpacing(SPACING);
220 QRadioButton* aDiag13RB = new QRadioButton(tr("USE_DIAGONAL_1_3"), myChoiceWidget);
221 QRadioButton* aDiag24RB = new QRadioButton(tr("USE_DIAGONAL_2_4"), myChoiceWidget);
222 QRadioButton* aNumFuncRB = new QRadioButton(tr("USE_NUMERIC_FUNC"), myChoiceWidget);
224 aGroupChoiceLayout->addWidget(aDiag13RB);
225 aGroupChoiceLayout->addWidget(aDiag24RB);
226 aGroupChoiceLayout->addWidget(aNumFuncRB);
227 myGroupChoice->addButton(aDiag13RB, 0);
228 myGroupChoice->addButton(aDiag24RB, 1);
229 myGroupChoice->addButton(aNumFuncRB, 2);
230 aDiag13RB->setChecked(true);
232 myComboBoxFunctor = new QComboBox(myCriterionGrp);
233 myComboBoxFunctor->addItem(tr("ASPECTRATIO_ELEMENTS"));
234 myComboBoxFunctor->addItem(tr("MINIMUMANGLE_ELEMENTS"));
235 myComboBoxFunctor->addItem(tr("SKEW_ELEMENTS"));
236 myComboBoxFunctor->setCurrentIndex(0);
238 aCriterionLayout->addWidget(myChoiceWidget);
239 aCriterionLayout->addWidget(myComboBoxFunctor);
241 myCriterionGrp->hide();
242 myChoiceWidget->hide();
243 myComboBoxFunctor->setEnabled(false);
245 // "Select from" group
246 QGroupBox* aGrp = new QGroupBox(tr("SELECT_FROM"), aMainGrp);
247 QGridLayout* aGrpLayout = new QGridLayout(aGrp);
248 aGrpLayout->setMargin(MARGIN);
249 aGrpLayout->setSpacing(SPACING);
251 mySubmeshChk = new QCheckBox(tr("SMESH_SUBMESH"), aGrp);
252 mySubmeshBtn = new QPushButton(aGrp);
253 mySubmesh = new QLineEdit(aGrp);
254 mySubmesh->setReadOnly(true);
255 mySubmeshBtn->setIcon(aPix);
257 myGroupChk = new QCheckBox(tr("SMESH_GROUP"), aGrp);
258 myGroupBtn = new QPushButton(aGrp);
259 myGroup = new QLineEdit(aGrp);
260 myGroup->setReadOnly(true);
261 myGroupBtn->setIcon(aPix);
263 aGrpLayout->addWidget(mySubmeshChk,0,0);
264 aGrpLayout->addWidget(mySubmeshBtn,0,1);
265 aGrpLayout->addWidget(mySubmesh,0,2);
266 aGrpLayout->addWidget(myGroupChk,1,0);
267 aGrpLayout->addWidget(myGroupBtn,1,1);
268 aGrpLayout->addWidget(myGroup,1,2);
270 aMainGrpLayout->addWidget(mySelGrp);
271 aMainGrpLayout->addWidget(myCriterionGrp);
272 aMainGrpLayout->addWidget(aGrp);
277 //=======================================================================
278 // name : SMESHGUI_MultiEditDlg::createButtonFrame
279 // Purpose : Create frame containing buttons
280 //=======================================================================
281 QWidget* SMESHGUI_MultiEditDlg::createButtonFrame (QWidget* theParent)
283 QGroupBox* aFrame = new QGroupBox(theParent);
285 myOkBtn = new QPushButton (tr("SMESH_BUT_APPLY_AND_CLOSE"), aFrame);
286 myApplyBtn = new QPushButton (tr("SMESH_BUT_APPLY"), aFrame);
287 myCloseBtn = new QPushButton (tr("SMESH_BUT_CLOSE"), aFrame);
288 myHelpBtn = new QPushButton (tr("SMESH_BUT_HELP"), aFrame);
290 QHBoxLayout* aLay = new QHBoxLayout (aFrame);
291 aLay->setMargin(MARGIN);
292 aLay->setSpacing(SPACING);
294 aLay->addWidget(myOkBtn);
295 aLay->addSpacing(10);
296 aLay->addWidget(myApplyBtn);
297 aLay->addSpacing(10);
299 aLay->addWidget(myCloseBtn);
300 aLay->addWidget(myHelpBtn);
305 //=======================================================================
306 // name : SMESHGUI_MultiEditDlg::isValid
307 // Purpose : Verify validity of input data
308 //=======================================================================
309 bool SMESHGUI_MultiEditDlg::isValid (const bool /*theMess*/)
311 return (!myMesh->_is_nil() &&
312 (myListBox->count() > 0 || (myToAllChk->isChecked() && nbElemsInMesh() > 0)));
315 //=======================================================================
316 // name : SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg
317 // Purpose : Destructor
318 //=======================================================================
319 SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg()
321 if (myFilterDlg != 0)
323 myFilterDlg->setParent(0);
328 //=======================================================================
329 // name : SMESHGUI_MultiEditDlg::eventFilter
330 // Purpose : event filter
331 //=======================================================================
332 bool SMESHGUI_MultiEditDlg::eventFilter (QObject* object, QEvent* event)
334 if (object == myListBox && event->type() == QEvent::KeyPress) {
335 QKeyEvent* ke = (QKeyEvent*)event;
336 if (ke->key() == Qt::Key_Delete)
339 return QDialog::eventFilter(object, event);
342 //=======================================================================
343 // name : SMESHGUI_MultiEditDlg::getNumericalFunctor
345 //=======================================================================
346 SMESH::NumericalFunctor_ptr SMESHGUI_MultiEditDlg::getNumericalFunctor()
348 SMESH::NumericalFunctor_var aNF = SMESH::NumericalFunctor::_nil();
350 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
351 if (aFilterMgr->_is_nil())
354 if (myComboBoxFunctor->currentText() == tr("ASPECTRATIO_ELEMENTS"))
355 aNF = aFilterMgr->CreateAspectRatio();
356 else if (myComboBoxFunctor->currentText() == tr("WARP_ELEMENTS"))
357 aNF = aFilterMgr->CreateWarping();
358 else if (myComboBoxFunctor->currentText() == tr("MINIMUMANGLE_ELEMENTS"))
359 aNF = aFilterMgr->CreateMinimumAngle();
360 else if (myComboBoxFunctor->currentText() == tr("TAPER_ELEMENTS"))
361 aNF = aFilterMgr->CreateTaper();
362 else if (myComboBoxFunctor->currentText() == tr("SKEW_ELEMENTS"))
363 aNF = aFilterMgr->CreateSkew();
364 else if (myComboBoxFunctor->currentText() == tr("AREA_ELEMENTS"))
365 aNF = aFilterMgr->CreateArea();
366 else if (myComboBoxFunctor->currentText() == tr("LENGTH2D_EDGES"))
367 aNF = aFilterMgr->CreateLength2D();
368 else if (myComboBoxFunctor->currentText() == tr("MULTI2D_BORDERS"))
369 aNF = aFilterMgr->CreateMultiConnection2D();
370 else if (myComboBoxFunctor->currentText() == tr("MIN_DIAG_ELEMENTS"))
371 aNF = aFilterMgr->CreateMaxElementLength2D();
377 //=======================================================================
378 // name : SMESHGUI_MultiEditDlg::Init
379 // Purpose : Init dialog fields, connect signals and slots, show dialog
380 //=======================================================================
381 void SMESHGUI_MultiEditDlg::Init()
383 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
388 emit ListContensChanged();
391 connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
392 connect(myCloseBtn, SIGNAL(clicked()), SLOT(reject()));
393 connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
394 connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
396 // selection and SMESHGUI
397 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
398 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
399 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject()));
400 connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), SLOT( onOpenView()));
401 connect(mySMESHGUI, SIGNAL(SignalCloseView()), SLOT( onCloseView()));
404 connect(myFilterBtn, SIGNAL(clicked()), SLOT(onFilterBtn() ));
405 connect(myAddBtn, SIGNAL(clicked()), SLOT(onAddBtn() ));
406 connect(myRemoveBtn, SIGNAL(clicked()), SLOT(onRemoveBtn() ));
407 connect(mySortBtn, SIGNAL(clicked()), SLOT(onSortListBtn()));
409 connect(mySubmeshChk, SIGNAL(stateChanged(int)), SLOT(onSubmeshChk()));
410 connect(myGroupChk, SIGNAL(stateChanged(int)), SLOT(onGroupChk() ));
411 connect(myToAllChk, SIGNAL(stateChanged(int)), SLOT(onToAllChk() ));
414 connect(myEntityTypeGrp, SIGNAL(buttonClicked(int)), SLOT(on3d2dChanged(int)));
416 connect(myListBox, SIGNAL(itemSelectionChanged()), SLOT(onListSelectionChanged()));
420 // set selection mode
425 //=======================================================================
426 // name : SMESHGUI_MultiEditDlg::onOk
427 // Purpose : SLOT called when "Ok" button pressed.
428 // Assign filters VTK viewer and close dialog
429 //=======================================================================
430 void SMESHGUI_MultiEditDlg::onOk()
436 //=======================================================================
437 // name : SMESHGUI_MultiEditDlg::getIds
438 // Purpose : Retrieve identifiers from list box or the whole object
439 //=======================================================================
441 SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds(SMESH::SMESH_IDSource_var& obj)
443 SMESH::long_array_var anIds = new SMESH::long_array;
445 if (myToAllChk->isChecked())
448 obj = SMESH::SMESH_IDSource::_narrow( myMesh );
451 anIds->length(myIds.Extent());
452 TColStd_MapIteratorOfMapOfInteger anIter(myIds);
453 for (int i = 0; anIter.More(); anIter.Next() )
455 anIds[ i++ ] = anIter.Key();
457 return anIds._retn();
460 //=======================================================================
461 // name : SMESHGUI_MultiEditDlg::reject
462 // Purpose : SLOT called when "Close" button pressed. Close dialog
463 //=======================================================================
464 void SMESHGUI_MultiEditDlg::reject()
466 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
467 aViewWindow->SetSelectionMode(ActorSelection);
468 disconnect(mySelectionMgr, 0, this, 0);
469 disconnect(mySMESHGUI, 0, this, 0);
470 mySMESHGUI->ResetState();
472 SMESH::RemoveFilters();
473 SMESH::SetPickable();
475 //mySelectionMgr->clearSelected();
476 mySelectionMgr->clearFilters();
481 //=================================================================================
482 // function : onOpenView()
484 //=================================================================================
485 void SMESHGUI_MultiEditDlg::onOpenView()
488 mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
489 mySMESHGUI->EmitSignalDeactivateDialog();
494 //=================================================================================
495 // function : onCloseView()
497 //=================================================================================
498 void SMESHGUI_MultiEditDlg::onCloseView()
505 //=================================================================================
506 // function : onHelp()
508 //=================================================================================
509 void SMESHGUI_MultiEditDlg::onHelp()
511 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
513 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
517 platform = "winapplication";
519 platform = "application";
521 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
522 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
523 arg(app->resourceMgr()->stringValue("ExternalBrowser",
525 arg(myHelpFileName));
529 //=======================================================================
530 // name : SMESHGUI_MultiEditDlg::onSelectionDone
531 // Purpose : SLOT called when selection changed
532 //=======================================================================
533 void SMESHGUI_MultiEditDlg::onSelectionDone()
535 if (myBusy || !isEnabled()) return;
538 const SALOME_ListIO& aList = mySelector->StoredIObjects();
540 int nbSel = aList.Extent();
541 myListBox->clearSelection();
543 if (mySubmeshChk->isChecked() || myGroupChk->isChecked()) {
544 QLineEdit* aNameEdit = mySubmeshChk->isChecked() ? mySubmesh : myGroup;
546 Handle(SALOME_InteractiveObject) anIO = aList.First();
548 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
549 anIO.IsNull() ? aNameEdit->clear() : aNameEdit->setText(aName);
551 if (mySubmeshChk->isChecked()) {
552 SMESH::SMESH_subMesh_var aSubMesh =
553 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIO);
554 if (!aSubMesh->_is_nil())
555 myMesh = aSubMesh->GetFather();
557 SMESH::SMESH_GroupBase_var aGroup =
558 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIO);
559 if (!aGroup->_is_nil())
560 myMesh = aGroup->GetMesh();
562 } else if (nbSel > 1) {
563 QString aStr = mySubmeshChk->isChecked() ?
564 tr("SMESH_SUBMESH_SELECTED") : tr("SMESH_GROUP_SELECTED");
565 aNameEdit->setText(aStr.arg(nbSel));
569 } else if (nbSel > 0) {
570 QString aListStr = "";
571 Handle(SALOME_InteractiveObject) anIO = aList.First();
572 int aNbItems = SMESH::GetNameOfSelectedElements(mySelector,anIO,aListStr);
574 QStringList anElements = aListStr.split(" ", QString::SkipEmptyParts);
575 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
576 QList<QListWidgetItem*> items = myListBox->findItems(*it, Qt::MatchExactly);
577 QListWidgetItem* anItem;
578 foreach(anItem, items)
579 anItem->setSelected(true);
582 SMESH::SMESH_Mesh_var aSelMesh = SMESH::GetMeshByIO(anIO);
583 if (!aSelMesh->_is_nil())
588 myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
590 myActor = SMESH::FindActorByObject(myMesh);
591 SVTK_Selector* aSelector = SMESH::GetSelector();
592 Handle(VTKViewer_Filter) aFilter = aSelector->GetFilter(myFilterType);
593 if (!aFilter.IsNull())
594 aFilter->SetActor(myActor);
601 //=======================================================================
602 // name : SMESHGUI_MultiEditDlg::onDeactivate
603 // Purpose : SLOT called when dialog must be deactivated
604 //=======================================================================
605 void SMESHGUI_MultiEditDlg::onDeactivate()
610 //=======================================================================
611 // name : SMESHGUI_MultiEditDlg::enterEvent
612 // Purpose : Event filter
613 //=======================================================================
614 void SMESHGUI_MultiEditDlg::enterEvent (QEvent*)
617 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
618 if ( aViewWindow && !mySelector) {
619 mySelector = aViewWindow->GetSelector();
621 mySMESHGUI->EmitSignalDeactivateDialog();
627 //=======================================================================
628 // name : SMESHGUI_MultiEditDlg::onFilterBtn
629 // Purpose : SLOT. Called when "Filter" button pressed.
630 // Start "Selection filters" dialog
631 //=======================================================================
632 void SMESHGUI_MultiEditDlg::onFilterBtn()
634 if (myFilterDlg == 0) {
635 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, entityType() ? SMESH::VOLUME : SMESH::FACE);
636 connect(myFilterDlg, SIGNAL(Accepted()), SLOT(onFilterAccepted()));
638 myFilterDlg->Init(entityType() ? SMESH::VOLUME : SMESH::FACE);
641 myFilterDlg->SetSelection();
642 myFilterDlg->SetMesh(myMesh);
643 myFilterDlg->SetSourceWg(myListBox, false);
648 //=======================================================================
649 // name : onFilterAccepted()
650 // Purpose : SLOT. Called when Filter dlg closed with OK button.
651 // Uncheck "Select submesh" and "Select group" checkboxes
652 //=======================================================================
653 void SMESHGUI_MultiEditDlg::onFilterAccepted()
656 for (int i = 0, n = myListBox->count(); i < n; i++)
657 myIds.Add(myListBox->item(i)->text().toInt());
659 emit ListContensChanged();
661 if (mySubmeshChk->isChecked() || myGroupChk->isChecked()) {
662 mySubmeshChk->blockSignals(true);
663 myGroupChk->blockSignals(true);
664 mySubmeshChk->setChecked(false);
665 myGroupChk->setChecked(false);
666 mySubmeshChk->blockSignals(false);
667 myGroupChk->blockSignals(false);
672 //=======================================================================
673 // name : SMESHGUI_MultiEditDlg::isIdValid
674 // Purpose : Verify whether Id of element satisfies to filters from viewer
675 //=======================================================================
676 bool SMESHGUI_MultiEditDlg::isIdValid (const int theId) const
679 return true; // filter can't work w/o actor
681 SVTK_Selector* aSelector = SMESH::GetSelector();
682 Handle(SMESHGUI_Filter) aFilter =
683 Handle(SMESHGUI_Filter)::DownCast(aSelector->GetFilter(myFilterType));
685 return (!aFilter.IsNull() && aFilter->IsObjValid(theId));
688 //=======================================================================
689 // name : SMESHGUI_MultiEditDlg::onAddBtn
690 // Purpose : SLOT. Called when "Add" button pressed.
691 // Add selected in viewer entities in list box
692 //=======================================================================
693 void SMESHGUI_MultiEditDlg::onAddBtn()
695 const SALOME_ListIO& aList = mySelector->StoredIObjects();
697 int nbSelected = aList.Extent();
701 TColStd_IndexedMapOfInteger toBeAdded;
703 if (!mySubmeshChk->isChecked() && !myGroupChk->isChecked()) {
705 mySelector->GetIndex(aList.First(),toBeAdded);
706 } else if (mySubmeshChk->isChecked()) {
707 SALOME_ListIteratorOfListIO anIter(aList);
708 for ( ; anIter.More(); anIter.Next()) {
709 SMESH::SMESH_subMesh_var aSubMesh =
710 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIter.Value());
711 if (!aSubMesh->_is_nil()) {
712 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
713 SMESH::long_array_var anIds = aSubMesh->GetElementsId();
714 for (int i = 0, n = anIds->length(); i < n; i++) {
715 if (isIdValid(anIds[ i ]))
716 toBeAdded.Add(anIds[ i ]);
721 } else if (myGroupChk->isChecked()) {
722 SALOME_ListIteratorOfListIO anIter(aList);
723 for ( ; anIter.More(); anIter.Next()) {
724 SMESH::SMESH_GroupBase_var aGroup =
725 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value());
726 if (!aGroup->_is_nil() && ((aGroup->GetType() == SMESH::FACE && entityType() == 0) ||
727 (aGroup->GetType() == SMESH::VOLUME && entityType() == 1))) {
728 if (aGroup->GetMesh()->GetId() == myMesh->GetId()) {
729 SMESH::long_array_var anIds = aGroup->GetListOfID();
730 for (int i = 0, n = anIds->length(); i < n; i++) {
731 if (isIdValid(anIds[ i ]))
732 toBeAdded.Add(anIds[ i ]);
741 bool isGroupOrSubmesh = (mySubmeshChk->isChecked() || myGroupChk->isChecked());
742 mySubmeshChk->setChecked(false);
743 myGroupChk->setChecked(false);
745 for(int i = 1; i <= toBeAdded.Extent(); i++)
746 if (myIds.Add(toBeAdded(i))) {
747 items.append(QString("%1").arg(toBeAdded(i)));
749 myListBox->addItems(items);
750 myListBox->selectAll();
753 emit ListContensChanged();
755 if (isGroupOrSubmesh)
756 onListSelectionChanged();
761 //=======================================================================
762 // name : SMESHGUI_MultiEditDlg::updateButtons
763 // Purpose : Enable/disable buttons of dialog in accordance with current state
764 //=======================================================================
765 void SMESHGUI_MultiEditDlg::updateButtons()
767 bool isOk = isValid(false);
768 myOkBtn->setEnabled(isOk);
769 myApplyBtn->setEnabled(isOk);
771 bool isListBoxNonEmpty = myListBox->count() > 0;
772 bool isToAll = myToAllChk->isChecked();
773 myFilterBtn->setEnabled(!isToAll);
774 myRemoveBtn->setEnabled(myListBox->selectedItems().count() && !isToAll);
775 mySortBtn->setEnabled(isListBoxNonEmpty &&!isToAll);
777 const SALOME_ListIO& aList = mySelector->StoredIObjects();
781 aList.Extent() < 1 ||
782 (SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(aList.First())->_is_nil() &&
783 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(aList.First())->_is_nil() &&
784 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(aList.First())->_is_nil()))
785 myAddBtn->setEnabled(false);
787 myAddBtn->setEnabled(true);
789 mySubmeshChk->setEnabled(!isToAll);
790 mySubmeshBtn->setEnabled(mySubmeshChk->isChecked());
791 mySubmesh->setEnabled(mySubmeshChk->isChecked());
793 myGroupChk->setEnabled(!isToAll);
794 myGroupBtn->setEnabled(myGroupChk->isChecked());
795 myGroup->setEnabled(myGroupChk->isChecked());
797 if (!mySubmeshChk->isChecked())
799 if (!myGroupChk->isChecked())
804 //=======================================================================
805 // name : SMESHGUI_MultiEditDlg::onRemoveBtn
806 // Purpose : SLOT. Called when "Remove" button pressed.
807 // Remove selected in list box entities
808 //=======================================================================
809 void SMESHGUI_MultiEditDlg::onRemoveBtn()
813 QList<QListWidgetItem*> selItems = myListBox->selectedItems();
814 QListWidgetItem* item;
815 foreach(item, selItems)
817 myIds.Remove(item->text().toInt());
823 emit ListContensChanged();
827 //=======================================================================
828 // name : SMESHGUI_MultiEditDlg::onSortListBtn
829 // Purpose : SLOT. Called when "Sort list" button pressed.
830 // Sort entities of list box
831 //=======================================================================
832 void SMESHGUI_MultiEditDlg::onSortListBtn()
836 int i, k = myListBox->count();
839 QList<int> aSelected;
840 std::vector<int> anArray(k);
841 for (i = 0; i < k; i++)
843 int id = myListBox->item(i)->text().toInt();
845 if (myListBox->item(i)->isSelected())
846 aSelected.append(id);
849 std::sort(anArray.begin(), anArray.end());
852 for (i = 0; i < k; i++) {
853 QListWidgetItem* item = new QListWidgetItem(QString::number(anArray[i]));
854 myListBox->addItem(item);
855 item->setSelected(aSelected.contains(anArray[i]));
861 //=======================================================================
862 // name : SMESHGUI_MultiEditDlg::onListSelectionChanged
863 // Purpose : SLOT. Called when selection in list box changed.
864 // Highlight in selected entities
865 //=======================================================================
866 void SMESHGUI_MultiEditDlg::onListSelectionChanged()
868 if (myActor == 0 || myBusy)
871 if (mySubmeshChk->isChecked() || myGroupChk->isChecked())
874 SMESH_Actor * anActor = SMESH::FindActorByObject(myMesh);
877 TVisualObjPtr anObj = anActor->GetObject();
879 TColStd_MapOfInteger anIndexes;
880 int total = myListBox->count();
881 for (int i = 0; i < total; i++)
883 if (myListBox->item(i)->isSelected())
885 int anId = myListBox->item(i)->text().toInt();
886 if (anObj->GetElemVTKId(anId) >= 0) // avoid exception in highlight
891 mySelector->AddOrRemoveIndex(anActor->getIO(),anIndexes,false);
892 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
893 aViewWindow->highlight(anActor->getIO(),true,true);
895 myRemoveBtn->setEnabled( anIndexes.Extent() );
898 //=======================================================================
899 // name : SMESHGUI_MultiEditDlg::onSubmeshChk
900 // Purpose : SLOT. Called when state of "SubMesh" check box changed.
901 // Activate/deactivate selection of submeshes
902 //=======================================================================
903 void SMESHGUI_MultiEditDlg::onSubmeshChk()
905 bool isChecked = mySubmeshChk->isChecked();
906 mySubmeshBtn->setEnabled(isChecked);
907 mySubmesh->setEnabled(isChecked);
910 if (isChecked && myGroupChk->isChecked())
911 myGroupChk->setChecked(false);
916 //=======================================================================
917 // name : SMESHGUI_MultiEditDlg::onGroupChk
918 // Purpose : SLOT. Called when state of "Group" check box changed.
919 // Activate/deactivate selection of groupes
920 //=======================================================================
921 void SMESHGUI_MultiEditDlg::onGroupChk()
923 bool isChecked = myGroupChk->isChecked();
924 myGroupBtn->setEnabled(isChecked);
925 myGroup->setEnabled(isChecked);
928 if (isChecked && mySubmeshChk->isChecked())
929 mySubmeshChk->setChecked(false);
934 //=======================================================================
935 // name : SMESHGUI_MultiEditDlg::onToAllChk
936 // Purpose : SLOT. Called when state of "Apply to all" check box changed.
937 // Activate/deactivate selection
938 //=======================================================================
939 void SMESHGUI_MultiEditDlg::onToAllChk()
941 bool isChecked = myToAllChk->isChecked();
948 emit ListContensChanged();
954 //=======================================================================
955 // name : SMESHGUI_MultiEditDlg::setSelectionMode
956 // Purpose : Set selection mode
957 //=======================================================================
958 void SMESHGUI_MultiEditDlg::setSelectionMode()
960 SMESH::RemoveFilters();
962 // mySelectionMgr->clearSelected();
963 mySelectionMgr->clearFilters();
965 if (mySubmeshChk->isChecked()) {
966 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
967 aViewWindow->SetSelectionMode(ActorSelection);
968 mySelectionMgr->installFilter(new SMESH_TypeFilter(SMESH::SUBMESH));
970 else if (myGroupChk->isChecked()) {
971 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
972 aViewWindow->SetSelectionMode(ActorSelection);
973 mySelectionMgr->installFilter(new SMESH_TypeFilter(SMESH::GROUP));
977 SMESH::SetFilter(new SMESHGUI_VolumesFilter());
978 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
979 aViewWindow->SetSelectionMode(VolumeSelection); // here myActor set to a filter
981 if (myFilterType == SMESH::TriaFilter)
982 SMESH::SetFilter(new SMESHGUI_TriangleFilter());
983 else if (myFilterType == SMESH::QuadFilter)
984 SMESH::SetFilter(new SMESHGUI_QuadrangleFilter());
986 SMESH::SetFilter(new SMESHGUI_FacesFilter());
987 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
988 aViewWindow->SetSelectionMode(FaceSelection); // here myActor set to a filter
992 //=======================================================================
993 // name : SMESHGUI_MultiEditDlg::onApply
994 // Purpose : SLOT. Called when "Apply" button clicked.
995 //=======================================================================
996 bool SMESHGUI_MultiEditDlg::onApply()
998 if (SMESHGUI::isStudyLocked())
1003 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
1004 if (aMeshEditor->_is_nil())
1009 SUIT_OverrideCursor aWaitCursor;
1011 SMESH::SMESH_IDSource_var obj;
1012 SMESH::long_array_var anIds = getIds(obj);
1014 bool aResult = process(aMeshEditor, anIds.inout(), obj);
1018 mySelectionMgr->selectedObjects( sel );
1019 mySelector->ClearIndex();
1020 mySelectionMgr->setSelectedObjects( sel );
1021 SMESH::UpdateView();
1022 SMESHGUI::Modified();
1027 emit ListContensChanged();
1031 obj._retn(); // else myMesh is deleted by ~obj
1037 //=======================================================================
1038 // name : SMESHGUI_MultiEditDlg::on3d2dChanged
1040 //=======================================================================
1041 void SMESHGUI_MultiEditDlg::on3d2dChanged (int type)
1043 if (myEntityType != type) {
1044 myEntityType = type;
1049 emit ListContensChanged();
1052 myFilterType = SMESH::VolumeFilter;
1054 myFilterType = SMESH::FaceFilter;
1061 //=======================================================================
1062 // name : SMESHGUI_MultiEditDlg::entityType
1064 //=======================================================================
1065 int SMESHGUI_MultiEditDlg::entityType()
1067 return myEntityType;
1070 //=================================================================================
1071 // function : keyPressEvent()
1073 //=================================================================================
1074 void SMESHGUI_MultiEditDlg::keyPressEvent( QKeyEvent* e )
1076 QDialog::keyPressEvent( e );
1077 if ( e->isAccepted() )
1080 if ( e->key() == Qt::Key_F1 ) {
1087 * Class : SMESHGUI_ChangeOrientationDlg
1088 * Description : Modification of orientation of faces
1091 SMESHGUI_ChangeOrientationDlg
1092 ::SMESHGUI_ChangeOrientationDlg(SMESHGUI* theModule):
1093 SMESHGUI_MultiEditDlg(theModule, SMESH::FaceFilter, true)
1095 setWindowTitle(tr("CAPTION"));
1096 myHelpFileName = "changing_orientation_of_elements.html";
1099 SMESHGUI_ChangeOrientationDlg::~SMESHGUI_ChangeOrientationDlg()
1103 bool SMESHGUI_ChangeOrientationDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
1104 const SMESH::long_array& theIds,
1105 SMESH::SMESH_IDSource_ptr obj)
1107 if ( CORBA::is_nil( obj ))
1108 return theEditor->Reorient(theIds);
1110 return theEditor->ReorientObject( obj );
1113 int SMESHGUI_ChangeOrientationDlg::nbElemsInMesh()
1115 return ( myFilterType == SMESH::FaceFilter ) ? myMesh->NbFaces() : myMesh->NbVolumes();
1119 * Class : SMESHGUI_UnionOfTrianglesDlg
1120 * Description : Construction of quadrangles by automatic association of triangles
1123 SMESHGUI_UnionOfTrianglesDlg
1124 ::SMESHGUI_UnionOfTrianglesDlg(SMESHGUI* theModule):
1125 SMESHGUI_MultiEditDlg(theModule, SMESH::TriaFilter, false)
1127 setWindowTitle(tr("CAPTION"));
1130 myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), mySelGrp);
1131 QGridLayout* aLay = (QGridLayout*)(mySelGrp->layout());
1132 aLay->addWidget(myPreviewCheckBox, aLay->rowCount(), 0, 1, aLay->columnCount());
1134 myComboBoxFunctor->setEnabled(true);
1135 myComboBoxFunctor->addItem(tr("AREA_ELEMENTS"));
1136 myComboBoxFunctor->addItem(tr("WARP_ELEMENTS")); // for quadrangles only
1137 myComboBoxFunctor->addItem(tr("TAPER_ELEMENTS")); // for quadrangles only
1140 QWidget* aMaxAngleGrp = new QWidget(myCriterionGrp);
1141 QHBoxLayout* aMaxAngleGrpLayout = new QHBoxLayout(aMaxAngleGrp);
1142 aMaxAngleGrpLayout->setMargin(0);
1143 aMaxAngleGrpLayout->setSpacing(SPACING);
1145 QLabel* aLab = new QLabel (tr("MAXIMUM_ANGLE"), aMaxAngleGrp);
1146 myMaxAngleSpin = new SMESHGUI_SpinBox (aMaxAngleGrp);
1147 myMaxAngleSpin->RangeStepAndValidator(0, 180.0, 1.0, "angle_precision");
1148 myMaxAngleSpin->SetValue(30.0);
1150 aMaxAngleGrpLayout->addWidget(aLab);
1151 aMaxAngleGrpLayout->addWidget(myMaxAngleSpin);
1153 ((QVBoxLayout*)(myCriterionGrp->layout()))->addWidget(aMaxAngleGrp);
1154 myCriterionGrp->show();
1156 connect(myComboBoxFunctor, SIGNAL(activated(int)), this, SLOT(toDisplaySimulation()));
1157 connect(myMaxAngleSpin, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
1158 connect(this, SIGNAL(ListContensChanged()), this, SLOT(toDisplaySimulation()));
1159 connectPreviewControl(); //To Connect preview check box
1161 myPreviewCheckBox->setChecked(false);
1162 onDisplaySimulation(false);
1164 myHelpFileName = "uniting_set_of_triangles.html";
1167 SMESHGUI_UnionOfTrianglesDlg::~SMESHGUI_UnionOfTrianglesDlg()
1171 bool SMESHGUI_UnionOfTrianglesDlg::isValid (const bool theMess)
1173 bool ok = SMESHGUI_MultiEditDlg::isValid( theMess );
1178 ok = myMaxAngleSpin->isValid( msg, theMess );
1181 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1182 if ( !msg.isEmpty() )
1184 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1192 bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
1193 const SMESH::long_array& theIds,
1194 SMESH::SMESH_IDSource_ptr obj)
1197 QStringList aParameters;
1198 aParameters << myMaxAngleSpin->text();
1199 myMesh->SetParameters( aParameters.join(":").toUtf8().constData() );
1201 SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
1202 double aMaxAngle = myMaxAngleSpin->GetValue() * M_PI / 180.0;
1204 if ( CORBA::is_nil( obj ))
1205 ok = theEditor->TriToQuad(theIds, aCriterion, aMaxAngle);
1207 ok = theEditor->TriToQuadObject(obj, aCriterion, aMaxAngle);
1211 int SMESHGUI_UnionOfTrianglesDlg::nbElemsInMesh()
1213 return myMesh->NbTriangles();
1216 void SMESHGUI_UnionOfTrianglesDlg::onDisplaySimulation( bool toDisplayPreview )
1218 if ( myPreviewCheckBox->isChecked() && toDisplayPreview ) {
1219 if ( isValid( true ) ) {
1221 SUIT_OverrideCursor aWaitCursor;
1222 // get Ids of elements
1223 SMESH::SMESH_IDSource_var obj;
1224 SMESH::long_array_var anElemIds = getIds( obj );
1226 SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
1227 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1229 double aMaxAngle = myMaxAngleSpin->GetValue() * M_PI / 180.0;
1231 if ( CORBA::is_nil( obj ) )
1232 aMeshEditor->TriToQuad( anElemIds.inout(), aCriterion, aMaxAngle );
1234 aMeshEditor->TriToQuadObject( obj, aCriterion, aMaxAngle );
1236 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1238 vtkProperty* aProp = vtkProperty::New();
1239 aProp->SetRepresentationToWireframe();
1240 aProp->SetColor( 250, 0, 250 );
1241 aProp->SetLineWidth( SMESH::GetFloat( "SMESH:element_width", 1 ) + 3 );
1242 mySimulation->GetActor()->SetProperty( aProp );
1245 mySimulation->SetData( aMeshPreviewStruct.in() );
1258 * Class : SMESHGUI_CuttingOfQuadsDlg
1259 * Description : Automatic splitting of quadrangles into triangles
1262 SMESHGUI_CuttingOfQuadsDlg
1263 ::SMESHGUI_CuttingOfQuadsDlg(SMESHGUI* theModule):
1264 SMESHGUI_MultiEditDlg(theModule, SMESH::QuadFilter, false)
1266 setWindowTitle(tr("CAPTION"));
1269 myPreviewChk = new QCheckBox (tr("PREVIEW"), mySelGrp);
1270 QGridLayout* aLay = (QGridLayout*)(mySelGrp->layout());
1271 aLay->addWidget(myPreviewChk, aLay->rowCount(), 0, 1, aLay->columnCount());
1273 // "split to 4 tria" option
1275 QRadioButton* to4TriaRB = new QRadioButton(tr("TO_4_TRIA"), myChoiceWidget);
1276 ((QVBoxLayout*)(myCriterionGrp->layout()))->insertWidget(0, to4TriaRB);
1277 myGroupChoice->addButton(to4TriaRB, 3);
1278 to4TriaRB->setChecked(true);
1281 myCriterionGrp->show();
1282 myChoiceWidget->show();
1283 myComboBoxFunctor->insertItem(0, tr("MIN_DIAG_ELEMENTS"));
1284 myComboBoxFunctor->setCurrentIndex(0);
1285 myComboBoxFunctor->setEnabled(false);
1287 connect(myPreviewChk, SIGNAL(stateChanged(int)), this, SLOT(onPreviewChk()));
1288 connect(myGroupChoice, SIGNAL(buttonClicked(int)), this, SLOT(onCriterionRB()));
1289 connect(myComboBoxFunctor, SIGNAL(activated(int)), this, SLOT(onPreviewChk()));
1290 connect(this, SIGNAL(ListContensChanged()), this, SLOT(onPreviewChk()));
1292 myHelpFileName = "cutting_quadrangles.html";
1295 SMESHGUI_CuttingOfQuadsDlg::~SMESHGUI_CuttingOfQuadsDlg()
1299 void SMESHGUI_CuttingOfQuadsDlg::reject()
1302 SMESHGUI_MultiEditDlg::reject();
1305 bool SMESHGUI_CuttingOfQuadsDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
1306 const SMESH::long_array& theIds,
1307 SMESH::SMESH_IDSource_ptr obj)
1309 bool hasObj = (! CORBA::is_nil( obj ));
1310 switch (myGroupChoice->checkedId()) {
1311 case 0: // use diagonal 1-3
1312 return hasObj ? theEditor->SplitQuadObject(obj, true) : theEditor->SplitQuad(theIds, true);
1313 case 1: // use diagonal 2-4
1314 return hasObj ? theEditor->SplitQuadObject(obj, false) : theEditor->SplitQuad(theIds, false);
1315 case 3: // split to 4 tria
1318 return theEditor->QuadTo4Tri( obj ), true;
1319 SMESH::IDSource_wrap elems = theEditor->MakeIDSource( theIds, SMESH::FACE );
1320 theEditor->QuadTo4Tri( elems );
1323 default: // use numeric functor
1327 SMESH::NumericalFunctor_var aCrit = getNumericalFunctor();
1328 return hasObj ? theEditor->QuadToTriObject(obj, aCrit) : theEditor->QuadToTri(theIds, aCrit);
1331 int SMESHGUI_CuttingOfQuadsDlg::nbElemsInMesh()
1333 return myMesh->NbQuadrangles();
1337 void SMESHGUI_CuttingOfQuadsDlg::onCriterionRB()
1339 if (myGroupChoice->checkedId() == 2) // Use numeric functor
1340 myComboBoxFunctor->setEnabled(true);
1342 myComboBoxFunctor->setEnabled(false);
1344 if (myGroupChoice->checkedId() == 3) // To 4 tria
1346 if ( myPreviewChk->isChecked() )
1347 myPreviewChk->setChecked( false );
1348 myPreviewChk->setEnabled( false );
1352 myPreviewChk->setEnabled( true );
1357 void SMESHGUI_CuttingOfQuadsDlg::onPreviewChk()
1359 myPreviewChk->isChecked() ? displayPreview() : erasePreview();
1362 void SMESHGUI_CuttingOfQuadsDlg::erasePreview()
1364 if (myPreviewActor == 0)
1367 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) {
1368 vf->RemoveActor(myPreviewActor);
1371 myPreviewActor->Delete();
1375 void SMESHGUI_CuttingOfQuadsDlg::displayPreview()
1380 if (myPreviewActor != 0)
1383 SUIT_OverrideCursor aWaitCursor;
1384 // get Ids of elements
1385 SMESH::SMESH_IDSource_var obj;
1386 SMESH::long_array_var anElemIds = getIds(obj);
1387 if (anElemIds->length() == 0 && obj->_is_nil() )
1390 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
1394 // 0 - use diagonal 1-3, 1 - use diagonal 2-4, 2 - use numerical functor
1395 int aChoice = myGroupChoice->checkedId();
1396 SMESH::NumericalFunctor_var aCriterion = SMESH::NumericalFunctor::_nil();
1397 SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH::SMESH_MeshEditor::_nil();
1399 aCriterion = getNumericalFunctor();
1400 aMeshEditor = myMesh->GetMeshEditor();
1401 if (aMeshEditor->_is_nil())
1405 if ( anElemIds->length() == 0 ) {
1406 anElemIds = obj->GetIDs();
1410 vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
1412 vtkIdType aNbCells = anElemIds->length() * 2;
1413 vtkIdType aCellsSize = 4 * aNbCells;
1414 vtkCellArray* aConnectivity = vtkCellArray::New();
1415 aConnectivity->Allocate(aCellsSize, 0);
1417 vtkPoints* aPoints = vtkPoints::New();
1418 aPoints->SetNumberOfPoints(anElemIds->length() * 4);
1420 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1421 aCellTypesArray->SetNumberOfComponents(1);
1422 aCellTypesArray->Allocate(aNbCells * aCellTypesArray->GetNumberOfComponents());
1424 vtkIdList *anIdList = vtkIdList::New();
1425 anIdList->SetNumberOfIds(3);
1427 TColStd_DataMapOfIntegerInteger anIdToVtk;
1431 for (int i = 0, n = anElemIds->length(); i < n; i++)
1433 const SMDS_MeshElement* anElem = aMesh->FindElement(anElemIds[ i ]);
1434 if (anElem == 0 || anElem->NbNodes() != 4)
1437 SMDS_ElemIteratorPtr anIter = anElem->nodesIterator();
1439 while (anIter->more()) {
1440 const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(anIter->next());
1443 if (!anIdToVtk.IsBound(aNode->GetID()))
1445 aPoints->SetPoint(++nbPoints, aNode->X(), aNode->Y(), aNode->Z());
1446 anIdToVtk.Bind(aNode->GetID(), nbPoints);
1449 aNodes[ k++ ] = aNode->GetID();
1456 bool isDiag13 = true;
1457 if (aChoice == 0) // use diagonal 1-3
1461 else if (aChoice == 1) // use diagonal 2-4
1465 else // use numerical functor
1467 // compare two sets of possible triangles
1468 int diag = aMeshEditor->BestSplit(anElemIds[i], aCriterion);
1469 if (diag == 1) // 1-3
1471 else if (diag == 2) // 2-4
1479 anIdList->SetId(0, anIdToVtk(aNodes[ 0 ]));
1480 anIdList->SetId(1, anIdToVtk(aNodes[ 1 ]));
1481 anIdList->SetId(2, anIdToVtk(aNodes[ 2 ]));
1482 aConnectivity->InsertNextCell(anIdList);
1483 aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1485 anIdList->SetId(0, anIdToVtk(aNodes[ 2 ]));
1486 anIdList->SetId(1, anIdToVtk(aNodes[ 3 ]));
1487 anIdList->SetId(2, anIdToVtk(aNodes[ 0 ]));
1488 aConnectivity->InsertNextCell(anIdList);
1489 aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1493 anIdList->SetId(0, anIdToVtk(aNodes[ 1 ]));
1494 anIdList->SetId(1, anIdToVtk(aNodes[ 2 ]));
1495 anIdList->SetId(2, anIdToVtk(aNodes[ 3 ]));
1496 aConnectivity->InsertNextCell(anIdList);
1497 aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1499 anIdList->SetId(0, anIdToVtk(aNodes[ 3 ]));
1500 anIdList->SetId(1, anIdToVtk(aNodes[ 0 ]));
1501 anIdList->SetId(2, anIdToVtk(aNodes[ 1 ]));
1502 aConnectivity->InsertNextCell(anIdList);
1503 aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1507 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
1508 aCellLocationsArray->SetNumberOfComponents(1);
1509 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1511 aConnectivity->InitTraversal();
1512 vtkIdType const *pts(nullptr);
1513 for(vtkIdType idType = 0, npts; aConnectivity->GetNextCell(npts, pts); idType++)
1514 aCellLocationsArray->SetValue(idType, aConnectivity->GetTraversalLocation(npts));
1516 aGrid->SetPoints(aPoints);
1517 aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aConnectivity);
1519 // Create and display actor
1520 vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
1521 aMapper->SetInputData(aGrid);
1523 myPreviewActor = SALOME_Actor::New();
1524 myPreviewActor->PickableOff();
1525 myPreviewActor->SetMapper(aMapper);
1527 vtkProperty* aProp = vtkProperty::New();
1528 aProp->SetRepresentationToWireframe();
1529 aProp->SetColor(250, 0, 250);
1530 aProp->SetLineWidth(myActor->GetLineWidth() + 1);
1531 myPreviewActor->SetProperty(aProp);
1533 SMESH::GetCurrentVtkView()->AddActor(myPreviewActor);
1534 SMESH::GetCurrentVtkView()->Repaint();
1538 aConnectivity->Delete();
1542 aCellTypesArray->Delete();
1543 aCellLocationsArray->Delete();
1547 * Class : SMESHGUI_SplitVolumesDlg
1548 * Description : Spliter of volumes into tetrahedra or prisms
1551 SMESHGUI_SplitVolumesDlg::SMESHGUI_SplitVolumesDlg(SMESHGUI* theModule)
1552 : SMESHGUI_MultiEditDlg(theModule, SMESH::VolumeFilter, /*the3d2d=*/true, /*doInit=*/false)
1554 setWindowTitle(tr("CAPTION"));
1555 myHelpFileName = "split_to_tetra.html";
1559 // Facet selection group
1561 myFacetSelGrp = new QGroupBox(tr("FACET_TO_SPLIT"), myCriterionGrp->parentWidget());
1562 QGridLayout* facetSelLayout = new QGridLayout( myFacetSelGrp );
1563 facetSelLayout->setMargin(MARGIN);
1564 facetSelLayout->setSpacing(SPACING);
1566 QLabel* pointLbl = new QLabel( tr("START_POINT"), myFacetSelGrp);
1567 QLabel* normalLbl = new QLabel( tr("FACET_NORMAL"), myFacetSelGrp);
1568 myFacetSelBtn = new QPushButton( mySubmeshBtn->icon(), "", myFacetSelGrp );
1569 myFacetSelBtn->setCheckable( true );
1570 QLabel* XLbl = new QLabel( tr("SMESH_X"), myFacetSelGrp);
1571 QLabel* YLbl = new QLabel( tr("SMESH_Y"), myFacetSelGrp);
1572 QLabel* ZLbl = new QLabel( tr("SMESH_Z"), myFacetSelGrp);
1573 QLabel* dXLbl = new QLabel( tr("SMESH_DX"), myFacetSelGrp);
1574 QLabel* dYLbl = new QLabel( tr("SMESH_DY"), myFacetSelGrp);
1575 QLabel* dZLbl = new QLabel( tr("SMESH_DZ"), myFacetSelGrp);
1576 for ( int i = 0; i < 3; ++i )
1578 myPointSpin[i] = new SMESHGUI_SpinBox( myFacetSelGrp );
1579 myDirSpin [i] = new SMESHGUI_SpinBox( myFacetSelGrp );
1580 myPointSpin[i]->RangeStepAndValidator( -1e10, 1e10, 10 );
1581 myDirSpin [i]->RangeStepAndValidator( -1., 1., 0.1 );
1582 myPointSpin[i]->SetValue(0.);
1583 myDirSpin [i]->SetValue(0.);
1584 myAxisBtn [i] = new QPushButton( QString("|| O") + char('X'+i ), myFacetSelGrp);
1586 myDirSpin[2]->SetValue(1.);
1588 myAllDomainsChk = new QCheckBox( tr("ALL_DOMAINS"), mySelGrp );
1590 facetSelLayout->addWidget( pointLbl, 0, 0 );
1591 facetSelLayout->addWidget( myFacetSelBtn, 0, 1 );
1592 facetSelLayout->addWidget( XLbl, 0, 2 );
1593 facetSelLayout->addWidget( myPointSpin[0],0, 3 );
1594 facetSelLayout->addWidget( YLbl, 0, 4 );
1595 facetSelLayout->addWidget( myPointSpin[1],0, 5 );
1596 facetSelLayout->addWidget( ZLbl, 0, 6 );
1597 facetSelLayout->addWidget( myPointSpin[2],0, 7 );
1599 facetSelLayout->addWidget( normalLbl, 1, 0 );
1600 facetSelLayout->addWidget( dXLbl, 1, 2 );
1601 facetSelLayout->addWidget( myDirSpin[0], 1, 3 );
1602 facetSelLayout->addWidget( dYLbl, 1, 4 );
1603 facetSelLayout->addWidget( myDirSpin[1], 1, 5 );
1604 facetSelLayout->addWidget( dZLbl, 1, 6 );
1605 facetSelLayout->addWidget( myDirSpin[2], 1, 7 );
1607 facetSelLayout->addWidget( myAxisBtn[0], 2, 2, 1, 2 );
1608 facetSelLayout->addWidget( myAxisBtn[1], 2, 4, 1, 2 );
1609 facetSelLayout->addWidget( myAxisBtn[2], 2, 6, 1, 2 );
1611 myCriterionGrp->layout()->addWidget( myFacetSelGrp );
1612 myCriterionGrp->layout()->addWidget( myAllDomainsChk );
1613 //myChoiceWidget->layout()->addWidget( myAllDomainsChk );
1615 connect( myFacetSelBtn, SIGNAL(clicked(bool)), SLOT(onFacetSelection(bool)) );
1616 for ( int i = 0; i < 3; ++i )
1618 connect( myAxisBtn [i], SIGNAL(clicked()), SLOT(onSetDir()) );
1619 connect( myPointSpin[i], SIGNAL(valueChanged (const QString&)),
1620 this, SLOT (updateNormalPreview(const QString&)) );
1621 connect( myDirSpin [i], SIGNAL(valueChanged (const QString&)),
1622 this, SLOT (updateNormalPreview(const QString&)) );
1624 if ( myEntityTypeGrp )
1626 myEntityTypeGrp->button(0)->setText( tr("SMESH_TETRAHEDRON"));
1627 myEntityTypeGrp->button(1)->setText( tr("SMESH_PRISM"));
1628 if ( QGroupBox* gb = qobject_cast< QGroupBox* >( myEntityTypeGrp->button(0)->parent() ))
1629 gb->setTitle( tr("TARGET_ELEM_TYPE"));
1632 myToAllChk->setChecked( true ); //apply to the whole mesh by default
1634 bool hasHexa = true;//myMesh->_is_nil() ? false : myMesh->NbHexas();
1637 myCriterionGrp->setTitle( tr("SPLIT_METHOD"));
1638 myCriterionGrp->show();
1639 myComboBoxFunctor->hide();
1640 myChoiceWidget->show();
1647 SMESHGUI_SplitVolumesDlg::~SMESHGUI_SplitVolumesDlg()
1651 bool SMESHGUI_SplitVolumesDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
1652 const SMESH::long_array& theIds,
1653 SMESH::SMESH_IDSource_ptr theObj)
1655 SMESH::IDSource_wrap obj = theObj;
1656 if ( CORBA::is_nil( obj ))
1657 obj = theEditor->MakeIDSource( theIds, SMESH::VOLUME );
1661 if ( isIntoPrisms() )
1663 QStringList aParameters;
1664 aParameters << myPointSpin[0]->text();
1665 aParameters << myPointSpin[1]->text();
1666 aParameters << myPointSpin[2]->text();
1667 aParameters << myDirSpin[0]->text();
1668 aParameters << myDirSpin[1]->text();
1669 aParameters << myDirSpin[2]->text();
1670 myMesh->SetParameters( aParameters.join(":").toUtf8().constData() );
1672 SMESH::PointStruct_var point = new SMESH::PointStruct;
1673 point->x = myPointSpin[0]->GetValue();
1674 point->y = myPointSpin[1]->GetValue();
1675 point->z = myPointSpin[2]->GetValue();
1676 SMESH::DirStruct_var norm = new SMESH::DirStruct;
1677 norm->PS.x = myDirSpin[0]->GetValue();
1678 norm->PS.y = myDirSpin[1]->GetValue();
1679 norm->PS.z = myDirSpin[2]->GetValue();
1681 theEditor->SplitHexahedraIntoPrisms( obj, point, norm,
1682 myGroupChoice->checkedId()+1,
1683 myAllDomainsChk->isChecked() );
1687 theEditor->SplitVolumesIntoTetra( obj, myGroupChoice->checkedId()+1 );
1690 catch ( const SALOME::SALOME_Exception& S_ex ) {
1691 SalomeApp_Tools::QtCatchCorbaException( S_ex );
1700 int SMESHGUI_SplitVolumesDlg::nbElemsInMesh()
1702 return isIntoPrisms() ? myMesh->NbHexas() : myMesh->NbVolumes() - myMesh->NbTetras();
1705 bool SMESHGUI_SplitVolumesDlg::isIntoPrisms()
1707 return ( myEntityTypeGrp->checkedId() == 1 );
1710 //================================================================================
1712 * \brief Slot called when a target element type changes
1714 //================================================================================
1716 void SMESHGUI_SplitVolumesDlg::on3d2dChanged(int isPrism)
1720 myFacetSelGrp->show();
1721 myAllDomainsChk->show();
1722 myGroupChoice->button(2)->hide();
1723 myGroupChoice->button(0)->setText( tr("SPLIT_HEX_TO_2_PRISMS"));
1724 myGroupChoice->button(1)->setText( tr("SPLIT_HEX_TO_4_PRISMS"));
1728 myFacetSelGrp->hide();
1729 myAllDomainsChk->hide();
1730 myGroupChoice->button(2)->show();
1731 myGroupChoice->button(0)->setText( tr("SPLIT_HEX_TO_5_TETRA"));
1732 myGroupChoice->button(1)->setText( tr("SPLIT_HEX_TO_6_TETRA"));
1733 myGroupChoice->button(2)->setText( tr("SPLIT_HEX_TO_24_TETRA"));
1735 SMESHGUI_MultiEditDlg::on3d2dChanged( !myEntityType );
1736 myEntityType = 1; // == VOLUME
1737 myChoiceWidget->hide();
1738 myChoiceWidget->show();
1739 resize(minimumSizeHint());
1743 //================================================================================
1745 * \brief Set selection mode
1747 //================================================================================
1749 void SMESHGUI_SplitVolumesDlg::setSelectionMode()
1751 if ( myBusy || !isEnabled() ) return;
1753 SMESH::RemoveFilters();
1755 mySelectionMgr->clearFilters();
1757 if (mySubmeshChk->isChecked()) {
1758 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1759 aViewWindow->SetSelectionMode(ActorSelection);
1760 mySelectionMgr->installFilter(new SMESH_TypeFilter(SMESH::SUBMESH));
1761 myFacetSelBtn->setChecked( false );
1763 else if (myGroupChk->isChecked()) {
1764 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1765 aViewWindow->SetSelectionMode(ActorSelection);
1766 mySelectionMgr->installFilter(new SMESH_TypeFilter(SMESH::GROUP));
1767 myFacetSelBtn->setChecked( false );
1770 if ( myFacetSelBtn->isChecked() )
1772 // facet selection - select any element
1773 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1774 aViewWindow->SetSelectionMode( CellSelection );
1775 myFilterType = SMESH::AllElementsFilter;
1779 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1780 aViewWindow->SetSelectionMode( VolumeSelection );
1781 if ( isIntoPrisms() )
1783 SMESH::SetFilter(new SMESHGUI_VolumeShapeFilter( SMDSGeom_HEXA ));
1784 myFilterType = SMESHGUI_VolumeShapeFilter::GetId( SMDSGeom_HEXA );
1786 else // to tetrahedra
1788 SMESH::SetFilter(new SMESHGUI_VolumesFilter());
1789 myFilterType = SMESH::VolumeFilter;
1794 //================================================================================
1796 * \brief SLOT called when selection changed
1798 //================================================================================
1800 void SMESHGUI_SplitVolumesDlg::onSelectionDone()
1802 if (myBusy || !isEnabled()) return;
1804 if ( !myFacetSelBtn->isChecked() )
1806 SMESHGUI_MultiEditDlg::onSelectionDone();
1808 else // set point and normal by a selected element
1810 const SALOME_ListIO& aList = mySelector->StoredIObjects();
1811 int nbSel = aList.Extent();
1814 Handle(SALOME_InteractiveObject) anIO = aList.First();
1816 myActor = SMESH::FindActorByEntry( anIO->getEntry() );
1818 SMESH::SMESH_Mesh_var aSelMesh = SMESH::GetMeshByIO(anIO);
1819 if (!aSelMesh->_is_nil())
1822 TColStd_IndexedMapOfInteger aMapIndex;
1823 mySelector->GetIndex( anIO, aMapIndex );
1824 if ( !aMapIndex.IsEmpty() )
1825 showFacetByElement( aMapIndex(1) );
1826 else if ( myCellSize < 0 )
1827 showFacetByElement( 1 );
1832 myCriterionGrp->setEnabled( !myMesh->_is_nil() && nbElemsInMesh() > 0 );
1835 //================================================================================
1837 * \brief Show facet normal by a selected element
1839 //================================================================================
1841 void SMESHGUI_SplitVolumesDlg::showFacetByElement( int elemID )
1843 if ( !isIntoPrisms() || !myActor )
1845 mySimulation->SetVisibility( false );
1848 SMDS_Mesh* mesh = myActor->GetObject()->GetMesh();
1849 const SMDS_MeshElement* elem = mesh->FindElement( elemID );
1850 if ( !elem ) return;
1852 // set point XYZ by the element barycenter
1855 SMDS_NodeIteratorPtr nIt = elem->nodeIterator();
1856 std::vector< const SMDS_MeshNode* > nodes;
1857 nodes.reserve( elem->NbNodes() );
1858 while ( nIt->more() )
1860 nodes.push_back( nIt->next() );
1861 gp_XYZ p = SMESH_TNodeXYZ( nodes.back() );
1867 myPointSpin[0]->SetValue( bc.X() );
1868 myPointSpin[1]->SetValue( bc.Y() );
1869 myPointSpin[2]->SetValue( bc.Z() );
1872 myCellSize = sqrt( bbox.SquareExtent() );
1874 // set normal and size
1876 switch ( elem->GetType())
1880 norm = SMESH_TNodeXYZ( nodes[1] ) - SMESH_TNodeXYZ( nodes[0] );
1885 if ( !SMESH_MeshAlgos::FaceNormal( elem, norm, /*normalized=*/false ))
1889 case SMDSAbs_Volume:
1891 SMDS_VolumeTool vTool( elem );
1892 vTool.SetExternalNormal();
1893 bool freeFacetFound = false;
1895 for ( int i = 0; i < vTool.NbFaces() && !freeFacetFound; ++i )
1896 if (( freeFacetFound = vTool.IsFreeFace( i )))
1897 vTool.GetFaceNormal( i, n[0], n[1], n[2] );
1898 if ( !freeFacetFound )
1899 vTool.GetFaceNormal( 0, n[0], n[1], n[2] );
1900 norm.SetCoord( n[0], n[1], n[2] );
1906 double size = norm.Modulus();
1911 myDirSpin[0]->SetValue( norm.X() );
1912 myDirSpin[1]->SetValue( norm.Y() );
1913 myDirSpin[2]->SetValue( norm.Z() );
1915 if ( myCellSize > 0. )
1916 updateNormalPreview();
1919 //================================================================================
1921 * \brief SLOT called when a point or a normal changes
1923 //================================================================================
1925 void SMESHGUI_SplitVolumesDlg::updateNormalPreview(const QString&)
1927 if ( myCellSize < 0. )
1929 showFacetByElement( 1 );
1933 gp_Pnt point ( myPointSpin[0]->GetValue(),
1934 myPointSpin[1]->GetValue(),
1935 myPointSpin[2]->GetValue() );
1936 gp_XYZ norm ( myDirSpin[0]->GetValue(),
1937 myDirSpin[1]->GetValue(),
1938 myDirSpin[2]->GetValue() );
1939 if ( norm.Modulus() < 1e-20 )
1942 vtkUnstructuredGrid* grid = mySimulation->GetGrid();
1944 // Initialize the preview mesh of an arrow
1945 if ( grid->GetNumberOfPoints() == 0 )
1947 mySimulation->SetArrowShapeAndNb( /*nb=*/1, /*hLen=*/0.3, /*R=*/0.1, /*start=*/0 );
1950 // Compute new coordinates of the grid according to the dialog controls
1952 gp_Ax1 axis( point, norm );
1953 mySimulation->SetArrows( &axis, 4 * myCellSize );
1954 mySimulation->SetVisibility(true);
1957 //================================================================================
1959 * \brief Slot called when facet selection button is clicked
1961 //================================================================================
1963 void SMESHGUI_SplitVolumesDlg::onFacetSelection(bool isFacetSelection)
1967 mySelGrp->setEnabled( !isFacetSelection );
1970 //================================================================================
1972 * \brief Slot called when an || axis button is clicked
1974 //================================================================================
1976 void SMESHGUI_SplitVolumesDlg::onSetDir()
1978 myDirSpin[0]->SetValue(0.);
1979 myDirSpin[1]->SetValue(0.);
1980 myDirSpin[2]->SetValue(0.);
1982 for ( ; i < 3; ++i )
1983 if ( sender() == myAxisBtn[i] )
1987 myDirSpin[i]->SetValue(1.);
1989 if ( myActor && !myMesh->_is_nil() && myMesh->NbNodes() > 0 )
1992 myActor->GetUnstructuredGrid()->GetBounds(b);
1993 gp_XYZ center( 0.5 * ( b[0] + b[1] ),
1994 0.5 * ( b[2] + b[3] ),
1995 0.5 * ( b[4] + b[5] ));
1996 gp_XYZ point ( myPointSpin[0]->GetValue(),
1997 myPointSpin[1]->GetValue(),
1998 myPointSpin[2]->GetValue() );
1999 gp_XYZ norm ( myDirSpin[0]->GetValue(),
2000 myDirSpin[1]->GetValue(),
2001 myDirSpin[2]->GetValue() );
2003 gp_Vec cp( center, point );
2004 if ( cp.Dot( norm ) < 0. )
2005 myDirSpin[i]->SetValue(-1.);
2008 updateNormalPreview();