]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix bunch of issues for B-splines (#3155, #3156, #3157, #3159)
authorazv <azv@opencascade.com>
Thu, 27 Feb 2020 05:16:46 +0000 (08:16 +0300)
committerazv <azv@opencascade.com>
Thu, 27 Feb 2020 08:16:37 +0000 (11:16 +0300)
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

src/PartSet/PartSet_BSplineWidget.cpp
src/PartSet/PartSet_Validators.cpp
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/SketchPlugin_msg_en.ts
src/SketchPlugin/SketchPlugin_msg_fr.ts
src/SketchPlugin/plugin-Sketch.xml
src/SketcherPrs/SketcherPrs_PositionMgr.cpp

index 9ca97448d277b246ee80c4e46416c6441214cee0..b2e0334c77a37041d4e3564e16e6b09e484daca3 100644 (file)
@@ -37,6 +37,8 @@
 #include <QToolButton>
 
 
+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);
index f8d05fe0a6c011c731d314ee19bc06739368b871..19463281c93b267b26ffa1f9c09c2c3bdc9281aa 100644 (file)
@@ -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);
 }
 
 
index 9e60ab2e3441dad5e39418527b13c09d8df1251a..454d8c8712a1349f44b576b71ae775098ae70e37 100644 (file)
@@ -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"
 
 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
@@ -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<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() &&
index 3a5255ce5a4e9d144f64359858ffba8e6f8eb4f7..5dd2eaa01fc945eaaaeb20aa1e60cb458fcaf672 100644 (file)
       <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>
index ae9a9a884df7b24d8aa6deed254f970bf64468a5..778266d91e89c8f95b2b8dbfb6b80b63a319bccc 100644 (file)
       <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>
index 408781f166c776275800dbd6df2631bce2db1b28..fd13e7bcd2a7b8f4e4269121525508fbcb2142ca 100644 (file)
                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>
index 7aacd2002093c332c992a444deaac12f75898e03..84fe258903ac8f0fd93fdec4f15c89667308c9e3 100644 (file)
@@ -346,7 +346,7 @@ std::list<ObjectPtr> 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<ObjectPtr> 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);
       }