Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aTDShape, mySketch);
+
if (aPnt) {
- isDone = setPoint(aPnt->x(), aPnt->y());
- setConstraintToPoint(aPnt->x(), aPnt->y(), aValue);
+ //isDone = setPoint(aPnt->x(), aPnt->y());
+ //setConstraintToPoint(aPnt->x(), aPnt->y(), aValue);
+ processSelection(aValue, aPnt->x(), aPnt->y());
+ isDone = true;
}
}
}
return isDone;
}
-void PartSet_WidgetPoint2D::selectContent()
-{
- // myXSpin->selectAll();
-}
+//void PartSet_WidgetPoint2D::selectContent()
+//{
+// // myXSpin->selectAll();
+//}
bool PartSet_WidgetPoint2D::setPoint(double theX, double theY)
{
aFirstValue = myPreSelected;
}
+ double aX=0, aY=0;
+ bool aHasPoint = false;
+ if (aFirstValue.get()) {
+ GeomShapePtr aShape = aFirstValue->shape();
+ if (aShape->shapeType() == TopAbs_VERTEX) {
+ const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+ GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aTDShape, mySketch);
+ aX = aPnt->x();
+ aY = aPnt->y();
+ aHasPoint = true;
+ }
+ }
+ if (!aHasPoint) {
+ gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
+ PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY);
+ }
+ processSelection(aFirstValue, aX, aY);
+}
+
+void PartSet_WidgetPoint2D::processSelection(const ModuleBase_ViewerPrsPtr& theValue,
+ double theX, double theY)
+{
+ if (!setPoint(theX, theY))
+ return;
// if we have selection and use it
- if (aFirstValue.get() && isValidSelectionCustom(aFirstValue) &&
- aFirstValue->shape().get()) { /// Trihedron Axis may be selected, but shape is empty
- GeomShapePtr aGeomShape = aFirstValue->shape();
+ if (theValue.get() && isValidSelectionCustom(theValue) && theValue->shape().get()) {
+ /// Trihedron Axis may be selected, but shape is empty
+ GeomShapePtr aGeomShape = theValue->shape();
TopoDS_Shape aShape = aGeomShape->impl<TopoDS_Shape>();
- ObjectPtr aObject = aFirstValue->object();
+ ObjectPtr aObject = theValue->object();
FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aObject);
bool anExternal = false;
}
}
if (anExternal) {
- GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aShape, mySketch);
- double aX = 0, aY = 0;
- if (aPnt) {
- aX = aPnt->x();
- aY = aPnt->y();
- }
- if (aPnt && isFeatureContainsPoint(myFeature, aX, aY)) {
- // do not create a constraint to the point, which already used by the feature
- // if the feature contains the point, focus is not switched
- setPoint(aX, aY);
- }
- else {
- if (aPnt)
- setPoint(aX, aY);
- else {
- if (aShape.ShapeType() == TopAbs_EDGE) {
- // point is taken from mouse event and set in attribute. It should be done before set
- // coinident constraint to the external line. If a point is created, it should be in
- // the mouse clicked point
- gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(),
- theWindow->v3dView());
- PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY);
- setPoint(aX, aY);
- }
+ if (!isFeatureContainsPoint(myFeature, theX, theY)) {
+ if (aShape.ShapeType() == TopAbs_EDGE) {
setValueState(Stored); // in case of edge selection, Apply state should also be updated
}
bool anOrphanPoint = aShape.ShapeType() == TopAbs_VERTEX ||
- isOrphanPoint(aSelectedFeature, mySketch, aX, aY);
+ isOrphanPoint(aSelectedFeature, mySketch, theX, theY);
if (anExternal) {
// we should not stop reentrant operation on external objects because
anOrphanPoint = true;
if (aShape.ShapeType() == TopAbs_VERTEX) {
FeaturePtr aFixedFeature = ModelAPI_Feature::feature(aFixedObject);
if (aFixedFeature.get() && aFixedFeature->getKind() == SketchPlugin_Point::ID()) {
- anOrphanPoint = isOrphanPoint(aFixedFeature, mySketch, aX, aY);
+ anOrphanPoint = isOrphanPoint(aFixedFeature, mySketch, theX, theY);
}
}
}
emit focusOutWidget(this);
}
}
- if (!anExternal) {
- GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aShape, mySketch);
- if (aPnt && isFeatureContainsPoint(myFeature, aPnt->x(), aPnt->y())) {
- // when the point is selected, the coordinates of the point should be set into the attribute
- // if the feature contains the point, focus is not switched
- setPoint(aPnt->x(), aPnt->y());
- }
- else {
+ else {
+ if (!isFeatureContainsPoint(myFeature, theX, theY)) {
double aX = 0, aY = 0;
bool anOrphanPoint = isOrphanPoint(aSelectedFeature, mySketch, aX, aY);
// do not set a coincidence constraint in the attribute if the feature contains a point
// with the same coordinates. It is important for line creation in order to do not set
// the same constraints for the same points, oterwise the result line has zero length.
bool isAuxiliaryFeature = false;
- if (aPnt) {
- aX = aPnt->x();
- aY = aPnt->y();
- setPoint(aX, aY);
- setConstraintToPoint(aX, aY, aFirstValue);
+ if (aShape.ShapeType() == TopAbs_VERTEX) {
+ setConstraintToPoint(theX, theY, theValue);
}
else if (aShape.ShapeType() == TopAbs_EDGE) {
// point is taken from mouse event and set in attribute. It should be done before setting
// coinident constraint to the external line. If a point is created, it should be in
// the mouse clicked point
- gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView());
- PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY);
- setPoint(aX, aY);
setConstraintToObject(aObject);
setValueState(Stored); // in case of edge selection, Apply state should also be updated
isAuxiliaryFeature = PartSet_Tools::isAuxiliarySketchEntity(aObject);
}
}
// The selection could be a center of an external circular object
- else if (aFirstValue.get() && (!aFirstValue->interactive().IsNull())) {
+ else if (theValue.get() && (!theValue->interactive().IsNull())) {
Handle(PartSet_CenterPrs) aAIS =
- Handle(PartSet_CenterPrs)::DownCast(aFirstValue->interactive());
+ Handle(PartSet_CenterPrs)::DownCast(theValue->interactive());
if (!aAIS.IsNull()) {
gp_Pnt aPntComp = aAIS->Component()->Pnt();
GeomVertexPtr aVertPtr(new GeomAPI_Vertex(aPntComp.X(), aPntComp.Y(), aPntComp.Z()));
// external objects e.g. selection of trihedron axis when input end arc point
updateObject(feature());
- GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aShape, mySketch);
- if (aPnt) {
- // do not create a constraint to the point, which already used by the feature
- // if the feature contains the point, focus is not switched
- setPoint(aPnt->x(), aPnt->y());
- }
emit vertexSelected(); // it stops the reentrant operation
myPreSelected.reset();
emit focusOutWidget(this);
}
else {
// A case when point is taken from mouse event
- gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView());
- double aX = 0, aY = 0;
- PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY);
// if the feature contains the point, focus is not switched
- if (!setPoint(aX, aY) || isFeatureContainsPoint(myFeature, aX, aY))
+ if (isFeatureContainsPoint(myFeature, theX, theY))
return;
myPreSelected.reset();