]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Thu, 24 Jul 2014 10:19:02 +0000 (14:19 +0400)
committersbh <sergey.belash@opencascade.com>
Thu, 24 Jul 2014 10:19:02 +0000 (14:19 +0400)
41 files changed:
src/ConstructionPlugin/point_widget.xml
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Validator.cpp
src/Model/Model_Validator.h
src/ModelAPI/ModelAPI_Attribute.h
src/ModelAPI/ModelAPI_Data.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_Module.h
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 35397224fd39560d15d452003f5c72c4e8d6cae4..c39b43ad0d4d6a25373c06488f363b4fdcb7a149 100644 (file)
@@ -1,6 +1,6 @@
 <source>
   <doublevalue id="x" label="X:" max="50" step="1.0" default="0" icon=":pictures/x_point.png" tooltip="Set X">
-    <validator id="between" parameters="a,b"/
+    <!-- validator id="between" parameters="a,b"/ --
   </doublevalue>
   <doublevalue id="y" label="Y:" min="x" default="1" icon=":pictures/y_point.png" tooltip="Set Y"/>
   <doublevalue id="z" label="Z:" min="-20" step="0.1" default="2" icon=":pictures/z_point.png" tooltip="Set Z"/>
index 9cd9d082cedb5969b7e95ba9163409ee48591705..2cf5b1b86b66f2c4e30b06e6500e6bd8674637a9 100644 (file)
@@ -37,7 +37,7 @@ string Model_Data::name()
   return ""; // not defined
 }
 
-void Model_Data::setName(string theName)
+void Model_Data::setName(const string& theName)
 {
   bool isModified = false;
   Handle(TDataStd_Name) aName;
@@ -49,13 +49,14 @@ void Model_Data::setName(string theName)
     if (isModified)
       aName->Set(theName.c_str());
   }
-  if (isModified) {
+  // to do not cause the update of the result on name change
+  /*if (isModified) {
     static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
     ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false);
-  }
+  }*/
 }
 
-void Model_Data::addAttribute(string theID, string theAttrType)
+void Model_Data::addAttribute(const string& theID, const string theAttrType)
 {
   TDF_Label anAttrLab = myLab.FindChild(myAttrs.size() + 1);
   ModelAPI_Attribute* anAttr = 0;
@@ -87,7 +88,7 @@ void Model_Data::addAttribute(string theID, string theAttrType)
   }
 }
 
