X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_SelectionMgr.cpp;h=f32ed5012b18c7180f8eab47693b092b19e3cd19;hb=176403004ff97696f3c0b5f8bdf48692177fb34a;hp=11e2e76fc4190ce292a8b5ca4fe37a1e49407681;hpb=d7341d62e08a5185a7184de4f4c74c6c4a76ca15;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp old mode 100644 new mode 100755 index 11e2e76fc..f32ed5012 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -19,6 +19,10 @@ #include #include #include +#include + +#include +#include #include @@ -61,6 +65,8 @@ void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& the aContext->AddOrRemoveSelected(anOwner, isUpdateViewer); } } + ModuleBase_Tools::selectionInfo(aContext, + "XGUI_SelectionMgr::setSelectedOwners -- AddOrRemoveSelected"); } //************************************************************** @@ -93,21 +99,33 @@ void XGUI_SelectionMgr::updateSelectedOwners(bool isUpdateViewer) //************************************************************** void XGUI_SelectionMgr::onObjectBrowserSelection() { - QList aSelectedPrs = + QList aSelectedPrs = myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Browser); - QList aTmpList = aSelectedPrs; + QList aTmpList = aSelectedPrs; ObjectPtr aObject; FeaturePtr aFeature; - foreach(ModuleBase_ViewerPrs aPrs, aTmpList) { - aObject = aPrs.object(); + foreach(ModuleBase_ViewerPrsPtr aPrs, aTmpList) { + aObject = aPrs->object(); if (aObject.get()) { aFeature = std::dynamic_pointer_cast(aObject); if (aFeature.get()) { const std::list> aResList = aFeature->results(); + ResultPtr aResult; + ResultCompSolidPtr aCompSolid; std::list::const_iterator aIt; for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) { - aSelectedPrs.append(ModuleBase_ViewerPrs((*aIt), GeomShapePtr(), NULL)); + aResult = (*aIt); + aSelectedPrs.append(std::shared_ptr( + new ModuleBase_ViewerPrs(aResult, GeomShapePtr(), NULL))); + aCompSolid = std::dynamic_pointer_cast(aResult); + if (aCompSolid.get()) { + for (int i = 0; i < aCompSolid->numberOfSubs(); i++) { + ResultBodyPtr aResult = aCompSolid->subResult(i); + aSelectedPrs.append(std::shared_ptr( + new ModuleBase_ViewerPrs(aResult, aResult->shape(), NULL))); + } + } } } } @@ -120,25 +138,28 @@ void XGUI_SelectionMgr::onObjectBrowserSelection() //************************************************************** void XGUI_SelectionMgr::onViewerSelection() { + SessionPtr aMgr = ModelAPI_Session::get(); + DocumentPtr anActiveDocument = aMgr->activeDocument(); QObjectPtrList aFeatures; - Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); - if (!aContext.IsNull()) { - QList aPresentations = selection()->getSelected(ModuleBase_ISelection::Viewer); - foreach(ModuleBase_ViewerPrs aPrs, aPresentations) { - if (aPrs.object().get()) - aFeatures.append(aPrs.object()); - } - } - // Add features by selected results - QObjectPtrList aTmpList = aFeatures; ResultPtr aResult; FeaturePtr aFeature; - foreach(ObjectPtr aObj, aTmpList) { - aResult = std::dynamic_pointer_cast(aObj); - if (aResult.get()) { - aFeature = ModelAPI_Feature::feature(aResult); - if (aFeature.get() && (!aFeatures.contains(aFeature))) - aFeatures.append(aFeature); + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + if (!aContext.IsNull()) { + QList aPresentations = + selection()->getSelected(ModuleBase_ISelection::Viewer); + foreach(ModuleBase_ViewerPrsPtr aPrs, aPresentations) { + if (aPrs->object().get()) { + if (!aFeatures.contains(aPrs->object())) + aFeatures.append(aPrs->object()); + if (aPrs->shape().get()) { + aResult = std::dynamic_pointer_cast(aPrs->object()); + if (aResult.get()) { + aFeature = anActiveDocument->producedByFeature(aResult, aPrs->shape()); + if (aFeature.get() && (!aFeatures.contains(aFeature))) + aFeatures.append(aFeature); + } + } + } } } bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true); @@ -151,7 +172,7 @@ void XGUI_SelectionMgr::onViewerSelection() //************************************************************** void XGUI_SelectionMgr::updateSelectionBy(const ModuleBase_ISelection::SelectionPlace& thePlace) { - QList aSelectedPrs = + QList aSelectedPrs = myWorkshop->selector()->selection()->getSelected(thePlace); if (thePlace == ModuleBase_ISelection::Browser) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); @@ -167,7 +188,7 @@ void XGUI_SelectionMgr::clearSelection() myWorkshop->objectBrowser()->setObjectsSelected(aFeatures); myWorkshop->objectBrowser()->blockSignals(aBlocked); - QList aSelectedPrs = + QList aSelectedPrs = myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Browser); XGUI_Displayer* aDisplayer = myWorkshop->displayer();