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
24 // File : GroupGUI_GroupDlg.cxx
25 // Author : Sergey ANIKIN
29 #include "GroupGUI_GroupDlg.h"
31 #include "SUIT_Desktop.h"
32 #include "SUIT_Session.h"
33 #include "SalomeApp_Application.h"
34 #include "SalomeApp_Study.h"
35 #include "LightApp_SelectionMgr.h"
39 #include "GEOMImpl_Types.hxx"
43 #include <qlineedit.h>
46 #include <TColStd_IndexedMapOfInteger.hxx>
47 #include <TColStd_MapOfInteger.hxx>
50 GroupGUI_GroupDlg::GroupGUI_GroupDlg(Mode mode, GeometryGUI* theGeometryGUI, QWidget* parent)
51 :GEOMBase_Skeleton( theGeometryGUI, parent, "GroupGUI_GroupDlg", false,
52 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
56 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
58 QPixmap image0 (resMgr->loadPixmap("GEOM", tr("ICON_OBJBROWSER_VERTEX")));
59 QPixmap image1 (resMgr->loadPixmap("GEOM", tr("ICON_OBJBROWSER_EDGE")));
60 QPixmap image2 (resMgr->loadPixmap("GEOM", tr("ICON_OBJBROWSER_FACE")));
61 QPixmap image3 (resMgr->loadPixmap("GEOM", tr("ICON_OBJBROWSER_SOLID")));
62 QPixmap iconSelect (resMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
64 setCaption( myMode == CreateGroup ? tr( "CREATE_GROUP_TITLE" ) : tr( "EDIT_GROUP_TITLE" ) );
66 // Shape type button group
67 GroupConstructors->setEnabled( myMode == CreateGroup );
68 GroupConstructors->setTitle( tr( "SHAPE_TYPE" ) );
69 RadioButton1->setPixmap( image0 );
70 RadioButton2->setPixmap( image1 );
71 RadioButton3->setPixmap( image2 );
72 RadioButton4->setPixmap( image3 );
76 GroupBoxName->setTitle( tr( "GROUP_NAME" ) );
78 // Main shape and sub-shapes
79 GroupMedium = new QGroupBox( 1, Qt::Vertical, tr( "MAIN_SUB_SHAPES" ), this );
80 GroupMedium->setInsideMargin( 10 );
81 Layout1->addWidget( GroupMedium, 2, 0 );
83 QWidget* aFrame = new QWidget( GroupMedium );
84 QGridLayout* aMedLayout = new QGridLayout( aFrame, 4, 4, 0, 6 );
86 QLabel* aMainLabel = new QLabel( tr( "MAIN_SHAPE" ), aFrame );
88 mySelBtn = new QPushButton( aFrame );
89 mySelBtn->setPixmap( iconSelect );
90 mySelBtn->setEnabled( myMode == CreateGroup );
92 myMainName = new QLineEdit( aFrame );
93 myMainName->setReadOnly( true );
94 myMainName->setEnabled( myMode == CreateGroup );
96 mySelSubBtn = new QPushButton( tr( "SELECT_SUB_SHAPES" ), aFrame );
97 mySelAllBtn = new QPushButton( tr( "SELECT_ALL" ), aFrame );
98 myAddBtn = new QPushButton( tr( "ADD" ), aFrame );
99 myRemBtn = new QPushButton( tr( "REMOVE" ), aFrame );
100 myIdList = new QListBox( aFrame );
102 myIdList->setSelectionMode( QListBox::Extended );
103 myIdList->setRowMode( QListBox::FitToWidth );
105 aMedLayout->addWidget( aMainLabel, 0, 0 );
106 aMedLayout->addWidget( mySelBtn, 0, 1 );
107 aMedLayout->addMultiCellWidget( myMainName, 0, 0, 2, 3 );
108 aMedLayout->addMultiCellWidget( mySelSubBtn, 1, 1, 0, 2 );
109 aMedLayout->addWidget( mySelAllBtn, 1, 3 );
110 aMedLayout->addMultiCellWidget( myIdList, 2, 3, 0, 2 );
111 aMedLayout->addWidget( myAddBtn, 2, 3 );
112 aMedLayout->addWidget( myRemBtn, 3, 3 );
114 setHelpFileName("working_with_groups.htm");
119 GroupGUI_GroupDlg::~GroupGUI_GroupDlg()
124 //=================================================================================
127 //=================================================================================
128 void GroupGUI_GroupDlg::Init()
130 // san -- TODO: clear selected sub-shapes...
132 if ( myMode == CreateGroup ) {
133 initName( tr( "GROUP_PREFIX" ) );
135 // Get ready for main shape selection
136 myEditCurrentArgument = myMainName;
138 connect( GroupConstructors, SIGNAL( clicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
139 connect( mySelBtn, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
141 else if ( myMode == EditGroup && IObjectCount() ) {
142 Standard_Boolean aResult = Standard_False;
143 GEOM::GEOM_Object_var anObj =
144 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
146 if ( aResult && !CORBA::is_nil( anObj ) && anObj->GetType() == GEOM_GROUP ) {
149 ResultName->setText( GEOMBase::GetName( myGroup ) );
151 GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
152 myMainObj = anOp->GetMainShape( myGroup );
153 if ( !CORBA::is_nil( myMainObj ) )
154 myMainName->setText( GEOMBase::GetName( myMainObj ) );
156 setShapeType( (TopAbs_ShapeEnum)anOp->GetType( myGroup ) );
158 GEOM::ListOfLong_var aCurrList = anOp->GetObjects( myGroup );
159 QListBoxItem* anItem;
160 for ( int i = 0, n = aCurrList->length(); i < n; i++ ) {
161 anItem = new QListBoxText( QString( "%1" ).arg(aCurrList[i] ) );
162 myIdList->insertItem( anItem );
165 myEditCurrentArgument = 0;
169 LightApp_SelectionMgr* aSelMgr =
170 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr();
172 connect( aSelMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
174 connect( buttonOk , SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
175 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
177 connect( mySelSubBtn, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
178 connect( mySelAllBtn, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
179 connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( add() ) );
180 connect( myRemBtn, SIGNAL( clicked() ), this, SLOT( remove() ) );
181 connect( myIdList, SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) );
186 //=================================================================================
187 // function : enterEvent()
189 //=================================================================================
190 void GroupGUI_GroupDlg::enterEvent( QEvent* e )
192 if ( !buttonCancel->isEnabled() )
193 this->ActivateThisDialog();
196 //=================================================================================
197 // function : ClickOnOk()
199 //=================================================================================
200 void GroupGUI_GroupDlg::ClickOnOk()
202 if ( ClickOnApply() )
206 //=================================================================================
207 // function : ClickOnApply()
209 //=================================================================================
210 bool GroupGUI_GroupDlg::ClickOnApply()
212 if ( !onAccept( myMode == CreateGroup, true ) )
215 if ( myMode == CreateGroup )
226 //=================================================================================
227 // function : ActivateThisDialog()
229 //=================================================================================
230 void GroupGUI_GroupDlg::ActivateThisDialog()
232 GEOMBase_Skeleton::ActivateThisDialog();
234 connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
235 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
240 //=================================================================================
241 // function : LineEditReturnPressed()
243 //=================================================================================
244 void GroupGUI_GroupDlg::LineEditReturnPressed()
246 QLineEdit* send = ( QLineEdit* )sender();
248 if ( send == myMainName && !myEditCurrentArgument ) {
249 myEditCurrentArgument = myMainName;
253 GEOMBase_Skeleton::LineEditReturnPressed();
259 //=================================================================================
260 // function : SetEditCurrentArgument()
262 //=================================================================================
263 void GroupGUI_GroupDlg::SetEditCurrentArgument()
265 QPushButton* send = (QPushButton*)sender();
267 if ( send == mySelBtn )
268 myEditCurrentArgument = myMainName;
269 else if ( send == mySelSubBtn || send == mySelAllBtn )
270 myEditCurrentArgument = 0;
274 if ( send == mySelAllBtn )
275 selectAllSubShapes();
281 //=================================================================================
282 // function : SelectionIntoArgument()
283 // purpose : Called when selection has changed
284 //=================================================================================
285 void GroupGUI_GroupDlg::SelectionIntoArgument()
287 if ( myEditCurrentArgument ) { // Selection of a main shape is active
288 myEditCurrentArgument->setText( "" );
291 if ( IObjectCount() == 1 ) {
292 Standard_Boolean aResult = Standard_False;
293 GEOM::GEOM_Object_var anObj =
294 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
296 if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) {
298 myEditCurrentArgument->setText( GEOMBase::GetName( anObj ) );
304 myMainObj = GEOM::GEOM_Object::_nil();
306 else { // an attempt to synchronize list box selection with 3d viewer
310 bool isBlocked = myIdList->signalsBlocked();
311 myIdList->blockSignals( true );
312 myIdList->clearSelection();
314 TColStd_IndexedMapOfInteger aMapIndex;
316 if ( IObjectCount() == 1 ) {
317 Standard_Boolean aResult = Standard_False;
318 GEOM::GEOM_Object_var anObj =
319 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
321 if ( aResult && !anObj->_is_nil() )
322 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->
323 selectionMgr()->GetIndexes( firstIObject(), aMapIndex );
326 // try to find out and process the object browser selection
327 if ( !aMapIndex.Extent() ) {
328 globalSelection( GEOM_ALLSHAPES );
330 GEOM::ListOfGO anObjects;
331 GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
333 GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
334 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
336 for (int i = 0; i < anObjects.length(); i++)
338 GEOM::GEOM_Object_var aGeomObj = anObjects[i];
339 GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
341 if ( GEOMBase::GetShape(aGeomObj, aShape, getShapeType()) )
343 aSubObjects->length(1);
344 aSubObjects[0] = aGeomObj;
346 else if (aGeomObj->GetType() == GEOM_GROUP)
347 aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
351 for (int i = 0; i < aSubObjects->length(); i++)
354 if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) )
356 CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
358 aMapIndex.Add( anIndex );
363 if ( !myMainObj->_is_nil() )
364 localSelection( myMainObj, getShapeType() );
367 if (aMapIndex.Extent() >= 1) {
369 for ( int i = 0, n = myIdList->count(); i < n; i++ )
370 aMap.insert( myIdList->item( i )->text().toInt(), i );
372 for ( int ii = 1, nn = aMapIndex.Extent(); ii <= nn; ii++ ) {
373 if ( aMap.contains( aMapIndex( ii ) ) )
374 myIdList->setSelected( aMap[aMapIndex( ii )], true );
377 myIdList->blockSignals( isBlocked );
383 //=================================================================================
384 // function : ConstructorsClicked()
385 // purpose : Radio button management
386 //=================================================================================
387 void GroupGUI_GroupDlg::ConstructorsClicked( int constructorId )
394 //=================================================================================
395 // function : selectAllSubShapes
397 //=================================================================================
398 void GroupGUI_GroupDlg::selectAllSubShapes()
400 if ( CORBA::is_nil( myMainObj ) )
403 GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
405 GEOM::ListOfLong_var aSubShapes = aShOp->SubShapeAllIDs(myMainObj, getShapeType(), false);
406 if ( !aShOp->IsDone() )
409 bool isBlocked = myIdList->signalsBlocked();
410 myIdList->blockSignals( true );
413 QListBoxItem* anItem;
414 for ( int i = 0, n = aSubShapes->length(); i < n; i++ ) {
415 CORBA::Long anIndex = aSubShapes[i];
419 anItem = new QListBoxText( QString( "%1" ).arg( anIndex ) );
420 myIdList->insertItem( anItem );
421 myIdList->setSelected( anItem, true );
424 myIdList->blockSignals( isBlocked );
425 highlightSubShapes();
426 //updateState(); // already done in highlightSubShapes()
429 //=================================================================================
432 //=================================================================================
433 void GroupGUI_GroupDlg::add()
435 TColStd_MapOfInteger aMap;
436 for ( int i = 0, n = myIdList->count(); i < n; i++ )
437 aMap.Add( myIdList->item( i )->text().toInt() );
439 TColStd_IndexedMapOfInteger aMapIndex;
441 if ( IObjectCount() == 1 ) {
442 Standard_Boolean aResult = Standard_False;
443 GEOM::GEOM_Object_var anObj =
444 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
446 if ( aResult && !anObj->_is_nil() )
447 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->
448 selectionMgr()->GetIndexes( firstIObject(), aMapIndex );
451 // try to find out and process the object browser selection
452 if ( !aMapIndex.Extent() ) {
453 GEOM::ListOfGO anObjects;
454 GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
456 GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
457 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
459 for (int i = 0; i < anObjects.length(); i++)
461 GEOM::GEOM_Object_var aGeomObj = anObjects[i];
462 GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
464 if ( GEOMBase::GetShape(aGeomObj, aShape, getShapeType()) )
466 aSubObjects->length(1);
467 aSubObjects[0] = aGeomObj;
469 else if (aGeomObj->GetType() == GEOM_GROUP)
470 aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
474 for (int i = 0; i < aSubObjects->length(); i++)
477 if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) )
479 CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
481 aMapIndex.Add( anIndex );
487 if ( aMapIndex.Extent() >= 1 ) {
488 QListBoxItem* anItem;
489 bool isBlocked = myIdList->signalsBlocked();
490 myIdList->blockSignals( true );
492 for ( int i = 1, n = aMapIndex.Extent(); i <= n; i++ ) {
493 if ( aMap.Contains( aMapIndex( i ) ) )
496 anItem = new QListBoxText( QString( "%1" ).arg( aMapIndex( i ) ) );
497 myIdList->insertItem( anItem );
498 myIdList->setSelected( anItem, true );
501 myIdList->blockSignals( isBlocked );
507 //=================================================================================
510 //=================================================================================
511 void GroupGUI_GroupDlg::remove()
513 for ( int i = myIdList->count() - 1; i >= 0; i-- ) {
514 if ( myIdList->isSelected( i ) )
515 myIdList->removeItem( i );
521 //=================================================================================
522 // function : getConstructorId()
524 //=================================================================================
525 int GroupGUI_GroupDlg::getConstructorId() const
527 return GroupConstructors->id( GroupConstructors->selected() );
530 //=================================================================================
531 // function : getShapeType()
533 //=================================================================================
534 TopAbs_ShapeEnum GroupGUI_GroupDlg::getShapeType() const
536 switch ( getConstructorId() ) {
537 case 0: return TopAbs_VERTEX;
538 case 1: return TopAbs_EDGE;
539 case 2: return TopAbs_FACE;
540 case 3: return TopAbs_SOLID;
541 default: return TopAbs_SHAPE;
545 //=================================================================================
546 // function : setShapeType()
548 //=================================================================================
549 void GroupGUI_GroupDlg::setShapeType( const TopAbs_ShapeEnum theType )
553 case TopAbs_VERTEX: anId = 0; break;
554 case TopAbs_EDGE: anId = 1; break;
555 case TopAbs_FACE: anId = 2; break;
556 case TopAbs_SOLID: anId = 3; break;
558 GroupConstructors->setButton( anId );
562 //=================================================================================
563 // function : activateSelection
564 // purpose : Activate selection in accordance with myEditCurrentArgument
565 //=================================================================================
566 void GroupGUI_GroupDlg::activateSelection()
568 globalSelection( GEOM_ALLSHAPES );
570 if ( !myMainObj->_is_nil() && !myEditCurrentArgument ) {
571 localSelection( myMainObj, getShapeType() );
574 SelectionIntoArgument();
577 //=================================================================================
578 // function : updateState
580 //=================================================================================
581 void GroupGUI_GroupDlg::updateState()
585 TColStd_IndexedMapOfInteger aMapIndex;
587 SALOME_ListIO aSelIOs;
588 SalomeApp_Application* app = myGeomGUI->getApp();
590 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
592 aSelMgr->selectedObjects(aSelIOs);
594 if ( aSelIOs.Extent() == 1 ) {
595 Standard_Boolean aResult = Standard_False;
596 GEOM::GEOM_Object_var anObj =
597 GEOMBase::ConvertIOinGEOMObject( aSelIOs.First(), aResult );
599 if ( aResult && !anObj->_is_nil() )
600 aSelMgr->GetIndexes( aSelIOs.First(), aMapIndex );
605 // try to find out and process the object browser selection
606 if ( !aMapIndex.Extent() && !CORBA::is_nil( myMainObj ) ) {
607 GEOM::ListOfGO anObjects;
608 //GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
609 GEOMBase::ConvertListOfIOInListOfGO(aSelIOs, anObjects);
611 GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
612 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
616 for (int i = 0; i < anObjects.length(); i++)
618 GEOM::GEOM_Object_var aGeomObj = anObjects[i];
619 GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
621 if ( GEOMBase::GetShape(aGeomObj, aShape, getShapeType()) ) {
622 aSubObjects->length(1);
623 aSubObjects[0] = aGeomObj;
625 else if (aGeomObj->GetType() == GEOM_GROUP) {
626 aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
633 for (int i = 0; i < aSubObjects->length(); i++)
637 if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) )
639 CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
641 aMapIndex.Add( anIndex );
661 isAdd = aMapIndex.Extent() > 0;
663 myAddBtn->setEnabled( !myEditCurrentArgument && !CORBA::is_nil( myMainObj ) && isAdd );
665 for ( int ii = 0, nn = myIdList->count(); !hasSel && ii < nn; ii++ )
666 hasSel = myIdList->isSelected( ii );
667 myRemBtn->setEnabled( hasSel );
668 mySelSubBtn->setEnabled( !CORBA::is_nil( myMainObj ) );
669 mySelAllBtn->setEnabled( !CORBA::is_nil( myMainObj ) );
672 //=================================================================================
673 // function : selectionChanged
675 //=================================================================================
676 void GroupGUI_GroupDlg::selectionChanged()
678 highlightSubShapes();
681 //=================================================================================
682 // function : highlightSubShapes
684 //=================================================================================
685 void GroupGUI_GroupDlg::highlightSubShapes()
687 if ( CORBA::is_nil( myMainObj ) )
690 Standard_Boolean isOk;
691 char* objIOR = GEOMBase::GetIORFromObject( myMainObj );
692 Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIORinGEOMAISShape( objIOR, isOk, true );
694 if ( !isOk || aSh.IsNull() )
697 TColStd_MapOfInteger anIds;
701 for ( int ii = 0, nn = myIdList->count(); ii < nn; ii++ )
702 if ( myIdList->isSelected( ii ) )
703 anIds.Add( myIdList->item( ii )->text().toInt() );
705 LightApp_SelectionMgr* aSelMgr =
706 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr();
707 aSelMgr->clearSelected();
708 aSelMgr->AddOrRemoveIndex( aSh->getIO(), anIds, false );
715 //=================================================================================
716 // function : createOperation
718 //=================================================================================
719 GEOM::GEOM_IOperations_ptr GroupGUI_GroupDlg::createOperation()
721 return getGeomEngine()->GetIGroupOperations( getStudyId() );
724 #define RETURN_WITH_MSG(a, b) \
730 //=================================================================================
731 // function : isValid()
732 // purpose : Verify validity of input data
733 //=================================================================================
734 bool GroupGUI_GroupDlg::isValid( QString& theMessage )
736 SalomeApp_Study* study = getStudy();
738 RETURN_WITH_MSG ( !study->studyDS()->GetProperties()->IsLocked(), tr( "GEOM_STUDY_LOCKED" ) )
740 if ( myMode == CreateGroup ) {
741 RETURN_WITH_MSG( !CORBA::is_nil( myMainObj ), tr( "NO_MAIN_OBJ" ) )
744 RETURN_WITH_MSG( !CORBA::is_nil( myMainObj ), tr( "NO_GROUP" ) )
747 QString aName (getNewObjectName());
748 RETURN_WITH_MSG ( !aName.stripWhiteSpace().isEmpty(), tr( "EMPTY_NAME" ) )
750 RETURN_WITH_MSG ( myIdList->count(), tr( "EMPTY_LIST" ) )
754 //=================================================================================
755 // function : execute
757 //=================================================================================
758 bool GroupGUI_GroupDlg::execute( ObjectList& objects )
760 GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow(getOperation());
762 GEOM::GEOM_Object_var aGroup;
763 if (myMode == CreateGroup)
764 aGroup = anOp->CreateGroup(myMainObj, getShapeType());
765 else if (myMode == EditGroup)
768 if (CORBA::is_nil(aGroup) || (myMode == CreateGroup && !anOp->IsDone()))
771 GEOM::ListOfLong_var aCurrList = anOp->GetObjects(aGroup);
775 if (aCurrList->length() > 0)
777 anOp->DifferenceIDs(aGroup, aCurrList);
782 int ii, nn = myIdList->count();
785 GEOM::ListOfLong_var aNewList = new GEOM::ListOfLong;
786 aNewList->length(nn);
787 for (ii = 0; ii < nn; ii++) {
788 aNewList[ii] = myIdList->item(ii)->text().toInt();
790 anOp->UnionIDs(aGroup, aNewList);
795 SalomeApp_Study* study = getStudy();
797 char* objIOR = GEOMBase::GetIORFromObject( aGroup );
798 string IOR( objIOR );
801 _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) );
803 _PTR(StudyBuilder) aBuilder (study->studyDS()->NewBuilder());
804 aBuilder->SetName( SO, getNewObjectName() );
809 objects.push_back( aGroup._retn() );
814 //================================================================
815 // Function : getFather
816 // Purpose : Get father object for object to be added in study
817 // ( called with addInStudy method )
818 //================================================================
819 GEOM::GEOM_Object_ptr GroupGUI_GroupDlg::getFather( GEOM::GEOM_Object_ptr theObj )
821 GEOM::GEOM_Object_var aFatherObj;
822 if ( theObj->GetType() == GEOM_GROUP ) {
823 GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
824 aFatherObj = anOp->GetMainShape( theObj );
826 return aFatherObj._retn();