-void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
- const FeaturePtr& theSketch,
- ModuleBase_IWorkshop* theWorkshop,
- FeatureToSelectionMap& theSelection)
-{
- if (theFeature.get() == NULL)
- return;
-
- std::set<AttributePtr> aSelectedAttributes;
- std::set<ResultPtr> aSelectedResults;
-
- ModuleBase_IViewer* aViewer = theWorkshop->viewer();
- Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
- if (!aContext.IsNull()) {
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
- XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
-
- std::list<ResultPtr> aResults = theFeature->results();
- std::list<ResultPtr>::const_iterator aIt;
- for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
- {
- ResultPtr aResult = *aIt;
- AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
- if (aAISObj.get() == NULL)
- continue;
- Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
- for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
- {
- Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
- if (anOwner->Selectable() != anAISIO)
- continue;
- getAttributesOrResults(anOwner, theFeature, theSketch, aResult,
- aSelectedAttributes, aSelectedResults);
- }
- for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
- Handle(SelectMgr_EntityOwner) anOwner = aContext->DetectedOwner();
- if (anOwner.IsNull())
- continue;
- if (anOwner->Selectable() != anAISIO)
- continue;
- getAttributesOrResults(anOwner, theFeature, theSketch, aResult,
- aSelectedAttributes, aSelectedResults);
- }
- }
- }
- theSelection[theFeature] = std::make_pair(aSelectedAttributes, aSelectedResults);
-}
-