-boost::shared_ptr<ModelAPI_AttributeDocRef> Model_Data::docRef(const string theID)
+boost::shared_ptr<ModelAPI_AttributeDocRef> Model_Data::docRef(const string& theID)
 {
   map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
   if (aFound == myAttrs.end()) {
@@ -102,7 +103,7 @@ boost::shared_ptr<ModelAPI_AttributeDocRef> Model_Data::docRef(const string theI
   return aRes;
 }
 
-boost::shared_ptr<ModelAPI_AttributeDouble> Model_Data::real(const string theID)
+boost::shared_ptr<ModelAPI_AttributeDouble> Model_Data::real(const string& theID)
 {
   map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
   if (aFound == myAttrs.end()) {
@@ -117,7 +118,7 @@ boost::shared_ptr<ModelAPI_AttributeDouble> Model_Data::real(const string theID)
   return aRes;
 }
 
-boost::shared_ptr<ModelAPI_AttributeBoolean> Model_Data::boolean(const std::string theID)
+boost::shared_ptr<ModelAPI_AttributeBoolean> Model_Data::boolean(const std::string& theID)
 {
   map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
   if (aFound == myAttrs.end()) {
@@ -132,7 +133,7 @@ boost::shared_ptr<ModelAPI_AttributeBoolean> Model_Data::boolean(const std::stri
   return aRes;
 }
 
-boost::shared_ptr<ModelAPI_AttributeReference> Model_Data::reference(const string theID)
+boost::shared_ptr<ModelAPI_AttributeReference> Model_Data::reference(const string& theID)
 {
   map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
   if (aFound == myAttrs.end()) {
@@ -147,7 +148,7 @@ boost::shared_ptr<ModelAPI_AttributeReference> Model_Data::reference(const strin
   return aRes;
 }
 
-boost::shared_ptr<ModelAPI_AttributeRefAttr> Model_Data::refattr(const string theID)
+boost::shared_ptr<ModelAPI_AttributeRefAttr> Model_Data::refattr(const string& theID)
 {
   map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
   if (aFound == myAttrs.end()) {
@@ -162,7 +163,7 @@ boost::shared_ptr<ModelAPI_AttributeRefAttr> Model_Data::refattr(const string th
   return aRes;
 }
 
-boost::shared_ptr<ModelAPI_AttributeRefList> Model_Data::reflist(const string theID)
+boost::shared_ptr<ModelAPI_AttributeRefList> Model_Data::reflist(const string& theID)
 {
   map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
   if (aFound == myAttrs.end()) {
@@ -177,7 +178,7 @@ boost::shared_ptr<ModelAPI_AttributeRefList> Model_Data::reflist(const string th
   return aRes;
 }
 
-boost::shared_ptr<ModelAPI_Attribute> Model_Data::attribute(const std::string theID)
+boost::shared_ptr<ModelAPI_Attribute> Model_Data::attribute(const std::string& theID)
 {
   boost::shared_ptr<ModelAPI_Attribute> aResult;
   if (myAttrs.find(theID) == myAttrs.end()) // no such attribute
@@ -185,7 +186,7 @@ boost::shared_ptr<ModelAPI_Attribute> Model_Data::attribute(const std::string th
   return myAttrs[theID];
 }
 
-const string& Model_Data::id(const boost::shared_ptr<ModelAPI_Attribute> theAttr)
+const string& Model_Data::id(const boost::shared_ptr<ModelAPI_Attribute>& theAttr)
 {
   map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = myAttrs.begin();
   for(; anAttr != myAttrs.end(); anAttr++) {
@@ -196,7 +197,7 @@ const string& Model_Data::id(const boost::shared_ptr<ModelAPI_Attribute> theAttr
   return anEmpty;
 }
 
-bool Model_Data::isEqual(const boost::shared_ptr<ModelAPI_Data> theData)
+bool Model_Data::isEqual(const boost::shared_ptr<ModelAPI_Data>& theData)
 {
   boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theData);
   if (aData)
@@ -209,7 +210,7 @@ bool Model_Data::isValid()
   return !myLab.IsNull() && myLab.HasAttribute();
 }
 
-list<boost::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const string theType)
+list<boost::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const string& theType)
 {
   list<boost::shared_ptr<ModelAPI_Attribute> > aResult;
   map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttrsIter = myAttrs.begin();
@@ -224,6 +225,8 @@ list<boost::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const string
 void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr)
 {
   theAttr->setInitialized();
-  static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
-  ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
+  if (theAttr->isArgument()) {
+    static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+    ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
+  }
 }
index c63bce4760be2f493f829d01c9fd691331ad2623..7faa34331cf3e42130b06d4521ade472a0b1abca 100644 (file)
@@ -43,36 +43,36 @@ public:
   /// Returns the name of the feature visible by the user in the object browser
   MODEL_EXPORT virtual std::string name();
   /// Defines the name of the feature visible by the user in the object browser
-  MODEL_EXPORT virtual void setName(std::string theName);
+  MODEL_EXPORT virtual void setName(const std::string& theName);
   /// Returns the attribute that references to another document
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID);
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string& theID);
   /// Returns the attribute that contains real value with double precision
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID);
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string& theID);
   /// Returns the attribute that contains reference to a feature
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeReference> 
-    reference(const std::string theID);
+    reference(const std::string& theID);
   /// Returns the attribute that contains reference to an attribute of a feature
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeRefAttr>
-    refattr(const std::string theID);
+    refattr(const std::string& theID);
   /// Returns the attribute that contains list of references to features
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeRefList> 
-    reflist(const std::string theID);
+    reflist(const std::string& theID);
   /// Returns the attribute that contains boolean value
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeBoolean> 
-    boolean(const std::string theID);
+    boolean(const std::string& theID);
   /// Returns the generic attribute by identifier
   /// \param theID identifier of the attribute
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string theID);
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID);
   /// Returns all attributes ofthe feature of the given type
   /// or all attributes if "theType" is empty
   MODEL_EXPORT virtual std::list<boost::shared_ptr<ModelAPI_Attribute> >
-    attributes(const std::string theType);
+    attributes(const std::string& theType);
 
   /// Identifier by the id (not fast, iteration by map)
   /// \param theAttr attribute already created in this data
-  MODEL_EXPORT virtual const std::string& id(const boost::shared_ptr<ModelAPI_Attribute> theAttr);
+  MODEL_EXPORT virtual const std::string& id(const boost::shared_ptr<ModelAPI_Attribute>& theAttr);
   /// Returns true if data belongs to same features
-  MODEL_EXPORT virtual bool isEqual(const boost::shared_ptr<ModelAPI_Data> theData);
+  MODEL_EXPORT virtual bool isEqual(const boost::shared_ptr<ModelAPI_Data>& theData);
   /// Returns true if it is correctly connected t othe data model
   MODEL_EXPORT virtual bool isValid();
 
@@ -83,7 +83,7 @@ public:
   /// for each attribute of the object
   /// \param theID identifier of the attribute that can be referenced by this ID later
   /// \param theAttrType type of the created attribute (received from the type method)
-  MODEL_EXPORT virtual void addAttribute(std::string theID, std::string theAttrType);
+  MODEL_EXPORT virtual void addAttribute(const std::string& theID, const std::string theAttrType);
 
   /// Useful method for "set" methods of the attributes: sends an UPDATE event and
   /// makes attribute initialized
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 55cbb7cfd9c1d8fc82b2c3ee3ccff5980db91c46..7ea04aa8e16e145d5482d6720ea2473daadbf432 100644 (file)
@@ -21,6 +21,7 @@ class ModelAPI_Attribute
   boost::shared_ptr<ModelAPI_Object> myObject;
 protected: // accessible from the attributes
   bool myIsInitialized;
+  bool myIsArgument;
 public:
   
   /// Returns the type of this class of attributes, not static method
@@ -43,9 +44,16 @@ public:
   /// Makes attribute initialized
   MODELAPI_EXPORT void setInitialized() {myIsInitialized = true;}
 
+  /// Set this attribute is argument for result (change of this attribute requires update of result).
+  /// By default it is true.
+  MODELAPI_EXPORT void setIsArgument(const bool theFlag) {myIsArgument = theFlag;}
+
+  /// Returns true if attribute causes the result change
+  MODELAPI_EXPORT bool isArgument() {return myIsArgument;}
+
 protected:
   /// Objects are created for features automatically
-  ModelAPI_Attribute() {myIsInitialized = false;}
+  ModelAPI_Attribute() {myIsInitialized = false; myIsArgument = true;}
 
 };
 
index eea1d1ae87ac75bbc9f4c614edb2907467d4cc14..3a414e1eaaea533d1894423663da6a23dbbc4148 100644 (file)
@@ -34,33 +34,33 @@ public:
   virtual std::string name() = 0;
 
   /// Defines the name of the feature visible by the user in the object browser
-  virtual void setName(std::string theName) = 0;
+  virtual void setName(const std::string& theName) = 0;
 
   /// Returns the attribute that references to another document
-  virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID) = 0;
+  virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string& theID) = 0;
   /// Returns the attribute that contains real value with double precision
-  virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID) = 0;
+  virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string& theID) = 0;
   /// Returns the attribute that contains reference to a feature
