X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Validators.cpp;h=cf8d1ca4a65a7b2fc421b5ec8a8955178ed9fca3;hb=7b9662e1e63565ccfb95255f2b154d53357d091e;hp=46a3581146295dfc7617f22fca40a4f7096cf547;hpb=c9b11eac574f71b147c8441f2b97ba7ed3ebed5a;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 46a358114..cf8d1ca4a 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -65,7 +65,9 @@ #include #include #include + #include +#include #include #include @@ -771,7 +773,8 @@ bool SketchPlugin_MiddlePointAttrValidator::isValid(const AttributePtr& theAttri if (aFeature->getKind() == SketchPlugin_Point::ID()) ++aNbPoints; else if (aFeature->getKind() == SketchPlugin_Line::ID() || - aFeature->getKind() == SketchPlugin_Arc::ID()) + aFeature->getKind() == SketchPlugin_Arc::ID() || + aFeature->getKind() == SketchPlugin_EllipticArc::ID()) ++aNbLines; } } @@ -870,7 +873,7 @@ bool SketchPlugin_ArcTransversalPointValidator::isValid( } } else { - theError = "Unable to build transversal arc on %1"; + theError = "Unable to build perpendicular arc on %1"; theError.arg(anAttrFeature->getKind()); return false; } @@ -945,8 +948,16 @@ bool SketchPlugin_SplitValidator::isValid(const AttributePtr& theAttribute, } AttributeReferencePtr aFeatureAttr = std::dynamic_pointer_cast(theAttribute); + std::shared_ptr aSplitFeature = + std::dynamic_pointer_cast(theAttribute->owner()); ObjectPtr anAttrObject = aFeatureAttr->value(); + if (!anAttrObject) { + AttributePtr aPreviewAttr = aSplitFeature->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()); + aFeatureAttr = std::dynamic_pointer_cast(aPreviewAttr); + anAttrObject = aFeatureAttr->value(); + } + FeaturePtr anAttrFeature = ModelAPI_Feature::feature(anAttrObject); if (!anAttrFeature) return aValid; @@ -1114,38 +1125,35 @@ bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute, std::shared_ptr aNormal = aPlane->direction(); std::shared_ptr anOrigin = aPlane->location(); + bool aValid = true; if (anEdge->isLine()) { std::shared_ptr aLine = anEdge->line(); std::shared_ptr aLineDir = aLine->direction(); double aDot = fabs(aNormal->dot(aLineDir)); - bool aValid = fabs(aDot - 1.0) >= tolerance * tolerance; + aValid = fabs(aDot - 1.0) >= tolerance * tolerance; if (!aValid) theError = "Error: Line is orthogonal to the sketch plane."; - return aValid; } else if (anEdge->isCircle() || anEdge->isArc()) { std::shared_ptr aCircle = anEdge->circle(); std::shared_ptr aCircNormal = aCircle->normal(); double aDot = fabs(aNormal->dot(aCircNormal)); - bool aValid = aDot >= tolerance * tolerance; + aValid = aDot >= tolerance * tolerance; if (!aValid) theError.arg(anEdge->isCircle() ? "Error: Circle is orthogonal to the sketch plane." : "Error: Arc is orthogonal to the sketch plane."); - return aValid; } else if (anEdge->isEllipse()) { std::shared_ptr anEllipse = anEdge->ellipse(); std::shared_ptr anEllipseNormal = anEllipse->normal(); double aDot = fabs(aNormal->dot(anEllipseNormal)); - bool aValid = fabs(aDot - 1.0) <= tolerance * tolerance; + aValid = fabs(aDot - 1.0) <= tolerance * tolerance; if (!aValid) theError.arg(anEdge->isClosed() ? "Error: Ellipse is orthogonal to the sketch plane." : "Error: Elliptic Arc is orthogonal to the sketch plane."); - return aValid; } - theError = "Error: Selected object is not supported for projection."; - return false; + return aValid; } @@ -1770,3 +1778,20 @@ bool SketchPlugin_MultiRotationAngleValidator::isValid(const AttributePtr& theAt return true; } + +bool SketchPlugin_BSplineValidator::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const +{ + AttributePoint2DArrayPtr aPolesArray = + std::dynamic_pointer_cast(theAttribute); + if (!aPolesArray) + return false; + + if (aPolesArray->size() < 2) { + theError = "Number of B-spline poles should be 2 and more"; + return false; + } + + return true; +}