X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Validators.cpp;h=2230d9eb2458939a525a01b8937d849a06be5e27;hb=d44671b5418920fef3264b53af7e62a8f8cb2bb7;hp=1470d03538a6c14b6f10cd1ca688f9594e04d3fc;hpb=ca03465754f3815ede43f8686305fe39b6703a9c;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index 1470d0353..2230d9eb2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -181,43 +181,40 @@ bool FeaturesPlugin_ValidatorCompositeLauncher::isValid(const AttributePtr& theA theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; return false; } - - bool aValid = true; - GeomValidators_FeatureKind* aValidator = new GeomValidators_FeatureKind(); - // check whether the selection is on the sketch - bool aFeatureKindValid = aValidator->isValid(theAttribute, theArguments, theError); - if (!aFeatureKindValid) { - // check if selection has Face selected - GeomValidators_ShapeType* aShapeType = new GeomValidators_ShapeType(); - std::list anArguments; - anArguments.push_back("face"); - aValid = aShapeType->isValid(theAttribute, anArguments, theError); + if (theArguments.size() != 2) { + theError = "Wrong parameters in XML definition for " + theAttribute->attributeType() + " type"; + return false; } - return aValid; -} - -//================================================================================================= -bool FeaturesPlugin_ValidatorCompositeLauncher_::isValid(const AttributePtr& theAttribute, - const std::list& theArguments, - std::string& theError) const -{ - FeaturesPlugin_ValidatorBaseForGeneration aBaseValidator; - - if(aBaseValidator.isValid(theAttribute, theArguments, theError)) { - return true; + // first argument is for the base attribute, second - for skipping feature kind + std::list::const_iterator anIt = theArguments.begin(); + std::string aBaseAttributeId = *anIt; + FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner()); + AttributePtr aBaseAttribute = aFeature->attribute(aBaseAttributeId); + if (!aBaseAttribute.get()) { + theError = "Wrong parameters in XML definition for " + theAttribute->attributeType() + " type"; + return false; } + if (aBaseAttribute->isInitialized()) // when base list of composite feature is already filled, + // this validator is not necessary anymore + return true; - // Check that face selected. - GeomValidators_ShapeType aShapeType; + anIt++; + std::string aFeatureAttributeKind = *anIt; + GeomValidators_FeatureKind* aValidator = new GeomValidators_FeatureKind(); + // check whether the selection is on the sketch std::list anArguments; - anArguments.push_back("face"); - if(aShapeType.isValid(theAttribute, anArguments, theError)) { - return true; - } + anArguments.push_back(aFeatureAttributeKind); - theError = "Selected shape is not suitable for this operation"; + bool aFeatureKind = aValidator->isValid(theAttribute, theArguments, theError); + bool aPlanarFace = false; + // check if selection has Face selected + GeomValidators_ShapeType* aShapeType = new GeomValidators_ShapeType(); + anArguments.clear(); + anArguments.push_back("face"); + aPlanarFace = aShapeType->isValid(theAttribute, anArguments, theError); - return false; + bool aValid = !aFeatureKind && aPlanarFace; + return aValid; } //=================================================================================================