]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Result attributes validators created
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 23 Jul 2014 14:22:23 +0000 (18:22 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 23 Jul 2014 14:22:23 +0000 (18:22 +0400)
33 files changed:
src/Model/Model_Validator.cpp
src/Model/Model_Validator.h
src/ModelAPI/ModelAPI_Validator.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_ResultValidators.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_ResultValidators.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetBoolValue.cpp
src/ModuleBase/ModuleBase_WidgetBoolValue.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.h
src/ModuleBase/ModuleBase_WidgetEditor.cpp
src/ModuleBase/ModuleBase_WidgetEditor.h
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFactory.h
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/ModuleBase/ModuleBase_WidgetFeature.h
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.h
src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp
src/ModuleBase/ModuleBase_WidgetPoint2dDistance.h
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 771ea6c34bd461fdcf5899b88d8b9aece6736d89..8ca1bf09f25be9dca2b659dff978f8cad556c58f 100644 (file)
@@ -79,6 +79,18 @@ const ModelAPI_Validator* Model_ValidatorsFactory::validator(const string& theFe
   return NULL; // not found
 }
 
+const ModelAPI_Validator* Model_ValidatorsFactory::validator(
+  const std::string& theFeatureID, const std::string& theAttrID) const
+{
+  map<string, map<string, pair<ModelAPI_Validator*, list<string> > > >::const_iterator
+    aFeature = myAttrs.find(theFeatureID);
+  if (aFeature == myAttrs.cend()) return NULL; // feature is not found
+  map<string, pair<ModelAPI_Validator*, list<string> > >::const_iterator 
+    anAttr = aFeature->second.find(theAttrID);
+  if (anAttr == aFeature->second.cend()) return NULL; // attribute is not found
+  return anAttr->second.first;
+}
+
 /*bool Model_ValidatorsFactory::validate(
   const boost::shared_ptr<ModelAPI_Feature>& theFeature, const string& theAttrID ) const
 {
index a917911d91c5dce5218c927a4167a21b6ebd0041..8655b91a92ceda8203ed0825a028777b44c21e9b 100644 (file)
@@ -43,6 +43,9 @@ public:
 
   /// Provides a validator for the feature, returns NULL if no validator
   MODEL_EXPORT virtual const ModelAPI_Validator* validator(const std::string& theFeatureID) const;
+  /// Provides a validator for the attribute, returns NULL if no validator
+  MODEL_EXPORT virtual const ModelAPI_Validator* validator(
+    const std::string& theFeatureID, const std::string& theAttrID) const;
 
   /// Returns the result of "validate" method for attribute of validator.
   /// If validator is not exists, returns true: everything is valid by default.
index 4c807763ac2f2cd104415b062846b1fc8e23444f..7bc08324a78db0b7ab1616dc0bc696c6e3bd4ed5 100644 (file)
@@ -67,6 +67,10 @@ public:
   /// Provides a validator for the feature, returns NULL if no validator
   virtual const ModelAPI_Validator* validator(const std::string& theFeatureID) const = 0;
 
+  /// Provides a validator for the attribute, returns NULL if no validator
+  virtual const ModelAPI_Validator* validator(
+    const std::string& theFeatureID, const std::string& theAttrID) const = 0;
+
   /// Returns the result of "validate" method for attribute of validator.
   /// If validator is not exists, returns true: everything is valid by default.
   //virtual bool validate(
index 350af8c02bd923f2d018b0ecd1300cc84db03312..1d8531d4d7b53455d9f8c9120a74c98dbf3717bb 100644 (file)
@@ -26,6 +26,7 @@ SET(PROJECT_HEADERS
        ModuleBase_ISelection.h
        ModuleBase_ViewerPrs.h
        ModuleBase_Tools.h
+       ModuleBase_ResultValidators.h
 )
 
 SET(PROJECT_SOURCES
@@ -46,6 +47,7 @@ SET(PROJECT_SOURCES
        ModuleBase_WidgetValue.cpp
        ModuleBase_WidgetValueFeature.cpp
        ModuleBase_Tools.cpp
+       ModuleBase_ResultValidators.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 178eb5d6316cf0db2bb2cf77c712614f498f7a0c..756451c299f834cd66652c3f911bd29c312da05f 100644 (file)
 
 #include <QWidget>
 
-ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData)
- : QObject(theParent), myHasDefaultValue(false)
+ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, 
+  const Config_WidgetAPI* theData, 
+  const std::string& theParentId)
+ : QObject(theParent), myHasDefaultValue(false), myParentId(theParentId)
 {
   myAttributeID = theData ? theData->widgetId() : "";
 }
@@ -35,8 +37,3 @@ bool ModuleBase_ModelWidget::focusTo()
   }
   return true;
 }
-
-std::string ModuleBase_ModelWidget::attributeID() const
-{
-  return myAttributeID;
-}
index 8e4b010f6fce72e933ced50fec39124e07608790..45c5789a5ae75ffc83d67d28f63c1a03bf99b9b7 100644 (file)
@@ -33,7 +33,7 @@ public:
   /// Constructor
   /// \theParent the parent object
   /// \theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData);
+  ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
   /// Destructor
   virtual ~ModuleBase_ModelWidget() {};
 
@@ -68,7 +68,11 @@ public:
 
   /// Returns the attribute name
   /// \returns the string value
-  std::string attributeID() const;
+  std::string attributeID() const { return myAttributeID; }
+
+  /// Returns the parent of the attribute
+  /// \returns the string value
+  std::string parentID() const { return myParentId; }
 
 signals:
   /// The signal about widget values changed
@@ -90,6 +94,7 @@ protected:
 
 private:
   std::string myAttributeID; /// the attribute name of the model feature
+  std::string myParentId;    /// name of parent
 };
 
 #endif
diff --git a/src/ModuleBase/ModuleBase_ResultValidators.cpp b/src/ModuleBase/ModuleBase_ResultValidators.cpp
new file mode 100644 (file)
index 0000000..631857d
--- /dev/null
@@ -0,0 +1,83 @@
+// File:        ModuleBase_ResultValidators.cpp
+// Created:     23 July 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "ModuleBase_ResultValidators.h"
+#include "ModuleBase_Tools.h"
+
+#include <ModelAPI_Result.h>
+#include <GeomAPI_Shape.h>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+#include <GeomAdaptor_Curve.hxx>
+
+
+ResultPtr result(const ObjectPtr theObject)
+{
+  return boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+}
+
+TopoDS_Shape shape(ResultPtr theResult)
+{
+  boost::shared_ptr<GeomAPI_Shape> aShape = ModuleBase_Tools::shape(theResult);
+  if (aShape)
+    return aShape->impl<TopoDS_Shape>();
+  return TopoDS_Shape();
+}
+
+
+bool ModuleBase_ResulPointValidator::isValid(const ObjectPtr theObject) const
+{
+  ResultPtr aResult = result(theObject);
+  if (!aResult)
+    return false;
+  TopoDS_Shape aShape = shape(aResult);
+  if (aShape.IsNull())
+    return false;
+
+  return aShape.ShapeType() == TopAbs_VERTEX;
+}
+
+
+bool ModuleBase_ResulLineValidator::isValid(const ObjectPtr theObject) const
+{
+  ResultPtr aResult = result(theObject);
+  if (!aResult)
+    return false;
+  TopoDS_Shape aShape = shape(aResult);
+  if (aShape.IsNull())
+    return false;
+
+  if (aShape.ShapeType() == TopAbs_EDGE) {
+    TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+    Standard_Real aStart, aEnd;
+    Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
+    GeomAdaptor_Curve aAdaptor(aCurve);
+    return aAdaptor.GetType() == GeomAbs_Line;
+  }
+  return false;
+}
+
+
+bool ModuleBase_ResulArcValidator::isValid(const ObjectPtr theObject) const
+{
+  ResultPtr aResult = result(theObject);
+  if (!aResult)
+    return false;
+  TopoDS_Shape aShape = shape(aResult);
+  if (aShape.IsNull())
+    return false;
+
+  if (aShape.ShapeType() == TopAbs_EDGE) {
+    TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+    Standard_Real aStart, aEnd;
+    Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
+    GeomAdaptor_Curve aAdaptor(aCurve);
+    return aAdaptor.GetType() == GeomAbs_Circle;
+  }
+  return false;
+}
+
diff --git a/src/ModuleBase/ModuleBase_ResultValidators.h b/src/ModuleBase/ModuleBase_ResultValidators.h
new file mode 100644 (file)
index 0000000..50cc2e7
--- /dev/null
@@ -0,0 +1,36 @@
+// File:        ModuleBase_ResultValidators.h
+// Created:     23 July 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef ModuleBase_ResultValidators_H
+#define ModuleBase_ResultValidators_H
+
+#include "ModuleBase.h"
+#include <ModelAPI_Validator.h>
+#include <ModelAPI_Object.h>
+
+class ModuleBase_ResultValidator: public ModelAPI_Validator
+{
+public:
+  virtual bool isValid(const ObjectPtr theObject) const = 0;
+};
+
+class ModuleBase_ResulPointValidator: public ModuleBase_ResultValidator
+{
+public:
+  MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+class ModuleBase_ResulLineValidator: public ModuleBase_ResultValidator
+{
+public:
+  MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+class ModuleBase_ResulArcValidator: public ModuleBase_ResultValidator
+{
+public:
+  MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+#endif
\ No newline at end of file
index 2c5faadd25fdb9053aef8afb7bb9a9ca0d8213b2..1c3b68d1d9bcbb87029802de5b55f24aefb53eba 100644 (file)
 #include <QLayout>
 #include <QCheckBox>
 
-ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent, const Config_WidgetAPI* theData)
-  : ModuleBase_ModelWidget(theParent, theData)
+ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent, 
+  const Config_WidgetAPI* theData, 
+  const std::string& theParentId)
+  : ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
   QString aText = QString::fromStdString(theData->widgetLabel());
   QString aToolTip = QString::fromStdString(theData->widgetTooltip());
index 3969e643e47a3dde01d7deac7fb1a6d0b40fc3d0..17c5a68498b1bdec2e02b237216c4acb040a980c 100644 (file)
@@ -19,7 +19,7 @@ public:
   /// Constructor
   /// \theParent the parent object
   /// \theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_WidgetBoolValue(QWidget* theParent, const Config_WidgetAPI* theData);
+  ModuleBase_WidgetBoolValue(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
 
   virtual ~ModuleBase_WidgetBoolValue();
 
index f246713cd7d5e6d54482a6f0b27bf3a547a513fc..04f80d8792ac2d21bcbf9e9a36e5dfb658d12610 100644 (file)
 #endif
 
 
-ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData)
-  : ModuleBase_ModelWidget(theParent, theData)
+ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, 
+  const Config_WidgetAPI* theData, 
+  const std::string& theParentId)
+  : ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
   myContainer = new QWidget(theParent);
   QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
index 909855d18e9712d349fe3794e080839b56e43621..a04a4e928fa804b2a349d1548b3280cd6a68df3c 100644 (file)
@@ -20,7 +20,7 @@ public:
   /// Constructor
   /// \theParent the parent object
   /// \theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData);
+  ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
 
   virtual ~ModuleBase_WidgetDoubleValue();
 
index 16d4c52cbc60bc9dbdf0de0e2ae3a5389695e69f..9774a52bbb86c664001846b2e9cf190a42ad1fe3 100644 (file)
 #include <QDoubleSpinBox>
 
 ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent,
-                                                 const Config_WidgetAPI* theData)
-: ModuleBase_WidgetDoubleValue(theParent, theData)
+                                                 const Config_WidgetAPI* theData, 
+                                                 const std::string& theParentId)
+: ModuleBase_WidgetDoubleValue(theParent, theData, theParentId)
 {
 }
 
 ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent, const std::string& theAttribute)
-: ModuleBase_WidgetDoubleValue(theParent, 0)
+: ModuleBase_WidgetDoubleValue(theParent, 0, "")
 {
   setAttributeID(theAttribute);
 }
index 4585bdbbc110d2cb72aa4ee69083d1bd92d975f1..9c567bfcc7f65d4f5e57fee6ef1664353f4863cc 100644 (file)
@@ -26,7 +26,7 @@ public:
   /// \theParent the parent object
   /// \theParent the parent object
   /// \theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData);
+  ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
   /// Constructor
   /// \theParent the parent object
   /// \theParent the parent object
index 0c62cf36106de4730782099a10e05de8203e15be..6f292f3a602060e9d110284f681ab6ca20781b4f 100644 (file)
@@ -54,6 +54,7 @@ ModuleBase_WidgetFactory::~ModuleBase_WidgetFactory()
 
 void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
 {
+  myParentId = myWidgetApi->widgetId();
   if (!myWidgetApi->toChildWidget())
     return;
 
@@ -177,7 +178,8 @@ QWidget* ModuleBase_WidgetFactory::createContainer(const std::string& theType, Q
 
 QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent)
 {
-  ModuleBase_WidgetDoubleValue* aDblWgt = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi);
+  ModuleBase_WidgetDoubleValue* aDblWgt = 
+    new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId);
   myModelWidgets.append(aDblWgt);
 
   return aDblWgt->getControl();
@@ -185,29 +187,32 @@ QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent)
 
 QWidget* ModuleBase_WidgetFactory::pointSelectorControl(QWidget* theParent)
 {
-  ModuleBase_WidgetPoint2D* aWidget = new ModuleBase_WidgetPoint2D(theParent, myWidgetApi);
+  ModuleBase_WidgetPoint2D* aWidget = 
+    new ModuleBase_WidgetPoint2D(theParent, myWidgetApi, myParentId);
   myModelWidgets.append(aWidget);
   return aWidget->getControl();
 }
 
 QWidget* ModuleBase_WidgetFactory::featureSelectorControl(QWidget* theParent)
 {
-  ModuleBase_WidgetFeature* aWidget = new ModuleBase_WidgetFeature(theParent, myWidgetApi);
+  ModuleBase_WidgetFeature* aWidget = 
+    new ModuleBase_WidgetFeature(theParent, myWidgetApi, myParentId);
   myModelWidgets.append(aWidget);
   return aWidget->getControl();
 }
 
 QWidget* ModuleBase_WidgetFactory::featureOrAttributeSelectorControl(QWidget* theParent)
 {
-  ModuleBase_WidgetFeatureOrAttribute* aWidget = new ModuleBase_WidgetFeatureOrAttribute(theParent,
-                                                                                      myWidgetApi);
+  ModuleBase_WidgetFeatureOrAttribute* aWidget = 
+    new ModuleBase_WidgetFeatureOrAttribute(theParent, myWidgetApi, myParentId);
   myModelWidgets.append(aWidget);
   return aWidget->getControl();
 }
 
 QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent)
 {
-  ModuleBase_WidgetEditor* aWidget = new ModuleBase_WidgetEditor(theParent, myWidgetApi);
+  ModuleBase_WidgetEditor* aWidget = 
+    new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId);
   myModelWidgets.append(aWidget);
   return aWidget->getControl();
 }
@@ -230,7 +235,8 @@ bool ModuleBase_WidgetFactory::isInternalWidget(const std::string& theType)
 
 QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent)
 {
-  ModuleBase_WidgetSelector* aSelector = new ModuleBase_WidgetSelector(theParent, myWorkshop, myWidgetApi);
+  ModuleBase_WidgetSelector* aSelector = 
+    new ModuleBase_WidgetSelector(theParent, myWorkshop, myWidgetApi, myParentId);
   myModelWidgets.append(aSelector);
   return aSelector->getControl();
 }
@@ -238,7 +244,8 @@ QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent)
 
 QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
 {
-  ModuleBase_WidgetBoolValue* aBoolWgt = new ModuleBase_WidgetBoolValue(theParent, myWidgetApi);
+  ModuleBase_WidgetBoolValue* aBoolWgt = 
+    new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId);
   myModelWidgets.append(aBoolWgt);
 
   return aBoolWgt->getControl();
@@ -247,7 +254,8 @@ QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
 
 QWidget* ModuleBase_WidgetFactory::point2dDistanceControl(QWidget* theParent)
 {
-  ModuleBase_WidgetPoint2dDistance* aDistWgt = new ModuleBase_WidgetPoint2dDistance(theParent, myWidgetApi);
+  ModuleBase_WidgetPoint2dDistance* aDistWgt = 
+    new ModuleBase_WidgetPoint2dDistance(theParent, myWidgetApi, myParentId);
   myModelWidgets.append(aDistWgt);
 
   return aDistWgt->getControl();
index dbbdcffd21ea63f40ba1c1c66abe30cf0727b66c..5360f35dbba39a443ee05b2e460c5a06f4fe2b54 100644 (file)
@@ -58,6 +58,7 @@ private:
   ModuleBase_IWorkshop*   myWorkshop;
 
   QList<ModuleBase_ModelWidget*> myModelWidgets;
+  std::string myParentId;
 };
 
 #endif /* ModuleBase_WidgetFactory_H_ */
index 7bf014ed3302378e7c81ac5104d52795d8c21639..6d533508eb56a94828efe12ac513237227c76426 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <ModuleBase_WidgetValueFeature.h>
 #include <ModuleBase_WidgetValue.h>
+#include <ModuleBase_ResultValidators.h>
 
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
@@ -17,6 +18,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_Validator.h>
 
 #include <QWidget>
 #include <QLineEdit>
 #include <QLabel>
 
 ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent,
-                                                   const Config_WidgetAPI* theData)
-: ModuleBase_ModelWidget(theParent, theData)
+                                                   const Config_WidgetAPI* theData, 
+                                                   const std::string& theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
-  QString aKinds = QString::fromStdString(theData->getProperty(FEATURE_KEYSEQUENCE));
-  myObjectKinds = aKinds.split(" ");
+  //QString aKinds = QString::fromStdString(theData->getProperty(FEATURE_KEYSEQUENCE));
+  //myObjectKinds = aKinds.split(" ");
+  //theData->
 
   myContainer = new QWidget(theParent);
   QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
