]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Union of validator and filter functionalities.
authornds <natalia.donis@opencascade.com>
Thu, 26 Mar 2015 08:23:14 +0000 (11:23 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 26 Mar 2015 08:23:14 +0000 (11:23 +0300)
It renames the shape validator to the external validator.

src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_ExternalValidator.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ExternalValidator.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_ShapeValidator.cpp [deleted file]
src/SketchPlugin/SketchPlugin_ShapeValidator.h [deleted file]
src/SketchPlugin/plugin-Sketch.xml

index 22ce7d27eda3dce82e05a8039a73bad2c22198c1..e94f680c15c1921d582fabd8c854adbb23486452 100644 (file)
@@ -28,7 +28,7 @@ SET(PROJECT_HEADERS
     SketchPlugin_ConstraintTangent.h
     SketchPlugin_ConstraintMirror.h
     SketchPlugin_ConstraintFillet.h
-    SketchPlugin_ShapeValidator.h
+    SketchPlugin_ExternalValidator.h
     SketchPlugin_Validators.h
 )
 
@@ -55,7 +55,7 @@ SET(PROJECT_SOURCES
     SketchPlugin_ConstraintTangent.cpp
     SketchPlugin_ConstraintMirror.cpp
     SketchPlugin_ConstraintFillet.cpp
-    SketchPlugin_ShapeValidator.cpp
+    SketchPlugin_ExternalValidator.cpp
     SketchPlugin_Validators.cpp
 )
 
diff --git a/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp b/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp
new file mode 100644 (file)
index 0000000..7b85871
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        Model_ResultValidators.cpp
+// Created:     27 Feb 2015
+// Author:      Natalia ERMOLAEVA
+
+#include "SketchPlugin_ExternalValidator.h"
+#include "SketchPlugin_Feature.h"
+
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Result.h>
+#include <ModelAPI_Tools.h>
+#include <ModelAPI_AttributeRefAttr.h>
+
+bool SketchPlugin_ExternalValidator::isValid(const AttributePtr& theAttribute,
+                                          const std::list<std::string>& theArguments) const
+{
+  if (theArguments.size() != 1)
+    return true;
+
+  // ask whether the feature of the attribute is external
+  bool isAttributeExternal = isExternalAttribute(theAttribute);
+
+  // ask whether the feature of the attribute by parameter identifier is external
+  std::string aFrontArgument = theArguments.front();
+  FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+  bool isParameterExternal = isExternalAttribute(aFeature->attribute(aFrontArgument));
+
+  // it is not possible that both features, attribute and attribute in parameter, are external
+  if (isAttributeExternal && isParameterExternal)
+    return false;
+  return true;
+}
+
+bool SketchPlugin_ExternalValidator::isExternalAttribute(const AttributePtr& theAttribute) const
+{
+  bool isExternal = false;
+  AttributeRefAttrPtr anAttribute = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+
+  if (anAttribute.get() != NULL) {
+    FeaturePtr anArgumentFeature = ModelAPI_Feature::feature(anAttribute->object());
+    if (anArgumentFeature.get() != NULL) {
+      std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
+                                    std::dynamic_pointer_cast<SketchPlugin_Feature>(anArgumentFeature);
+      if (aSketchFeature.get() != NULL) {
+        isExternal = aSketchFeature->isExternal();
+      }
+    }
+  }
+  return isExternal;
+}
diff --git a/src/SketchPlugin/SketchPlugin_ExternalValidator.h b/src/SketchPlugin/SketchPlugin_ExternalValidator.h
new file mode 100644 (file)
index 0000000..62d95bf
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        Model_ResultValidators.h
+// Created:     27 Feb 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef SketchPlugin_ExternalValidator_H
+#define SketchPlugin_ExternalValidator_H
+
+#include <SketchPlugin.h>
+#include <ModelAPI_AttributeValidator.h>
+
+/**\class SketchPlugin_ResultPointValidator
+ * \ingroup Validators
+ * \brief Validator for the points selection
+ *
+ * Allows to select points only.
+ */
+class SketchPlugin_ExternalValidator : public ModelAPI_AttributeValidator
+{
+public:
+  /// returns true if the feature of attribute do not contain external features in the given attribute and
+  /// among attributes listed in the arguments
+  /// \param theAttribute an attribute to check
+  /// \param theArguments a filter parameters
+  SKETCHPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
+                                           const std::list<std::string>& theArguments) const;
+
+protected:
+  /// returns true if the feature of the attribute is external
+  /// \param theAttribute an attribute to check
+  bool isExternalAttribute(const AttributePtr& theAttribute) const;
+};
+
+#endif
index 04347759e5655848a0831c73ab5977e2abbc211d..68302fee1541fe700c648e15a9875c25297a213c 100644 (file)
@@ -20,7 +20,7 @@
 #include <SketchPlugin_ConstraintTangent.h>
 #include <SketchPlugin_ConstraintVertical.h>
 #include <SketchPlugin_Validators.h>
-#include <SketchPlugin_ShapeValidator.h>
+#include <SketchPlugin_ExternalValidator.h>
 
 #include <Events_Loop.h>
 #include <GeomDataAPI_Dir.h>
@@ -51,15 +51,12 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   aFactory->registerValidator("SketchPlugin_DistanceAttr",
                               new SketchPlugin_DistanceAttrValidator);  
-  //aFactory->registerValidator("SketchPlugin_DifferentObjects",
-  //                            new SketchPlugin_DifferentObjectsValidator);
-
-  aFactory->registerValidator("SketchPlugin_ShapeValidator",
-                              new SketchPlugin_ShapeValidator);
+  aFactory->registerValidator("SketchPlugin_ExternalValidator",
+                              new SketchPlugin_ExternalValidator);
 
   // register this plugin
   ModelAPI_Session::get()->registerPlugin(this);
