From 99533173636470077fa168a0e35fc37163b043c1 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 30 Dec 2014 13:17:50 +0300 Subject: [PATCH] Issue #338: Provide sketch validator for extrusion --- src/FeaturesPlugin/extrusion_widget.xml | 11 ++++++----- src/PartSet/PartSet_Module.cpp | 1 + src/PartSet/PartSet_Validators.cpp | 8 ++++++++ src/PartSet/PartSet_Validators.h | 10 ++++++++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index d37d8da99..6f2ea7d18 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -1,14 +1,15 @@ - + object_types="construction"> + + registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator); aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator); aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator); + aFactory->registerValidator("PartSet_SketchValidator", new PartSet_SketchValidator); } void PartSet_Module::registerFilters() diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index fa7ac518f..69c488639 100644 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -17,6 +17,8 @@ #include #include +#include + #include #ifdef _DEBUG #include @@ -171,3 +173,9 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute // not implemented return true; } + +bool PartSet_SketchValidator::isValid(const ObjectPtr theObject) const +{ + FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); + return aFeature->getKind() == SketchPlugin_Sketch::ID(); +} diff --git a/src/PartSet/PartSet_Validators.h b/src/PartSet/PartSet_Validators.h index d0829b586..eb44d6daa 100644 --- a/src/PartSet/PartSet_Validators.h +++ b/src/PartSet/PartSet_Validators.h @@ -12,6 +12,7 @@ #include #include #include +#include /* * Selector validators @@ -72,5 +73,14 @@ class PartSet_DifferentObjectsValidator : public ModelAPI_RefAttrValidator const std::list& theArguments) const; }; +/** +* aValidator which validates tha selected object is a Sketch +*/ +class PartSet_SketchValidator : public ModelAPI_ResultValidator +{ + public: + virtual bool isValid(const ObjectPtr theObject) const; +}; + #endif -- 2.39.2