@@ -70,6 +74,17 @@ bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue)
 
 bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject)
 {
+  PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+  const ModelAPI_Validator* aValidator = aFactory->validator(parentID(), attributeID());
+  if (aValidator) {
+    const ModuleBase_ResultValidator* aResValidator = 
+      dynamic_cast<const ModuleBase_ResultValidator*>(aValidator);
+    if (aResValidator) {
+      if (!aResValidator->isValid(theObject))
+        return false;
+    }
+  }
   // TODO
   //if (!myObjectKinds.contains(theObject->getKind().c_str()))
   //  return false;
index 8cfd499a62a3bbf2ebd5ddf721c1873e04f3c9c7..fbfc7e2e9a9a620a128dc7f69f81b6f232a20558 100644 (file)
@@ -29,7 +29,7 @@ public:
   /// \theParent the parent object
   /// \theParent the parent object
   /// \theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_WidgetFeature(QWidget* theParent, const Config_WidgetAPI* theData);
+  ModuleBase_WidgetFeature(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
   /// Destructor
   virtual ~ModuleBase_WidgetFeature();
 
index 70c0fe959a14e570ae8f2dfbaf0487f1f861fd5e..633adbc439e22e36df7a632acd878b5fd734b47d 100644 (file)
@@ -29,8 +29,9 @@
 #include <QLabel>
 
 ModuleBase_WidgetFeatureOrAttribute::ModuleBase_WidgetFeatureOrAttribute(QWidget* theParent,
-                                                   const Config_WidgetAPI* theData)
-: ModuleBase_WidgetFeature(theParent, theData)
+                                                   const Config_WidgetAPI* theData, 
+                                                   const std::string& theParentId)
+: ModuleBase_WidgetFeature(theParent, theData, theParentId)
 {
 }
 
index 7084165a520ba6843f5bc829e217dbaba970bb63..dc9bad6d8b4e249c5703795411a93fca11416d30 100644 (file)
@@ -25,7 +25,7 @@ public:
   /// \theParent the parent object
   /// \theParent the parent object
   /// \theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_WidgetFeatureOrAttribute(QWidget* theParent, const Config_WidgetAPI* theData);
+  ModuleBase_WidgetFeatureOrAttribute(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
   /// Destructor
   virtual ~ModuleBase_WidgetFeatureOrAttribute();
 
index cefa9284771c98de52d5b0ebf2f55af5febd0e02..9fbc7b7e68ae29462f689255a78ee03e777cd73f 100644 (file)
@@ -28,8 +28,9 @@
 #include <climits>
 
 ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent,
-                                                   const Config_WidgetAPI* theData)
-: ModuleBase_ModelWidget(theParent, theData)
+                                                   const Config_WidgetAPI* theData, 
+                                                   const std::string& theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
   myOptionParam = theData->getProperty(PREVIOUS_FEATURE_PARAM);
   myGroupBox = new QGroupBox(QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME)),
