#include <GeomAPI_Pnt2d.h>
#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_ConstraintCoincidence.h>
#include <QGroupBox>
#include <QGridLayout>
{
}
-bool PartSet_WidgetPoint2D::setSelection(ModuleBase_ViewerPrs theValue)
+bool PartSet_WidgetPoint2D::setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition)
{
+ if (thePosition < 0 || thePosition >= theValues.size())
+ return false;
+ ModuleBase_ViewerPrs aValue = theValues[thePosition];
+ thePosition++;
+
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
bool isDone = false;
- TopoDS_Shape aShape = theValue.shape();
+ TopoDS_Shape aShape = aValue.shape();
double aX, aY;
if (getPoint2d(aView, aShape, aX, aY)) {
isDone = setPoint(aX, aY);
QIntList aModes;
aModes << TopAbs_VERTEX;
- if (isEditingMode())
- aModes << TopAbs_EDGE;
+ aModes << TopAbs_EDGE;
myWorkshop->moduleConnector()->activateSubShapesSelection(aModes);
}
emit vertexSelected();
emit focusOutWidget(this);
return;
+ } else if (aShape.ShapeType() == TopAbs_EDGE) {
+ // Create point-edge coincedence
+ FeaturePtr aFeature = mySketch->addFeature(SketchPlugin_ConstraintCoincidence::ID());
+ std::shared_ptr<ModelAPI_Data> aData = aFeature->data();
+
+ std::shared_ptr<ModelAPI_AttributeRefAttr> aRef1 = std::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ AttributePtr aThisAttr = feature()->data()->attribute(attributeID());
+ std::shared_ptr<GeomDataAPI_Point2D> aThisPoint =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aThisAttr);
+ aRef1->setAttr(aThisPoint);
+
+ std::shared_ptr<ModelAPI_AttributeRefAttr> aRef2 = std::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
+ aRef2->setObject(aObject);
+ aFeature->execute();
+ emit vertexSelected();
+ emit focusOutWidget(this);
+ return;
}
}
// End of Bug dependent fragment