]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_WidgetPoint2d.cpp
Salome HOME
#1107 Tab key does not change focus to Apply in circle sketch feature.
[modules/shaper.git] / src / PartSet / PartSet_WidgetPoint2d.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetPoint2D.cpp
4 // Created:     25 Apr 2014
5 // Author:      Natalia ERMOLAEVA
6
7 #include "PartSet_WidgetPoint2d.h"
8 #include <PartSet_Tools.h>
9 #include <PartSet_Module.h>
10
11 #include <ModuleBase_ParamSpinBox.h>
12 #include <ModuleBase_Tools.h>
13 #include <ModuleBase_IViewer.h>
14 #include <ModuleBase_IViewWindow.h>
15 #include <ModuleBase_ISelection.h>
16
17 #include <Config_Keywords.h>
18 #include <Config_WidgetAPI.h>
19
20 #include <Events_Loop.h>
21 #include <ModelAPI_Events.h>
22
23 #include <ModelAPI_Feature.h>
24 #include <ModelAPI_Data.h>
25 #include <ModelAPI_Object.h>
26 #include <GeomDataAPI_Point2D.h>
27 #include <GeomAPI_Pnt2d.h>
28
29 #include <SketchPlugin_Feature.h>
30 #include <SketchPlugin_ConstraintCoincidence.h>
31 #include <SketchPlugin_Line.h>
32 #include <SketchPlugin_Arc.h>
33 #include <SketchPlugin_Circle.h>
34 #include <SketchPlugin_Point.h>
35
36 #include <QGroupBox>
37 #include <QGridLayout>
38 #include <QLabel>
39 #include <QEvent>
40 #include <QMouseEvent>
41 #include <QApplication>
42
43 #include <TopoDS.hxx>
44 #include <TopoDS_Vertex.hxx>
45 #include <BRep_Tool.hxx>
46
47 #include <cfloat>
48 #include <climits>
49
50 const double MaxCoordinate = 1e12;
51
52 static QStringList MyFeaturesForCoincedence;
53
54 PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, 
55                                              ModuleBase_IWorkshop* theWorkshop,
56                                              const Config_WidgetAPI* theData,
57                                              const std::string& theParentId)
58  : ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop)
59 {
60   if (MyFeaturesForCoincedence.isEmpty()) {
61     MyFeaturesForCoincedence << SketchPlugin_Line::ID().c_str()
62       << SketchPlugin_Arc::ID().c_str()
63       << SketchPlugin_Point::ID().c_str()
64       << SketchPlugin_Circle::ID().c_str();
65   }
66
67   // the control should accept the focus, so the boolen flag is corrected to be true
68   myIsObligatory = true;
69   //myOptionParam = theData->getProperty(PREVIOUS_FEATURE_PARAM);
70   QString aPageName = QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME));
71   myGroupBox = new QGroupBox(aPageName, theParent);
72   myGroupBox->setFlat(false);
73
74   QGridLayout* aGroupLay = new QGridLayout(myGroupBox);
75   ModuleBase_Tools::adjustMargins(aGroupLay);
76   aGroupLay->setSpacing(2);
77   aGroupLay->setColumnStretch(1, 1);
78   {
79     QLabel* aLabel = new QLabel(myGroupBox);
80     aLabel->setText(tr("X "));
81     aGroupLay->addWidget(aLabel, 0, 0);
82
83     myXSpin = new ModuleBase_ParamSpinBox(myGroupBox);
84     myXSpin->setMinimum(-DBL_MAX);
85     myXSpin->setMaximum(DBL_MAX);
86     myXSpin->setToolTip(tr("X"));
87     aGroupLay->addWidget(myXSpin, 0, 1);
88
89     connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
90   }
91   {
92     QLabel* aLabel = new QLabel(myGroupBox);
93     aLabel->setText(tr("Y "));
94     aGroupLay->addWidget(aLabel, 1, 0);
95
96     myYSpin = new ModuleBase_ParamSpinBox(myGroupBox);
97     myYSpin->setMinimum(-DBL_MAX);
98     myYSpin->setMaximum(DBL_MAX);
99     myYSpin->setToolTip(tr("Y"));
100     aGroupLay->addWidget(myYSpin, 1, 1);
101
102     connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
103   }
104   QVBoxLayout* aLayout = new QVBoxLayout(this);
105   ModuleBase_Tools::zeroMargins(aLayout);
106   aLayout->addWidget(myGroupBox);
107   setLayout(aLayout);
108 }
109
110 bool PartSet_WidgetPoint2D::resetCustom()
111 {
112   bool aDone = false;
113   if (!isUseReset() || isComputedDefault() || myXSpin->hasVariable() || myYSpin->hasVariable()) {
114     aDone = false;
115   }
116   else {
117     bool isOk;
118     double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
119     // it is important to block the spin box control in order to do not through out the
120     // locking of the validating state.
121     ModuleBase_Tools::setSpinValue(myXSpin, isOk ? aDefValue : 0.0);
122     ModuleBase_Tools::setSpinValue(myYSpin, isOk ? aDefValue : 0.0);
123     storeValueCustom();
124     aDone = true;
125   }
126   return aDone;
127 }
128
129 PartSet_WidgetPoint2D::~PartSet_WidgetPoint2D()
130 {
131 }
132
133 bool PartSet_WidgetPoint2D::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
134                                          const bool theToValidate)
135 {
136   bool isDone = false;
137   if (theValues.empty())
138     return isDone;
139
140   ModuleBase_ViewerPrs aValue = theValues.takeFirst();
141   TopoDS_Shape aShape = aValue.shape();
142   if (!aShape.IsNull()) {
143     Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
144     double aX, aY;
145     if (getPoint2d(aView, aShape, aX, aY)) {
146       isDone = setPoint(aX, aY);
147     }
148   }
149   else if (canBeActivatedByMove()) {
150     if (feature()->getKind() == SketchPlugin_Line::ID()) {
151       FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aValue.object());
152       // Initialise new line with first point equal to end of previous
153       if (aFeature.get()) {
154         std::shared_ptr<ModelAPI_Data> aData = aFeature->data();
155         std::shared_ptr<GeomDataAPI_Point2D> aPoint = 
156           std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
157                                        aData->attribute(SketchPlugin_Line::END_ID()));
158         if (aPoint) {
159           setPoint(aPoint->x(), aPoint->y());
160           PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aPoint->x(),
161                                         aPoint->y());
162           isDone = true;
163         }
164       }
165     }
166   }
167   return isDone;
168 }
169
170 void PartSet_WidgetPoint2D::selectContent()
171 {
172   myXSpin->selectAll();
173 }
174
175 bool PartSet_WidgetPoint2D::setPoint(double theX, double theY)
176 {
177   if (fabs(theX) >= MaxCoordinate)
178     return false;
179   if (fabs(theY) >= MaxCoordinate)
180     return false;
181
182   ModuleBase_Tools::setSpinValue(myXSpin, theX);
183   ModuleBase_Tools::setSpinValue(myYSpin, theY);
184
185   storeValue();
186   return true;
187 }
188
189 bool PartSet_WidgetPoint2D::storeValueCustom() const
190 {
191   std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
192   if (!aData) // can be on abort of sketcher element
193     return false;
194   std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
195       aData->attribute(attributeID()));
196
197   PartSet_WidgetPoint2D* that = (PartSet_WidgetPoint2D*) this;
198   bool isBlocked = that->blockSignals(true);
199   bool isImmutable = aPoint->setImmutable(true);
200
201   // if text is not empty then setValue will be ignored
202   // so we should set the text at first
203   aPoint->setText(myXSpin->hasVariable() ? myXSpin->text().toStdString() : "",
204                   myYSpin->hasVariable() ? myYSpin->text().toStdString() : "");
205   aPoint->setValue(!myXSpin->hasVariable() ? myXSpin->value() : aPoint->x(),
206                    !myYSpin->hasVariable() ? myYSpin->value() : aPoint->y());
207
208   // after movement the solver will call the update event: optimization
209   moveObject(myFeature);
210   aPoint->setImmutable(isImmutable);
211   that->blockSignals(isBlocked);
212
213   return true;
214 }
215
216 bool PartSet_WidgetPoint2D::restoreValueCustom()
217 {
218   std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
219   std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
220       aData->attribute(attributeID()));
221   QString aTextX = QString::fromStdString(aPoint->textX());
222   QString aTextY = QString::fromStdString(aPoint->textY());
223
224   bool isDouble = false;
225   double aVal = 0;
226   if (aTextX.isEmpty()) {
227     ModuleBase_Tools::setSpinValue(myXSpin, aPoint->x());
228   } else {
229     aVal = aTextX.toDouble(&isDouble);
230     if (isDouble)
231       ModuleBase_Tools::setSpinValue(myXSpin, aVal);
232     else
233       ModuleBase_Tools::setSpinText(myXSpin, aTextX);
234   }
235   if (aTextY.isEmpty()) {
236     ModuleBase_Tools::setSpinValue(myYSpin, aPoint->y());
237   } else {
238     aVal = aTextY.toDouble(&isDouble);
239     if (isDouble)
240       ModuleBase_Tools::setSpinValue(myYSpin, aVal);
241     else
242       ModuleBase_Tools::setSpinText(myYSpin, aTextY);
243   }
244   //if (aTextX.empty() || aTextY.empty()) {
245   //  ModuleBase_Tools::setSpinValue(myXSpin, aPoint->x());
246   //  ModuleBase_Tools::setSpinValue(myYSpin, aPoint->y());
247   //} else {
248   //  ModuleBase_Tools::setSpinText(myXSpin, QString::fromStdString(aTextX));
249   //  ModuleBase_Tools::setSpinText(myYSpin, QString::fromStdString(aTextY));
250   //}
251   return true;
252 }
253
254 QList<QWidget*> PartSet_WidgetPoint2D::getControls() const
255 {
256   QList<QWidget*> aControls;
257   aControls.append(myXSpin);
258   aControls.append(myYSpin);
259   return aControls;
260 }
261
262
263 void PartSet_WidgetPoint2D::activateCustom()
264 {
265   ModuleBase_IViewer* aViewer = myWorkshop->viewer();
266   connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), 
267           this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
268   connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
269           this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
270
271   QIntList aModes;
272   aModes << TopAbs_VERTEX;
273   aModes << TopAbs_EDGE;
274   myWorkshop->activateSubShapesSelection(aModes);
275 }
276
277 bool PartSet_WidgetPoint2D::canBeActivatedByMove()
278 {
279   bool aCanBeActivated = false;
280   if (feature()->getKind() == SketchPlugin_Line::ID() &&
281       attributeID() == SketchPlugin_Line::START_ID())
282     aCanBeActivated = true;
283
284   return aCanBeActivated;
285 }
286
287 void PartSet_WidgetPoint2D::deactivate()
288 {
289   // the value of the control should be stored to model if it was not
290   // initialized yet. It is important when we leave this control by Tab key.
291   // It should not be performed by the widget activation as the preview
292   // is visualized with default value. Line point is moved to origin.
293   AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
294   if (anAttribute && !anAttribute->isInitialized())
295     storeValue();
296
297   ModuleBase_ModelWidget::deactivate();
298   ModuleBase_IViewer* aViewer = myWorkshop->viewer();
299   disconnect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
300              this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
301   disconnect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
302              this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
303
304   myWorkshop->deactivateSubShapesSelection();
305 }
306
307 bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView, 
308                                        const TopoDS_Shape& theShape, 
309                                        double& theX, double& theY) const
310 {
311   if (!theShape.IsNull()) {
312     if (theShape.ShapeType() == TopAbs_VERTEX) {
313       const TopoDS_Vertex& aVertex = TopoDS::Vertex(theShape);
314       if (!aVertex.IsNull()) {
315         // A case when point is taken from existing vertex
316         gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
317         PartSet_Tools::convertTo2D(aPoint, mySketch, theView, theX, theY);
318         return true;
319       }
320     }
321   }
322   return false;
323 }
324
325 void PartSet_WidgetPoint2D::setConstraintWith(const ObjectPtr& theObject)
326 {
327   // Create point-edge coincedence
328   FeaturePtr aFeature = mySketch->addFeature(SketchPlugin_ConstraintCoincidence::ID());
329   std::shared_ptr<ModelAPI_Data> aData = aFeature->data();
330
331   std::shared_ptr<ModelAPI_AttributeRefAttr> aRef1 = std::dynamic_pointer_cast<
332       ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
333   AttributePtr aThisAttr = feature()->data()->attribute(attributeID());
334   std::shared_ptr<GeomDataAPI_Point2D> aThisPoint = 
335     std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aThisAttr);
336   aRef1->setAttr(aThisPoint);
337
338   std::shared_ptr<ModelAPI_AttributeRefAttr> aRef2 = std::dynamic_pointer_cast<
339       ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
340   aRef2->setObject(theObject);
341
342   aFeature->execute();
343 }
344
345 void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
346 {
347   // the contex menu release by the right button should not be processed by this widget
348   if (theEvent->button() != Qt::LeftButton)
349     return;
350
351   ModuleBase_ISelection* aSelection = myWorkshop->selection();
352   Handle(V3d_View) aView = theWnd->v3dView();
353   // TODO: This fragment doesn't work because bug in OCC Viewer. It can be used after fixing.
354   NCollection_List<TopoDS_Shape> aShapes;
355   std::list<ObjectPtr> aObjects;
356   aSelection->selectedShapes(aShapes, aObjects);
357   // if we have selection
358   if (aShapes.Extent() > 0) {
359     TopoDS_Shape aShape = aShapes.First();
360     ObjectPtr aObject = aObjects.front();
361     FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aObject);
362     bool anExternal = false;
363       std::shared_ptr<SketchPlugin_Feature> aSPFeature;
364       if (aSelectedFeature.get() != NULL)
365         aSPFeature = std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
366       if ((!aSPFeature) && (!aShape.IsNull())) {
367         anExternal = true;
368         ResultPtr aFixedObject = PartSet_Tools::findFixedObjectByExternal(aShape, aObject, mySketch);
369         if (!aFixedObject.get())
370           aObject = PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
371
372         double aX, aY;
373         if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) {
374           // do not create a constraint to the point, which already used by the feature
375           // if the feature contains the point, focus is not switched
376           setPoint(aX, aY);
377         }
378         else {
379           if (getPoint2d(aView, aShape, aX, aY))
380             setPoint(aX, aY);
381           bool anOrphanPoint = isOrphanPoint(aSelectedFeature, mySketch, aX, aY);
382           setConstraintWith(aObject);
383           if (!anOrphanPoint)
384             emit vertexSelected();
385           emit focusOutWidget(this);
386         }
387       }
388     if (!anExternal) {
389       double aX, aY;
390       bool isProcessed = false;
391       if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) {
392         // when the point is selected, the coordinates of the point should be set into the attribute
393         // if the feature contains the point, focus is not switched
394         setPoint(aX, aY);
395       }
396       else {
397         bool anOrphanPoint = isOrphanPoint(aSelectedFeature, mySketch, aX, aY);
398         // do not set a coincidence constraint in the attribute if the feature contains a point
399         // with the same coordinates. It is important for line creation in order to do not set
400         // the same constraints for the same points, oterwise the result line has zero length.
401         if (getPoint2d(aView, aShape, aX, aY)) {
402           setPoint(aX, aY);
403           PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
404         }
405         else if (aShape.ShapeType() == TopAbs_EDGE) {
406           if (MyFeaturesForCoincedence.contains(myFeature->getKind().c_str()))
407             setConstraintWith(aObject);
408         }
409         // it is important to perform updateObject() in order to the current value is 
410         // processed by Sketch Solver. Test case: line is created from a previous point
411         // to some distance, but in the area of the highlighting of the point. Constraint
412         // coincidence is created, after the solver is performed, the distance between the
413         // points of the line becomes less than the tolerance. Validator of the line returns
414         // false, the line will be aborted, but sketch stays valid.
415         updateObject(feature());
416         if (!anOrphanPoint)
417           emit vertexSelected();
418         emit focusOutWidget(this);
419       }
420     }
421   }
422   // End of Bug dependent fragment
423   else {
424     // A case when point is taken from mouse event
425     gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
426     double aX, anY;
427     PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, anY);
428
429     // if the feature contains the point, focus is not switched
430     if (!setPoint(aX, anY) || isFeatureContainsPoint(myFeature, aX, anY))
431       return;
432
433     /// Start alternative code
434     //std::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint = std::dynamic_pointer_cast<
435     //    GeomDataAPI_Point2D>(feature()->data()->attribute(attributeID()));
436     //QList<FeaturePtr> aIgnore;
437     //aIgnore.append(feature());
438
439     //double aTolerance = aView->Convert(7);
440     //std::shared_ptr<GeomDataAPI_Point2D> aAttrPnt = 
441     //  PartSet_Tools::findAttributePoint(mySketch, aX, anY, aTolerance, aIgnore);
442     //if (aAttrPnt.get() != NULL) {
443     //  aFeaturePoint->setValue(aAttrPnt->pnt());
444     //  PartSet_Tools::createConstraint(mySketch, aAttrPnt, aFeaturePoint);
445     //  emit vertexSelected();
446     //}
447     /// End alternative code
448     emit focusOutWidget(this);
449   }
450 }
451
452
453 void PartSet_WidgetPoint2D::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
454 {
455   if (isEditingMode())
456     return;
457
458   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
459
460   double aX, anY;
461   PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, anY);
462   // we need to block the value state change 
463   bool isBlocked = blockValueState(true);
464   setPoint(aX, anY);
465   blockValueState(isBlocked);
466   setValueState(ModifiedInViewer);
467 }
468
469 double PartSet_WidgetPoint2D::x() const
470 {
471   return myXSpin->value();
472 }
473
474 double PartSet_WidgetPoint2D::y() const
475 {
476   return myYSpin->value();
477 }
478
479
480 bool PartSet_WidgetPoint2D::isFeatureContainsPoint(const FeaturePtr& theFeature,
481                                                    double theX, double theY)
482 {
483   bool aPointIsFound = false;
484
485   if (feature()->getKind() != SketchPlugin_Line::ID())
486     return aPointIsFound;
487
488   AttributePtr aWidgetAttribute = myFeature->attribute(attributeID());
489
490   std::shared_ptr<GeomAPI_Pnt2d> aPnt2d = 
491                                     std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
492   std::list<AttributePtr> anAttributes =
493                                 myFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
494   std::list<AttributePtr>::iterator anIter = anAttributes.begin();
495   for(; anIter != anAttributes.end() && !aPointIsFound; anIter++) {
496     AttributePoint2DPtr aPoint2DAttribute =
497       std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIter);
498     if (aPoint2DAttribute == aWidgetAttribute)
499       continue;
500     if (aPoint2DAttribute.get() && aPoint2DAttribute->isInitialized()) {
501       aPointIsFound = aPoint2DAttribute->pnt()->isEqual(aPnt2d);
502     }
503   }
504   return aPointIsFound;
505 }
506
507 void PartSet_WidgetPoint2D::initializeValueByActivate()
508 {
509 }
510
511 /*void PartSet_WidgetPoint2D::onValuesChanged()
512 {
513   emit valuesChanged();
514 }*/
515
516 bool PartSet_WidgetPoint2D::processEnter()
517 {
518   bool isModified = getValueState() == ModifiedInPP;
519   if (isModified) {
520     bool isXModified = myXSpin->hasFocus();
521     emit valuesChanged();
522     if (isXModified)
523       myXSpin->selectAll();
524     else
525       myYSpin->selectAll();
526   }
527   return isModified;
528 }
529
530 bool PartSet_WidgetPoint2D::isOrphanPoint(const FeaturePtr& theFeature,
531                                           const CompositeFeaturePtr& theSketch,
532                                           double theX, double theY)
533 {
534   bool anOrphanPoint = false;
535   if (theFeature.get()) {
536     std::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
537     std::string aFeatureKind = theFeature->getKind();
538     if (aFeatureKind == SketchPlugin_Point::ID())
539       aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
540                                        theFeature->attribute(SketchPlugin_Point::COORD_ID()));
541     else if (aFeatureKind == SketchPlugin_Circle::ID())
542       aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
543                                        theFeature->attribute(SketchPlugin_Circle::CENTER_ID()));
544
545     else if (aFeatureKind == SketchPlugin_Arc::ID())
546       aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
547                                        theFeature->attribute(SketchPlugin_Arc::CENTER_ID()));
548
549     /// check that the geometry point with the given coordinates is the checked point
550     /// e.g. in arc the (x,y) point can not coicide to the center point and it automatically
551     /// means that this point is not an orphant one.
552     if (aPointAttr.get()) {
553       std::shared_ptr<GeomAPI_Pnt2d> aCheckedPoint = std::shared_ptr<GeomAPI_Pnt2d>(
554                                                     new GeomAPI_Pnt2d(theX, theY));
555       if (!aCheckedPoint->isEqual(aPointAttr->pnt()))
556         return anOrphanPoint;
557     }
558
559     if (aPointAttr.get()) {
560       std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointAttr->pnt();
561       FeaturePtr aCoincidence = PartSet_Tools::findFirstCoincidence(theFeature, aPoint);
562       anOrphanPoint = true;
563       // if there is at least one concident line to the point, the point is not an orphant
564       if (aCoincidence.get()) {
565         QList<FeaturePtr> aCoinsideLines;
566         PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines,
567                                         SketchPlugin_ConstraintCoincidence::ENTITY_A());
568         PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines,
569                                         SketchPlugin_ConstraintCoincidence::ENTITY_B());
570         QList<FeaturePtr>::const_iterator anIt = aCoinsideLines.begin(),
571                                           aLast = aCoinsideLines.end();
572         for (; anIt != aLast && anOrphanPoint; anIt++) {
573           anOrphanPoint = (*anIt)->getKind() != SketchPlugin_Line::ID();
574         }
575       }
576     }
577   }
578   return anOrphanPoint;
579 }