1 // Copyright (C) 2007-2010 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 // GEOM GEOMGUI : GUI for Geometry component
23 // File : EntityGUI_SubShapeDlg.cxx
24 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26 #include "EntityGUI_SubShapeDlg.h"
29 #include <GeometryGUI.h>
32 #include <OCCViewer_ViewModel.h>
33 #include <SVTK_ViewModel.h>
34 #include <SalomeApp_Study.h>
35 #include <SalomeApp_Application.h>
36 #include <LightApp_SelectionMgr.h>
37 #include <SALOME_ListIteratorOfListIO.hxx>
39 #include <SUIT_Desktop.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SUIT_Session.h>
42 #include <SUIT_ViewManager.h>
43 #include <SUIT_ViewWindow.h>
46 #include <TopExp_Explorer.hxx>
47 #include <TopoDS_Iterator.hxx>
48 #include <TopTools_MapOfShape.hxx>
49 #include <TopTools_IndexedMapOfShape.hxx>
51 #include <TColStd_IndexedMapOfInteger.hxx>
53 #include <QMessageBox>
55 #include <GEOMImpl_Types.hxx>
57 //=================================================================================
58 // class : EntityGUI_SubShapeDlg
59 // purpose : Constructs a EntityGUI_SubShapeDlg which is a child of 'parent', with the
60 // name 'name' and widget flags set to 'f'.
61 // The dialog will by default be modeless, unless you set 'modal' to
62 // TRUE to construct a modal dialog.
63 //=================================================================================
64 EntityGUI_SubShapeDlg::EntityGUI_SubShapeDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
65 bool modal, Qt::WindowFlags fl)
66 : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
68 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SUBSHAPE")));
69 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
71 setWindowTitle(tr("GEOM_SUBSHAPE_TITLE"));
73 /***************************************************************/
74 mainFrame()->GroupConstructors->setTitle(tr("GEOM_SUB_SHAPE"));
75 mainFrame()->RadioButton1->setIcon(image0);
76 mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
77 mainFrame()->RadioButton2->close();
78 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
79 mainFrame()->RadioButton3->close();
81 GroupPoints = new DlgRef_1Sel1List1Check3Btn(centralWidget());
83 GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
84 GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
85 GroupPoints->TextLabel2->setText(tr("GEOM_SUBSHAPE_TYPE"));
86 GroupPoints->CheckButton1->setText(tr("GEOM_SUBSHAPE_SELECT"));
87 GroupPoints->PushButton1->setIcon(image1);
88 GroupPoints->PushButton2->setText(tr("SHOW_ONLY_SELECTED"));
89 GroupPoints->PushButton3->setText(tr("HIDE_SELECTED"));
90 GroupPoints->PushButton4->setText(tr("SHOW_ALL_SUB_SHAPES"));
91 GroupPoints->LineEdit1->setReadOnly(true);
93 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
94 layout->setMargin(0); layout->setSpacing(6);
95 layout->addWidget(GroupPoints);
96 /***************************************************************/
98 setIsOptimizedBrowsing(true);
100 setHelpFileName("create_explode_page.html");
102 mainFrame()->GroupBoxName->hide();
107 //=================================================================================
108 // function : ~EntityGUI_SubShapeDlg()
109 // purpose : Destroys the object and frees any allocated resources
110 //=================================================================================
111 EntityGUI_SubShapeDlg::~EntityGUI_SubShapeDlg()
115 //=================================================================================
118 //=================================================================================
119 void EntityGUI_SubShapeDlg::Init()
122 myEditCurrentArgument = GroupPoints->LineEdit1;
123 myObject = GEOM::GEOM_Object::_nil();
127 /* type for sub shape selection */
128 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compound");
129 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compsolid");
130 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Solid");
131 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shell");
132 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Face");
133 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Wire");
134 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Edge");
135 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Vertex");
136 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
138 if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType()
139 != OCCViewer_Viewer::Type())
140 GroupPoints->CheckButton1->setEnabled(false);
142 /* signals and slots connections */
143 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
145 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
146 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
148 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
149 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
151 connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged()));
152 connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(SubShapeToggled()));
154 connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
155 connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
156 connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
158 connect(myGeomGUI->getApp()->selectionMgr(),
159 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
163 SelectionIntoArgument();
166 //=================================================================================
167 // function : enterEvent()
169 //=================================================================================
170 void EntityGUI_SubShapeDlg::enterEvent(QEvent*)
172 if (!mainFrame()->GroupConstructors->isEnabled())
173 ActivateThisDialog();
176 //=================================================================================
177 // function : ActivateThisDialog()
179 //=================================================================================
180 void EntityGUI_SubShapeDlg::ActivateThisDialog()
182 GEOMBase_Skeleton::ActivateThisDialog();
183 connect(myGeomGUI->getApp()->selectionMgr(),
184 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
189 //=================================================================================
190 //function : closeEvent
191 //purpose : remove temporary geom object
192 //=================================================================================
193 void EntityGUI_SubShapeDlg::closeEvent(QCloseEvent* e)
196 GEOMBase_Skeleton::closeEvent(e);
199 //=================================================================================
200 // function : ClickOnOk()
202 //=================================================================================
203 void EntityGUI_SubShapeDlg::ClickOnOk()
205 setIsApplyAndClose(true);
207 SUIT_Session::session()->activeApplication()->putInfo("");
209 /* Explode all sub shapes */
211 if (isAllSubShapes()) {
212 /* More than 30 subshapes : ask confirmation */
213 unsigned int nb = NumberOfSubShapes(myShape, shapeType());
215 const QString caption = tr("GEOM_CONFIRM");
216 const QString text = tr("GEOM_CONFIRM_INFO").arg(nb);
217 const QString button0 = tr("GEOM_BUT_EXPLODE");
218 const QString button1 = tr("GEOM_BUT_CANCEL");
220 if (QMessageBox::warning(this, caption, text, button0, button1) != 0)
221 isOk = false; /* aborted */
232 //=================================================================================
233 // function : ClickOnApply()
235 //=================================================================================
236 bool EntityGUI_SubShapeDlg::ClickOnApply()
238 SUIT_Session::session()->activeApplication()->putInfo("");
240 /* Explode all sub shapes */
241 if (isAllSubShapes()) {
242 /* More than 30 subshapes : ask confirmation */
243 unsigned int nb = NumberOfSubShapes(myShape, shapeType());
245 const QString caption = tr("GEOM_CONFIRM");
246 const QString text = tr("GEOM_CONFIRM_INFO").arg(nb);
247 const QString button0 = tr("GEOM_BUT_EXPLODE");
248 const QString button1 = tr("GEOM_BUT_CANCEL");
250 if (QMessageBox::warning(this, caption, text, button0, button1) != 0)
251 return false; /* aborted */
255 bool isOk = onAccept();
257 // restore selection, corresponding to current selection mode
263 //=================================================================================
264 // function : SelectionIntoArgument()
265 // purpose : Called when selection has changed or other case
266 //=================================================================================
267 void EntityGUI_SubShapeDlg::SelectionIntoArgument()
269 if (!isAllSubShapes())
272 ResetStateOfDialog();
274 QString aString = ""; /* name of selection */
276 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
277 SALOME_ListIO aSelList;
278 aSelMgr->selectedObjects(aSelList);
280 int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
284 Handle(SALOME_InteractiveObject) IO = aSelList.First();
285 if (!IO->hasEntry()) {
286 SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
291 TopoDS_Shape S = GEOMBase::GetTopoFromSelection(aSelList);
292 if (S.IsNull() || S.ShapeType() == TopAbs_VERTEX) {
293 myObject = GEOM::GEOM_Object::_nil();
298 myObject = GEOMBase::ConvertIOinGEOMObject(IO);
299 if (myObject->_is_nil()) {
305 GroupPoints->LineEdit1->setText(aString);
307 int SelectedShapeType = GroupPoints->ComboBox1->currentIndex();
308 int count = GroupPoints->ComboBox1->count();
315 if (myShape.ShapeType() == TopAbs_COMPOUND) {
316 unsigned int nb = NumberOfSubShapes(myShape, TopAbs_COMPOUND);
320 while (i <= myShape.ShapeType()) {
321 GroupPoints->ComboBox1->removeItem(0);
325 if (myShape.ShapeType() == TopAbs_COMPOUND) {
326 if (myWithShape == false) {
327 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
332 if (myWithShape == true) {
333 GroupPoints->ComboBox1->removeItem(GroupPoints->ComboBox1->count() - 1);
338 int count1 = GroupPoints->ComboBox1->count();
342 if (SelectedShapeType > myShape.ShapeType()) {
343 if (SelectedShapeType == 8) {
344 if (myShape.ShapeType() != TopAbs_COMPOUND) {
345 GroupPoints->ComboBox1->setCurrentIndex(0);
350 GroupPoints->ComboBox1->setCurrentIndex(count1 - count + SelectedShapeType);
353 GroupPoints->ComboBox1->setCurrentIndex(0);
360 //=================================================================================
361 // function : SetEditCurrentArgument()
363 //=================================================================================
364 void EntityGUI_SubShapeDlg::SetEditCurrentArgument()
366 GroupPoints->LineEdit1->setFocus();
367 myEditCurrentArgument = GroupPoints->LineEdit1;
369 GroupPoints->CheckButton1->setChecked(false);
371 SelectionIntoArgument();
374 //=================================================================================
375 // function : LineEditReturnPressed()
377 //=================================================================================
378 void EntityGUI_SubShapeDlg::LineEditReturnPressed()
380 QLineEdit* send = (QLineEdit*)sender();
381 if (send == GroupPoints->LineEdit1)
382 SetEditCurrentArgument();
386 GEOMBase_Skeleton::LineEditReturnPressed();
389 //=================================================================================
390 // function : ResetStateOfDialog()
391 // purpose : Completely reset the state of method including local context
392 //=================================================================================
393 void EntityGUI_SubShapeDlg::ResetStateOfDialog()
395 myObject = GEOM::GEOM_Object::_nil();
397 myEditCurrentArgument->setText("");
399 int SelectedShapeType = GroupPoints->ComboBox1->currentIndex();
400 int count = GroupPoints->ComboBox1->count();
404 /* type for sub shape selection */
405 GroupPoints->ComboBox1->clear();
406 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compound");
407 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compsolid");
408 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Solid");
409 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shell");
410 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Face");
411 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Wire");
412 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Edge");
413 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Vertex");
414 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
418 GroupPoints->ComboBox1->setCurrentIndex(8 - count + SelectedShapeType);
424 //=================================================================================
425 // function : SubShapeToggled()
426 // purpose : Allow user selection of all or only selected sub shapes
427 // : Called when 'CheckButton1' state change
428 //=================================================================================
429 void EntityGUI_SubShapeDlg::SubShapeToggled()
431 GroupPoints->PushButton2->setEnabled(!isAllSubShapes());
432 GroupPoints->PushButton3->setEnabled(!isAllSubShapes());
433 GroupPoints->PushButton4->setEnabled(!isAllSubShapes());
438 //=================================================================================
439 // function : ComboTextChanged()
441 //=================================================================================
442 void EntityGUI_SubShapeDlg::ComboTextChanged()
444 /* Select sub shapes mode not checked */
449 //=================================================================================
450 // function : NumberOfSubShapes()
452 //=================================================================================
453 unsigned int EntityGUI_SubShapeDlg::NumberOfSubShapes(const TopoDS_Shape& S,
454 const int shapeType) const
459 unsigned int index = 0;
460 TopTools_MapOfShape M;
462 if (S.ShapeType() == TopAbs_COMPOUND &&
463 (TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE ||
464 TopAbs_ShapeEnum(shapeType) == TopAbs_COMPSOLID ||
465 TopAbs_ShapeEnum(shapeType) == TopAbs_COMPOUND)) {
466 TopoDS_Iterator It(S, Standard_True, Standard_True);
467 for (; It.More(); It.Next()) {
468 if (M.Add(It.Value())) {
469 if (TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE ||
470 TopAbs_ShapeEnum(shapeType) == It.Value().ShapeType()) {
477 TopExp_Explorer Exp (S, TopAbs_ShapeEnum(shapeType));
478 for (; Exp.More(); Exp.Next()) {
479 if (M.Add(Exp.Current())) {
489 //=================================================================================
490 // function : updateButtonState
492 //=================================================================================
493 void EntityGUI_SubShapeDlg::updateButtonState()
495 if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() != OCCViewer_Viewer::Type() ||
496 myObject->_is_nil() || shapeType() == TopAbs_SHAPE || shapeType() == TopAbs_COMPOUND) {
497 GroupPoints->CheckButton1->setChecked(false);
498 GroupPoints->CheckButton1->setEnabled(false);
501 GroupPoints->CheckButton1->setEnabled(true);
504 //=================================================================================
505 // function : isAllSubShapes
507 //=================================================================================
508 bool EntityGUI_SubShapeDlg::isAllSubShapes() const
510 return !GroupPoints->CheckButton1->isChecked() || !GroupPoints->CheckButton1->isEnabled();
513 //=================================================================================
514 // function : shapeType
516 //=================================================================================
517 int EntityGUI_SubShapeDlg::shapeType() const
519 int type = GroupPoints->ComboBox1->currentIndex();
521 if (myObject->_is_nil())
525 type += myShape.ShapeType() + 1;
526 if (myShape.ShapeType() == TopAbs_COMPOUND &&
527 NumberOfSubShapes(myShape, TopAbs_COMPOUND) > 0) {
534 //=================================================================================
535 // function : showOnlySelected
537 //=================================================================================
538 void EntityGUI_SubShapeDlg::showOnlySelected()
540 if (CORBA::is_nil(myObject) || isAllSubShapes())
543 QPushButton* send = (QPushButton*)sender();
544 if (send == GroupPoints->PushButton4) {
549 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
550 SALOME_ListIO aSelList;
551 aSelMgr->selectedObjects(aSelList);
553 GEOM_Displayer* aDisplayer = getDisplayer();
555 if (send == GroupPoints->PushButton3) {
556 aDisplayer->Erase(aSelList, false, true);
559 aDisplayer->EraseAll();
560 aDisplayer->Display(aSelList, true);
564 //=================================================================================
565 // function : getSelectedSubshapes
567 //=================================================================================
568 int EntityGUI_SubShapeDlg::getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMapIndex)
572 SalomeApp_Application* app = myGeomGUI->getApp();
573 if (!app || myObject->_is_nil())
576 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
577 SALOME_ListIO aSelList;
578 aSelMgr->selectedObjects(aSelList);
580 // try to find out and process the global selection
581 // (of not published objects and of published sub-shapes)
583 SALOME_ListIteratorOfListIO anIter (aSelList);
584 for (int i = 0; anIter.More(); anIter.Next(), i++)
586 Handle(SALOME_InteractiveObject) anIObj = anIter.Value();
587 QString anEntry = anIObj->getEntry();
589 int index = anEntry.lastIndexOf(str);
590 if (index > 0) // selection among special preview
592 anEntry.remove(0, index+1);
593 int anIndex = anEntry.toInt();
595 theMapIndex.Add(anIndex);
597 else // selection among published shapes
599 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
600 if (!appStudy) return 0;
601 _PTR(Study) aStudy = appStudy->studyDS();
603 _PTR(SObject) aSObj (aStudy->FindObjectID(anEntry.toLatin1().constData()));
604 GEOM::GEOM_Object_var aGeomObj =
605 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObj));
607 if (GEOMBase::GetShape(aGeomObj, aShape)) {
608 if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == (TopAbs_ShapeEnum)shapeType()) {
609 TopTools_IndexedMapOfShape aMainMap;
610 TopExp::MapShapes(myShape, aMainMap);
612 TopExp_Explorer anExp (aShape, (TopAbs_ShapeEnum)shapeType());
613 for (; anExp.More(); anExp.Next()) {
614 TopoDS_Shape aSubShape = anExp.Current();
615 int anIndex = aMainMap.FindIndex(aSubShape);
617 theMapIndex.Add(anIndex);
626 return theMapIndex.Extent();
629 //=================================================================================
630 // function : activateSelection
631 // purpose : Activate selection in accordance with myEditCurrentArgument
632 //=================================================================================
633 void EntityGUI_SubShapeDlg::activateSelection()
638 if (!myObject->_is_nil() && !isAllSubShapes())
640 GEOM_Displayer* aDisplayer = getDisplayer();
641 aDisplayer->Erase(myObject, false, false);
643 int prevDisplayMode = aDisplayer->SetDisplayMode(0);
645 SUIT_ViewWindow* aViewWindow = 0;
646 SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
648 aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
649 if (aViewWindow == 0) return;
651 SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
652 if (aViewManager->getType() != OCCViewer_Viewer::Type() &&
653 aViewManager->getType() != SVTK_Viewer::Type())
656 SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
657 SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
658 if (aView == 0) return;
660 //TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject);
662 TopTools_IndexedMapOfShape aSubShapesMap;
663 TopExp::MapShapes(myShape, aSubShapesMap);
664 CORBA::String_var aMainEntry = myObject->GetStudyEntry();
665 QString anEntryBase = aMainEntry.in();
667 TopExp_Explorer anExp (myShape, (TopAbs_ShapeEnum)shapeType());
668 for (; anExp.More(); anExp.Next())
670 TopoDS_Shape aSubShape = anExp.Current();
671 int index = aSubShapesMap.FindIndex(aSubShape);
672 QString anEntry = anEntryBase + QString("_%1").arg(index);
674 SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
676 displayPreview(aPrs, true, false); // append, do not update
679 aDisplayer->UpdateViewer();
680 aDisplayer->SetDisplayMode(prevDisplayMode);
683 globalSelection(GEOM_ALLSHAPES);
686 //=================================================================================
687 // function : createOperation
689 //=================================================================================
690 GEOM::GEOM_IOperations_ptr EntityGUI_SubShapeDlg::createOperation()
692 return getGeomEngine()->GetIShapesOperations(getStudyId());
695 //=================================================================================
696 // function : isValid
698 //=================================================================================
699 bool EntityGUI_SubShapeDlg::isValid (QString& msg)
703 if (myObject->_is_nil()) {
708 if (isAllSubShapes())
711 TColStd_IndexedMapOfInteger aMapIndex;
712 int nbSel = getSelectedSubshapes(aMapIndex);
716 msg += tr("NO_SUBSHAPES_SELECTED");
722 //=================================================================================
723 // function : execute
725 //=================================================================================
726 bool EntityGUI_SubShapeDlg::execute (ObjectList& objects)
728 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
730 if (!isAllSubShapes()) {
732 TColStd_IndexedMapOfInteger aMapIndex;
733 int nbSel = getSelectedSubshapes(aMapIndex);
738 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
739 anArray->length(nbSel);
741 for (i = 1; i <= nbSel; i++)
742 anArray[i - 1] = aMapIndex.FindKey(i);
744 GEOM::ListOfGO_var aList = anOper->MakeSubShapes(myObject, anArray);
745 int n = aList->length();
746 for (i = 0; i < n; i++)
747 objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
751 GEOM::ListOfGO_var aList = anOper->ExtractSubShapes(myObject, shapeType(), true);
752 if (!aList->length())
754 for (int i = 0, n = aList->length(); i < n; i++)
755 objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
758 return objects.size();
761 //================================================================
762 // Function : getFather
763 // Purpose : Get father object for object to be added in study
764 // (called with addInStudy method)
765 //================================================================
766 GEOM::GEOM_Object_ptr EntityGUI_SubShapeDlg::getFather(GEOM::GEOM_Object_ptr)
771 //================================================================
772 // Function : getNewObjectName
774 //================================================================
775 QString EntityGUI_SubShapeDlg::getNewObjectName() const
777 return QString::null;