index 5c72695209625ec94169c2c433678a4e745ae571..ed249c4b76feae800cb8929fc53f99a2a6b7220c 100644 (file)
@@ -29,7 +29,7 @@ public:
   /// \theParent the parent object
   /// \theParent the parent object
   /// \theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData);
+  ModuleBase_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
   /// Destructor
   virtual ~ModuleBase_WidgetPoint2D();
 
index 871654bd21c99da06bc005768d8b300c1be95419..ef5cf3207b1a193cf12632dc0906fa350499277d 100644 (file)
@@ -14,8 +14,9 @@
 
 #include <QDoubleSpinBox>
 
-ModuleBase_WidgetPoint2dDistance::ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData)
-  : ModuleBase_WidgetDoubleValue(theParent, theData)
+ModuleBase_WidgetPoint2dDistance::ModuleBase_WidgetPoint2dDistance(QWidget* theParent, 
+  const Config_WidgetAPI* theData, const std::string& theParentId)
+  : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId)
 {
   myFirstPntName = theData->getProperty("first_point");
 }
index c635aa4f5406a4b96f3bb38c85c3e74518fd37dd..3ab47c62c85e74e71c52f00799f72163c60919b5 100644 (file)
@@ -19,7 +19,7 @@ public:
   /// Constructor
   /// \theParent the parent object
   /// \theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData);
