1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_WidgetPoint2D.cpp
4 // Created: 25 Apr 2014
5 // Author: Natalia ERMOLAEVA
7 #include "PartSet_WidgetPoint2d.h"
8 #include <PartSet_Tools.h>
9 #include <PartSet_Module.h>
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>
17 #include <Config_Keywords.h>
18 #include <Config_WidgetAPI.h>
20 #include <Events_Loop.h>
21 #include <ModelAPI_Events.h>
22 #include <ModelAPI_AttributeBoolean.h>
24 #include <ModelAPI_Feature.h>
25 #include <ModelAPI_Data.h>
26 #include <ModelAPI_Object.h>
27 #include <GeomDataAPI_Point2D.h>
28 #include <GeomAPI_Pnt2d.h>
30 #include <SketchPlugin_Feature.h>
31 #include <SketchPlugin_ConstraintCoincidence.h>
32 #include <SketchPlugin_Line.h>
33 #include <SketchPlugin_Arc.h>
34 #include <SketchPlugin_Circle.h>
35 #include <SketchPlugin_Point.h>
38 #include <QGridLayout>
41 #include <QMouseEvent>
42 #include <QApplication>
45 #include <TopoDS_Vertex.hxx>
46 #include <BRep_Tool.hxx>
51 const double MaxCoordinate = 1e12;
53 static QStringList MyFeaturesForCoincedence;
55 PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
56 ModuleBase_IWorkshop* theWorkshop,
57 const Config_WidgetAPI* theData,
58 const std::string& theParentId)
59 : ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop),
60 myValueIsCashed(false), myXValueInCash(0), myYValueInCash(0)
62 if (MyFeaturesForCoincedence.isEmpty()) {
63 MyFeaturesForCoincedence << SketchPlugin_Line::ID().c_str()
64 << SketchPlugin_Arc::ID().c_str()
65 << SketchPlugin_Point::ID().c_str()
66 << SketchPlugin_Circle::ID().c_str();
69 // the control should accept the focus, so the boolean flag is corrected to be true
70 myIsObligatory = true;
71 //myOptionParam = theData->getProperty(PREVIOUS_FEATURE_PARAM);
72 QString aPageName = QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME));
73 myGroupBox = new QGroupBox(aPageName, theParent);
74 myGroupBox->setFlat(false);
76 bool aAcceptVariables = theData->getBooleanAttribute(DOUBLE_WDG_ACCEPT_EXPRESSIONS, true);
78 QGridLayout* aGroupLay = new QGridLayout(myGroupBox);
79 ModuleBase_Tools::adjustMargins(aGroupLay);
80 aGroupLay->setSpacing(2);
81 aGroupLay->setColumnStretch(1, 1);
83 QLabel* aLabel = new QLabel(myGroupBox);
84 aLabel->setText(tr("X "));
85 aGroupLay->addWidget(aLabel, 0, 0);
87 myXSpin = new ModuleBase_ParamSpinBox(myGroupBox);
88 myXSpin->setAcceptVariables(aAcceptVariables);
89 myXSpin->setMinimum(-DBL_MAX);
90 myXSpin->setMaximum(DBL_MAX);
91 myXSpin->setToolTip(tr("X"));
92 aGroupLay->addWidget(myXSpin, 0, 1);
94 connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
97 QLabel* aLabel = new QLabel(myGroupBox);
98 aLabel->setText(tr("Y "));
99 aGroupLay->addWidget(aLabel, 1, 0);
101 myYSpin = new ModuleBase_ParamSpinBox(myGroupBox);
102 myYSpin->setAcceptVariables(aAcceptVariables);
103 myYSpin->setMinimum(-DBL_MAX);
104 myYSpin->setMaximum(DBL_MAX);
105 myYSpin->setToolTip(tr("Y"));
106 aGroupLay->addWidget(myYSpin, 1, 1);
108 connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
110 QVBoxLayout* aLayout = new QVBoxLayout(this);
111 ModuleBase_Tools::zeroMargins(aLayout);
112 aLayout->addWidget(myGroupBox);
116 bool PartSet_WidgetPoint2D::resetCustom()
119 if (!isUseReset() || isComputedDefault() || myXSpin->hasVariable() || myYSpin->hasVariable()) {
123 if (myValueIsCashed) {
124 // fill the control widgets by the cashed value
125 restoreCurentValue();
126 // store value to the model
128 setValueState(Stored);
133 double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
134 // it is important to block the spin box control in order to do not through out the
135 // locking of the validating state.
136 ModuleBase_Tools::setSpinValue(myXSpin, isOk ? aDefValue : 0.0);
137 ModuleBase_Tools::setSpinValue(myYSpin, isOk ? aDefValue : 0.0);
145 PartSet_WidgetPoint2D::~PartSet_WidgetPoint2D()
149 bool PartSet_WidgetPoint2D::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
150 const bool theToValidate)
153 if (theValues.empty())
156 ModuleBase_ViewerPrs aValue = theValues.takeFirst();
157 TopoDS_Shape aShape = aValue.shape();
158 if (!aShape.IsNull()) {
159 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
161 if (getPoint2d(aView, aShape, aX, aY)) {
162 isDone = setPoint(aX, aY);
163 PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
166 else if (canBeActivatedByMove()) {
167 if (feature()->getKind() == SketchPlugin_Line::ID()) {
168 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aValue.object());
169 // Initialize new line with first point equal to end of previous
170 if (aFeature.get()) {
171 std::shared_ptr<ModelAPI_Data> aData = aFeature->data();
172 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
173 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
174 aData->attribute(SketchPlugin_Line::END_ID()));
176 setPoint(aPoint->x(), aPoint->y());
177 PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aPoint->x(),
187 void PartSet_WidgetPoint2D::selectContent()
189 myXSpin->selectAll();
192 bool PartSet_WidgetPoint2D::setPoint(double theX, double theY)
194 if (fabs(theX) >= MaxCoordinate)
196 if (fabs(theY) >= MaxCoordinate)
199 ModuleBase_Tools::setSpinValue(myXSpin, theX);
200 ModuleBase_Tools::setSpinValue(myYSpin, theY);
206 bool PartSet_WidgetPoint2D::storeValueCustom() const
208 std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
209 if (!aData) // can be on abort of sketcher element
211 std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
212 aData->attribute(attributeID()));
214 PartSet_WidgetPoint2D* that = (PartSet_WidgetPoint2D*) this;
215 bool isBlocked = that->blockSignals(true);
216 bool isImmutable = aPoint->setImmutable(true);
218 // if text is not empty then setValue will be ignored
219 // so we should set the text at first
220 aPoint->setText(myXSpin->hasVariable() ? myXSpin->text().toStdString() : "",
221 myYSpin->hasVariable() ? myYSpin->text().toStdString() : "");
222 aPoint->setValue(!myXSpin->hasVariable() ? myXSpin->value() : aPoint->x(),
223 !myYSpin->hasVariable() ? myYSpin->value() : aPoint->y());
225 // after movement the solver will call the update event: optimization
226 moveObject(myFeature);
227 aPoint->setImmutable(isImmutable);
228 that->blockSignals(isBlocked);
233 bool PartSet_WidgetPoint2D::restoreValueCustom()
235 std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
236 std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
237 aData->attribute(attributeID()));
238 QString aTextX = QString::fromStdString(aPoint->textX());
239 QString aTextY = QString::fromStdString(aPoint->textY());
241 bool isDouble = false;
243 if (aTextX.isEmpty()) {
244 ModuleBase_Tools::setSpinValue(myXSpin, aPoint->x());
246 aVal = aTextX.toDouble(&isDouble);
248 ModuleBase_Tools::setSpinValue(myXSpin, aVal);
250 ModuleBase_Tools::setSpinText(myXSpin, aTextX);
252 if (aTextY.isEmpty()) {
253 ModuleBase_Tools::setSpinValue(myYSpin, aPoint->y());
255 aVal = aTextY.toDouble(&isDouble);
257 ModuleBase_Tools::setSpinValue(myYSpin, aVal);
259 ModuleBase_Tools::setSpinText(myYSpin, aTextY);
261 //if (aTextX.empty() || aTextY.empty()) {
262 // ModuleBase_Tools::setSpinValue(myXSpin, aPoint->x());
263 // ModuleBase_Tools::setSpinValue(myYSpin, aPoint->y());
265 // ModuleBase_Tools::setSpinText(myXSpin, QString::fromStdString(aTextX));
266 // ModuleBase_Tools::setSpinText(myYSpin, QString::fromStdString(aTextY));
271 void PartSet_WidgetPoint2D::storeCurentValue()
273 // do not use cash if a variable is used
274 if (myXSpin->hasVariable() || myYSpin->hasVariable())
277 myValueIsCashed = true;
278 myXValueInCash = myXSpin->value();
279 myYValueInCash = myYSpin->value();
282 void PartSet_WidgetPoint2D::restoreCurentValue()
284 myValueIsCashed = false;
285 ModuleBase_Tools::setSpinValue(myXSpin, myXValueInCash);
286 ModuleBase_Tools::setSpinValue(myYSpin, myYValueInCash);
289 QList<QWidget*> PartSet_WidgetPoint2D::getControls() const
291 QList<QWidget*> aControls;
292 aControls.append(myXSpin);
293 aControls.append(myYSpin);
298 void PartSet_WidgetPoint2D::activateCustom()
300 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
301 connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
302 this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
303 connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
304 this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
307 aModes << TopAbs_VERTEX;
308 aModes << TopAbs_EDGE;
309 myWorkshop->activateSubShapesSelection(aModes);
311 if (!isEditingMode()) {
312 FeaturePtr aFeature = feature();
313 if (aFeature.get() && aFeature->getKind() == SketchPlugin_Point::ID())
318 bool PartSet_WidgetPoint2D::canBeActivatedByMove()
320 bool aCanBeActivated = false;
321 if (feature()->getKind() == SketchPlugin_Line::ID() &&
322 attributeID() == SketchPlugin_Line::START_ID())
323 aCanBeActivated = true;
325 return aCanBeActivated;
328 void PartSet_WidgetPoint2D::deactivate()
330 // the value of the control should be stored to model if it was not
331 // initialized yet. It is important when we leave this control by Tab key.
332 // It should not be performed by the widget activation as the preview
333 // is visualized with default value. Line point is moved to origin.
334 AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
335 if (anAttribute && !anAttribute->isInitialized())
338 ModuleBase_ModelWidget::deactivate();
339 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
340 disconnect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
341 this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
342 disconnect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
343 this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
345 myWorkshop->deactivateSubShapesSelection();
348 bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView,
349 const TopoDS_Shape& theShape,
350 double& theX, double& theY) const
352 if (!theShape.IsNull()) {
353 if (theShape.ShapeType() == TopAbs_VERTEX) {
354 const TopoDS_Vertex& aVertex = TopoDS::Vertex(theShape);
355 if (!aVertex.IsNull()) {
356 // A case when point is taken from existing vertex
357 gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
358 PartSet_Tools::convertTo2D(aPoint, mySketch, theView, theX, theY);
366 void PartSet_WidgetPoint2D::setConstraintWith(const ObjectPtr& theObject)
368 // Create point-edge coincedence
369 FeaturePtr aFeature = mySketch->addFeature(SketchPlugin_ConstraintCoincidence::ID());
370 std::shared_ptr<ModelAPI_Data> aData = aFeature->data();
372 std::shared_ptr<ModelAPI_AttributeRefAttr> aRef1 = std::dynamic_pointer_cast<
373 ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
374 AttributePtr aThisAttr = feature()->data()->attribute(attributeID());
375 std::shared_ptr<GeomDataAPI_Point2D> aThisPoint =
376 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aThisAttr);
377 aRef1->setAttr(aThisPoint);
379 std::shared_ptr<ModelAPI_AttributeRefAttr> aRef2 = std::dynamic_pointer_cast<
380 ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
381 aRef2->setObject(theObject);
386 void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
388 // the contex menu release by the right button should not be processed by this widget
389 if (theEvent->button() != Qt::LeftButton)
392 ModuleBase_ISelection* aSelection = myWorkshop->selection();
393 Handle(V3d_View) aView = theWnd->v3dView();
394 // TODO: This fragment doesn't work because bug in OCC Viewer. It can be used after fixing.
395 NCollection_List<TopoDS_Shape> aShapes;
396 std::list<ObjectPtr> aObjects;
397 aSelection->selectedShapes(aShapes, aObjects);
398 // if we have selection and use it
399 if (aShapes.Extent() > 0 && useSelectedShapes()) {
400 TopoDS_Shape aShape = aShapes.First();
401 ObjectPtr aObject = aObjects.front();
402 FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aObject);
403 bool anExternal = false;
404 std::shared_ptr<SketchPlugin_Feature> aSPFeature;
405 if (aSelectedFeature.get() != NULL)
406 aSPFeature = std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
407 if ((!aSPFeature && !aShape.IsNull()) ||
408 (aSPFeature.get() && aSPFeature->isExternal())) {
410 ResultPtr aFixedObject = PartSet_Tools::findFixedObjectByExternal(aShape, aObject, mySketch);
411 if (!aFixedObject.get())
412 aFixedObject = PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
415 if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) {
416 // do not create a constraint to the point, which already used by the feature
417 // if the feature contains the point, focus is not switched
421 if (getPoint2d(aView, aShape, aX, aY))
424 setValueState(Stored); // in case of edge selection, Apply state should also be updated
425 bool anOrphanPoint = aShape.ShapeType() == TopAbs_VERTEX ||
426 isOrphanPoint(aSelectedFeature, mySketch, aX, aY);
428 anOrphanPoint = true; // we should not stop reentrant operation on external objects because
429 // they are not participate in the contour creation excepting external vertices
430 if (aShape.ShapeType() == TopAbs_VERTEX) {
431 FeaturePtr aFixedFeature = ModelAPI_Feature::feature(aFixedObject);
432 if (aFixedFeature.get() && aFixedFeature->getKind() == SketchPlugin_Point::ID()) {
433 anOrphanPoint = isOrphanPoint(aFixedFeature, mySketch, aX, aY, true);
438 setConstraintWith(aFixedObject);
439 // fignal updated should be flushed in order to visualize possible created external objects
440 // e.g. selection of trihedron axis when input end arc point
441 updateObject(feature());
444 emit vertexSelected(); // it stops the reentrant operation
446 emit focusOutWidget(this);
451 bool isProcessed = false;
452 if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) {
453 // when the point is selected, the coordinates of the point should be set into the attribute
454 // if the feature contains the point, focus is not switched
458 bool anOrphanPoint = isOrphanPoint(aSelectedFeature, mySketch, aX, aY);
459 // do not set a coincidence constraint in the attribute if the feature contains a point
460 // with the same coordinates. It is important for line creation in order to do not set
461 // the same constraints for the same points, oterwise the result line has zero length.
462 bool isAuxiliaryFeature = false;
463 if (getPoint2d(aView, aShape, aX, aY)) {
465 PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
467 else if (aShape.ShapeType() == TopAbs_EDGE) {
468 if (MyFeaturesForCoincedence.contains(myFeature->getKind().c_str())) {
469 setConstraintWith(aObject);
470 setValueState(Stored); // in case of edge selection, Apply state should also be updated
472 FeaturePtr anObjectFeature = ModelAPI_Feature::feature(aObject);
473 std::string anAuxiliaryAttribute = SketchPlugin_SketchEntity::AUXILIARY_ID();
474 AttributeBooleanPtr anAuxiliaryAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(
475 anObjectFeature->data()->attribute(anAuxiliaryAttribute));
476 if (anAuxiliaryAttr.get())
477 isAuxiliaryFeature = anAuxiliaryAttr->value();
480 // it is important to perform updateObject() in order to the current value is
481 // processed by Sketch Solver. Test case: line is created from a previous point
482 // to some distance, but in the area of the highlighting of the point. Constraint
483 // coincidence is created, after the solver is performed, the distance between the
484 // points of the line becomes less than the tolerance. Validator of the line returns
485 // false, the line will be aborted, but sketch stays valid.
486 updateObject(feature());
487 if (!anOrphanPoint && !anExternal && !isAuxiliaryFeature)
488 emit vertexSelected();
489 emit focusOutWidget(this);
493 // End of Bug dependent fragment
495 // A case when point is taken from mouse event
496 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
498 PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, anY);
500 // if the feature contains the point, focus is not switched
501 if (!setPoint(aX, anY) || isFeatureContainsPoint(myFeature, aX, anY))
504 /// Start alternative code
505 //std::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint = std::dynamic_pointer_cast<
506 // GeomDataAPI_Point2D>(feature()->data()->attribute(attributeID()));
507 //QList<FeaturePtr> aIgnore;
508 //aIgnore.append(feature());
510 //double aTolerance = aView->Convert(7);
511 //std::shared_ptr<GeomDataAPI_Point2D> aAttrPnt =
512 // PartSet_Tools::findAttributePoint(mySketch, aX, anY, aTolerance, aIgnore);
513 //if (aAttrPnt.get() != NULL) {
514 // aFeaturePoint->setValue(aAttrPnt->pnt());
515 // PartSet_Tools::createConstraint(mySketch, aAttrPnt, aFeaturePoint);
516 // emit vertexSelected();
518 /// End alternative code
519 emit focusOutWidget(this);
524 void PartSet_WidgetPoint2D::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
529 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
532 PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, anY);
533 if (myState != ModifiedInViewer)
535 // we need to block the value state change
536 bool isBlocked = blockValueState(true);
538 blockValueState(isBlocked);
539 setValueState(ModifiedInViewer);
542 double PartSet_WidgetPoint2D::x() const
544 return myXSpin->value();
547 double PartSet_WidgetPoint2D::y() const
549 return myYSpin->value();
553 bool PartSet_WidgetPoint2D::isFeatureContainsPoint(const FeaturePtr& theFeature,
554 double theX, double theY)
556 bool aPointIsFound = false;
558 if (feature()->getKind() != SketchPlugin_Line::ID())
559 return aPointIsFound;
561 AttributePtr aWidgetAttribute = myFeature->attribute(attributeID());
563 std::shared_ptr<GeomAPI_Pnt2d> aPnt2d =
564 std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
565 std::list<AttributePtr> anAttributes =
566 myFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
567 std::list<AttributePtr>::iterator anIter = anAttributes.begin();
568 for(; anIter != anAttributes.end() && !aPointIsFound; anIter++) {
569 AttributePoint2DPtr aPoint2DAttribute =
570 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIter);
571 if (aPoint2DAttribute == aWidgetAttribute)
573 if (aPoint2DAttribute.get() && aPoint2DAttribute->isInitialized()) {
574 aPointIsFound = aPoint2DAttribute->pnt()->isEqual(aPnt2d);
577 return aPointIsFound;
580 void PartSet_WidgetPoint2D::initializeValueByActivate()
584 /*void PartSet_WidgetPoint2D::onValuesChanged()
586 emit valuesChanged();
589 bool PartSet_WidgetPoint2D::processEnter()
591 bool isModified = getValueState() == ModifiedInPP;
593 bool isXModified = myXSpin->hasFocus();
594 emit valuesChanged();
596 myXSpin->selectAll();
598 myYSpin->selectAll();
603 bool PartSet_WidgetPoint2D::useSelectedShapes() const
608 bool PartSet_WidgetPoint2D::isOrphanPoint(const FeaturePtr& theFeature,
609 const CompositeFeaturePtr& theSketch,
610 double theX, double theY, const bool theSearchInResults)
612 bool anOrphanPoint = false;
613 if (theFeature.get()) {
614 std::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
615 std::string aFeatureKind = theFeature->getKind();
616 if (aFeatureKind == SketchPlugin_Point::ID())
617 aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
618 theFeature->attribute(SketchPlugin_Point::COORD_ID()));
619 else if (aFeatureKind == SketchPlugin_Circle::ID())
620 aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
621 theFeature->attribute(SketchPlugin_Circle::CENTER_ID()));
623 else if (aFeatureKind == SketchPlugin_Arc::ID())
624 aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
625 theFeature->attribute(SketchPlugin_Arc::CENTER_ID()));
627 /// check that the geometry point with the given coordinates is the checked point
628 /// e.g. in arc the (x,y) point can not coicide to the center point and it automatically
629 /// means that this point is not an orphant one.
630 if (aPointAttr.get()) {
631 std::shared_ptr<GeomAPI_Pnt2d> aCheckedPoint = std::shared_ptr<GeomAPI_Pnt2d>(
632 new GeomAPI_Pnt2d(theX, theY));
633 if (!aCheckedPoint->isEqual(aPointAttr->pnt()))
634 return anOrphanPoint;
637 if (aPointAttr.get()) {
638 std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointAttr->pnt();
639 // we need to find coincidence features in results also, because external object(point)
640 // uses refs to me in another feature.
641 FeaturePtr aCoincidence = PartSet_Tools::findFirstCoincidence(theFeature, aPoint, theSearchInResults);
642 anOrphanPoint = true;
643 // if there is at least one concident line to the point, the point is not an orphant
644 if (aCoincidence.get()) {
645 QList<FeaturePtr> aCoinsideLines;
646 PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines,
647 SketchPlugin_ConstraintCoincidence::ENTITY_A());
648 PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines,
649 SketchPlugin_ConstraintCoincidence::ENTITY_B());
650 QList<FeaturePtr>::const_iterator anIt = aCoinsideLines.begin(),
651 aLast = aCoinsideLines.end();
652 for (; anIt != aLast && anOrphanPoint; anIt++) {
653 anOrphanPoint = (*anIt)->getKind() != SketchPlugin_Line::ID();
658 return anOrphanPoint;