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_GroupDlg.cxx
24 // Author : Natalia KOPNOVA
28 #include "SMESHGUI_GroupDlg.h"
29 #include "SMESHGUI_FilterDlg.h"
30 #include "SMESHGUI_ShapeByMeshDlg.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_MeshUtils.h"
36 #include "SMESHGUI_GroupUtils.h"
37 #include "SMESHGUI_FilterUtils.h"
38 #include "SMESHGUI_GEOMGenUtils.h"
40 #include "SMESH_TypeFilter.hxx"
41 #include "SMESH_Actor.h"
42 #include "SMESH_ActorUtils.h"
45 #include "GEOM_SelectionFilter.h"
47 #include "SUIT_Desktop.h"
48 #include "SUIT_ResourceMgr.h"
49 #include "SUIT_Session.h"
50 #include "SUIT_MessageBox.h"
52 #include "SalomeApp_Tools.h"
53 #include "SalomeApp_Application.h"
54 #include "SalomeApp_Study.h"
55 #include "LightApp_Application.h"
56 #include "SALOMEDSClient_Study.hxx"
57 #include "SALOME_ListIO.hxx"
58 #include "SALOME_ListIteratorOfListIO.hxx"
60 #include "SVTK_ViewWindow.h"
61 #include "SVTK_Selector.h"
63 #include "utilities.h"
66 #include <vtkRenderer.h>
67 #include <vtkActorCollection.h>
70 #include <TColStd_MapOfInteger.hxx>
73 #include <qbuttongroup.h>
75 #include <qgroupbox.h>
78 #include <qlineedit.h>
79 #include <qpushbutton.h>
80 #include <qtoolbutton.h>
81 #include <qradiobutton.h>
82 #include <qcheckbox.h>
87 #include <qmemarray.h>
88 #include <qwidgetstack.h>
89 #include <qcolordialog.h>
91 #include <QtxIntSpinBox.h>
100 //=================================================================================
101 // function : SMESHGUI_GroupDlg()
103 //=================================================================================
104 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
105 SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl)
106 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
107 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
108 mySMESHGUI( theModule ),
109 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
110 mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
112 myNameChanged(false),
115 if (!name) setName("SMESHGUI_GroupDlg");
117 if (!theMesh->_is_nil())
120 mySelectSubMesh->setEnabled(false);
121 mySelectGroup->setEnabled(false);
122 myGeomGroupBtn->setEnabled(false);
123 myGeomGroupLine->setEnabled(false);
127 //=================================================================================
128 // function : SMESHGUI_GroupDlg()
130 //=================================================================================
131 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
132 SMESH::SMESH_GroupBase_ptr theGroup, bool modal, WFlags fl)
133 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
134 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
135 mySMESHGUI( theModule ),
136 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
137 mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
141 if (!name) setName("SMESHGUI_GroupDlg");
144 if (!theGroup->_is_nil())
147 mySelectSubMesh->setEnabled(false);
148 mySelectGroup->setEnabled(false);
150 myCurrentLineEdit = myMeshGroupLine;
155 //=================================================================================
156 // function : SMESHGUI_GroupDlg()
158 //=================================================================================
159 void SMESHGUI_GroupDlg::initDialog(bool create)
163 myCurrentLineEdit = 0;
167 myGeomObjects = new GEOM::ListOfGO();
168 myGeomObjects->length(0);
170 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
173 setCaption(tr("SMESH_CREATE_GROUP_TITLE"));
174 myHelpFileName = "creating_groups_page.html";
177 setCaption(tr("SMESH_EDIT_GROUP_TITLE"));
178 myHelpFileName = "editing_groups_page.html";
181 setSizeGripEnabled(TRUE);
183 QGridLayout* aMainLayout = new QGridLayout(this, 7, 3, 11, 6);
185 /***************************************************************/
186 QLabel* meshGroupLab = new QLabel(this, "mesh/group label");
188 meshGroupLab->setText(tr("SMESH_MESH"));
190 meshGroupLab->setText(tr("SMESH_GROUP"));
191 myMeshGroupBtn = new QPushButton(this, "mesh/group button");
192 myMeshGroupBtn->setPixmap(image0);
193 myMeshGroupLine = new QLineEdit(this, "mesh/group line");
194 myMeshGroupLine->setReadOnly(true);
196 /***************************************************************/
197 myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types");
198 myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE"));
199 myTypeGroup->setExclusive(true);
202 types.append(tr("MESH_NODE"));
203 types.append(tr("SMESH_EDGE"));
204 types.append(tr("SMESH_FACE"));
205 types.append(tr("SMESH_VOLUME"));
207 for (int i = 0; i < types.count(); i++) {
208 rb = new QRadioButton(types[i], myTypeGroup);
210 myTypeGroup->setEnabled(create);
213 /***************************************************************/
214 QLabel* aName = new QLabel(this, "name label");
215 aName->setText(tr("SMESH_NAME"));
216 aName->setMinimumSize(50,0);
217 myName = new QLineEdit(this, "name");
219 /***************************************************************/
220 myGrpTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Type of group");
221 myGrpTypeGroup->setTitle(tr("SMESH_GROUP_TYPE"));
222 myGrpTypeGroup->setExclusive(true);
223 QRadioButton* rb1 = new QRadioButton( tr("SMESH_GROUP_STANDALONE"), myGrpTypeGroup);
224 QRadioButton* rb2 = new QRadioButton( tr("SMESH_GROUP_GEOMETRY"), myGrpTypeGroup);
225 myGrpTypeGroup->setEnabled(create);
228 /***************************************************************/
229 myWGStack = new QWidgetStack( this, "widget stack");
230 QWidget* wg1 = new QFrame( myWGStack, "first widget" );
231 QWidget* wg2 = new QFrame( myWGStack, "second widget" );
233 /***************************************************************/
234 QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, wg1, "content box");
235 aContentBox->setTitle(tr("SMESH_CONTENT"));
236 QFrame* aContent = new QFrame(aContentBox, "content");
237 QGridLayout* aLayout = new QGridLayout(aContent, 7, 4);
238 aLayout->setSpacing(6);
239 aLayout->setAutoAdd(false);
241 QLabel* aLabel = new QLabel(aContent, "elements label");
242 aLabel->setText(tr("SMESH_ID_ELEMENTS"));
243 myElements = new QListBox(aContent, "elements list");
244 myElements->setSelectionMode(QListBox::Extended);
246 myFilter = new QPushButton(aContent, "filter");
247 myFilter->setText(tr("SMESH_BUT_FILTER"));
248 QPushButton* aAddBtn = new QPushButton(aContent, "add");
249 aAddBtn->setText(tr("SMESH_BUT_ADD"));
250 QPushButton* aRemoveBtn = new QPushButton(aContent, "remove");
251 aRemoveBtn->setText(tr("SMESH_BUT_REMOVE"));
252 QPushButton* aSortBtn = new QPushButton(aContent, "sort");
253 aSortBtn->setText(tr("SMESH_BUT_SORT"));
255 aLayout->addWidget(aLabel, 0, 0);
256 aLayout->addMultiCellWidget(myElements, 1, 6, 0, 0);
257 aLayout->addWidget(myFilter, 1, 2);
258 aLayout->addWidget(aAddBtn, 3, 2);
259 aLayout->addWidget(aRemoveBtn, 4, 2);
260 aLayout->addWidget(aSortBtn, 6, 2);
262 aLayout->setColStretch(0, 1);
263 aLayout->addColSpacing(1, 20);
264 aLayout->addColSpacing(3, 20);
265 aLayout->setRowStretch(2, 1);
266 aLayout->setRowStretch(5, 1);
268 /***************************************************************/
269 QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, wg1, "select box");
270 aSelectBox->setTitle(tr("SMESH_SELECT_FROM"));
272 mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox");
273 mySelectSubMesh->setText(tr("SMESH_SUBMESH"));
274 mySelectSubMesh->setMinimumSize(50, 0);
275 mySubMeshBtn = new QPushButton(aSelectBox, "submesh button");
276 mySubMeshBtn->setText("");
277 mySubMeshBtn->setPixmap(image0);
278 mySubMeshLine = new QLineEdit(aSelectBox, "submesh line");
279 mySubMeshLine->setReadOnly(true);
280 onSelectSubMesh(false);
282 mySelectGroup = new QCheckBox(aSelectBox, "group checkbox");
283 mySelectGroup->setText(tr("SMESH_GROUP"));
284 mySelectGroup->setMinimumSize(50, 0);
285 myGroupBtn = new QPushButton(aSelectBox, "group button");
286 myGroupBtn->setText("");
287 myGroupBtn->setPixmap(image0);
288 myGroupLine = new QLineEdit(aSelectBox, "group line");
289 myGroupLine->setReadOnly(true);
290 onSelectGroup(false);
292 /***************************************************************/
293 QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 );
294 wg1Layout->addWidget(aContentBox, 0, 0);
295 wg1Layout->addWidget(aSelectBox, 1, 0);
296 wg1Layout->setRowStretch(2, 5);
298 /***************************************************************/
299 QLabel* geomObject = new QLabel(wg2, "geometry object label");
300 geomObject->setText(tr("SMESH_OBJECT_GEOM"));
301 myGeomGroupBtn = new QToolButton(wg2, "geometry group button");
302 myGeomGroupBtn->setIconSet( QIconSet(image0) );
303 myGeomGroupBtn->setToggleButton(true);
304 myGeomGroupLine = new QLineEdit(wg2, "geometry group line");
305 myGeomGroupLine->setReadOnly(true); //VSR ???
306 onSelectGeomGroup(false);
310 myGeomGroupBtn->setEnabled(false);
311 myGeomGroupLine->setEnabled(false);
314 /***************************************************************/
315 QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 );
316 wg2Layout->addWidget(geomObject, 0, 0);
317 wg2Layout->addWidget(myGeomGroupBtn, 0, 1);
318 wg2Layout->addWidget(myGeomGroupLine,0, 2);
319 wg2Layout->setRowStretch(1, 5);
321 /***************************************************************/
322 QVBoxLayout* dumb = new QVBoxLayout(myWGStack);
323 dumb->addWidget(wg1);
324 dumb->addWidget(wg2);
325 myWGStack->addWidget( wg1, myGrpTypeGroup->id(rb1) );
326 myWGStack->addWidget( wg2, myGrpTypeGroup->id(rb2) );
328 /***************************************************************/
329 QGroupBox* aColorBox = new QGroupBox(2, Qt::Horizontal, this, "color box");
330 aColorBox->setTitle(tr("SMESH_SET_COLOR"));
332 new QLabel( tr("SMESH_CHECK_COLOR"), aColorBox, "color label" );
333 myColorBtn = new QPushButton(aColorBox, "color button");
334 myColorBtn->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
336 /***************************************************************/
338 QFrame* aButtons = new QFrame(this, "button box");
339 aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken);
340 QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6);
341 aBtnLayout->setAutoAdd(false);
343 QPushButton* aApplyBtn = new QPushButton(aButtons, "apply");
344 aApplyBtn->setText(tr("SMESH_BUT_APPLY"));
345 aApplyBtn->setAutoDefault(true);
346 QPushButton* aCloseBtn = new QPushButton(aButtons, "close");
347 aCloseBtn->setText(tr("SMESH_BUT_CLOSE"));
348 aCloseBtn->setAutoDefault(true);
349 QPushButton* aOKBtn = new QPushButton(aButtons, "ok");
350 aOKBtn->setText(tr("SMESH_BUT_APPLY_AND_CLOSE"));
351 aOKBtn->setAutoDefault(true);
352 aOKBtn->setDefault(true);
353 QPushButton* aHelpBtn = new QPushButton(aButtons, "help");
354 aHelpBtn->setText(tr("SMESH_BUT_HELP"));
355 aHelpBtn->setAutoDefault(true);
357 aBtnLayout->addWidget(aOKBtn);
358 aBtnLayout->addWidget(aApplyBtn);
359 aBtnLayout->addStretch();
360 aBtnLayout->addWidget(aCloseBtn);
361 aBtnLayout->addWidget(aHelpBtn);
363 /***************************************************************/
364 aMainLayout->addWidget(meshGroupLab, 0, 0);
365 aMainLayout->addWidget(myMeshGroupBtn, 0, 1);
366 aMainLayout->addWidget(myMeshGroupLine, 0, 2);
367 aMainLayout->addMultiCellWidget(myTypeGroup, 1, 1, 0, 2);
368 aMainLayout->addWidget(aName, 2, 0);
369 aMainLayout->addWidget(myName, 2, 2);
370 aMainLayout->addMultiCellWidget(myGrpTypeGroup, 3, 3, 0, 2);
371 aMainLayout->addMultiCellWidget(myWGStack, 4, 4, 0, 2);
372 aMainLayout->setRowStretch( 5, 5 );
373 aMainLayout->addMultiCellWidget(aColorBox, 6, 6, 0, 2);
374 aMainLayout->addMultiCellWidget(aButtons, 7, 7, 0, 2);
376 /* signals and slots connections */
377 connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
379 connect(myGrpTypeGroup, SIGNAL(clicked(int)), this, SLOT(onGrpTypeChanged(int)));
381 connect(myTypeGroup, SIGNAL(clicked(int)), this, SLOT(onTypeChanged(int)));
383 connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
384 connect(myElements, SIGNAL(selectionChanged()), this, SLOT(onListSelectionChanged()));
386 connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters()));
387 connect(aAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
388 connect(aRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
389 connect(aSortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
391 connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool)));
392 connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool)));
393 connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
394 connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
395 connect(myGeomGroupBtn, SIGNAL(toggled(bool)), this, SLOT(onGeomSelectionButton(bool)));
396 connect(myColorBtn, SIGNAL(clicked()), this, SLOT(onSelectColor()));
398 connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
399 connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
400 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
401 connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
404 mySMESHGUI->SetActiveDialogBox(this);
405 mySMESHGUI->SetState(800);
407 mySelectionMode = -1;
408 myMeshFilter = new SMESH_TypeFilter(MESH);
409 mySubMeshFilter = new SMESH_TypeFilter(SUBMESH);
410 myGroupFilter = new SMESH_TypeFilter(GROUP);
411 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
412 myGeomFilter = new GEOM_SelectionFilter( aStudy, true );
414 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
415 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose()));
416 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
418 myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!!
419 onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!!
421 if (myMesh->_is_nil() )
422 myTypeGroup->setButton(0);
425 //myName->setText(GetDefaultName(tr("SMESH_GROUP")));
428 //=================================================================================
429 // function : ~SMESHGUI_GroupDlg()
430 // purpose : Destroys the object and frees any allocated resources
431 //=================================================================================
432 SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg()
434 // no need to delete child widgets, Qt does it all for us
435 if ( myFilterDlg != 0 )
437 myFilterDlg->reparent( 0, QPoint() );
442 //=================================================================================
443 // function : GetDefaultName()
444 // purpose : Get the Group Name if Create new Group
445 //=================================================================================
446 QString SMESHGUI_GroupDlg::GetDefaultName(const QString& theOperation)
450 // collect all object names of SMESH component
451 SalomeApp_Study* appStudy =
452 dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
453 if ( !appStudy ) return aName;
454 _PTR(Study) aStudy = appStudy->studyDS();
456 std::set<std::string> aSet;
457 _PTR(SComponent) aMeshCompo (aStudy->FindComponent("SMESH"));
459 _PTR(ChildIterator) it (aStudy->NewChildIterator(aMeshCompo));
461 for (it->InitEx(true); it->More(); it->Next()) {
463 aSet.insert(obj->GetName());
467 // build a unique name
469 bool isUnique = false;
471 aName = theOperation + "_" + QString::number(++aNumber);
472 isUnique = (aSet.count(aName.latin1()) == 0);
478 //=================================================================================
481 //=================================================================================
482 void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh)
484 mySelectionMgr->installFilter(myMeshFilter);
486 /* init data from current selection */
487 restoreShowEntityMode();
488 myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh);
490 myGroup = SMESH::SMESH_Group::_nil();
491 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
493 // NPAL19389: create a group with a selection in another group
494 // set actor of myMesh, if it is visible, else try
495 // any visible actor of group or submesh of myMesh
496 SetAppropriateActor();
498 setDefaultGroupColor();
501 mySelectionMgr->selectedObjects( aList );
502 if ( !aList.IsEmpty() )
504 QString aName = aList.First()->getName();
505 myMeshGroupLine->setText(aName);
506 myMeshGroupLine->home( false );
509 myCurrentLineEdit = 0;
511 myTypeGroup->setButton(0);
515 //=================================================================================
518 //=================================================================================
519 void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
521 restoreShowEntityMode();
522 myMesh = theGroup->GetMesh();
525 myNameChanged = true;
526 myName->blockSignals(true);
527 myName->setText(theGroup->GetName());
528 myName->blockSignals(false);
531 SALOMEDS::Color aColor = theGroup->GetColor();
532 setGroupColor( aColor );
534 myMeshGroupLine->setText(theGroup->GetName());
537 switch(theGroup->GetType()) {
538 case SMESH::NODE: aType= 0; break;
539 case SMESH::EDGE: aType = 1; break;
540 case SMESH::FACE: aType = 2; break;
541 case SMESH::VOLUME: aType = 3; break;
543 myTypeGroup->setButton(aType);
545 myGroup = SMESH::SMESH_Group::_narrow( theGroup );
547 if (!myGroup->_is_nil())
549 // NPAL19389: create a group with a selection in another group
550 // set actor of myMesh, if it is visible, else set
551 // actor of myGroup, if it is visible, else try
552 // any visible actor of group or submesh of myMesh
553 // commented, because an attempt to set selection on not displayed cells leads to error
554 //SetAppropriateActor();
555 myActor = SMESH::FindActorByObject(myMesh);
557 myActor = SMESH::FindActorByObject(myGroup);
558 SMESH::SetPickable(myActor);
560 myGrpTypeGroup->setButton(0);
563 myCurrentLineEdit = 0;
565 setSelectionMode(aType);
568 setShowEntityMode(); // depends on myTypeId
571 if (!myGroup->IsEmpty()) {
572 SMESH::long_array_var anElements = myGroup->GetListOfID();
573 int k = anElements->length();
574 for (int i = 0; i < k; i++) {
575 myIdList.append(anElements[i]);
576 myElements->insertItem(QString::number(anElements[i]));
578 myElements->selectAll(true);
583 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
585 if ( !myGroupOnGeom->_is_nil() )
587 // NPAL19389: create a group with a selection in another group
588 // set actor of myMesh, if it is visible, else set
589 // actor of myGroupOnGeom, if it is visible, else try
590 // any visible actor of group or submesh of myMesh
591 // commented, because an attempt to set selection on not displayed cells leads to error
592 //SetAppropriateActor();
593 myActor = SMESH::FindActorByObject(myMesh);
595 myActor = SMESH::FindActorByObject(myGroupOnGeom);
596 SMESH::SetPickable(myActor);
598 myGrpTypeGroup->setButton(1);
601 QString aShapeName("");
602 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
603 GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
604 if (!aGroupShape->_is_nil())
606 _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
607 aShapeName = aGroupShapeSO->GetName().c_str();
609 myGeomGroupLine->setText( aShapeName );
610 myNameChanged = true;
611 myName->blockSignals(true);
612 myName->setText("Group On " + aShapeName);
613 myName->blockSignals(false);
618 //=================================================================================
619 // function : updateButtons()
621 //=================================================================================
622 void SMESHGUI_GroupDlg::updateButtons()
624 bool enable = !myName->text().stripWhiteSpace().isEmpty();
626 if (myGrpTypeId == 0) {
627 enable = enable && myElements->count() > 0;
628 enable = enable && (!myGroup->_is_nil() || !myMesh->_is_nil());
630 else if (myGrpTypeId == 1) {
631 if (CORBA::is_nil(myGroupOnGeom)) { // creation mode
632 enable = enable && myGeomObjects->length() > 0 && !myMesh->_is_nil();
637 aBtn = (QPushButton*) child("ok", "QPushButton");
638 if (aBtn) aBtn->setEnabled(enable);
639 aBtn = (QPushButton*) child("apply", "QPushButton");
640 if (aBtn) aBtn->setEnabled(enable);
643 //=================================================================================
644 // function : onNameChanged()
646 //=================================================================================
647 void SMESHGUI_GroupDlg::onNameChanged (const QString& text)
649 myOldName = myName->text();
651 QString tmp = myName->text();
652 tmp.stripWhiteSpace();
654 myNameChanged = true;
656 myNameChanged = false;
659 //=================================================================================
660 // function : onTypeChanged()
661 // purpose : Group elements type radio button management
662 //=================================================================================
663 void SMESHGUI_GroupDlg::onTypeChanged (int id)
665 if (myTypeId != id) {
667 if (myCurrentLineEdit == 0)
668 setSelectionMode(id);
674 //=================================================================================
675 // function : onGrpTypeChanged()
676 // purpose : Group type radio button management
677 //=================================================================================
678 void SMESHGUI_GroupDlg::onGrpTypeChanged (int id)
680 if (myGrpTypeId != id) {
681 myWGStack->raiseWidget( id );
682 myName->blockSignals(true);
683 myName->setText(myOldName);
684 myName->blockSignals(false);
685 onSelectGeomGroup(id == 1);
690 //=================================================================================
691 // function : onSelectColor()
693 //=================================================================================
694 void SMESHGUI_GroupDlg::onSelectColor()
696 QColor color = getGroupQColor();
697 color = QColorDialog::getColor( color );
698 setGroupQColor( color );
703 //=================================================================================
704 // function : setSelectionMode()
705 // purpose : Radio button management
706 //=================================================================================
707 void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
710 if (myMesh->_is_nil())
712 if (mySelectionMode != theMode) {
713 // [PAL10408] mySelectionMgr->clearSelected();
714 mySelectionMgr->clearFilters();
716 myActor->SetPointRepresentation(false);
718 SMESH::SetPointRepresentation(false);
723 myActor->SetPointRepresentation(true);
725 SMESH::SetPointRepresentation(true);
726 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
727 aViewWindow->SetSelectionMode(NodeSelection);
730 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
731 aViewWindow->SetSelectionMode(EdgeSelection);
734 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
735 aViewWindow->SetSelectionMode(FaceSelection);
738 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
739 aViewWindow->SetSelectionMode(VolumeSelection);
743 mySelectionMgr->installFilter(mySubMeshFilter);
744 else if (theMode == 5)
745 mySelectionMgr->installFilter(myGroupFilter);
746 else if (theMode == 6)
747 mySelectionMgr->installFilter(myMeshFilter);
748 else if (theMode == 7)
749 mySelectionMgr->installFilter(myGeomFilter);
751 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
752 aViewWindow->SetSelectionMode(ActorSelection);
754 mySelectionMode = theMode;
758 //=================================================================================
759 // function : onApply()
761 //=================================================================================
762 bool SMESHGUI_GroupDlg::onApply()
764 if (mySMESHGUI->isActiveStudyLocked())
767 if (myName->text().stripWhiteSpace().isEmpty())
770 if (myGrpTypeId == 0) { // on mesh elements
771 if (!myElements->count())
774 mySelectionMgr->clearSelected();
776 if (myGroup->_is_nil()) { // creation
777 if (myMesh->_is_nil())
780 SMESH::ElementType aType = SMESH::ALL;
782 case 0: aType = SMESH::NODE; break;
783 case 1: aType = SMESH::EDGE; break;
784 case 2: aType = SMESH::FACE; break;
785 case 3: aType = SMESH::VOLUME; break;
788 SMESH::long_array_var anIdList = new SMESH::long_array;
789 int i, k = myElements->count();
791 QListBoxItem* anItem;
792 for (i = 0, anItem = myElements->firstItem(); anItem != 0; i++, anItem = anItem->next()) {
793 anIdList[i] = anItem->text().toInt();
796 myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
797 myGroup->Add(anIdList.inout());
799 SALOMEDS::Color aColor = getGroupColor();
800 myGroup->SetColor(aColor);
802 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
804 //SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
805 SMESH::setFileType ( aMeshGroupSO, "COULEURGROUP" );
807 /* init for next operation */
810 myGroup = SMESH::SMESH_Group::_nil();
813 myGroup->SetName(myName->text());
815 SALOMEDS::Color aColor = getGroupColor();
816 myGroup->SetColor(aColor);
818 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
820 if (SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) {
821 switch ( myTypeId ) {
822 case 0: anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
823 case 1: anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
825 case 3: anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B ); break;
829 QValueList<int> aAddList;
830 QValueList<int>::iterator anIt;
831 QListBoxItem* anItem;
833 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
834 int anId = anItem->text().toInt();
835 if ((anIt = myIdList.find(anId)) == myIdList.end())
836 aAddList.append(anId);
838 myIdList.remove(anIt);
840 if (!aAddList.empty()) {
841 SMESH::long_array_var anIdList = new SMESH::long_array;
842 anIdList->length(aAddList.count());
844 for (i = 0, anIt = aAddList.begin(); anIt != aAddList.end(); anIt++, i++)
846 myGroup->Add(anIdList.inout());
848 if (!myIdList.empty()) {
849 SMESH::long_array_var anIdList = new SMESH::long_array;
850 anIdList->length(myIdList.count());
852 for (i = 0, anIt = myIdList.begin(); anIt != myIdList.end(); anIt++, i++)
854 myGroup->Remove(anIdList.inout());
856 /* init for next operation */
858 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next())
859 myIdList.append(anItem->text().toInt());
862 mySMESHGUI->updateObjBrowser(true);
863 SMESH::UpdateView(); // asv: fix of BUG PAL5515
864 mySelectionMgr->clearSelected();
867 else if (myGrpTypeId == 1) { // on geom object
868 if (CORBA::is_nil(myGroupOnGeom)) { // creation
869 if (myMesh->_is_nil() || !myGeomObjects->length())
872 SMESH::ElementType aType = SMESH::ALL;
874 case 0: aType = SMESH::NODE; break;
875 case 1: aType = SMESH::EDGE; break;
876 case 2: aType = SMESH::FACE; break;
877 case 3: aType = SMESH::VOLUME; break;
880 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
881 GEOM::GEOM_IGroupOperations_var aGroupOp =
882 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
884 if (myGeomObjects->length() == 1) {
885 myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomObjects[0]);
888 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
889 if ( aSMESHGen->_is_nil() )
892 // create a geometry group
893 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
894 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
896 if (geomGen->_is_nil() || !aStudy)
899 GEOM::GEOM_IGroupOperations_var op =
900 geomGen->GetIGroupOperations(aStudy->StudyId());
904 // check and add all selected GEOM objects: they must be
905 // a sub-shapes of the main GEOM and must be of one type
906 TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
907 for ( int i =0; i < myGeomObjects->length(); i++) {
908 TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)myGeomObjects[i]->GetShapeType();
910 aGroupType = aSubShapeType;
911 else if (aSubShapeType != aGroupType) {
912 aGroupType = TopAbs_SHAPE;
917 GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
918 GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(aMeshShape, aGroupType);
919 op->UnionList(aGroupVar, myGeomObjects);
922 // publish the GEOM group in study
923 QString aNewGeomGroupName ("Auto_group_for_");
924 aNewGeomGroupName += myName->text();
925 SALOMEDS::SObject_var aNewGroupSO =
926 geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar, aNewGeomGroupName, aMeshShape);
929 myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(), aGroupVar);
932 SALOMEDS::Color aColor = getGroupColor();
933 myGroupOnGeom->SetColor(aColor);
935 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
937 //SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
938 SMESH::setFileType ( aMeshGroupSO,"COULEURGROUP" );
940 /* init for next operation */
942 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
945 myGroupOnGeom->SetName(myName->text());
947 SALOMEDS::Color aColor = getGroupColor();
948 myGroupOnGeom->SetColor(aColor);
950 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
951 if (SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) {
952 switch ( myTypeId ) {
953 case 0: anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
954 case 1: anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
956 case 3: anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B ); break;
961 mySMESHGUI->updateObjBrowser(true);
962 mySelectionMgr->clearSelected();
969 //=================================================================================
972 //=================================================================================
973 void SMESHGUI_GroupDlg::onOK()
979 //=================================================================================
980 // function : onListSelectionChanged()
981 // purpose : Called when selection in element list is changed
982 //=================================================================================
983 void SMESHGUI_GroupDlg::onListSelectionChanged()
985 // MESSAGE("SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor);
986 if ( myIsBusy || !myActor) return;
989 if (myCurrentLineEdit == 0) {
990 mySelectionMgr->clearSelected();
991 TColStd_MapOfInteger aIndexes;
992 QListBoxItem* anItem;
993 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
994 if (anItem->isSelected()) {
995 int anId = anItem->text().toInt();
999 mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
1000 SALOME_ListIO aList;
1001 aList.Append(myActor->getIO());
1002 mySelectionMgr->setSelectedObjects(aList,false);
1007 //=================================================================================
1008 // function : onObjectSelectionChanged()
1009 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1010 //=================================================================================
1011 void SMESHGUI_GroupDlg::onObjectSelectionChanged()
1013 if (myIsBusy || !isEnabled()) return;
1014 if (myCurrentLineEdit == myGeomGroupLine && !myGeomGroupBtn->isOn()) return;
1018 SALOME_ListIO aList;
1019 mySelectionMgr->selectedObjects( aList );
1021 int aNbSel = aList.Extent();
1022 myElements->clearSelection();
1024 if (myCurrentLineEdit)
1026 myCurrentLineEdit->setText("");
1027 QString aString = "";
1029 if (myCurrentLineEdit == myMeshGroupLine)
1031 mySelectSubMesh->setEnabled(false);
1032 mySelectGroup->setEnabled(false);
1033 myGroupLine->setText("");
1034 mySubMeshLine->setText("");
1036 myGeomGroupBtn->setEnabled(false);
1037 myGeomGroupLine->setEnabled(false);
1038 myGeomGroupLine->setText("");
1039 myGeomObjects = new GEOM::ListOfGO();
1040 myGeomObjects->length(0);
1042 if (myGeomGroupBtn->isOn())
1043 myGeomGroupBtn->setOn(false);
1045 myName->setText("");
1047 myElements->clear();
1050 myGroup = SMESH::SMESH_Group::_nil();
1051 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
1052 restoreShowEntityMode();
1053 myMesh = SMESH::SMESH_Mesh::_nil();
1059 Handle(SALOME_InteractiveObject) IO = aList.First();
1062 restoreShowEntityMode();
1063 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
1064 setShowEntityMode();
1066 if (myMesh->_is_nil())
1072 myGroup = SMESH::SMESH_Group::_nil();
1074 // NPAL19389: create a group with a selection in another group
1075 // set actor of myMesh, if it is visible, else try
1076 // any visible actor of group or submesh of myMesh
1077 SetAppropriateActor();
1079 aString = aList.First()->getName();
1080 myMeshGroupLine->setText(aString);
1081 myMeshGroupLine->home( false );
1083 mySelectSubMesh->setEnabled(true);
1084 mySelectGroup->setEnabled(true);
1085 myGeomGroupBtn->setEnabled(true);
1086 myGeomGroupLine->setEnabled(true);
1089 SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
1090 if (aGroup->_is_nil())
1096 myCurrentLineEdit = 0;
1098 myGroup = SMESH::SMESH_Group::_nil();
1099 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
1103 mySelectSubMesh->setEnabled(true);
1104 mySelectGroup->setEnabled(true);
1106 myCurrentLineEdit = 0;
1111 if (myGrpTypeId == 0)
1117 myElements->clear();
1118 setSelectionMode(myTypeId);
1125 else if (myCurrentLineEdit == myGeomGroupLine)
1127 myGeomObjects = new GEOM::ListOfGO();
1130 _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
1132 if (aNbSel == 0 || !aMeshSO)
1134 myGeomObjects->length(0);
1140 myGeomObjects->length(aNbSel);
1142 GEOM::GEOM_Object_var aGeomGroup;
1143 Standard_Boolean testResult;
1146 SALOME_ListIteratorOfListIO anIt (aList);
1147 for (; anIt.More(); anIt.Next())
1149 testResult = Standard_False;
1150 aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value(), testResult);
1152 // Check if the object is a geometry group
1153 if (!testResult || CORBA::is_nil(aGeomGroup))
1156 // Check if group constructed on the same shape as a mesh or on its child
1157 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1158 GEOM::GEOM_IGroupOperations_var anOp =
1159 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1161 // The main shape of the group
1162 GEOM::GEOM_Object_var aGroupMainShape;
1163 if (aGeomGroup->GetType() == 37)
1164 aGroupMainShape = anOp->GetMainShape(aGeomGroup);
1166 aGroupMainShape = GEOM::GEOM_Object::_duplicate(aGeomGroup);
1167 _PTR(SObject) aGroupMainShapeSO =
1168 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape));
1169 aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
1171 _PTR(SObject) anObj, aRef;
1172 bool isRefOrSubShape = false;
1173 if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) {
1174 //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) {
1175 if (aRef->GetID() == aGroupMainShapeSO->GetID()) {
1176 isRefOrSubShape = true;
1178 _PTR(SObject) aFather = aGroupMainShapeSO->GetFather();
1179 _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent();
1180 //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) {
1181 while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) {
1182 //if (strcmp(aRef->GetID(), aFather->GetID()) == 0)
1183 if (aRef->GetID() == aFather->GetID())
1184 isRefOrSubShape = true;
1186 aFather = aFather->GetFather();
1190 if (isRefOrSubShape)
1191 myGeomObjects[i++] = aGeomGroup;
1194 myGeomObjects->length(i);
1206 if (myCurrentLineEdit == mySubMeshLine)
1207 aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel);
1208 else if (myCurrentLineEdit == myGroupLine)
1209 aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel);
1210 else if (myCurrentLineEdit == myGeomGroupLine)
1211 aString = tr("%1 Objects").arg(aNbSel);
1214 aString = aList.First()->getName();
1218 myCurrentLineEdit->setText(aString);
1219 myCurrentLineEdit->home(false);
1220 // 07.06.2008 skl for IPAL19574:
1221 // change name of group only if it is empty
1222 QString tmp = myName->text();
1223 tmp.stripWhiteSpace();
1224 if( tmp.isEmpty() || !myNameChanged ) {
1225 myOldName = myName->text();
1226 myName->blockSignals(true);
1227 myName->setText(aString);
1228 myName->blockSignals(false);
1233 else // !myCurrentLineEdit: local selection of nodes or elements
1235 if (aNbSel == 1 && myActor && myActor->hasIO())
1237 #ifdef ENABLE_SWITCH_ACTOR_DURING_ELEMENTS_SELECTION
1238 // NPAL19389: create a group with a selection in another group
1239 // Switch myActor to the newly selected one, if the last
1240 // is visible and belongs to group or submesh of myMesh
1241 Handle(SALOME_InteractiveObject) curIO = myActor->getIO();
1242 Handle(SALOME_InteractiveObject) selIO = aList.First();
1243 if (curIO->hasEntry() && selIO->hasEntry()) {
1244 const char* selEntry = selIO->getEntry();
1245 if (strcmp(curIO->getEntry(), selEntry) != 0) {
1246 // different objects: selected and myActor
1247 SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
1248 if (aViewWindow && aViewWindow->isVisible(selIO)) {
1249 // newly selected actor is visible
1252 _PTR(SObject) aSObject = SMESH::FindSObject(myMesh);
1254 CORBA::String_var meshEntry = aSObject->GetID().c_str();
1255 int len = strlen(meshEntry);
1257 if (strncmp(selEntry, meshEntry, len) == 0) {
1258 // selected object is myMesh or a part of it
1259 SMESH_Actor* anActor = SMESH::FindActorByEntry(selEntry);
1262 SMESH::SetPickable(myActor);
1270 #endif // ENABLE_SWITCH_ACTOR_DURING_ELEMENTS_SELECTION
1272 QString aListStr = "";
1274 if (myTypeId == 0) {
1275 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1277 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1280 QStringList anElements = QStringList::split(" ", aListStr);
1281 QListBoxItem* anItem = 0;
1282 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1283 anItem = myElements->findItem(*it, Qt::ExactMatch);
1284 if (anItem) myElements->setSelected(anItem, true);
1291 if (!myGroup->_is_nil())
1292 myActor = SMESH::FindActorByObject(myGroup);
1293 else if (!myGroupOnGeom->_is_nil())
1294 myActor = SMESH::FindActorByObject(myGroupOnGeom);
1296 myActor = SMESH::FindActorByObject(myMesh);
1299 // somehow, if we display the mesh, while selecting from another actor,
1300 // the mesh becomes pickable, and there is no way to select any element
1302 SMESH::SetPickable(myActor);
1307 //=================================================================================
1308 // function : onSelectSubMesh()
1309 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1310 //=================================================================================
1311 void SMESHGUI_GroupDlg::onSelectSubMesh(bool on)
1314 if (mySelectGroup->isChecked()) {
1315 mySelectGroup->setChecked(false);
1317 //VSR: else if (mySelectGeomGroup->isChecked()) {
1318 //VSR: mySelectGeomGroup->setChecked(false);
1320 myCurrentLineEdit = mySubMeshLine;
1321 setSelectionMode(4);
1324 mySubMeshLine->setText("");
1325 myCurrentLineEdit = 0;
1327 setSelectionMode(myTypeId);
1329 mySubMeshBtn->setEnabled(on);
1330 mySubMeshLine->setEnabled(on);
1334 //=================================================================================
1335 // function : (onSelectGroup)
1336 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1337 //=================================================================================
1338 void SMESHGUI_GroupDlg::onSelectGroup(bool on)
1341 if (mySelectSubMesh->isChecked()) {
1342 mySelectSubMesh->setChecked(false);
1344 myCurrentLineEdit = myGroupLine;
1345 setSelectionMode(5);
1348 myGroupLine->setText("");
1349 myCurrentLineEdit = 0;
1351 setSelectionMode(myTypeId);
1353 myGroupBtn->setEnabled(on);
1354 myGroupLine->setEnabled(on);
1358 //=================================================================================
1359 // function : (onSelectGeomGroup)
1360 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1361 //=================================================================================
1362 void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
1365 if (mySelectSubMesh->isChecked()) {
1366 mySelectSubMesh->setChecked(false);
1368 else if (mySelectGroup->isChecked()) {
1369 mySelectGroup->setChecked(false);
1371 myCurrentLineEdit = myGeomGroupLine;
1373 setSelectionMode(8);
1376 myGeomGroupBtn->setOn(false);
1377 myGeomObjects->length(0);
1378 myGeomGroupLine->setText("");
1379 myCurrentLineEdit = 0;
1381 setSelectionMode(myTypeId);
1386 //=================================================================================
1387 // function : setCurrentSelection()
1389 //=================================================================================
1390 void SMESHGUI_GroupDlg::setCurrentSelection()
1392 QPushButton* send = (QPushButton*)sender();
1393 myCurrentLineEdit = 0;
1394 if (send == myMeshGroupBtn) {
1395 myCurrentLineEdit = myMeshGroupLine;
1397 setSelectionMode(6);
1399 setSelectionMode(5);
1400 onObjectSelectionChanged();
1402 else if (send == mySubMeshBtn) {
1403 myCurrentLineEdit = mySubMeshLine;
1404 onObjectSelectionChanged();
1406 else if (send == myGroupBtn) {
1407 myCurrentLineEdit = myGroupLine;
1408 onObjectSelectionChanged();
1413 //=================================================================================
1414 // function : setFilters()
1415 // purpose : SLOT. Called when "Filter" button pressed.
1416 //=================================================================================
1417 void SMESHGUI_GroupDlg::setFilters()
1419 SMESH::ElementType aType = SMESH::ALL;
1422 case 0 : aType = SMESH::NODE; break;
1423 case 1 : aType = SMESH::EDGE; break;
1424 case 2 : aType = SMESH::FACE; break;
1425 case 3 : aType = SMESH::VOLUME; break;
1429 if ( myFilterDlg == 0 )
1431 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType );
1432 connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) );
1435 myFilterDlg->Init( aType );
1437 myFilterDlg->SetSelection();
1438 myFilterDlg->SetMesh( myMesh );
1439 myFilterDlg->SetSourceWg( myElements );
1441 myFilterDlg->show();
1444 //=================================================================================
1445 // function : onFilterAccepted()
1446 // purpose : SLOT. Called when Filter dlg closed with OK button.
1447 // Uncheck "Select submesh" and "Select group" checkboxes
1448 //=================================================================================
1449 void SMESHGUI_GroupDlg::onFilterAccepted()
1451 if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() )
1453 mySelectionMode = myTypeId;
1454 mySelectSubMesh->setChecked( false );
1455 mySelectGroup->setChecked( false );
1459 //=================================================================================
1460 // function : onAdd()
1462 //=================================================================================
1463 void SMESHGUI_GroupDlg::onAdd()
1465 SALOME_ListIO aList;
1466 mySelectionMgr->selectedObjects( aList );
1468 int aNbSel = aList.Extent();
1470 if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
1474 SMESH::ElementType aType = SMESH::ALL;
1477 aType = SMESH::NODE;
1478 mySelector->SetSelectionMode(NodeSelection);
1481 aType = SMESH::EDGE;
1482 mySelector->SetSelectionMode(EdgeSelection);
1485 aType = SMESH::FACE;
1486 mySelector->SetSelectionMode(FaceSelection);
1489 aType = SMESH::VOLUME;
1490 mySelector->SetSelectionMode(VolumeSelection);
1493 mySelector->SetSelectionMode(ActorSelection);
1496 if (myCurrentLineEdit == 0) {
1497 //if (aNbSel != 1) { myIsBusy = false; return; }
1498 QString aListStr = "";
1500 if (myTypeId == 0) {
1501 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1504 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1507 QStringList anElements = QStringList::split(" ", aListStr);
1508 QListBoxItem* anItem = 0;
1509 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1510 anItem = myElements->findItem(*it, Qt::ExactMatch);
1512 anItem = new QListBoxText(*it);
1513 myElements->insertItem(anItem);
1515 myElements->setSelected(anItem, true);
1518 } else if (myCurrentLineEdit == mySubMeshLine) {
1519 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1521 SALOME_ListIO aList;
1522 mySelectionMgr->selectedObjects( aList );
1524 SALOME_ListIteratorOfListIO anIt (aList);
1525 for (; anIt.More(); anIt.Next()) {
1526 SMESH::SMESH_subMesh_var aSubMesh =
1527 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1528 if (!aSubMesh->_is_nil()) {
1529 // check if mesh is the same
1530 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1532 SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType);
1533 int k = anElements->length();
1534 QListBoxItem* anItem = 0;
1535 for (int i = 0; i < k; i++) {
1536 QString aText = QString::number(anElements[i]);
1537 anItem = myElements->findItem(aText, Qt::ExactMatch);
1539 anItem = new QListBoxText(aText);
1540 myElements->insertItem(anItem);
1542 myElements->setSelected(anItem, true);
1545 catch (const SALOME::SALOME_Exception& ex) {
1546 SalomeApp_Tools::QtCatchCorbaException(ex);
1551 mySelectSubMesh->setChecked(false);
1553 onListSelectionChanged();
1555 } else if (myCurrentLineEdit == myGroupLine) {
1556 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1557 SALOME_ListIO aList;
1558 mySelectionMgr->selectedObjects( aList );
1560 SALOME_ListIteratorOfListIO anIt (aList);
1561 for (; anIt.More(); anIt.Next()) {
1562 SMESH::SMESH_Group_var aGroup =
1563 SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1564 if (!aGroup->_is_nil()) {
1565 // check if mesh is the same
1566 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1567 SMESH::long_array_var anElements = aGroup->GetListOfID();
1568 int k = anElements->length();
1569 QListBoxItem* anItem = 0;
1570 for (int i = 0; i < k; i++) {
1571 QString aText = QString::number(anElements[i]);
1572 anItem = myElements->findItem(aText, Qt::ExactMatch);
1574 anItem = new QListBoxText(aText);
1575 myElements->insertItem(anItem);
1577 myElements->setSelected(anItem, true);
1582 mySelectGroup->setChecked(false);
1584 onListSelectionChanged();
1586 } else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) {
1587 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1588 GEOM::GEOM_IGroupOperations_var aGroupOp =
1589 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1591 SMESH::ElementType aGroupType = SMESH::ALL;
1592 switch(aGroupOp->GetType(myGeomObjects[0])) {
1593 case 7: aGroupType = SMESH::NODE; break;
1594 case 6: aGroupType = SMESH::EDGE; break;
1595 case 4: aGroupType = SMESH::FACE; break;
1596 case 2: aGroupType = SMESH::VOLUME; break;
1597 default: myIsBusy = false; return;
1600 if (aGroupType == aType) {
1601 _PTR(SObject) aGroupSO =
1602 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
1603 aStudy->FindObjectID(myGeomObjects[0]->GetStudyEntry());
1605 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
1606 SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
1607 SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();;
1608 aBelongToGeom->SetGeom(myGeomObjects[0]);
1609 aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str());
1610 aBelongToGeom->SetElementType(aType);
1611 aFilter->SetPredicate(aBelongToGeom);
1613 SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh);
1615 int k = anElements->length();
1616 QListBoxItem* anItem = 0;
1617 for (int i = 0; i < k; i++) {
1618 QString aText = QString::number(anElements[i]);
1619 anItem = myElements->findItem(aText, Qt::ExactMatch);
1621 anItem = new QListBoxText(aText);
1622 myElements->insertItem(anItem);
1624 myElements->setSelected(anItem, true);
1628 //VSR: mySelectGeomGroup->setChecked(false);
1630 onListSelectionChanged();
1633 // mySelectionMgr->clearSelected();
1637 //=================================================================================
1638 // function : onRemove()
1640 //=================================================================================
1641 void SMESHGUI_GroupDlg::onRemove()
1644 if (myCurrentLineEdit == 0) {
1645 for (int i = myElements->count(); i > 0; i--) {
1646 if (myElements->isSelected(i-1)) {
1647 myElements->removeItem(i-1);
1651 SALOME_ListIO aList;
1652 mySelectionMgr->selectedObjects( aList );
1654 int aNbSel = aList.Extent();
1656 if (aNbSel == 0) { myIsBusy = false; return; }
1658 SMESH::ElementType aType = SMESH::ALL;
1660 case 0: aType = SMESH::NODE; break;
1661 case 1: aType = SMESH::EDGE; break;
1662 case 2: aType = SMESH::FACE; break;
1663 case 3: aType = SMESH::VOLUME; break;
1666 if (myCurrentLineEdit == mySubMeshLine) {
1667 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1668 SALOME_ListIO aList;
1669 mySelectionMgr->selectedObjects( aList );
1671 SALOME_ListIteratorOfListIO anIt (aList);
1672 for (; anIt.More(); anIt.Next()) {
1673 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1674 if (!aSubMesh->_is_nil()) {
1675 // check if mesh is the same
1676 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1677 if (aType == SMESH::NODE) {
1679 SMESH::long_array_var anElements = aSubMesh->GetNodesId();
1680 int k = anElements->length();
1681 QListBoxItem* anItem = 0;
1682 for (int i = 0; i < k; i++) {
1683 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1684 if (anItem) delete anItem;
1687 catch (const SALOME::SALOME_Exception& ex) {
1688 SalomeApp_Tools::QtCatchCorbaException(ex);
1693 SMESH::long_array_var anElements = aSubMesh->GetElementsId();
1694 int k = anElements->length();
1695 QListBoxItem* anItem = 0;
1696 for (int i = 0; i < k; i++) {
1697 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1698 if (anItem) delete anItem;
1701 catch (const SALOME::SALOME_Exception& ex) {
1702 SalomeApp_Tools::QtCatchCorbaException(ex);
1709 else if (myCurrentLineEdit == myGroupLine) {
1710 Standard_Boolean aRes;
1711 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1712 SALOME_ListIO aList;
1713 mySelectionMgr->selectedObjects( aList );
1715 SALOME_ListIteratorOfListIO anIt (aList);
1716 for (; anIt.More(); anIt.Next()) {
1717 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1718 if (aRes && !aGroup->_is_nil()) {
1719 // check if mesh is the same
1720 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1721 SMESH::long_array_var anElements = aGroup->GetListOfID();
1722 int k = anElements->length();
1723 QListBoxItem* anItem = 0;
1724 for (int i = 0; i < k; i++) {
1725 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1726 if (anItem) delete anItem;
1737 //=================================================================================
1738 // function : onSort()
1740 //=================================================================================
1741 void SMESHGUI_GroupDlg::onSort()
1743 // PAL5412: sorts items in ascending by "string" value
1744 // myElements->sort(true);
1745 // myElements->update();
1746 int i, k = myElements->count();
1749 QStringList aSelected;
1750 std::vector<int> anArray(k);
1751 // QMemArray<int> anArray(k);
1752 QListBoxItem* anItem;
1754 for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) {
1755 anArray[i] = anItem->text().toInt();
1756 if (anItem->isSelected())
1757 aSelected.append(anItem->text());
1759 // sort & update list
1760 std::sort(anArray.begin(), anArray.end());
1762 myElements->clear();
1763 for (i = 0; i < k; i++) {
1764 myElements->insertItem(QString::number(anArray[i]));
1766 for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) {
1767 anItem = myElements->findItem(*it, Qt::ExactMatch);
1768 if (anItem) myElements->setSelected(anItem, true);
1774 //=================================================================================
1775 // function : closeEvent()
1777 //=================================================================================
1778 void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
1783 //=================================================================================
1784 // function : SMESHGUI_GroupDlg::onClose
1785 // purpose : SLOT called when "Close" button pressed. Close dialog
1786 //=================================================================================
1787 void SMESHGUI_GroupDlg::onClose()
1789 if (SMESH::GetCurrentVtkView()) {
1790 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
1791 SMESH::SetPointRepresentation(false);
1792 SMESH::SetPickable();
1793 restoreShowEntityMode();
1796 mySelectionMgr->clearSelected();
1797 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1798 aViewWindow->SetSelectionMode(ActorSelection);
1799 mySelectionMgr->clearFilters();
1800 mySMESHGUI->ResetState();
1805 //=================================================================================
1806 // function : onHelp()
1808 //=================================================================================
1809 void SMESHGUI_GroupDlg::onHelp()
1811 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1813 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""),
1818 platform = "winapplication";
1820 platform = "application";
1822 SUIT_MessageBox::warn1
1823 (0, QObject::tr("WRN_WARNING"),
1824 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1825 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
1826 QObject::tr("BUT_OK"));
1830 //=================================================================================
1831 // function : SMESHGUI_GroupDlg::onDeactivate
1832 // purpose : SLOT called when dialog must be deativated
1833 //=================================================================================
1834 void SMESHGUI_GroupDlg::onDeactivate()
1836 mySMESHGUI->ResetState();
1840 //=================================================================================
1841 // function : SMESHGUI_GroupDlg::enterEvent
1842 // purpose : Event filter
1843 //=================================================================================
1844 void SMESHGUI_GroupDlg::enterEvent (QEvent*)
1847 mySMESHGUI->EmitSignalDeactivateDialog();
1849 mySelectionMode = -1;
1850 setSelectionMode(myTypeId);
1851 //mySMESHGUI->SetActiveDialogBox((QDialog*)this);
1852 mySMESHGUI->SetActiveDialogBox(this);
1853 mySMESHGUI->SetState(800);
1857 //=================================================================================
1858 // function : hideEvent
1859 // purpose : caused by ESC key
1860 //=================================================================================
1861 void SMESHGUI_GroupDlg::hideEvent (QHideEvent*)
1863 if (!isMinimized() && !myIsBusy)
1867 //=================================================================================
1868 // function : keyPressEvent()
1870 //=================================================================================
1871 void SMESHGUI_GroupDlg::keyPressEvent( QKeyEvent* e )
1873 QDialog::keyPressEvent( e );
1874 if ( e->isAccepted() )
1877 if ( e->key() == Key_F1 )
1884 //================================================================================
1886 * \brief Enable showing of the popup when Geometry selection btn is clicked
1887 * \param enable - true to enable
1889 //================================================================================
1891 enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
1893 void SMESHGUI_GroupDlg::updateGeomPopup()
1895 bool enable = false;
1897 if ( !myMesh->_is_nil() )
1898 enable = myMesh->NbEdges() > 0;
1900 if ( myGeomGroupBtn )
1902 disconnect( myGeomGroupBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
1904 if ( !myGeomPopup ) {
1905 myGeomPopup = new QPopupMenu();
1906 myGeomPopup->insertItem( tr("DIRECT_GEOM_SELECTION"), DIRECT_GEOM_INDEX );
1907 myGeomPopup->insertItem( tr("GEOM_BY_MESH_ELEM_SELECTION"), GEOM_BY_MESH_INDEX );
1908 connect( myGeomPopup, SIGNAL( activated( int ) ), SLOT( onGeomPopup( int ) ) );
1910 connect( myGeomGroupBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
1916 //=================================================================================
1917 // function : onGeomSelectionButton()
1919 //=================================================================================
1920 void SMESHGUI_GroupDlg::onGeomSelectionButton(bool isBtnOn)
1922 if ( myGeomPopup && isBtnOn )
1924 myCurrentLineEdit = myGeomGroupLine;
1925 int id = myGeomPopup->exec( QCursor::pos() );
1926 if (id == DIRECT_GEOM_INDEX || id == -1)
1927 setSelectionMode(7);
1931 myCurrentLineEdit = 0;
1932 setSelectionMode(8);
1936 //=================================================================================
1937 // function : onGeomPopup()
1939 //=================================================================================
1940 void SMESHGUI_GroupDlg::onGeomPopup( int index )
1942 if ( index == GEOM_BY_MESH_INDEX )
1944 mySelectionMode = -1;
1945 if ( !myShapeByMeshOp ) {
1946 myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp(true);
1947 connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
1948 SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
1949 connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
1950 SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
1952 // set mesh object to SMESHGUI_ShapeByMeshOp and start it
1953 if ( !myMesh->_is_nil() ) {
1955 hide(); // stop processing selection
1957 myShapeByMeshOp->setModule( mySMESHGUI );
1958 myShapeByMeshOp->setStudy( 0 ); // it's really necessary
1959 myShapeByMeshOp->SetMesh( myMesh );
1960 myShapeByMeshOp->start();
1965 //================================================================================
1967 * \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg
1969 //================================================================================
1971 void SMESHGUI_GroupDlg::onPublishShapeByMeshDlg(SUIT_Operation* op)
1973 if ( myShapeByMeshOp == op ) {
1974 mySMESHGUI->getApp()->updateObjectBrowser();
1976 // Select a found geometry object
1977 GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();
1978 if ( !aGeomVar->_is_nil() )
1980 QString ID = aGeomVar->GetStudyEntry();
1981 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1982 if ( _PTR(SObject) aGeomSO = aStudy->FindObjectID( ID.latin1() )) {
1983 SALOME_ListIO anIOList;
1984 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
1985 ( aGeomSO->GetID().c_str(), "SMESH", aGeomSO->GetName().c_str() );
1986 anIOList.Append( anIO );
1987 mySelectionMgr->setSelectedObjects( anIOList, false );
1988 onObjectSelectionChanged();
1994 //================================================================================
1996 * \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
1998 //================================================================================
2000 void SMESHGUI_GroupDlg::onCloseShapeByMeshDlg(SUIT_Operation* op)
2002 if ( myShapeByMeshOp == op )
2005 setSelectionMode(7);
2009 //=================================================================================
2010 // function : setGroupColor()
2012 //=================================================================================
2013 void SMESHGUI_GroupDlg::setGroupColor( const SALOMEDS::Color& theColor )
2015 QColor aQColor( (int)( theColor.R * 255.0 ),
2016 (int)( theColor.G * 255.0 ),
2017 (int)( theColor.B * 255.0 ) );
2018 setGroupQColor( aQColor );
2021 //=================================================================================
2022 // function : getGroupColor()
2024 //=================================================================================
2025 SALOMEDS::Color SMESHGUI_GroupDlg::getGroupColor() const
2027 QColor aQColor = getGroupQColor();
2029 SALOMEDS::Color aColor;
2030 aColor.R = (float)aQColor.red() / 255.0;
2031 aColor.G = (float)aQColor.green() / 255.0;
2032 aColor.B = (float)aQColor.blue() / 255.0;
2037 //=================================================================================
2038 // function : setGroupQColor()
2040 //=================================================================================
2041 void SMESHGUI_GroupDlg::setGroupQColor( const QColor& theColor )
2043 if ( theColor.isValid() )
2045 QPalette pal = myColorBtn->palette();
2046 pal.setColor(QColorGroup::Button, theColor);
2047 myColorBtn->setPalette(pal);
2051 //=================================================================================
2052 // function : getGroupQColor()
2054 //=================================================================================
2055 QColor SMESHGUI_GroupDlg::getGroupQColor() const
2057 QColor aColor = myColorBtn->palette().active().button();
2061 //=================================================================================
2062 // function : setDefaultGroupColor()
2064 //=================================================================================
2065 void SMESHGUI_GroupDlg::setDefaultGroupColor()
2067 if ( myMesh->_is_nil() )
2070 bool isAutoColor = myMesh->GetAutoColor();
2075 int r = 0, g = 0, b = 0;
2076 SMESH::GetColor( "SMESH", "fill_color", r, g, b, QColor( 0, 170, 255 ) );
2077 aQColor.setRgb( r, g, b );
2081 SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
2083 QValueList<SALOMEDS::Color> aReservedColors;
2084 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
2086 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
2087 SALOMEDS::Color aReservedColor = aGroupObject->GetColor();
2088 aReservedColors.append( aReservedColor );
2091 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
2092 aQColor.setRgb( (int)( aColor.R * 255.0 ),
2093 (int)( aColor.G * 255.0 ),
2094 (int)( aColor.B * 255.0 ) );
2098 setGroupQColor( aQColor );
2101 //=================================================================================
2102 // function : SetAppropriateActor()
2103 // purpose : Find more appropriate of visible actors, set it to myActor, allow picking
2104 // NPAL19389: create a group with a selection in another group.
2105 // if mesh actor is not visible - find any first visible group or submesh
2106 //=================================================================================
2107 bool SMESHGUI_GroupDlg::SetAppropriateActor()
2109 bool isActor = false;
2111 if (myMesh->_is_nil()) return false;
2113 SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
2116 myActor = SMESH::FindActorByObject(myMesh);
2117 if (myActor && myActor->hasIO())
2120 if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
2124 // try current group actor
2126 if (!myGroup->_is_nil()) {
2127 myActor = SMESH::FindActorByObject(myGroup);
2128 if (myActor && myActor->hasIO())
2131 if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
2137 // try current group on geometry actor
2139 if (!myGroupOnGeom->_is_nil()) {
2140 myActor = SMESH::FindActorByObject(myGroupOnGeom);
2141 if (myActor && myActor->hasIO())
2144 if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
2150 // try any visible actor of group or submesh of current mesh
2151 if (!isActor && aViewWindow) {
2153 _PTR(SObject) aSObject = SMESH::FindSObject(myMesh);
2155 CORBA::String_var meshEntry = aSObject->GetID().c_str();
2156 int len = strlen(meshEntry);
2158 // iterate on all actors in current view window, search for
2159 // any visible actor, that belongs to group or submesh of current mesh
2160 vtkActorCollection *aCollection = aViewWindow->getRenderer()->GetActors();
2161 aCollection->InitTraversal();
2162 for (vtkActor *anAct = aCollection->GetNextActor();
2164 anAct = aCollection->GetNextActor())
2166 SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct);
2167 if (anActor && anActor->hasIO()) {
2168 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
2169 if (aViewWindow->isVisible(anIO)) {
2170 if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0) {
2181 SMESH::SetPickable(myActor);
2186 //=======================================================================
2187 //function : setShowEntityMode
2188 //purpose : make shown only entity corresponding to my type
2189 //=======================================================================
2190 void SMESHGUI_GroupDlg::setShowEntityMode()
2192 if ( !myMesh->_is_nil() ) {
2193 if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) ) {
2194 if (!myStoredShownEntity)
2195 myStoredShownEntity = actor->GetEntityMode();
2196 switch ( myTypeId ) {
2197 case 0: restoreShowEntityMode(); break;
2198 case 1: actor->SetEntityMode( SMESH_Actor::eEdges ); break;
2199 case 2: actor->SetEntityMode( SMESH_Actor::eFaces ); break;
2200 case 3: actor->SetEntityMode( SMESH_Actor::eVolumes ); break;
2206 //=======================================================================
2207 //function : restoreShowEntityMode
2208 //purpose : restore ShowEntity mode of myActor
2209 //=======================================================================
2210 void SMESHGUI_GroupDlg::restoreShowEntityMode()
2212 if ( myStoredShownEntity && !myMesh->_is_nil() ) {
2213 if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) ) {
2214 actor->SetEntityMode(myStoredShownEntity);
2217 myStoredShownEntity = 0;