+  ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
 
   virtual ~ModuleBase_WidgetPoint2dDistance();
 
index 5e0cd3e9837fce05a1d1cca2d2c49c42cc2bb396..1ae894aeb82b5ddd4e5f8a756f0665347d48ed14 100644 (file)
@@ -56,8 +56,9 @@ TopAbs_ShapeEnum ModuleBase_WidgetSelector::shapeType(const QString& theType)
 
 ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent, 
                                                      ModuleBase_IWorkshop* theWorkshop, 
-                                                     const Config_WidgetAPI* theData)
-: ModuleBase_ModelWidget(theParent, theData), myWorkshop(theWorkshop), myActivateOnStart(false)
+                                                     const Config_WidgetAPI* theData,
+                                                     const std::string& theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop), myActivateOnStart(false)
 {
   myContainer = new QWidget(theParent);
   QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
index b1782d072b43765f68cf8588b5ca917f69c03209..1388bc77317fcc2addf1cad120bd7a155d46e719 100644 (file)
@@ -28,7 +28,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetSelector: public ModuleBase_ModelWidget
 public:
   ModuleBase_WidgetSelector(QWidget* theParent, 
                             ModuleBase_IWorkshop* theWorkshop, 
-                            const Config_WidgetAPI* theData);
+                            const Config_WidgetAPI* theData, const std::string& theParentId);
 
   virtual ~ModuleBase_WidgetSelector();
 
