X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Validators.cpp;h=69c488639f9e7287e05406cb7b1ba60b7f7e06ae;hb=5709da577274e3e7ff0e572c05166337d7851e15;hp=7a976bda33749c371cf392ef0478f5217e0edfc6;hpb=61da4e89d2ec63daa429d304f928482a0e6fa0b7;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 7a976bda3..69c488639 100644 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: PartSet_Validators.cpp // Created: 09 July 2014 // Author: Vitaly SMETANNIKOV @@ -11,7 +13,16 @@ #include #include +#include +#include +#include + +#include + #include +#ifdef _DEBUG +#include +#endif int shapesNbPoints(const ModuleBase_ISelection* theSelection) { @@ -49,7 +60,7 @@ int shapesNbLines(const ModuleBase_ISelection* theSelection) bool PartSet_DistanceValidator::isValid(const ModuleBase_ISelection* theSelection) const { - int aCount = shapesNbPoints(theSelection); + int aCount = shapesNbPoints(theSelection) + shapesNbLines(theSelection); return (aCount > 0) && (aCount < 3); } @@ -92,3 +103,79 @@ bool PartSet_RadiusValidator::isValid(const ModuleBase_ISelection* theSelection) return (aCount > 0) && (aCount < 2); } +bool PartSet_RigidValidator::isValid(const ModuleBase_ISelection* theSelection) const +{ + int aCount = shapesNbLines(theSelection); + return (aCount > 0) && (aCount < 2); +} + +bool PartSet_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature, + const std::list& theArguments, + const ObjectPtr& theObject) const +{ + // Check RefAttr attributes + std::list > anAttrs = + theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type()); + if (anAttrs.size() > 0) { + std::list >::iterator anAttr = anAttrs.begin(); + for(; anAttr != anAttrs.end(); anAttr++) { + if (*anAttr) { + std::shared_ptr aRef = + std::dynamic_pointer_cast(*anAttr); + // check the object is already presented + if (aRef->isObject() && aRef->object() == theObject) + return false; + } + } + } + // Check selection attributes + anAttrs = theFeature->data()->attributes(ModelAPI_AttributeSelection::type()); + if (anAttrs.size() > 0) { + std::list >::iterator anAttr = anAttrs.begin(); + for(; anAttr != anAttrs.end(); anAttr++) { + if (*anAttr) { + std::shared_ptr aRef = + std::dynamic_pointer_cast(*anAttr); + // check the object is already presented + if (aRef->isInitialized() && aRef->context() == theObject) + return false; + } + } + } + // Check selection attributes + anAttrs = theFeature->data()->attributes(ModelAPI_AttributeReference::type()); + if (anAttrs.size() > 0) { + std::list >::iterator anAttr = anAttrs.begin(); + for(; anAttr != anAttrs.end(); anAttr++) { + if (*anAttr) { + std::shared_ptr aRef = + std::dynamic_pointer_cast(*anAttr); + // check the object is already presented + if (aRef->isInitialized() && aRef->value() == theObject) + return false; + } + } + } + return true; +} + +bool PartSet_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature, + const std::list& theArguments, + const AttributePtr& theAttribute) const +{ + // not implemented + return true; +} + +bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute, + const std::list& theArguments) const +{ + // not implemented + return true; +} + +bool PartSet_SketchValidator::isValid(const ObjectPtr theObject) const +{ + FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); + return aFeature->getKind() == SketchPlugin_Sketch::ID(); +}