]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_WidgetPoint2d.cpp
Salome HOME
9c7f6b1e5dc8cfff6d31584874299760d1e54c18
[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       PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
148     }
149   }
150   else if (canBeActivatedByMove()) {
151     if (feature()->getKind() == SketchPlugin_Line::ID()) {
152       FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aValue.object());
153       // Initialise new line with first point equal to end of previous
154       if (aFeature.get()) {
155         std::shared_ptr<ModelAPI_Data> aData = aFeature->data();
156         std::shared_ptr<GeomDataAPI_Point2D> aPoint = 
157           std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
158                                        aData->attribute(SketchPlugin_Line::END_ID()));
159         if (aPoint) {
160           setPoint(aPoint->x(), aPoint->y());
161           PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aPoint->x(),
162                                         aPoint->y());
163           isDone = true;
164         }
165       }
166     }
167   }
168   return isDone;
169 }
170
171 void PartSet_WidgetPoint2D::selectContent()
172 {
173   myXSpin->selectAll();
174 }
175
176 bool PartSet_WidgetPoint2D::setPoint(double theX, double theY)
177 {
178   if (fabs(theX) >= MaxCoordinate)
179     return false;
180   if (fabs(theY) >= MaxCoordinate)
181     return false;
182
183   ModuleBase_Tools::setSpinValue(myXSpin, theX);
184   ModuleBase_Tools::setSpinValue(myYSpin, theY);
185
186   storeValue();
187   return true;
188 }
189
190 bool PartSet_WidgetPoint2D::storeValueCustom() const
191 {
192   std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
193   if (!aData) // can be on abort of sketcher element
194     return false;
195   std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
196       aData->attribute(attributeID()));
197
198   PartSet_WidgetPoint2D* that = (PartSet_WidgetPoint2D*) this;
199   bool isBlocked = that->blockSignals(true);
200   bool isImmutable = aPoint->setImmutable(true);
201
202   // if text is not empty then setValue will be ignored
203   // so we should set the text at first
204   aPoint->setText(myXSpin->hasVariable() ? myXSpin->text().toStdString() : "",
205                   myYSpin->hasVariable() ? myYSpin->text().toStdString() : "");
206   aPoint->setValue(!myXSpin->hasVariable() ? myXSpin->value() : aPoint->x(),
207                    !myYSpin->hasVariable() ? myYSpin->value() : aPoint->y());
208
209   // after movement the solver will call the update event: optimization
210   moveObject(myFeature);
211   aPoint->setImmutable(isImmutable);
212   that->blockSignals(isBlocked);
213
214   return true;
215 }
216
217 bool PartSet_WidgetPoint2D::restoreValueCustom()
218 {
219   std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
220   std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
221       aData->attribute(attributeID()));
222   QString aTextX = QString::fromStdString(aPoint->textX());
223   QString aTextY = QString::fromStdString(aPoint->textY());
224
225   bool isDouble = false;
226   double aVal = 0;
227   if (aTextX.isEmpty()) {
228     ModuleBase_Tools::setSpinValue(myXSpin, aPoint->x());
229   } else {
230     aVal = aTextX.toDouble(&isDouble);
231     if (isDouble)
232       ModuleBase_Tools::setSpinValue(myXSpin, aVal);
233     else
234       ModuleBase_Tools::setSpinText(myXSpin, aTextX);
235   }
236   if (aTextY.isEmpty()) {
237     ModuleBase_Tools::setSpinValue(myYSpin, aPoint->y());
238   } else {
239     aVal = aTextY.toDouble(&isDouble);
240     if (isDouble)
241       ModuleBase_Tools::setSpinValue(myYSpin, aVal);
242     else
243       ModuleBase_Tools::setSpinText(myYSpin, aTextY);
244   }
245   //if (aTextX.empty() || aTextY.empty()) {
246   //  ModuleBase_Tools::setSpinValue(myXSpin, aPoint->x());
247   //  ModuleBase_Tools::setSpinValue(myYSpin, aPoint->y());
248   //} else {
249   //  ModuleBase_Tools::setSpinText(myXSpin, QString::fromStdString(aTextX));
250   //  ModuleBase_Tools::setSpinText(myYSpin, QString::fromStdString(aTextY));
251   //}
252   return true;
253 }
254
255 QList<QWidget*> PartSet_WidgetPoint2D::getControls() const
256 {
257   QList<QWidget*> aControls;
258   aControls.append(myXSpin);
259   aControls.append(myYSpin);
260   return aControls;
261 }
262
263
264 void PartSet_WidgetPoint2D::activateCustom()
265 {
266   ModuleBase_IViewer* aViewer = myWorkshop->viewer();
267   connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), 
268           this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
269   connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
270           this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
271
272   QIntList aModes;
273   aModes << TopAbs_VERTEX;
274   aModes << TopAbs_EDGE;
275   myWorkshop->activateSubShapesSelection(aModes);
276 }
277
278 bool PartSet_WidgetPoint2D::canBeActivatedByMove()
279 {
280   bool aCanBeActivated = false;
281   if (feature()->getKind() == SketchPlugin_Line::ID() &&
282       attributeID() == SketchPlugin_Line::START_ID())
283     aCanBeActivated = true;
284
285   return aCanBeActivated;
286 }
287
288 void PartSet_WidgetPoint2D::deactivate()
289 {
290   // the value of the control should be stored to model if it was not
291   // initialized yet. It is important when we leave this control by Tab key.
292   // It should not be performed by the widget activation as the preview
293   // is visualized with default value. Line point is moved to origin.
294   AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
295   if (anAttribute && !anAttribute->isInitialized())
296     storeValue();
297
298   ModuleBase_ModelWidget::deactivate();
299   ModuleBase_IViewer* aViewer = myWorkshop->viewer();
300   disconnect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
301              this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
302   disconnect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
303              this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
304
305   myWorkshop->deactivateSubShapesSelection();
306 }
307
308 bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView, 
309                                        const TopoDS_Shape& theShape, 
310                                        double& theX, double& theY) const
311 {
312   if (!theShape.IsNull()) {
313     if (theShape.ShapeType() == TopAbs_VERTEX) {
314       const TopoDS_Vertex& aVertex = TopoDS::Vertex(theShape);
315       if (!aVertex.IsNull()) {
316         // A case when point is taken from existing vertex
317         gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
318         PartSet_Tools::convertTo2D(aPoint, mySketch, theView, theX, theY);
319         return true;
320       }
321     }
322   }
323   return false;
324 }
325
326 void PartSet_WidgetPoint2D::setConstraintWith(const ObjectPtr& theObject)
327 {
328   // Create point-edge coincedence
329   FeaturePtr aFeature = mySketch->addFeature(SketchPlugin_ConstraintCoincidence::ID());
330   std::shared_ptr<ModelAPI_Data> aData = aFeature->data();
331
332   std::shared_ptr<ModelAPI_AttributeRefAttr> aRef1 = std::dynamic_pointer_cast<
333       ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
334   AttributePtr aThisAttr = feature()->data()->attribute(attributeID());
335   std::shared_ptr<GeomDataAPI_Point2D> aThisPoint = 
336     std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aThisAttr);
337   aRef1->setAttr(aThisPoint);
338
339   std::shared_ptr<ModelAPI_AttributeRefAttr> aRef2 = std::dynamic_pointer_cast<
340       ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
341   aRef2->setObject(theObject);
342
343   aFeature->execute();
344 }
345
346 void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
347 {
348   // the contex menu release by the right button should not be processed by this widget
349   if (theEvent->button() != Qt::LeftButton)
350     return;
351
352   ModuleBase_ISelection* aSelection = myWorkshop->selection();
353   Handle(V3d_View) aView = theWnd->v3dView();
354   // TODO: This fragment doesn't work because bug in OCC Viewer. It can be used after fixing.
355   NCollection_List<TopoDS_Shape> aShapes;
356   std::list<ObjectPtr> aObjects;
357   aSelection->selectedShapes(aShapes, aObjects);
358   // if we have selection
359   if (aShapes.Extent() > 0) {
360     TopoDS_Shape aShape = aShapes.First();
361     ObjectPtr aObject = aObjects.front();
362     FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aObject);
363     bool anExternal = false;
364       std::shared_ptr<SketchPlugin_Feature> aSPFeature;
365       if (aSelectedFeature.get() != NULL)
366         aSPFeature = std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
367       if ((!aSPFeature) && (!aShape.IsNull())) {
368         anExternal = true;
369         ResultPtr aFixedObject = PartSet_Tools::findFixedObjectByExternal(aShape, aObject, mySketch);
370         if (!aFixedObject.get())
371           aObject = PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
372
373         double aX, aY;
374         if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) {
375           // do not create a constraint to the point, which already used by the feature
376           // if the feature contains the point, focus is not switched
377           setPoint(aX, aY);
378         }
379         else {
380           if (getPoint2d(aView, aShape, aX, aY))
381             setPoint(aX, aY);
382           bool anOrphanPoint = aShape.ShapeType() == TopAbs_VERTEX ||
383                                isOrphanPoint(aSelectedFeature, mySketch, aX, aY);
384           setConstraintWith(aObject);
385           if (!anOrphanPoint)
386             emit vertexSelected();
387           emit focusOutWidget(this);
388         }
389       }
390     if (!anExternal) {
391       double aX, aY;
392       bool isProcessed = false;
393       if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) {
394         // when the point is selected, the coordinates of the point should be set into the attribute
395         // if the feature contains the point, focus is not switched
396         setPoint(aX, aY);
397       }
398       else {
399         bool anOrphanPoint = isOrphanPoint(aSelectedFeature, mySketch, aX, aY);
400         // do not set a coincidence constraint in the attribute if the feature contains a point
401         // with the same coordinates. It is important for line creation in order to do not set
402         // the same constraints for the same points, oterwise the result line has zero length.
403         if (getPoint2d(aView, aShape, aX, aY)) {
404           setPoint(aX, aY);
405           PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
406         }
407         else if (aShape.ShapeType() == TopAbs_EDGE) {
408           if (MyFeaturesForCoincedence.contains(myFeature->getKind().c_str()))
409             setConstraintWith(aObject);
410         }
411         // it is important to perform updateObject() in order to the current value is 
412         // processed by Sketch Solver. Test case: line is created from a previous point
413         // to some distance, but in the area of the highlighting of the point. Constraint
414         // coincidence is created, after the solver is performed, the distance between the
415         // points of the line becomes less than the tolerance. Validator of the line returns
416         // false, the line will be aborted, but sketch stays valid.
417         updateObject(feature());
418         if (!anOrphanPoint)
419           emit vertexSelected();
420         emit focusOutWidget(this);
421       }
422     }
423   }
424   // End of Bug dependent fragment
425   else {
426     // A case when point is taken from mouse event
427     gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
428     double aX, anY;
429     PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, anY);
430
431     // if the feature contains the point, focus is not switched
432     if (!setPoint(aX, anY) || isFeatureContainsPoint(myFeature, aX, anY))
433       return;
434
435     /// Start alternative code
436     //std::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint = std::dynamic_pointer_cast<
437     //    GeomDataAPI_Point2D>(feature()->data()->attribute(attributeID()));
438     //QList<FeaturePtr> aIgnore;
439     //aIgnore.append(feature());
440
441     //double aTolerance = aView->Convert(7);
442     //std::shared_ptr<GeomDataAPI_Point2D> aAttrPnt = 
443     //  PartSet_Tools::findAttributePoint(mySketch, aX, anY, aTolerance, aIgnore);
444     //if (aAttrPnt.get() != NULL) {
445     //  aFeaturePoint->setValue(aAttrPnt->pnt());
446     //  PartSet_Tools::createConstraint(mySketch, aAttrPnt, aFeaturePoint);
447     //  emit vertexSelected();
448     //}
449     /// End alternative code
450     emit focusOutWidget(this);
451   }
452 }
453
454
455 void PartSet_WidgetPoint2D::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
456 {
457   if (isEditingMode())
458     return;
459
460   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
461
462   double aX, anY;
463   PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, anY);
464   // we need to block the value state change 
465   bool isBlocked = blockValueState(true);
466   setPoint(aX, anY);
467   blockValueState(isBlocked);
468   setValueState(ModifiedInViewer);
469 }
470
471 double PartSet_WidgetPoint2D::x() const
472 {
473   return myXSpin->value();
474 }
475
476 double PartSet_WidgetPoint2D::y() const
477 {
478   return myYSpin->value();
479 }
480
481
482 bool PartSet_WidgetPoint2D::isFeatureContainsPoint(const FeaturePtr& theFeature,
483                                                    double theX, double theY)
484 {
485   bool aPointIsFound = false;
486
487   if (feature()->getKind() != SketchPlugin_Line::ID())
488     return aPointIsFound;
489
490   AttributePtr aWidgetAttribute = myFeature->attribute(attributeID());
491
492   std::shared_ptr<GeomAPI_Pnt2d> aPnt2d = 
493                                     std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
494   std::list<AttributePtr> anAttributes =
495                                 myFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
496   std::list<AttributePtr>::iterator anIter = anAttributes.begin();
497   for(; anIter != anAttributes.end() && !aPointIsFound; anIter++) {
498     AttributePoint2DPtr aPoint2DAttribute =
499       std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIter);
500     if (aPoint2DAttribute == aWidgetAttribute)
501       continue;
502     if (aPoint2DAttribute.get() && aPoint2DAttribute->isInitialized()) {
503       aPointIsFound = aPoint2DAttribute->pnt()->isEqual(aPnt2d);
504     }
505   }
506   return aPointIsFound;
507 }
508
509 void PartSet_WidgetPoint2D::initializeValueByActivate()
510 {
511 }
512
513 /*void PartSet_WidgetPoint2D::onValuesChanged()
514 {
515   emit valuesChanged();
516 }*/
517
518 bool PartSet_WidgetPoint2D::processEnter()
519 {
520   bool isModified = getValueState() == ModifiedInPP;
521   if (isModified) {
522     bool isXModified = myXSpin->hasFocus();
523     emit valuesChanged();
524     if (isXModified)
525       myXSpin->selectAll();
526     else
527       myYSpin->selectAll();
528   }
529   return isModified;
530 }
531
532 bool PartSet_WidgetPoint2D::isOrphanPoint(const FeaturePtr& theFeature,
533                                           const CompositeFeaturePtr& theSketch,
534                                           double theX, double theY)
535 {
536   bool anOrphanPoint = false;
537   if (theFeature.get()) {
538     std::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
539     std::string aFeatureKind = theFeature->getKind();
540     if (aFeatureKind == SketchPlugin_Point::ID())
541       aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
542                                        theFeature->attribute(SketchPlugin_Point::COORD_ID()));
543     else if (aFeatureKind == SketchPlugin_Circle::ID())
544       aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
545                                        theFeature->attribute(SketchPlugin_Circle::CENTER_ID()));
546
547     else if (aFeatureKind == SketchPlugin_Arc::ID())
548       aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
549                                        theFeature->attribute(SketchPlugin_Arc::CENTER_ID()));
550
551     /// check that the geometry point with the given coordinates is the checked point
552     /// e.g. in arc the (x,y) point can not coicide to the center point and it automatically
553     /// means that this point is not an orphant one.
554     if (aPointAttr.get()) {
555       std::shared_ptr<GeomAPI_Pnt2d> aCheckedPoint = std::shared_ptr<GeomAPI_Pnt2d>(
556                                                     new GeomAPI_Pnt2d(theX, theY));
557       if (!aCheckedPoint->isEqual(aPointAttr->pnt()))
558         return anOrphanPoint;
559     }
560
561     if (aPointAttr.get()) {
562       std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointAttr->pnt();
563       FeaturePtr aCoincidence = PartSet_Tools::findFirstCoincidence(theFeature, aPoint);
564       anOrphanPoint = true;
565       // if there is at least one concident line to the point, the point is not an orphant
566       if (aCoincidence.get()) {
567         QList<FeaturePtr> aCoinsideLines;
568         PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines,
569                                         SketchPlugin_ConstraintCoincidence::ENTITY_A());
570         PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines,
571                                         SketchPlugin_ConstraintCoincidence::ENTITY_B());
572         QList<FeaturePtr>::const_iterator anIt = aCoinsideLines.begin(),
573                                           aLast = aCoinsideLines.end();
574         for (; anIt != aLast && anOrphanPoint; anIt++) {
575           anOrphanPoint = (*anIt)->getKind() != SketchPlugin_Line::ID();
576         }
577       }
578     }
579   }
580   return anOrphanPoint;
581 }