]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Union of validator and filter functionalities.
authornds <natalia.donis@opencascade.com>
Mon, 23 Mar 2015 10:54:42 +0000 (13:54 +0300)
committernds <natalia.donis@opencascade.com>
Mon, 23 Mar 2015 10:54:42 +0000 (13:54 +0300)
It replaces ResultValidator to AttributeValidator in order to have a similar interface for most of validators.

19 files changed:
src/FeaturesPlugin/extrusion_widget.xml
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_RefAttrValidator.h [deleted file]
src/ModelAPI/ModelAPI_ResultValidator.h [deleted file]
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/ModuleBase/ModuleBase_WidgetValidated.cpp
src/ModuleBase/ModuleBase_WidgetValidated.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h
src/PartSet/PartSet_WidgetShapeSelector.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_ResultValidators.cpp [deleted file]
src/SketchPlugin/SketchPlugin_ResultValidators.h [deleted file]
src/SketchPlugin/SketchPlugin_ShapeValidator.cpp
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/SketchPlugin_Validators.h
src/SketchPlugin/plugin-Sketch.xml

index 1109883fb1629417b689814a97b8ac81ab5194ec..adbe17b11541e5971ca8a5724a65584af036ddc2 100644 (file)
@@ -6,7 +6,7 @@
     icon=":icons/sketch.png"
     tooltip="Select a sketch face"
     type_choice="Faces">
-    <validator id="PartSet_SketchEntityValidator"/>
+    <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
   </multi_selector>
   <doublevalue
     id="size"
index 44602ce1c17ab5e8dbff136c9bab23e62280acb5..d20cb1d0577efcce3100ed7fca8f90172b2c6b96 100644 (file)
@@ -28,14 +28,12 @@ SET(PROJECT_HEADERS
     ModelAPI_FeatureValidator.h
     ModelAPI_Object.h
     ModelAPI_Plugin.h
-    ModelAPI_RefAttrValidator.h 
     ModelAPI_Result.h
     ModelAPI_ResultBody.h
     ModelAPI_ResultConstruction.h
     ModelAPI_ResultGroup.h
     ModelAPI_ResultParameters.h
     ModelAPI_ResultPart.h
-    ModelAPI_ResultValidator.h
     ModelAPI_Session.h
     ModelAPI_Tools.h
     ModelAPI_ShapeValidator.h
diff --git a/src/ModelAPI/ModelAPI_RefAttrValidator.h b/src/ModelAPI/ModelAPI_RefAttrValidator.h
deleted file mode 100644 (file)
index 087cff4..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        ModelAPI_RefAttrValidator.h
-// Created:     5 Aug 2014
-// Author:      Vitaly SMETANNIKOV
-
-#ifndef ModelAPI_RefAttrValidator_H
-#define ModelAPI_RefAttrValidator_H
-
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Object.h>
-#include <ModelAPI_Attribute.h>
-#include <ModelAPI_AttributeValidator.h>
-
-/**\class ModelAPI_RefAttrValidator
- * \ingroup DataModel
- * Used for filtering out the object that can be used for reference attribute value
- */
-class ModelAPI_RefAttrValidator : public ModelAPI_AttributeValidator
-{
-public:
-};
-
-#endif
diff --git a/src/ModelAPI/ModelAPI_ResultValidator.h b/src/ModelAPI/ModelAPI_ResultValidator.h
deleted file mode 100644 (file)
index 01d73ea..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        ModelAPI_ResultValidators.h
-// Created:     23 July 2014
-// Author:      Vitaly SMETANNIKOV
-
-#ifndef ModelAPI_ResultValidators_H
-#define ModelAPI_ResultValidators_H
-
-#include "ModelAPI_Validator.h"
-#include "ModelAPI_Object.h"
-
-/**\class ModelAPI_ResultValidator
- * \ingroup DataModel
- * \brief The base class for selection filter for results of features.
- *
- * The referenced arguments of feature is normally results displayed in the viewer or by the 
- * selection attribute. This filter allows to filter out the results not usable as this argument.
- */
-class ModelAPI_ResultValidator : public ModelAPI_Validator
-{
-public:
-  /// The abstract method for implementation in the specific validator.
-  /// \param theObject the checked object as an argument
-  /// \returns true if object is OK for this filter
-  virtual bool isValid(const ObjectPtr theObject) const = 0;
-};
-
-#endif
index 9708a6ccdade9d7fd5a44d6020a909fedad023cb..265a9e42c22da4776159d4c3bd8fcf9a5e8c141a 100644 (file)
@@ -33,7 +33,6 @@
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_Validator.h>
-#include <ModelAPI_ResultValidator.h>
 #include <ModelAPI_AttributeValidator.h>
 #include <ModelAPI_ShapeValidator.h>
 
index 88c587aff5ee622c0b7db7bc3aa08ee678b2a07a..97723530bd21371533a04ec5474ced4baa4936f1 100644 (file)
@@ -6,7 +6,6 @@
 
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
-#include <ModelAPI_ResultValidator.h>
 #include <ModelAPI_AttributeValidator.h>
 
 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
@@ -80,74 +79,14 @@ bool ModuleBase_WidgetValidated::isValidAttribute() const
   return aValid;
 }
 
