X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_SelectionMgr.cpp;h=ad92b420b0568a91ebf1e53bfbf049e71a6a6231;hb=1cef78af4c4328ecf99a3ced86bda38e6e82e15c;hp=8304179726f246d4106c5cef7f06256dd71a53b5;hpb=2a1ea255610239ce41c79f9dc1fe5135459c61f5;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index 830417972..ad92b420b 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -9,7 +9,9 @@ #include "XGUI_Displayer.h" #include "XGUI_Selection.h" +#ifndef HAVE_SALOME #include +#endif #include #include @@ -50,12 +52,14 @@ void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& the selection()->selectedOwners(aSelectedOwners); Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); - for (Standard_Integer i = 1, n = theSelectedOwners.Extent(); i <= n; i++) { - Handle(SelectMgr_EntityOwner) anOwner = theSelectedOwners(i); - if (aSelectedOwners.FindIndex(anOwner) > 0) - continue; + if (!aContext.IsNull()) { + for (Standard_Integer i = 1, n = theSelectedOwners.Extent(); i <= n; i++) { + Handle(SelectMgr_EntityOwner) anOwner = theSelectedOwners(i); + if (aSelectedOwners.FindIndex(anOwner) > 0) + continue; - aContext->AddOrRemoveSelected(anOwner, isUpdateViewer); + aContext->AddOrRemoveSelected(anOwner, isUpdateViewer); + } } } @@ -63,6 +67,9 @@ void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& the void XGUI_SelectionMgr::updateSelectedOwners(bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + if (aContext.IsNull()) + return; + const SelectMgr_ListOfFilter& aFilters = aContext->Filters(); SelectMgr_IndexedMapOfOwner anOwnersToDeselect; @@ -86,9 +93,11 @@ void XGUI_SelectionMgr::updateSelectedOwners(bool isUpdateViewer) //************************************************************** void XGUI_SelectionMgr::onObjectBrowserSelection() { - QObjectPtrList aObjects = myWorkshop->objectBrowser()->selectedObjects(); + QList aSelectedPrs = + myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Browser); + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - aDisplayer->setSelected(aObjects); + aDisplayer->setSelected(aSelectedPrs); emit selectionChanged(); } @@ -97,11 +106,12 @@ void XGUI_SelectionMgr::onViewerSelection() { QObjectPtrList aFeatures; Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); - for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { - Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive(); - ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO); - if (aResult) - aFeatures.append(aResult); + if (!aContext.IsNull()) { + QList aPresentations = selection()->getSelected(ModuleBase_ISelection::Viewer); + foreach(ModuleBase_ViewerPrs aPrs, aPresentations) { + if (aPrs.object().get()) + aFeatures.append(aPrs.object()); + } } bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true); myWorkshop->objectBrowser()->setObjectsSelected(aFeatures); @@ -111,34 +121,29 @@ void XGUI_SelectionMgr::onViewerSelection() } //************************************************************** -/*QFeatureList XGUI_SelectionMgr::selectedFeatures() const - { - return myWorkshop->objectBrowser()->selectedFeatures(); - } - - //************************************************************** - QModelIndexList XGUI_SelectionMgr::selectedIndexes() const - { - return myWorkshop->objectBrowser()->selectedIndexes(); - } - - //************************************************************** - void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const - { - Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); - theList.Clear(); - for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) - theList.Append(aContext->SelectedInteractive()); - } - - //************************************************************** - void XGUI_SelectionMgr::selectedShapes(NCollection_List& theList) const - { - theList.Clear(); - Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); - for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { - TopoDS_Shape aShape = aContext->SelectedShape(); - if (!aShape.IsNull()) - theList.Append(aShape); - } - }*/ +void XGUI_SelectionMgr::updateSelectionBy(const ModuleBase_ISelection::SelectionPlace& thePlace) +{ + QList aSelectedPrs = + myWorkshop->selector()->selection()->getSelected(thePlace); + if (thePlace == ModuleBase_ISelection::Browser) { + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + aDisplayer->setSelected(aSelectedPrs); + } + +} +//************************************************************** +void XGUI_SelectionMgr::clearSelection() +{ + QObjectPtrList aFeatures; + bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true); + myWorkshop->objectBrowser()->setObjectsSelected(aFeatures); + myWorkshop->objectBrowser()->blockSignals(aBlocked); + + QList aSelectedPrs = + myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Browser); + + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + aDisplayer->setSelected(aSelectedPrs); + + emit selectionChanged(); +}