1 // Copyright (C) 2007-2011 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
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : EntityGUI_SubShapeDlg.cxx
25 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
27 #include "EntityGUI_SubShapeDlg.h"
30 #include <GeometryGUI.h>
33 #include <OCCViewer_ViewModel.h>
34 #include <SVTK_ViewModel.h>
35 #include <SalomeApp_Study.h>
36 #include <SalomeApp_Application.h>
37 #include <LightApp_SelectionMgr.h>
38 #include <SALOME_ListIteratorOfListIO.hxx>
40 #include <SUIT_Desktop.h>
41 #include <SUIT_ResourceMgr.h>
42 #include <SUIT_Session.h>
43 #include <SUIT_ViewManager.h>
44 #include <SUIT_ViewWindow.h>
47 #include <TopExp_Explorer.hxx>
48 #include <TopoDS_Iterator.hxx>
49 #include <TopTools_MapOfShape.hxx>
50 #include <TopTools_IndexedMapOfShape.hxx>
52 #include <TColStd_IndexedMapOfInteger.hxx>
54 #include <QMessageBox>
56 #include <GEOMImpl_Types.hxx>
58 //=================================================================================
59 // class : EntityGUI_SubShapeDlg
60 // purpose : Constructs a EntityGUI_SubShapeDlg which is a child of 'parent', with the
61 // name 'name' and widget flags set to 'f'.
62 // The dialog will by default be modeless, unless you set 'modal' to
63 // TRUE to construct a modal dialog.
64 //=================================================================================
65 EntityGUI_SubShapeDlg::EntityGUI_SubShapeDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
66 bool modal, Qt::WindowFlags fl)
67 : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
69 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SUBSHAPE")));
70 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
72 setWindowTitle(tr("GEOM_SUBSHAPE_TITLE"));
74 /***************************************************************/
75 mainFrame()->GroupConstructors->setTitle(tr("GEOM_SUB_SHAPE"));
76 mainFrame()->RadioButton1->setIcon(image0);
77 mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
78 mainFrame()->RadioButton2->close();
79 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
80 mainFrame()->RadioButton3->close();
82 GroupPoints = new DlgRef_1Sel1List1Check3Btn(centralWidget());
84 GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
85 GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
86 GroupPoints->TextLabel2->setText(tr("GEOM_SUBSHAPE_TYPE"));
87 GroupPoints->CheckButton1->setText(tr("GEOM_SUBSHAPE_SELECT"));
88 GroupPoints->PushButton1->setIcon(image1);
89 GroupPoints->PushButton2->setText(tr("SHOW_ONLY_SELECTED"));
90 GroupPoints->PushButton3->setText(tr("HIDE_SELECTED"));
91 GroupPoints->PushButton4->setText(tr("SHOW_ALL_SUB_SHAPES"));
92 GroupPoints->LineEdit1->setReadOnly(true);
94 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
95 layout->setMargin(0); layout->setSpacing(6);
96 layout->addWidget(GroupPoints);
97 /***************************************************************/
99 setIsOptimizedBrowsing(true);
101 setHelpFileName("create_explode_page.html");
103 mainFrame()->GroupBoxName->hide();
108 //=================================================================================
109 // function : ~EntityGUI_SubShapeDlg()
110 // purpose : Destroys the object and frees any allocated resources
111 //=================================================================================
112 EntityGUI_SubShapeDlg::~EntityGUI_SubShapeDlg()
116 //=================================================================================
119 //=================================================================================
120 void EntityGUI_SubShapeDlg::Init()
123 myEditCurrentArgument = GroupPoints->LineEdit1;
124 myObject = GEOM::GEOM_Object::_nil();
128 /* type for sub shape selection */
129 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compound");
130 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compsolid");
131 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Solid");
132 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shell");
133 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Face");
134 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Wire");
135 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Edge");
136 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Vertex");
137 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
139 if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType()
140 != OCCViewer_Viewer::Type())
141 GroupPoints->CheckButton1->setEnabled(false);
143 /* signals and slots connections */
144 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
146 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
147 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
149 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
150 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
152 connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged()));
153 connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(SubShapeToggled()));
155 connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
156 connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
157 connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
159 connect(myGeomGUI->getApp()->selectionMgr(),
160 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
164 SelectionIntoArgument();
167 //=================================================================================
168 // function : enterEvent()
170 //=================================================================================
171 void EntityGUI_SubShapeDlg::enterEvent(QEvent*)
173 if (!mainFrame()->GroupConstructors->isEnabled())
174 ActivateThisDialog();
177 //=================================================================================
178 // function : ActivateThisDialog()
180 //=================================================================================
181 void EntityGUI_SubShapeDlg::ActivateThisDialog()
183 GEOMBase_Skeleton::ActivateThisDialog();
184 connect(myGeomGUI->getApp()->selectionMgr(),
185 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
190 //=================================================================================
191 //function : closeEvent
192 //purpose : remove temporary geom object
193 //=================================================================================
194 void EntityGUI_SubShapeDlg::closeEvent(QCloseEvent* e)
197 GEOMBase_Skeleton::closeEvent(e);
200 //=================================================================================
201 // function : ClickOnOk()
203 //=================================================================================
204 void EntityGUI_SubShapeDlg::ClickOnOk()
206 setIsApplyAndClose(true);
208 SUIT_Session::session()->activeApplication()->putInfo("");
210 /* Explode all sub shapes */
212 if (isAllSubShapes()) {
213 /* More than 30 subshapes : ask confirmation */
214 unsigned int nb = NumberOfSubShapes(myShape, shapeType());
216 const QString caption = tr("GEOM_CONFIRM");
217 const QString text = tr("GEOM_CONFIRM_INFO").arg(nb);
218 const QString button0 = tr("GEOM_BUT_EXPLODE");
219 const QString button1 = tr("GEOM_BUT_CANCEL");
221 if (QMessageBox::warning(this, caption, text, button0, button1) != 0)
222 isOk = false; /* aborted */
233 //=================================================================================
234 // function : ClickOnApply()
236 //=================================================================================
237 bool EntityGUI_SubShapeDlg::ClickOnApply()
239 SUIT_Session::session()->activeApplication()->putInfo("");
241 /* Explode all sub shapes */
242 if (isAllSubShapes()) {
243 /* More than 30 subshapes : ask confirmation */
244 unsigned int nb = NumberOfSubShapes(myShape, shapeType());
246 const QString caption = tr("GEOM_CONFIRM");
247 const QString text = tr("GEOM_CONFIRM_INFO").arg(nb);
248 const QString button0 = tr("GEOM_BUT_EXPLODE");
249 const QString button1 = tr("GEOM_BUT_CANCEL");
251 if (QMessageBox::warning(this, caption, text, button0, button1) != 0)
252 return false; /* aborted */
256 bool isOk = onAccept();
258 // restore selection, corresponding to current selection mode
264 //=================================================================================
265 // function : SelectionIntoArgument()
266 // purpose : Called when selection has changed or other case
267 //=================================================================================
268 void EntityGUI_SubShapeDlg::SelectionIntoArgument()
270 if (!isAllSubShapes())
273 ResetStateOfDialog();
275 QString aString = ""; /* name of selection */
277 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
278 SALOME_ListIO aSelList;
279 aSelMgr->selectedObjects(aSelList);
281 int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
285 Handle(SALOME_InteractiveObject) IO = aSelList.First();
286 if (!IO->hasEntry()) {
287 SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
292 TopoDS_Shape S = GEOMBase::GetTopoFromSelection(aSelList);
293 if (S.IsNull() || S.ShapeType() == TopAbs_VERTEX) {
294 myObject = GEOM::GEOM_Object::_nil();
299 myObject = GEOMBase::ConvertIOinGEOMObject(IO);
300 if (myObject->_is_nil()) {
306 GroupPoints->LineEdit1->setText(aString);
308 int SelectedShapeType = GroupPoints->ComboBox1->currentIndex();
309 int count = GroupPoints->ComboBox1->count();
316 if (myShape.ShapeType() == TopAbs_COMPOUND) {
317 unsigned int nb = NumberOfSubShapes(myShape, TopAbs_COMPOUND);
321 while (i <= myShape.ShapeType()) {
322 GroupPoints->ComboBox1->removeItem(0);
326 if (myShape.ShapeType() == TopAbs_COMPOUND) {
327 if (myWithShape == false) {
328 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
333 if (myWithShape == true) {
334 GroupPoints->ComboBox1->removeItem(GroupPoints->ComboBox1->count() - 1);
339 int count1 = GroupPoints->ComboBox1->count();
343 if (SelectedShapeType > myShape.ShapeType()) {
344 if (SelectedShapeType == 8) {
345 if (myShape.ShapeType() != TopAbs_COMPOUND) {
346 GroupPoints->ComboBox1->setCurrentIndex(0);
351 GroupPoints->ComboBox1->setCurrentIndex(count1 - count + SelectedShapeType);
354 GroupPoints->ComboBox1->setCurrentIndex(0);
361 //=================================================================================
362 // function : SetEditCurrentArgument()
364 //=================================================================================
365 void EntityGUI_SubShapeDlg::SetEditCurrentArgument()
367 GroupPoints->LineEdit1->setFocus();
368 myEditCurrentArgument = GroupPoints->LineEdit1;
370 GroupPoints->CheckButton1->setChecked(false);
372 SelectionIntoArgument();
375 //=================================================================================
376 // function : LineEditReturnPressed()
378 //=================================================================================
379 void EntityGUI_SubShapeDlg::LineEditReturnPressed()
381 QLineEdit* send = (QLineEdit*)sender();
382 if (send == GroupPoints->LineEdit1)
383 SetEditCurrentArgument();
387 GEOMBase_Skeleton::LineEditReturnPressed();
390 //=================================================================================
391 // function : ResetStateOfDialog()
392 // purpose : Completely reset the state of method including local context
393 //=================================================================================
394 void EntityGUI_SubShapeDlg::ResetStateOfDialog()
396 myObject = GEOM::GEOM_Object::_nil();
398 myEditCurrentArgument->setText("");
400 int SelectedShapeType = GroupPoints->ComboBox1->currentIndex();
401 int count = GroupPoints->ComboBox1->count();
405 /* type for sub shape selection */
406 GroupPoints->ComboBox1->clear();
407 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compound");
408 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compsolid");
409 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Solid");
410 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shell");
411 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Face");
412 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Wire");
413 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Edge");
414 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Vertex");
415 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
419 GroupPoints->ComboBox1->setCurrentIndex(8 - count + SelectedShapeType);
421 // to avoid recursion: SelectionIntoArgument->ResetStateOfDialog->ComboTextChanged->SubShapeToggled->activateSelection->(currentSelectionChanged)->SelectionIntoArgument
422 //ComboTextChanged();
427 //=================================================================================
428 // function : SubShapeToggled()
429 // purpose : Allow user selection of all or only selected sub shapes
430 // : Called when 'CheckButton1' state change
431 //=================================================================================
432 void EntityGUI_SubShapeDlg::SubShapeToggled()
434 GroupPoints->PushButton2->setEnabled(!isAllSubShapes());
435 GroupPoints->PushButton3->setEnabled(!isAllSubShapes());
436 GroupPoints->PushButton4->setEnabled(!isAllSubShapes());
441 //=================================================================================
442 // function : ComboTextChanged()
444 //=================================================================================
445 void EntityGUI_SubShapeDlg::ComboTextChanged()
447 /* Select sub shapes mode not checked */
452 //=================================================================================
453 // function : NumberOfSubShapes()
455 //=================================================================================
456 unsigned int EntityGUI_SubShapeDlg::NumberOfSubShapes(const TopoDS_Shape& S,
457 const int shapeType) const
462 unsigned int index = 0;
463 TopTools_MapOfShape M;
465 if (S.ShapeType() == TopAbs_COMPOUND &&
466 (TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE ||
467 TopAbs_ShapeEnum(shapeType) == TopAbs_COMPSOLID ||
468 TopAbs_ShapeEnum(shapeType) == TopAbs_COMPOUND)) {
469 TopoDS_Iterator It(S, Standard_True, Standard_True);
470 for (; It.More(); It.Next()) {
471 if (M.Add(It.Value())) {
472 if (TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE ||
473 TopAbs_ShapeEnum(shapeType) == It.Value().ShapeType()) {
480 TopExp_Explorer Exp (S, TopAbs_ShapeEnum(shapeType));
481 for (; Exp.More(); Exp.Next()) {
482 if (M.Add(Exp.Current())) {
492 //=================================================================================
493 // function : updateButtonState
495 //=================================================================================
496 void EntityGUI_SubShapeDlg::updateButtonState()
498 if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() != OCCViewer_Viewer::Type() ||
499 myObject->_is_nil() || shapeType() == TopAbs_SHAPE || shapeType() == TopAbs_COMPOUND) {
500 GroupPoints->CheckButton1->setChecked(false);
501 GroupPoints->CheckButton1->setEnabled(false);
504 GroupPoints->CheckButton1->setEnabled(true);
507 //=================================================================================
508 // function : isAllSubShapes
510 //=================================================================================
511 bool EntityGUI_SubShapeDlg::isAllSubShapes() const
513 return !GroupPoints->CheckButton1->isChecked() || !GroupPoints->CheckButton1->isEnabled();
516 //=================================================================================
517 // function : shapeType
519 //=================================================================================
520 int EntityGUI_SubShapeDlg::shapeType() const
522 int type = GroupPoints->ComboBox1->currentIndex();
524 if (myObject->_is_nil())
528 type += myShape.ShapeType() + 1;
529 if (myShape.ShapeType() == TopAbs_COMPOUND &&
530 NumberOfSubShapes(myShape, TopAbs_COMPOUND) > 0) {
537 //=================================================================================
538 // function : showOnlySelected
540 //=================================================================================
541 void EntityGUI_SubShapeDlg::showOnlySelected()
543 if (CORBA::is_nil(myObject) || isAllSubShapes())
546 QPushButton* send = (QPushButton*)sender();
547 if (send == GroupPoints->PushButton4) {
552 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
553 SALOME_ListIO aSelList;
554 aSelMgr->selectedObjects(aSelList);
556 GEOM_Displayer* aDisplayer = getDisplayer();
558 if (send == GroupPoints->PushButton3) {
559 aDisplayer->Erase(aSelList, false, true);
562 aDisplayer->EraseAll();
563 aDisplayer->Display(aSelList, true);
567 //=================================================================================
568 // function : getSelectedSubshapes
570 //=================================================================================
571 int EntityGUI_SubShapeDlg::getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMapIndex)
575 SalomeApp_Application* app = myGeomGUI->getApp();
576 if (!app || myObject->_is_nil())
579 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
580 SALOME_ListIO aSelList;
581 aSelMgr->selectedObjects(aSelList);
583 // try to find out and process the global selection
584 // (of not published objects and of published sub-shapes)
586 SALOME_ListIteratorOfListIO anIter (aSelList);
587 for (int i = 0; anIter.More(); anIter.Next(), i++)
589 Handle(SALOME_InteractiveObject) anIObj = anIter.Value();
590 QString anEntry = anIObj->getEntry();
592 int index = anEntry.lastIndexOf(str);
593 if (index > 0) // selection among special preview
595 anEntry.remove(0, index+1);
596 int anIndex = anEntry.toInt();
598 theMapIndex.Add(anIndex);
600 else // selection among published shapes
602 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
603 if (!appStudy) return 0;
604 _PTR(Study) aStudy = appStudy->studyDS();
606 _PTR(SObject) aSObj (aStudy->FindObjectID(anEntry.toLatin1().constData()));
607 GEOM::GEOM_Object_var aGeomObj =
608 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObj));
610 if (GEOMBase::GetShape(aGeomObj, aShape)) {
611 if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == (TopAbs_ShapeEnum)shapeType()) {
612 TopTools_IndexedMapOfShape aMainMap;
613 TopExp::MapShapes(myShape, aMainMap);
615 TopExp_Explorer anExp (aShape, (TopAbs_ShapeEnum)shapeType());
616 for (; anExp.More(); anExp.Next()) {
617 TopoDS_Shape aSubShape = anExp.Current();
618 int anIndex = aMainMap.FindIndex(aSubShape);
620 theMapIndex.Add(anIndex);
629 return theMapIndex.Extent();
632 //=================================================================================
633 // function : activateSelection
634 // purpose : Activate selection in accordance with myEditCurrentArgument
635 //=================================================================================
636 void EntityGUI_SubShapeDlg::activateSelection()
641 if (!myObject->_is_nil() && !isAllSubShapes())
643 GEOM_Displayer* aDisplayer = getDisplayer();
644 aDisplayer->Erase(myObject, false, false);
646 int prevDisplayMode = aDisplayer->SetDisplayMode(0);
648 SUIT_ViewWindow* aViewWindow = 0;
649 SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
651 aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
652 if (aViewWindow == 0) return;
654 SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
655 if (aViewManager->getType() != OCCViewer_Viewer::Type() &&
656 aViewManager->getType() != SVTK_Viewer::Type())
659 SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
660 SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
661 if (aView == 0) return;
663 //TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject);
665 TopTools_IndexedMapOfShape aSubShapesMap;
666 TopExp::MapShapes(myShape, aSubShapesMap);
667 CORBA::String_var aMainEntry = myObject->GetStudyEntry();
668 QString anEntryBase = aMainEntry.in();
670 TopExp_Explorer anExp (myShape, (TopAbs_ShapeEnum)shapeType());
671 for (; anExp.More(); anExp.Next())
673 TopoDS_Shape aSubShape = anExp.Current();
674 int index = aSubShapesMap.FindIndex(aSubShape);
675 QString anEntry = anEntryBase + QString("_%1").arg(index);
677 SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
679 displayPreview(aPrs, true, false); // append, do not update
682 aDisplayer->UpdateViewer();
683 aDisplayer->SetDisplayMode(prevDisplayMode);
686 globalSelection(GEOM_ALLSHAPES);
689 //=================================================================================
690 // function : createOperation
692 //=================================================================================
693 GEOM::GEOM_IOperations_ptr EntityGUI_SubShapeDlg::createOperation()
695 return getGeomEngine()->GetIShapesOperations(getStudyId());
698 //=================================================================================
699 // function : isValid
701 //=================================================================================
702 bool EntityGUI_SubShapeDlg::isValid (QString& msg)
706 if (myObject->_is_nil()) {
711 if (isAllSubShapes())
714 TColStd_IndexedMapOfInteger aMapIndex;
715 int nbSel = getSelectedSubshapes(aMapIndex);
719 msg += tr("NO_SUBSHAPES_SELECTED");
725 //=================================================================================
726 // function : execute
728 //=================================================================================
729 bool EntityGUI_SubShapeDlg::execute (ObjectList& objects)
731 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
733 if (!isAllSubShapes()) {
735 TColStd_IndexedMapOfInteger aMapIndex;
736 int nbSel = getSelectedSubshapes(aMapIndex);
741 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
742 anArray->length(nbSel);
744 for (i = 1; i <= nbSel; i++)
745 anArray[i - 1] = aMapIndex.FindKey(i);
747 GEOM::ListOfGO_var aList = anOper->MakeSubShapes(myObject, anArray);
748 int n = aList->length();
749 for (i = 0; i < n; i++)
750 objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
754 GEOM::ListOfGO_var aList = anOper->ExtractSubShapes(myObject, shapeType(), true);
755 if (!aList->length())
757 for (int i = 0, n = aList->length(); i < n; i++)
758 objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
761 return objects.size();
764 //================================================================
765 // Function : getFather
766 // Purpose : Get father object for object to be added in study
767 // (called with addInStudy method)
768 //================================================================
769 GEOM::GEOM_Object_ptr EntityGUI_SubShapeDlg::getFather(GEOM::GEOM_Object_ptr)
774 //================================================================
775 // Function : getNewObjectName
777 //================================================================
778 QString EntityGUI_SubShapeDlg::getNewObjectName() const
780 return QString::null;