#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAlgoAPI_WireBuilder.h>
+//==================================================================================================
+bool FeaturesPlugin_ValidatorPipePath::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const
+{
+ AttributeSelectionPtr aPathAttrSelection = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ if(!aPathAttrSelection.get()) {
+ theError = "Error: This validator can only work with path selector in \"Pipe\" feature.";
+ return false;
+ }
+
+ GeomShapePtr aPathShape = aPathAttrSelection->value();
+ ResultPtr aContext = aPathAttrSelection->context();
+ if(!aContext.get()) {
+ theError = "Error: Empty context.";
+ return false;
+ }
+ GeomShapePtr aContextShape = aContext->shape();
+ if(aPathShape.get() && aPathShape->shapeType() == GeomAPI_Shape::WIRE && !aPathShape->isEqual(aContextShape)) {
+ theError = "Error: Local selection of wires not allowed.";
+ return false;
+ }
+
+ return true;
+}
+
//==================================================================================================
bool FeaturesPlugin_ValidatorPipeLocations::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
#include <ModelAPI_AttributeValidator.h>
#include <ModelAPI_FeatureValidator.h>
+/// \class FeaturesPlugin_ValidatorPipePath
+/// \ingroup Validators
+/// \brief A validator for selection pipe path.
+class FeaturesPlugin_ValidatorPipePath: public ModelAPI_AttributeValidator
+{
+public:
+ //! \return True if the attribute is valid.
+ //! \param[in] theAttribute the checked attribute.
+ //! \param[in] theArguments arguments of the attribute.
+ //! \param[out] theError error message.
+ virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const;
+};
+
/// \class FeaturesPlugin_ValidatorPipeLocations
/// \ingroup Validators
/// \brief Validator for the pipe locations.
class FeaturesPlugin_ValidatorBaseForGeneration: public ModelAPI_AttributeValidator
{
public:
- //! Returns true if attribute has selection type listed in the parameter arguments.
+ //! \return true if attribute has selection type listed in the parameter arguments.
//! \param[in] theAttribute the checked attribute.
//! \param[in] theArguments arguments of the attribute.
//! \param[out] theError error message.
class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
{
public:
- //! Returns true if attribute has selection type listed in the parameter arguments.
+ //! \return true if attribute has selection type listed in the parameter arguments.
//! \param[in] theAttribute the checked attribute.
//! \param[in] theArguments arguments of the attribute.
//! \param[out] theError error message.
class FeaturesPlugin_ValidatorCanBeEmpty: public ModelAPI_FeatureValidator
{
public:
- //! Returns true if attribute listed in the parameter arguments are planar.
+ //! \return true if attribute listed in the parameter arguments are planar.
//! \param[in] theFeature the checked feature.
//! \param[in] theArguments arguments of the attribute.
//! \param[out] theError error message.
const std::list<std::string>& theArguments,
std::string& theError) const;
- /// Returns true if the attribute in feature is not obligatory for the feature execution
+ /// \return true if the attribute in feature is not obligatory for the feature execution
virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
private:
const std::list<std::string>& theArguments,
std::string& theError) const;
- /// Returns true if the attribute in feature is not obligatory for the feature execution
+ /// \return true if the attribute in feature is not obligatory for the feature execution
virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
};