1 // Copyright (C) 2007-2013 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),
72 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SUBSHAPE")));
73 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
75 setWindowTitle(tr("GEOM_SUBSHAPE_TITLE"));
77 /***************************************************************/
78 mainFrame()->GroupConstructors->setTitle(tr("GEOM_SUB_SHAPE"));
79 mainFrame()->RadioButton1->setIcon(image0);
80 mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
81 mainFrame()->RadioButton2->close();
82 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
83 mainFrame()->RadioButton3->close();
85 GroupPoints = new DlgRef_1Sel1List1Check3Btn(centralWidget());
87 GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
88 GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
89 GroupPoints->TextLabel2->setText(tr("GEOM_SUBSHAPE_TYPE"));
90 GroupPoints->CheckButton1->setText(tr("GEOM_SUBSHAPE_SELECT"));
91 GroupPoints->PushButton1->setIcon(image1);
92 GroupPoints->PushButton2->setText(tr("SHOW_ONLY_SELECTED"));
93 GroupPoints->PushButton3->setText(tr("HIDE_SELECTED"));
94 GroupPoints->PushButton4->setText(tr("SHOW_ALL_SUB_SHAPES"));
95 GroupPoints->LineEdit1->setReadOnly(true);
97 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
98 layout->setMargin(0); layout->setSpacing(6);
99 layout->addWidget(GroupPoints);
100 /***************************************************************/
102 setIsOptimizedBrowsing(true);
104 setHelpFileName("create_explode_page.html");
106 mainFrame()->GroupBoxName->hide();
111 //=================================================================================
112 // function : ~EntityGUI_SubShapeDlg()
113 // purpose : Destroys the object and frees any allocated resources
114 //=================================================================================
115 EntityGUI_SubShapeDlg::~EntityGUI_SubShapeDlg()
117 if (myIsHiddenMain) {
118 GEOM_Displayer* aDisplayer = getDisplayer();
119 aDisplayer->Display(myObject);
120 myIsHiddenMain = false;
125 //=================================================================================
128 //=================================================================================
129 void EntityGUI_SubShapeDlg::Init()
133 myEditCurrentArgument = GroupPoints->LineEdit1;
134 myObject = GEOM::GEOM_Object::_nil();
138 /* type for sub-shape selection */
139 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compound");
140 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compsolid");
141 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Solid");
142 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shell");
143 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Face");
144 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Wire");
145 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Edge");
146 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Vertex");
147 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
149 if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType()
150 != OCCViewer_Viewer::Type())
151 GroupPoints->CheckButton1->setEnabled(false);
153 /* signals and slots connections */
154 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
156 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
157 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
159 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
160 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
162 connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged()));
163 connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(SubShapeToggled()));
165 connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
166 connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
167 connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
169 connect(myGeomGUI->getApp()->selectionMgr(),
170 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
174 SelectionIntoArgument();
177 //=================================================================================
178 // function : enterEvent()
180 //=================================================================================
181 void EntityGUI_SubShapeDlg::enterEvent(QEvent*)
183 if (!mainFrame()->GroupConstructors->isEnabled())
184 ActivateThisDialog();
187 //=================================================================================
188 // function : ActivateThisDialog()
190 //=================================================================================
191 void EntityGUI_SubShapeDlg::ActivateThisDialog()
193 GEOMBase_Skeleton::ActivateThisDialog();
194 connect(myGeomGUI->getApp()->selectionMgr(),
195 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
200 //=================================================================================
201 //function : closeEvent
202 //purpose : remove temporary geom object
203 //=================================================================================
204 void EntityGUI_SubShapeDlg::closeEvent(QCloseEvent* e)
207 GEOMBase_Skeleton::closeEvent(e);
210 //=================================================================================
211 // function : ClickOnOk()
213 //=================================================================================
214 void EntityGUI_SubShapeDlg::ClickOnOk()
216 setIsApplyAndClose(true);
218 SUIT_Session::session()->activeApplication()->putInfo("");
220 /* Explode all sub-shapes */
222 if (isAllSubShapes()) {
223 /* More than 30 sub-shapes : ask confirmation */
224 unsigned int nb = NumberOfSubShapes(myShape, shapeType());
226 const QString caption = tr("GEOM_CONFIRM");
227 const QString text = tr("GEOM_CONFIRM_INFO").arg(nb);
228 const QString button0 = tr("GEOM_BUT_EXPLODE");
229 const QString button1 = tr("GEOM_BUT_CANCEL");
231 if (QMessageBox::warning(this, caption, text, button0, button1) != 0)
232 isOk = false; /* aborted */
243 //=================================================================================
244 // function : ClickOnApply()
246 //=================================================================================
247 bool EntityGUI_SubShapeDlg::ClickOnApply()
249 SUIT_Session::session()->activeApplication()->putInfo("");
251 /* Explode all sub-shapes */
252 if (isAllSubShapes()) {
253 /* More than 30 sub-shapes : ask confirmation */
254 unsigned int nb = NumberOfSubShapes(myShape, shapeType());
256 const QString caption = tr("GEOM_CONFIRM");
257 const QString text = tr("GEOM_CONFIRM_INFO").arg(nb);
258 const QString button0 = tr("GEOM_BUT_EXPLODE");
259 const QString button1 = tr("GEOM_BUT_CANCEL");
261 if (QMessageBox::warning(this, caption, text, button0, button1) != 0)
262 return false; /* aborted */
266 setIsDisableBrowsing( true );
267 bool isOk = onAccept( true, true, false );
268 setIsDisableBrowsing( false );
270 // restore selection, corresponding to current selection mode
276 //=================================================================================
277 // function : SelectionIntoArgument()
278 // purpose : Called when selection has changed or other case
279 //=================================================================================
280 void EntityGUI_SubShapeDlg::SelectionIntoArgument()
282 if (!isAllSubShapes())
285 ResetStateOfDialog();
287 QString aString = ""; /* name of selection */
289 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
290 SALOME_ListIO aSelList;
291 aSelMgr->selectedObjects(aSelList);
293 int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
297 Handle(SALOME_InteractiveObject) IO = aSelList.First();
298 if (!IO->hasEntry()) {
299 SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
304 if (myIsHiddenMain) {
305 GEOM_Displayer* aDisplayer = getDisplayer();
306 aDisplayer->Display(myObject);
307 myIsHiddenMain = false;
310 TopoDS_Shape S = GEOMBase::GetTopoFromSelection(aSelList);
311 if (S.IsNull() || S.ShapeType() == TopAbs_VERTEX) {
312 myObject = GEOM::GEOM_Object::_nil();
317 myObject = GEOMBase::ConvertIOinGEOMObject(IO);
318 if (myObject->_is_nil()) {
324 GroupPoints->LineEdit1->setText(aString);
326 int SelectedShapeType = GroupPoints->ComboBox1->currentIndex();
327 int count = GroupPoints->ComboBox1->count();
334 if (myShape.ShapeType() == TopAbs_COMPOUND) {
335 unsigned int nb = NumberOfSubShapes(myShape, TopAbs_COMPOUND);
339 while (i <= myShape.ShapeType()) {
340 GroupPoints->ComboBox1->removeItem(0);
344 if (myShape.ShapeType() == TopAbs_COMPOUND) {
345 if (myWithShape == false) {
346 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
351 if (myWithShape == true) {
352 GroupPoints->ComboBox1->removeItem(GroupPoints->ComboBox1->count() - 1);
357 int count1 = GroupPoints->ComboBox1->count();
361 if (SelectedShapeType > myShape.ShapeType()) {
362 if (SelectedShapeType == 8) {
363 if (myShape.ShapeType() != TopAbs_COMPOUND) {
364 GroupPoints->ComboBox1->setCurrentIndex(0);
369 GroupPoints->ComboBox1->setCurrentIndex(count1 - count + SelectedShapeType);
372 GroupPoints->ComboBox1->setCurrentIndex(0);
379 //=================================================================================
380 // function : SetEditCurrentArgument()
382 //=================================================================================
383 void EntityGUI_SubShapeDlg::SetEditCurrentArgument()
385 GroupPoints->LineEdit1->setFocus();
386 myEditCurrentArgument = GroupPoints->LineEdit1;
388 GroupPoints->CheckButton1->setChecked(false);
390 SelectionIntoArgument();
393 //=================================================================================
394 // function : LineEditReturnPressed()
396 //=================================================================================
397 void EntityGUI_SubShapeDlg::LineEditReturnPressed()
399 QLineEdit* send = (QLineEdit*)sender();
400 if (send == GroupPoints->LineEdit1)
401 SetEditCurrentArgument();
405 GEOMBase_Skeleton::LineEditReturnPressed();
408 //=================================================================================
409 // function : ResetStateOfDialog()
410 // purpose : Completely reset the state of method including local context
411 //=================================================================================
412 void EntityGUI_SubShapeDlg::ResetStateOfDialog()
414 if (myIsHiddenMain) {
415 GEOM_Displayer* aDisplayer = getDisplayer();
416 aDisplayer->Display(myObject);
417 myIsHiddenMain = false;
419 myObject = GEOM::GEOM_Object::_nil();
421 myEditCurrentArgument->setText("");
423 int SelectedShapeType = GroupPoints->ComboBox1->currentIndex();
424 int count = GroupPoints->ComboBox1->count();
428 /* type for sub-shape selection */
429 GroupPoints->ComboBox1->clear();
430 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compound");
431 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compsolid");
432 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Solid");
433 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shell");
434 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Face");
435 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Wire");
436 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Edge");
437 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Vertex");
438 GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
442 GroupPoints->ComboBox1->setCurrentIndex(8 - count + SelectedShapeType);
444 // to avoid recursion: SelectionIntoArgument->ResetStateOfDialog->ComboTextChanged->SubShapeToggled->activateSelection->(currentSelectionChanged)->SelectionIntoArgument
445 //ComboTextChanged();
450 //=================================================================================
451 // function : SubShapeToggled()
452 // purpose : Allow user selection of all or only selected sub-shapes
453 // : Called when 'CheckButton1' state change
454 //=================================================================================
455 void EntityGUI_SubShapeDlg::SubShapeToggled()
457 GroupPoints->PushButton2->setEnabled(!isAllSubShapes());
458 GroupPoints->PushButton3->setEnabled(!isAllSubShapes());
459 GroupPoints->PushButton4->setEnabled(!isAllSubShapes());
464 //=================================================================================
465 // function : ComboTextChanged()
467 //=================================================================================
468 void EntityGUI_SubShapeDlg::ComboTextChanged()
470 /* Select sub-shapes mode not checked */
475 //=================================================================================
476 // function : NumberOfSubShapes()
478 //=================================================================================
479 unsigned int EntityGUI_SubShapeDlg::NumberOfSubShapes(const TopoDS_Shape& S,
480 const int shapeType) const
485 unsigned int index = 0;
486 TopTools_MapOfShape M;
488 if (S.ShapeType() == TopAbs_COMPOUND &&
489 (TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE ||
490 TopAbs_ShapeEnum(shapeType) == TopAbs_COMPSOLID ||
491 TopAbs_ShapeEnum(shapeType) == TopAbs_COMPOUND)) {
492 TopoDS_Iterator It(S, Standard_True, Standard_True);
493 for (; It.More(); It.Next()) {
494 if (M.Add(It.Value())) {
495 if (TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE ||
496 TopAbs_ShapeEnum(shapeType) == It.Value().ShapeType()) {
503 TopExp_Explorer Exp (S, TopAbs_ShapeEnum(shapeType));
504 for (; Exp.More(); Exp.Next()) {
505 if (M.Add(Exp.Current())) {
515 //=================================================================================
516 // function : updateButtonState
518 //=================================================================================
519 void EntityGUI_SubShapeDlg::updateButtonState()
521 if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() != OCCViewer_Viewer::Type() ||
522 myObject->_is_nil() || shapeType() == TopAbs_SHAPE || shapeType() == TopAbs_COMPOUND) {
523 GroupPoints->CheckButton1->setChecked(false);
524 GroupPoints->CheckButton1->setEnabled(false);
527 GroupPoints->CheckButton1->setEnabled(true);
530 //=================================================================================
531 // function : isAllSubShapes
533 //=================================================================================
534 bool EntityGUI_SubShapeDlg::isAllSubShapes() const
536 return !GroupPoints->CheckButton1->isChecked() || !GroupPoints->CheckButton1->isEnabled();
539 //=================================================================================
540 // function : shapeType
542 //=================================================================================
543 int EntityGUI_SubShapeDlg::shapeType() const
545 int type = GroupPoints->ComboBox1->currentIndex();
547 if (myObject->_is_nil())
551 type += myShape.ShapeType() + 1;
552 if (myShape.ShapeType() == TopAbs_COMPOUND &&
553 NumberOfSubShapes(myShape, TopAbs_COMPOUND) > 0) {
560 //=================================================================================
561 // function : showOnlySelected
563 //=================================================================================
564 void EntityGUI_SubShapeDlg::showOnlySelected()
566 if (CORBA::is_nil(myObject) || isAllSubShapes())
569 QPushButton* send = (QPushButton*)sender();
570 if (send == GroupPoints->PushButton4) {
575 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
576 SALOME_ListIO aSelList;
577 aSelMgr->selectedObjects(aSelList);
579 GEOM_Displayer* aDisplayer = getDisplayer();
581 if (send == GroupPoints->PushButton3) {
582 aDisplayer->Erase(aSelList, /*forced=*/false, /*updateViewer=*/true);
585 // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
586 SALOME_View* view = GEOM_Displayer::GetActiveView();
588 CORBA::String_var aMainEntry = myObject->GetStudyEntry();
589 Handle(SALOME_InteractiveObject) io =
590 new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
591 if (view->isVisible(io)) myIsHiddenMain = true;
594 aDisplayer->EraseAll(/*forced = false, updateViewer = true*/);
595 aDisplayer->Display(aSelList, true);
597 // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
598 if ((TopAbs_ShapeEnum)shapeType() == TopAbs_VERTEX && myIsHiddenMain) {
599 aDisplayer->Display(myObject);
604 //=================================================================================
605 // function : getSelectedSubshapes
607 //=================================================================================
608 int EntityGUI_SubShapeDlg::getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMapIndex)
612 SalomeApp_Application* app = myGeomGUI->getApp();
613 if (!app || myObject->_is_nil())
616 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
617 SALOME_ListIO aSelList;
618 aSelMgr->selectedObjects(aSelList);
620 // try to find out and process the global selection
621 // (of not published objects and of published sub-shapes)
623 SALOME_ListIteratorOfListIO anIter (aSelList);
624 for (int i = 0; anIter.More(); anIter.Next(), i++)
626 Handle(SALOME_InteractiveObject) anIObj = anIter.Value();
627 QString anEntry = anIObj->getEntry();
629 int index = anEntry.lastIndexOf(str);
630 if (index > 0) // selection among special preview
632 anEntry.remove(0, index+1);
633 int anIndex = anEntry.toInt();
635 theMapIndex.Add(anIndex);
637 else // selection among published shapes
639 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
640 if (!appStudy) return 0;
641 _PTR(Study) aStudy = appStudy->studyDS();
643 _PTR(SObject) aSObj (aStudy->FindObjectID(anEntry.toLatin1().constData()));
644 GEOM::GEOM_Object_var aGeomObj =
645 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObj));
647 if (GEOMBase::GetShape(aGeomObj, aShape)) {
648 if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == (TopAbs_ShapeEnum)shapeType()) {
649 TopTools_IndexedMapOfShape aMainMap;
650 TopExp::MapShapes(myShape, aMainMap);
652 TopExp_Explorer anExp (aShape, (TopAbs_ShapeEnum)shapeType());
653 for (; anExp.More(); anExp.Next()) {
654 TopoDS_Shape aSubShape = anExp.Current();
655 int anIndex = aMainMap.FindIndex(aSubShape);
657 theMapIndex.Add(anIndex);
666 return theMapIndex.Extent();
669 //=================================================================================
670 // function : activateSelection
671 // purpose : Activate selection in accordance with myEditCurrentArgument
672 //=================================================================================
673 void EntityGUI_SubShapeDlg::activateSelection()
675 bool isApply = ((QPushButton*)sender() == buttonApply());
681 if (!myObject->_is_nil() && !isAllSubShapes())
683 GEOM_Displayer* aDisplayer = getDisplayer();
685 //display mode for main shape
686 if ( myDmMode == -1 ) {
687 SALOME_View* view = GEOM_Displayer::GetActiveView();
689 CORBA::String_var aMainEntry = myObject->GetStudyEntry();
690 Handle(SALOME_InteractiveObject) io =
691 new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
692 if ( view->isVisible( io ) ) {
693 Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIOinGEOMAISShape( io, true );
695 myDmMode = aSh->isTopLevel() ? aSh->prevDisplayMode() : aSh->DisplayMode();
697 // Hide main shape, if explode on VERTEX
698 if (shapeType() != TopAbs_VERTEX) {
699 aDisplayer->Erase(myObject, false, false);
700 myIsHiddenMain = true;
704 myDmMode = SUIT_Session::session()->resourceMgr()->integerValue( "Geometry", "display_mode" );
707 // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
708 if (shapeType() == TopAbs_VERTEX) {
710 aDisplayer->Display(myObject);
712 aDisplayer->SetDisplayMode(myDmMode);
715 SUIT_ViewWindow* aViewWindow = 0;
716 SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
718 aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
719 if (aViewWindow == 0) return;
721 SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
722 if (aViewManager->getType() != OCCViewer_Viewer::Type() &&
723 aViewManager->getType() != SVTK_Viewer::Type())
726 SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
727 SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
728 if (aView == 0) return;
730 //TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject);
732 TopTools_IndexedMapOfShape aSubShapesMap;
733 TopExp::MapShapes(myShape, aSubShapesMap);
734 CORBA::String_var aMainEntry = myObject->GetStudyEntry();
735 QString anEntryBase = aMainEntry.in();
737 TopExp_Explorer anExp (myShape, (TopAbs_ShapeEnum)shapeType());
738 for (; anExp.More(); anExp.Next())
740 TopoDS_Shape aSubShape = anExp.Current();
741 int index = aSubShapesMap.FindIndex(aSubShape);
742 QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
744 SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
746 displayPreview(aPrs, true, false); // append, do not update
749 aDisplayer->UnsetDisplayMode();
750 aDisplayer->UpdateViewer();
754 globalSelection(GEOM_ALLSHAPES);
757 //=================================================================================
758 // function : createOperation
760 //=================================================================================
761 GEOM::GEOM_IOperations_ptr EntityGUI_SubShapeDlg::createOperation()
763 return getGeomEngine()->GetIShapesOperations(getStudyId());
766 //=================================================================================
767 // function : isValid
769 //=================================================================================
770 bool EntityGUI_SubShapeDlg::isValid (QString& msg)
774 if (myObject->_is_nil()) {
779 if (isAllSubShapes())
782 TColStd_IndexedMapOfInteger aMapIndex;
783 int nbSel = getSelectedSubshapes(aMapIndex);
787 msg += tr("NO_SUBSHAPES_SELECTED");
793 //=================================================================================
794 // function : execute
796 //=================================================================================
797 bool EntityGUI_SubShapeDlg::execute (ObjectList& objects)
799 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
801 if (!isAllSubShapes()) {
803 TColStd_IndexedMapOfInteger aMapIndex;
804 int nbSel = getSelectedSubshapes(aMapIndex);
809 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
810 anArray->length(nbSel);
812 for (i = 1; i <= nbSel; i++)
813 anArray[i - 1] = aMapIndex.FindKey(i);
815 GEOM::ListOfGO_var aList = anOper->MakeSubShapes(myObject, anArray);
816 int n = aList->length();
817 for (i = 0; i < n; i++)
818 objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
822 GEOM::ListOfGO_var aList = anOper->ExtractSubShapes(myObject, shapeType(), true);
823 if (!aList->length())
825 for (int i = 0, n = aList->length(); i < n; i++)
826 objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
829 return objects.size();
832 //================================================================
833 // Function : getFather
834 // Purpose : Get father object for object to be added in study
835 // (called with addInStudy method)
836 //================================================================
837 GEOM::GEOM_Object_ptr EntityGUI_SubShapeDlg::getFather(GEOM::GEOM_Object_ptr)
842 //================================================================
843 // Function : getNewObjectName
845 //================================================================
846 QString EntityGUI_SubShapeDlg::getNewObjectName (int) const
848 return QString::null;