-//********************************************************************
-bool ModuleBase_WidgetValidated::isValid(ObjectPtr theObj, GeomShapePtr theShape) const
-{
-  SessionPtr aMgr = ModelAPI_Session::get();
-  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-  std::list<ModelAPI_Validator*> aValidators;
-  std::list<std::list<std::string> > anArguments;
-  aFactory->validators(parentID(), attributeID(), aValidators, anArguments);
-
-  // Check the type of selected object
-  std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
-  bool isValid = true;
-  for (; aValidator != aValidators.end(); aValidator++) {
-    const ModelAPI_ResultValidator* aResValidator =
-        dynamic_cast<const ModelAPI_ResultValidator*>(*aValidator);
-    if (aResValidator) {
-      isValid = false;
-      if (aResValidator->isValid(theObj)) {
-        isValid = true;
-        break;
-      }
-    }
-  }
-  return isValid;
-}
-
-#define VALIDATOR_FILTER
 void ModuleBase_WidgetValidated::activateFilters(ModuleBase_IWorkshop* theWorkshop,
                                                  const bool toActivate) const
 {
   ModuleBase_IViewer* aViewer = theWorkshop->viewer();
 
-#ifdef VALIDATOR_FILTER
   Handle(SelectMgr_Filter) aSelFilter = theWorkshop->validatorFilter();
   if (toActivate)
     aViewer->addSelectionFilter(aSelFilter);
   else
     aViewer->removeSelectionFilter(aSelFilter);
-#else
-  // apply filters loaded from the XML definition of the widget
-  ModuleBase_FilterFactory* aFactory = theWorkshop->selectionFilters();
-  SelectMgr_ListOfFilter aFactoryFilters;
-  aFactory->filters(parentID(), attributeID(), aFactoryFilters);
-  SelectMgr_ListIteratorOfListOfFilter aFactoryIt(aFactoryFilters);
-  for (; aFactoryIt.More(); aFactoryIt.Next()) {
-    Handle(SelectMgr_Filter) aSelFilter = aFactoryIt.Value();
-    if (aSelFilter.IsNull())
-      continue;
-    if (toActivate)
-      aViewer->addSelectionFilter(aSelFilter);
-    else
-      aViewer->removeSelectionFilter(aSelFilter);
-  }
-#endif
-}
-
-void ModuleBase_WidgetValidated::selectionFilters(ModuleBase_IWorkshop* theWorkshop,
-                                                  SelectMgr_ListOfFilter& theFilters) const
-{
-  ModuleBase_FilterFactory* aFactory = theWorkshop->selectionFilters();
-  SelectMgr_ListOfFilter aFilters;
-  aFactory->filters(parentID(), attributeID(), aFilters);
-  SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
-  for (; aIt.More(); aIt.Next()) {
-    Handle(SelectMgr_Filter) aSelFilter = aIt.Value();
-    if (aSelFilter.IsNull())
-      continue;
-
-    theFilters.Append(aSelFilter);
-  }
 }
index fdb0941120ba0b647e9f0633492747b967f9423a..db28807d15628b0c08222dd74b23ea29cf7530db 100644 (file)
@@ -64,21 +64,10 @@ protected:
   // \return true if all validators return that the attribute is valid
   bool isValidAttribute() const;
 