-
+  
   Config_PropManager::registerProp("Visualization", "sketch_entity_color", "Sketch enity color",
                                    Config_Prop::Color, SKETCH_ENTITY_COLOR);
 
diff --git a/src/SketchPlugin/SketchPlugin_ShapeValidator.cpp b/src/SketchPlugin/SketchPlugin_ShapeValidator.cpp
deleted file mode 100644 (file)
index 0722ce1..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File:        Model_ResultValidators.cpp
-// Created:     27 Feb 2015
-// Author:      Natalia ERMOLAEVA
-
-#include "SketchPlugin_ShapeValidator.h"
-#include "SketchPlugin_Feature.h"
-
-#include <ModelAPI_Session.h>
-#include <ModelAPI_Result.h>
-#include <ModelAPI_Tools.h>
-#include <ModelAPI_AttributeRefAttr.h>
-
-bool SketchPlugin_ShapeValidator::isValid(const AttributePtr& theAttribute,
-                                          const std::list<std::string>& theArguments) const
-{
-  if (theArguments.size() != 1)
-    return true;
-
-  // ask whether the feature of the attribute is external
-  bool isAttributeExternal = isExternalAttribute(theAttribute);
-
-  // ask whether the feature of the attribute by parameter identifier is external
-  std::string aFrontArgument = theArguments.front();
-  FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
-  bool isParameterExternal = isExternalAttribute(aFeature->attribute(aFrontArgument));
-
-  // it is not possible that both features, attribute and attribute in parameter, are external
-  if (isAttributeExternal && isParameterExternal)
-    return false;
-  return true;
-}
-
-bool SketchPlugin_ShapeValidator::isExternalAttribute(const AttributePtr& theAttribute) const
-{
-  bool isExternal = false;
-  AttributeRefAttrPtr anAttribute = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
-
-  if (anAttribute.get() != NULL) {
-    FeaturePtr anArgumentFeature = ModelAPI_Feature::feature(anAttribute->object());
-    if (anArgumentFeature.get() != NULL) {
-      std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
-                                    std::dynamic_pointer_cast<SketchPlugin_Feature>(anArgumentFeature);
-      if (aSketchFeature.get() != NULL) {
-        isExternal = aSketchFeature->isExternal();
-      }
-    }
-  }
-  return isExternal;
-}
diff --git a/src/SketchPlugin/SketchPlugin_ShapeValidator.h b/src/SketchPlugin/SketchPlugin_ShapeValidator.h
deleted file mode 100644 (file)
index d07581e..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File:        Model_ResultValidators.h
-// Created:     27 Feb 2015
-// Author:      Natalia ERMOLAEVA
-
-#ifndef SketchPlugin_ShapeValidator_H
-#define SketchPlugin_ShapeValidator_H
-
-#include <SketchPlugin.h>
-#include <ModelAPI_AttributeValidator.h>
-
-/**\class SketchPlugin_ResultPointValidator
- * \ingroup Validators
- * \brief Validator for the points selection
- *
- * Allows to select points only.
- */
-class SketchPlugin_ShapeValidator : public ModelAPI_AttributeValidator
-{
-public:
-  /// returns true if the feature of attribute do not contain external features in the given attribute and
-  /// among attributes listed in the arguments
-  /// \param theAttribute an attribute to check
-  /// \param theArguments a filter parameters
-  SKETCHPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
-                                           const std::list<std::string>& theArguments) const;
-
-protected:
-  /// returns true if the feature of the attribute is external
-  /// \param theAttribute an attribute to check
-  bool isExternalAttribute(const AttributePtr& theAttribute) const;
-};
-
-#endif
index f1bc36d9b27c41994d0a79f142c99c07659b778b..9127d418f7a91ccf2fc3aa7112faf5a527dbc308 100644 (file)
@@ -57,7 +57,7 @@
               label="First object"
               tooltip="Select point, line end point, line, center of circle or arc."
               shape_types="edge vertex">
-          <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityB"/>
+          <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
           <validator id="GeomValidators_EdgeOrVertex"/>
         </sketch_shape_selector>/>
         <sketch_shape_selector 
@@ -67,7 +67,7 @@
                 shape_types="edge vertex">
           <validator id="PartSet_DifferentObjects"/>
           <validator id="SketchPlugin_DistanceAttr" parameters="ConstraintEntityA"/>
-          <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityA"/>
+          <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
           <validator id="GeomValidators_EdgeOrVertex"/>
         </sketch_shape_selector>
         
         <sketch_constraint_shape_selector id="ConstraintEntityA" 
             label="First line" tooltip="Select a line" shape_types="edge">
             <validator id="GeomValidators_Edge" parameters="line"/>
-            <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityB"/>
+            <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
         </sketch_constraint_shape_selector>
         
         <sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select a line" 
             shape_types="edge">
             <validator id="GeomValidators_Edge" parameters="line"/>
             <validator id="PartSet_DifferentObjects"/>
-            <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityA"/>
+            <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
         </sketch_constraint_shape_selector>
         
         <validator id="PartSet_ParallelValidator"/>
         <sketch_constraint_shape_selector id="ConstraintEntityA" 
             label="First line" tooltip="Select an line" 
             shape_types="edge">
-          <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityB"/>
+          <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
             <validator id="GeomValidators_Edge" parameters="line"/>
         </sketch_constraint_shape_selector>
         
             label="Last line" tooltip="Select an line" 
             shape_types="edge">
             <validator id="PartSet_DifferentObjects"/>
-          <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityA"/>
+          <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
             <validator id="GeomValidators_Edge" parameters="line"/>
         </sketch_constraint_shape_selector>
         <validator id="PartSet_PerpendicularValidator"/>