From: azv Date: Thu, 27 Feb 2020 05:16:46 +0000 (+0300) Subject: Fix bunch of issues for B-splines (#3155, #3156, #3157, #3159) X-Git-Tag: V9_5_0a2~86 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=629889bb85c8e4d8446651e8b597f20c14714aa1;p=modules%2Fshaper.git Fix bunch of issues for B-splines (#3155, #3156, #3157, #3159) Issue #3155: Increase low boundary of Weight for Bspline (minimal positive value of B-spline weight is set) Issue #3156: Prohibit selection of Bspline in equality constraint (Equal, Tangent and Perpendicular constraints are protected by validators) Issue #3157: Sign of Tangent constraint between ellipse arc and Bspline is shown directly on connection point Issue #3159: Equality and Intersection constraints are enabled for B-spline --- diff --git a/src/PartSet/PartSet_BSplineWidget.cpp b/src/PartSet/PartSet_BSplineWidget.cpp index 9ca97448d..b2e0334c7 100644 --- a/src/PartSet/PartSet_BSplineWidget.cpp +++ b/src/PartSet/PartSet_BSplineWidget.cpp @@ -37,6 +37,8 @@ #include +static const double THE_MIN_WEIGHT = 1.e-7; + PartSet_BSplineWidget::PartSet_BSplineWidget( QWidget* theParent, const Config_WidgetAPI* theData) @@ -175,7 +177,7 @@ QGroupBox* PartSet_BSplineWidget::createPoleWidget(BSplinePoleWidgets& thePole, thePole.myY = new ModuleBase_LabelValue(aPoleGroupBox, tr("Y")); aPoleLay->addWidget(thePole.myY, 1, 0, 1, 3); thePole.myWeight = new ModuleBase_ParamSpinBox(aPoleGroupBox); - thePole.myWeight->setMinimum(0.0); + thePole.myWeight->setMinimum(THE_MIN_WEIGHT); aPoleLay->addWidget(new QLabel(tr("Weight :"), aPoleGroupBox), 2, 0); aPoleLay->addWidget(thePole.myWeight, 2, 1); diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index f8d05fe0a..19463281c 100644 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -338,7 +338,8 @@ bool PartSet_EqualSelection::isValid(const ModuleBase_ISelection* theSelection, aType = 3; else if (aType != 3) return false; - } + } else if (aEdge.isBSpline()) + return false; } else return false; } @@ -391,23 +392,15 @@ bool PartSet_SplitSelection::isValid(const ModuleBase_ISelection* theSelection, bool PartSet_ProjectionSelection::isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const { - if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) { - return isEmptySelectionValid(theOperation); - } else { - int aCount = shapesNbLines(theSelection); - return aCount > 0; - } + return theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0 && + isEmptySelectionValid(theOperation); } bool PartSet_IntersectionSelection::isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const { - if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) { - return isEmptySelectionValid(theOperation); - } else { - int aCount = shapesNbLines(theSelection); - return aCount == 0; - } + return theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0 && + isEmptySelectionValid(theOperation); } diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 9e60ab2e3..454d8c871 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -20,6 +20,8 @@ #include "SketchPlugin_Validators.h" #include "SketchPlugin_Arc.h" +#include "SketchPlugin_BSpline.h" +#include "SketchPlugin_BSplinePeriodic.h" #include "SketchPlugin_Circle.h" #include "SketchPlugin_ConstraintCoincidence.h" #include "SketchPlugin_ConstraintDistance.h" @@ -74,6 +76,13 @@ const double tolerance = 1.e-7; +static bool isSpline(FeaturePtr theFeature) +{ + return theFeature && (theFeature->getKind() == SketchPlugin_BSpline::ID() || + theFeature->getKind() == SketchPlugin_BSplinePeriodic::ID()); +} + + bool SketchPlugin_DistanceAttrValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, Events_InfoMessage& theError) const @@ -171,6 +180,10 @@ bool SketchPlugin_TangentAttrValidator::isValid(const AttributePtr& theAttribute theError = "Two segments cannot be tangent"; return false; } + else if (isSpline(aRefFea) && isSpline(aOtherFea)) { + theError = "Two B-splines cannot be tangent"; + return false; + } return true; } else { @@ -207,15 +220,17 @@ bool SketchPlugin_PerpendicularAttrValidator::isValid(const AttributePtr& theAtt AttributeRefAttrPtr aOtherAttr = anOwner->refattr(aParamA); ObjectPtr aOtherObject = aOtherAttr->object(); FeaturePtr aOtherFea = ModelAPI_Feature::feature(aOtherObject); - if (!aOtherFea) - return true; // at least one feature should be a line if (aRefFea->getKind() != SketchPlugin_Line::ID() && - aOtherFea->getKind() != SketchPlugin_Line::ID()) { + aOtherFea && aOtherFea->getKind() != SketchPlugin_Line::ID()) { theError = "At least one feature should be a line"; return false; } + else if (isSpline(aRefFea) || isSpline(aOtherFea)) { + theError = "B-spline is not supported"; + return false; + } } else { theError = "It uses an empty object"; @@ -294,17 +309,9 @@ bool SketchPlugin_EqualAttrValidator::isValid(const AttributePtr& theAttribute, std::string aType[2]; std::list anArguments; for (int i = 0; i < 2; i++) { - ObjectPtr anObject = aRefAttr[i]->object(); - if (!anObject.get()) { - theError = "An empty object is used."; - return false; - } - - aFeature = ModelAPI_Feature::feature(anObject); - if (!aFeature.get()) { - theError = "An empty feature is used."; - return false; - } + aFeature = ModelAPI_Feature::feature(aRefAttr[i]->object()); + if (!aFeature.get()) + return true; aType[i] = aFeature->getKind(); if (aFeature->getKind() != SketchPlugin_Line::ID() && diff --git a/src/SketchPlugin/SketchPlugin_msg_en.ts b/src/SketchPlugin/SketchPlugin_msg_en.ts index 3a5255ce5..5dd2eaa01 100644 --- a/src/SketchPlugin/SketchPlugin_msg_en.ts +++ b/src/SketchPlugin/SketchPlugin_msg_en.ts @@ -2099,6 +2099,10 @@ Two segments cannot be tangent Two segments cannot be tangent + + Two B-splines cannot be tangent + Two B-splines cannot be tangent + SketchConstraintTangent:ConstraintEntityB:SketchPlugin_TangentAttr diff --git a/src/SketchPlugin/SketchPlugin_msg_fr.ts b/src/SketchPlugin/SketchPlugin_msg_fr.ts index ae9a9a884..778266d91 100644 --- a/src/SketchPlugin/SketchPlugin_msg_fr.ts +++ b/src/SketchPlugin/SketchPlugin_msg_fr.ts @@ -2250,6 +2250,10 @@ Two segments cannot be tangent Deux segments ne peuvent pas être tangents + + Two B-splines cannot be tangent + Deux B-splines ne peuvent pas être tangents + SketchConstraintTangent:ConstraintEntityB:SketchPlugin_TangentAttr diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 408781f16..fd13e7bcd 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -1330,6 +1330,7 @@ helpfile="equalFeature.html"> + diff --git a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp index 7aacd2002..84fe25890 100644 --- a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp +++ b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp @@ -346,7 +346,7 @@ std::list getCurves(const GeomPointPtr& thePnt, const SketcherPrs_Sym if (aCurve.get()) { GeomPointPtr aProjPnt; if (aFeature->getKind() == SketchPlugin_Circle::ID() || - aFeature->getKind() == SketchPlugin_Arc::ID()) { + aFeature->getKind() == SketchPlugin_Arc::ID()) { GeomCirclePtr aCircle = GeomCirclePtr(new GeomAPI_Circ(aCurve)); aProjPnt = aCircle->project(thePnt); } @@ -354,6 +354,8 @@ std::list getCurves(const GeomPointPtr& thePnt, const SketcherPrs_Sym GeomEllipsePtr anEllipse = GeomEllipsePtr(new GeomAPI_Ellipse(aCurve)); aProjPnt = anEllipse->project(thePnt); } + else + aProjPnt = aCurve->project(thePnt); if (aProjPnt && thePnt->distance(aProjPnt) <= Precision::Confusion()) aList.push_back(aResObj); }