]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_SketcherMgr.cpp
Salome HOME
The local selection restore for a feature vertex (it is checked on the line feature)
[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 ((aHighlighted.size() == 1) && (aSelected.size() == 0)) {
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       return;
223     }
224   }
225   if (!aViewer->isMultiSelectionEnabled()) {
226     aViewer->enableMultiselection(true);
227   }
228   //aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
229   //if (theEvent->modifiers() & Qt::ShiftModifier)
230   //  aViewer->AISContext()->ShiftSelect();
231   //else
232   //  aViewer->AISContext()->Select();
233 }
234
235 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
236 {
237   if (myIsDragging) {
238     ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
239     if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
240       return; // No edit operation activated
241
242     static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
243
244     Handle(V3d_View) aView = theWnd->v3dView();
245     gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
246     double aX, aY;
247     PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
248     double dX =  aX - myCurX;
249     double dY =  aY - myCurY;
250
251     if ((aOperation->id().toStdString() == SketchPlugin_Line::ID()) &&
252         (myEditingAttr.size() == 1) && 
253         myEditingAttr.first()) {
254       // probably we have prehighlighted point
255       AttributePtr aAttr = myEditingAttr.first();
256       std::string aAttrId = aAttr->id();
257       ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
258       QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
259       // Find corresponded widget to provide dragging
260       foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
261         if (aWgt->attributeID() == aAttrId) {
262           PartSet_WidgetPoint2D* aWgt2d = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
263           if (aWgt2d) {
264             aWgt2d->setPoint(aWgt2d->x() + dX, aWgt2d->y() + dY);
265             break;
266           }
267         }
268       }
269     } else {
270       ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
271       XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
272       XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
273       bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
274
275       foreach(FeaturePtr aFeature, myEditingFeatures) {
276         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
277           std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
278         if (aSketchFeature) {
279           // save the previous selection
280
281           std::list<AttributePtr> aSelectedAttributes;
282           getCurrentSelection(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes);
283           // save the previous selection: end
284
285           aSketchFeature->move(dX, dY);
286           // TODO: the selection restore should be after the AIS presentation is rebuilt
287           Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
288           Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
289
290           // restore the previous selection
291           SelectMgr_IndexedMapOfOwner anOwnersToSelect;
292           getSelectionOwners(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes,
293                              anOwnersToSelect);
294           aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
295           // restore the previous selection
296         }
297         ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent, true);
298         Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
299       }
300       // TODO: set here
301       //Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
302       //Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
303
304       //Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
305       aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
306       aDisplayer->updateViewer();
307     }
308     myDragDone = true;
309     myCurX = aX;
310     myCurY = aY;
311   }
312 }
313
314 void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
315 {
316   ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
317   if (aOperation && aOperation->isEditOperation()) {
318     std::string aId = aOperation->id().toStdString();
319     if ((aId == SketchPlugin_ConstraintLength::ID()) ||
320       (aId == SketchPlugin_ConstraintDistance::ID()) ||
321       (aId == SketchPlugin_ConstraintRadius::ID())) 
322     {
323       // Activate dimension value editing on double click
324       ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
325       QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
326       // Find corresponded widget to activate value editing
327       foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
328         if (aWgt->attributeID() == "ConstraintValue") {
329           aWgt->focusTo();
330           return;
331         }
332       }
333     }
334   }
335 }
336
337 void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
338                                 double& theX, double& theY)
339 {
340   Handle(V3d_View) aView = theWnd->v3dView();
341   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
342   PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, theX, theY);
343 }
344
345 void PartSet_SketcherMgr::launchEditing()
346 {
347   if (myEditingFeatures.size() > 0) {
348     FeaturePtr aFeature = myEditingFeatures.first();
349     std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
350               std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
351     if (aSPFeature) {
352       myModule->editFeature(aSPFeature);
353     }
354   }
355 }
356
357
358 QStringList PartSet_SketcherMgr::sketchOperationIdList()
359 {
360   static QStringList aIds;
361   if (aIds.size() == 0) {
362     aIds << SketchPlugin_Line::ID().c_str();
363     aIds << SketchPlugin_Point::ID().c_str();
364     aIds << SketchPlugin_Arc::ID().c_str();
365     aIds << SketchPlugin_Circle::ID().c_str();
366     aIds << SketchPlugin_ConstraintLength::ID().c_str();
367     aIds << SketchPlugin_ConstraintDistance::ID().c_str();
368     aIds << SketchPlugin_ConstraintRigid::ID().c_str();
369     aIds << SketchPlugin_ConstraintRadius::ID().c_str();
370     aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
371     aIds << SketchPlugin_ConstraintParallel::ID().c_str();
372   }
373   return aIds;
374 }
375
376 void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
377 {
378   // Display all sketcher sub-Objects
379   myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
380   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
381   XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
382
383   // Hide sketcher result
384   std::list<ResultPtr> aResults = myCurrentSketch->results();
385   std::list<ResultPtr>::const_iterator aIt;
386   for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
387     aDisplayer->erase((*aIt), false);
388   }
389   aDisplayer->erase(myCurrentSketch, false);
390
391   // Display sketcher objects
392   for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
393     FeaturePtr aFeature = myCurrentSketch->subFeature(i);
394     std::list<ResultPtr> aResults = aFeature->results();
395     std::list<ResultPtr>::const_iterator aIt;
396     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
397       aDisplayer->display((*aIt), false);
398     }
399     aDisplayer->display(aFeature, false);
400   }
401
402   if (myPlaneFilter.IsNull()) 
403     myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
404
405   myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
406   if (theOperation->isEditOperation()) {
407     // If it is editing of sketch then it means that plane is already defined
408     std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
409     myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
410   }
411   aDisplayer->updateViewer();
412 }
413
414 void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
415 {
416   DataPtr aData = myCurrentSketch->data();
417   if ((!aData) || (!aData->isValid())) {
418     // The sketch was aborted
419     myCurrentSketch = CompositeFeaturePtr();
420     myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
421     return; 
422   }
423   // Hide all sketcher sub-Objects
424   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
425   XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
426   for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
427     FeaturePtr aFeature = myCurrentSketch->subFeature(i);
428     std::list<ResultPtr> aResults = aFeature->results();
429     std::list<ResultPtr>::const_iterator aIt;
430     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
431       aDisplayer->erase((*aIt), false);
432     }
433     aDisplayer->erase(aFeature, false);
434   }
435   // Display sketcher result
436   std::list<ResultPtr> aResults = myCurrentSketch->results();
437   std::list<ResultPtr>::const_iterator aIt;
438   for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
439     aDisplayer->display((*aIt), false);
440   }
441   aDisplayer->display(myCurrentSketch);
442     
443   myCurrentSketch = CompositeFeaturePtr();
444   myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
445   aDisplayer->updateViewer();
446 }
447
448
449 void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
450 {
451   myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
452 }
453
454 void PartSet_SketcherMgr::getCurrentSelection(const ObjectPtr& theObject,
455                                               const FeaturePtr& theSketch,
456                                               ModuleBase_IWorkshop* theWorkshop,
457                                               std::list<AttributePtr>& theSelectedAttributes)
458 {
459   FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
460   if (aFeature.get() == NULL)
461     return;
462
463   ModuleBase_IViewer* aViewer = theWorkshop->viewer();
464   Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
465   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
466   XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
467
468   // TODO: check all results and IPresentable feature
469   ResultPtr aResult = aFeature->firstResult();
470
471   bool isVisibleSketch = aDisplayer->isVisible(aResult);
472   AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
473
474   if (aAISObj.get() != NULL) {
475     Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
476     for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
477     {
478       Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(
479                                                                       aContext->SelectedOwner());
480       if (aBRepOwner.IsNull()) continue;
481
482       Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(
483                                                                        aBRepOwner->Selectable());
484       if (anIO != anAISIO) continue;
485
486       if (aBRepOwner->HasShape()) {
487         const TopoDS_Shape& aShape = aBRepOwner->Shape();
488         TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
489         if (aShapeType == TopAbs_VERTEX) {
490           AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theObject,
491                                                                         aShape, theSketch);
492           if (aPntAttr.get() != NULL)
493             theSelectedAttributes.push_back(aPntAttr);
494         }
495       }
496     }
497   }
498 }
499
500 void PartSet_SketcherMgr::getSelectionOwners(const ObjectPtr& theObject,
501                                              const FeaturePtr& theSketch,
502                                              ModuleBase_IWorkshop* theWorkshop,
503                                              const std::list<AttributePtr>& theSelectedAttributes,
504                                              SelectMgr_IndexedMapOfOwner& anOwnersToSelect)
505 {
506   FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
507   if (aFeature.get() == NULL)
508     return;
509
510   ModuleBase_IViewer* aViewer = theWorkshop->viewer();
511   Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
512   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
513   XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
514
515   // TODO: check all results and IPresentable feature
516   ResultPtr aResult = aFeature->firstResult();
517
518   bool isVisibleSketch = aDisplayer->isVisible(aResult);
519   AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
520
521   if (aAISObj.get() != NULL) {
522     Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
523
524     SelectMgr_IndexedMapOfOwner aSelectedOwners;
525
526     aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
527     for  ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) {
528       Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i));
529       if ( anOwner.IsNull() || !anOwner->HasShape() )
530         continue;
531       const TopoDS_Shape& aShape = anOwner->Shape();
532       TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
533       if (aShapeType == TopAbs_VERTEX) {
534         AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(aFeature, aShape, theSketch);
535         if (aPntAttr.get() != NULL) {
536           std::list<AttributePtr>::const_iterator anIt = theSelectedAttributes.begin(),
537                                                   aLast = theSelectedAttributes.end();
538           for (; anIt != aLast; anIt++) {
539             AttributePtr anAttrIt = *anIt;
540             if (anAttrIt.get() == aPntAttr.get()) {
541               anOwnersToSelect.Add(anOwner);
542             }
543           }
544         }
545       }
546     }
547   }
548 }