1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 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
24 // File : SMESHGUI_GroupDlg.cxx
25 // Author : Natalia KOPNOVA
29 #include "SMESHGUI_GroupDlg.h"
30 #include "SMESHGUI_FilterDlg.h"
31 #include "SMESHGUI_ShapeByMeshDlg.h"
34 #include "SMESHGUI_Utils.h"
35 #include "SMESHGUI_VTKUtils.h"
36 #include "SMESHGUI_MeshUtils.h"
37 #include "SMESHGUI_GroupUtils.h"
38 #include "SMESHGUI_FilterUtils.h"
39 #include "SMESHGUI_GEOMGenUtils.h"
41 #include "SMESH_TypeFilter.hxx"
42 #include "SMESH_Actor.h"
43 #include "SMESH_ActorUtils.h"
46 #include "GEOM_SelectionFilter.h"
48 #include "SUIT_Desktop.h"
49 #include "SUIT_ResourceMgr.h"
50 #include "SUIT_Session.h"
51 #include "SUIT_MessageBox.h"
53 #include "SalomeApp_Tools.h"
54 #include "SalomeApp_Application.h"
55 #include "SalomeApp_Study.h"
56 #include "LightApp_Application.h"
57 #include "SALOMEDSClient_Study.hxx"
58 #include "SALOME_ListIO.hxx"
59 #include "SALOME_ListIteratorOfListIO.hxx"
61 #include "SVTK_ViewWindow.h"
62 #include "SVTK_Selector.h"
64 #include "utilities.h"
67 #include <vtkRenderer.h>
68 #include <vtkActorCollection.h>
71 #include <TColStd_MapOfInteger.hxx>
74 #include <qbuttongroup.h>
76 #include <qgroupbox.h>
79 #include <qlineedit.h>
80 #include <qpushbutton.h>
81 #include <qtoolbutton.h>
82 #include <qradiobutton.h>
83 #include <qcheckbox.h>
88 #include <qmemarray.h>
89 #include <qwidgetstack.h>
90 #include <qcolordialog.h>
92 #include <QtxIntSpinBox.h>
101 //=================================================================================
102 // function : SMESHGUI_GroupDlg()
104 //=================================================================================
105 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
106 SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl)
107 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
108 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
109 mySMESHGUI( theModule ),
110 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
111 mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
113 myNameChanged(false),
116 if (!name) setName("SMESHGUI_GroupDlg");
118 if (!theMesh->_is_nil())
121 mySelectSubMesh->setEnabled(false);
122 mySelectGroup->setEnabled(false);
123 myGeomGroupBtn->setEnabled(false);
124 myGeomGroupLine->setEnabled(false);
128 //=================================================================================
129 // function : SMESHGUI_GroupDlg()
131 //=================================================================================
132 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
133 SMESH::SMESH_GroupBase_ptr theGroup, bool modal, WFlags fl)
134 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
135 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
136 mySMESHGUI( theModule ),
137 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
138 mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
142 if (!name) setName("SMESHGUI_GroupDlg");
145 if (!theGroup->_is_nil())
148 mySelectSubMesh->setEnabled(false);
149 mySelectGroup->setEnabled(false);
151 myCurrentLineEdit = myMeshGroupLine;
156 //=================================================================================
157 // function : SMESHGUI_GroupDlg()
159 //=================================================================================
160 void SMESHGUI_GroupDlg::initDialog(bool create)
164 myCurrentLineEdit = 0;
168 myGeomObjects = new GEOM::ListOfGO();
169 myGeomObjects->length(0);
171 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
174 setCaption(tr("SMESH_CREATE_GROUP_TITLE"));
175 myHelpFileName = "creating_groups_page.html";
178 setCaption(tr("SMESH_EDIT_GROUP_TITLE"));
179 myHelpFileName = "editing_groups_page.html";
182 setSizeGripEnabled(TRUE);
184 QGridLayout* aMainLayout = new QGridLayout(this, 7, 3, 11, 6);
186 /***************************************************************/
187 QLabel* meshGroupLab = new QLabel(this, "mesh/group label");
189 meshGroupLab->setText(tr("SMESH_MESH"));
191 meshGroupLab->setText(tr("SMESH_GROUP"));
192 myMeshGroupBtn = new QPushButton(this, "mesh/group button");
193 myMeshGroupBtn->setPixmap(image0);
194 myMeshGroupLine = new QLineEdit(this, "mesh/group line");
195 myMeshGroupLine->setReadOnly(true);
197 /***************************************************************/
198 myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types");
199 myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE"));
200 myTypeGroup->setExclusive(true);
203 types.append(tr("MESH_NODE"));
204 types.append(tr("SMESH_EDGE"));
205 types.append(tr("SMESH_FACE"));
206 types.append(tr("SMESH_VOLUME"));
208 for (int i = 0; i < types.count(); i++) {
209 rb = new QRadioButton(types[i], myTypeGroup);
211 myTypeGroup->setEnabled(create);
214 /***************************************************************/
215 QLabel* aName = new QLabel(this, "name label");
216 aName->setText(tr("SMESH_NAME"));
217 aName->setMinimumSize(50,0);
218 myName = new QLineEdit(this, "name");
220 /***************************************************************/
221 myGrpTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Type of group");
222 myGrpTypeGroup->setTitle(tr("SMESH_GROUP_TYPE"));
223 myGrpTypeGroup->setExclusive(true);
224 QRadioButton* rb1 = new QRadioButton( tr("SMESH_GROUP_STANDALONE"), myGrpTypeGroup);
225 QRadioButton* rb2 = new QRadioButton( tr("SMESH_GROUP_GEOMETRY"), myGrpTypeGroup);
226 myGrpTypeGroup->setEnabled(create);
229 /***************************************************************/
230 myWGStack = new QWidgetStack( this, "widget stack");
231 QWidget* wg1 = new QFrame( myWGStack, "first widget" );
232 QWidget* wg2 = new QFrame( myWGStack, "second widget" );
234 /***************************************************************/
235 QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, wg1, "content box");
236 aContentBox->setTitle(tr("SMESH_CONTENT"));
237 QFrame* aContent = new QFrame(aContentBox, "content");
238 QGridLayout* aLayout = new QGridLayout(aContent, 7, 4);
239 aLayout->setSpacing(6);
240 aLayout->setAutoAdd(false);
242 QLabel* aLabel = new QLabel(aContent, "elements label");
243 aLabel->setText(tr("SMESH_ID_ELEMENTS"));
244 myElements = new QListBox(aContent, "elements list");
245 myElements->setSelectionMode(QListBox::Extended);
247 myFilter = new QPushButton(aContent, "filter");
248 myFilter->setText(tr("SMESH_BUT_FILTER"));
249 QPushButton* aAddBtn = new QPushButton(aContent, "add");
250 aAddBtn->setText(tr("SMESH_BUT_ADD"));
251 QPushButton* aRemoveBtn = new QPushButton(aContent, "remove");
252 aRemoveBtn->setText(tr("SMESH_BUT_REMOVE"));
253 QPushButton* aSortBtn = new QPushButton(aContent, "sort");
254 aSortBtn->setText(tr("SMESH_BUT_SORT"));
256 aLayout->addWidget(aLabel, 0, 0);
257 aLayout->addMultiCellWidget(myElements, 1, 6, 0, 0);
258 aLayout->addWidget(myFilter, 1, 2);
259 aLayout->addWidget(aAddBtn, 3, 2);
260 aLayout->addWidget(aRemoveBtn, 4, 2);
261 aLayout->addWidget(aSortBtn, 6, 2);
263 aLayout->setColStretch(0, 1);
264 aLayout->addColSpacing(1, 20);
265 aLayout->addColSpacing(3, 20);
266 aLayout->setRowStretch(2, 1);
267 aLayout->setRowStretch(5, 1);
269 /***************************************************************/
270 QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, wg1, "select box");
271 aSelectBox->setTitle(tr("SMESH_SELECT_FROM"));
273 mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox");
274 mySelectSubMesh->setText(tr("SMESH_SUBMESH"));
275 mySelectSubMesh->setMinimumSize(50, 0);
276 mySubMeshBtn = new QPushButton(aSelectBox, "submesh button");
277 mySubMeshBtn->setText("");
278 mySubMeshBtn->setPixmap(image0);
279 mySubMeshLine = new QLineEdit(aSelectBox, "submesh line");
280 mySubMeshLine->setReadOnly(true);
281 onSelectSubMesh(false);
283 mySelectGroup = new QCheckBox(aSelectBox, "group checkbox");
284 mySelectGroup->setText(tr("SMESH_GROUP"));
285 mySelectGroup->setMinimumSize(50, 0);
286 myGroupBtn = new QPushButton(aSelectBox, "group button");
287 myGroupBtn->setText("");
288 myGroupBtn->setPixmap(image0);
289 myGroupLine = new QLineEdit(aSelectBox, "group line");
290 myGroupLine->setReadOnly(true);
291 onSelectGroup(false);
293 /***************************************************************/
294 QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 );
295 wg1Layout->addWidget(aContentBox, 0, 0);
296 wg1Layout->addWidget(aSelectBox, 1, 0);
297 wg1Layout->setRowStretch(2, 5);
299 /***************************************************************/
300 QLabel* geomObject = new QLabel(wg2, "geometry object label");
301 geomObject->setText(tr("SMESH_OBJECT_GEOM"));
302 myGeomGroupBtn = new QToolButton(wg2, "geometry group button");
303 myGeomGroupBtn->setIconSet( QIconSet(image0) );
304 myGeomGroupBtn->setToggleButton(true);
305 myGeomGroupLine = new QLineEdit(wg2, "geometry group line");
306 myGeomGroupLine->setReadOnly(true); //VSR ???
307 onSelectGeomGroup(false);
311 myGeomGroupBtn->setEnabled(false);
312 myGeomGroupLine->setEnabled(false);
315 /***************************************************************/
316 QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 );
317 wg2Layout->addWidget(geomObject, 0, 0);
318 wg2Layout->addWidget(myGeomGroupBtn, 0, 1);
319 wg2Layout->addWidget(myGeomGroupLine,0, 2);
320 wg2Layout->setRowStretch(1, 5);
322 /***************************************************************/
323 QVBoxLayout* dumb = new QVBoxLayout(myWGStack);
324 dumb->addWidget(wg1);
325 dumb->addWidget(wg2);
326 myWGStack->addWidget( wg1, myGrpTypeGroup->id(rb1) );
327 myWGStack->addWidget( wg2, myGrpTypeGroup->id(rb2) );
329 /***************************************************************/
330 QGroupBox* aColorBox = new QGroupBox(2, Qt::Horizontal, this, "color box");
331 aColorBox->setTitle(tr("SMESH_SET_COLOR"));
333 new QLabel( tr("SMESH_CHECK_COLOR"), aColorBox, "color label" );
334 myColorBtn = new QPushButton(aColorBox, "color button");
335 myColorBtn->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
337 /***************************************************************/
339 QFrame* aButtons = new QFrame(this, "button box");
340 aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken);
341 QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6);
342 aBtnLayout->setAutoAdd(false);
344 QPushButton* aApplyBtn = new QPushButton(aButtons, "apply");
345 aApplyBtn->setText(tr("SMESH_BUT_APPLY"));
346 aApplyBtn->setAutoDefault(true);
347 QPushButton* aCloseBtn = new QPushButton(aButtons, "close");
348 aCloseBtn->setText(tr("SMESH_BUT_CLOSE"));
349 aCloseBtn->setAutoDefault(true);
350 QPushButton* aOKBtn = new QPushButton(aButtons, "ok");
351 aOKBtn->setText(tr("SMESH_BUT_APPLY_AND_CLOSE"));
352 aOKBtn->setAutoDefault(true);
353 aOKBtn->setDefault(true);
354 QPushButton* aHelpBtn = new QPushButton(aButtons, "help");
355 aHelpBtn->setText(tr("SMESH_BUT_HELP"));
356 aHelpBtn->setAutoDefault(true);
358 aBtnLayout->addWidget(aOKBtn);
359 aBtnLayout->addWidget(aApplyBtn);
360 aBtnLayout->addStretch();
361 aBtnLayout->addWidget(aCloseBtn);
362 aBtnLayout->addWidget(aHelpBtn);
364 /***************************************************************/
365 aMainLayout->addWidget(meshGroupLab, 0, 0);
366 aMainLayout->addWidget(myMeshGroupBtn, 0, 1);
367 aMainLayout->addWidget(myMeshGroupLine, 0, 2);
368 aMainLayout->addMultiCellWidget(myTypeGroup, 1, 1, 0, 2);
369 aMainLayout->addWidget(aName, 2, 0);
370 aMainLayout->addWidget(myName, 2, 2);
371 aMainLayout->addMultiCellWidget(myGrpTypeGroup, 3, 3, 0, 2);
372 aMainLayout->addMultiCellWidget(myWGStack, 4, 4, 0, 2);
373 aMainLayout->setRowStretch( 5, 5 );
374 aMainLayout->addMultiCellWidget(aColorBox, 6, 6, 0, 2);
375 aMainLayout->addMultiCellWidget(aButtons, 7, 7, 0, 2);
377 /* signals and slots connections */
378 connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
380 connect(myGrpTypeGroup, SIGNAL(clicked(int)), this, SLOT(onGrpTypeChanged(int)));
382 connect(myTypeGroup, SIGNAL(clicked(int)), this, SLOT(onTypeChanged(int)));
384 connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
385 connect(myElements, SIGNAL(selectionChanged()), this, SLOT(onListSelectionChanged()));
387 connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters()));
388 connect(aAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
389 connect(aRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
390 connect(aSortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
392 connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool)));
393 connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool)));
394 connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
395 connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
396 connect(myGeomGroupBtn, SIGNAL(toggled(bool)), this, SLOT(onGeomSelectionButton(bool)));
397 connect(myColorBtn, SIGNAL(clicked()), this, SLOT(onSelectColor()));
399 connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
400 connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
401 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
402 connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
405 mySMESHGUI->SetActiveDialogBox(this);
406 mySMESHGUI->SetState(800);
408 mySelectionMode = -1;
409 myMeshFilter = new SMESH_TypeFilter(MESH);
410 mySubMeshFilter = new SMESH_TypeFilter(SUBMESH);
411 myGroupFilter = new SMESH_TypeFilter(GROUP);
412 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
413 myGeomFilter = new GEOM_SelectionFilter( aStudy, true );
415 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
416 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose()));
417 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
419 myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!!
420 onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!!
422 if (myMesh->_is_nil() )
423 myTypeGroup->setButton(0);
426 //myName->setText(GetDefaultName(tr("SMESH_GROUP")));
429 //=================================================================================
430 // function : ~SMESHGUI_GroupDlg()
431 // purpose : Destroys the object and frees any allocated resources
432 //=================================================================================
433 SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg()
435 // no need to delete child widgets, Qt does it all for us
436 if ( myFilterDlg != 0 )
438 myFilterDlg->reparent( 0, QPoint() );
443 //=================================================================================
444 // function : GetDefaultName()
445 // purpose : Get the Group Name if Create new Group
446 //=================================================================================
447 QString SMESHGUI_GroupDlg::GetDefaultName(const QString& theOperation)
451 // collect all object names of SMESH component
452 SalomeApp_Study* appStudy =
453 dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
454 if ( !appStudy ) return aName;
455 _PTR(Study) aStudy = appStudy->studyDS();
457 std::set<std::string> aSet;
458 _PTR(SComponent) aMeshCompo (aStudy->FindComponent("SMESH"));
460 _PTR(ChildIterator) it (aStudy->NewChildIterator(aMeshCompo));
462 for (it->InitEx(true); it->More(); it->Next()) {
464 aSet.insert(obj->GetName());
468 // build a unique name
470 bool isUnique = false;
472 aName = theOperation + "_" + QString::number(++aNumber);
473 isUnique = (aSet.count(aName.latin1()) == 0);
479 //=================================================================================
482 //=================================================================================
483 void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh)
485 mySelectionMgr->installFilter(myMeshFilter);
487 /* init data from current selection */
488 restoreShowEntityMode();
489 myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh);
491 myGroup = SMESH::SMESH_Group::_nil();
492 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
494 // NPAL19389: create a group with a selection in another group
495 // set actor of myMesh, if it is visible, else try
496 // any visible actor of group or submesh of myMesh
497 SetAppropriateActor();
499 setDefaultGroupColor();
502 mySelectionMgr->selectedObjects( aList );
503 if ( !aList.IsEmpty() )
505 QString aName = aList.First()->getName();
506 myMeshGroupLine->setText(aName);
507 myMeshGroupLine->home( false );
510 myCurrentLineEdit = 0;
512 myTypeGroup->setButton(0);
516 //=================================================================================
519 //=================================================================================
520 void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
522 restoreShowEntityMode();
523 myMesh = theGroup->GetMesh();
526 myNameChanged = true;
527 myName->blockSignals(true);
528 myName->setText(theGroup->GetName());
529 myName->blockSignals(false);
532 SALOMEDS::Color aColor = theGroup->GetColor();
533 setGroupColor( aColor );
535 myMeshGroupLine->setText(theGroup->GetName());
538 switch(theGroup->GetType()) {
539 case SMESH::NODE: aType= 0; break;
540 case SMESH::EDGE: aType = 1; break;
541 case SMESH::FACE: aType = 2; break;
542 case SMESH::VOLUME: aType = 3; break;
544 myTypeGroup->setButton(aType);
546 myGroup = SMESH::SMESH_Group::_narrow( theGroup );
548 if (!myGroup->_is_nil())
550 // NPAL19389: create a group with a selection in another group
551 // set actor of myMesh, if it is visible, else set
552 // actor of myGroup, if it is visible, else try
553 // any visible actor of group or submesh of myMesh
554 // commented, because an attempt to set selection on not displayed cells leads to error
555 //SetAppropriateActor();
556 myActor = SMESH::FindActorByObject(myMesh);
558 myActor = SMESH::FindActorByObject(myGroup);
559 SMESH::SetPickable(myActor);
561 myGrpTypeGroup->setButton(0);
564 myCurrentLineEdit = 0;
566 setSelectionMode(aType);
569 setShowEntityMode(); // depends on myTypeId
572 if (!myGroup->IsEmpty()) {
573 SMESH::long_array_var anElements = myGroup->GetListOfID();
574 int k = anElements->length();
575 for (int i = 0; i < k; i++) {
576 myIdList.append(anElements[i]);
577 myElements->insertItem(QString::number(anElements[i]));
579 myElements->selectAll(true);
584 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
586 if ( !myGroupOnGeom->_is_nil() )
588 // NPAL19389: create a group with a selection in another group
589 // set actor of myMesh, if it is visible, else set
590 // actor of myGroupOnGeom, if it is visible, else try
591 // any visible actor of group or submesh of myMesh
592 // commented, because an attempt to set selection on not displayed cells leads to error
593 //SetAppropriateActor();
594 myActor = SMESH::FindActorByObject(myMesh);
596 myActor = SMESH::FindActorByObject(myGroupOnGeom);
597 SMESH::SetPickable(myActor);
599 myGrpTypeGroup->setButton(1);
602 QString aShapeName("");
603 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
604 GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
605 if (!aGroupShape->_is_nil())
607 _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
608 aShapeName = aGroupShapeSO->GetName().c_str();
610 myGeomGroupLine->setText( aShapeName );
611 myNameChanged = true;
612 myName->blockSignals(true);
613 myName->setText("Group On " + aShapeName);
614 myName->blockSignals(false);
619 //=================================================================================
620 // function : updateButtons()
622 //=================================================================================
623 void SMESHGUI_GroupDlg::updateButtons()
625 bool enable = !myName->text().stripWhiteSpace().isEmpty();
627 if (myGrpTypeId == 0) {
628 enable = enable && myElements->count() > 0;
629 enable = enable && (!myGroup->_is_nil() || !myMesh->_is_nil());
631 else if (myGrpTypeId == 1) {
632 if (CORBA::is_nil(myGroupOnGeom)) { // creation mode
633 enable = enable && myGeomObjects->length() > 0 && !myMesh->_is_nil();
638 aBtn = (QPushButton*) child("ok", "QPushButton");
639 if (aBtn) aBtn->setEnabled(enable);
640 aBtn = (QPushButton*) child("apply", "QPushButton");
641 if (aBtn) aBtn->setEnabled(enable);
644 //=================================================================================
645 // function : onNameChanged()
647 //=================================================================================
648 void SMESHGUI_GroupDlg::onNameChanged (const QString& text)
650 myOldName = myName->text();
652 QString tmp = myName->text();
653 tmp.stripWhiteSpace();
655 myNameChanged = true;
657 myNameChanged = false;
660 //=================================================================================
661 // function : onTypeChanged()
662 // purpose : Group elements type radio button management
663 //=================================================================================
664 void SMESHGUI_GroupDlg::onTypeChanged (int id)
666 if (myTypeId != id) {
668 if (myCurrentLineEdit == 0)
669 setSelectionMode(id);
675 //=================================================================================
676 // function : onGrpTypeChanged()
677 // purpose : Group type radio button management
678 //=================================================================================
679 void SMESHGUI_GroupDlg::onGrpTypeChanged (int id)
681 if (myGrpTypeId != id) {
682 myWGStack->raiseWidget( id );
683 myName->blockSignals(true);
684 myName->setText(myOldName);
685 myName->blockSignals(false);
686 onSelectGeomGroup(id == 1);
691 //=================================================================================
692 // function : onSelectColor()
694 //=================================================================================
695 void SMESHGUI_GroupDlg::onSelectColor()
697 QColor color = getGroupQColor();
698 color = QColorDialog::getColor( color );
699 setGroupQColor( color );
704 //=================================================================================
705 // function : setSelectionMode()
706 // purpose : Radio button management
707 //=================================================================================
708 void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
711 if (myMesh->_is_nil())
713 if (mySelectionMode != theMode) {
714 // [PAL10408] mySelectionMgr->clearSelected();
715 mySelectionMgr->clearFilters();
717 myActor->SetPointRepresentation(false);
719 SMESH::SetPointRepresentation(false);
724 myActor->SetPointRepresentation(true);
726 SMESH::SetPointRepresentation(true);
727 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
728 aViewWindow->SetSelectionMode(NodeSelection);
731 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
732 aViewWindow->SetSelectionMode(EdgeSelection);
735 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
736 aViewWindow->SetSelectionMode(FaceSelection);
739 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
740 aViewWindow->SetSelectionMode(VolumeSelection);
744 mySelectionMgr->installFilter(mySubMeshFilter);
745 else if (theMode == 5)
746 mySelectionMgr->installFilter(myGroupFilter);
747 else if (theMode == 6)
748 mySelectionMgr->installFilter(myMeshFilter);
749 else if (theMode == 7)
750 mySelectionMgr->installFilter(myGeomFilter);
752 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
753 aViewWindow->SetSelectionMode(ActorSelection);
755 mySelectionMode = theMode;
759 //=================================================================================
760 // function : onApply()
762 //=================================================================================
763 bool SMESHGUI_GroupDlg::onApply()
765 if (mySMESHGUI->isActiveStudyLocked())
768 if (myName->text().stripWhiteSpace().isEmpty())
771 if (myGrpTypeId == 0) { // on mesh elements
772 if (!myElements->count())
775 mySelectionMgr->clearSelected();
777 if (myGroup->_is_nil()) { // creation
778 if (myMesh->_is_nil())
781 SMESH::ElementType aType = SMESH::ALL;
783 case 0: aType = SMESH::NODE; break;
784 case 1: aType = SMESH::EDGE; break;
785 case 2: aType = SMESH::FACE; break;
786 case 3: aType = SMESH::VOLUME; break;
789 SMESH::long_array_var anIdList = new SMESH::long_array;
790 int i, k = myElements->count();
792 QListBoxItem* anItem;
793 for (i = 0, anItem = myElements->firstItem(); anItem != 0; i++, anItem = anItem->next()) {
794 anIdList[i] = anItem->text().toInt();
797 myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
798 myGroup->Add(anIdList.inout());
800 SALOMEDS::Color aColor = getGroupColor();
801 myGroup->SetColor(aColor);
803 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
805 //SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
806 SMESH::setFileType ( aMeshGroupSO, "COULEURGROUP" );
808 /* init for next operation */
811 myGroup = SMESH::SMESH_Group::_nil();
814 myGroup->SetName(myName->text());
816 SALOMEDS::Color aColor = getGroupColor();
817 myGroup->SetColor(aColor);
819 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
820 if (SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str()))
821 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
823 QValueList<int> aAddList;
824 QValueList<int>::iterator anIt;
825 QListBoxItem* anItem;
827 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
828 int anId = anItem->text().toInt();
829 if ((anIt = myIdList.find(anId)) == myIdList.end())
830 aAddList.append(anId);
832 myIdList.remove(anIt);
834 if (!aAddList.empty()) {
835 SMESH::long_array_var anIdList = new SMESH::long_array;
836 anIdList->length(aAddList.count());
838 for (i = 0, anIt = aAddList.begin(); anIt != aAddList.end(); anIt++, i++)
840 myGroup->Add(anIdList.inout());
842 if (!myIdList.empty()) {
843 SMESH::long_array_var anIdList = new SMESH::long_array;
844 anIdList->length(myIdList.count());
846 for (i = 0, anIt = myIdList.begin(); anIt != myIdList.end(); anIt++, i++)
848 myGroup->Remove(anIdList.inout());
850 /* init for next operation */
852 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next())
853 myIdList.append(anItem->text().toInt());
856 mySMESHGUI->updateObjBrowser(true);
857 SMESH::UpdateView(); // asv: fix of BUG PAL5515
858 mySelectionMgr->clearSelected();
861 else if (myGrpTypeId == 1) { // on geom object
862 if (CORBA::is_nil(myGroupOnGeom)) { // creation
863 if (myMesh->_is_nil() || !myGeomObjects->length())
866 SMESH::ElementType aType = SMESH::ALL;
868 case 0: aType = SMESH::NODE; break;
869 case 1: aType = SMESH::EDGE; break;
870 case 2: aType = SMESH::FACE; break;
871 case 3: aType = SMESH::VOLUME; break;
874 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
875 GEOM::GEOM_IGroupOperations_var aGroupOp =
876 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
878 if (myGeomObjects->length() == 1) {
879 myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomObjects[0]);
882 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
883 if ( aSMESHGen->_is_nil() )
886 // create a geometry group
887 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
888 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
890 if (geomGen->_is_nil() || !aStudy)
893 GEOM::GEOM_IGroupOperations_var op =
894 geomGen->GetIGroupOperations(aStudy->StudyId());
898 // check and add all selected GEOM objects: they must be
899 // a sub-shapes of the main GEOM and must be of one type
900 TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
901 for ( int i =0; i < myGeomObjects->length(); i++) {
902 TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)myGeomObjects[i]->GetShapeType();
904 aGroupType = aSubShapeType;
905 else if (aSubShapeType != aGroupType) {
906 aGroupType = TopAbs_SHAPE;
911 GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
912 GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(aMeshShape, aGroupType);
913 op->UnionList(aGroupVar, myGeomObjects);
916 // publish the GEOM group in study
917 QString aNewGeomGroupName ("Auto_group_for_");
918 aNewGeomGroupName += myName->text();
919 SALOMEDS::SObject_var aNewGroupSO =
920 geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar, aNewGeomGroupName, aMeshShape);
923 myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(), aGroupVar);
926 SALOMEDS::Color aColor = getGroupColor();
927 myGroupOnGeom->SetColor(aColor);
929 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
931 //SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
932 SMESH::setFileType ( aMeshGroupSO,"COULEURGROUP" );
934 /* init for next operation */
936 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
939 myGroupOnGeom->SetName(myName->text());
941 SALOMEDS::Color aColor = getGroupColor();
942 myGroupOnGeom->SetColor(aColor);
944 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
945 if (SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str()))
946 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
949 mySMESHGUI->updateObjBrowser(true);
950 mySelectionMgr->clearSelected();
957 //=================================================================================
960 //=================================================================================
961 void SMESHGUI_GroupDlg::onOK()
967 //=================================================================================
968 // function : onListSelectionChanged()
969 // purpose : Called when selection in element list is changed
970 //=================================================================================
971 void SMESHGUI_GroupDlg::onListSelectionChanged()
973 // MESSAGE("SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor);
974 if ( myIsBusy || !myActor) return;
977 if (myCurrentLineEdit == 0) {
978 mySelectionMgr->clearSelected();
979 TColStd_MapOfInteger aIndexes;
980 QListBoxItem* anItem;
981 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
982 if (anItem->isSelected()) {
983 int anId = anItem->text().toInt();
987 mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
989 aList.Append(myActor->getIO());
990 mySelectionMgr->setSelectedObjects(aList,false);
995 //=================================================================================
996 // function : onObjectSelectionChanged()
997 // purpose : Called when selection in 3D view or ObjectBrowser is changed
998 //=================================================================================
999 void SMESHGUI_GroupDlg::onObjectSelectionChanged()
1001 if (myIsBusy || !isEnabled()) return;
1002 if (myCurrentLineEdit == myGeomGroupLine && !myGeomGroupBtn->isOn()) return;
1006 SALOME_ListIO aList;
1007 mySelectionMgr->selectedObjects( aList );
1009 int aNbSel = aList.Extent();
1010 myElements->clearSelection();
1012 if (myCurrentLineEdit)
1014 myCurrentLineEdit->setText("");
1015 QString aString = "";
1017 if (myCurrentLineEdit == myMeshGroupLine)
1019 mySelectSubMesh->setEnabled(false);
1020 mySelectGroup->setEnabled(false);
1021 myGroupLine->setText("");
1022 mySubMeshLine->setText("");
1024 myGeomGroupBtn->setEnabled(false);
1025 myGeomGroupLine->setEnabled(false);
1026 myGeomGroupLine->setText("");
1027 myGeomObjects = new GEOM::ListOfGO();
1028 myGeomObjects->length(0);
1030 if (myGeomGroupBtn->isOn())
1031 myGeomGroupBtn->setOn(false);
1033 myName->setText("");
1035 myElements->clear();
1038 myGroup = SMESH::SMESH_Group::_nil();
1039 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
1040 restoreShowEntityMode();
1041 myMesh = SMESH::SMESH_Mesh::_nil();
1047 Handle(SALOME_InteractiveObject) IO = aList.First();
1050 restoreShowEntityMode();
1051 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
1052 setShowEntityMode();
1054 if (myMesh->_is_nil())
1060 myGroup = SMESH::SMESH_Group::_nil();
1062 // NPAL19389: create a group with a selection in another group
1063 // set actor of myMesh, if it is visible, else try
1064 // any visible actor of group or submesh of myMesh
1065 SetAppropriateActor();
1067 aString = aList.First()->getName();
1068 myMeshGroupLine->setText(aString);
1069 myMeshGroupLine->home( false );
1071 mySelectSubMesh->setEnabled(true);
1072 mySelectGroup->setEnabled(true);
1073 myGeomGroupBtn->setEnabled(true);
1074 myGeomGroupLine->setEnabled(true);
1077 SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
1078 if (aGroup->_is_nil())
1084 myCurrentLineEdit = 0;
1086 myGroup = SMESH::SMESH_Group::_nil();
1087 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
1091 mySelectSubMesh->setEnabled(true);
1092 mySelectGroup->setEnabled(true);
1094 myCurrentLineEdit = 0;
1099 if (myGrpTypeId == 0)
1105 myElements->clear();
1106 setSelectionMode(myTypeId);
1113 else if (myCurrentLineEdit == myGeomGroupLine)
1115 myGeomObjects = new GEOM::ListOfGO();
1118 _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
1120 if (aNbSel == 0 || !aMeshSO)
1122 myGeomObjects->length(0);
1128 myGeomObjects->length(aNbSel);
1130 GEOM::GEOM_Object_var aGeomGroup;
1131 Standard_Boolean testResult;
1134 SALOME_ListIteratorOfListIO anIt (aList);
1135 for (; anIt.More(); anIt.Next())
1137 testResult = Standard_False;
1138 aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value(), testResult);
1140 // Check if the object is a geometry group
1141 if (!testResult || CORBA::is_nil(aGeomGroup))
1144 // Check if group constructed on the same shape as a mesh or on its child
1145 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1146 GEOM::GEOM_IGroupOperations_var anOp =
1147 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1149 // The main shape of the group
1150 GEOM::GEOM_Object_var aGroupMainShape;
1151 if (aGeomGroup->GetType() == 37)
1152 aGroupMainShape = anOp->GetMainShape(aGeomGroup);
1154 aGroupMainShape = GEOM::GEOM_Object::_duplicate(aGeomGroup);
1155 _PTR(SObject) aGroupMainShapeSO =
1156 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape));
1157 aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
1159 _PTR(SObject) anObj, aRef;
1160 bool isRefOrSubShape = false;
1161 if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) {
1162 //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) {
1163 if (aRef->GetID() == aGroupMainShapeSO->GetID()) {
1164 isRefOrSubShape = true;
1166 _PTR(SObject) aFather = aGroupMainShapeSO->GetFather();
1167 _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent();
1168 //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) {
1169 while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) {
1170 //if (strcmp(aRef->GetID(), aFather->GetID()) == 0)
1171 if (aRef->GetID() == aFather->GetID())
1172 isRefOrSubShape = true;
1174 aFather = aFather->GetFather();
1178 if (isRefOrSubShape)
1179 myGeomObjects[i++] = aGeomGroup;
1182 myGeomObjects->length(i);
1194 if (myCurrentLineEdit == mySubMeshLine)
1195 aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel);
1196 else if (myCurrentLineEdit == myGroupLine)
1197 aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel);
1198 else if (myCurrentLineEdit == myGeomGroupLine)
1199 aString = tr("%1 Objects").arg(aNbSel);
1202 aString = aList.First()->getName();
1206 myCurrentLineEdit->setText(aString);
1207 myCurrentLineEdit->home(false);
1208 // 07.06.2008 skl for IPAL19574:
1209 // change name of group only if it is empty
1210 QString tmp = myName->text();
1211 tmp.stripWhiteSpace();
1212 if( tmp.isEmpty() || !myNameChanged ) {
1213 myOldName = myName->text();
1214 myName->blockSignals(true);
1215 myName->setText(aString);
1216 myName->blockSignals(false);
1221 else // !myCurrentLineEdit: local selection of nodes or elements
1223 if (aNbSel == 1 && myActor && myActor->hasIO())
1225 #ifdef ENABLE_SWITCH_ACTOR_DURING_ELEMENTS_SELECTION
1226 // NPAL19389: create a group with a selection in another group
1227 // Switch myActor to the newly selected one, if the last
1228 // is visible and belongs to group or submesh of myMesh
1229 Handle(SALOME_InteractiveObject) curIO = myActor->getIO();
1230 Handle(SALOME_InteractiveObject) selIO = aList.First();
1231 if (curIO->hasEntry() && selIO->hasEntry()) {
1232 const char* selEntry = selIO->getEntry();
1233 if (strcmp(curIO->getEntry(), selEntry) != 0) {
1234 // different objects: selected and myActor
1235 SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
1236 if (aViewWindow && aViewWindow->isVisible(selIO)) {
1237 // newly selected actor is visible
1240 _PTR(SObject) aSObject = SMESH::FindSObject(myMesh);
1242 CORBA::String_var meshEntry = aSObject->GetID().c_str();
1243 int len = strlen(meshEntry);
1245 if (strncmp(selEntry, meshEntry, len) == 0) {
1246 // selected object is myMesh or a part of it
1247 SMESH_Actor* anActor = SMESH::FindActorByEntry(selEntry);
1250 SMESH::SetPickable(myActor);
1258 #endif // ENABLE_SWITCH_ACTOR_DURING_ELEMENTS_SELECTION
1260 QString aListStr = "";
1262 if (myTypeId == 0) {
1263 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1265 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1268 QStringList anElements = QStringList::split(" ", aListStr);
1269 QListBoxItem* anItem = 0;
1270 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1271 anItem = myElements->findItem(*it, Qt::ExactMatch);
1272 if (anItem) myElements->setSelected(anItem, true);
1279 if (!myGroup->_is_nil())
1280 myActor = SMESH::FindActorByObject(myGroup);
1281 else if (!myGroupOnGeom->_is_nil())
1282 myActor = SMESH::FindActorByObject(myGroupOnGeom);
1284 myActor = SMESH::FindActorByObject(myMesh);
1287 // somehow, if we display the mesh, while selecting from another actor,
1288 // the mesh becomes pickable, and there is no way to select any element
1290 SMESH::SetPickable(myActor);
1295 //=================================================================================
1296 // function : onSelectSubMesh()
1297 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1298 //=================================================================================
1299 void SMESHGUI_GroupDlg::onSelectSubMesh(bool on)
1302 if (mySelectGroup->isChecked()) {
1303 mySelectGroup->setChecked(false);
1305 //VSR: else if (mySelectGeomGroup->isChecked()) {
1306 //VSR: mySelectGeomGroup->setChecked(false);
1308 myCurrentLineEdit = mySubMeshLine;
1309 setSelectionMode(4);
1312 mySubMeshLine->setText("");
1313 myCurrentLineEdit = 0;
1315 setSelectionMode(myTypeId);
1317 mySubMeshBtn->setEnabled(on);
1318 mySubMeshLine->setEnabled(on);
1322 //=================================================================================
1323 // function : (onSelectGroup)
1324 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1325 //=================================================================================
1326 void SMESHGUI_GroupDlg::onSelectGroup(bool on)
1329 if (mySelectSubMesh->isChecked()) {
1330 mySelectSubMesh->setChecked(false);
1332 myCurrentLineEdit = myGroupLine;
1333 setSelectionMode(5);
1336 myGroupLine->setText("");
1337 myCurrentLineEdit = 0;
1339 setSelectionMode(myTypeId);
1341 myGroupBtn->setEnabled(on);
1342 myGroupLine->setEnabled(on);
1346 //=================================================================================
1347 // function : (onSelectGeomGroup)
1348 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1349 //=================================================================================
1350 void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
1353 if (mySelectSubMesh->isChecked()) {
1354 mySelectSubMesh->setChecked(false);
1356 else if (mySelectGroup->isChecked()) {
1357 mySelectGroup->setChecked(false);
1359 myCurrentLineEdit = myGeomGroupLine;
1361 setSelectionMode(8);
1364 myGeomGroupBtn->setOn(false);
1365 myGeomObjects->length(0);
1366 myGeomGroupLine->setText("");
1367 myCurrentLineEdit = 0;
1369 setSelectionMode(myTypeId);
1374 //=================================================================================
1375 // function : setCurrentSelection()
1377 //=================================================================================
1378 void SMESHGUI_GroupDlg::setCurrentSelection()
1380 QPushButton* send = (QPushButton*)sender();
1381 myCurrentLineEdit = 0;
1382 if (send == myMeshGroupBtn) {
1383 myCurrentLineEdit = myMeshGroupLine;
1385 setSelectionMode(6);
1387 setSelectionMode(5);
1388 onObjectSelectionChanged();
1390 else if (send == mySubMeshBtn) {
1391 myCurrentLineEdit = mySubMeshLine;
1392 onObjectSelectionChanged();
1394 else if (send == myGroupBtn) {
1395 myCurrentLineEdit = myGroupLine;
1396 onObjectSelectionChanged();
1401 //=================================================================================
1402 // function : setFilters()
1403 // purpose : SLOT. Called when "Filter" button pressed.
1404 //=================================================================================
1405 void SMESHGUI_GroupDlg::setFilters()
1407 SMESH::ElementType aType = SMESH::ALL;
1410 case 0 : aType = SMESH::NODE; break;
1411 case 1 : aType = SMESH::EDGE; break;
1412 case 2 : aType = SMESH::FACE; break;
1413 case 3 : aType = SMESH::VOLUME; break;
1417 if ( myFilterDlg == 0 )
1419 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType );
1420 connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) );
1423 myFilterDlg->Init( aType );
1425 myFilterDlg->SetSelection();
1426 myFilterDlg->SetMesh( myMesh );
1427 myFilterDlg->SetSourceWg( myElements );
1429 myFilterDlg->show();
1432 //=================================================================================
1433 // function : onFilterAccepted()
1434 // purpose : SLOT. Called when Filter dlg closed with OK button.
1435 // Uncheck "Select submesh" and "Select group" checkboxes
1436 //=================================================================================
1437 void SMESHGUI_GroupDlg::onFilterAccepted()
1439 if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() )
1441 mySelectionMode = myTypeId;
1442 mySelectSubMesh->setChecked( false );
1443 mySelectGroup->setChecked( false );
1447 //=================================================================================
1448 // function : onAdd()
1450 //=================================================================================
1451 void SMESHGUI_GroupDlg::onAdd()
1453 SALOME_ListIO aList;
1454 mySelectionMgr->selectedObjects( aList );
1456 int aNbSel = aList.Extent();
1458 if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
1462 SMESH::ElementType aType = SMESH::ALL;
1465 aType = SMESH::NODE;
1466 mySelector->SetSelectionMode(NodeSelection);
1469 aType = SMESH::EDGE;
1470 mySelector->SetSelectionMode(EdgeSelection);
1473 aType = SMESH::FACE;
1474 mySelector->SetSelectionMode(FaceSelection);
1477 aType = SMESH::VOLUME;
1478 mySelector->SetSelectionMode(VolumeSelection);
1481 mySelector->SetSelectionMode(ActorSelection);
1484 if (myCurrentLineEdit == 0) {
1485 //if (aNbSel != 1) { myIsBusy = false; return; }
1486 QString aListStr = "";
1488 if (myTypeId == 0) {
1489 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1492 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1495 QStringList anElements = QStringList::split(" ", aListStr);
1496 QListBoxItem* anItem = 0;
1497 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1498 anItem = myElements->findItem(*it, Qt::ExactMatch);
1500 anItem = new QListBoxText(*it);
1501 myElements->insertItem(anItem);
1503 myElements->setSelected(anItem, true);
1506 } else if (myCurrentLineEdit == mySubMeshLine) {
1507 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1509 SALOME_ListIO aList;
1510 mySelectionMgr->selectedObjects( aList );
1512 SALOME_ListIteratorOfListIO anIt (aList);
1513 for (; anIt.More(); anIt.Next()) {
1514 SMESH::SMESH_subMesh_var aSubMesh =
1515 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1516 if (!aSubMesh->_is_nil()) {
1517 // check if mesh is the same
1518 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1520 SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType);
1521 int k = anElements->length();
1522 QListBoxItem* anItem = 0;
1523 for (int i = 0; i < k; i++) {
1524 QString aText = QString::number(anElements[i]);
1525 anItem = myElements->findItem(aText, Qt::ExactMatch);
1527 anItem = new QListBoxText(aText);
1528 myElements->insertItem(anItem);
1530 myElements->setSelected(anItem, true);
1533 catch (const SALOME::SALOME_Exception& ex) {
1534 SalomeApp_Tools::QtCatchCorbaException(ex);
1539 mySelectSubMesh->setChecked(false);
1541 onListSelectionChanged();
1543 } else if (myCurrentLineEdit == myGroupLine) {
1544 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1545 SALOME_ListIO aList;
1546 mySelectionMgr->selectedObjects( aList );
1548 SALOME_ListIteratorOfListIO anIt (aList);
1549 for (; anIt.More(); anIt.Next()) {
1550 SMESH::SMESH_Group_var aGroup =
1551 SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1552 if (!aGroup->_is_nil()) {
1553 // check if mesh is the same
1554 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1555 SMESH::long_array_var anElements = aGroup->GetListOfID();
1556 int k = anElements->length();
1557 QListBoxItem* anItem = 0;
1558 for (int i = 0; i < k; i++) {
1559 QString aText = QString::number(anElements[i]);
1560 anItem = myElements->findItem(aText, Qt::ExactMatch);
1562 anItem = new QListBoxText(aText);
1563 myElements->insertItem(anItem);
1565 myElements->setSelected(anItem, true);
1570 mySelectGroup->setChecked(false);
1572 onListSelectionChanged();
1574 } else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) {
1575 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1576 GEOM::GEOM_IGroupOperations_var aGroupOp =
1577 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1579 SMESH::ElementType aGroupType = SMESH::ALL;
1580 switch(aGroupOp->GetType(myGeomObjects[0])) {
1581 case 7: aGroupType = SMESH::NODE; break;
1582 case 6: aGroupType = SMESH::EDGE; break;
1583 case 4: aGroupType = SMESH::FACE; break;
1584 case 2: aGroupType = SMESH::VOLUME; break;
1585 default: myIsBusy = false; return;
1588 if (aGroupType == aType) {
1589 _PTR(SObject) aGroupSO =
1590 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
1591 aStudy->FindObjectID(myGeomObjects[0]->GetStudyEntry());
1593 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
1594 SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
1595 SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();;
1596 aBelongToGeom->SetGeom(myGeomObjects[0]);
1597 aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str());
1598 aBelongToGeom->SetElementType(aType);
1599 aFilter->SetPredicate(aBelongToGeom);
1601 SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh);
1603 int k = anElements->length();
1604 QListBoxItem* anItem = 0;
1605 for (int i = 0; i < k; i++) {
1606 QString aText = QString::number(anElements[i]);
1607 anItem = myElements->findItem(aText, Qt::ExactMatch);
1609 anItem = new QListBoxText(aText);
1610 myElements->insertItem(anItem);
1612 myElements->setSelected(anItem, true);
1616 //VSR: mySelectGeomGroup->setChecked(false);
1618 onListSelectionChanged();
1621 // mySelectionMgr->clearSelected();
1625 //=================================================================================
1626 // function : onRemove()
1628 //=================================================================================
1629 void SMESHGUI_GroupDlg::onRemove()
1632 if (myCurrentLineEdit == 0) {
1633 for (int i = myElements->count(); i > 0; i--) {
1634 if (myElements->isSelected(i-1)) {
1635 myElements->removeItem(i-1);
1639 SALOME_ListIO aList;
1640 mySelectionMgr->selectedObjects( aList );
1642 int aNbSel = aList.Extent();
1644 if (aNbSel == 0) { myIsBusy = false; return; }
1646 SMESH::ElementType aType = SMESH::ALL;
1648 case 0: aType = SMESH::NODE; break;
1649 case 1: aType = SMESH::EDGE; break;
1650 case 2: aType = SMESH::FACE; break;
1651 case 3: aType = SMESH::VOLUME; break;
1654 if (myCurrentLineEdit == mySubMeshLine) {
1655 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1656 SALOME_ListIO aList;
1657 mySelectionMgr->selectedObjects( aList );
1659 SALOME_ListIteratorOfListIO anIt (aList);
1660 for (; anIt.More(); anIt.Next()) {
1661 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1662 if (!aSubMesh->_is_nil()) {
1663 // check if mesh is the same
1664 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1665 if (aType == SMESH::NODE) {
1667 SMESH::long_array_var anElements = aSubMesh->GetNodesId();
1668 int k = anElements->length();
1669 QListBoxItem* anItem = 0;
1670 for (int i = 0; i < k; i++) {
1671 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1672 if (anItem) delete anItem;
1675 catch (const SALOME::SALOME_Exception& ex) {
1676 SalomeApp_Tools::QtCatchCorbaException(ex);
1681 SMESH::long_array_var anElements = aSubMesh->GetElementsId();
1682 int k = anElements->length();
1683 QListBoxItem* anItem = 0;
1684 for (int i = 0; i < k; i++) {
1685 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1686 if (anItem) delete anItem;
1689 catch (const SALOME::SALOME_Exception& ex) {
1690 SalomeApp_Tools::QtCatchCorbaException(ex);
1697 else if (myCurrentLineEdit == myGroupLine) {
1698 Standard_Boolean aRes;
1699 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1700 SALOME_ListIO aList;
1701 mySelectionMgr->selectedObjects( aList );
1703 SALOME_ListIteratorOfListIO anIt (aList);
1704 for (; anIt.More(); anIt.Next()) {
1705 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1706 if (aRes && !aGroup->_is_nil()) {
1707 // check if mesh is the same
1708 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1709 SMESH::long_array_var anElements = aGroup->GetListOfID();
1710 int k = anElements->length();
1711 QListBoxItem* anItem = 0;
1712 for (int i = 0; i < k; i++) {
1713 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1714 if (anItem) delete anItem;
1725 //=================================================================================
1726 // function : onSort()
1728 //=================================================================================
1729 void SMESHGUI_GroupDlg::onSort()
1731 // PAL5412: sorts items in ascending by "string" value
1732 // myElements->sort(true);
1733 // myElements->update();
1734 int i, k = myElements->count();
1737 QStringList aSelected;
1738 std::vector<int> anArray(k);
1739 // QMemArray<int> anArray(k);
1740 QListBoxItem* anItem;
1742 for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) {
1743 anArray[i] = anItem->text().toInt();
1744 if (anItem->isSelected())
1745 aSelected.append(anItem->text());
1747 // sort & update list
1748 std::sort(anArray.begin(), anArray.end());
1750 myElements->clear();
1751 for (i = 0; i < k; i++) {
1752 myElements->insertItem(QString::number(anArray[i]));
1754 for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) {
1755 anItem = myElements->findItem(*it, Qt::ExactMatch);
1756 if (anItem) myElements->setSelected(anItem, true);
1762 //=================================================================================
1763 // function : closeEvent()
1765 //=================================================================================
1766 void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
1771 //=================================================================================
1772 // function : SMESHGUI_GroupDlg::onClose
1773 // purpose : SLOT called when "Close" button pressed. Close dialog
1774 //=================================================================================
1775 void SMESHGUI_GroupDlg::onClose()
1777 if (SMESH::GetCurrentVtkView()) {
1778 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
1779 SMESH::SetPointRepresentation(false);
1780 SMESH::SetPickable();
1781 restoreShowEntityMode();
1784 mySelectionMgr->clearSelected();
1785 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1786 aViewWindow->SetSelectionMode(ActorSelection);
1787 mySelectionMgr->clearFilters();
1788 mySMESHGUI->ResetState();
1793 //=================================================================================
1794 // function : onHelp()
1796 //=================================================================================
1797 void SMESHGUI_GroupDlg::onHelp()
1799 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1801 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""),
1806 platform = "winapplication";
1808 platform = "application";
1810 SUIT_MessageBox::warn1
1811 (0, QObject::tr("WRN_WARNING"),
1812 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1813 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
1814 QObject::tr("BUT_OK"));
1818 //=================================================================================
1819 // function : SMESHGUI_GroupDlg::onDeactivate
1820 // purpose : SLOT called when dialog must be deativated
1821 //=================================================================================
1822 void SMESHGUI_GroupDlg::onDeactivate()
1824 mySMESHGUI->ResetState();
1828 //=================================================================================
1829 // function : SMESHGUI_GroupDlg::enterEvent
1830 // purpose : Event filter
1831 //=================================================================================
1832 void SMESHGUI_GroupDlg::enterEvent (QEvent*)
1835 mySMESHGUI->EmitSignalDeactivateDialog();
1837 mySelectionMode = -1;
1838 setSelectionMode(myTypeId);
1839 //mySMESHGUI->SetActiveDialogBox((QDialog*)this);
1840 mySMESHGUI->SetActiveDialogBox(this);
1841 mySMESHGUI->SetState(800);
1845 //=================================================================================
1846 // function : hideEvent
1847 // purpose : caused by ESC key
1848 //=================================================================================
1849 void SMESHGUI_GroupDlg::hideEvent (QHideEvent*)
1851 if (!isMinimized() && !myIsBusy)
1855 //=================================================================================
1856 // function : keyPressEvent()
1858 //=================================================================================
1859 void SMESHGUI_GroupDlg::keyPressEvent( QKeyEvent* e )
1861 QDialog::keyPressEvent( e );
1862 if ( e->isAccepted() )
1865 if ( e->key() == Key_F1 )
1872 //================================================================================
1874 * \brief Enable showing of the popup when Geometry selection btn is clicked
1875 * \param enable - true to enable
1877 //================================================================================
1879 enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
1881 void SMESHGUI_GroupDlg::updateGeomPopup()
1883 bool enable = false;
1885 if ( !myMesh->_is_nil() )
1886 enable = myMesh->NbEdges() > 0;
1888 if ( myGeomGroupBtn )
1890 disconnect( myGeomGroupBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
1892 if ( !myGeomPopup ) {
1893 myGeomPopup = new QPopupMenu();
1894 myGeomPopup->insertItem( tr("DIRECT_GEOM_SELECTION"), DIRECT_GEOM_INDEX );
1895 myGeomPopup->insertItem( tr("GEOM_BY_MESH_ELEM_SELECTION"), GEOM_BY_MESH_INDEX );
1896 connect( myGeomPopup, SIGNAL( activated( int ) ), SLOT( onGeomPopup( int ) ) );
1898 connect( myGeomGroupBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
1904 //=================================================================================
1905 // function : onGeomSelectionButton()
1907 //=================================================================================
1908 void SMESHGUI_GroupDlg::onGeomSelectionButton(bool isBtnOn)
1910 if ( myGeomPopup && isBtnOn )
1912 myCurrentLineEdit = myGeomGroupLine;
1913 int id = myGeomPopup->exec( QCursor::pos() );
1914 if (id == DIRECT_GEOM_INDEX || id == -1)
1915 setSelectionMode(7);
1919 myCurrentLineEdit = 0;
1920 setSelectionMode(8);
1924 //=================================================================================
1925 // function : onGeomPopup()
1927 //=================================================================================
1928 void SMESHGUI_GroupDlg::onGeomPopup( int index )
1930 if ( index == GEOM_BY_MESH_INDEX )
1932 mySelectionMode = -1;
1933 if ( !myShapeByMeshOp ) {
1934 myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp(true);
1935 connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
1936 SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
1937 connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
1938 SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
1940 // set mesh object to SMESHGUI_ShapeByMeshOp and start it
1941 if ( !myMesh->_is_nil() ) {
1943 hide(); // stop processing selection
1945 myShapeByMeshOp->setModule( mySMESHGUI );
1946 myShapeByMeshOp->setStudy( 0 ); // it's really necessary
1947 myShapeByMeshOp->SetMesh( myMesh );
1948 myShapeByMeshOp->start();
1953 //================================================================================
1955 * \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg
1957 //================================================================================
1959 void SMESHGUI_GroupDlg::onPublishShapeByMeshDlg(SUIT_Operation* op)
1961 if ( myShapeByMeshOp == op ) {
1962 mySMESHGUI->getApp()->updateObjectBrowser();
1964 // Select a found geometry object
1965 GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();
1966 if ( !aGeomVar->_is_nil() )
1968 QString ID = aGeomVar->GetStudyEntry();
1969 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1970 if ( _PTR(SObject) aGeomSO = aStudy->FindObjectID( ID.latin1() )) {
1971 SALOME_ListIO anIOList;
1972 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
1973 ( aGeomSO->GetID().c_str(), "SMESH", aGeomSO->GetName().c_str() );
1974 anIOList.Append( anIO );
1975 mySelectionMgr->setSelectedObjects( anIOList, false );
1976 onObjectSelectionChanged();
1982 //================================================================================
1984 * \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
1986 //================================================================================
1988 void SMESHGUI_GroupDlg::onCloseShapeByMeshDlg(SUIT_Operation* op)
1990 if ( myShapeByMeshOp == op )
1993 setSelectionMode(7);
1997 //=================================================================================
1998 // function : setGroupColor()
2000 //=================================================================================
2001 void SMESHGUI_GroupDlg::setGroupColor( const SALOMEDS::Color& theColor )
2003 QColor aQColor( (int)( theColor.R * 255.0 ),
2004 (int)( theColor.G * 255.0 ),
2005 (int)( theColor.B * 255.0 ) );
2006 setGroupQColor( aQColor );
2009 //=================================================================================
2010 // function : getGroupColor()
2012 //=================================================================================
2013 SALOMEDS::Color SMESHGUI_GroupDlg::getGroupColor() const
2015 QColor aQColor = getGroupQColor();
2017 SALOMEDS::Color aColor;
2018 aColor.R = (float)aQColor.red() / 255.0;
2019 aColor.G = (float)aQColor.green() / 255.0;
2020 aColor.B = (float)aQColor.blue() / 255.0;
2025 //=================================================================================
2026 // function : setGroupQColor()
2028 //=================================================================================
2029 void SMESHGUI_GroupDlg::setGroupQColor( const QColor& theColor )
2031 if ( theColor.isValid() )
2033 QPalette pal = myColorBtn->palette();
2034 pal.setColor(QColorGroup::Button, theColor);
2035 myColorBtn->setPalette(pal);
2039 //=================================================================================
2040 // function : getGroupQColor()
2042 //=================================================================================
2043 QColor SMESHGUI_GroupDlg::getGroupQColor() const
2045 QColor aColor = myColorBtn->palette().active().button();
2049 //=================================================================================
2050 // function : setDefaultGroupColor()
2052 //=================================================================================
2053 void SMESHGUI_GroupDlg::setDefaultGroupColor()
2055 if ( myMesh->_is_nil() )
2058 bool isAutoColor = myMesh->GetAutoColor();
2063 int r = 0, g = 0, b = 0;
2064 SMESH::GetColor( "SMESH", "fill_color", r, g, b, QColor( 0, 170, 255 ) );
2065 aQColor.setRgb( r, g, b );
2069 SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
2071 QValueList<SALOMEDS::Color> aReservedColors;
2072 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
2074 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
2075 SALOMEDS::Color aReservedColor = aGroupObject->GetColor();
2076 aReservedColors.append( aReservedColor );
2079 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
2080 aQColor.setRgb( (int)( aColor.R * 255.0 ),
2081 (int)( aColor.G * 255.0 ),
2082 (int)( aColor.B * 255.0 ) );
2086 setGroupQColor( aQColor );
2089 //=================================================================================
2090 // function : SetAppropriateActor()
2091 // purpose : Find more appropriate of visible actors, set it to myActor, allow picking
2092 // NPAL19389: create a group with a selection in another group.
2093 // if mesh actor is not visible - find any first visible group or submesh
2094 //=================================================================================
2095 bool SMESHGUI_GroupDlg::SetAppropriateActor()
2097 bool isActor = false;
2099 if (myMesh->_is_nil()) return false;
2101 SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
2104 myActor = SMESH::FindActorByObject(myMesh);
2105 if (myActor && myActor->hasIO())
2108 if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
2112 // try current group actor
2114 if (!myGroup->_is_nil()) {
2115 myActor = SMESH::FindActorByObject(myGroup);
2116 if (myActor && myActor->hasIO())
2119 if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
2125 // try current group on geometry actor
2127 if (!myGroupOnGeom->_is_nil()) {
2128 myActor = SMESH::FindActorByObject(myGroupOnGeom);
2129 if (myActor && myActor->hasIO())
2132 if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
2138 // try any visible actor of group or submesh of current mesh
2139 if (!isActor && aViewWindow) {
2141 _PTR(SObject) aSObject = SMESH::FindSObject(myMesh);
2143 CORBA::String_var meshEntry = aSObject->GetID().c_str();
2144 int len = strlen(meshEntry);
2146 // iterate on all actors in current view window, search for
2147 // any visible actor, that belongs to group or submesh of current mesh
2148 vtkActorCollection *aCollection = aViewWindow->getRenderer()->GetActors();
2149 aCollection->InitTraversal();
2150 for (vtkActor *anAct = aCollection->GetNextActor();
2152 anAct = aCollection->GetNextActor())
2154 SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct);
2155 if (anActor && anActor->hasIO()) {
2156 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
2157 if (aViewWindow->isVisible(anIO)) {
2158 if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0) {
2169 SMESH::SetPickable(myActor);
2174 //=======================================================================
2175 //function : setShowEntityMode
2176 //purpose : make shown only entity corresponding to my type
2177 //=======================================================================
2178 void SMESHGUI_GroupDlg::setShowEntityMode()
2180 if ( !myMesh->_is_nil() ) {
2181 if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) ) {
2182 if (!myStoredShownEntity)
2183 myStoredShownEntity = actor->GetEntityMode();
2184 switch ( myTypeId ) {
2185 case 0: restoreShowEntityMode(); break;
2186 case 1: actor->SetEntityMode( SMESH_Actor::eEdges ); break;
2187 case 2: actor->SetEntityMode( SMESH_Actor::eFaces ); break;
2188 case 3: actor->SetEntityMode( SMESH_Actor::eVolumes ); break;
2194 //=======================================================================
2195 //function : restoreShowEntityMode
2196 //purpose : restore ShowEntity mode of myActor
2197 //=======================================================================
2198 void SMESHGUI_GroupDlg::restoreShowEntityMode()
2200 if ( myStoredShownEntity && !myMesh->_is_nil() ) {
2201 if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) ) {
2202 actor->SetEntityMode(myStoredShownEntity);
2205 myStoredShownEntity = 0;