From b3f2bfa6fbd0b1769d684742a8495840148b8808 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 29 Dec 2016 14:56:05 +0300 Subject: [PATCH] Issue #1744: Disable senseless operations --- src/PartSet/PartSet_Module.cpp | 4 ++++ src/PartSet/PartSet_Validators.cpp | 34 +++++++++++++++++++++++++++++- src/PartSet/PartSet_Validators.h | 27 ++++++++++++++++++++++++ src/SketchPlugin/plugin-Sketch.xml | 5 +++++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index a092bbe68..3947c7c3d 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -231,6 +231,10 @@ void PartSet_Module::registerValidators() aFactory->registerValidator("PartSet_MiddlePointSelection", new PartSet_MiddlePointSelection); aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator); aFactory->registerValidator("PartSet_CoincidentAttr", new PartSet_CoincidentAttr); + aFactory->registerValidator("PartSet_MultyTranslationSelection", + new PartSet_MultyTranslationSelection); + aFactory->registerValidator("PartSet_SplitSelection", new PartSet_SplitSelection); + aFactory->registerValidator("PartSet_ProjectionSelection", new PartSet_ProjectionSelection); } void PartSet_Module::registerFilters() diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index b31ef035a..b45f59e43 100755 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -343,6 +343,39 @@ bool PartSet_MiddlePointSelection::isValid(const ModuleBase_ISelection* theSelec return shapesNbLines(theSelection) == 1 || shapesNbPoints(theSelection) == 1; } +bool PartSet_MultyTranslationSelection::isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const +{ + if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) { + return isEmptySelectionValid(theOperation); + } else { + int aCount = shapesNbLines(theSelection); + return aCount > 0; + } +} + +bool PartSet_SplitSelection::isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const +{ + if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) { + return isEmptySelectionValid(theOperation); + } else { + int aCount = shapesNbLines(theSelection); + return aCount > 0; + } +} + +bool PartSet_ProjectionSelection::isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const +{ + if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) { + return isEmptySelectionValid(theOperation); + } else { + int aCount = shapesNbLines(theSelection); + return aCount > 0; + } +} + std::string PartSet_DifferentObjectsValidator::errorMessage( const PartSet_DifferentObjectsValidator::ErrorType& theType, @@ -613,4 +646,3 @@ bool PartSet_CoincidentAttr::isValid(const AttributePtr& theAttribute, theError = "There is no a common coincident point."; return false; } - diff --git a/src/PartSet/PartSet_Validators.h b/src/PartSet/PartSet_Validators.h index 64c61c9b9..886cf21e6 100644 --- a/src/PartSet/PartSet_Validators.h +++ b/src/PartSet/PartSet_Validators.h @@ -145,6 +145,33 @@ public: ModuleBase_Operation* theOperation) const; }; +//! \ingroup Validators +//! A class to validate a selection for Middle point constraints operation +class PartSet_MultyTranslationSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Middle point constraints operation +class PartSet_SplitSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Middle point constraints operation +class PartSet_ProjectionSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + ////////////// Attribute validators //////////////// diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index e27329d85..5a62d1200 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -138,6 +138,7 @@ use_external="false"> + @@ -176,6 +177,7 @@ use_sketch_plane="false"> + @@ -197,6 +199,7 @@ greed ="true"> + @@ -260,6 +263,7 @@ default="2" min="2" use_reset="false"> + @@ -304,6 +308,7 @@ default="2" min="2" use_reset="false"> + -- 2.39.2