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
#include <QToolButton>
+static const double THE_MIN_WEIGHT = 1.e-7;
+
PartSet_BSplineWidget::PartSet_BSplineWidget(
QWidget* theParent,
const Config_WidgetAPI* theData)
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);
aType = 3;
else if (aType != 3)
return false;
- }
+ } else if (aEdge.isBSpline())
+ return false;
} else
return false;
}
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);
}
#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"
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<std::string>& theArguments,
Events_InfoMessage& theError) const
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 {
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";
std::string aType[2];
std::list<std::string> 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() &&
<source>Two segments cannot be tangent</source>
<translation>Two segments cannot be tangent</translation>
</message>
+ <message>
+ <source>Two B-splines cannot be tangent</source>
+ <translation>Two B-splines cannot be tangent</translation>
+ </message>
</context>
<context>
<name>SketchConstraintTangent:ConstraintEntityB:SketchPlugin_TangentAttr</name>
<source>Two segments cannot be tangent</source>
<translation>Deux segments ne peuvent pas être tangents</translation>
</message>
+ <message>
+ <source>Two B-splines cannot be tangent</source>
+ <translation>Deux B-splines ne peuvent pas être tangents</translation>
+ </message>
</context>
<context>
<name>SketchConstraintTangent:ConstraintEntityB:SketchPlugin_TangentAttr</name>
helpfile="equalFeature.html">
<sketch_shape_selector id="ConstraintEntityA"
label="First object" tooltip="Select edge" shape_types="edge">
+ <validator id="SketchPlugin_EqualAttr" parameters="ConstraintEntityB"/>
<validator id="PartSet_DifferentObjects"/>
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
</sketch_shape_selector>
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);
}
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);
}