index 99d36b0ad8f3400c492f6a56e866447672ea5c6b..6ddaeabe155a71db3cc1c02997f9671e7fa8fee8 100644 (file)
@@ -106,10 +106,6 @@ XGUI_Workshop* PartSet_Module::workshop() const
 
 void PartSet_Module::createFeatures()
 {
-  Config_ModuleReader aXMLReader = Config_ModuleReader();
-  aXMLReader.readAll();
-  myFeaturesInFiles = aXMLReader.featuresInFiles();
-
   //!! Test registering of validators
   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
@@ -118,6 +114,10 @@ void PartSet_Module::createFeatures()
   aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
   aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
   aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
+
+  Config_ModuleReader aXMLReader = Config_ModuleReader();
+  aXMLReader.readAll();
+  myFeaturesInFiles = aXMLReader.featuresInFiles();
 }
 
 void PartSet_Module::featureCreated(QAction* theFeature)
@@ -613,7 +613,7 @@ QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget*
                          Config_WidgetAPI* theWidgetApi, QList<ModuleBase_ModelWidget*>& theModelWidgets)
 {
   if (theType == "sketch-start-label") {
-    PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi);
+    PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, "");
     aWgt->setOperationsMgr(myWorkshop->operationMgr());
     theModelWidgets.append(aWgt);
     return aWgt->getControl();
