]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #338: Provide sketch validator for extrusion
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 30 Dec 2014 10:17:50 +0000 (13:17 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 30 Dec 2014 10:17:50 +0000 (13:17 +0300)
src/FeaturesPlugin/extrusion_widget.xml
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h

index d37d8da99025f8ef85bda4864f70d1905b35eab7..6f2ea7d180a200a40a376c189a38778ea59fd114 100644 (file)
@@ -1,14 +1,15 @@
 <!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
 
 <source>
-  <shape_selector id="extrusion_face" 
-    label="Select a face" 
-    icon=":icons/sketch.png" 
+  <shape_selector id="extrusion_face"
+    label="Select a face"
+    icon=":icons/sketch.png"
     tooltip="Select a face"
     activate="true"
     shape_types="face"
-       object_types="construction"
-  />
+         object_types="construction">
+    <validator id="PartSet_SketchValidator"/>
+  </shape_selector>
   <doublevalue
     id="extrusion_size"
     label="Size"
index e3807bd7ec4cae95a3c9c0836339f2ff58b76d71..fb68b9e4d9f4695078c25e1954d6d8f190d33703 100644 (file)
@@ -113,6 +113,7 @@ void PartSet_Module::registerValidators()
   aFactory->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()
index fa7ac518f60a1696c8a4b04f5b88cc7392107735..69c488639f9e7287e05406cb7b1ba60b7f7e06ae 100644 (file)
@@ -17,6 +17,8 @@
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeReference.h>
 
+#include <SketchPlugin_Sketch.h>
+
 #include <list>
 #ifdef _DEBUG
 #include <iostream>
@@ -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();
+}
index d0829b58692fe405a404b8df7874b119a9c12060..eb44d6daae3eaaf8e6d1116eadcda3ecbb13f39b 100644 (file)
@@ -12,6 +12,7 @@
 #include <ModuleBase_SelectionValidator.h>
 #include <ModuleBase_ISelection.h>
 #include <ModelAPI_RefAttrValidator.h>
+#include <ModelAPI_ResultValidator.h>
 
 /*
  * Selector validators
@@ -72,5 +73,14 @@ class PartSet_DifferentObjectsValidator : public ModelAPI_RefAttrValidator
                        const std::list<std::string>& 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