1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_SketcherMgr.cpp
4 // Created: 19 Dec 2014
5 // Author: Vitaly SMETANNIKOV
7 #include "PartSet_SketcherMgr.h"
8 #include "PartSet_Module.h"
9 #include "PartSet_WidgetPoint2d.h"
10 #include "PartSet_Tools.h"
12 #include <XGUI_ModuleConnector.h>
13 #include <XGUI_Displayer.h>
14 #include <XGUI_Workshop.h>
15 #include <XGUI_Selection.h>
16 #include <XGUI_SelectionMgr.h>
18 #include <ModuleBase_IViewer.h>
19 #include <ModuleBase_IWorkshop.h>
20 #include <ModuleBase_IViewWindow.h>
21 #include <ModuleBase_Operation.h>
22 #include <ModuleBase_ISelection.h>
23 #include <ModuleBase_IPropertyPanel.h>
24 #include <ModuleBase_Operation.h>
26 #include <GeomDataAPI_Point2D.h>
28 #include <Events_Loop.h>
30 #include <SketchPlugin_Line.h>
31 #include <SketchPlugin_Sketch.h>
32 #include <SketchPlugin_Point.h>
33 #include <SketchPlugin_Arc.h>
34 #include <SketchPlugin_Circle.h>
35 #include <SketchPlugin_ConstraintLength.h>
36 #include <SketchPlugin_ConstraintDistance.h>
37 #include <SketchPlugin_ConstraintParallel.h>
38 #include <SketchPlugin_ConstraintPerpendicular.h>
39 #include <SketchPlugin_ConstraintRadius.h>
40 #include <SketchPlugin_ConstraintRigid.h>
42 #include <SelectMgr_IndexedMapOfOwner.hxx>
43 #include <StdSelect_BRepOwner.hxx>
45 #include <ModelAPI_Events.h>
47 #include <QMouseEvent>
48 #include <QApplication>
51 /// Returns list of unique objects by sum of objects from List1 and List2
52 /*QList<ModuleBase_ViewerPrs> getSumList(const QList<ModuleBase_ViewerPrs>& theList1,
53 const QList<ModuleBase_ViewerPrs>& theList2)
55 QList<ModuleBase_ViewerPrs> aRes;
56 foreach (ModuleBase_ViewerPrs aPrs, theList1) {
57 if (!aRes.contains(aPrs))
60 foreach (ModuleBase_ViewerPrs aPrs, theList2) {
61 if (!aRes.contains(aPrs))
67 void fillFeature2Attribute(const QList<ModuleBase_ViewerPrs>& theList,
68 QMap<FeaturePtr, QList<AttributePtr> >& theFeature2AttributeMap,
69 const FeaturePtr theSketch)
71 QList<ModuleBase_ViewerPrs> aRes;
73 QList<ModuleBase_ViewerPrs>::const_iterator anIt = theList.begin(),
74 aLast = theList.end();
75 for (; anIt != aLast; anIt++)
77 ModuleBase_ViewerPrs aPrs = *anIt;
78 FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs.object());
79 if (aFeature.get() == NULL)
82 QList<AttributePtr> anAttributes;
83 if (theFeature2AttributeMap.contains(aFeature)) {
84 anAttributes = theFeature2AttributeMap[aFeature];
87 TopoDS_Shape aShape = aPrs.shape();
88 if (!aShape.IsNull()) {
89 if (aShape.ShapeType() == TopAbs_VERTEX) {
90 anAttr = PartSet_Tools::findAttributeBy2dPoint(aFeature, aShape, theSketch);
91 if (anAttr.get() != NULL && !anAttributes.contains(anAttr))
92 anAttributes.push_back(anAttr);
95 theFeature2AttributeMap[aFeature] = anAttributes;
102 PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
103 : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false)
105 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
106 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
108 myPreviousSelectionEnabled = true;//aViewer->isSelectionEnabled();
110 connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
111 this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*)));
113 connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
114 this, SLOT(onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*)));
116 connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
117 this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
119 connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)),
120 this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
123 PartSet_SketcherMgr::~PartSet_SketcherMgr()
125 if (!myPlaneFilter.IsNull())
126 myPlaneFilter.Nullify();
129 void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
132 if (!(theEvent->buttons() & Qt::LeftButton))
135 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
136 ModuleBase_Operation* aOperation = aWorkshop->currentOperation();
137 // Use only for sketch operations
138 if (aOperation && myCurrentSketch) {
139 if (!PartSet_Tools::sketchPlane(myCurrentSketch))
142 bool isSketcher = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
143 bool isSketchOpe = sketchOperationIdList().contains(aOperation->id());
145 // Avoid non-sketch operations
146 if ((!isSketchOpe) && (!isSketcher))
149 bool isEditing = aOperation->isEditOperation();
151 // Ignore creation sketch operation
152 if ((!isSketcher) && (!isEditing))
155 // MoveTo in order to highlight current object
156 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
157 aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
159 // Remember highlighted objects for editing
160 ModuleBase_ISelection* aSelect = aWorkshop->selection();
161 QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
162 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
163 myFeature2AttributeMap.clear();
165 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
167 fillFeature2Attribute(aHighlighted, myFeature2AttributeMap, myCurrentSketch);
168 fillFeature2Attribute(aSelected, myFeature2AttributeMap, myCurrentSketch);
171 fillFeature2Attribute(aHighlighted, myFeature2AttributeMap, myCurrentSketch);
174 if (myFeature2AttributeMap.empty()) {
175 if (isSketchOpe && (!isSketcher))
176 // commit previous operation
177 if (!aOperation->commit())
185 get2dPoint(theWnd, theEvent, myCurX, myCurY);
189 } else if (isSketchOpe && isEditing) {
190 // If selected another object commit current result
191 aOperation->commit();
194 get2dPoint(theWnd, theEvent, myCurX, myCurY);
197 // This is necessary in order to finalize previous operation
198 QApplication::processEvents();
204 void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
206 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
207 ModuleBase_Operation* aOp = aWorkshop->currentOperation();
210 if (!sketchOperationIdList().contains(aOp->id()))
213 // Only for sketcher operations
214 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
216 aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
217 myIsDragging = false;
220 myFeature2AttributeMap.clear();
222 // Reselect edited object
223 /*aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
224 if (theEvent->modifiers() & Qt::ShiftModifier)
225 aViewer->AISContext()->ShiftSelect();
227 aViewer->AISContext()->Select();
234 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
237 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
238 // 1. it is necessary to save current selection in order to restore it after the features moving
239 FeatureToSelectionMap aCurrentSelection;
240 getCurrentSelection(myFeature2AttributeMap, myCurrentSketch, aWorkshop, aCurrentSelection);
242 // 2. the enable selection in the viewer should be temporary switched off in order to ignore
243 // mouse press signal in the viewer(it call Select for AIS context and the dragged objects are
244 // deselected). This flag should be restored in the slot, processed the mouse release signal.
245 ModuleBase_IViewer* aViewer = myModule->workshop()->viewer();
246 aViewer->enableSelection(false);
248 ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
249 if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
250 return; // No edit operation activated
252 Handle(V3d_View) aView = theWnd->v3dView();
253 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
255 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
256 double dX = aX - myCurX;
257 double dY = aY - myCurY;
259 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
260 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
261 // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
262 // viewer happens by deselect/select the modified objects. The flag should be restored after
263 // the selection processing. The update viewer should be also called.
264 bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
266 static Events_ID aMoveEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
267 //static Events_ID aUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
269 FeatureToAttributesMap::const_iterator anIt = myFeature2AttributeMap.begin(),
270 aLast = myFeature2AttributeMap.end();
271 // 4. the features and attributes modification(move)
272 for (; anIt != aLast; anIt++) {
273 FeaturePtr aFeature = anIt.key();
275 AttributeList anAttributes = anIt.value();
276 // Process selection by attribute: the priority to the attribute
277 if (!anAttributes.empty()) {
278 AttributeList::const_iterator anAttIt = anAttributes.begin(), anAttLast = anAttributes.end();
279 for (; anAttIt != anAttLast; anAttIt++) {
280 AttributePtr anAttr = *anAttIt;
281 if (anAttr.get() == NULL)
283 std::string aAttrId = anAttr->id();
284 DataPtr aData = aFeature->data();
285 if (aData.get() != NULL) {
286 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
287 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
288 if (aPoint.get() != NULL) {
289 bool isImmutable = aPoint->setImmutable(true);
290 aPoint->move(dX, dY);
291 ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
292 aPoint->setImmutable(isImmutable);
297 // Process selection by feature
298 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
299 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
300 if (aSketchFeature) {
301 aSketchFeature->move(dX, dY);
302 ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent);
306 Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
307 //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations
309 // 5. it is necessary to save current selection in order to restore it after the features moving
310 FeatureToSelectionMap::const_iterator aSIt = aCurrentSelection.begin(),
311 aSLast = aCurrentSelection.end();
312 SelectMgr_IndexedMapOfOwner anOwnersToSelect;
313 for (; aSIt != aSLast; aSIt++) {
314 anOwnersToSelect.Clear();
315 getSelectionOwners(aSIt->first, myCurrentSketch, aWorkshop, aCurrentSelection,
317 aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
320 // 6. restore the update viewer flag and call this update
321 aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
322 aDisplayer->updateViewer();
329 void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
331 ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
332 if (aOperation && aOperation->isEditOperation()) {
333 std::string aId = aOperation->id().toStdString();
334 if ((aId == SketchPlugin_ConstraintLength::ID()) ||
335 (aId == SketchPlugin_ConstraintDistance::ID()) ||
336 (aId == SketchPlugin_ConstraintRadius::ID()))
338 // Activate dimension value editing on double click
339 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
340 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
341 // Find corresponded widget to activate value editing
342 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
343 if (aWgt->attributeID() == "ConstraintValue") {
352 void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
353 double& theX, double& theY)
355 Handle(V3d_View) aView = theWnd->v3dView();
356 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
357 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, theX, theY);
360 void PartSet_SketcherMgr::launchEditing()
362 // there should be activate the vertex selection mode because the edit can happens by the selected
365 aModes << TopAbs_VERTEX << TopAbs_EDGE;
366 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
367 aConnector->activateSubShapesSelection(aModes);
369 if (!myFeature2AttributeMap.empty()) {
370 FeaturePtr aFeature = myFeature2AttributeMap.begin().key();
371 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
372 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
374 myModule->editFeature(aSPFeature);
381 QStringList PartSet_SketcherMgr::sketchOperationIdList()
383 static QStringList aIds;
384 if (aIds.size() == 0) {
385 aIds << SketchPlugin_Line::ID().c_str();
386 aIds << SketchPlugin_Point::ID().c_str();
387 aIds << SketchPlugin_Arc::ID().c_str();
388 aIds << SketchPlugin_Circle::ID().c_str();
389 aIds << SketchPlugin_ConstraintLength::ID().c_str();
390 aIds << SketchPlugin_ConstraintDistance::ID().c_str();
391 aIds << SketchPlugin_ConstraintRigid::ID().c_str();
392 aIds << SketchPlugin_ConstraintRadius::ID().c_str();
393 aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
394 aIds << SketchPlugin_ConstraintParallel::ID().c_str();
399 void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
401 // Display all sketcher sub-Objects
402 myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
403 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
404 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
406 // Hide sketcher result
407 std::list<ResultPtr> aResults = myCurrentSketch->results();
408 std::list<ResultPtr>::const_iterator aIt;
409 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
410 aDisplayer->erase((*aIt), false);
412 aDisplayer->erase(myCurrentSketch, false);
414 // Display sketcher objects
415 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
416 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
417 std::list<ResultPtr> aResults = aFeature->results();
418 std::list<ResultPtr>::const_iterator aIt;
419 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
420 aDisplayer->display((*aIt), false);
422 aDisplayer->display(aFeature, false);
425 if (myPlaneFilter.IsNull())
426 myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
428 myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
429 if (theOperation->isEditOperation()) {
430 // If it is editing of sketch then it means that plane is already defined
431 std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
432 myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
434 aDisplayer->updateViewer();
437 void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
439 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
440 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
442 DataPtr aData = myCurrentSketch->data();
443 if ((!aData) || (!aData->isValid())) {
444 // The sketch was aborted
445 myCurrentSketch = CompositeFeaturePtr();
446 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
448 // Erase all sketcher objects
449 QStringList aSketchIds = sketchOperationIdList();
450 QObjectPtrList aObjects = aDisplayer->displayedObjects();
451 foreach (ObjectPtr aObj, aObjects) {
452 DataPtr aObjData = aObj->data();
453 if ((!aObjData) || (!aObjData->isValid()))
454 aDisplayer->erase(aObj);
458 // Hide all sketcher sub-Objects
459 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
460 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
461 std::list<ResultPtr> aResults = aFeature->results();
462 std::list<ResultPtr>::const_iterator aIt;
463 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
464 aDisplayer->erase((*aIt), false);
466 aDisplayer->erase(aFeature, false);
468 // Display sketcher result
469 std::list<ResultPtr> aResults = myCurrentSketch->results();
470 std::list<ResultPtr>::const_iterator aIt;
471 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
472 aDisplayer->display((*aIt), false);
474 aDisplayer->display(myCurrentSketch);
476 myCurrentSketch = CompositeFeaturePtr();
477 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
478 aDisplayer->updateViewer();
482 void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
484 myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
487 void PartSet_SketcherMgr::getCurrentSelection(const FeatureToAttributesMap& theFeatureToAttributes,
488 const FeaturePtr& theSketch,
489 ModuleBase_IWorkshop* theWorkshop,
490 FeatureToSelectionMap& theSelection)
492 FeatureToAttributesMap::const_iterator anIt = theFeatureToAttributes.begin(),
493 aLast = theFeatureToAttributes.end();
494 for (; anIt != aLast; anIt++) {
495 FeaturePtr aFeature = anIt.key();
496 getCurrentSelection(aFeature, theSketch, theWorkshop, theSelection);
500 void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
501 const FeaturePtr& theSketch,
502 ModuleBase_IWorkshop* theWorkshop,
503 FeatureToSelectionMap& theSelection)
505 if (theFeature.get() == NULL)
508 std::set<AttributePtr> aSelectedAttributes;
509 std::set<ResultPtr> aSelectedResults;
511 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
512 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
513 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
514 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
516 std::list<ResultPtr> aResults = theFeature->results();
517 std::list<ResultPtr>::const_iterator aIt;
518 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
520 ResultPtr aResult = *aIt;
521 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
522 if (aAISObj.get() == NULL)
524 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
525 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
527 Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(
528 aContext->SelectedOwner());
529 if (aBRepOwner.IsNull())
531 Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(
532 aBRepOwner->Selectable());
533 if (aBRepOwner->HasShape()) {
534 const TopoDS_Shape& aShape = aBRepOwner->Shape();
535 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
536 if (aShapeType == TopAbs_VERTEX) {
537 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature,
539 if (aPntAttr.get() != NULL)
540 aSelectedAttributes.insert(aPntAttr);
542 else if (aShapeType == TopAbs_EDGE &&
543 aSelectedResults.find(aResult) == aSelectedResults.end()) {
544 aSelectedResults.insert(aResult);
549 theSelection[theFeature] = std::make_pair(aSelectedAttributes, aSelectedResults);
552 void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
553 const FeaturePtr& theSketch,
554 ModuleBase_IWorkshop* theWorkshop,
555 //const std::set<AttributePtr>& theSelectedAttributes,
556 //const std::set<ResultPtr>& theSelectedResults,
557 const FeatureToSelectionMap& theSelection,
558 SelectMgr_IndexedMapOfOwner& anOwnersToSelect)
560 if (theFeature.get() == NULL)
563 FeatureToSelectionMap::const_iterator anIt = theSelection.find(theFeature);
564 std::set<AttributePtr> aSelectedAttributes = anIt->second.first;
565 std::set<ResultPtr> aSelectedResults = anIt->second.second;
567 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
568 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
569 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
570 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
572 std::list<ResultPtr> aResults = theFeature->results();
573 std::list<ResultPtr>::const_iterator aIt;
574 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
576 ResultPtr aResult = *aIt;
577 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
578 if (aAISObj.get() == NULL)
580 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
582 SelectMgr_IndexedMapOfOwner aSelectedOwners;
583 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
584 for ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) {
585 Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i));
586 if ( anOwner.IsNull() || !anOwner->HasShape() )
588 const TopoDS_Shape& aShape = anOwner->Shape();
589 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
590 if (aShapeType == TopAbs_VERTEX) {
591 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature, aShape, theSketch);
592 if (aPntAttr.get() != NULL &&
593 aSelectedAttributes.find(aPntAttr) != aSelectedAttributes.end()) {
594 anOwnersToSelect.Add(anOwner);
597 else if (aShapeType == TopAbs_EDGE) {
598 bool aFound = aSelectedResults.find(aResult) != aSelectedResults.end();
599 if (aSelectedResults.find(aResult) != aSelectedResults.end() &&
600 anOwnersToSelect.FindIndex(anOwner) <= 0)
601 anOwnersToSelect.Add(anOwner);