index 1c8c5836b19bd31a29e4e498d2550364cf308b18..0b390fe761550717492b4a7ddab488e9f220f177 100644 (file)
@@ -146,11 +146,11 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle
     }
   }
   ObjectPtr aFeature;
-/* TODO if (!theSelected.empty()) {
+  if (!theSelected.empty()) {
     ModuleBase_ViewerPrs aPrs = theSelected.front();
     aFeature = aPrs.object();
-  } else*/
-  aFeature = feature(); // for the widget distance only
+  } else
+    aFeature = feature(); // for the widget distance only
 
   bool isApplyed = setWidgetValue(aFeature, aX, anY);
   if (isApplyed) {
index 4b39dc60e9362641af45ec564a40f45754d0ee54..6089ab850600ee24b185e137f962df8899399831 100644 (file)
@@ -13,8 +13,9 @@
 #include <QLabel>
 
 PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent, 
-                                                     const Config_WidgetAPI* theData)
-: ModuleBase_ModelWidget(theParent, theData)
+  const Config_WidgetAPI* theData, 
+  const std::string& theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
   myText = QString::fromStdString(theData->getProperty("title"));
   myLabel = new QLabel(myText, theParent);
index 839b3ec57826adee4982677712e40741b255bab3..558747b46864da25f2bb5eb7dec59e0ce730a964 100644 (file)
@@ -17,7 +17,9 @@ class PARTSET_EXPORT PartSet_WidgetSketchLabel : public ModuleBase_ModelWidget
 {
   Q_OBJECT
 public:
-  PartSet_WidgetSketchLabel(QWidget* theParent, const Config_WidgetAPI* theData);
+  PartSet_WidgetSketchLabel(QWidget* theParent, 
+    const Config_WidgetAPI* theData, 
+    const std::string& theParentId);
 
   virtual ~PartSet_WidgetSketchLabel() {};
 
index 999d742d2d97ee4652cac06c8fec0cc8ad35cad2..e6d71aa232f7b64251fbce45bc64916a45764b58 100644 (file)
          
     <group id="Constraints">
       <feature id="SketchConstraintCoincidence" title="Coincident" tooltip="Create constraint for the coincidence of two points" internal="1"/>
+
       <feature id="SketchConstraintDistance" title="Distance" tooltip="Create constraint for the distance from a point to an object">
         <label title="Select point and another feature (point or point on line) between which to calculate distance" tooltip="Select point and another feature (point or point on line) between which to calculate distance"/>
-        <feature_or_attribute_selector id="ConstraintEntityA" label="First point" tooltip="Select an point in the viewer" keysequence="SketchPoint Point2D"/>
-        <feature_or_attribute_selector id="ConstraintEntityB" label="Last point" tooltip="Select an point in the viewer" keysequence="SketchPoint Point2D"/>
+        <feature_or_attribute_selector id="ConstraintEntityA" label="First point" tooltip="Select an point in the viewer">
+          <validator id="ModuleBase_ResulPointValidator"/>
+        </feature_or_attribute_selector>
+        <feature_or_attribute_selector id="ConstraintEntityB" label="Last point" tooltip="Select an point in the viewer">
+          <validator id="ModuleBase_ResulPointValidator"/>
+        </feature_or_attribute_selector>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
         <validator id="PartSet_DistanceValidator"/> 
       </feature>
+      
       <feature id="SketchConstraintLength" title="Length" tooltip="Create constraint for the given length of a line segment">
         <label title="Select a line on which to calculate lenght" tooltip="Select a line on which to calculate lenght"/>
-        <feature_selector id="ConstraintEntityA" label="Line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
+        <feature_selector id="ConstraintEntityA" label="Line" tooltip="Select an line in the viewer">
+          <validator id="ModuleBase_ResulLineValidator"/>
+        </feature_selector>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
         <validator id="PartSet_LengthValidator"/> 
       </feature>
+      
       <feature id="SketchConstraintRadius" title="Radius" tooltip="Create constraint for the given radius of a circle or an arc">
         <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"/>
-        <feature_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc in the viewer" keysequence="SketchCircle SketchArc"/>
+        <feature_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc in the viewer">
+          <validator id="ModuleBase_ResulArcValidator"/>
+        </feature_selector>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
         <validator id="PartSet_RadiusValidator"/>
       </feature>
+      
       <feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines">
-        <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
-        <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
+        <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer">
+          <validator id="ModuleBase_ResulLineValidator"/>
+        </feature_selector>
+        <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer">
+          <validator id="ModuleBase_ResulLineValidator"/>
+        </feature_selector>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <validator id="PartSet_ParallelValidator"/>
       </feature>
+      
       <feature id="SketchConstraintPerpendicular" title="Perpendicular" tooltip="Create constraint defining two perpendicular lines">
-        <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
-        <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
+        <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer">
+          <validator id="ModuleBase_ResulLineValidator"/>
+        </feature_selector>
+        <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer">
+          <validator id="ModuleBase_ResulLineValidator"/>
+        </feature_selector>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <validator id="PartSet_PerpendicularValidator"/>
       </feature>
index 0ca48658f2fdde9b5e57a5016e1427497a5813ea..9505d9cf2e2b29ce834ca696c1df132f434eb5b0 100644 (file)
@@ -41,6 +41,7 @@
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_SelectionValidator.h>
+#include <ModuleBase_ResultValidators.h>
 
 #include <Config_Common.h>
 #include <Config_FeatureMessage.h>
@@ -135,6 +136,7 @@ void XGUI_Workshop::startApplication()
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 
+  registerValidators();
   activateModule();
   if (myMainWindow) {
     myMainWindow->show();
@@ -997,3 +999,15 @@ void XGUI_Workshop::updateCommandsOnViewSelection()
     }
   }
 }
+
+
+//**************************************************************
+void XGUI_Workshop::registerValidators() const
+{
+  PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+
+  aFactory->registerValidator("ModuleBase_ResulPointValidator", new ModuleBase_ResulPointValidator);
+  aFactory->registerValidator("ModuleBase_ResulLineValidator", new ModuleBase_ResulLineValidator);
+  aFactory->registerValidator("ModuleBase_ResulArcValidator", new ModuleBase_ResulArcValidator);
+}
index c0d5d64551235f98e38fd66280d39be3ebd8abe0..74c20b177a4f38e11d3b18166d66eda1ce7b3736 100644 (file)
@@ -177,6 +177,9 @@ protected slots:
 private:
   void initMenu();
 
+  void registerValidators() const;
+
+
   ModuleBase_IModule* loadModule(const QString& theModule);
   bool activateModule();