-  virtual boost::shared_ptr<ModelAPI_AttributeReference> reference(const std::string theID) = 0;
+  virtual boost::shared_ptr<ModelAPI_AttributeReference> reference(const std::string& theID) = 0;
   /// Returns the attribute that contains reference to an attribute of a feature
-  virtual boost::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string theID) = 0;
+  virtual boost::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string& theID) = 0;
   /// Returns the attribute that contains list of references to features
-  virtual boost::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string theID) = 0;
+  virtual boost::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string& theID) = 0;
   /// Returns the attribute that contains boolean value
-  virtual boost::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string theID) = 0;
+  virtual boost::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string& theID) = 0;
 
   /// Returns the generic attribute by identifier
   /// \param theID identifier of the attribute
-  virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string theID) = 0;
+  virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID) = 0;
   /// Returns all attributes ofthe feature of the given type
   /// or all attributes if "theType" is empty
   virtual std::list<boost::shared_ptr<ModelAPI_Attribute> >
-    attributes(const std::string theType) = 0;
+    attributes(const std::string& theType) = 0;
   /// Identifier by the id (not fast, iteration by map)
   /// \param theAttr attribute already created in this data
-  virtual const std::string& id(const boost::shared_ptr<ModelAPI_Attribute> theAttr) = 0;
+  virtual const std::string& id(const boost::shared_ptr<ModelAPI_Attribute>& theAttr) = 0;
   /// Returns true if data belongs to same features
-  virtual bool isEqual(const boost::shared_ptr<ModelAPI_Data> theData) = 0;
+  virtual bool isEqual(const boost::shared_ptr<ModelAPI_Data>& theData) = 0;
   /// Returns true if it is correctly connected t othe data model
   virtual bool isValid() = 0;
 
@@ -68,7 +68,7 @@ public:
   /// for each attribute of the object
   /// \param theID identifier of the attribute that can be referenced by this ID later
   /// \param theAttrType type of the created attribute (received from the type method)
-  virtual void addAttribute(std::string theID, std::string theAttrType) = 0;
+  virtual void addAttribute(const std::string& theID, const std::string theAttrType) = 0;
 
   /// Useful method for "set" methods of the attributes: sends an UPDATE event and
   /// makes attribute initialized
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..4cea1a7bf62bd349bb79d047ca87f9a28540947b 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)
@@ -172,8 +172,8 @@ void PartSet_Module::onOperationStarted()
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp) {
     XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
-    connect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
-      this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)), Qt::UniqueConnection);
+    connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
+      this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection);
   }
 }
 
