Salome HOME
fd8a22ee036f59b52242c20a5305a6c0317ebc71
[modules/shaper.git] / src / PartSet / PartSet_SketcherMgr.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_SketcherMgr.cpp
4 // Created:     19 Dec 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #include "PartSet_SketcherMgr.h"
8 #include "PartSet_Module.h"
9 #include "PartSet_WidgetPoint2D.h"
10 #include "PartSet_Tools.h"
11
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>
17
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>
25
26 #include <Events_Loop.h>
27
28 #include <SketchPlugin_Line.h>
29 #include <SketchPlugin_Sketch.h>
30 #include <SketchPlugin_Point.h>
31 #include <SketchPlugin_Arc.h>
32 #include <SketchPlugin_Circle.h>
33 #include <SketchPlugin_ConstraintLength.h>
34 #include <SketchPlugin_ConstraintDistance.h>
35 #include <SketchPlugin_ConstraintParallel.h>
36 #include <SketchPlugin_ConstraintPerpendicular.h>
37 #include <SketchPlugin_ConstraintRadius.h>
38 #include <SketchPlugin_ConstraintRigid.h>
39
40 #include <SelectMgr_IndexedMapOfOwner.hxx>
41 #include <StdSelect_BRepOwner.hxx>
42
43 #include <ModelAPI_Events.h>
44
45 #include <QMouseEvent>
46 #include <QApplication>
47
48
49
50
51 /// Returns list of unique objects by sum of objects from List1 and List2
52 QList<ObjectPtr> getSumList(const QList<ModuleBase_ViewerPrs>& theList1,
53                                        const QList<ModuleBase_ViewerPrs>& theList2)
54 {
55   QList<ObjectPtr> aRes;
56   foreach (ModuleBase_ViewerPrs aPrs, theList1) {
57     if (!aRes.contains(aPrs.object()))
58       aRes.append(aPrs.object());
59   }
60   foreach (ModuleBase_ViewerPrs aPrs, theList2) {
61     if (!aRes.contains(aPrs.object()))
62       aRes.append(aPrs.object());
63   }
64   return aRes;
65 }
66
67
68
69
70 PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
71   : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false)
72 {
73   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
74   ModuleBase_IViewer* aViewer = aWorkshop->viewer();
75
76   connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
77           this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*)));
78
79   connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
80           this, SLOT(onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*)));
81
82   connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
83           this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
84
85   connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)),
86           this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
87 }
88
89 PartSet_SketcherMgr::~PartSet_SketcherMgr()
90 {
91   if (!myPlaneFilter.IsNull())
92     myPlaneFilter.Nullify();
93 }
94
95 void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
96 {
97   // 
98   if (!(theEvent->buttons() & Qt::LeftButton))
99     return;
100
101   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
102   ModuleBase_Operation* aOperation = aWorkshop->currentOperation();
103   // Use only for sketch operations
104   if (aOperation && myCurrentSketch) {
105     if (!PartSet_Tools::sketchPlane(myCurrentSketch))
106       return;
107
108     bool isSketcher = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
109     bool isSketchOpe = sketchOperationIdList().contains(aOperation->id());
110
111     // Avoid non-sketch operations
112     if ((!isSketchOpe) && (!isSketcher))
113       return;
114
115     bool isEditing = aOperation->isEditOperation();
116
117     // Ignore creation sketch operation
118     if ((!isSketcher) && (!isEditing))
119       return;
120
121     if (theEvent->modifiers()) {
122       // If user performs multiselection
123       if (isSketchOpe /* && (!isSketcher)*/)
124         if (!aOperation->commit())
125           aOperation->abort();
126       return;
127     }
128     // Remember highlighted objects for editing
129     ModuleBase_ISelection* aSelect = aWorkshop->selection();
130     QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
131     QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
132     myEditingFeatures.clear();
133     myEditingAttr.clear();
134
135     bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
136     QObjectPtrList aSelObjects;
137     if (aHasShift)
138       aSelObjects = getSumList(aHighlighted, aSelected);
139     else {
140       foreach (ModuleBase_ViewerPrs aPrs, aHighlighted) {
141         aSelObjects.append(aPrs.object());
142       }
143     }
144     if ((aSelObjects.size() == 0)) {
145       if (isSketchOpe && (!isSketcher))
146         // commit previous operation
147         if (!aOperation->commit())
148           aOperation->abort();
149       return;
150     }
151     if (aSelObjects.size() == 1) {
152       // Move by selected shape (vertex). Can be used only for single selection
153       foreach(ModuleBase_ViewerPrs aPrs, aHighlighted) {
154         FeaturePtr aFeature = ModelAPI_Feature::feature(aHighlighted.first().object());
155         if (aFeature) {
156           myEditingFeatures.append(aFeature);
157           TopoDS_Shape aShape = aPrs.shape();
158           if (!aShape.IsNull()) {
159             if (aShape.ShapeType() == TopAbs_VERTEX) {
160               AttributePtr aAttr = PartSet_Tools::findAttributeBy2dPoint(myEditingFeatures.first(), 
161                                                                          aShape, myCurrentSketch);
162               if (aAttr)
163                 myEditingAttr.append(aAttr);
164             }
165           }
166         }
167       }
168     } else {
169       // Provide multi-selection. Can be used only for features
170       foreach (ObjectPtr aObj, aSelObjects) {
171         FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
172         if (aFeature && (!myEditingFeatures.contains(aFeature)))
173           myEditingFeatures.append(aFeature);
174       }
175
176     }
177     // If nothing highlighted - return
178     if (myEditingFeatures.size() == 0)
179       return;
180
181     if (isSketcher) {
182       myIsDragging = true;
183       get2dPoint(theWnd, theEvent, myCurX, myCurY);
184       myDragDone = false;
185       aWorkshop->viewer()->enableMultiselection(false);
186       launchEditing();
187
188     } else if (isSketchOpe && isEditing) {
189       // If selected another object
190       aOperation->abort();
191
192       myIsDragging = true;
193       get2dPoint(theWnd, theEvent, myCurX, myCurY);
194       myDragDone = false;
195       aWorkshop->viewer()->enableMultiselection(false);
196
197       // This is necessary in order to finalize previous operation
198       QApplication::processEvents();
199       launchEditing();
200     }
201   }
202 }
203
204 void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
205 {
206   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
207   ModuleBase_Operation* aOp = aWorkshop->currentOperation();
208   if (!aOp)
209     return;
210   if (!sketchOperationIdList().contains(aOp->id()))
211     return;
212
213   // Only for sketcher operations
214   ModuleBase_IViewer* aViewer = aWorkshop->viewer();
215   if (myIsDragging) {
216     myIsDragging = false;
217     if (myDragDone) {
218       aViewer->enableMultiselection(true);
219       aOp->commit();
220       myEditingFeatures.clear();
221       myEditingAttr.clear();
222
223       // Reselect edited object
224       aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
225       if (theEvent->modifiers() & Qt::ShiftModifier)
226         aViewer->AISContext()->ShiftSelect();
227       else
228         aViewer->AISContext()->Select();
229       return;
230     }
231   }
232   if (!aViewer->isMultiSelectionEnabled()) {
233     aViewer->enableMultiselection(true);
234   }
235 }
236
237 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
238 {
239   if (myIsDragging) {
240     ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
241     if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
242       return; // No edit operation activated
243
244     static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
245     Handle(V3d_View) aView = theWnd->v3dView();
246     gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
247     double aX, aY;
248     PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
249     double dX =  aX - myCurX;
250     double dY =  aY - myCurY;
251
252     if ((aOperation->id().toStdString() == SketchPlugin_Line::ID()) &&
253         (myEditingAttr.size() == 1) && 
254         myEditingAttr.first()) {
255       // probably we have prehighlighted point
256       AttributePtr aAttr = myEditingAttr.first();
257       std::string aAttrId = aAttr->id();
258       ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
259       QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
260       // Find corresponded widget to provide dragging
261       foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
262         if (aWgt->attributeID() == aAttrId) {
263           PartSet_WidgetPoint2D* aWgt2d = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
264           if (aWgt2d) {
265             aWgt2d->setPoint(aWgt2d->x() + dX, aWgt2d->y() + dY);
266             break;
267           }
268         }
269       }
270     } else {
271       foreach(FeaturePtr aFeature, myEditingFeatures) {
272         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
273           std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
274         if (aSketchFeature) { 
275           // save the previous selection
276           /*ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
277           XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
278           XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
279           QIntList anActivatedModes;
280
281           ResultPtr aResult = aSketchFeature->firstResult();
282
283           aDisplayer->getModesOfActivation(aResult, anActivatedModes);
284
285           std::list<AttributePtr> aSelectedAttributes;
286           getCurrentSelection(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes);*/
287           // save the previous selection: end
288
289
290           aSketchFeature->move(dX, dY);
291           ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent);
292           /*
293           // TODO: the selection restore should be after the AIS presentation is rebuilt
294           Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
295           Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
296
297           // restore the previous selection
298           aResult = aSketchFeature->firstResult();
299             aDisplayer->activate(aResult, anActivatedModes);
300
301           SelectMgr_IndexedMapOfOwner anOwnersToSelect;
302           getSelectionOwners(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes,
303                              anOwnersToSelect);
304           
305           ModuleBase_IViewer* aViewer = aWorkshop->viewer();
306           Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
307           for (Standard_Integer i = 1, n = anOwnersToSelect.Extent(); i <= n; i++)
308             aContext->AddOrRemoveSelected(anOwnersToSelect(i), false); // SetSelected()
309
310           aContext->UpdateCurrentViewer();
311           // restore the previous selection*/
312         }
313       }
314       // TODO: set here
315       Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
316       Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
317     }
318     myDragDone = true;
319     myCurX = aX;
320     myCurY = aY;
321   }
322 }
323
324 void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
325 {
326   ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
327   if (aOperation && aOperation->isEditOperation()) {
328     std::string aId = aOperation->id().toStdString();
329     if ((aId == SketchPlugin_ConstraintLength::ID()) ||
330       (aId == SketchPlugin_ConstraintDistance::ID()) ||
331       (aId == SketchPlugin_ConstraintRadius::ID())) 
332     {
333       // Activate dimension value editing on double click
334       ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
335       QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
336       // Find corresponded widget to activate value editing
337       foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
338         if (aWgt->attributeID() == "ConstraintValue") {
339           aWgt->focusTo();
340           return;
341         }
342       }
343     }
344   }
345 }
346
347 void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
348                                 double& theX, double& theY)
349 {
350   Handle(V3d_View) aView = theWnd->v3dView();
351   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
352   PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, theX, theY);
353 }
354
355 void PartSet_SketcherMgr::launchEditing()
356 {
357   if (myEditingFeatures.size() > 0) {
358     FeaturePtr aFeature = myEditingFeatures.first();
359     std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
360               std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
361     if (aSPFeature) {
362       myModule->editFeature(aSPFeature);
363     }
364   }
365 }
366
367
368 QStringList PartSet_SketcherMgr::sketchOperationIdList()
369 {
370   static QStringList aIds;
371   if (aIds.size() == 0) {
372     aIds << SketchPlugin_Line::ID().c_str();
373     aIds << SketchPlugin_Point::ID().c_str();
374     aIds << SketchPlugin_Arc::ID().c_str();
375     aIds << SketchPlugin_Circle::ID().c_str();
376     aIds << SketchPlugin_ConstraintLength::ID().c_str();
377     aIds << SketchPlugin_ConstraintDistance::ID().c_str();
378     aIds << SketchPlugin_ConstraintRigid::ID().c_str();
379     aIds << SketchPlugin_ConstraintRadius::ID().c_str();
380     aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
381     aIds << SketchPlugin_ConstraintParallel::ID().c_str();
382   }
383   return aIds;
384 }
385
386 void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
387 {
388   // Display all sketcher sub-Objects
389   myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
390   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
391   XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
392
393   // Hide sketcher result
394   std::list<ResultPtr> aResults = myCurrentSketch->results();
395   std::list<ResultPtr>::const_iterator aIt;
396   for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
397     aDisplayer->erase((*aIt), false);
398   }
399   aDisplayer->erase(myCurrentSketch, false);
400
401   // Display sketcher objects
402   for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
403     FeaturePtr aFeature = myCurrentSketch->subFeature(i);
404     std::list<ResultPtr> aResults = aFeature->results();
405     std::list<ResultPtr>::const_iterator aIt;
406     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
407       aDisplayer->display((*aIt), false);
408     }
409     aDisplayer->display(aFeature, false);
410   }
411
412   if (myPlaneFilter.IsNull()) 
413     myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
414
415   myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
416   if (theOperation->isEditOperation()) {
417     // If it is editing of sketch then it means that plane is already defined
418     std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
419     myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
420   }
421   aDisplayer->updateViewer();
422 }
423
424 void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
425 {
426   DataPtr aData = myCurrentSketch->data();
427   if ((!aData) || (!aData->isValid())) {
428     // The sketch was aborted
429     myCurrentSketch = CompositeFeaturePtr();
430     myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
431     return; 
432   }
433   // Hide all sketcher sub-Objects
434   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
435   XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
436   for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
437     FeaturePtr aFeature = myCurrentSketch->subFeature(i);
438     std::list<ResultPtr> aResults = aFeature->results();
439     std::list<ResultPtr>::const_iterator aIt;
440     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
441       aDisplayer->erase((*aIt), false);
442     }
443     aDisplayer->erase(aFeature, false);
444   }
445   // Display sketcher result
446   std::list<ResultPtr> aResults = myCurrentSketch->results();
447   std::list<ResultPtr>::const_iterator aIt;
448   for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
449     aDisplayer->display((*aIt), false);
450   }
451   aDisplayer->display(myCurrentSketch);
452     
453   myCurrentSketch = CompositeFeaturePtr();
454   myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
455   aDisplayer->updateViewer();
456 }
457
458
459 void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
460 {
461   myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
462 }
463
464 void PartSet_SketcherMgr::getCurrentSelection(const ObjectPtr& theObject,
465                                               const FeaturePtr& theSketch,
466                                               ModuleBase_IWorkshop* theWorkshop,
467                                               std::list<AttributePtr>& theSelectedAttributes)
468 {
469   FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
470   if (aFeature.get() == NULL)
471     return;
472
473   ModuleBase_IViewer* aViewer = theWorkshop->viewer();
474   Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
475   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
476   XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
477
478   // TODO: check all results and IPresentable feature
479   ResultPtr aResult = aFeature->firstResult();
480
481   bool isVisibleSketch = aDisplayer->isVisible(aResult);
482   AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
483
484   if (aAISObj.get() != NULL) {
485     Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
486     for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
487     {
488       Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(
489                                                                       aContext->SelectedOwner());
490       if (aBRepOwner.IsNull()) continue;
491
492       Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(
493                                                                        aBRepOwner->Selectable());
494       if (anIO != anAISIO) continue;
495
496       if (aBRepOwner->HasShape()) {
497         const TopoDS_Shape& aShape = aBRepOwner->Shape();
498         TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
499         if (aShapeType == TopAbs_VERTEX) {
500           AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theObject,
501                                                                         aShape, theSketch);
502           if (aPntAttr.get() != NULL)
503             theSelectedAttributes.push_back(aPntAttr);
504         }
505       }
506     }
507   }
508 }
509
510 void PartSet_SketcherMgr::getSelectionOwners(const ObjectPtr& theObject,
511                                              const FeaturePtr& theSketch,
512                                              ModuleBase_IWorkshop* theWorkshop,
513                                              const std::list<AttributePtr>& theSelectedAttributes,
514                                              SelectMgr_IndexedMapOfOwner& anOwnersToSelect)
515 {
516   FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
517   if (aFeature.get() == NULL)
518     return;
519
520   ModuleBase_IViewer* aViewer = theWorkshop->viewer();
521   Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
522   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
523   XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
524
525   // TODO: check all results and IPresentable feature
526   ResultPtr aResult = aFeature->firstResult();
527
528   bool isVisibleSketch = aDisplayer->isVisible(aResult);
529   AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
530
531   if (aAISObj.get() != NULL) {
532     Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
533
534     SelectMgr_IndexedMapOfOwner aSelectedOwners;
535
536     aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
537     for  ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) {
538       Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i));
539       if ( anOwner.IsNull() || !anOwner->HasShape() )
540         continue;
541       const TopoDS_Shape& aShape = anOwner->Shape();
542       TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
543       if (aShapeType == TopAbs_VERTEX) {
544         AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(aFeature, aShape, theSketch);
545         if (aPntAttr.get() != NULL) {
546           std::list<AttributePtr>::const_iterator anIt = theSelectedAttributes.begin(),
547                                                   aLast = theSelectedAttributes.end();
548           for (; anIt != aLast; anIt++) {
549             AttributePtr anAttrIt = *anIt;
550             if (anAttrIt.get() == aPntAttr.get()) {
551               anOwnersToSelect.Add(anOwner);
552             }
553           }
554         }
555       }
556     }
557   }
558 }