1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2004 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 // File : GroupGUI_GroupDlg.cxx
23 // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
26 #include "GroupGUI_GroupDlg.h"
28 #include <SUIT_Desktop.h>
29 #include <SUIT_Session.h>
30 #include <SUIT_ResourceMgr.h>
31 #include <SalomeApp_Application.h>
32 #include <SalomeApp_Study.h>
33 #include <LightApp_SelectionMgr.h>
38 #include <GEOMImpl_Types.hxx>
40 #include <TColStd_IndexedMapOfInteger.hxx>
41 #include <TColStd_MapOfInteger.hxx>
43 GroupGUI_GroupDlg::GroupGUI_GroupDlg( Mode mode, GeometryGUI* theGeometryGUI, QWidget* parent )
44 : GEOMBase_Skeleton( theGeometryGUI, parent, false ),
48 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
50 QPixmap image0 ( resMgr->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_VERTEX" ) ) );
51 QPixmap image1 ( resMgr->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_EDGE" ) ) );
52 QPixmap image2 ( resMgr->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_FACE" ) ) );
53 QPixmap image3 ( resMgr->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_SOLID" ) ) );
54 QPixmap iconSelect( resMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
56 setWindowTitle( myMode == CreateGroup ? tr( "CREATE_GROUP_TITLE" ) : tr( "EDIT_GROUP_TITLE" ) );
58 // Shape type button group
59 mainFrame()->GroupConstructors->setEnabled( myMode == CreateGroup );
60 mainFrame()->GroupConstructors->setTitle( tr( "SHAPE_TYPE" ) );
61 mainFrame()->RadioButton1->setIcon( image0 );
62 mainFrame()->RadioButton2->setIcon( image1 );
63 mainFrame()->RadioButton3->setIcon( image2 );
64 mainFrame()->RadioButton4->setIcon( image3 );
65 mainFrame()->RadioButton4->show();
68 mainFrame()->GroupBoxName->setTitle( tr( "GROUP_NAME" ) );
70 // Main shape and sub-shapes
71 myGroupBox = new DlgRef_1Sel1List4Btn( centralWidget() );
72 myGroupBox->GroupBox1->setTitle( tr( "MAIN_SUB_SHAPES" ) );
73 myGroupBox->TextLabel1->setText( tr( "MAIN_SHAPE" ) );
74 myGroupBox->PushButton1->setIcon( iconSelect );
75 myGroupBox->PushButton1->setEnabled( myMode == CreateGroup );
76 myGroupBox->LineEdit1->setReadOnly( true );
77 myGroupBox->LineEdit1->setEnabled( myMode == CreateGroup );
78 myGroupBox->PushButton2->setText( tr( "SELECT_SUB_SHAPES" ) );
79 myGroupBox->PushButton3->setText( tr( "SELECT_ALL" ) );
80 myGroupBox->PushButton4->setText( tr( "ADD" ) );
81 myGroupBox->PushButton5->setText( tr( "REMOVE" ) );
82 myGroupBox->ListView1->setSelectionMode( QAbstractItemView::ExtendedSelection );
83 myGroupBox->ListView1->setFlow( QListView::TopToBottom );
84 myGroupBox->ListView1->setWrapping( true );
86 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
87 layout->setMargin( 0 ); layout->setSpacing( 6 );
88 layout->addWidget( myGroupBox );
90 setHelpFileName( "working_with_groups.htm" );
95 GroupGUI_GroupDlg::~GroupGUI_GroupDlg()
100 //=================================================================================
103 //=================================================================================
104 void GroupGUI_GroupDlg::Init()
106 // san -- TODO: clear selected sub-shapes...
108 if ( myMode == CreateGroup ) {
109 initName( tr( "GROUP_PREFIX" ) );
111 // Get ready for main shape selection
112 myEditCurrentArgument = myGroupBox->LineEdit1;
114 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
115 connect( myGroupBox->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
117 else if ( myMode == EditGroup && IObjectCount() ) {
118 Standard_Boolean aResult = Standard_False;
119 GEOM::GEOM_Object_var anObj =
120 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
122 if ( aResult && !CORBA::is_nil( anObj ) && anObj->GetType() == GEOM_GROUP ) {
125 mainFrame()->ResultName->setText( GEOMBase::GetName( myGroup ) );
127 GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
128 myMainObj = anOp->GetMainShape( myGroup );
129 if ( !CORBA::is_nil( myMainObj ) )
130 myGroupBox->LineEdit1->setText( GEOMBase::GetName( myMainObj ) );
132 setShapeType( (TopAbs_ShapeEnum)anOp->GetType( myGroup ) );
134 GEOM::ListOfLong_var aCurrList = anOp->GetObjects( myGroup );
135 for ( int i = 0, n = aCurrList->length(); i < n; i++ )
136 myGroupBox->ListView1->addItem( new QListWidgetItem( QString( "%1" ).arg( aCurrList[i] ) ) );
138 myEditCurrentArgument = 0;
142 LightApp_SelectionMgr* aSelMgr =
143 ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr();
145 connect( aSelMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
147 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
148 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
150 connect( myGroupBox->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
151 connect( myGroupBox->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
152 connect( myGroupBox->PushButton4, SIGNAL( clicked() ), this, SLOT( add() ) );
153 connect( myGroupBox->PushButton5, SIGNAL( clicked() ), this, SLOT( remove() ) );
154 connect( myGroupBox->ListView1, SIGNAL( itemSelectionChanged() ), this, SLOT( selectionChanged() ) );
159 //=================================================================================
160 // function : enterEvent()
162 //=================================================================================
163 void GroupGUI_GroupDlg::enterEvent( QEvent* )
165 if ( !buttonCancel()->isEnabled() )
166 this->ActivateThisDialog();
169 //=================================================================================
170 // function : ClickOnOk()
172 //=================================================================================
173 void GroupGUI_GroupDlg::ClickOnOk()
175 if ( ClickOnApply() )
179 //=================================================================================
180 // function : ClickOnApply()
182 //=================================================================================
183 bool GroupGUI_GroupDlg::ClickOnApply()
185 if ( !onAccept( myMode == CreateGroup, true ) )
188 if ( myMode == CreateGroup ) {
190 myGroupBox->ListView1->clear();
199 //=================================================================================
200 // function : ActivateThisDialog()
202 //=================================================================================
203 void GroupGUI_GroupDlg::ActivateThisDialog()
205 GEOMBase_Skeleton::ActivateThisDialog();
207 connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
208 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
213 //=================================================================================
214 // function : LineEditReturnPressed()
216 //=================================================================================
217 void GroupGUI_GroupDlg::LineEditReturnPressed()
219 QLineEdit* send = ( QLineEdit* )sender();
221 if ( send == myGroupBox->LineEdit1 && !myEditCurrentArgument ) {
222 myEditCurrentArgument = myGroupBox->LineEdit1;
226 GEOMBase_Skeleton::LineEditReturnPressed();
233 //=================================================================================
234 // function : SetEditCurrentArgument()
236 //=================================================================================
237 void GroupGUI_GroupDlg::SetEditCurrentArgument()
239 QPushButton* send = (QPushButton*)sender();
241 if ( send == myGroupBox->PushButton1 )
242 myEditCurrentArgument = myGroupBox->LineEdit1;
243 else if ( send == myGroupBox->PushButton2 || send == myGroupBox->PushButton3 )
244 myEditCurrentArgument = 0;
248 if ( send == myGroupBox->PushButton3 )
249 selectAllSubShapes();
255 //=================================================================================
256 // function : SelectionIntoArgument()
257 // purpose : Called when selection has changed
258 //=================================================================================
259 void GroupGUI_GroupDlg::SelectionIntoArgument()
261 if ( myEditCurrentArgument ) { // Selection of a main shape is active
262 myEditCurrentArgument->setText( "" );
263 myGroupBox->ListView1->clear();
265 if ( IObjectCount() == 1 ) {
266 Standard_Boolean aResult = Standard_False;
267 GEOM::GEOM_Object_var anObj =
268 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
270 if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) {
272 myEditCurrentArgument->setText( GEOMBase::GetName( anObj ) );
278 myMainObj = GEOM::GEOM_Object::_nil();
280 else { // an attempt to synchronize list box selection with 3d viewer
284 bool isBlocked = myGroupBox->ListView1->signalsBlocked();
285 myGroupBox->ListView1->blockSignals( true );
286 myGroupBox->ListView1->clearSelection();
288 TColStd_IndexedMapOfInteger aMapIndex;
290 if ( IObjectCount() == 1 ) {
291 Standard_Boolean aResult = Standard_False;
292 GEOM::GEOM_Object_var anObj =
293 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
295 if ( aResult && !anObj->_is_nil() )
296 ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->
297 selectionMgr()->GetIndexes( firstIObject(), aMapIndex );
300 // try to find out and process the object browser selection
301 if ( !aMapIndex.Extent() ) {
302 globalSelection( GEOM_ALLSHAPES );
304 GEOM::ListOfGO anObjects;
305 GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
307 GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
308 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
310 for (int i = 0; i < anObjects.length(); i++) {
311 GEOM::GEOM_Object_var aGeomObj = anObjects[i];
312 GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
314 if ( GEOMBase::GetShape( aGeomObj, aShape, getShapeType() ) ) {
315 aSubObjects->length(1);
316 aSubObjects[0] = aGeomObj;
318 else if (aGeomObj->GetType() == GEOM_GROUP)
319 aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
323 for (int i = 0; i < aSubObjects->length(); i++) {
325 if ( GEOMBase::GetShape( aSubObjects[i], aShape, getShapeType() ) ) {
326 CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
328 aMapIndex.Add( anIndex );
333 if ( !myMainObj->_is_nil() )
334 localSelection( myMainObj, getShapeType() );
337 if ( aMapIndex.Extent() >= 1 ) {
339 for ( int i = 0, n = myGroupBox->ListView1->count(); i < n; i++ )
340 aMap.insert( myGroupBox->ListView1->item( i )->text().toInt(), i );
342 for ( int ii = 1, nn = aMapIndex.Extent(); ii <= nn; ii++ ) {
343 if ( aMap.contains( aMapIndex( ii ) ) )
344 myGroupBox->ListView1->item( aMap[aMapIndex( ii )])->setSelected( true );
347 myGroupBox->ListView1->blockSignals( isBlocked );
353 //=================================================================================
354 // function : ConstructorsClicked()
355 // purpose : Radio button management
356 //=================================================================================
357 void GroupGUI_GroupDlg::ConstructorsClicked( int )
359 myGroupBox->ListView1->clear();
364 //=================================================================================
365 // function : selectAllSubShapes
367 //=================================================================================
368 void GroupGUI_GroupDlg::selectAllSubShapes()
370 if ( CORBA::is_nil( myMainObj ) )
373 GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
374 GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
376 GEOM::ListOfGO_var aSubShapes = aShOp->MakeExplode( myMainObj, getShapeType(), false );
377 if ( !aShOp->IsDone() )
380 bool isBlocked = myGroupBox->ListView1->signalsBlocked();
381 myGroupBox->ListView1->blockSignals( true );
382 myGroupBox->ListView1->clear();
384 for ( int i = 0, n = aSubShapes->length(); i < n; i++ ) {
385 CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubShapes[i] );
389 QListWidgetItem* anItem = new QListWidgetItem( QString( "%1" ).arg( anIndex ) );
390 myGroupBox->ListView1->addItem( anItem );
391 anItem->setSelected( true );
394 myGroupBox->ListView1->blockSignals( isBlocked );
395 highlightSubShapes();
399 //=================================================================================
402 //=================================================================================
403 void GroupGUI_GroupDlg::add()
405 TColStd_MapOfInteger aMap;
406 for ( int i = 0, n = myGroupBox->ListView1->count(); i < n; i++ )
407 aMap.Add( myGroupBox->ListView1->item( i )->text().toInt() );
409 TColStd_IndexedMapOfInteger aMapIndex;
411 if ( IObjectCount() == 1 ) {
412 Standard_Boolean aResult = Standard_False;
413 GEOM::GEOM_Object_var anObj =
414 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
416 if ( aResult && !anObj->_is_nil() )
417 ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->
418 selectionMgr()->GetIndexes( firstIObject(), aMapIndex );
421 // try to find out and process the object browser selection
422 if ( !aMapIndex.Extent() ) {
423 GEOM::ListOfGO anObjects;
424 GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
426 GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
427 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
429 for ( int i = 0; i < anObjects.length(); i++ ) {
430 GEOM::GEOM_Object_var aGeomObj = anObjects[i];
431 GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
433 if ( GEOMBase::GetShape( aGeomObj, aShape, getShapeType() ) ) {
434 aSubObjects->length( 1 );
435 aSubObjects[0] = aGeomObj;
437 else if ( aGeomObj->GetType() == GEOM_GROUP )
438 aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false );
442 for ( int i = 0; i < aSubObjects->length(); i++ ) {
444 if ( GEOMBase::GetShape( aSubObjects[i], aShape, getShapeType() ) ) {
445 CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
447 aMapIndex.Add( anIndex );
453 if ( aMapIndex.Extent() >= 1 ) {
454 bool isBlocked = myGroupBox->ListView1->signalsBlocked();
455 myGroupBox->ListView1->blockSignals( true );
457 for ( int i = 1, n = aMapIndex.Extent(); i <= n; i++ ) {
458 if ( aMap.Contains( aMapIndex( i ) ) )
461 QListWidgetItem* anItem = new QListWidgetItem( QString( "%1" ).arg( aMapIndex( i ) ) );
462 myGroupBox->ListView1->addItem( anItem );
463 anItem->setSelected( true );
466 myGroupBox->ListView1->blockSignals( isBlocked );
472 //=================================================================================
475 //=================================================================================
476 void GroupGUI_GroupDlg::remove()
478 QListIterator<QListWidgetItem*> it( myGroupBox->ListView1->selectedItems() );
479 while ( it.hasNext() )
485 //=================================================================================
486 // function : getShapeType()
488 //=================================================================================
489 TopAbs_ShapeEnum GroupGUI_GroupDlg::getShapeType() const
491 switch ( getConstructorId() ) {
492 case 0: return TopAbs_VERTEX;
493 case 1: return TopAbs_EDGE;
494 case 2: return TopAbs_FACE;
495 case 3: return TopAbs_SOLID;
496 default: return TopAbs_SHAPE;
500 //=================================================================================
501 // function : setShapeType()
503 //=================================================================================
504 void GroupGUI_GroupDlg::setShapeType( const TopAbs_ShapeEnum theType )
508 case TopAbs_VERTEX: anId = 0; break;
509 case TopAbs_EDGE: anId = 1; break;
510 case TopAbs_FACE: anId = 2; break;
511 case TopAbs_SOLID: anId = 3; break;
513 setConstructorId( anId );
517 //=================================================================================
518 // function : activateSelection
519 // purpose : Activate selection in accordance with myEditCurrentArgument
520 //=================================================================================
521 void GroupGUI_GroupDlg::activateSelection()
523 globalSelection( GEOM_ALLSHAPES );
525 if ( !myMainObj->_is_nil() && !myEditCurrentArgument ) {
526 localSelection( myMainObj, getShapeType() );
529 SelectionIntoArgument();
532 //=================================================================================
533 // function : updateState
535 //=================================================================================
536 void GroupGUI_GroupDlg::updateState()
540 TColStd_IndexedMapOfInteger aMapIndex;
542 if ( IObjectCount() == 1 ) {
543 Standard_Boolean aResult = Standard_False;
544 GEOM::GEOM_Object_var anObj =
545 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
547 if ( aResult && !anObj->_is_nil() )
548 ( (SalomeApp_Application*)(SUIT_Session::session()->activeApplication() ) )->
549 selectionMgr()->GetIndexes( firstIObject(), aMapIndex );
552 // try to find out and process the object browser selection
553 if ( !aMapIndex.Extent() && !CORBA::is_nil( myMainObj ) ) {
554 GEOM::ListOfGO anObjects;
555 GEOMBase::ConvertListOfIOInListOfGO( selectedIO(), anObjects );
557 GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
558 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
562 for ( int i = 0; i < anObjects.length(); i++ ) {
563 GEOM::GEOM_Object_var aGeomObj = anObjects[i];
564 GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
566 if ( GEOMBase::GetShape( aGeomObj, aShape, getShapeType() ) ) {
567 aSubObjects->length( 1 );
568 aSubObjects[0] = aGeomObj;
570 else if ( aGeomObj->GetType() == GEOM_GROUP )
571 aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false );
577 for ( int i = 0; i < aSubObjects->length(); i++ ) {
580 if ( GEOMBase::GetShape( aSubObjects[i], aShape, getShapeType() ) ) {
581 CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
583 aMapIndex.Add( anIndex );
603 isAdd = aMapIndex.Extent() > 0;
605 myGroupBox->PushButton4->setEnabled( !myEditCurrentArgument && !CORBA::is_nil( myMainObj ) && isAdd );
606 bool hasSel = myGroupBox->ListView1->selectedItems().count() > 0;
607 myGroupBox->PushButton5->setEnabled( hasSel );
608 myGroupBox->PushButton2->setEnabled( !CORBA::is_nil( myMainObj ) );
609 myGroupBox->PushButton3->setEnabled( !CORBA::is_nil( myMainObj ) );
612 //=================================================================================
613 // function : selectionChanged
615 //=================================================================================
616 void GroupGUI_GroupDlg::selectionChanged()
618 highlightSubShapes();
621 //=================================================================================
622 // function : highlightSubShapes
624 //=================================================================================
625 void GroupGUI_GroupDlg::highlightSubShapes()
627 if ( CORBA::is_nil( myMainObj ) )
630 Standard_Boolean isOk;
631 char* objIOR = GEOMBase::GetIORFromObject( myMainObj );
632 Handle(GEOM_AISShape) aSh =
633 GEOMBase::ConvertIORinGEOMAISShape( objIOR, isOk, true );
635 if ( !isOk || aSh.IsNull() )
638 TColStd_MapOfInteger anIds;
642 for ( int ii = 0, nn = myGroupBox->ListView1->count(); ii < nn; ii++ )
643 if ( myGroupBox->ListView1->item( ii )->isSelected() )
644 anIds.Add( myGroupBox->ListView1->item( ii )->text().toInt() );
646 LightApp_SelectionMgr* aSelMgr =
647 ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr();
648 aSelMgr->clearSelected();
649 aSelMgr->AddOrRemoveIndex( aSh->getIO(), anIds, false );
656 //=================================================================================
657 // function : createOperation
659 //=================================================================================
660 GEOM::GEOM_IOperations_ptr GroupGUI_GroupDlg::createOperation()
662 return getGeomEngine()->GetIGroupOperations( getStudyId() );
665 #define RETURN_WITH_MSG(a, b) \
671 //=================================================================================
672 // function : isValid()
673 // purpose : Verify validity of input data
674 //=================================================================================
675 bool GroupGUI_GroupDlg::isValid( QString& theMessage )
677 SalomeApp_Study* study = getStudy();
679 RETURN_WITH_MSG ( !study->studyDS()->GetProperties()->IsLocked(), tr( "GEOM_STUDY_LOCKED" ) )
681 if ( myMode == CreateGroup ) {
682 RETURN_WITH_MSG( !CORBA::is_nil( myMainObj ), tr( "NO_MAIN_OBJ" ) )
685 RETURN_WITH_MSG( !CORBA::is_nil( myMainObj ), tr( "NO_GROUP" ) )
688 QString aName( getNewObjectName() );
689 RETURN_WITH_MSG ( !aName.trimmed().isEmpty(), tr( "EMPTY_NAME" ) )
691 RETURN_WITH_MSG ( myGroupBox->ListView1->count(), tr( "EMPTY_LIST" ) )
695 //=================================================================================
696 // function : execute
698 //=================================================================================
699 bool GroupGUI_GroupDlg::execute( ObjectList& objects )
701 GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
703 GEOM::GEOM_Object_var aGroup;
704 if ( myMode == CreateGroup )
705 aGroup = anOp->CreateGroup( myMainObj, getShapeType() );
706 else if ( myMode == EditGroup )
709 if ( CORBA::is_nil( aGroup ) || ( myMode == CreateGroup && !anOp->IsDone() ) )
712 GEOM::ListOfLong_var aCurrList = anOp->GetObjects( aGroup );
713 if ( !anOp->IsDone() )
716 for ( int i = 0, n = aCurrList->length(); i < n; i++ ) {
717 anOp->RemoveObject( aGroup, aCurrList[i] );
718 if ( !anOp->IsDone() )
722 for ( int ii = 0, nn = myGroupBox->ListView1->count(); ii < nn; ii++ ) {
723 anOp->AddObject( aGroup, myGroupBox->ListView1->item( ii )->text().toInt() );
724 if ( !anOp->IsDone() )
728 SalomeApp_Study* study = getStudy();
730 char* objIOR = GEOMBase::GetIORFromObject( aGroup );
731 string IOR( objIOR );
734 _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) );
736 _PTR(StudyBuilder) aBuilder (study->studyDS()->NewBuilder());
737 aBuilder->SetName( SO, getNewObjectName() );
742 objects.push_back( aGroup._retn() );
747 //================================================================
748 // Function : getFather
749 // Purpose : Get father object for object to be added in study
750 // ( called with addInStudy method )
751 //================================================================
752 GEOM::GEOM_Object_ptr GroupGUI_GroupDlg::getFather( GEOM::GEOM_Object_ptr theObj )
754 GEOM::GEOM_Object_var aFatherObj;
755 if ( theObj->GetType() == GEOM_GROUP ) {
756 GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
757 aFatherObj = anOp->GetMainShape( theObj );
759 return aFatherObj._retn();