X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Validators.cpp;h=822ddaf6ceb365cb404720053783280fb16a25d7;hb=93152527420704cf35e22b11d1de198e1710bd90;hp=14f5aaa9bf69b4d5295157ef9ccd868ef4571d9b;hpb=489132d99e1d417d5c7ce93fed8fb8ee138befbc;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 14f5aaa9b..822ddaf6c 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature, @@ -20,7 +22,7 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature, // If the object is not a line then it is accepted const ModelAPI_ResultValidator* aLineValidator = - dynamic_cast(aFactory->validator("SketchPlugin_ResultLineValidator")); + dynamic_cast(aFactory->validator("SketchPlugin_ResultLine")); if (!aLineValidator->isValid(theObject)) return true; @@ -44,10 +46,64 @@ bool SketchPlugin_DistanceAttrValidator::isValid( return true; // it may be not reference attribute, in this case, it is OK } -bool SketchPlugin_RadiusValidator::isValid( - const AttributePtr& theAttribute, const std::list& theArguments) const +bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature, + const std::list& theArguments, + const ObjectPtr& theObject) const +{ + std::list > anAttrs = + theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type()); + std::list >::iterator anAttr = anAttrs.begin(); + for(; anAttr != anAttrs.end(); anAttr++) { + if (*anAttr) { + boost::shared_ptr aRef = + boost::dynamic_pointer_cast(*anAttr); + // check the object is already presented + if (aRef->isObject() && aRef->object() == theObject) + return false; + } + } + return true; +} + +bool SketchPlugin_DifferentObjectsValidator::isValid( + const AttributePtr& theAttribute, const std::list& theArguments ) const +{ + boost::shared_ptr anOrigAttr = + boost::dynamic_pointer_cast(theAttribute); + if (anOrigAttr && anOrigAttr->isObject()) { + const ObjectPtr& anObj = theAttribute->owner(); + const FeaturePtr aFeature = boost::dynamic_pointer_cast(anObj); + + std::list > anAttrs = + aFeature->data()->attributes(ModelAPI_AttributeRefAttr::type()); + std::list >::iterator anAttr = anAttrs.begin(); + for(; anAttr != anAttrs.end(); anAttr++) { + if (*anAttr && *anAttr != theAttribute) { + boost::shared_ptr aRef = + boost::dynamic_pointer_cast(*anAttr); + // check the object is already presented + if (aRef->isObject() && aRef->object() == anOrigAttr->object()) + return false; + } + } + } + return true; +} + +bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature, + const std::list& theArguments, const AttributePtr& theAttribute) const { - boost::shared_ptr aDouble = - boost::dynamic_pointer_cast(theAttribute); - return aDouble->isInitialized() && aDouble->value() > 1.e-5; + std::list > anAttrs = + theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type()); + std::list >::iterator anAttr = anAttrs.begin(); + for(; anAttr != anAttrs.end(); anAttr++) { + if (*anAttr) { + boost::shared_ptr aRef = + boost::dynamic_pointer_cast(*anAttr); + // check the object is already presented + if (!aRef->isObject() && aRef->attr() == theAttribute) + return false; + } + } + return true; }