@@ -184,8 +184,8 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
   if (aPreviewOp) {
     XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
-    //disconnect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
-    //           this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)));
+    //disconnect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
+    //           this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)));
   }
 }
 
@@ -273,15 +273,22 @@ void PartSet_Module::onFitAllView()
   myWorkshop->viewer()->fitAll();
 }
 
-void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theFeature)
+void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject)
 {
-  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
   if (!aFeature) {
-    qDebug("Warning! Restart operation without feature!");
-    return;
+    ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aResult) {
+      PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+      DocumentPtr aDoc = aMgr->rootDocument();
+      aFeature = aDoc->feature(aResult);
+    } else {
+      qDebug("Warning! Restart operation without feature!");
+      return;
+    }
   }
   ModuleBase_Operation* anOperation = createOperation(theName.c_str(),
-                                                      theFeature ? aFeature->getKind() : "");
+                                                      aFeature ? aFeature->getKind() : "");
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp)
   {
@@ -361,15 +368,6 @@ void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
         }
       }
     }
-/*      FeaturePtr aFeature = aPrevOp->feature();
-      if (aFeature) {
-        std::list<ResultPtr> aResList = aFeature->results();
-        std::list<ResultPtr>::iterator aIt;
-        for (aIt = aResList.begin(); aIt != aResList.end(); ++aIt) {
-          aDisplayer->deactivate((*aIt), false);
-        }
-      }
-    }*/
     ModelAPI_EventCreator::get()->sendUpdated(theFeature, 
         Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
 //  }
@@ -575,17 +573,19 @@ void PartSet_Module::editFeature(FeaturePtr theFeature)
 //  }
 }
 
-void PartSet_Module::onStorePoint2D(FeaturePtr theFeature, const std::string& theAttribute)
+void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute)
 {
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
+
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
   if (!aPreviewOp)
     return;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(theAttribute));
 
-  PartSet_Tools::setConstraints(aPreviewOp->sketch(), theFeature, theAttribute,
+  PartSet_Tools::setConstraints(aPreviewOp->sketch(), aFeature, theAttribute,
                                 aPoint->x(), aPoint->y());
 }
 
@@ -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 ac90ea98a02730215a7fc137396dd72d61729d9a..c32b3af077ecd2e5fbbabdcc27256bee8fcfce94 100644 (file)
@@ -140,7 +140,7 @@ public slots:
   /// Slot which reacts to the point 2d set to the feature. Creates a constraint
   /// \param the feature
   /// \param the attribute of the feature
-  void onStorePoint2D(FeaturePtr theFeature, const std::string& theAttribute);
+  void onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute);
 
 protected:
   /// Creates a new operation
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 adf7b27481b978ee2bf0799d1970bcb80d068e33..99f8b066da82feb19b8ebb00cb198f87658d4ca4 100644 (file)
@@ -94,8 +94,8 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
 
       ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
       if (aPointWidget)
-        connect(aPointWidget, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
-                this, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)));
+        connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
+                this, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)));
     }
     ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
     if (aLastWidget) {
index 74c3c5fba03fbd2186504843b60f7249686b2ee1..22853105352ca4edcc3ba6be5495d52105091c04 100644 (file)
@@ -52,7 +52,7 @@ signals:
   /// Signal about the point 2d set to the feature
   /// \param the feature
   /// \param the attribute of the feature
-  void storedPoint2D(FeaturePtr theFeature, const std::string& theAttribute);
+  void storedPoint2D(ObjectPtr theFeature, const std::string& theAttribute);
 
 private:
   QWidget* myCustomWidget;
index 419cfc532d367f2fcedc7230c564a592c49a687e..27eee74701d21f716bc7f1b6a43ba4059287590f 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();
@@ -467,7 +469,8 @@ void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
     aCommand = aMenu->feature(theOperation->getDescription()->operationId());
   }
   //Abort operation on uncheck the command
-  connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
+  if (aCommand)
+    connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
 }
 
 /*
@@ -767,7 +770,7 @@ QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
   aObjDock->setWindowTitle(tr("Object browser"));
   aObjDock->setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
   myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
-  connect(myObjectBrowser, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(changeCurrentDocument(FeaturePtr)));
+  connect(myObjectBrowser, SIGNAL(activePartChanged(ObjectPtr)), this, SLOT(changeCurrentDocument(ObjectPtr)));
   aObjDock->setWidget(myObjectBrowser);
 
   myContextMenuMgr->connectObjectBrowser();
@@ -999,3 +1002,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();