]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1744: Disable senseless operations
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 29 Dec 2016 11:56:05 +0000 (14:56 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 29 Dec 2016 11:56:05 +0000 (14:56 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h
src/SketchPlugin/plugin-Sketch.xml

index a092bbe686d5a0265e7617948dc0478b7a23af54..3947c7c3dd38a5a62d673a71ca1b5501ab99dff9 100755 (executable)
@@ -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()
index b31ef035a9416ab98ab9d441120e1a937c57a2c1..b45f59e439a84773d00ac47018a27ea490e28b5f 100755 (executable)
@@ -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;
 }
-
index 64c61c9b9052823016cf99c6d8ca5074a674ef99..886cf21e66a68a4f866cc37d6c34da7dfa16bab5 100644 (file)
@@ -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 ////////////////
 
 
index e27329d857e48c1d471c304d319887df413e8bda..5a62d12004e57761783b531b778d9240e2852e35 100644 (file)
             use_external="false">
           <validator id="SketchPlugin_SplitValidator"/>
         </sketch_sub_shape_selector>
+        <validator id="PartSet_SplitSelection"/>
       </feature>
     </group>
 
               use_sketch_plane="false">
           <validator id="SketchPlugin_ProjectionValidator"/>
         </sketch_shape_selector>
+        <validator id="PartSet_ProjectionSelection"/>
       </feature>
     </group>
 
             greed ="true">
           <validator id="SketchPlugin_MirrorAttr" />
         </sketch_multi_selector>
+        <validator id="PartSet_MultyTranslationSelection" />
       </feature>
 
       <!--  SketchMultiTranslation  -->
             default="2" min="2" use_reset="false">
           <validator id="GeomValidators_Positive"/>
         </integervalue>
+        <validator id="PartSet_MultyTranslationSelection" />
       </feature>
 
       <!--  SketchMultiRotation  -->
             default="2" min="2" use_reset="false">
           <validator id="GeomValidators_Positive"/>
         </integervalue>
+        <validator id="PartSet_MultyTranslationSelection" />
       </feature>
     </group>