-  /// Check the selected with validators if installed
-  /// \param theObj the object for checking
-  /// \param theShape the shape for checking
-  virtual bool isValid(ObjectPtr theObj, GeomShapePtr theShape) const;
-
   /// It obtains selection filters from the workshop and activates them in the active viewer
   /// \param theWorkshop an active workshop
   /// \param toActivate a flag about activation or deactivation the filters
   virtual void activateFilters(ModuleBase_IWorkshop* theWorkshop, const bool toActivate) const;
-
-  /// Fills the given list with all widget filters.
-  /// \param theWorkshop an active workshop
-  /// \param theFilters a list of filters
-  void selectionFilters(ModuleBase_IWorkshop* theWorkshop,
-                        SelectMgr_ListOfFilter& theFilters) const;
 };
 
 #endif /* MODULEBASE_WIDGETVALIDATED_H_ */
index 6299ff04ad4fed863865986c61b67f69adbab122..9646b8398677cffaeb97f6256ab2622d74b920c6 100644 (file)
@@ -130,7 +130,6 @@ void PartSet_Module::registerValidators()
   aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
   aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
   aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator);
-  aFactory->registerValidator("PartSet_SketchValidator", new PartSet_SketchValidator);
 
   aFactory->registerValidator("ModuleBase_ValidatorLinearEdge", new ModuleBase_ValidatorLinearEdge);
   aFactory->registerValidator("ModuleBase_ValidatorLinearEdgeOrVertex",
index 305647650d0372de3edb8be328155e8e5f92fe00..b246046d509408010fc3d474693d38225ed23082 100644 (file)
@@ -192,29 +192,41 @@ bool PartSet_DifferentObjectsValidator::featureHasReferences(const AttributePtr&
 bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
                                             const std::list<std::string>& theArguments) const
 {
-  AttributeSelectionListPtr aSelectionListAttr = 
-                    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
-
-  // it filters only selection list attributes
-  if (aSelectionListAttr.get() == NULL)
-    return true;
-
-  std::string aType = aSelectionListAttr->selectionType().c_str();
-
-  // all context objects should be sketch entities
   bool isSketchEntities = true;
-  int aSize = aSelectionListAttr->size();
-  for (int i = 0; i < aSelectionListAttr->size(); i++) {
-    AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
-    ObjectPtr anObject = aSelectAttr->context();
-    FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
-    isSketchEntities = aFeature->getKind() == SketchPlugin_Sketch::ID();
+  std::set<std::string> anEntityKinds;
+  std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
+  for (; anIt != aLast; anIt++) {
+    anEntityKinds.insert(*anIt);
   }
-  return isSketchEntities;
-}
 
-bool PartSet_SketchValidator::isValid(const ObjectPtr theObject) const
-{
-  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-  return aFeature->getKind() == SketchPlugin_Sketch::ID();
+  std::string anAttributeType = theAttribute->attributeType();
+  if (anAttributeType == ModelAPI_AttributeSelectionList::type()) {
+    AttributeSelectionListPtr aSelectionListAttr = 
+                      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+    // it filters only selection list attributes
+    std::string aType = aSelectionListAttr->selectionType().c_str();
+    // all context objects should be sketch entities
+    int aSize = aSelectionListAttr->size();
+    for (int i = 0; i < aSelectionListAttr->size() && isSketchEntities; i++) {
+      AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
+      ObjectPtr anObject = aSelectAttr->context();
+      FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+      isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+    }
+  }
+  if (anAttributeType == ModelAPI_AttributeRefAttr::type()) {
+    std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
+                     std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+    isSketchEntities = false;
+    if (aRef->isObject()) {
+      ObjectPtr anObject = aRef->object();
+      if (anObject.get() != NULL) {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+        if (aFeature.get() != NULL)
+          isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+      }
+    }
+  }
+
+  return isSketchEntities;
 }
index 556c2ce06d4e15888c25c59c964d14ddb7913f6c..389cc4fa20def49b2048b0aa4707063d680465a1 100644 (file)
@@ -11,8 +11,7 @@
 
 #include <ModuleBase_SelectionValidator.h>
 #include <ModuleBase_ISelection.h>
-#include <ModelAPI_RefAttrValidator.h>
-#include <ModelAPI_ResultValidator.h>
+#include <ModelAPI_AttributeValidator.h>
 
 /*
  * Selector validators
@@ -70,7 +69,7 @@ class PartSet_RigidValidator : public ModuleBase_SelectionValidator
 * \ingroup Validators
 * A validator which checks that objects selected for feature attributes are different (not the same)
 */
-class PartSet_DifferentObjectsValidator : public ModelAPI_RefAttrValidator
+class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator
 {
  public:
   //! Returns true if the attribute is good for the feature attribute
@@ -95,7 +94,7 @@ protected:
 * \ingroup Validators
 * A validator which checks that objects selected for feature attributes are different (not the same)
 */
-class PartSet_SketchEntityValidator : public ModelAPI_RefAttrValidator
+class PartSet_SketchEntityValidator : public ModelAPI_AttributeValidator
 {
  public:
   //! Returns true if the attribute is good for the feature attribute
@@ -105,16 +104,4 @@ class PartSet_SketchEntityValidator : public ModelAPI_RefAttrValidator
                        const std::list<std::string>& theArguments) const;
 };
 
-/**
-* \ingroup Validators
-* A Validator which validates tha selected object is a Sketch
-*/
-class PartSet_SketchValidator : public ModelAPI_ResultValidator
-{
- public:
-   /// Returns True if the given object is a sketch
-   /// \param theObject an object
-  virtual bool isValid(const ObjectPtr theObject) const;
-};
-
 #endif
\ No newline at end of file
index 726f8c160dcca63d3f3a8dc8636cf65febfc59bb..45fe790e76675c38f733199dba43de5e6853eeb2 100644 (file)
@@ -9,8 +9,6 @@
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
-#include <ModelAPI_RefAttrValidator.h>
-#include <ModelAPI_ResultValidator.h>
 
 #include <PartSet_Tools.h>
 #include <SketchPlugin_Feature.h>
index 2984571336bda4ddd527db36df7b537f8d02b198..992bd6bdbd491ff5c1310ef2923577985236c474 100644 (file)
@@ -30,7 +30,6 @@ SET(PROJECT_HEADERS
     SketchPlugin_ConstraintFillet.h
     SketchPlugin_ShapeValidator.h
     SketchPlugin_Validators.h
-    SketchPlugin_ResultValidators.h 
 )
 
 SET(PROJECT_SOURCES
@@ -58,7 +57,6 @@ SET(PROJECT_SOURCES
     SketchPlugin_ConstraintFillet.cpp
     SketchPlugin_ShapeValidator.cpp
     SketchPlugin_Validators.cpp
-    SketchPlugin_ResultValidators.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 9bcc299bf59d46bee2b8bf2b158e9d9311f60d3c..04347759e5655848a0831c73ab5977e2abbc211d 100644 (file)
@@ -20,7 +20,6 @@
 #include <SketchPlugin_ConstraintTangent.h>
 #include <SketchPlugin_ConstraintVertical.h>
 #include <SketchPlugin_Validators.h>
-#include <SketchPlugin_ResultValidators.h>
 #include <SketchPlugin_ShapeValidator.h>
 
 #include <Events_Loop.h>
@@ -54,9 +53,7 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
                               new SketchPlugin_DistanceAttrValidator);  
   //aFactory->registerValidator("SketchPlugin_DifferentObjects",
   //                            new SketchPlugin_DifferentObjectsValidator);
-  aFactory->registerValidator("SketchPlugin_ResultPoint", new SketchPlugin_ResultPointValidator);
-  aFactory->registerValidator("SketchPlugin_ResultLine", new SketchPlugin_ResultLineValidator);
-  aFactory->registerValidator("SketchPlugin_ResultArc", new SketchPlugin_ResultArcValidator);
+
   aFactory->registerValidator("SketchPlugin_ShapeValidator",
                               new SketchPlugin_ShapeValidator);
 
diff --git a/src/SketchPlugin/SketchPlugin_ResultValidators.cpp b/src/SketchPlugin/SketchPlugin_ResultValidators.cpp
deleted file mode 100644 (file)
index 15f8554..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File:        Model_ResultValidators.cpp
-// Created:     23 July 2014
-// Author:      Vitaly SMETANNIKOV
-
-#include "SketchPlugin_ResultValidators.h"
-
-#include <ModelAPI_Result.h>
-#include <ModelAPI_Tools.h>
-#include <GeomAPI_Curve.h>
-
-ResultPtr result(const ObjectPtr theObject)
-{
-  return std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-}
-
-bool SketchPlugin_ResultPointValidator::isValid(const ObjectPtr theObject) const
-{
-  ResultPtr aResult = result(theObject);
-  if (!aResult)
-    return false;
-  std::shared_ptr<GeomAPI_Shape> aShape = ModelAPI_Tools::shape(aResult);
-  return aShape && aShape->isVertex();
-}
-
-bool SketchPlugin_ResultLineValidator::isValid(const ObjectPtr theObject) const
-{
-  ResultPtr aResult = result(theObject);
-  if (!aResult)
-    return false;
-  std::shared_ptr<GeomAPI_Shape> aShape = ModelAPI_Tools::shape(aResult);
-  return aShape && aShape->isEdge() && GeomAPI_Curve(aShape).isLine();
-}
-
-bool SketchPlugin_ResultArcValidator::isValid(const ObjectPtr theObject) const
-{
-  ResultPtr aResult = result(theObject);
-  if (!aResult)
-    return false;
-  std::shared_ptr<GeomAPI_Shape> aShape = ModelAPI_Tools::shape(aResult);
-  return aShape && aShape->isEdge() && GeomAPI_Curve(aShape).isCircle();
-}
diff --git a/src/SketchPlugin/SketchPlugin_ResultValidators.h b/src/SketchPlugin/SketchPlugin_ResultValidators.h
deleted file mode 100644 (file)
index 6e328b1..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File:        Model_ResultValidators.h
-// Created:     23 July 2014
-// Author:      Vitaly SMETANNIKOV
-
-#ifndef Model_ResultValidators_H
-#define Model_ResultValidators_H
-
-#include <SketchPlugin.h>
-#include <ModelAPI_ResultValidator.h>
-#include <ModelAPI_Object.h>
-
-/**\class SketchPlugin_ResultPointValidator
- * \ingroup Validators
- * \brief Validator for the points selection
- *
- * Allows to select points only.
- */
-class SketchPlugin_ResultPointValidator : public ModelAPI_ResultValidator
-{
-public:
-  /// Returns true if theObject is a point
-  SKETCHPLUGIN_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
-};
-
-/**\class SketchPlugin_ResultLineValidator
- * \ingroup Validators
- * \brief Validator for the linear segments selection
- *
- * Allows to select linear segments only.
- */
-class SketchPlugin_ResultLineValidator : public ModelAPI_ResultValidator
-{
-public:
-  /// Returns true if theObject is a line
-  SKETCHPLUGIN_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
-};
-
-/**\class SketchPlugin_ResultArcValidator
- * \ingroup Validators
- * \brief Validator for the circular segments selection
- *
- * Allows to select circular segments only.
- */
-class SketchPlugin_ResultArcValidator : public ModelAPI_ResultValidator
-{
- public:
-  /// Returns true if theObject is an arc
-  SKETCHPLUGIN_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
-};
-
-#endif
index e1dacf811bc9702ef7eb0563741e86130ffce78b..0722ce1b3fd36877c2282c67127ef5801954aa19 100644 (file)
@@ -11,7 +11,6 @@
 #include <ModelAPI_Result.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_ResultValidator.h>
 
 bool SketchPlugin_ShapeValidator::isValid(const AttributePtr& theAttribute,
                                           const std::list<std::string>& theArguments) const
index e69dce246f6b1ff333720f7bca8b8716dfcb474e..ec5e929abb7d0b6101fe2e35f0e583d71f05f1ba 100644 (file)
@@ -8,10 +8,12 @@
 #include "SketchPlugin_ConstraintDistance.h"
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Validator.h>
-#include <ModelAPI_ResultValidator.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_Session.h>
+
+//#include <ModuleBase_ValidatorLinearEdge.h>
+
 #include <GeomDataAPI_Point2D.h>
 
 bool SketchPlugin_DistanceAttrValidator::isValid(
@@ -33,8 +35,23 @@ bool SketchPlugin_DistanceAttrValidator::isValid(
   } else {
     // 1. check whether the references object is a linear
     ObjectPtr anObject = aRefAttr->object();
-    const ModelAPI_ResultValidator* anArcValidator =
-        dynamic_cast<const ModelAPI_ResultValidator*>(aFactory->validator("SketchPlugin_ResultArc"));
+    /*
+    const ModelAPI_AttributeValidator* aCircleValidator = 
+      dynamic_cast<ModuleBase_ValidatorLinearEdge*>(aFactory->validator("ModuleBase_ValidatorLinearEdge"));
+    std::list<std::string> anArguments;
+    anArguments.push_back("circle");
+    bool anEdgeValid = aCircleValidator->isValid(aRefAttr, anArguments);
+    if (anEdgeValid)
+      return false;
+      
+    anArguments.clear();
+    anArguments.push_back("line");
+    bool anEdgeValid = aCircleValidator->isValid(aRefAttr, anArguments);
+    if (!anEdgeValid)
+      return true;*/
+
+    /*const ModelAPI_ResultValidator* anArcValidator = aFactory->validator("ModuleBase_ValidatorLinearEdge");
+    //dynamic_cast<const ModelAPI_ResultValidator*>(aFactory->validator("SketchPlugin_ResultArc"));
     bool anArcValid = anArcValidator->isValid(anObject);
     if (anArcValid)
       return false;
@@ -44,9 +61,9 @@ bool SketchPlugin_DistanceAttrValidator::isValid(
         dynamic_cast<const ModelAPI_ResultValidator*>(aFactory->validator("SketchPlugin_ResultLine"));
     bool aLineValid = aLineValidator->isValid(anObject);
     if (!aLineValid)
-      return true;
-    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+      return true;*/
 
+    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
     // If it is a line then we have to check that first attribute id not a line
     std::shared_ptr<GeomDataAPI_Point2D> aPoint = getFeaturePoint(aFeature->data(), aParamA);
     if (aPoint)
index 9b732adee3c456ac7dfcc70bc4e20b0f8d5c15df..ff2183425529a7e001e9b3978497afee51154bf4 100644 (file)
@@ -8,7 +8,7 @@
 #define SketchPlugin_Validators_H
 
 #include "SketchPlugin.h"
-#include <ModelAPI_RefAttrValidator.h>
+#include <ModelAPI_AttributeValidator.h>
 
 /**\class SketchPlugin_DistanceAttrValidator
  * \ingroup Validators
@@ -16,7 +16,7 @@
  *
  * It just checks that distance is greater than zero.
  */
-class SketchPlugin_DistanceAttrValidator : public ModelAPI_RefAttrValidator
+class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator
 {
  public:
   //! returns true if attribute is valid
index 8d69365e2c628f33406c0d5529bda96f5066c4dc..498db23ddb4dfb0913f16779cf4081b67ebcdf95 100644 (file)
@@ -82,9 +82,7 @@
         <label title="Select a line on which to calculate length" tooltip="Select a line on which to calculate length"/>
         <shape_selector id="ConstraintEntityA" label="Line" tooltip="Select an line" 
             shape_types="edge" >
-            <validator id="SketchPlugin_ResultLine"/>
-            <validator id="ModuleBase_ValidatorLinearEdge" parameters="line"/>
-      <validator id="SketchPlugin_ResultLine"/>
+        <validator id="ModuleBase_ValidatorLinearEdge" parameters="line"/>
     </shape_selector>
         <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
         <doublevalue_editor label="Value" tooltip="Length" id="ConstraintValue" default="computed">
@@ -97,7 +95,6 @@
         <label title="Select a circle or an arc on which to calculate radius" tooltip="Select a circle or an arc on which to calculate radius"/>
         <shape_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc" 
             shape_types="edge">
-            <validator id="SketchPlugin_ResultArc"/>
             <validator id="ModuleBase_ValidatorLinearEdge" parameters="circle"/>
         </shape_selector>
         <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt"  default="computed" internal="1" obligatory="0"/>
       <feature id="SketchConstraintRigid" title="Fixed" tooltip="Fix an object" icon=":icons/fixed.png">
         <shape_selector id="ConstraintEntityA" label="Object" tooltip="Select an object" 
             shape_types="edge vertex">
-            <validator id="SketchPlugin_ResultPoint"/>
-            <validator id="SketchPlugin_ResultLine"/>
-            <validator id="SketchPlugin_ResultArc"/>
+          <validator id="PartSet_SketchEntityValidator" parameters="SketchPoint,SketchLine,SketchCircle,SketchArc"/>
         </shape_selector>
         <validator id="PartSet_RigidValidator"/>
       </feature>