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 "VTKViewer_Algorithm.h"
65 #include "utilities.h"
68 #include <vtkRenderer.h>
69 #include <vtkActorCollection.h>
72 #include <TColStd_MapOfInteger.hxx>
75 #include <qbuttongroup.h>
77 #include <qgroupbox.h>
80 #include <qlineedit.h>
81 #include <qpushbutton.h>
82 #include <qtoolbutton.h>
83 #include <qradiobutton.h>
84 #include <qcheckbox.h>
89 #include <qmemarray.h>
90 #include <qwidgetstack.h>
91 #include <qcolordialog.h>
93 #include <QtxIntSpinBox.h>
102 //=================================================================================
103 // function : SMESHGUI_GroupDlg()
105 //=================================================================================
106 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
107 SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl)
108 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
109 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
110 mySMESHGUI( theModule ),
111 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
112 mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
114 myNameChanged(false),
117 if (!name) setName("SMESHGUI_GroupDlg");
119 if (!theMesh->_is_nil())
122 mySelectSubMesh->setEnabled(false);
123 mySelectGroup->setEnabled(false);
124 myGeomGroupBtn->setEnabled(false);
125 myGeomGroupLine->setEnabled(false);
129 //=================================================================================
130 // function : SMESHGUI_GroupDlg()
132 //=================================================================================
133 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
134 SMESH::SMESH_GroupBase_ptr theGroup, bool modal, WFlags fl)
135 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
136 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
137 mySMESHGUI( theModule ),
138 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
139 mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
143 if (!name) setName("SMESHGUI_GroupDlg");
146 if (!theGroup->_is_nil())
149 mySelectSubMesh->setEnabled(false);
150 mySelectGroup->setEnabled(false);
152 myCurrentLineEdit = myMeshGroupLine;
157 //=================================================================================
158 // function : SMESHGUI_GroupDlg()
160 //=================================================================================
161 void SMESHGUI_GroupDlg::initDialog(bool create)
165 myCurrentLineEdit = 0;
169 myGeomObjects = new GEOM::ListOfGO();
170 myGeomObjects->length(0);
172 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
175 setCaption(tr("SMESH_CREATE_GROUP_TITLE"));
176 myHelpFileName = "creating_groups_page.html";
179 setCaption(tr("SMESH_EDIT_GROUP_TITLE"));
180 myHelpFileName = "editing_groups_page.html";
183 setSizeGripEnabled(TRUE);
185 QGridLayout* aMainLayout = new QGridLayout(this, 7, 3, 11, 6);
187 /***************************************************************/
188 QLabel* meshGroupLab = new QLabel(this, "mesh/group label");
190 meshGroupLab->setText(tr("SMESH_MESH"));
192 meshGroupLab->setText(tr("SMESH_GROUP"));
193 myMeshGroupBtn = new QPushButton(this, "mesh/group button");
194 myMeshGroupBtn->setPixmap(image0);
195 myMeshGroupLine = new QLineEdit(this, "mesh/group line");
196 myMeshGroupLine->setReadOnly(true);
198 /***************************************************************/
199 myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types");
200 myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE"));
201 myTypeGroup->setExclusive(true);
204 types.append(tr("MESH_NODE"));
205 types.append(tr("SMESH_EDGE"));
206 types.append(tr("SMESH_FACE"));
207 types.append(tr("SMESH_VOLUME"));
209 for (int i = 0; i < types.count(); i++) {
210 rb = new QRadioButton(types[i], myTypeGroup);
212 myTypeGroup->setEnabled(create);
215 /***************************************************************/
216 QLabel* aName = new QLabel(this, "name label");
217 aName->setText(tr("SMESH_NAME"));
218 aName->setMinimumSize(50,0);
219 myName = new QLineEdit(this, "name");
221 /***************************************************************/
222 myGrpTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Type of group");
223 myGrpTypeGroup->setTitle(tr("SMESH_GROUP_TYPE"));
224 myGrpTypeGroup->setExclusive(true);
225 QRadioButton* rb1 = new QRadioButton( tr("SMESH_GROUP_STANDALONE"), myGrpTypeGroup);
226 QRadioButton* rb2 = new QRadioButton( tr("SMESH_GROUP_GEOMETRY"), myGrpTypeGroup);
227 myGrpTypeGroup->setEnabled(create);
230 /***************************************************************/
231 myWGStack = new QWidgetStack( this, "widget stack");
232 QWidget* wg1 = new QFrame( myWGStack, "first widget" );
233 QWidget* wg2 = new QFrame( myWGStack, "second widget" );
235 /***************************************************************/
236 QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, wg1, "content box");
237 aContentBox->setTitle(tr("SMESH_CONTENT"));
238 QFrame* aContent = new QFrame(aContentBox, "content");
239 QGridLayout* aLayout = new QGridLayout(aContent, 7, 4);
240 aLayout->setSpacing(6);
241 aLayout->setAutoAdd(false);
243 QLabel* aLabel = new QLabel(aContent, "elements label");
244 aLabel->setText(tr("SMESH_ID_ELEMENTS"));
245 myElements = new QListBox(aContent, "elements list");
246 myElements->setSelectionMode(QListBox::Extended);
248 myFilter = new QPushButton(aContent, "filter");
249 myFilter->setText(tr("SMESH_BUT_FILTER"));
250 QPushButton* aAddBtn = new QPushButton(aContent, "add");
251 aAddBtn->setText(tr("SMESH_BUT_ADD"));
252 QPushButton* aRemoveBtn = new QPushButton(aContent, "remove");
253 aRemoveBtn->setText(tr("SMESH_BUT_REMOVE"));
254 QPushButton* aSortBtn = new QPushButton(aContent, "sort");
255 aSortBtn->setText(tr("SMESH_BUT_SORT"));
257 aLayout->addWidget(aLabel, 0, 0);
258 aLayout->addMultiCellWidget(myElements, 1, 6, 0, 0);
259 aLayout->addWidget(myFilter, 1, 2);
260 aLayout->addWidget(aAddBtn, 3, 2);
261 aLayout->addWidget(aRemoveBtn, 4, 2);
262 aLayout->addWidget(aSortBtn, 6, 2);
264 aLayout->setColStretch(0, 1);
265 aLayout->addColSpacing(1, 20);
266 aLayout->addColSpacing(3, 20);
267 aLayout->setRowStretch(2, 1);
268 aLayout->setRowStretch(5, 1);
270 /***************************************************************/
271 QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, wg1, "select box");
272 aSelectBox->setTitle(tr("SMESH_SELECT_FROM"));
274 mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox");
275 mySelectSubMesh->setText(tr("SMESH_SUBMESH"));
276 mySelectSubMesh->setMinimumSize(50, 0);
277 mySubMeshBtn = new QPushButton(aSelectBox, "submesh button");
278 mySubMeshBtn->setText("");
279 mySubMeshBtn->setPixmap(image0);
280 mySubMeshLine = new QLineEdit(aSelectBox, "submesh line");
281 mySubMeshLine->setReadOnly(true);
282 onSelectSubMesh(false);
284 mySelectGroup = new QCheckBox(aSelectBox, "group checkbox");
285 mySelectGroup->setText(tr("SMESH_GROUP"));
286 mySelectGroup->setMinimumSize(50, 0);
287 myGroupBtn = new QPushButton(aSelectBox, "group button");
288 myGroupBtn->setText("");
289 myGroupBtn->setPixmap(image0);
290 myGroupLine = new QLineEdit(aSelectBox, "group line");
291 myGroupLine->setReadOnly(true);
292 onSelectGroup(false);
294 /***************************************************************/
295 QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 );
296 wg1Layout->addWidget(aContentBox, 0, 0);
297 wg1Layout->addWidget(aSelectBox, 1, 0);
298 wg1Layout->setRowStretch(2, 5);
300 /***************************************************************/
301 QLabel* geomObject = new QLabel(wg2, "geometry object label");
302 geomObject->setText(tr("SMESH_OBJECT_GEOM"));
303 myGeomGroupBtn = new QToolButton(wg2, "geometry group button");
304 myGeomGroupBtn->setIconSet( QIconSet(image0) );
305 myGeomGroupBtn->setToggleButton(true);
306 myGeomGroupLine = new QLineEdit(wg2, "geometry group line");
307 myGeomGroupLine->setReadOnly(true); //VSR ???
308 onSelectGeomGroup(false);
312 myGeomGroupBtn->setEnabled(false);
313 myGeomGroupLine->setEnabled(false);
316 /***************************************************************/
317 QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 );
318 wg2Layout->addWidget(geomObject, 0, 0);
319 wg2Layout->addWidget(myGeomGroupBtn, 0, 1);
320 wg2Layout->addWidget(myGeomGroupLine,0, 2);
321 wg2Layout->setRowStretch(1, 5);
323 /***************************************************************/
324 QVBoxLayout* dumb = new QVBoxLayout(myWGStack);
325 dumb->addWidget(wg1);
326 dumb->addWidget(wg2);
327 myWGStack->addWidget( wg1, myGrpTypeGroup->id(rb1) );
328 myWGStack->addWidget( wg2, myGrpTypeGroup->id(rb2) );
330 /***************************************************************/
331 QGroupBox* aColorBox = new QGroupBox(2, Qt::Horizontal, this, "color box");
332 aColorBox->setTitle(tr("SMESH_SET_COLOR"));
334 new QLabel( tr("SMESH_CHECK_COLOR"), aColorBox, "color label" );
335 myColorBtn = new QPushButton(aColorBox, "color button");
336 myColorBtn->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
338 /***************************************************************/
340 QFrame* aButtons = new QFrame(this, "button box");
341 aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken);
342 QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6);
343 aBtnLayout->setAutoAdd(false);
345 QPushButton* aApplyBtn = new QPushButton(aButtons, "apply");
346 aApplyBtn->setText(tr("SMESH_BUT_APPLY"));
347 aApplyBtn->setAutoDefault(true);
348 QPushButton* aCloseBtn = new QPushButton(aButtons, "close");
349 aCloseBtn->setText(tr("SMESH_BUT_CLOSE"));
350 aCloseBtn->setAutoDefault(true);
351 QPushButton* aOKBtn = new QPushButton(aButtons, "ok");
352 aOKBtn->setText(tr("SMESH_BUT_APPLY_AND_CLOSE"));
353 aOKBtn->setAutoDefault(true);
354 aOKBtn->setDefault(true);
355 QPushButton* aHelpBtn = new QPushButton(aButtons, "help");
356 aHelpBtn->setText(tr("SMESH_BUT_HELP"));
357 aHelpBtn->setAutoDefault(true);
359 aBtnLayout->addWidget(aOKBtn);
360 aBtnLayout->addWidget(aApplyBtn);
361 aBtnLayout->addStretch();
362 aBtnLayout->addWidget(aCloseBtn);
363 aBtnLayout->addWidget(aHelpBtn);
365 /***************************************************************/
366 aMainLayout->addWidget(meshGroupLab, 0, 0);
367 aMainLayout->addWidget(myMeshGroupBtn, 0, 1);
368 aMainLayout->addWidget(myMeshGroupLine, 0, 2);
369 aMainLayout->addMultiCellWidget(myTypeGroup, 1, 1, 0, 2);
370 aMainLayout->addWidget(aName, 2, 0);
371 aMainLayout->addWidget(myName, 2, 2);
372 aMainLayout->addMultiCellWidget(myGrpTypeGroup, 3, 3, 0, 2);
373 aMainLayout->addMultiCellWidget(myWGStack, 4, 4, 0, 2);
374 aMainLayout->setRowStretch( 5, 5 );
375 aMainLayout->addMultiCellWidget(aColorBox, 6, 6, 0, 2);
376 aMainLayout->addMultiCellWidget(aButtons, 7, 7, 0, 2);
378 /* signals and slots connections */
379 connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
381 connect(myGrpTypeGroup, SIGNAL(clicked(int)), this, SLOT(onGrpTypeChanged(int)));
383 connect(myTypeGroup, SIGNAL(clicked(int)), this, SLOT(onTypeChanged(int)));
385 connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
386 connect(myElements, SIGNAL(selectionChanged()), this, SLOT(onListSelectionChanged()));
388 connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters()));
389 connect(aAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
390 connect(aRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
391 connect(aSortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
393 connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool)));
394 connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool)));
395 connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
396 connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
397 connect(myGeomGroupBtn, SIGNAL(toggled(bool)), this, SLOT(onGeomSelectionButton(bool)));
398 connect(myColorBtn, SIGNAL(clicked()), this, SLOT(onSelectColor()));
400 connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
401 connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
402 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
403 connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
406 mySMESHGUI->SetActiveDialogBox(this);
407 mySMESHGUI->SetState(800);
409 mySelectionMode = -1;
410 myMeshFilter = new SMESH_TypeFilter(MESH);
411 mySubMeshFilter = new SMESH_TypeFilter(SUBMESH);
412 myGroupFilter = new SMESH_TypeFilter(GROUP);
413 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
414 myGeomFilter = new GEOM_SelectionFilter( aStudy, true );
416 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
417 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose()));
418 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
420 myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!!
421 onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!!
423 if (myMesh->_is_nil() )
424 myTypeGroup->setButton(0);
427 //myName->setText(GetDefaultName(tr("SMESH_GROUP")));
430 //=================================================================================
431 // function : ~SMESHGUI_GroupDlg()
432 // purpose : Destroys the object and frees any allocated resources
433 //=================================================================================
434 SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg()
436 // no need to delete child widgets, Qt does it all for us
437 if ( myFilterDlg != 0 )
439 myFilterDlg->reparent( 0, QPoint() );
444 //=================================================================================
445 // function : GetDefaultName()
446 // purpose : Get the Group Name if Create new Group
447 //=================================================================================
448 QString SMESHGUI_GroupDlg::GetDefaultName(const QString& theOperation)
452 // collect all object names of SMESH component
453 SalomeApp_Study* appStudy =
454 dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
455 if ( !appStudy ) return aName;
456 _PTR(Study) aStudy = appStudy->studyDS();
458 std::set<std::string> aSet;
459 _PTR(SComponent) aMeshCompo (aStudy->FindComponent("SMESH"));
461 _PTR(ChildIterator) it (aStudy->NewChildIterator(aMeshCompo));
463 for (it->InitEx(true); it->More(); it->Next()) {
465 aSet.insert(obj->GetName());
469 // build a unique name
471 bool isUnique = false;
473 aName = theOperation + "_" + QString::number(++aNumber);
474 isUnique = (aSet.count(aName.latin1()) == 0);
480 //=================================================================================
483 //=================================================================================
484 void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh)
486 mySelectionMgr->installFilter(myMeshFilter);
488 /* init data from current selection */
489 restoreShowEntityMode();
490 myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh);
492 myGroup = SMESH::SMESH_Group::_nil();
493 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
495 // NPAL19389: create a group with a selection in another group
496 // set actor of myMesh, if it is visible, else try
497 // any visible actor of group or submesh of myMesh
498 SetAppropriateActor();
500 setDefaultGroupColor();
503 mySelectionMgr->selectedObjects( aList );
504 if ( !aList.IsEmpty() )
506 QString aName = aList.First()->getName();
507 myMeshGroupLine->setText(aName);
508 myMeshGroupLine->home( false );
511 myCurrentLineEdit = 0;
513 myTypeGroup->setButton(0);
517 //=================================================================================
520 //=================================================================================
521 void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
523 restoreShowEntityMode();
524 myMesh = theGroup->GetMesh();
527 myNameChanged = true;
528 myName->blockSignals(true);
529 myName->setText(theGroup->GetName());
530 myName->blockSignals(false);
533 SALOMEDS::Color aColor = theGroup->GetColor();
534 setGroupColor( aColor );
536 myMeshGroupLine->setText(theGroup->GetName());
539 switch(theGroup->GetType()) {
540 case SMESH::NODE: aType= 0; break;
541 case SMESH::EDGE: aType = 1; break;
542 case SMESH::FACE: aType = 2; break;
543 case SMESH::VOLUME: aType = 3; break;
545 myTypeGroup->setButton(aType);
547 myGroup = SMESH::SMESH_Group::_narrow( theGroup );
549 if (!myGroup->_is_nil())
551 // NPAL19389: create a group with a selection in another group
552 // set actor of myMesh, if it is visible, else set
553 // actor of myGroup, if it is visible, else try
554 // any visible actor of group or submesh of myMesh
555 // commented, because an attempt to set selection on not displayed cells leads to error
556 //SetAppropriateActor();
557 myActor = SMESH::FindActorByObject(myMesh);
559 myActor = SMESH::FindActorByObject(myGroup);
560 SMESH::SetPickable(myActor);
562 myGrpTypeGroup->setButton(0);
565 myCurrentLineEdit = 0;
567 setSelectionMode(aType);
570 setShowEntityMode(); // depends on myTypeId
573 if (!myGroup->IsEmpty()) {
574 SMESH::long_array_var anElements = myGroup->GetListOfID();
575 int k = anElements->length();
576 for (int i = 0; i < k; i++) {
577 myIdList.append(anElements[i]);
578 myElements->insertItem(QString::number(anElements[i]));
580 myElements->selectAll(true);
585 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
587 if ( !myGroupOnGeom->_is_nil() )
589 // NPAL19389: create a group with a selection in another group
590 // set actor of myMesh, if it is visible, else set
591 // actor of myGroupOnGeom, if it is visible, else try
592 // any visible actor of group or submesh of myMesh
593 // commented, because an attempt to set selection on not displayed cells leads to error
594 //SetAppropriateActor();
595 myActor = SMESH::FindActorByObject(myMesh);
597 myActor = SMESH::FindActorByObject(myGroupOnGeom);
598 SMESH::SetPickable(myActor);
600 myGrpTypeGroup->setButton(1);
603 QString aShapeName("");
604 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
605 GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
606 if (!aGroupShape->_is_nil())
608 _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
609 aShapeName = aGroupShapeSO->GetName().c_str();
611 myGeomGroupLine->setText( aShapeName );
612 myNameChanged = true;
613 myName->blockSignals(true);
614 myName->setText(theGroup->GetName());
615 myName->blockSignals(false);
620 //=================================================================================
621 // function : updateButtons()
623 //=================================================================================
624 void SMESHGUI_GroupDlg::updateButtons()
626 bool enable = !myName->text().stripWhiteSpace().isEmpty();
628 if (myGrpTypeId == 0) {
629 enable = enable && myElements->count() > 0;
630 enable = enable && (!myGroup->_is_nil() || !myMesh->_is_nil());
632 else if (myGrpTypeId == 1) {
633 if (CORBA::is_nil(myGroupOnGeom)) { // creation mode
634 enable = enable && myGeomObjects->length() > 0 && !myMesh->_is_nil();
639 aBtn = (QPushButton*) child("ok", "QPushButton");
640 if (aBtn) aBtn->setEnabled(enable);
641 aBtn = (QPushButton*) child("apply", "QPushButton");
642 if (aBtn) aBtn->setEnabled(enable);
645 //=================================================================================
646 // function : onNameChanged()
648 //=================================================================================
649 void SMESHGUI_GroupDlg::onNameChanged (const QString& text)
651 myOldName = myName->text();
653 QString tmp = myName->text();
654 tmp.stripWhiteSpace();
656 myNameChanged = true;
658 myNameChanged = false;
661 //=================================================================================
662 // function : onTypeChanged()
663 // purpose : Group elements type radio button management
664 //=================================================================================
665 void SMESHGUI_GroupDlg::onTypeChanged (int id)
667 if (myTypeId != id) {
669 if (myCurrentLineEdit == 0)
670 setSelectionMode(id);
676 //=================================================================================
677 // function : onGrpTypeChanged()
678 // purpose : Group type radio button management
679 //=================================================================================
680 void SMESHGUI_GroupDlg::onGrpTypeChanged (int id)
682 if (myGrpTypeId != id) {
683 myWGStack->raiseWidget( id );
684 myName->blockSignals(true);
685 myName->setText(myOldName);
686 myName->blockSignals(false);
687 onSelectGeomGroup(id == 1);
692 //=================================================================================
693 // function : onSelectColor()
695 //=================================================================================
696 void SMESHGUI_GroupDlg::onSelectColor()
698 QColor color = getGroupQColor();
699 color = QColorDialog::getColor( color );
700 setGroupQColor( color );
705 //=================================================================================
706 // function : setSelectionMode()
707 // purpose : Radio button management
708 //=================================================================================
709 void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
712 if (myMesh->_is_nil())
714 if (mySelectionMode != theMode) {
715 // [PAL10408] mySelectionMgr->clearSelected();
716 mySelectionMgr->clearFilters();
718 myActor->SetPointRepresentation(false);
720 SMESH::SetPointRepresentation(false);
725 myActor->SetPointRepresentation(true);
727 SMESH::SetPointRepresentation(true);
728 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
729 aViewWindow->SetSelectionMode(NodeSelection);
732 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
733 aViewWindow->SetSelectionMode(EdgeSelection);
736 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
737 aViewWindow->SetSelectionMode(FaceSelection);
740 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
741 aViewWindow->SetSelectionMode(VolumeSelection);
745 mySelectionMgr->installFilter(mySubMeshFilter);
746 else if (theMode == 5)
747 mySelectionMgr->installFilter(myGroupFilter);
748 else if (theMode == 6)
749 mySelectionMgr->installFilter(myMeshFilter);
750 else if (theMode == 7)
751 mySelectionMgr->installFilter(myGeomFilter);
753 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
754 aViewWindow->SetSelectionMode(ActorSelection);
756 mySelectionMode = theMode;
760 //=================================================================================
761 // function : onApply()
763 //=================================================================================
764 bool SMESHGUI_GroupDlg::onApply()
766 if (mySMESHGUI->isActiveStudyLocked())
769 if (myName->text().stripWhiteSpace().isEmpty())
772 if (myGrpTypeId == 0) { // on mesh elements
773 if (!myElements->count())
776 mySelectionMgr->clearSelected();
778 if (myGroup->_is_nil()) { // creation
779 if (myMesh->_is_nil())
782 SMESH::ElementType aType = SMESH::ALL;
784 case 0: aType = SMESH::NODE; break;
785 case 1: aType = SMESH::EDGE; break;
786 case 2: aType = SMESH::FACE; break;
787 case 3: aType = SMESH::VOLUME; break;
790 SMESH::long_array_var anIdList = new SMESH::long_array;
791 int i, k = myElements->count();
793 QListBoxItem* anItem;
794 for (i = 0, anItem = myElements->firstItem(); anItem != 0; i++, anItem = anItem->next()) {
795 anIdList[i] = anItem->text().toInt();
798 myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
799 myGroup->Add(anIdList.inout());
801 SALOMEDS::Color aColor = getGroupColor();
802 myGroup->SetColor(aColor);
804 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
806 //SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
807 SMESH::setFileType ( aMeshGroupSO, "COULEURGROUP" );
809 /* init for next operation */
812 myGroup = SMESH::SMESH_Group::_nil();
815 myGroup->SetName(myName->text());
817 SALOMEDS::Color aColor = getGroupColor();
818 myGroup->SetColor(aColor);
820 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
822 if (SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) {
823 switch ( myTypeId ) {
824 case 0: anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
825 case 1: anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
827 case 3: anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B ); break;
831 QValueList<int> aAddList;
832 QValueList<int>::iterator anIt;
833 QListBoxItem* anItem;
835 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
836 int anId = anItem->text().toInt();
837 if ((anIt = myIdList.find(anId)) == myIdList.end())
838 aAddList.append(anId);
840 myIdList.remove(anIt);
842 if (!aAddList.empty()) {
843 SMESH::long_array_var anIdList = new SMESH::long_array;
844 anIdList->length(aAddList.count());
846 for (i = 0, anIt = aAddList.begin(); anIt != aAddList.end(); anIt++, i++)
848 myGroup->Add(anIdList.inout());
850 if (!myIdList.empty()) {
851 SMESH::long_array_var anIdList = new SMESH::long_array;
852 anIdList->length(myIdList.count());
854 for (i = 0, anIt = myIdList.begin(); anIt != myIdList.end(); anIt++, i++)
856 myGroup->Remove(anIdList.inout());
858 /* init for next operation */
860 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next())
861 myIdList.append(anItem->text().toInt());
864 mySMESHGUI->updateObjBrowser(true);
865 SMESH::UpdateView(); // asv: fix of BUG PAL5515
866 mySelectionMgr->clearSelected();
869 else if (myGrpTypeId == 1) { // on geom object
870 if (CORBA::is_nil(myGroupOnGeom)) { // creation
871 if (myMesh->_is_nil() || !myGeomObjects->length())
874 SMESH::ElementType aType = SMESH::ALL;
876 case 0: aType = SMESH::NODE; break;
877 case 1: aType = SMESH::EDGE; break;
878 case 2: aType = SMESH::FACE; break;
879 case 3: aType = SMESH::VOLUME; break;
882 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
883 GEOM::GEOM_IGroupOperations_var aGroupOp =
884 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
886 if (myGeomObjects->length() == 1) {
887 myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomObjects[0]);
890 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
891 if ( aSMESHGen->_is_nil() )
894 // create a geometry group
895 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
896 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
898 if (geomGen->_is_nil() || !aStudy)
901 GEOM::GEOM_IGroupOperations_var op =
902 geomGen->GetIGroupOperations(aStudy->StudyId());
906 // check and add all selected GEOM objects: they must be
907 // a sub-shapes of the main GEOM and must be of one type
908 TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
909 for ( int i =0; i < myGeomObjects->length(); i++) {
910 TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)myGeomObjects[i]->GetShapeType();
912 aGroupType = aSubShapeType;
913 else if (aSubShapeType != aGroupType) {
914 aGroupType = TopAbs_SHAPE;
919 GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
920 GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(aMeshShape, aGroupType);
921 op->UnionList(aGroupVar, myGeomObjects);
924 // publish the GEOM group in study
925 QString aNewGeomGroupName ("Auto_group_for_");
926 aNewGeomGroupName += myName->text();
927 SALOMEDS::SObject_var aNewGroupSO =
928 geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar, aNewGeomGroupName, aMeshShape);
931 myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(), aGroupVar);
934 SALOMEDS::Color aColor = getGroupColor();
935 myGroupOnGeom->SetColor(aColor);
937 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
939 //SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
940 SMESH::setFileType ( aMeshGroupSO,"COULEURGROUP" );
942 /* init for next operation */
944 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
947 myGroupOnGeom->SetName(myName->text());
949 SALOMEDS::Color aColor = getGroupColor();
950 myGroupOnGeom->SetColor(aColor);
952 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
953 if (SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) {
954 switch ( myTypeId ) {
955 case 0: anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
956 case 1: anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
958 case 3: anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B ); break;
963 mySMESHGUI->updateObjBrowser(true);
964 mySelectionMgr->clearSelected();
971 //=================================================================================
974 //=================================================================================
975 void SMESHGUI_GroupDlg::onOK()
981 //=================================================================================
982 // function : onListSelectionChanged()
983 // purpose : Called when selection in element list is changed
984 //=================================================================================
985 void SMESHGUI_GroupDlg::onListSelectionChanged()
987 // MESSAGE("SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor);
988 if ( myIsBusy || !myActor) return;
991 if (myCurrentLineEdit == 0) {
992 mySelectionMgr->clearSelected();
993 TColStd_MapOfInteger aIndexes;
994 QListBoxItem* anItem;
995 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
996 if (anItem->isSelected()) {
997 int anId = anItem->text().toInt();
1001 mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
1002 SALOME_ListIO aList;
1003 aList.Append(myActor->getIO());
1004 mySelectionMgr->setSelectedObjects(aList,false);
1009 //=================================================================================
1010 // function : onObjectSelectionChanged()
1011 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1012 //=================================================================================
1013 void SMESHGUI_GroupDlg::onObjectSelectionChanged()
1015 if (myIsBusy || !isEnabled()) return;
1016 if (myCurrentLineEdit == myGeomGroupLine && !myGeomGroupBtn->isOn()) return;
1020 SALOME_ListIO aList;
1021 mySelectionMgr->selectedObjects( aList );
1023 int aNbSel = aList.Extent();
1024 myElements->clearSelection();
1026 if (myCurrentLineEdit)
1028 myCurrentLineEdit->setText("");
1029 QString aString = "";
1031 if (myCurrentLineEdit == myMeshGroupLine)
1033 mySelectSubMesh->setEnabled(false);
1034 mySelectGroup->setEnabled(false);
1035 myGroupLine->setText("");
1036 mySubMeshLine->setText("");
1038 myGeomGroupBtn->setEnabled(false);
1039 myGeomGroupLine->setEnabled(false);
1040 myGeomGroupLine->setText("");
1041 myGeomObjects = new GEOM::ListOfGO();
1042 myGeomObjects->length(0);
1044 if (myGeomGroupBtn->isOn())
1045 myGeomGroupBtn->setOn(false);
1047 myName->setText("");
1049 myElements->clear();
1052 myGroup = SMESH::SMESH_Group::_nil();
1053 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
1054 restoreShowEntityMode();
1055 myMesh = SMESH::SMESH_Mesh::_nil();
1061 Handle(SALOME_InteractiveObject) IO = aList.First();
1064 restoreShowEntityMode();
1065 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
1066 setShowEntityMode();
1068 if (myMesh->_is_nil())
1074 myGroup = SMESH::SMESH_Group::_nil();
1076 // NPAL19389: create a group with a selection in another group
1077 // set actor of myMesh, if it is visible, else try
1078 // any visible actor of group or submesh of myMesh
1079 SetAppropriateActor();
1081 aString = aList.First()->getName();
1082 myMeshGroupLine->setText(aString);
1083 myMeshGroupLine->home( false );
1085 mySelectSubMesh->setEnabled(true);
1086 mySelectGroup->setEnabled(true);
1087 myGeomGroupBtn->setEnabled(true);
1088 myGeomGroupLine->setEnabled(true);
1091 SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
1092 if (aGroup->_is_nil())
1098 myCurrentLineEdit = 0;
1100 myGroup = SMESH::SMESH_Group::_nil();
1101 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
1105 mySelectSubMesh->setEnabled(true);
1106 mySelectGroup->setEnabled(true);
1108 myCurrentLineEdit = 0;
1113 if (myGrpTypeId == 0)
1119 myElements->clear();
1120 setSelectionMode(myTypeId);
1127 else if (myCurrentLineEdit == myGeomGroupLine)
1129 myGeomObjects = new GEOM::ListOfGO();
1132 _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
1134 if (aNbSel == 0 || !aMeshSO)
1136 myGeomObjects->length(0);
1142 myGeomObjects->length(aNbSel);
1144 GEOM::GEOM_Object_var aGeomGroup;
1145 Standard_Boolean testResult;
1148 SALOME_ListIteratorOfListIO anIt (aList);
1149 for (; anIt.More(); anIt.Next())
1151 testResult = Standard_False;
1152 aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value(), testResult);
1154 // Check if the object is a geometry group
1155 if (!testResult || CORBA::is_nil(aGeomGroup))
1158 // Check if group constructed on the same shape as a mesh or on its child
1159 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1160 GEOM::GEOM_IGroupOperations_var anOp =
1161 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1163 // The main shape of the group
1164 GEOM::GEOM_Object_var aGroupMainShape;
1165 if (aGeomGroup->GetType() == 37)
1166 aGroupMainShape = anOp->GetMainShape(aGeomGroup);
1168 aGroupMainShape = GEOM::GEOM_Object::_duplicate(aGeomGroup);
1169 _PTR(SObject) aGroupMainShapeSO =
1170 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape));
1171 aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
1173 _PTR(SObject) anObj, aRef;
1174 bool isRefOrSubShape = false;
1175 if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) {
1176 //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) {
1177 if (aRef->GetID() == aGroupMainShapeSO->GetID()) {
1178 isRefOrSubShape = true;
1180 _PTR(SObject) aFather = aGroupMainShapeSO->GetFather();
1181 _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent();
1182 //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) {
1183 while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) {
1184 //if (strcmp(aRef->GetID(), aFather->GetID()) == 0)
1185 if (aRef->GetID() == aFather->GetID())
1186 isRefOrSubShape = true;
1188 aFather = aFather->GetFather();
1192 if (isRefOrSubShape)
1193 myGeomObjects[i++] = aGeomGroup;
1196 myGeomObjects->length(i);
1208 if (myCurrentLineEdit == mySubMeshLine)
1209 aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel);
1210 else if (myCurrentLineEdit == myGroupLine)
1211 aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel);
1212 else if (myCurrentLineEdit == myGeomGroupLine)
1213 aString = tr("%1 Objects").arg(aNbSel);
1216 aString = aList.First()->getName();
1220 myCurrentLineEdit->setText(aString);
1221 myCurrentLineEdit->home(false);
1222 // 07.06.2008 skl for IPAL19574:
1223 // change name of group only if it is empty
1224 QString tmp = myName->text();
1225 tmp.stripWhiteSpace();
1226 if( tmp.isEmpty() || !myNameChanged ) {
1227 myOldName = myName->text();
1228 myName->blockSignals(true);
1229 myName->setText(aString);
1230 myName->blockSignals(false);
1235 else // !myCurrentLineEdit: local selection of nodes or elements
1237 if (aNbSel == 1 && myActor && myActor->hasIO())
1239 #ifdef ENABLE_SWITCH_ACTOR_DURING_ELEMENTS_SELECTION
1240 // NPAL19389: create a group with a selection in another group
1241 // Switch myActor to the newly selected one, if the last
1242 // is visible and belongs to group or submesh of myMesh
1243 Handle(SALOME_InteractiveObject) curIO = myActor->getIO();
1244 Handle(SALOME_InteractiveObject) selIO = aList.First();
1245 if (curIO->hasEntry() && selIO->hasEntry()) {
1246 const char* selEntry = selIO->getEntry();
1247 if (strcmp(curIO->getEntry(), selEntry) != 0) {
1248 // different objects: selected and myActor
1249 SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
1250 if (aViewWindow && aViewWindow->isVisible(selIO)) {
1251 // newly selected actor is visible
1254 _PTR(SObject) aSObject = SMESH::FindSObject(myMesh);
1256 CORBA::String_var meshEntry = aSObject->GetID().c_str();
1257 int len = strlen(meshEntry);
1259 if (strncmp(selEntry, meshEntry, len) == 0) {
1260 // selected object is myMesh or a part of it
1261 SMESH_Actor* anActor = SMESH::FindActorByEntry(selEntry);
1264 SMESH::SetPickable(myActor);
1272 #endif // ENABLE_SWITCH_ACTOR_DURING_ELEMENTS_SELECTION
1274 QString aListStr = "";
1276 if (myTypeId == 0) {
1277 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1279 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1282 QStringList anElements = QStringList::split(" ", aListStr);
1283 QListBoxItem* anItem = 0;
1284 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1285 anItem = myElements->findItem(*it, Qt::ExactMatch);
1286 if (anItem) myElements->setSelected(anItem, true);
1293 if (!myGroup->_is_nil())
1294 myActor = SMESH::FindActorByObject(myGroup);
1295 else if (!myGroupOnGeom->_is_nil())
1296 myActor = SMESH::FindActorByObject(myGroupOnGeom);
1298 myActor = SMESH::FindActorByObject(myMesh);
1301 // somehow, if we display the mesh, while selecting from another actor,
1302 // the mesh becomes pickable, and there is no way to select any element
1304 SMESH::SetPickable(myActor);
1309 //=================================================================================
1310 // function : onSelectSubMesh()
1311 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1312 //=================================================================================
1313 void SMESHGUI_GroupDlg::onSelectSubMesh(bool on)
1316 if (mySelectGroup->isChecked()) {
1317 mySelectGroup->setChecked(false);
1319 //VSR: else if (mySelectGeomGroup->isChecked()) {
1320 //VSR: mySelectGeomGroup->setChecked(false);
1322 myCurrentLineEdit = mySubMeshLine;
1323 setSelectionMode(4);
1326 mySubMeshLine->setText("");
1327 myCurrentLineEdit = 0;
1329 setSelectionMode(myTypeId);
1331 mySubMeshBtn->setEnabled(on);
1332 mySubMeshLine->setEnabled(on);
1336 //=================================================================================
1337 // function : (onSelectGroup)
1338 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1339 //=================================================================================
1340 void SMESHGUI_GroupDlg::onSelectGroup(bool on)
1343 if (mySelectSubMesh->isChecked()) {
1344 mySelectSubMesh->setChecked(false);
1346 myCurrentLineEdit = myGroupLine;
1347 setSelectionMode(5);
1350 myGroupLine->setText("");
1351 myCurrentLineEdit = 0;
1353 setSelectionMode(myTypeId);
1355 myGroupBtn->setEnabled(on);
1356 myGroupLine->setEnabled(on);
1360 //=================================================================================
1361 // function : (onSelectGeomGroup)
1362 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1363 //=================================================================================
1364 void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
1367 if (mySelectSubMesh->isChecked()) {
1368 mySelectSubMesh->setChecked(false);
1370 else if (mySelectGroup->isChecked()) {
1371 mySelectGroup->setChecked(false);
1373 myCurrentLineEdit = myGeomGroupLine;
1375 setSelectionMode(8);
1378 myGeomGroupBtn->setOn(false);
1379 myGeomObjects->length(0);
1380 myGeomGroupLine->setText("");
1381 myCurrentLineEdit = 0;
1383 setSelectionMode(myTypeId);
1388 //=================================================================================
1389 // function : setCurrentSelection()
1391 //=================================================================================
1392 void SMESHGUI_GroupDlg::setCurrentSelection()
1394 QPushButton* send = (QPushButton*)sender();
1395 myCurrentLineEdit = 0;
1396 if (send == myMeshGroupBtn) {
1397 myCurrentLineEdit = myMeshGroupLine;
1399 setSelectionMode(6);
1401 setSelectionMode(5);
1402 onObjectSelectionChanged();
1404 else if (send == mySubMeshBtn) {
1405 myCurrentLineEdit = mySubMeshLine;
1406 onObjectSelectionChanged();
1408 else if (send == myGroupBtn) {
1409 myCurrentLineEdit = myGroupLine;
1410 onObjectSelectionChanged();
1415 //=================================================================================
1416 // function : setFilters()
1417 // purpose : SLOT. Called when "Filter" button pressed.
1418 //=================================================================================
1419 void SMESHGUI_GroupDlg::setFilters()
1421 SMESH::ElementType aType = SMESH::ALL;
1424 case 0 : aType = SMESH::NODE; break;
1425 case 1 : aType = SMESH::EDGE; break;
1426 case 2 : aType = SMESH::FACE; break;
1427 case 3 : aType = SMESH::VOLUME; break;
1431 if ( myFilterDlg == 0 )
1433 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType );
1434 connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) );
1437 myFilterDlg->Init( aType );
1439 myFilterDlg->SetSelection();
1440 myFilterDlg->SetMesh( myMesh );
1441 myFilterDlg->SetSourceWg( myElements );
1443 myFilterDlg->show();
1446 //=================================================================================
1447 // function : onFilterAccepted()
1448 // purpose : SLOT. Called when Filter dlg closed with OK button.
1449 // Uncheck "Select submesh" and "Select group" checkboxes
1450 //=================================================================================
1451 void SMESHGUI_GroupDlg::onFilterAccepted()
1453 if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() )
1455 mySelectionMode = myTypeId;
1456 mySelectSubMesh->setChecked( false );
1457 mySelectGroup->setChecked( false );
1461 //=================================================================================
1462 // function : onAdd()
1464 //=================================================================================
1465 void SMESHGUI_GroupDlg::onAdd()
1467 SALOME_ListIO aList;
1468 mySelectionMgr->selectedObjects( aList );
1470 int aNbSel = aList.Extent();
1472 if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
1476 SMESH::ElementType aType = SMESH::ALL;
1479 aType = SMESH::NODE;
1480 mySelector->SetSelectionMode(NodeSelection);
1483 aType = SMESH::EDGE;
1484 mySelector->SetSelectionMode(EdgeSelection);
1487 aType = SMESH::FACE;
1488 mySelector->SetSelectionMode(FaceSelection);
1491 aType = SMESH::VOLUME;
1492 mySelector->SetSelectionMode(VolumeSelection);
1495 mySelector->SetSelectionMode(ActorSelection);
1498 if (myCurrentLineEdit == 0) {
1499 //if (aNbSel != 1) { myIsBusy = false; return; }
1500 QString aListStr = "";
1502 if (myTypeId == 0) {
1503 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1506 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1509 QStringList anElements = QStringList::split(" ", aListStr);
1510 QListBoxItem* anItem = 0;
1511 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1512 anItem = myElements->findItem(*it, Qt::ExactMatch);
1514 anItem = new QListBoxText(*it);
1515 myElements->insertItem(anItem);
1517 myElements->setSelected(anItem, true);
1520 } else if (myCurrentLineEdit == mySubMeshLine) {
1521 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1523 SALOME_ListIO aList;
1524 mySelectionMgr->selectedObjects( aList );
1526 SALOME_ListIteratorOfListIO anIt (aList);
1527 for (; anIt.More(); anIt.Next()) {
1528 SMESH::SMESH_subMesh_var aSubMesh =
1529 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1530 if (!aSubMesh->_is_nil()) {
1531 // check if mesh is the same
1532 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1534 SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType);
1535 int k = anElements->length();
1536 QListBoxItem* anItem = 0;
1537 for (int i = 0; i < k; i++) {
1538 QString aText = QString::number(anElements[i]);
1539 anItem = myElements->findItem(aText, Qt::ExactMatch);
1541 anItem = new QListBoxText(aText);
1542 myElements->insertItem(anItem);
1544 myElements->setSelected(anItem, true);
1547 catch (const SALOME::SALOME_Exception& ex) {
1548 SalomeApp_Tools::QtCatchCorbaException(ex);
1553 mySelectSubMesh->setChecked(false);
1555 onListSelectionChanged();
1557 } else if (myCurrentLineEdit == myGroupLine) {
1558 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1559 SALOME_ListIO aList;
1560 mySelectionMgr->selectedObjects( aList );
1562 SALOME_ListIteratorOfListIO anIt (aList);
1563 for (; anIt.More(); anIt.Next()) {
1564 SMESH::SMESH_Group_var aGroup =
1565 SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1566 if (!aGroup->_is_nil()) {
1567 // check if mesh is the same
1568 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1569 SMESH::long_array_var anElements = aGroup->GetListOfID();
1570 int k = anElements->length();
1571 QListBoxItem* anItem = 0;
1572 for (int i = 0; i < k; i++) {
1573 QString aText = QString::number(anElements[i]);
1574 anItem = myElements->findItem(aText, Qt::ExactMatch);
1576 anItem = new QListBoxText(aText);
1577 myElements->insertItem(anItem);
1579 myElements->setSelected(anItem, true);
1584 mySelectGroup->setChecked(false);
1586 onListSelectionChanged();
1588 } else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) {
1589 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1590 GEOM::GEOM_IGroupOperations_var aGroupOp =
1591 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1593 SMESH::ElementType aGroupType = SMESH::ALL;
1594 switch(aGroupOp->GetType(myGeomObjects[0])) {
1595 case 7: aGroupType = SMESH::NODE; break;
1596 case 6: aGroupType = SMESH::EDGE; break;
1597 case 4: aGroupType = SMESH::FACE; break;
1598 case 2: aGroupType = SMESH::VOLUME; break;
1599 default: myIsBusy = false; return;
1602 if (aGroupType == aType) {
1603 _PTR(SObject) aGroupSO =
1604 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
1605 aStudy->FindObjectID(myGeomObjects[0]->GetStudyEntry());
1607 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
1608 SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
1609 SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();;
1610 aBelongToGeom->SetGeom(myGeomObjects[0]);
1611 aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str());
1612 aBelongToGeom->SetElementType(aType);
1613 aFilter->SetPredicate(aBelongToGeom);
1615 SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh);
1617 int k = anElements->length();
1618 QListBoxItem* anItem = 0;
1619 for (int i = 0; i < k; i++) {
1620 QString aText = QString::number(anElements[i]);
1621 anItem = myElements->findItem(aText, Qt::ExactMatch);
1623 anItem = new QListBoxText(aText);
1624 myElements->insertItem(anItem);
1626 myElements->setSelected(anItem, true);
1630 //VSR: mySelectGeomGroup->setChecked(false);
1632 onListSelectionChanged();
1635 // mySelectionMgr->clearSelected();
1639 //=================================================================================
1640 // function : onRemove()
1642 //=================================================================================
1643 void SMESHGUI_GroupDlg::onRemove()
1646 if (myCurrentLineEdit == 0) {
1647 for (int i = myElements->count(); i > 0; i--) {
1648 if (myElements->isSelected(i-1)) {
1649 myElements->removeItem(i-1);
1653 SALOME_ListIO aList;
1654 mySelectionMgr->selectedObjects( aList );
1656 int aNbSel = aList.Extent();
1658 if (aNbSel == 0) { myIsBusy = false; return; }
1660 SMESH::ElementType aType = SMESH::ALL;
1662 case 0: aType = SMESH::NODE; break;
1663 case 1: aType = SMESH::EDGE; break;
1664 case 2: aType = SMESH::FACE; break;
1665 case 3: aType = SMESH::VOLUME; break;
1668 if (myCurrentLineEdit == mySubMeshLine) {
1669 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1670 SALOME_ListIO aList;
1671 mySelectionMgr->selectedObjects( aList );
1673 SALOME_ListIteratorOfListIO anIt (aList);
1674 for (; anIt.More(); anIt.Next()) {
1675 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1676 if (!aSubMesh->_is_nil()) {
1677 // check if mesh is the same
1678 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1679 if (aType == SMESH::NODE) {
1681 SMESH::long_array_var anElements = aSubMesh->GetNodesId();
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);
1695 SMESH::long_array_var anElements = aSubMesh->GetElementsId();
1696 int k = anElements->length();
1697 QListBoxItem* anItem = 0;
1698 for (int i = 0; i < k; i++) {
1699 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1700 if (anItem) delete anItem;
1703 catch (const SALOME::SALOME_Exception& ex) {
1704 SalomeApp_Tools::QtCatchCorbaException(ex);
1711 else if (myCurrentLineEdit == myGroupLine) {
1712 Standard_Boolean aRes;
1713 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1714 SALOME_ListIO aList;
1715 mySelectionMgr->selectedObjects( aList );
1717 SALOME_ListIteratorOfListIO anIt (aList);
1718 for (; anIt.More(); anIt.Next()) {
1719 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1720 if (aRes && !aGroup->_is_nil()) {
1721 // check if mesh is the same
1722 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1723 SMESH::long_array_var anElements = aGroup->GetListOfID();
1724 int k = anElements->length();
1725 QListBoxItem* anItem = 0;
1726 for (int i = 0; i < k; i++) {
1727 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1728 if (anItem) delete anItem;
1739 //=================================================================================
1740 // function : onSort()
1742 //=================================================================================
1743 void SMESHGUI_GroupDlg::onSort()
1745 // PAL5412: sorts items in ascending by "string" value
1746 // myElements->sort(true);
1747 // myElements->update();
1748 int i, k = myElements->count();
1751 QStringList aSelected;
1752 std::vector<int> anArray(k);
1753 // QMemArray<int> anArray(k);
1754 QListBoxItem* anItem;
1756 for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) {
1757 anArray[i] = anItem->text().toInt();
1758 if (anItem->isSelected())
1759 aSelected.append(anItem->text());
1761 // sort & update list
1762 std::sort(anArray.begin(), anArray.end());
1764 myElements->clear();
1765 for (i = 0; i < k; i++) {
1766 myElements->insertItem(QString::number(anArray[i]));
1768 for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) {
1769 anItem = myElements->findItem(*it, Qt::ExactMatch);
1770 if (anItem) myElements->setSelected(anItem, true);
1776 //=================================================================================
1777 // function : closeEvent()
1779 //=================================================================================
1780 void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
1785 //=================================================================================
1786 // function : SMESHGUI_GroupDlg::onClose
1787 // purpose : SLOT called when "Close" button pressed. Close dialog
1788 //=================================================================================
1789 void SMESHGUI_GroupDlg::onClose()
1791 if (SMESH::GetCurrentVtkView()) {
1792 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
1793 SMESH::SetPointRepresentation(false);
1794 SMESH::SetPickable();
1795 restoreShowEntityMode();
1798 mySelectionMgr->clearSelected();
1799 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1800 aViewWindow->SetSelectionMode(ActorSelection);
1801 mySelectionMgr->clearFilters();
1802 mySMESHGUI->ResetState();
1807 //=================================================================================
1808 // function : onHelp()
1810 //=================================================================================
1811 void SMESHGUI_GroupDlg::onHelp()
1813 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1815 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""),
1820 platform = "winapplication";
1822 platform = "application";
1824 SUIT_MessageBox::warn1
1825 (0, QObject::tr("WRN_WARNING"),
1826 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1827 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
1828 QObject::tr("BUT_OK"));
1832 //=================================================================================
1833 // function : SMESHGUI_GroupDlg::onDeactivate
1834 // purpose : SLOT called when dialog must be deativated
1835 //=================================================================================
1836 void SMESHGUI_GroupDlg::onDeactivate()
1838 mySMESHGUI->ResetState();
1842 //=================================================================================
1843 // function : SMESHGUI_GroupDlg::enterEvent
1844 // purpose : Event filter
1845 //=================================================================================
1846 void SMESHGUI_GroupDlg::enterEvent (QEvent*)
1849 mySMESHGUI->EmitSignalDeactivateDialog();
1851 mySelectionMode = -1;
1852 setSelectionMode(myTypeId);
1853 //mySMESHGUI->SetActiveDialogBox((QDialog*)this);
1854 mySMESHGUI->SetActiveDialogBox(this);
1855 mySMESHGUI->SetState(800);
1859 //=================================================================================
1860 // function : hideEvent
1861 // purpose : caused by ESC key
1862 //=================================================================================
1863 void SMESHGUI_GroupDlg::hideEvent (QHideEvent*)
1865 if (!isMinimized() && !myIsBusy)
1869 //=================================================================================
1870 // function : keyPressEvent()
1872 //=================================================================================
1873 void SMESHGUI_GroupDlg::keyPressEvent( QKeyEvent* e )
1875 QDialog::keyPressEvent( e );
1876 if ( e->isAccepted() )
1879 if ( e->key() == Key_F1 )
1886 //================================================================================
1888 * \brief Enable showing of the popup when Geometry selection btn is clicked
1889 * \param enable - true to enable
1891 //================================================================================
1893 enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
1895 void SMESHGUI_GroupDlg::updateGeomPopup()
1897 bool enable = false;
1899 if ( !myMesh->_is_nil() )
1900 enable = myMesh->NbEdges() > 0;
1902 if ( myGeomGroupBtn )
1904 disconnect( myGeomGroupBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
1906 if ( !myGeomPopup ) {
1907 myGeomPopup = new QPopupMenu();
1908 myGeomPopup->insertItem( tr("DIRECT_GEOM_SELECTION"), DIRECT_GEOM_INDEX );
1909 myGeomPopup->insertItem( tr("GEOM_BY_MESH_ELEM_SELECTION"), GEOM_BY_MESH_INDEX );
1910 connect( myGeomPopup, SIGNAL( activated( int ) ), SLOT( onGeomPopup( int ) ) );
1912 connect( myGeomGroupBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
1918 //=================================================================================
1919 // function : onGeomSelectionButton()
1921 //=================================================================================
1922 void SMESHGUI_GroupDlg::onGeomSelectionButton(bool isBtnOn)
1924 if ( myGeomPopup && isBtnOn )
1926 myCurrentLineEdit = myGeomGroupLine;
1927 int id = myGeomPopup->exec( QCursor::pos() );
1928 if (id == DIRECT_GEOM_INDEX || id == -1)
1929 setSelectionMode(7);
1933 myCurrentLineEdit = 0;
1934 setSelectionMode(8);
1938 //=================================================================================
1939 // function : onGeomPopup()
1941 //=================================================================================
1942 void SMESHGUI_GroupDlg::onGeomPopup( int index )
1944 if ( index == GEOM_BY_MESH_INDEX )
1946 mySelectionMode = -1;
1947 if ( !myShapeByMeshOp ) {
1948 myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp(true);
1949 connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
1950 SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
1951 connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
1952 SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
1954 // set mesh object to SMESHGUI_ShapeByMeshOp and start it
1955 if ( !myMesh->_is_nil() ) {
1957 hide(); // stop processing selection
1959 myShapeByMeshOp->setModule( mySMESHGUI );
1960 myShapeByMeshOp->setStudy( 0 ); // it's really necessary
1961 myShapeByMeshOp->SetMesh( myMesh );
1962 myShapeByMeshOp->start();
1967 //================================================================================
1969 * \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg
1971 //================================================================================
1973 void SMESHGUI_GroupDlg::onPublishShapeByMeshDlg(SUIT_Operation* op)
1975 if ( myShapeByMeshOp == op ) {
1976 mySMESHGUI->getApp()->updateObjectBrowser();
1978 // Select a found geometry object
1979 GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();
1980 if ( !aGeomVar->_is_nil() )
1982 QString ID = aGeomVar->GetStudyEntry();
1983 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1984 if ( _PTR(SObject) aGeomSO = aStudy->FindObjectID( ID.latin1() )) {
1985 SALOME_ListIO anIOList;
1986 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
1987 ( aGeomSO->GetID().c_str(), "SMESH", aGeomSO->GetName().c_str() );
1988 anIOList.Append( anIO );
1989 mySelectionMgr->setSelectedObjects( anIOList, false );
1990 onObjectSelectionChanged();
1996 //================================================================================
1998 * \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
2000 //================================================================================
2002 void SMESHGUI_GroupDlg::onCloseShapeByMeshDlg(SUIT_Operation* op)
2004 if ( myShapeByMeshOp == op )
2007 setSelectionMode(7);
2011 //=================================================================================
2012 // function : setGroupColor()
2014 //=================================================================================
2015 void SMESHGUI_GroupDlg::setGroupColor( const SALOMEDS::Color& theColor )
2017 QColor aQColor( (int)( theColor.R * 255.0 ),
2018 (int)( theColor.G * 255.0 ),
2019 (int)( theColor.B * 255.0 ) );
2020 setGroupQColor( aQColor );
2023 //=================================================================================
2024 // function : getGroupColor()
2026 //=================================================================================
2027 SALOMEDS::Color SMESHGUI_GroupDlg::getGroupColor() const
2029 QColor aQColor = getGroupQColor();
2031 SALOMEDS::Color aColor;
2032 aColor.R = (float)aQColor.red() / 255.0;
2033 aColor.G = (float)aQColor.green() / 255.0;
2034 aColor.B = (float)aQColor.blue() / 255.0;
2039 //=================================================================================
2040 // function : setGroupQColor()
2042 //=================================================================================
2043 void SMESHGUI_GroupDlg::setGroupQColor( const QColor& theColor )
2045 if ( theColor.isValid() )
2047 QPalette pal = myColorBtn->palette();
2048 pal.setColor(QColorGroup::Button, theColor);
2049 myColorBtn->setPalette(pal);
2053 //=================================================================================
2054 // function : getGroupQColor()
2056 //=================================================================================
2057 QColor SMESHGUI_GroupDlg::getGroupQColor() const
2059 QColor aColor = myColorBtn->palette().active().button();
2063 //=================================================================================
2064 // function : setDefaultGroupColor()
2066 //=================================================================================
2067 void SMESHGUI_GroupDlg::setDefaultGroupColor()
2069 if ( myMesh->_is_nil() )
2072 bool isAutoColor = myMesh->GetAutoColor();
2077 int r = 0, g = 0, b = 0;
2078 SMESH::GetColor( "SMESH", "fill_color", r, g, b, QColor( 0, 170, 255 ) );
2079 aQColor.setRgb( r, g, b );
2083 SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
2085 QValueList<SALOMEDS::Color> aReservedColors;
2086 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
2088 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
2089 SALOMEDS::Color aReservedColor = aGroupObject->GetColor();
2090 aReservedColors.append( aReservedColor );
2093 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
2094 aQColor.setRgb( (int)( aColor.R * 255.0 ),
2095 (int)( aColor.G * 255.0 ),
2096 (int)( aColor.B * 255.0 ) );
2100 setGroupQColor( aQColor );
2103 //=================================================================================
2104 // function : SetAppropriateActor()
2105 // purpose : Find more appropriate of visible actors, set it to myActor, allow picking
2106 // NPAL19389: create a group with a selection in another group.
2107 // if mesh actor is not visible - find any first visible group or submesh
2108 //=================================================================================
2109 bool SMESHGUI_GroupDlg::SetAppropriateActor()
2111 bool isActor = false;
2113 if (myMesh->_is_nil()) return false;
2115 SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
2118 myActor = SMESH::FindActorByObject(myMesh);
2119 if (myActor && myActor->hasIO())
2122 if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
2126 // try current group actor
2128 if (!myGroup->_is_nil()) {
2129 myActor = SMESH::FindActorByObject(myGroup);
2130 if (myActor && myActor->hasIO())
2133 if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
2139 // try current group on geometry actor
2141 if (!myGroupOnGeom->_is_nil()) {
2142 myActor = SMESH::FindActorByObject(myGroupOnGeom);
2143 if (myActor && myActor->hasIO())
2146 if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
2152 // try any visible actor of group or submesh of current mesh
2153 if (!isActor && aViewWindow) {
2155 _PTR(SObject) aSObject = SMESH::FindSObject(myMesh);
2157 CORBA::String_var meshEntry = aSObject->GetID().c_str();
2158 int len = strlen(meshEntry);
2160 // iterate on all actors in current view window, search for
2161 // any visible actor, that belongs to group or submesh of current mesh
2162 VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors());
2163 vtkActorCollection *aCollection = aCopy.GetActors();
2164 aCollection->InitTraversal();
2165 for (vtkActor *anAct = aCollection->GetNextActor();
2167 anAct = aCollection->GetNextActor())
2169 SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct);
2170 if (anActor && anActor->hasIO()) {
2171 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
2172 if (aViewWindow->isVisible(anIO)) {
2173 if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0) {
2184 SMESH::SetPickable(myActor);
2189 //=======================================================================
2190 //function : setShowEntityMode
2191 //purpose : make shown only entity corresponding to my type
2192 //=======================================================================
2193 void SMESHGUI_GroupDlg::setShowEntityMode()
2195 if ( !myMesh->_is_nil() ) {
2196 if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) ) {
2197 if (!myStoredShownEntity)
2198 myStoredShownEntity = actor->GetEntityMode();
2199 switch ( myTypeId ) {
2200 case 0: restoreShowEntityMode(); break;
2201 case 1: actor->SetEntityMode( SMESH_Actor::eEdges ); break;
2202 case 2: actor->SetEntityMode( SMESH_Actor::eFaces ); break;
2203 case 3: actor->SetEntityMode( SMESH_Actor::eVolumes ); break;
2209 //=======================================================================
2210 //function : restoreShowEntityMode
2211 //purpose : restore ShowEntity mode of myActor
2212 //=======================================================================
2213 void SMESHGUI_GroupDlg::restoreShowEntityMode()
2215 if ( myStoredShownEntity && !myMesh->_is_nil() ) {
2216 if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) ) {
2217 actor->SetEntityMode(myStoredShownEntity);
2220 myStoredShownEntity = 0;