Salome HOME
Merge branch 'master' into Dev_1.1.0
authorsbh <sergey.belash@opencascade.com>
Thu, 26 Mar 2015 09:55:05 +0000 (12:55 +0300)
committersbh <sergey.belash@opencascade.com>
Thu, 26 Mar 2015 09:55:05 +0000 (12:55 +0300)
Conflicts:
CMakeLists.txt
src/Config/Config_FeatureReader.cpp
src/Config/Config_FeatureReader.h
src/ConstructionPlugin/ConstructionPlugin_Axis.cpp
src/ConstructionPlugin/ConstructionPlugin_Plane.cpp
src/ConstructionPlugin/ConstructionPlugin_Point.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/FeaturesPlugin/Test/TestMultiBoolean.py
src/Model/Model_AttributeSelection.cpp
src/Model/Model_Update.cpp
src/ModelAPI/ModelAPI_RefAttrValidator.h
src/ModelAPI/ModelAPI_ShapeValidator.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h
src/PartSet/PartSet_WidgetShapeSelector.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/SketchPlugin_Validators.h
src/SketchPlugin/plugin-Sketch.xml

140 files changed:
CMakeLists.txt
doc/CMakeLists.txt
doc/doxyfile.in
doc/first_feature_help.doc
src/Config/CMakeLists.txt
src/Config/Config_FeatureReader.cpp
src/Config/Config_FeatureReader.h
src/Config/Config_ModuleReader.cpp
src/Config/Config_ModuleReader.h
src/Config/Config_ValidatorReader.cpp [new file with mode: 0644]
src/Config/Config_ValidatorReader.h [new file with mode: 0644]
src/Config/Config_WidgetReader.cpp
src/Config/Config_XMLReader.cpp
src/Config/Config_XMLReader.h
src/Config/plugins.xml
src/ConstructionPlugin/ConstructionPlugin_Axis.cpp
src/ConstructionPlugin/ConstructionPlugin_Plane.cpp
src/ConstructionPlugin/ConstructionPlugin_Point.cpp
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Group.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/FeaturesPlugin/Test/TestBoolean.py
src/FeaturesPlugin/Test/TestExtrusion.py
src/FeaturesPlugin/Test/TestGroup.py
src/FeaturesPlugin/Test/TestMultiBoolean.py
src/GeomAPI/GeomAPI.i
src/GeomAlgoAPI/GeomAlgoAPI.i
src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h
src/GeomData/CMakeLists.txt
src/GeomDataAPI/CMakeLists.txt
src/GeomDataAPI/GeomDataAPI.i
src/GeomDataAPI/GeomDataAPI_Dir.cpp [new file with mode: 0644]
src/GeomDataAPI/GeomDataAPI_Dir.h
src/GeomDataAPI/GeomDataAPI_Point.cpp [new file with mode: 0644]
src/GeomDataAPI/GeomDataAPI_Point.h
src/GeomDataAPI/GeomDataAPI_Point2D.cpp [new file with mode: 0644]
src/GeomDataAPI/GeomDataAPI_Point2D.h
src/GeomDataAPI/Test/TestConstants.py
src/GeomValidators/GeomValidators_EdgeOrVertex.cpp
src/GeomValidators/GeomValidators_Tools.cpp
src/Model/Model_AttributeSelection.cpp
src/Model/Model_Data.cpp
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultConstruction.cpp
src/Model/Model_ResultGroup.cpp
src/Model/Model_ResultPart.cpp
src/Model/Model_Session.cpp
src/Model/Model_Update.cpp
src/Model/Model_Update.h
src/ModelAPI/ModelAPI.i
src/ModelAPI/ModelAPI_AttributeBoolean.cpp
src/ModelAPI/ModelAPI_AttributeBoolean.h
src/ModelAPI/ModelAPI_AttributeDocRef.cpp
src/ModelAPI/ModelAPI_AttributeDocRef.h
src/ModelAPI/ModelAPI_AttributeDouble.cpp
src/ModelAPI/ModelAPI_AttributeDouble.h
src/ModelAPI/ModelAPI_AttributeIntArray.cpp
src/ModelAPI/ModelAPI_AttributeIntArray.h
src/ModelAPI/ModelAPI_AttributeInteger.cpp
src/ModelAPI/ModelAPI_AttributeInteger.h
src/ModelAPI/ModelAPI_AttributeRefAttr.cpp
src/ModelAPI/ModelAPI_AttributeRefAttr.h
src/ModelAPI/ModelAPI_AttributeRefList.cpp
src/ModelAPI/ModelAPI_AttributeRefList.h
src/ModelAPI/ModelAPI_AttributeReference.cpp
src/ModelAPI/ModelAPI_AttributeReference.h
src/ModelAPI/ModelAPI_AttributeSelection.cpp
src/ModelAPI/ModelAPI_AttributeSelection.h
src/ModelAPI/ModelAPI_AttributeSelectionList.cpp
src/ModelAPI/ModelAPI_AttributeSelectionList.h
src/ModelAPI/ModelAPI_AttributeString.cpp
src/ModelAPI/ModelAPI_AttributeString.h
src/ModelAPI/ModelAPI_Feature.cpp
src/ModelAPI/ModelAPI_ShapeValidator.cpp
src/ModelAPI/Test/TestConstants.py
src/ModuleBase/ModuleBase_FilterNoConsructionSubShapes.cpp
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/NewGeom/resources/LightApp.xml
src/NewGeom/resources/SalomeApp.xml
src/ParametersPlugin/ParametersPlugin_Parameter.cpp
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h
src/PartSet/PartSet_WidgetShapeSelector.cpp
src/PythonFeaturesPlugin/CMakeLists.txt [new file with mode: 0644]
src/PythonFeaturesPlugin/FeaturesAPI.py [new file with mode: 0644]
src/PythonFeaturesPlugin/PythonFeaturesPlugin.py [new file with mode: 0644]
src/PythonFeaturesPlugin/PythonFeaturesPlugin_Box.py [new file with mode: 0644]
src/PythonFeaturesPlugin/SketchResult.py [new file with mode: 0644]
src/PythonFeaturesPlugin/box_widget.xml [new file with mode: 0644]
src/PythonFeaturesPlugin/examples.py [new file with mode: 0644]
src/PythonFeaturesPlugin/extrusion.py [new file with mode: 0644]
src/PythonFeaturesPlugin/plugin-PythonFeatures.xml [new file with mode: 0644]
src/PythonFeaturesPlugin/sketch.py [new file with mode: 0644]
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintEqual.cpp
src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp
src/SketchPlugin/SketchPlugin_ConstraintHorizontal.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp
src/SketchPlugin/SketchPlugin_ConstraintTangent.cpp
src/SketchPlugin/SketchPlugin_ConstraintVertical.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_SketchEntity.cpp
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/SketchPlugin_Validators.h
src/SketchPlugin/Test/TestConstraintConcidence.py
src/SketchPlugin/Test/TestConstraintDistance.py
src/SketchPlugin/Test/TestConstraintEqual.py
src/SketchPlugin/Test/TestConstraintHorizontal.py
src/SketchPlugin/Test/TestConstraintLength.py
src/SketchPlugin/Test/TestConstraintMirror.py
src/SketchPlugin/Test/TestConstraintParallel.py
src/SketchPlugin/Test/TestConstraintPerpendicular.py
src/SketchPlugin/Test/TestConstraintRadius.py
src/SketchPlugin/Test/TestConstraintRigid.py
src/SketchPlugin/Test/TestConstraintTangent.py
src/SketchPlugin/Test/TestConstraintVertical.py
src/SketchPlugin/Test/TestHighload.py
src/SketchPlugin/Test/TestSketchArcCircle.py
src/SketchPlugin/Test/TestSketchPointLine.py
src/SketchPlugin/Test/TestSnowflake.py
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_ConstraintGroup.cpp

index bb42d8b4a6480861724889642a7b0d689e5dc0af..0cf7163c24bdc1fd8fef768eb1a502ecb4bc26cd 100644 (file)
@@ -55,6 +55,7 @@ ADD_SUBDIRECTORY (src/PartSetPlugin)
 ADD_SUBDIRECTORY (src/ConstructionPlugin)
 ADD_SUBDIRECTORY (src/FeaturesPlugin)
 ADD_SUBDIRECTORY (src/SketcherPrs)
+ADD_SUBDIRECTORY (src/PythonFeaturesPlugin)
 ADD_SUBDIRECTORY (src/SketchPlugin)
 ADD_SUBDIRECTORY (src/SketchSolver)
 ADD_SUBDIRECTORY (src/ModuleBase)
index c5d19b119c579d60ca232d9a2a2fb57574dea18e..42d0e9fff1d2c5ff882cce8b5045599e0f1ed5d2 100644 (file)
@@ -6,6 +6,12 @@ ELSE (WIN32)
   FIND_PROGRAM(DOXYGEN_EXECUTABLE doxygen)
 ENDIF(WIN32)
 
+IF(HAVE_SALOME)
+  SET(EXCLUDE_DOC_DIR "*/AppElements/*")
+ELSE(HAVE_SALOME)
+  SET(EXCLUDE_DOC_DIR "*/NewGeom/*")
+ENDIF(HAVE_SALOME)
+
 CONFIGURE_FILE(doxyfile.in
                "${CMAKE_CURRENT_BINARY_DIR}/doxyfile"
                IMMEDIATE @ONLY)
index 5f96a4dc137b297e5da641079926573648c65cc8..46e837496f2209c3bae1b2d9096c6a6c0fa47163 100644 (file)
@@ -720,8 +720,9 @@ EXCLUDE_SYMLINKS       = NO
 # against the file with absolute path, so to exclude all test directories
 # for example use the pattern */test/*
 
-EXCLUDE_PATTERNS       = */Test/*.py
-# (Python unit tests excluded)
+# Python unit tests excluded
+EXCLUDE_PATTERNS       = */Test/*.py \
+                         @EXCLUDE_DOC_DIR@
 
 # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
 # (namespaces, classes, functions, etc.) that should be excluded from the
index c40f79d60385df593ee133385c53e9990e4c3aca..fc7f1f9ebaecfdac6ef9144b02b4b1f68521c073 100644 (file)
@@ -118,13 +118,13 @@ And like a plugin implements a functionality to create 'feature' objects by stri
 \code
 void ConstructionPlugin_Point::initAttributes()
 {
-  data()->addAttribute("DoubleCounterData", ModelAPI_AttributeDouble::type());
+  data()->addAttribute("DoubleCounterData", ModelAPI_AttributeDouble::typeId());
 }
 \endcode
 Python:
 \code
   def initAttributes(self):
-    self.data().addAttribute("DoubleCounterData", ModelAPI.ModelAPI_AttributeDouble.type())
+    self.data().addAttribute("DoubleCounterData", ModelAPI.ModelAPI_AttributeDouble.typeId())
 \endcode
 As you may notice, this method defines that feature has a widget with "DoubleCounterData" id, which has Double type. Therefore, if your feature uses, in example, three widgets, the `initAttributes()` method should 'init' three attributes.
 \n
index c5ee88f7817fc6702c22500e4096b4b5c1a0e977..591c8489afc4d829063bf3c1d5388dd34b1496a1 100644 (file)
@@ -22,6 +22,7 @@ SET(PROJECT_HEADERS
   Config_PropManager.h
   Config_AttributeMessage.h
   Config_SelectionFilterMessage.h
+  Config_ValidatorReader.h
  )
  
 SET(PROJECT_SOURCES
@@ -38,6 +39,7 @@ SET(PROJECT_SOURCES
   Config_PropManager.cpp
   Config_AttributeMessage.cpp
   Config_SelectionFilterMessage.cpp
+  Config_ValidatorReader.cpp
 )
 
 SET(XML_RESOURCES
index dea07dfc7420203fffaa8da699e8ddd36fc3220d..2b024061a5335aa2ee405d36c6ddaca7726516e1 100644 (file)
@@ -89,7 +89,7 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode)
       storeAttribute(theNode, _ID); // save case:caseId (or box:boxId)
     }
   }
-  //Process SOURCE, VALIDATOR nodes.
+  //Process SOURCE nodes.
   Config_XMLReader::processNode(theNode);
 }
 
@@ -139,49 +139,3 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theFeatureNode,
   }
   outFeatureMessage->setDocumentKind(aDocKind);
 }
-
-void Config_FeatureReader::storeAttribute(xmlNodePtr theNode,
-                                          const char* theNodeAttribute)
-{
-  std::string aKey = getNodeName(theNode) + ":" + std::string(theNodeAttribute);
-  std::string aValue = getProperty(theNode, theNodeAttribute);
-  if(!aValue.empty()) {
-    myParentAttributes[aKey] = aValue;
-  }
-}
-
-std::string Config_FeatureReader::restoreAttribute(xmlNodePtr theNode,
-                                                   const char* theNodeAttribute)
-{
-  return restoreAttribute(getNodeName(theNode).c_str(), theNodeAttribute);
-}
-std::string Config_FeatureReader::restoreAttribute(const char* theNodeName,
-                                                   const char* theNodeAttribute)
-{
-  std::string aKey = std::string(theNodeName) + ":" + std::string(theNodeAttribute);
-  std::string result = "";
-  if(myParentAttributes.find(aKey) != myParentAttributes.end()) {
-    result = myParentAttributes[aKey];
-  }
-  return result;
-}
-
-bool Config_FeatureReader::cleanupAttribute(xmlNodePtr theNode,
-                                            const char* theNodeAttribute)
-{
-  return cleanupAttribute(getNodeName(theNode).c_str(), theNodeAttribute);
-}
-
-bool Config_FeatureReader::cleanupAttribute(const char* theNodeName,
-                                            const char* theNodeAttribute)
-{
-  std::string aKey = std::string(theNodeName) + ":" + std::string(theNodeAttribute);
-  bool result = false;
-  std::map<std::string, std::string>::iterator anEntry = myParentAttributes.find(aKey);
-  if( anEntry != myParentAttributes.end()) {
-    myParentAttributes.erase(anEntry);
-    result = true;
-  }
-  return result;
-}
-
index 75eb376e5cdd88ba8a6249a863e522e7ec1c3163..a0952ec1b69afacf95a44f43140848447b084bef 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <string>
 #include <list>
-#include <map>
 
 class Config_FeatureMessage;
 
@@ -50,21 +49,7 @@ class Config_FeatureReader : public Config_XMLReader
   void fillFeature(xmlNodePtr theRoot, 
                    const std::shared_ptr<Config_FeatureMessage>& outFeatureMessage);
 
-  /// Stores an attribute in internal map for later use.
-  /// Key is "Node_Name:Node_Attribute" and value is getProperty(theNodeAttribute)
-  void storeAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
-  /// Restores an attribute from internal map.
-  std::string restoreAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
-  /// Restores an attribute from internal map.
-  std::string restoreAttribute(const char* theNodeName, const char* theNodeAttribute);
-
-  bool cleanupAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
-  bool cleanupAttribute(const char* theNodeName, const char* theNodeAttribute);
-
  private:
-  /// A map to store all parent's attributes.
-  /// The key has from "Node_Name:Node_Attribute"
-  std::map<std::string, std::string> myParentAttributes;
   std::string myLibraryName;
 
   std::list<std::string> myFeatures;
index 2dfd4c135395f8d83c0d82860dae44179e7a9a73..ff9ba1f4d61decdce2c94f4aaf72d421baa4948d 100644 (file)
@@ -48,6 +48,11 @@ const std::map<std::string, std::string>& Config_ModuleReader::featuresInFiles()
   return myFeaturesInFiles;
 }
 
+const std::set<std::string>& Config_ModuleReader::modulePluginFiles() const
+{
+  return myPluginFiles;
+}
+
 /*!
  * Get module name from plugins.xml
  * (property "module")
@@ -64,6 +69,7 @@ void Config_ModuleReader::processNode(xmlNodePtr theNode)
     if (!hasRequiredModules(theNode))
       return;
     std::string aPluginConf = getProperty(theNode, PLUGIN_CONFIG);
+    if (!aPluginConf.empty()) myPluginFiles.insert(aPluginConf);
     std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY);
     std::string aPluginScript = getProperty(theNode, PLUGIN_SCRIPT);
     std::string aPluginName = addPlugin(aPluginLibrary, aPluginScript, aPluginConf);
index a6f8c1e2d4215565dc67b3e9afc059e1a5377e32..bef9c61246a6c149cce31154c9c9dc5eb1d2d5a1 100644 (file)
@@ -38,6 +38,8 @@ class Config_ModuleReader : public Config_XMLReader
   CONFIG_EXPORT virtual ~Config_ModuleReader();
   /// Returns map that describes which file contains a feature (the feature is key, the file is value)
   CONFIG_EXPORT const std::map<std::string, std::string>& featuresInFiles() const;
+  /// Returns list of module's xml files
+  CONFIG_EXPORT const std::set<std::string>& modulePluginFiles() const;
   /// Returns module name: an xml attribute from the root of the plugins.xml:
   /// e.g \code <plugins module="PartSet"> \endcode 
   CONFIG_EXPORT std::string getModuleName();
@@ -70,6 +72,7 @@ class Config_ModuleReader : public Config_XMLReader
 
  private:
   std::map<std::string, std::string> myFeaturesInFiles; ///< a feature name is key, a file is value
+  std::set<std::string> myPluginFiles; ///< a feature name is key, a file is value
   static std::map<std::string, PluginType> myPluginTypes; ///< a plugin name is key, a plugin type is value
   static std::set<std::string> myDependencyModules; ///< set of loaded modules
   const char* myEventGenerated; ///< gives ability to send Feature_Messages to various listeners
diff --git a/src/Config/Config_ValidatorReader.cpp b/src/Config/Config_ValidatorReader.cpp
new file mode 100644 (file)
index 0000000..d03dff5
--- /dev/null
@@ -0,0 +1,98 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+/*
+ * Config_ValidatorReader.cpp
+ *
+ *  Created on: Mar 20, 2015
+ *      Author: sbh
+ */
+
+#include <Config_ValidatorReader.h>
+#include <Config_Keywords.h>
+#include <Config_Common.h>
+#include <Config_ValidatorMessage.h>
+#include <Config_SelectionFilterMessage.h>
+#include <Config_PropManager.h>
+
+#include <Events_Loop.h>
+#include <Events_Error.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+#include <fstream>
+
+#ifdef _DEBUG
+#include <iostream>
+#endif
+
+Config_ValidatorReader::Config_ValidatorReader(const std::string& theXmlFileName)
+: Config_XMLReader(theXmlFileName)
+{
+}
+
+Config_ValidatorReader::~Config_ValidatorReader()
+{
+}
+
+void Config_ValidatorReader::processNode(xmlNodePtr theNode)
+{
+  if (isNode(theNode, NODE_VALIDATOR, NULL)) {
+    processValidator(theNode);
+  } else if (isNode(theNode, NODE_SELFILTER, NULL)) {
+    processSelectionFilter(theNode);
+  } else if (isNode(theNode, NODE_FEATURE, NULL)) {
+    storeAttribute(theNode, _ID);
+  }
+  //Process SOURCE nodes.
+  Config_XMLReader::processNode(theNode);
+}
+
+bool Config_ValidatorReader::processChildren(xmlNodePtr aNode)
+{
+  return true;
+}
+
+void Config_ValidatorReader::processValidator(xmlNodePtr theNode)
+{
+  Events_ID aValidatoEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED);
+  Events_Loop* aEvLoop = Events_Loop::loop();
+  std::shared_ptr<Config_ValidatorMessage> 
+    aMessage(new Config_ValidatorMessage(aValidatoEvent, this));
+  std::string aValidatorId;
+  std::list<std::string> aParameters;
+  getParametersInfo(theNode, aValidatorId, aParameters);
+  aMessage->setValidatorId(aValidatorId);
+  aMessage->setValidatorParameters(aParameters);
+  //TODO(sbh): update feature/attribute id restoring
+  // when "cleanup" technique will be available (v. >= 1.1.0)
+  xmlNodePtr aFeatureOrWdgNode = theNode->parent;
+  if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
+    aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
+  } else {
+    aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
+    aMessage->setFeatureId(restoreAttribute(NODE_FEATURE, _ID));
+  }
+  aEvLoop->send(aMessage);
+}
+
+void Config_ValidatorReader::processSelectionFilter(xmlNodePtr theNode)
+{
+  Events_ID aFilterEvent = Events_Loop::eventByName(EVENT_SELFILTER_LOADED);
+  Events_Loop* aEvLoop = Events_Loop::loop();
+  std::shared_ptr<Config_SelectionFilterMessage> aMessage =
+      std::make_shared<Config_SelectionFilterMessage>(aFilterEvent, this);
+  std::string aSelectionFilterId;
+  std::list<std::string> aParameters;
+  getParametersInfo(theNode, aSelectionFilterId, aParameters);
+  aMessage->setSelectionFilterId(aSelectionFilterId);
+  aMessage->setFilterParameters(aParameters);
+
+  xmlNodePtr aFeatureOrWdgNode = theNode->parent;
+  if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
+    aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
+  } else {
+    aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
+    aMessage->setFeatureId(restoreAttribute(NODE_FEATURE, _ID));
+  }
+  aEvLoop->send(aMessage);
+}
diff --git a/src/Config/Config_ValidatorReader.h b/src/Config/Config_ValidatorReader.h
new file mode 100644 (file)
index 0000000..f2ac629
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+/*
+ * Config_ValidatorReader.h
+ *
+ *  Created on: Mar 20, 2015
+ *      Author: sbh
+ */
+
+#ifndef CONFIG_VALIDATORREADER_H_
+#define CONFIG_VALIDATORREADER_H_
+
+#include <Config_def.h>
+#include <Config_XMLReader.h>
+
+#include <cstdarg>
+#include <string>
+
+/*!
+ * \class Config_ValidatorReader
+ * \ingroup Config
+ * \brief Base class for all libxml readers. Provides high-level API
+ * for all xml operations.
+*/
+class Config_ValidatorReader : public Config_XMLReader
+{
+ public:
+  /*!
+   * Constructor
+   * \param theXmlFile - full path to the xml file which will be processed by the reader
+   */
+  CONFIG_EXPORT Config_ValidatorReader(const std::string& theXmlFile);
+  CONFIG_EXPORT virtual ~Config_ValidatorReader();
+
+ protected:
+  /*!
+   * \brief Allows to customize reader's behavior for a node. Virtual.
+   * The default implementation process "source", "validator" and
+   * "selection_filter" nodes.
+   */
+  virtual void processNode(xmlNodePtr aNode);
+  /*!
+   * \brief Defines which nodes should be processed recursively. Virtual.
+   * The default impl is to read all nodes.
+   */
+  virtual bool processChildren(xmlNodePtr aNode);
+
+  /*!
+   * \brief Retrieves all the necessary info from the validator node.
+   * Sends ValidatorLoaded event
+   */
+  void processValidator(xmlNodePtr theNode);
+  /*!
+   * \brief Retrieves all the necessary info from the SelectionFilter node.
+   * Sends SelectionFilterLoaded event
+   */
+  void processSelectionFilter(xmlNodePtr theNode);
+};
+
+#endif /* CONFIG_VALIDATORREADER_H_ */
index c8ea412d88f56bf539534ffa743644c20b931b02..25d1fdc65c090722c4dddf32bf36ad88068f4cd3 100644 (file)
@@ -45,9 +45,9 @@ std::string Config_WidgetReader::featureDescription(const std::string& theFeatur
 void Config_WidgetReader::processNode(xmlNodePtr theNode)
 {
   if (isNode(theNode, NODE_FEATURE, NULL)) {
-    myCurrentFeature = getProperty(theNode, _ID);
-    myWidgetCache[myCurrentFeature] = dumpNode(theNode);
-    myDescriptionCache[myCurrentFeature] = getProperty(theNode, FEATURE_TEXT);
+    std::string aFeature = getProperty(theNode, _ID);
+    myWidgetCache[aFeature] = dumpNode(theNode);
+    myDescriptionCache[aFeature] = getProperty(theNode, FEATURE_TEXT);
   }
   //Process SOURCE nodes.
   Config_XMLReader::processNode(theNode);
index 768232b7457e05006f7e9b44caf1ba726fb124bd..c0a0a2ee0a0e4beac70cd5f8fec2f7ea4d2e8004 100644 (file)
@@ -10,8 +10,6 @@
 #include <Config_XMLReader.h>
 #include <Config_Keywords.h>
 #include <Config_Common.h>
-#include <Config_ValidatorMessage.h>
-#include <Config_SelectionFilterMessage.h>
 #include <Config_PropManager.h>
 
 #include <Events_Loop.h>
@@ -77,12 +75,8 @@ void Config_XMLReader::processNode(xmlNodePtr theNode)
     Config_XMLReader aSourceReader = Config_XMLReader(aSourceFile);
     readRecursively(aSourceReader.findRoot());
 #ifdef _DEBUG
-    std::cout << "Config_XMLReader::sourced node: " << aSourceFile << std::endl;
+    //std::cout << "Config_XMLReader::sourced node: " << aSourceFile << std::endl;
 #endif
-  } else if (isNode(theNode, NODE_VALIDATOR, NULL)) {
-    processValidator(theNode);
-  } else if (isNode(theNode, NODE_SELFILTER, NULL)) {
-    processSelectionFilter(theNode);
   }
 }
 
@@ -150,45 +144,43 @@ std::string Config_XMLReader::getNodeName(xmlNodePtr theNode)
   return result;
 }
 
-void Config_XMLReader::processValidator(xmlNodePtr theNode)
+void Config_XMLReader::storeAttribute(xmlNodePtr theNode, const char* theAttribute)
 {
-  Events_ID aValidatoEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED);
-  Events_Loop* aEvLoop = Events_Loop::loop();
-  std::shared_ptr<Config_ValidatorMessage> 
-    aMessage(new Config_ValidatorMessage(aValidatoEvent, this));
-  std::string aValidatorId;
-  std::list<std::string> aParameters;
-  getParametersInfo(theNode, aValidatorId, aParameters);
-  aMessage->setValidatorId(aValidatorId);
-  aMessage->setValidatorParameters(aParameters);
-  xmlNodePtr aFeatureOrWdgNode = theNode->parent;
-  if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
-    aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
-  } else {
-    aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
-    aMessage->setFeatureId(myCurrentFeature);
+  std::string aKey = getNodeName(theNode) + ":" + std::string(theAttribute);
+  std::string aValue = getProperty(theNode, theAttribute);
+  if(!aValue.empty()) {
+    myCachedAttributes[aKey] = aValue;
   }
-  aEvLoop->send(aMessage);
 }
 
-void Config_XMLReader::processSelectionFilter(xmlNodePtr theNode)
+std::string Config_XMLReader::restoreAttribute(xmlNodePtr theNode, const char* theAttribute)
 {
-  Events_ID aFilterEvent = Events_Loop::eventByName(EVENT_SELFILTER_LOADED);
-  Events_Loop* aEvLoop = Events_Loop::loop();
-  std::shared_ptr<Config_SelectionFilterMessage> aMessage =
-      std::make_shared<Config_SelectionFilterMessage>(aFilterEvent, this);
-  std::string aSelectionFilterId;
-  std::list<std::string> aParameters;
-  getParametersInfo(theNode, aSelectionFilterId, aParameters);
-  aMessage->setSelectionFilterId(aSelectionFilterId);
-  aMessage->setFilterParameters(aParameters);
-
-  xmlNodePtr aFeatureOrWdgNode = theNode->parent;
-  if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
-    aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
-  } else {
-    aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
-    aMessage->setFeatureId(myCurrentFeature);
+  return restoreAttribute(getNodeName(theNode).c_str(), theAttribute);
+}
+
+std::string Config_XMLReader::restoreAttribute(const char* theNodeName, const char* theAttribute)
+{
+  std::string aKey = std::string(theNodeName) + ":" + std::string(theAttribute);
+  std::string result = "";
+  if(myCachedAttributes.find(aKey) != myCachedAttributes.end()) {
+    result = myCachedAttributes[aKey];
   }
-  aEvLoop->send(aMessage);
+  return result;
+}
+
+bool Config_XMLReader::cleanupAttribute(xmlNodePtr theNode, const char* theNodeAttribute)
+{
+  return cleanupAttribute(getNodeName(theNode).c_str(), theNodeAttribute);
+}
+
+bool Config_XMLReader::cleanupAttribute(const char* theNodeName, const char* theNodeAttribute)
+{
+  std::string aKey = std::string(theNodeName) + ":" + std::string(theNodeAttribute);
+  bool result = false;
+  std::map<std::string, std::string>::iterator anEntry = myCachedAttributes.find(aKey);
+  if( anEntry != myCachedAttributes.end()) {
+    myCachedAttributes.erase(anEntry);
+    result = true;
+  }
+  return result;
 }
index 603ce7d1faea03605dcebf388af0af69105f8bc3..d19bd8467a482517d7602cb4b33e0bc595593ef7 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <cstdarg>
 #include <string>
+#include <map>
 
 //>> Forward declaration of xmlNodePtr.
 typedef struct _xmlNode xmlNode;
@@ -84,21 +85,22 @@ class Config_XMLReader
   xmlNodePtr node(void* theNode);
   /// Gets xml node name
   std::string getNodeName(xmlNodePtr theNode);
-  /*!
-   * \brief Retrieves all the necessary info from the validator node.
-   * Sends ValidatorLoaded event
-   */
-  void processValidator(xmlNodePtr theNode);
-  /*!
-   * \brief Retrieves all the necessary info from the SelectionFilter node.
-   * Sends SelectionFilterLoaded event
-   */
-  void processSelectionFilter(xmlNodePtr theNode);
+  /// Stores an attribute in internal map for later use.
+  /// Key is "Node_Name:Node_Attribute" and value is getProperty(theNodeAttribute)
+  void storeAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+  /// Restores an attribute from internal map.
+  std::string restoreAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+  /// Restores an attribute from internal map.
+  std::string restoreAttribute(const char* theNodeName, const char* theNodeAttribute);
+  bool cleanupAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+  bool cleanupAttribute(const char* theNodeName, const char* theNodeAttribute);
 
  protected:
-  std::string myCurrentFeature; ///< Name of currently processed feature
   std::string myDocumentPath; ///< Path to the xml document
   xmlDocPtr myXmlDoc; ///< Root of the xml document
+  /// A map to store all parent's attributes.
+  /// The key has from "Node_Name:Node_Attribute"
+  std::map<std::string, std::string> myCachedAttributes;
 };
 
 #endif /* CONFIG_XMLREADER_H_ */
index 623b8097394293d4479c6302bf8282185a5b657b..65cdd3beee68d3a7d196b6a5bc1e4c2bed0ab1d1 100644 (file)
@@ -8,6 +8,7 @@
   <plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
   <plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
   <plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
+  <plugin script="PythonFeaturesPlugin" configuration="plugin-PythonFeatures.xml"/>
   <plugin script="ConnectorPlugin" configuration="plugin-Connector.xml" dependency="Geometry"/>
   <plugin library="ParametersPlugin" configuration="plugin-Parameters.xml"/>
   <plugin library="SketchSolver"/>
index 5017f496a97af4842da4c557aa6a65478f362dfa..e3d7eb34c4f58e7f2edf07b540e17386bf62c61a 100644 (file)
@@ -29,13 +29,13 @@ ConstructionPlugin_Axis::ConstructionPlugin_Axis()
 void ConstructionPlugin_Axis::initAttributes()
 {
   data()->addAttribute(ConstructionPlugin_Axis::METHOD(),
-                       ModelAPI_AttributeString::type());
+                       ModelAPI_AttributeString::typeId());
   data()->addAttribute(ConstructionPlugin_Axis::POINT_FIRST(),
-                       ModelAPI_AttributeSelection::type());
+                       ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(ConstructionPlugin_Axis::POINT_SECOND(),
-                       ModelAPI_AttributeSelection::type());
+                       ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(ConstructionPlugin_Axis::CYLINDRICAL_FACE(),
-                       ModelAPI_AttributeSelection::type());
+                       ModelAPI_AttributeSelection::typeId());
 }
 
 void ConstructionPlugin_Axis::createAxisByTwoPoints()
index 7448f5a7e5aa62f5d8bc70b9b403f8593c0fcbdc..c206ff4d55b1a24f7aee3ba87fcf686966f10815 100644 (file)
@@ -23,15 +23,15 @@ ConstructionPlugin_Plane::ConstructionPlugin_Plane()
 
 void ConstructionPlugin_Plane::initAttributes()
 {
-  data()->addAttribute(ConstructionPlugin_Plane::METHOD(), ModelAPI_AttributeString::type());
+  data()->addAttribute(ConstructionPlugin_Plane::METHOD(), ModelAPI_AttributeString::typeId());
   // Face & Distance
-  data()->addAttribute(ConstructionPlugin_Plane::FACE(),  ModelAPI_AttributeSelection::type());
-  data()->addAttribute(ConstructionPlugin_Plane::DISTANCE(), ModelAPI_AttributeDouble::type());
+  data()->addAttribute(ConstructionPlugin_Plane::FACE(),  ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(ConstructionPlugin_Plane::DISTANCE(), ModelAPI_AttributeDouble::typeId());
   // General equation
-  data()->addAttribute(ConstructionPlugin_Plane::A(),  ModelAPI_AttributeDouble::type());
-  data()->addAttribute(ConstructionPlugin_Plane::B(),  ModelAPI_AttributeDouble::type());
-  data()->addAttribute(ConstructionPlugin_Plane::C(),  ModelAPI_AttributeDouble::type());
-  data()->addAttribute(ConstructionPlugin_Plane::D(),  ModelAPI_AttributeDouble::type());
+  data()->addAttribute(ConstructionPlugin_Plane::A(),  ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(ConstructionPlugin_Plane::B(),  ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(ConstructionPlugin_Plane::C(),  ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(ConstructionPlugin_Plane::D(),  ModelAPI_AttributeDouble::typeId());
 }
 
 void ConstructionPlugin_Plane::execute()
index 671a38cd7a1daf72a4d802470e5f3e60d2f02bdd..b31b3b55217d0b0bd94b538207392dc58d90ba14 100644 (file)
@@ -29,9 +29,9 @@ const std::string& ConstructionPlugin_Point::getKind()
 
 void ConstructionPlugin_Point::initAttributes()
 {
-  data()->addAttribute(ConstructionPlugin_Point::X(), ModelAPI_AttributeDouble::type());
-  data()->addAttribute(ConstructionPlugin_Point::Y(), ModelAPI_AttributeDouble::type());
-  data()->addAttribute(ConstructionPlugin_Point::Z(), ModelAPI_AttributeDouble::type());
+  data()->addAttribute(ConstructionPlugin_Point::X(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(ConstructionPlugin_Point::Y(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(ConstructionPlugin_Point::Z(), ModelAPI_AttributeDouble::typeId());
 }
 
 void ConstructionPlugin_Point::execute()
index 7fe93e09022b7b962ade8ce358258507c844bab7..f3f53a273e26fe136ecae73b051a9fdb9531c797 100644 (file)
@@ -54,7 +54,7 @@ const std::string& ExchangePlugin_ImportFeature::getKind()
  */
 void ExchangePlugin_ImportFeature::initAttributes()
 {
-  data()->addAttribute(ExchangePlugin_ImportFeature::FILE_PATH_ID(), ModelAPI_AttributeString::type());
+  data()->addAttribute(ExchangePlugin_ImportFeature::FILE_PATH_ID(), ModelAPI_AttributeString::typeId());
 }
 
 /*
index 779baa1f10ba51e6adf047583888dd1f10919130..2932d5e5cce410fa963f068e5579554a3dcfc13c 100644 (file)
@@ -23,9 +23,9 @@ FeaturesPlugin_Boolean::FeaturesPlugin_Boolean()
 
 void FeaturesPlugin_Boolean::initAttributes()
 {
-  data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::type());
-  data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::type());
-  data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::type());
+  data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::typeId());
+  data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::typeId());
+  data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::typeId());
 }
 
 std::shared_ptr<GeomAPI_Shape> FeaturesPlugin_Boolean::getShape(const std::string& theAttrName)
index 873753a8cf44bca3be2d580c85217b98e77e2478..3d8c5bbc842d2fb14bebc33d78070df9bb22f284 100644 (file)
@@ -30,11 +30,11 @@ void FeaturesPlugin_Extrusion::initAttributes()
 {
   AttributeSelectionListPtr aSelection = 
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
-    FeaturesPlugin_Extrusion::LIST_ID(), ModelAPI_AttributeSelectionList::type()));
+    FeaturesPlugin_Extrusion::LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
   // extrusion works with faces always
   aSelection->setSelectionType("FACE");
-  data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::type());
-  data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::type());
+  data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::typeId());
 }
 
 void FeaturesPlugin_Extrusion::execute()
@@ -158,4 +158,4 @@ void FeaturesPlugin_Extrusion::clearResult()
   std::shared_ptr<GeomAPI_Shape> anEmptyShape(new GeomAPI_Shape);
   aResultBody->store(anEmptyShape);
   setResult(aResultBody);
-}
\ No newline at end of file
+}
index 4708c6fc0f6250ac69e73772326676ae865043b9..98c6266ef83756dc29e10aac3e2b208c5ceebb08 100644 (file)
@@ -22,8 +22,8 @@ FeaturesPlugin_Group::FeaturesPlugin_Group()
 
 void FeaturesPlugin_Group::initAttributes()
 {
-  //data()->addAttribute(FeaturesPlugin_Group::NAME_ID(), ModelAPI_AttributeString::type());
-  data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::type());
+  //data()->addAttribute(FeaturesPlugin_Group::NAME_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
 }
 
 void FeaturesPlugin_Group::execute()
index f97b3248d112e95131995ef81d7cc5a9ec3429bd..3ba02779f5b5a7cdb10b849ae6676bb742986070 100644 (file)
@@ -26,10 +26,10 @@ FeaturesPlugin_Placement::FeaturesPlugin_Placement()
 
 void FeaturesPlugin_Placement::initAttributes()
 {
-  data()->addAttribute(FeaturesPlugin_Placement::BASE_OBJECT_ID(), ModelAPI_AttributeSelection::type());
-  data()->addAttribute(FeaturesPlugin_Placement::ATTRACT_OBJECT_ID(), ModelAPI_AttributeSelection::type());
-  data()->addAttribute(FeaturesPlugin_Placement::REVERSE_ID(), ModelAPI_AttributeBoolean::type());
-  data()->addAttribute(FeaturesPlugin_Placement::CENTERING_ID(), ModelAPI_AttributeBoolean::type());
+  data()->addAttribute(FeaturesPlugin_Placement::BASE_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(FeaturesPlugin_Placement::ATTRACT_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(FeaturesPlugin_Placement::REVERSE_ID(), ModelAPI_AttributeBoolean::typeId());
+  data()->addAttribute(FeaturesPlugin_Placement::CENTERING_ID(), ModelAPI_AttributeBoolean::typeId());
 }
 
 void FeaturesPlugin_Placement::execute()
index 19158fa536e14bdb8302e929e0487d2f91c964d2..d9a33eb1992157320084036eb738329118985273 100644 (file)
@@ -8,9 +8,9 @@
         static const std::string MY_TOOL_ID("tool_object");
         static const std::string MY_TYPE_ID("bool_type");
         
-        data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::type());
-        data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::type());
-        data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::type());
+        data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::typeId());
+        data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::typeId());
+        data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::typeId());
 """
 #=========================================================================
 # Initialization of the test
@@ -32,7 +32,7 @@ aSession.finishOperation()
 # Create a sketch with circle to extrude
 #=========================================================================
 aSession.startOperation()
-aCircleSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+aCircleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
 origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX"))
@@ -51,7 +51,7 @@ aSession.finishOperation()
 # Create a sketch with triangle to extrude
 #=========================================================================
 aSession.startOperation()
-aTriangleSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+aTriangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
 origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX"))
index f24ee3ce6d873b53e9387c34d1e2320083378a48..fd2c2a8faea32cb072d3547b1f4c0161b19bacb8 100644 (file)
@@ -8,9 +8,9 @@
         static const std::string MY_SIZE_ID("extrusion_size");
         static const std::string MY_REVERSE_ID("extrusion_reverse");
           
-        data()->addAttribute(FeaturesPlugin_Extrusion::FACE_ID(), ModelAPI_AttributeSelection::type());
-        data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::type());
-        data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::type());
+        data()->addAttribute(FeaturesPlugin_Extrusion::FACE_ID(), ModelAPI_AttributeSelection::typeId());
+        data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+        data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::typeId());
 """
 #=========================================================================
 # Initialization of the test
@@ -37,7 +37,7 @@ aPart = aPartResult.partDoc()
 # Create a sketch circle to extrude
 #=========================================================================
 aSession.startOperation()
-aSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
index 9692c2cddf3845eb1eb249ec4fc891a841e56c84..41f6a6cc0fe5b1301e3c3af838aaaa14b15cd439 100644 (file)
@@ -6,7 +6,7 @@
         static const std::string MY_GROUP_ID("Group");
         static const std::string MY_GROUP_LIST_ID("group_list");
         
-        data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::type());
+        data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
 """
 #=========================================================================
 # Initialization of the test
@@ -28,7 +28,7 @@ aPart = aSession.activeDocument()
 # Create a sketch with triangle and extrude it
 #=========================================================================
 aSession.startOperation()
-aTriangleSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+aTriangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
 origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX"))
index 594c3af72a88068cb7c417781e5a794c26a0fdfd..953ffc4ee0c3e4d15bb0b8f8d7afaa0c135412d0 100644 (file)
@@ -8,9 +8,9 @@
         static const std::string MY_SIZE_ID("size");
         static const std::string MY_REVERSE_ID("reverse");
           
-        data()->addAttribute(FeaturesPlugin_Extrusion::FACE_ID(), ModelAPI_AttributeSelection::type());
-        data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::type());
-        data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::type());
+        data()->addAttribute(FeaturesPlugin_Extrusion::FACE_ID(), ModelAPI_AttributeSelection::typeId());
+        data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+        data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::typeId());
 """
 
 # Number rows and columns of cylinders that cuts the big box. Number of Boolena operations is N*N
@@ -19,12 +19,13 @@ N = 5
 #=========================================================================
 # Initialization of the test
 #=========================================================================
-from ModelAPI import *
-from GeomDataAPI import *
-from GeomAlgoAPI import *
 from GeomAPI import *
+from GeomAlgoAPI import *
+from GeomDataAPI import *
+from ModelAPI import *
 
-__updated__ = "2015-02-25"
+
+__updated__ = "2015-03-26"
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -47,23 +48,23 @@ radius = 95. / N / 2.
 aSession.startOperation()
 aSketchFeatures = []
 for i in xrange(0, N):
-  for j in xrange(0, N):
-    # Create circle
-    aSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
-    origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
-    origin.setValue(0, 0, 0)
-    dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
-    dirx.setValue(1, 0, 0)
-    diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-    diry.setValue(0, 1, 0)
-    norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
-    norm.setValue(0, 0, 1)
-    aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-    anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-    aCircleRadius = aSketchCircle.real("CircleRadius")
-    anCircleCentr.setValue(0.5 + step * (0.5 + i), 0.5 + step * (0.5 + j))
-    aCircleRadius.setValue(radius)
-    aSketchFeatures.append(aSketchFeature)
+    for j in xrange(0, N):
+        # Create circle
+        aSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+        origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+        origin.setValue(0, 0, 0)
+        dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+        dirx.setValue(1, 0, 0)
+        diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
+        diry.setValue(0, 1, 0)
+        norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+        norm.setValue(0, 0, 1)
+        aSketchCircle = aSketchFeature.addFeature("SketchCircle")
+        anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+        aCircleRadius = aSketchCircle.real("CircleRadius")
+        anCircleCentr.setValue(0.5 + step * (0.5 + i), 0.5 + step * (0.5 + j))
+        aCircleRadius.setValue(radius)
+        aSketchFeatures.append(aSketchFeature)
 
 aSession.finishOperation()
 
@@ -77,24 +78,29 @@ aSession.startOperation()
 
 anExtrusions = []
 for i in xrange(0, N * N):
-  aSketchResult = aSketchFeatures[i].firstResult()
-  aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
-  origin = geomDataAPI_Point(aSketchFeatures[i].attribute("Origin")).pnt()
-  dirX = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirX")).dir()
-  dirY = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirY")).dir()
-  norm = geomDataAPI_Dir(aSketchFeatures[i].attribute("Norm")).dir()
-  aSketchFaces = ShapeList()
-  GeomAlgoAPI_SketchBuilder.createFaces(
-      origin, dirX, dirY, norm, aSketchEdges, aSketchFaces)
-
-  anExtrusionFt = aPart.addFeature("Extrusion")
-  assert (anExtrusionFt.getKind() == "Extrusion")
-
-  anExtrusionFt.selectionList("base").append(
-      aSketchResult, aSketchFaces[0])
-  anExtrusionFt.real("size").setValue(10)
-  anExtrusionFt.boolean("reverse").setValue(False)
-  anExtrusions.append(anExtrusionFt)
+    aSketchResult = aSketchFeatures[i].firstResult()
+    aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
+    origin = geomDataAPI_Point(aSketchFeatures[i].attribute("Origin")).pnt()
+    dirX = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirX")).dir()
+    dirY = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirY")).dir()
+    norm = geomDataAPI_Dir(aSketchFeatures[i].attribute("Norm")).dir()
+    aSketchFaces = ShapeList()
+    GeomAlgoAPI_SketchBuilder.createFaces(
+        origin, dirX, dirY, norm, aSketchEdges, aSketchFaces)
+
+    anExtrusionFt = aPart.addFeature("Extrusion")
+    assert (anExtrusionFt.getKind() == "Extrusion")
+
+    anExtrusionFt.selectionList("base").append(
+        aSketchResult, aSketchFaces[0])
+    anExtrusionFt.real("size").setValue(10)
+    anExtrusionFt.boolean("reverse").setValue(False)
+    # v1.0.2 from master
+    # anExtrusionFt.selection("extrusion_face").setValue(
+    #    aSketchResult, aSketchFaces[0])
+    # anExtrusionFt.real("extrusion_size").setValue(10)
+    # anExtrusionFt.boolean("extrusion_reverse").setValue(False)
+    anExtrusions.append(anExtrusionFt)
 
 aSession.finishOperation()
 
@@ -153,23 +159,29 @@ aBox.selectionList("base").append(
     aSketchResult, aSketchFaces[0])
 aBox.real("size").setValue(10)
 aBox.boolean("reverse").setValue(False)
+# v 1.0.2 from master
+# aBox.selection("extrusion_face").setValue(
+#     aSketchResult, aSketchFaces[0])
+# aBox.real("extrusion_size").setValue(10)
+# aBox.boolean("extrusion_reverse").setValue(False)
+
 aSession.finishOperation()
 
 
 #=========================================================================
-# Create a boolean cut of cylinders from the box: 
+# Create a boolean cut of cylinders from the box:
 # result of Boolean is the first argument of the next Boolean
 #=========================================================================
 aCurrentResult = aBox.firstResult()
 aSession.startOperation()
 for i in xrange(0, N * N):
-  aBooleanFt = aPart.addFeature("Boolean")
-  aBooleanFt.reference("main_object").setValue(modelAPI_ResultBody(aCurrentResult))
-  aBooleanFt.reference("tool_object").setValue(modelAPI_ResultBody(anExtrusions[i].firstResult()))
-  kBooleanTypeCut = 0
-  aBooleanFt.integer("bool_type").setValue(kBooleanTypeCut)
-  aBooleanFt.execute()
-  aCurrentResult = aBooleanFt.firstResult()
+    aBooleanFt = aPart.addFeature("Boolean")
+    aBooleanFt.reference("main_object").setValue(modelAPI_ResultBody(aCurrentResult))
+    aBooleanFt.reference("tool_object").setValue(modelAPI_ResultBody(anExtrusions[i].firstResult()))
+    kBooleanTypeCut = 0
+    aBooleanFt.integer("bool_type").setValue(kBooleanTypeCut)
+    aBooleanFt.execute()
+    aCurrentResult = aBooleanFt.firstResult()
 aSession.finishOperation()
 
 #=========================================================================
index 99ff18f0231f723c38e3e43f3df16ce8dda1a5ee..25c752b6135b5b2e1390d9869bb012e0abdfc052 100644 (file)
@@ -21,6 +21,9 @@
   #include "GeomAPI_Pnt.h"
   #include "GeomAPI_XY.h"
   #include "GeomAPI_XYZ.h"
+
+  #include <memory>
+  #include <string>
 %}
 
 // to avoid error on this
index 4a1b94eda26a22cb49054ef3f7cca3807457a491..18d82cbcf25771b9270fbd65d9183f49b08ff4bc 100644 (file)
   #include "GeomAlgoAPI_MakeShape.h"
   #include "GeomAlgoAPI_PointBuilder.h"
   #include "GeomAlgoAPI_SketchBuilder.h"
+
+  #include <memory>
+  #include <string>
+  #include <list>
 %}
 
 // to avoid error on this
index a8a5659de8ea2470759c9cd481f87936663de983..9ca251863ef5a812ecc7479b340f8b5820424b52 100644 (file)
@@ -8,9 +8,12 @@
 #define GeomAlgoAPI_Boolean_H_
 
 #include <GeomAlgoAPI.h>
-#include <GeomAPI_Shape.h>
 #include <GeomAlgoAPI_MakeShape.h>
+
+#include <GeomAPI_Shape.h>
+#include <GeomAPI_Interface.h>
 #include <GeomAPI_DataMapOfShapeShape.h>
+
 #include <memory>
 
 /**\class GeomAlgoAPI_Boolean
index 0469a36ea768c12b201f73fdca3a005f11a7d5e3..16a1329d7382314c2ada67edeff0597589ef648c 100644 (file)
@@ -16,6 +16,7 @@ SET(PROJECT_SOURCES
 )
 
 SET(PROJECT_LIBRARIES
+    GeomDataAPI
     ModelAPI 
     GeomAPI 
     Events
index 1f8880b751c479b752b6b736ba1eb38b3b90869f..8747e7eab30f15d1ab82f308b7a28f1468728ee2 100644 (file)
@@ -12,21 +12,36 @@ SET(PROJECT_HEADERS
     GeomDataAPI_Point2D.h
 )
 
-SET(CMAKE_SWIG_FLAGS "-Wall")
+SET(PROJECT_SOURCES
+    GeomDataAPI_Point.cpp
+    GeomDataAPI_Dir.cpp
+    GeomDataAPI_Point2D.cpp
+)
 
-SET_SOURCE_FILES_PROPERTIES(GeomDataAPI.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(GeomDataAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+SET(PROJECT_LIBRARIES
+    ModelAPI
+)
 
-INCLUDE_DIRECTORIES(
+INCLUDE_DIRECTORIES( 
   ../ModelAPI
 )
 
+ADD_DEFINITIONS(-DGEOMDATAAPI_EXPORTS)
+ADD_LIBRARY(GeomDataAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+SET_TARGET_PROPERTIES(GeomDataAPI PROPERTIES LINKER_LANGUAGE CXX)
+TARGET_LINK_LIBRARIES(GeomDataAPI ${PROJECT_LIBRARIES})
+
+SET(CMAKE_SWIG_FLAGS "-Wall")
+
+SET_SOURCE_FILES_PROPERTIES(GeomDataAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(GeomDataAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+
 SET(SWIG_SCRIPTS
   ${CMAKE_CURRENT_BINARY_DIR}/GeomDataAPI.py
 )
 
 SET(SWIG_LINK_LIBRARIES
-  ModelAPI
+  GeomDataAPI
   ${PYTHON_LIBRARIES}
 )
 
@@ -37,6 +52,7 @@ IF(WIN32)
   SET_TARGET_PROPERTIES(_GeomDataAPI PROPERTIES DEBUG_OUTPUT_NAME _GeomDataAPI_d)
 ENDIF(WIN32)
 
+INSTALL(TARGETS GeomDataAPI DESTINATION bin)
 INSTALL(TARGETS _GeomDataAPI DESTINATION swig)
 INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION swig)
 
index 98496183ef39a34639d9f1315577b49001cd04af..24da73652b8bbf0ddb185b9a499c39802f8940c1 100644 (file)
@@ -6,6 +6,10 @@
   #include "GeomDataAPI_Point.h"
   #include "GeomDataAPI_Dir.h"
   #include "GeomDataAPI_Point2D.h"
+
+  #include <memory>
+  #include <string>
+  #include <list>
   
   template<class T> std::shared_ptr<T> castTo(std::shared_ptr<ModelAPI_Attribute> theObject) 
   { 
diff --git a/src/GeomDataAPI/GeomDataAPI_Dir.cpp b/src/GeomDataAPI/GeomDataAPI_Dir.cpp
new file mode 100644 (file)
index 0000000..cfb37d6
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomDataAPI_Dir.cpp
+// Created:     24 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+
+#include <GeomDataAPI_Dir.h>
+
+std::string GeomDataAPI_Dir::attributeType()
+{
+  return typeId();
+}
+
+GeomDataAPI_Dir::GeomDataAPI_Dir()
+{
+}
+
+GeomDataAPI_Dir::~GeomDataAPI_Dir()
+{
+
+}
index 85d4b3a8c433706c41f92d0fb9580b719664c364..4e61cd8f072ace18a6caa6561712e71bcf9f5339 100644 (file)
@@ -38,22 +38,18 @@ class GeomDataAPI_Dir : public ModelAPI_Attribute
   virtual std::shared_ptr<GeomAPI_XYZ> xyz() = 0;
 
   /// Returns the type of this class of attributes
-  static inline std::string type()
+  static std::string typeId()
   {
     return std::string("Dir");
   }
 
   /// Returns the type of this class of attributes, not static method
-  virtual std::string attributeType()
-  {
-    return type();
-  }
+  GEOMDATAAPI_EXPORT virtual std::string attributeType();
 
  protected:
   /// Objects are created for features automatically
-  GeomDataAPI_Dir()
-  {
-  }
+  GEOMDATAAPI_EXPORT GeomDataAPI_Dir();
+  GEOMDATAAPI_EXPORT virtual ~GeomDataAPI_Dir();
 };
 
 #endif
diff --git a/src/GeomDataAPI/GeomDataAPI_Point.cpp b/src/GeomDataAPI/GeomDataAPI_Point.cpp
new file mode 100644 (file)
index 0000000..a5874ba
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomDataAPI_Point.cpp
+// Created:     24 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#include <GeomDataAPI_Point.h>
+
+std::string GeomDataAPI_Point::attributeType()
+{
+  return typeId();
+}
+
+GeomDataAPI_Point::GeomDataAPI_Point()
+{
+}
+
+GeomDataAPI_Point::~GeomDataAPI_Point()
+{
+}
index 9209e521013a827e33aabaea45fd13b8639f722a..245f9b0f80c65732e8647226c8297493a8f54d71 100644 (file)
@@ -35,22 +35,18 @@ class GeomDataAPI_Point : public ModelAPI_Attribute
   virtual std::shared_ptr<GeomAPI_Pnt> pnt() = 0;
 
   /// Returns the type of this class of attributes
-  static inline std::string type()
+  static std::string typeId()
   {
     return std::string("Point");
   }
 
   /// Returns the type of this class of attributes, not static method
-  virtual std::string attributeType()
-  {
-    return type();
-  }
+  GEOMDATAAPI_EXPORT virtual std::string attributeType();
 
  protected:
   /// Objects are created for features automatically
-  GeomDataAPI_Point()
-  {
-  }
+  GEOMDATAAPI_EXPORT GeomDataAPI_Point();
+  GEOMDATAAPI_EXPORT virtual ~GeomDataAPI_Point();
 };
 
 #endif
diff --git a/src/GeomDataAPI/GeomDataAPI_Point2D.cpp b/src/GeomDataAPI/GeomDataAPI_Point2D.cpp
new file mode 100644 (file)
index 0000000..dd8b39e
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomDataAPI_Point2D.cpp
+// Created:     24 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+
+#include <GeomDataAPI_Point2D.h>
+
+void GeomDataAPI_Point2D::move(const double theDeltaX, const double theDeltaY)
+{
+  setValue(x() + theDeltaX, y() + theDeltaY);
+}
+
+std::string GeomDataAPI_Point2D::attributeType()
+{
+  return typeId();
+}
+
+GeomDataAPI_Point2D::GeomDataAPI_Point2D()
+{
+}
+
+GeomDataAPI_Point2D::~GeomDataAPI_Point2D()
+{
+}
index 83acc0b57e05bb510735a3dd5991ce272d07b2bc..3c67bec90d85c9e7a39cd68156b76c2db745c349 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef GeomDataAPI_Point2D_H_
 #define GeomDataAPI_Point2D_H_
 
-#include "GeomDataAPI.h"
+#include <GeomDataAPI.h>
 #include <ModelAPI_Attribute.h>
 
 class GeomAPI_Pnt2d;
@@ -33,29 +33,21 @@ class GeomDataAPI_Point2D : public ModelAPI_Attribute
   virtual std::shared_ptr<GeomAPI_Pnt2d> pnt() = 0;
 
   /// Appends the delta values to point
-  void move(const double theDeltaX, const double theDeltaY)
-  {
-    setValue(x() + theDeltaX, y() + theDeltaY);
-  }
-
+  GEOMDATAAPI_EXPORT void move(const double theDeltaX, const double theDeltaY);
 
   /// Returns the type of this class of attributes
-  static inline std::string type()
+  static std::string typeId()
   {
     return std::string("Point2D");
   }
 
   /// Returns the type of this class of attributes, not static method
-  virtual std::string attributeType()
-  {
-    return type();
-  }
+  GEOMDATAAPI_EXPORT virtual std::string attributeType();
 
  protected:
   /// Objects are created for features automatically
-  GeomDataAPI_Point2D()
-  {
-  }
+  GEOMDATAAPI_EXPORT GeomDataAPI_Point2D();
+  GEOMDATAAPI_EXPORT virtual ~GeomDataAPI_Point2D();
 };
 
 #endif
index bb6bc044afec44519b189ad7d18acd6b5765f06a..2af03aba1ef9cb28edc1b8b645aa1337c8f33b08 100644 (file)
@@ -2,6 +2,6 @@
 # Test GeomDataAPI static methods
 #===============================================================================
 from GeomDataAPI import *
-assert (GeomDataAPI_Point.type() == "Point")
-assert (GeomDataAPI_Dir.type() == "Dir")  
-assert (GeomDataAPI_Point2D.type() == "Point2D")  
\ No newline at end of file
+assert (GeomDataAPI_Point.typeId() == "Point")
+assert (GeomDataAPI_Dir.typeId() == "Dir")  
+assert (GeomDataAPI_Point2D.typeId() == "Point2D")  
\ No newline at end of file
index 642d1cde9c0a493705b05f703ea61d423c36c40c..cfd78c994b3ac8100e45e033af3313433ae3d4bb 100644 (file)
@@ -54,7 +54,7 @@ bool GeomValidators_EdgeOrVertex::isValid(const AttributePtr& theAttribute,
       AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
       if (anAttr.get() != NULL) {
         AttributePtr aRefAttr = anAttr->attr();
-        aValid = aRefAttr.get() != NULL && aRefAttr->attributeType() == GeomDataAPI_Point2D::type();
+        aValid = aRefAttr.get() != NULL && aRefAttr->attributeType() == GeomDataAPI_Point2D::typeId();
       }
     }
   }
index f98088ed3b17f4059b46cbfc430d9838032497ae..898296961797985cb3289a1a3bb066020a559a0b 100644 (file)
@@ -16,17 +16,17 @@ namespace GeomValidators_Tools {
   {
     ObjectPtr anObject;
     std::string anAttrType = theAttribute->attributeType();
-    if (anAttrType == ModelAPI_AttributeRefAttr::type()) {
+    if (anAttrType == ModelAPI_AttributeRefAttr::typeId()) {
       AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
       if (anAttr != NULL && anAttr->isObject())
         anObject = anAttr->object();
     }
-    if (anAttrType == ModelAPI_AttributeSelection::type()) {
+    if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
       AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
       if (anAttr != NULL && anAttr->isInitialized())
         anObject = anAttr->context();
     }
-    if (anAttrType == ModelAPI_AttributeReference::type()) {
+    if (anAttrType == ModelAPI_AttributeReference::typeId()) {
       AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
       if (anAttr.get() != NULL && anAttr->isInitialized())
         anObject = anAttr->value();
index 9133794ae94460375cf53c75b966de982345e221..003fb28e9912227a90e23a41680f331e8ab7b333 100644 (file)
@@ -50,6 +50,7 @@
 #include <TDataStd_Name.hxx>
 #include <TopAbs_ShapeEnum.hxx>
 #include <TopoDS_Iterator.hxx>
+#include <TNaming_Iterator.hxx>
 using namespace std;
 //#define DEB_NAMING 1
 #ifdef DEB_NAMING
@@ -121,7 +122,7 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext,
 
   std::string aSelName = namingName();
   if(!aSelName.empty())
-         TDataStd_Name::Set(selectionLabel(), aSelName.c_str()); //set name
+    TDataStd_Name::Set(selectionLabel(), aSelName.c_str()); //set name
 #ifdef DDDD
   //####
   //selectSubShape("FACE",  "Extrusion_1/LateralFace_3");
@@ -341,40 +342,40 @@ bool Model_AttributeSelection::update()
           // if aSubIds take any, the first appropriate
           int aFeatureID = aComposite->subFeatureId(a);
           if (aSubIds->IsEmpty() || aSubIds->Contains(aFeatureID) ||
-              aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA) ||
-              aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA * 2)) {
-            // searching for deltas
-            int aVertexNum = 0;
-            if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA)) aVertexNum = 1;
-            else if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA * 2)) aVertexNum = 2;
-            // found the feature with appropriate edge
-            FeaturePtr aFeature = aComposite->subFeature(a);
-            std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter =
-              aFeature->results().cbegin();
-            for(;aResIter != aFeature->results().cend(); aResIter++) {
-              ResultConstructionPtr aRes = 
-                std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aResIter);
-              if (aRes && aRes->shape()) {
-                if (aRes->shape()->isVertex() && aVertexNum == 0) { // found!
-                  selectConstruction(aContext, aRes->shape());
-                  owner()->data()->sendAttributeUpdated(this);
-                  return true;
-                } else if (aRes->shape()->isEdge() && aVertexNum > 0) {
-                  const TopoDS_Shape& anEdge = aRes->shape()->impl<TopoDS_Shape>();
-                  int aVIndex = 1;
-                  for(TopExp_Explorer aVExp(anEdge, TopAbs_VERTEX); aVExp.More(); aVExp.Next()) {
-                    if (aVIndex == aVertexNum) { // found!
-                      std::shared_ptr<GeomAPI_Shape> aVertex(new GeomAPI_Shape);
-                      aVertex->setImpl(new TopoDS_Shape(aVExp.Current()));
-                      selectConstruction(aContext, aVertex);
-                      owner()->data()->sendAttributeUpdated(this);
-                      return true;
+            aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA) ||
+            aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA * 2)) {
+              // searching for deltas
+              int aVertexNum = 0;
+              if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA)) aVertexNum = 1;
+              else if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA * 2)) aVertexNum = 2;
+              // found the feature with appropriate edge
+              FeaturePtr aFeature = aComposite->subFeature(a);
+              std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter =
+                aFeature->results().cbegin();
+              for(;aResIter != aFeature->results().cend(); aResIter++) {
+                ResultConstructionPtr aRes = 
+                  std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aResIter);
+                if (aRes && aRes->shape()) {
+                  if (aRes->shape()->isVertex() && aVertexNum == 0) { // found!
+                    selectConstruction(aContext, aRes->shape());
+                    owner()->data()->sendAttributeUpdated(this);
+                    return true;
+                  } else if (aRes->shape()->isEdge() && aVertexNum > 0) {
+                    const TopoDS_Shape& anEdge = aRes->shape()->impl<TopoDS_Shape>();
+                    int aVIndex = 1;
+                    for(TopExp_Explorer aVExp(anEdge, TopAbs_VERTEX); aVExp.More(); aVExp.Next()) {
+                      if (aVIndex == aVertexNum) { // found!
+                        std::shared_ptr<GeomAPI_Shape> aVertex(new GeomAPI_Shape);
+                        aVertex->setImpl(new TopoDS_Shape(aVExp.Current()));
+                        selectConstruction(aContext, aVertex);
+                        owner()->data()->sendAttributeUpdated(this);
+                        return true;
+                      }
+                      aVIndex++;
                     }
-                    aVIndex++;
                   }
                 }
               }
-            }
           }
         }
       }
@@ -389,7 +390,7 @@ bool Model_AttributeSelection::update()
 
 
 void Model_AttributeSelection::selectBody(
-    const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
+  const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
 {
   // perform the selection
   TNaming_Selector aSel(selectionLabel());
@@ -397,10 +398,11 @@ void Model_AttributeSelection::selectBody(
   TopoDS_Shape aContext;
 
   ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myRef.value());
-  if (aBody)
+  if (aBody) {
     aContext = aBody->shape()->impl<TopoDS_Shape>();
-  else {
-    ResultConstructionPtr aConstr = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myRef.value());
+  } else {
+    ResultConstructionPtr aConstr = 
+      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myRef.value());
     if (aConstr) {
       aContext = aConstr->shape()->impl<TopoDS_Shape>();
     } else {
@@ -408,7 +410,11 @@ void Model_AttributeSelection::selectBody(
       return;
     }
   }
-  //BRepTools::Write(aNewShape, "Selection0.brep");
+  /// fix for issue 411: result modified shapes must not participate in this selection mechanism
+  FeaturePtr aFeatureOwner = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+  if (aFeatureOwner.get())
+    aFeatureOwner->eraseResults();
+
   aSel.Select(aNewShape, aContext); 
 }
 
@@ -444,7 +450,7 @@ static void registerSubShape(TDF_Label theMainLabel, TopoDS_Shape theShape,
 }
 
 void Model_AttributeSelection::selectConstruction(
-    const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
+  const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
 {
   std::shared_ptr<Model_Document> aMyDoc = 
     std::dynamic_pointer_cast<Model_Document>(owner()->document());
@@ -564,60 +570,72 @@ TDF_Label Model_AttributeSelection::selectionLabel()
 
 #define FIX_BUG1 1
 std::string GetShapeName(std::shared_ptr<Model_Document> theDoc, const TopoDS_Shape& theShape, 
-                                            const TDF_Label& theLabel)
+  const TDF_Label& theLabel)
 {
   std::string aName;
   // check if the subShape is already in DF
   Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(theShape, theLabel);
   Handle(TDataStd_Name) anAttr;
   if(!aNS.IsNull() && !aNS->IsEmpty()) { // in the document    
-       if(aNS->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) {
-         aName = TCollection_AsciiString(anAttr->Get()).ToCString();
-         if(!aName.empty()) {      
-           const TDF_Label& aLabel = theDoc->findNamingName(aName);
-    /* MPV: the same shape with the same name may be duplicated on different labels (selection of the same construction object)
-               if(!aLabel.IsEqual(aNS->Label())) {
-                 //aName.erase(); //something is wrong, to be checked!!!
-                 aName += "_SomethingWrong";
-                 return aName;
-               }*/
-               const TopoDS_Shape& aShape = aNS->Get();
-               if(aShape.ShapeType() == TopAbs_COMPOUND) {
-                 std::string aPostFix("_");
-                 TopoDS_Iterator it(aShape);                   
-                 for (int i = 1;it.More();it.Next(), i++) {
-                   if(it.Value() == theShape) {
-                         aPostFix += TCollection_AsciiString (i).ToCString();
-                         aName    += aPostFix;
-                         break;
-                       }
-                       else continue;                                          
-                 }
-               }
-         }     
-       }
+    if(aNS->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) {
+      aName = TCollection_AsciiString(anAttr->Get()).ToCString();
+      if(!aName.empty()) {         
+        const TDF_Label& aLabel = theDoc->findNamingName(aName);
+        /* MPV: the same shape with the same name may be duplicated on different labels (selection of the same construction object)
+        if(!aLabel.IsEqual(aNS->Label())) {
+        //aName.erase(); //something is wrong, to be checked!!!
+        aName += "_SomethingWrong";
+        return aName;
+        }*/
+
+        static const std::string aPostFix("_");
+        TNaming_Iterator anItL(aNS);
+        for(int i = 1; anItL.More(); anItL.Next(), i++) {
+          if(anItL.NewShape() == theShape) {
+            aName += aPostFix;
+            aName += TCollection_AsciiString (i).ToCString();
+            break;
+          }
+        }
+        /* MPV: the code below does not work because of TNaming_Tool.cxx line 145: aNS->Get() uses maps
+        const TopoDS_Shape& aShape = aNS->Get();
+        if(aShape.ShapeType() == TopAbs_COMPOUND) {
+        std::string aPostFix("_");
+        TopoDS_Iterator it(aShape);                    
+        for (int i = 1;it.More();it.Next(), i++) {
+        if(it.Value() == theShape) {
+        aPostFix += TCollection_AsciiString (i).ToCString();
+        aName    += aPostFix;
+        break;
+        }
+        else continue;                                         
+        }
+        }
+        */
+      }        
+    }
   }
   return aName;
 }
 
 bool isTrivial (const TopTools_ListOfShape& theAncestors, TopTools_IndexedMapOfShape& theSMap)
 {
-// a trivial case: F1 & F2,  aNumber = 1, i.e. intersection gives 1 edge.
+  // a trivial case: F1 & F2,  aNumber = 1, i.e. intersection gives 1 edge.
   TopoDS_Compound aCmp;
   BRep_Builder BB;
   BB.MakeCompound(aCmp);
   TopTools_ListIteratorOfListOfShape it(theAncestors);
   for(;it.More();it.Next()) {
-       BB.Add(aCmp, it.Value());
-       theSMap.Add(it.Value());
+    BB.Add(aCmp, it.Value());
+    theSMap.Add(it.Value());
   }
   int aNumber(0);
   TopTools_IndexedDataMapOfShapeListOfShape aMap2;
   TopExp::MapShapesAndAncestors(aCmp, TopAbs_EDGE, TopAbs_FACE, aMap2);
   for (int i = 1; i <= aMap2.Extent(); i++) {
-       const TopoDS_Shape& aKey = aMap2.FindKey(i);
-       const TopTools_ListOfShape& anAncestors = aMap2.FindFromIndex(i);
-       if(anAncestors.Extent() > 1) aNumber++;
+    const TopoDS_Shape& aKey = aMap2.FindKey(i);
+    const TopTools_ListOfShape& anAncestors = aMap2.FindFromIndex(i);
+    if(anAncestors.Extent() > 1) aNumber++;
   }
   if(aNumber > 1) return false;
   return true;
@@ -628,8 +646,8 @@ std::string Model_AttributeSelection::namingName()
   if(!this->isInitialized()) return aName;
   Handle(TDataStd_Name) anAtt;
   if(selectionLabel().FindAttribute(TDataStd_Name::GetID(), anAtt)) {
-       aName = TCollection_AsciiString(anAtt->Get()).ToCString();
-       return aName;
+    aName = TCollection_AsciiString(anAtt->Get()).ToCString();
+    return aName;
   }
 
   std::shared_ptr<GeomAPI_Shape> aSubSh = value();
@@ -655,8 +673,8 @@ std::string Model_AttributeSelection::namingName()
   aName = GetShapeName(aDoc, aSubShape, selectionLabel());
   if(aName.empty() ) { // not in the document!
     TopAbs_ShapeEnum aType = aSubShape.ShapeType();
-       switch (aType) {
-         case TopAbs_FACE:
+    switch (aType) {
+    case TopAbs_FACE:
       // the Face should be in DF. If it is not the case, it is an error ==> to be debugged            
                break;
          case TopAbs_EDGE:
@@ -722,82 +740,82 @@ std::string Model_AttributeSelection::namingName()
                  }
                  break;
 
-         case TopAbs_VERTEX:
-                 // name structure (Monifold Topology): 
-                 // 1) F1 | F2 | F3 - intersection of 3 faces defines a vertex - trivial case.
-                 // 2) F1 | F2 | F3 [|F4 [|Fn]] - redundant definition, but it should be kept as is to obtain safe recomputation
-                 // 2) F1 | F2      - intersection of 2 faces definses a vertex - applicable for case
-                 //                   when 1 faces is cylindrical, conical, spherical or revolution and etc.
-                 // 3) E1 | E2 | E3 - intersection of 3 edges defines a vertex - when we have case of a shell
-                 //                   or compound of 2 open faces.
-                 // 4) E1 | E2      - intesection of 2 edges defines a vertex - when we have a case of 
-                 //                   two independent edges (wire or compound)
-                 // implemented 2 first cases
-                 {
-                       TopTools_IndexedDataMapOfShapeListOfShape aMap;
-                   TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_FACE, aMap);
-                       const TopTools_ListOfShape& aList2  = aMap.FindFromKey(aSubShape);
-                       TopTools_ListOfShape aList;
-                       TopTools_MapOfShape aFMap;
+    case TopAbs_VERTEX:
+      // name structure (Monifold Topology): 
+      // 1) F1 | F2 | F3 - intersection of 3 faces defines a vertex - trivial case.
+      // 2) F1 | F2 | F3 [|F4 [|Fn]] - redundant definition, but it should be kept as is to obtain safe recomputation
+      // 2) F1 | F2      - intersection of 2 faces definses a vertex - applicable for case
+      //                   when 1 faces is cylindrical, conical, spherical or revolution and etc.
+      // 3) E1 | E2 | E3 - intersection of 3 edges defines a vertex - when we have case of a shell
+      //                   or compound of 2 open faces.
+      // 4) E1 | E2      - intesection of 2 edges defines a vertex - when we have a case of 
+      //                   two independent edges (wire or compound)
+      // implemented 2 first cases
+      {
+        TopTools_IndexedDataMapOfShapeListOfShape aMap;
+        TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_FACE, aMap);
+        const TopTools_ListOfShape& aList2  = aMap.FindFromKey(aSubShape);
+        TopTools_ListOfShape aList;
+        TopTools_MapOfShape aFMap;
 #ifdef FIX_BUG1
-                       //int n = aList2.Extent(); //bug! duplication
-                       // fix is below
-                       TopTools_ListIteratorOfListOfShape itl2(aList2);
-                   for (int i = 1;itl2.More();itl2.Next(),i++) {
-                         if(aFMap.Add(itl2.Value()))
-                               aList.Append(itl2.Value());
-                       }
-                       //n = aList.Extent();
+        //int n = aList2.Extent(); //bug! duplication
+        // fix is below
+        TopTools_ListIteratorOfListOfShape itl2(aList2);
+        for (int i = 1;itl2.More();itl2.Next(),i++) {
+          if(aFMap.Add(itl2.Value()))
+            aList.Append(itl2.Value());
+        }
+        //n = aList.Extent();
 #endif
-                       int n = aList.Extent();
-                       if(n < 3) { // open topology case or Compound case => via edges
-                         TopTools_IndexedDataMapOfShapeListOfShape aMap;
-                     TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_EDGE, aMap);
-                         const TopTools_ListOfShape& aList22  = aMap.FindFromKey(aSubShape);
-                         if(aList22.Extent() >= 2)  { // regular solution
+        int n = aList.Extent();
+        if(n < 3) { // open topology case or Compound case => via edges
+          TopTools_IndexedDataMapOfShapeListOfShape aMap;
+          TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_EDGE, aMap);
+          const TopTools_ListOfShape& aList22  = aMap.FindFromKey(aSubShape);
+          if(aList22.Extent() >= 2)  { // regular solution
 #ifdef FIX_BUG1
-                       
-                           // bug! duplication; fix is below
-                           aFMap.Clear();
-                           TopTools_ListOfShape aListE;
-                           TopTools_ListIteratorOfListOfShape itl2(aList22);
-                       for (int i = 1;itl2.More();itl2.Next(),i++) {
-                           if(aFMap.Add(itl2.Value()))
-                                 aListE.Append(itl2.Value());
-                               }
-                           n = aListE.Extent();
+
+            // bug! duplication; fix is below
+            aFMap.Clear();
+            TopTools_ListOfShape aListE;
+            TopTools_ListIteratorOfListOfShape itl2(aList22);
+            for (int i = 1;itl2.More();itl2.Next(),i++) {
+              if(aFMap.Add(itl2.Value()))
+                aListE.Append(itl2.Value());
+            }
+            n = aListE.Extent();
 #endif
-                               TopTools_ListIteratorOfListOfShape itl(aListE);
-                       for (int i = 1;itl.More();itl.Next(),i++) {
-                             const TopoDS_Shape& anEdge = itl.Value();
-                             std::string anEdgeName = GetShapeName(aDoc, anEdge, selectionLabel());
-                             if(i == 1)
-                               aName = anEdgeName;
-                             else 
-                               aName += "|" + anEdgeName;
-                               }
-                         }//reg
-                         else { // dangle vertex: if(aList22.Extent() == 1)
-                                 //it should be already in DF
-                         }
-                       
-                       else {
-                         TopTools_ListIteratorOfListOfShape itl(aList);
-                     for (int i = 1;itl.More();itl.Next(),i++) {
-                           const TopoDS_Shape& aFace = itl.Value();
-                           std::string aFaceName = GetShapeName(aDoc, aFace, selectionLabel());
-                           if(i == 1)
-                             aName = aFaceName;
-                           else 
-                             aName += "|" + aFaceName;
-                         }
-                       }
-                 }
-                 break;
-       }
+            TopTools_ListIteratorOfListOfShape itl(aListE);
+            for (int i = 1;itl.More();itl.Next(),i++) {
+              const TopoDS_Shape& anEdge = itl.Value();
+              std::string anEdgeName = GetShapeName(aDoc, anEdge, selectionLabel());
+              if(i == 1)
+                aName = anEdgeName;
+              else 
+                aName += "|" + anEdgeName;
+            }
+          }//reg
+          else { // dangle vertex: if(aList22.Extent() == 1)
+            //it should be already in DF
+          }
+        } 
+        else {
+          TopTools_ListIteratorOfListOfShape itl(aList);
+          for (int i = 1;itl.More();itl.Next(),i++) {
+            const TopoDS_Shape& aFace = itl.Value();
+            std::string aFaceName = GetShapeName(aDoc, aFace, selectionLabel());
+            if(i == 1)
+              aName = aFaceName;
+            else 
+              aName += "|" + aFaceName;
+          }
+        }
+      }
+      break;
+    }
     // register name                   
     // aDoc->addNamingName(selectionLabel(), aName);
-       // the selected sub-shape will not be shared and as result it will not require registration
+    // the selected sub-shape will not be shared and as result it will not require registration
   }
   return aName;
 }
@@ -834,28 +852,29 @@ TopAbs_ShapeEnum translateType (const std::string& theType)
   return TopAbs_SHAPE;
 }
 
-const TopoDS_Shape getShapeFromCompound(const std::string& theSubShapeName, const TopoDS_Shape& theCompound)
+const TopoDS_Shape getShapeFromNS(
+  const std::string& theSubShapeName, Handle(TNaming_NamedShape) theNS)
 {
   TopoDS_Shape aSelection;
   std::string::size_type n = theSubShapeName.rfind('/');                       
   if (n == std::string::npos) n = 0;
-       std::string aSubString = theSubShapeName.substr(n + 1);
-       n = aSubString.rfind('_');
-       if (n == std::string::npos) return aSelection;
-       aSubString = aSubString.substr(n+1);
-       int indx = atoi(aSubString.c_str());
-       TopoDS_Iterator it(theCompound);                        
-       for (int i = 1;it.More();it.Next(), i++) {
-         if(i == indx) {                         
-           aSelection = it.Value();                      
-           break;
-         }
-         else continue;                                                
-       }
+  std::string aSubString = theSubShapeName.substr(n + 1);
+  n = aSubString.rfind('_');
+  if (n == std::string::npos) return aSelection;
+  aSubString = aSubString.substr(n+1);
+  int indx = atoi(aSubString.c_str());
+
+  TNaming_Iterator anItL(theNS);
+  for(int i = 1; anItL.More(); anItL.Next(), i++) {
+    if (i == indx) {
+      return anItL.NewShape();
+    }
+  }
   return aSelection;   
 }
 
-const TopoDS_Shape findFaceByName(const std::string& theSubShapeName, std::shared_ptr<Model_Document> theDoc)
+const TopoDS_Shape findFaceByName(
+  const std::string& theSubShapeName, std::shared_ptr<Model_Document> theDoc)
 {
   TopoDS_Shape aFace;
   std::string::size_type n, nb = theSubShapeName.rfind('/');                   
@@ -863,23 +882,17 @@ const TopoDS_Shape findFaceByName(const std::string& theSubShapeName, std::share
   std::string aSubString = theSubShapeName.substr(nb + 1);
   n = aSubString.rfind('_');
   if (n != std::string::npos) {
-         std::string aSubStr2 = aSubString.substr(0, n);
-       aSubString  = theSubShapeName.substr(0, nb + 1);
-       aSubString = aSubString + aSubStr2;     
+    std::string aSubStr2 = aSubString.substr(0, n);
+    aSubString  = theSubShapeName.substr(0, nb + 1);
+    aSubString = aSubString + aSubStr2;        
   } else
-       aSubString = theSubShapeName;
-                               
+    aSubString = theSubShapeName;
+
   const TDF_Label& aLabel = theDoc->findNamingName(aSubString);
   if(aLabel.IsNull()) return aFace;
   Handle(TNaming_NamedShape) aNS;
   if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
-       const TopoDS_Shape& aShape = aNS->Get();
-       if(!aShape.IsNull()) {
-         if(aShape.ShapeType() == TopAbs_COMPOUND) 
-           aFace = getShapeFromCompound(theSubShapeName, aShape);
-         else 
-               aFace = aShape;   
-       }
+    aFace = getShapeFromNS(theSubShapeName, aNS);
   }
   return aFace;
 }
@@ -891,23 +904,24 @@ int ParseName(const std::string& theSubShapeName,   std::list<std::string>& theL
   int n1(0), n2(0); // n1 - start position, n2 - position of the delimiter
   while ((n2 = aName.find('|', n1)) != std::string::npos) {
     const std::string aName1 = aName.substr(n1, n2 - n1); //name of face
-       theList.push_back(aName1);      
-       n1 = n2 + 1;
-       aLastName = aName.substr(n1);
+    theList.push_back(aName1); 
+    n1 = n2 + 1;
+    aLastName = aName.substr(n1);
   }
   if(!aLastName.empty())
-       theList.push_back(aLastName);
+    theList.push_back(aLastName);
   return theList.size();
 }
 
-const TopoDS_Shape findCommonShape(const TopAbs_ShapeEnum theType, const TopTools_ListOfShape& theList)
+const TopoDS_Shape findCommonShape(
+  const TopAbs_ShapeEnum theType, const TopTools_ListOfShape& theList)
 {
   TopoDS_Shape aShape;
   std::vector<TopTools_MapOfShape> aVec;
   TopTools_MapOfShape aMap1, aMap2, aMap3, aMap4;
   if(theList.Extent() > 1) {
-       aVec.push_back(aMap1);
-       aVec.push_back(aMap2);
+    aVec.push_back(aMap1);
+    aVec.push_back(aMap2);
   }
   if(theList.Extent() > 2)
     aVec.push_back(aMap3);
@@ -917,66 +931,66 @@ const TopoDS_Shape findCommonShape(const TopAbs_ShapeEnum theType, const TopTool
   //fill maps
   TopTools_ListIteratorOfListOfShape it(theList);
   for(int i = 0;it.More();it.Next(),i++) {
-       const TopoDS_Shape& aFace = it.Value();         
-       if(i < 2) {
-         TopExp_Explorer anExp (aFace, theType);
-         for(;anExp.More();anExp.Next()) {
-           const TopoDS_Shape& anEdge = anExp.Current();
-           if (!anEdge.IsNull())
-                 aVec[i].Add(anExp.Current());
-         }
-       } else {
-         TopExp_Explorer anExp (aFace, TopAbs_VERTEX);
-         for(;anExp.More();anExp.Next()) {
-           const TopoDS_Shape& aVertex = anExp.Current();
-           if (!aVertex.IsNull())
-                 aVec[i].Add(anExp.Current());
-         }
-       }
+    const TopoDS_Shape& aFace = it.Value();            
+    if(i < 2) {
+      TopExp_Explorer anExp (aFace, theType);
+      for(;anExp.More();anExp.Next()) {
+        const TopoDS_Shape& anEdge = anExp.Current();
+        if (!anEdge.IsNull())
+          aVec[i].Add(anExp.Current());
+      }
+    } else {
+      TopExp_Explorer anExp (aFace, TopAbs_VERTEX);
+      for(;anExp.More();anExp.Next()) {
+        const TopoDS_Shape& aVertex = anExp.Current();
+        if (!aVertex.IsNull())
+          aVec[i].Add(anExp.Current());
+      }
+    }
   }
   //trivial case: 2 faces
   TopTools_ListOfShape aList;
   TopTools_MapIteratorOfMapOfShape it2(aVec[0]);
   for(;it2.More();it2.Next()) {
-       if(aVec[1].Contains(it2.Key())) {
-         aShape = it2.Key();
-         if(theList.Extent() == 2)
-           break;
-         else 
-               aList.Append(it2.Key());
-       }
+    if(aVec[1].Contains(it2.Key())) {
+      aShape = it2.Key();
+      if(theList.Extent() == 2)
+        break;
+      else 
+        aList.Append(it2.Key());
+    }
   }
   if(aList.Extent() && aVec.size() > 3) {// list of common edges ==> search ny neighbors 
-       if(aVec[2].Extent() && aVec[3].Extent()) {
-         TopTools_ListIteratorOfListOfShape it(aList);
-         for(;it.More();it.Next()) {
-               const TopoDS_Shape& aCand = it.Value();
-               // not yet completelly implemented, to be rechecked
-               TopoDS_Vertex aV1, aV2;
-               TopExp::Vertices(TopoDS::Edge(aCand), aV1, aV2);
-               int aNum(0);
-               if(aVec[2].Contains(aV1)) aNum++;
-               else if(aVec[2].Contains(aV2)) aNum++;
-               if(aVec[3].Contains(aV1)) aNum++;
-               else if(aVec[3].Contains(aV2)) aNum++;
-               if(aNum == 2) {
-                 aShape = aCand;
-                 break;
-               }
-         }
-       }
+    if(aVec[2].Extent() && aVec[3].Extent()) {
+      TopTools_ListIteratorOfListOfShape it(aList);
+      for(;it.More();it.Next()) {
+        const TopoDS_Shape& aCand = it.Value();
+        // not yet completelly implemented, to be rechecked
+        TopoDS_Vertex aV1, aV2;
+        TopExp::Vertices(TopoDS::Edge(aCand), aV1, aV2);
+        int aNum(0);
+        if(aVec[2].Contains(aV1)) aNum++;
+        else if(aVec[2].Contains(aV2)) aNum++;
+        if(aVec[3].Contains(aV1)) aNum++;
+        else if(aVec[3].Contains(aV2)) aNum++;
+        if(aNum == 2) {
+          aShape = aCand;
+          break;
+        }
+      }
+    }
   }
 
   if(aList.Extent() && aVec.size() == 3) {
 
     TopTools_ListIteratorOfListOfShape it(aList);
-         for(;it.More();it.Next()) {
-               const TopoDS_Shape& aCand = it.Value();
-               if(aVec[2].Contains(aCand)) {
-                 aShape = aCand;
-                 break;
-               }
-         }
+    for(;it.More();it.Next()) {
+      const TopoDS_Shape& aCand = it.Value();
+      if(aVec[2].Contains(aCand)) {
+        aShape = aCand;
+        break;
+      }
+    }
   }
   return aShape;
 }
@@ -990,11 +1004,13 @@ std::string getContextName(const std::string& theSubShapeName)
   return aName;
 }
 // type ::= COMP | COMS | SOLD | SHEL | FACE | WIRE | EDGE | VERT
-void Model_AttributeSelection::selectSubShape(const std::string& theType, const std::string& theSubShapeName)
+void Model_AttributeSelection::selectSubShape(
+  const std::string& theType, const std::string& theSubShapeName)
 {
   if(theSubShapeName.empty() || theType.empty()) return;
   TopAbs_ShapeEnum aType = translateType(theType);
-  std::shared_ptr<Model_Document> aDoc =  std::dynamic_pointer_cast<Model_Document>(owner()->document());//std::dynamic_pointer_cast<Model_Document>(aCont->document());
+  std::shared_ptr<Model_Document> aDoc = 
+    std::dynamic_pointer_cast<Model_Document>(owner()->document());
   std::string aContName = getContextName(theSubShapeName);
   if(aContName.empty()) return;
   //ResultPtr aCont = context();
@@ -1003,8 +1019,8 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType, const
   TopoDS_Shape aContext  = aCont->shape()->impl<TopoDS_Shape>();
   TopAbs_ShapeEnum aContType = aContext.ShapeType();
   if(aType <= aContType) return; // not applicable
-  
+
+
   TopoDS_Shape aSelection;
   switch (aType) 
   {
@@ -1018,89 +1034,79 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType, const
     break;
   case TopAbs_FACE:
     {
-         const TopoDS_Shape aSelection = findFaceByName(theSubShapeName, aDoc);
-         if(!aSelection.IsNull()) {// Select it
-               std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
+      const TopoDS_Shape aSelection = findFaceByName(theSubShapeName, aDoc);
+      if(!aSelection.IsNull()) {// Select it
+        std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
         aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection));
-               setValue(aCont, aShapeToBeSelected);
-         }
-       }
+        setValue(aCont, aShapeToBeSelected);
+      }
+    }
     break;
   case TopAbs_WIRE:
-       break;
+    break;
   case TopAbs_EDGE:
-       {  
-         TopoDS_Shape aSelection;// = findFaceByName(theSubShapeName, aDoc);
-         const TDF_Label& aLabel = aDoc->findNamingName(theSubShapeName);
+    {  
+      TopoDS_Shape aSelection;// = findFaceByName(theSubShapeName, aDoc);
+      const TDF_Label& aLabel = aDoc->findNamingName(theSubShapeName);
       if(!aLabel.IsNull()) {
         Handle(TNaming_NamedShape) aNS;
         if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
-             const TopoDS_Shape& aShape = aNS->Get();
-             if(!aShape.IsNull()) {
-               if(aShape.ShapeType() == TopAbs_COMPOUND) 
-                 aSelection = getShapeFromCompound(theSubShapeName, aShape);
-                       else 
-                   aSelection = aShape;          
-                 }
-               }
-         }
-         if(aSelection.IsNull()) {
-         std::list<std::string> aListofNames;
-         int n = ParseName(theSubShapeName, aListofNames);
-         if(n > 1 && n < 5) {
-               TopTools_ListOfShape aList;
-        for(std::list<std::string>::iterator it =aListofNames.begin();it != aListofNames.end();it++){
-                 const TopoDS_Shape aFace = findFaceByName(*it, aDoc);
-                 aList.Append(aFace);          
-               }
-               aSelection = findCommonShape(TopAbs_EDGE, aList);
-         }
-         }
-         if(!aSelection.IsNull()) {// Select it
-               std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
+          aSelection = getShapeFromNS(theSubShapeName, aNS);
+        }
+      }
+      if(aSelection.IsNull()) {
+        std::list<std::string> aListofNames;
+        int n = ParseName(theSubShapeName, aListofNames);
+        if(n > 1 && n < 5) {
+          TopTools_ListOfShape aList;
+          std::list<std::string>::iterator it =aListofNames.begin();
+          for(;it != aListofNames.end();it++){
+            const TopoDS_Shape aFace = findFaceByName(*it, aDoc);
+            aList.Append(aFace);               
+          }
+          aSelection = findCommonShape(TopAbs_EDGE, aList);
+        }
+      }
+      if(!aSelection.IsNull()) {// Select it
+        std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
         aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection));
-               setValue(aCont, aShapeToBeSelected);
-         }
-       }
+        setValue(aCont, aShapeToBeSelected);
+      }
+    }
     break;
   case TopAbs_VERTEX:
-         {
-         TopoDS_Shape aSelection;
-         const TDF_Label& aLabel = aDoc->findNamingName(theSubShapeName);
+    {
+      TopoDS_Shape aSelection;
+      const TDF_Label& aLabel = aDoc->findNamingName(theSubShapeName);
       if(!aLabel.IsNull()) {
         Handle(TNaming_NamedShape) aNS;
         if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
-             const TopoDS_Shape& aShape = aNS->Get();
-             if(!aShape.IsNull()) {
-               if(aShape.ShapeType() == TopAbs_COMPOUND) 
-                 aSelection = getShapeFromCompound(theSubShapeName, aShape);
-                       else 
-                   aSelection = aShape;          
-                 }
-               }
-         }
-         if(aSelection.IsNull()) {
-           std::list<std::string> aListofNames;
-               int n = ParseName(theSubShapeName, aListofNames);
-           if(n > 1 && n < 4) { // 2 || 3
-               TopTools_ListOfShape aList;
-          for(std::list<std::string>::iterator it =aListofNames.begin();it != aListofNames.end();it++){
-                   const TopoDS_Shape aFace = findFaceByName(*it, aDoc);
-                       if(!aFace.IsNull())
-                     aList.Append(aFace);              
-                 }
-                aSelection = findCommonShape(TopAbs_VERTEX, aList);
-               }
-         }
-         if(!aSelection.IsNull()) {// Select it
-               std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
+          aSelection = getShapeFromNS(theSubShapeName, aNS);
+        }
+      }
+      if(aSelection.IsNull()) {
+        std::list<std::string> aListofNames;
+        int n = ParseName(theSubShapeName, aListofNames);
+        if(n > 1 && n < 4) { // 2 || 3
+          TopTools_ListOfShape aList;
+          std::list<std::string>::iterator it = aListofNames.begin();
+          for(; it != aListofNames.end(); it++){
+            const TopoDS_Shape aFace = findFaceByName(*it, aDoc);
+            if(!aFace.IsNull())
+              aList.Append(aFace);             
+          }
+          aSelection = findCommonShape(TopAbs_VERTEX, aList);
+        }
+      }
+      if(!aSelection.IsNull()) {// Select it
+        std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected(new GeomAPI_Shape());
         aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection));
-               setValue(aCont, aShapeToBeSelected);
-         }
-         }
-       break;
+        setValue(aCont, aShapeToBeSelected);
+      }
+    }
+    break;
   default: //TopAbs_SHAPE
-       return;
+    return;
   }
 
 }
@@ -1113,7 +1119,7 @@ int Model_AttributeSelection::Id()
   const TopoDS_Shape& aSubShape = aSelection->impl<TopoDS_Shape>();
   int anID = 0;
   if (aSelection && !aSelection->isNull() &&
-      aContext   && !aContext->isNull())
+    aContext   && !aContext->isNull())
   {
     TopTools_IndexedMapOfShape aSubShapesMap;
     TopExp::MapShapes(aMainShape, aSubShapesMap);
index 82cc259187f241baf8d61af17ecd4be53b79251a..d537db894aa04f9a905c4a8339b9c7ddfbaa555f 100644 (file)
@@ -75,35 +75,35 @@ AttributePtr Model_Data::addAttribute(const std::string& theID, const std::strin
   AttributePtr aResult;
   TDF_Label anAttrLab = myLab.FindChild(myAttrs.size() + 1);
   ModelAPI_Attribute* anAttr = 0;
-  if (theAttrType == ModelAPI_AttributeDocRef::type()) {
+  if (theAttrType == ModelAPI_AttributeDocRef::typeId()) {
     anAttr = new Model_AttributeDocRef(anAttrLab);
-  } else if (theAttrType == Model_AttributeInteger::type()) {
+  } else if (theAttrType == Model_AttributeInteger::typeId()) {
     anAttr = new Model_AttributeInteger(anAttrLab);
-  } else if (theAttrType == ModelAPI_AttributeDouble::type()) {
+  } else if (theAttrType == ModelAPI_AttributeDouble::typeId()) {
     anAttr = new Model_AttributeDouble(anAttrLab);
-  } else if (theAttrType == Model_AttributeBoolean::type()) {
+  } else if (theAttrType == Model_AttributeBoolean::typeId()) {
     anAttr = new Model_AttributeBoolean(anAttrLab);
-  } else if (theAttrType == Model_AttributeString::type()) {
+  } else if (theAttrType == Model_AttributeString::typeId()) {
     anAttr = new Model_AttributeString(anAttrLab);
-  } else if (theAttrType == ModelAPI_AttributeReference::type()) {
+  } else if (theAttrType == ModelAPI_AttributeReference::typeId()) {
     anAttr = new Model_AttributeReference(anAttrLab);
-  } else if (theAttrType == ModelAPI_AttributeSelection::type()) {
+  } else if (theAttrType == ModelAPI_AttributeSelection::typeId()) {
     anAttr = new Model_AttributeSelection(anAttrLab);
-  } else if (theAttrType == ModelAPI_AttributeSelectionList::type()) {
+  } else if (theAttrType == ModelAPI_AttributeSelectionList::typeId()) {
     anAttr = new Model_AttributeSelectionList(anAttrLab);
-  } else if (theAttrType == ModelAPI_AttributeRefAttr::type()) {
+  } else if (theAttrType == ModelAPI_AttributeRefAttr::typeId()) {
     anAttr = new Model_AttributeRefAttr(anAttrLab);
-  } else if (theAttrType == ModelAPI_AttributeRefList::type()) {
+  } else if (theAttrType == ModelAPI_AttributeRefList::typeId()) {
     anAttr = new Model_AttributeRefList(anAttrLab);
-  } else if (theAttrType == ModelAPI_AttributeIntArray::type()) {
+  } else if (theAttrType == ModelAPI_AttributeIntArray::typeId()) {
     anAttr = new Model_AttributeIntArray(anAttrLab);
   } 
   // create also GeomData attributes here because only here the OCAF strucure is known
-  else if (theAttrType == GeomData_Point::type()) {
+  else if (theAttrType == GeomData_Point::typeId()) {
     anAttr = new GeomData_Point(anAttrLab);
-  } else if (theAttrType == GeomData_Dir::type()) {
+  } else if (theAttrType == GeomData_Dir::typeId()) {
     anAttr = new GeomData_Dir(anAttrLab);
-  } else if (theAttrType == GeomData_Point2D::type()) {
+  } else if (theAttrType == GeomData_Point2D::typeId()) {
     anAttr = new GeomData_Point2D(anAttrLab);
   }
   if (anAttr) {
@@ -278,21 +278,21 @@ void Model_Data::referencesToObjects(
   std::list<ObjectPtr> aReferenced; // not inside of cycle to avoid excess memory menagement
   for(; anAttr != myAttrs.end(); anAttr++) {
     std::string aType = anAttr->second->attributeType();
-    if (aType == ModelAPI_AttributeReference::type()) { // reference to object
+    if (aType == ModelAPI_AttributeReference::typeId()) { // reference to object
       std::shared_ptr<ModelAPI_AttributeReference> aRef = std::dynamic_pointer_cast<
           ModelAPI_AttributeReference>(anAttr->second);
       aReferenced.push_back(aRef->value());
-    } else if (aType == ModelAPI_AttributeRefAttr::type()) { // reference to attribute or object
+    } else if (aType == ModelAPI_AttributeRefAttr::typeId()) { // reference to attribute or object
       std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = std::dynamic_pointer_cast<
           ModelAPI_AttributeRefAttr>(anAttr->second);
       aReferenced.push_back(aRef->isObject() ? aRef->object() : aRef->attr()->owner());
-    } else if (aType == ModelAPI_AttributeRefList::type()) { // list of references
+    } else if (aType == ModelAPI_AttributeRefList::typeId()) { // list of references
       aReferenced = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttr->second)->list();
-    } else if (aType == ModelAPI_AttributeSelection::type()) { // selection attribute
+    } else if (aType == ModelAPI_AttributeSelection::typeId()) { // selection attribute
       std::shared_ptr<ModelAPI_AttributeSelection> aRef = std::dynamic_pointer_cast<
           ModelAPI_AttributeSelection>(anAttr->second);
       aReferenced.push_back(aRef->context());
-    } else if (aType == ModelAPI_AttributeSelectionList::type()) { // list of selection attributes
+    } else if (aType == ModelAPI_AttributeSelectionList::typeId()) { // list of selection attributes
       std::shared_ptr<ModelAPI_AttributeSelectionList> aRef = std::dynamic_pointer_cast<
           ModelAPI_AttributeSelectionList>(anAttr->second);
       for(int a = aRef->size() - 1; a >= 0; a--) {
index 2bdea7f5f30bdf54fbd2db814dccdc2b16615f1e..7708c92cfbda5f6707876e72b6e6e49db579d23f 100644 (file)
@@ -46,7 +46,7 @@ void Model_ResultBody::initAttributes()
 {
   // append the color attribute. It is empty, the attribute will be filled by a request
   DataPtr aData = data();
-  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type());
+  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
 }
 
 void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& theName,
index 2998e9f2db8a4879186ed9cbb458051d027100d1..1e2021c42637615880d9a35fa48c299f9c77e1e5 100644 (file)
@@ -15,7 +15,7 @@ void Model_ResultConstruction::initAttributes()
 {
   // append the color attribute. It is empty, the attribute will be filled by a request
   DataPtr aData = data();
-  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type());
+  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
 }
 
 void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::string& theName,
index dd4ee732b7091f9823036048d326bef3f3d6f1af..39809bade0444a0a964855077dd8926599024119 100644 (file)
@@ -22,7 +22,7 @@ void Model_ResultGroup::initAttributes()
 {
   // append the color attribute. It is empty, the attribute will be filled by a request
   DataPtr aData = data();
-  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type());
+  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
 }
 
 void Model_ResultGroup::colorConfigInfo(std::string& theSection, std::string& theName,
index 0392787f3c7a2b7a44558b0b851a81a3914a5eb6..a54ca670999c64d005f81c59f45d2a4712baf07e 100644 (file)
@@ -28,7 +28,7 @@ void Model_ResultPart::setData(std::shared_ptr<ModelAPI_Data> theData)
 {
   ModelAPI_Result::setData(theData);
   if (theData) {
-    data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::type());
+    data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::typeId());
   }
 }
 
index 9618362e823e60de18874e85d6efd33650ca7035..e7f21bf88a8470860d5c3bfba731f94b743dc564 100644 (file)
@@ -19,6 +19,7 @@
 #include <Config_AttributeMessage.h>
 #include <Config_ValidatorMessage.h>
 #include <Config_ModuleReader.h>
+#include <Config_ValidatorReader.h>
 #include <ModelAPI_ResultPart.h>
 
 #include <TDF_CopyTool.hxx>
@@ -351,8 +352,15 @@ void Model_Session::LoadPluginsInfo()
     return;
 
   // Read plugins information from XML files
-  Config_ModuleReader aXMLReader(Config_FeatureMessage::MODEL_EVENT());
-  aXMLReader.readAll();
+  Config_ModuleReader aModuleReader(Config_FeatureMessage::MODEL_EVENT());
+  aModuleReader.readAll();
+  std::set<std::string> aFiles = aModuleReader.modulePluginFiles();
+  std::set<std::string>::iterator it = aFiles.begin();
+  for ( ; it != aFiles.end(); it++ ) {
+    Config_ValidatorReader aValidatorReader (*it);
+    aValidatorReader.readAll();
+  };
+
 }
 
 void Model_Session::registerPlugin(ModelAPI_Plugin* thePlugin)
index 1b1a3d626820cb2aa587b421d0e357f76c80d930..2390df8268e737bb4e0038bd0df4e4e4e38f58d6 100644 (file)
@@ -51,7 +51,8 @@ Model_Update::Model_Update()
 
   Config_PropManager::registerProp("Model update", "automatic_rebuild", "Rebuild immediately",
                                    Config_Prop::Bool, "false");
-  isAutomatic = Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
+  myIsAutomatic =
+    Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
 }
 
 void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessage)
@@ -67,24 +68,30 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
   static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
   bool isAutomaticChanged = false;
   if (theMessage->eventID() == kChangedEvent) { // automatic and manual rebuild flag is changed
-    bool aPropVal = 
-    Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
-    if (aPropVal == isAutomatic)
-      return;// nothing to
-    isAutomatic = aPropVal;
+    bool aPropVal =
+      Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
+    if (aPropVal == myIsAutomatic)
+      return; // nothing is changed, so nithing to do
+    myIsAutomatic = aPropVal;
+    if (!myIsAutomatic)
+      return; // less automatization => nothing to do
   } else if (theMessage->eventID() == kRebuildEvent) { // the rebuild command
-    if (isAutomatic == false) {
+    if (myIsAutomatic == false) {
       isAutomaticChanged = true;
-      isAutomatic = true;
+      myIsAutomatic = true;
     }
   } else if (theMessage->eventID() == kCreatedEvent || theMessage->eventID() == kUpdatedEvent ||
-    theMessage->eventID() == kMovedEvent) {
+             theMessage->eventID() == kMovedEvent) {
     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
     const std::set<ObjectPtr>& anObjs = aMsg->objects();
     std::set<ObjectPtr>::const_iterator anObjIter = anObjs.cbegin();
     for(; anObjIter != anObjs.cend(); anObjIter++) {
       myJustCreatedOrUpdated.insert(*anObjIter);
+      // created objects are always must be up to date (python box feature)
+      // and updated not in internal uptation chain
+      if (!myIsExecuted || theMessage->eventID() == kCreatedEvent)
+        myInitial.insert(*anObjIter);
       // TODO(mpv): check the next line. Came into dev 0.6.1 from BR_PYTHON_PLUGIN
       // (*anObjIter)->data()->mustBeUpdated(true); // object must be updated because it was changed
     }
@@ -92,11 +99,12 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
       return; // this event is for solver update, not here
   } else if (theMessage->eventID() == kOpStartEvent) {
     myJustCreatedOrUpdated.clear();
+    myInitial.clear();
     return; // we don't need the update only on operation start (caused problems in PartSet_Listener::processEvent)
   } else if (theMessage->eventID() == kOpFinishEvent || theMessage->eventID() == kOpAbortEvent) {
-    if (isAutomatic == false) { // Apply button now works as "Rebuild"
+    if (myIsAutomatic == false) { // Apply button now works as "Rebuild"
       isAutomaticChanged = true;
-      isAutomatic = true;
+      myIsAutomatic = true;
     }
     // the hardcode (DBC asked): hide the sketch referenced by extrusion on apply
     if (theMessage->eventID() == kOpFinishEvent) {
@@ -120,17 +128,11 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
     }
   }
 
-  if (isExecuted)
+  if (myIsExecuted)
     return;  // nothing to do: it is executed now
 
   //Events_LongOp::start(this);
-  isExecuted = true;
-  std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
-      std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
-  if (aMsg) myInitial = aMsg->objects();
-  else {
-    myInitial.clear();
-  }
+  myIsExecuted = true;
   // iterate all documents: features in Root first, then - subs
   updateInDoc(ModelAPI_Session::get()->moduleDocument());
 
@@ -139,13 +141,14 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
   static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
   aLoop->flush(EVENT_DISP);
   //Events_LongOp::end(this);
-  if (isAutomaticChanged) isAutomatic = false;
+  if (isAutomaticChanged) myIsAutomatic = false;
 
   if (theMessage->eventID() == kOpFinishEvent || theMessage->eventID() == kOpAbortEvent) {
     myJustCreatedOrUpdated.clear();
+    myInitial.clear();
   }
 
-  isExecuted = false;
+  myIsExecuted = false;
 }
 
 void Model_Update::updateInDoc(std::shared_ptr<ModelAPI_Document> theDoc)
@@ -248,7 +251,7 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
       if (std::dynamic_pointer_cast<Model_Document>(theFeature->document())->executeFeatures() ||
           !theFeature->isPersistentResult()) {
         if (aFactory->validate(theFeature)) {
-          if (isAutomatic || 
+          if (myIsAutomatic || 
               (myJustCreatedOrUpdated.find(theFeature) != myJustCreatedOrUpdated.end()) ||
               !theFeature->isPersistentResult() /* execute quick, not persistent results */) 
           {
@@ -256,7 +259,7 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
               //std::cout<<"Execute feature "<<theFeature->getKind()<<std::endl;
               // before execution update the selection attributes if any
               list<AttributePtr> aRefs = 
-                theFeature->data()->attributes(ModelAPI_AttributeSelection::type());
+                theFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
               list<AttributePtr>::iterator aRefsIter = aRefs.begin();
               for (; aRefsIter != aRefs.end(); aRefsIter++) {
                 std::shared_ptr<ModelAPI_AttributeSelection> aSel =
@@ -267,7 +270,7 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
                     aState = ModelAPI_StateInvalidArgument;
                 }
               }
-              aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelectionList::type());
+              aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelectionList::typeId());
               for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
                 std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
                   std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
index a9a7bfee82e50711e447953cac2d8df2e063a309..6e09dc7ad324f83d670c4315d0e6e55a036a65bb 100644 (file)
@@ -23,14 +23,15 @@ class ModelAPI_Feature;
  */
 class Model_Update : public Events_Listener
 {
-  /// initial set of updated features that must be processed
+  /// initial set of updated features that must be processed: caused by external changes, not
+  /// by sequence of update of this class
   std::set<std::shared_ptr<ModelAPI_Object> > myInitial;
   /// already updated and processed features and modificated feature flag
   std::map<std::shared_ptr<ModelAPI_Object>, bool> myUpdated;
   /// to know that all next updates are caused by this execution
-  bool isExecuted;
+  bool myIsExecuted;
   /// to know execute or not automatically all update
-  bool isAutomatic;
+  bool myIsAutomatic;
   /// just created features: they must be updated immideately even in not-automatic mode for 
   /// preview; cleared on commit operations
   std::set<std::shared_ptr<ModelAPI_Object> > myJustCreatedOrUpdated;
index bdf6c28e52b440c0161f3fd7a0010419d974c8d9..bd8cc724a39efec30c605993c166a9373e7bea5c 100644 (file)
@@ -9,8 +9,6 @@
 }
 
 %{
-  #include "GeomAPI_Interface.h"
-  #include "GeomAPI_Shape.h"
   #include "ModelAPI.h"
   #include "ModelAPI_Document.h"
   #include "ModelAPI_Session.h"
   #include "ModelAPI_ResultParameters.h"
   #include "ModelAPI_ResultGroup.h"
   #include "ModelAPI_Tools.h"
+
+  #include <memory>
+  #include <string>
   
   template<class T1, class T2> 
   std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject)
   { 
     return std::dynamic_pointer_cast<T1>(theObject); 
   }
-  
+
 %}
 
 // to avoid error on this
 #define MODELAPI_EXPORT
-#define GEOMAPI_EXPORT
 
 // standard definitions
+%include "GeomAPI.i"
 %include "typemaps.i"
 %include "std_string.i"
 %include "std_list.i"
 %feature("director") ModelAPI_Plugin;
 %feature("director") ModelAPI_Object;
 %feature("director") ModelAPI_Feature;
+%feature("director") ModelAPI_CompositeFeature;
+%feature("director") ModelAPI_Data;
 
 // shared pointers
 // For ModelAPI_ResultConstruction.shape()
-%shared_ptr(GeomAPI_Interface)
-%shared_ptr(GeomAPI_Shape)
 %shared_ptr(ModelAPI_Document)
 %shared_ptr(ModelAPI_Session)
 %shared_ptr(ModelAPI_Plugin)
@@ -97,8 +98,6 @@
 %shared_ptr(ModelAPI_ResultParameters)
 
 // all supported interfaces
-%include "GeomAPI_Interface.h"
-%include "GeomAPI_Shape.h"
 %include "ModelAPI_Document.h"
 %include "ModelAPI_Session.h"
 %include "ModelAPI_Plugin.h"
 
 // std::dynamic_pointer_cast
 template<class T1, class T2> std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject);
-%template(modelAPI_CompositeFeature) shared_ptr_cast<ModelAPI_CompositeFeature, ModelAPI_Feature>;
-%template(modelAPI_Feature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_Object>;
+%template(featureToCompositeFeature) shared_ptr_cast<ModelAPI_CompositeFeature, ModelAPI_Feature>;
+%template(objectToFeature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_Object>;
+%template(compositeFeatureToFeature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_CompositeFeature>;
 
 %template(modelAPI_Result) shared_ptr_cast<ModelAPI_Result, ModelAPI_Object>;
 %template(modelAPI_ResultConstruction) shared_ptr_cast<ModelAPI_ResultConstruction, ModelAPI_Result>;
index 722c14fcd743a1772ac36cf45cfdba9ec4d6509e..5f0eb921be21967b0303c546dd57c5cd4baf20a2 100644 (file)
@@ -8,7 +8,7 @@
 
 std::string ModelAPI_AttributeBoolean::attributeType()
 {
-  return type();
+  return typeId();
 }
 
 /// To virtually destroy the fields of successors
index 122ffa70fdf700a67eb5c653e32a94005ca3da9e..661a8ffea25263f6a738875e789a9e29335b7ce4 100644 (file)
@@ -24,7 +24,7 @@ class ModelAPI_AttributeBoolean : public ModelAPI_Attribute
   MODELAPI_EXPORT virtual bool value() = 0;
 
   /// Returns the type of this class of attributes
-  MODELAPI_EXPORT static std::string type()
+  MODELAPI_EXPORT static std::string typeId()
   {
     return "Boolean";
   }
index 69563831ac607a57a96c1480a6cd1d5002816815..bf71a47260e33565c3275b84dfc45efbc8f5522b 100644 (file)
@@ -8,7 +8,7 @@
 
 std::string ModelAPI_AttributeDocRef::attributeType()
 {
-  return type();
+  return typeId();
 }
 
 ModelAPI_AttributeDocRef::~ModelAPI_AttributeDocRef()
index b1149c7f3ff873ff41b0e33822ab325ee3bb933a..0772c9fc3eba1aaaf538ff1a422ea073bfff16ef 100644 (file)
@@ -25,7 +25,7 @@ class ModelAPI_AttributeDocRef : public ModelAPI_Attribute
   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> value() = 0;
 
   /// Returns the type of this class of attributes
-  MODELAPI_EXPORT static std::string type()
+  MODELAPI_EXPORT static std::string typeId()
   {
     return "DocRef";
   }
index 7847dfabd7a94b621210446a0541d426dcbc7f3a..3aa85ae70f261a1ebf0e3c4e4ab05f1ebd00f7d1 100644 (file)
@@ -8,7 +8,7 @@
 
 std::string ModelAPI_AttributeDouble::attributeType()
 {
-  return type();
+  return typeId();
 }
 
 ModelAPI_AttributeDouble::~ModelAPI_AttributeDouble()
index 498b4050901c7d0cdb4b54be64e5ebcf358684cf..291bc18831bc0e94509b34bd66356c0ee250a966 100644 (file)
@@ -24,7 +24,7 @@ class ModelAPI_AttributeDouble : public ModelAPI_Attribute
   MODELAPI_EXPORT virtual double value() = 0;
 
   /// Returns the type of this class of attributes
-  MODELAPI_EXPORT static std::string type()
+  MODELAPI_EXPORT static std::string typeId()
   {
     return "Double";
   }
index 0e0304c46eea0234ca6a9424e76a483c0e99e105..52d870d57478d3179859de5766fb6b36934a1a8a 100644 (file)
@@ -9,7 +9,7 @@
 
 std::string ModelAPI_AttributeIntArray::attributeType()
 {
-  return type();
+  return typeId();
 }
 
 /// To virtually destroy the fields of successors
index 177db0422378aae8e002e44da6690ce32f9fbb32..8b319a16d48ca75c8f6237a8f65071cb6157eb34 100644 (file)
@@ -37,7 +37,7 @@ class ModelAPI_AttributeIntArray : public ModelAPI_Attribute
   MODELAPI_EXPORT virtual int value(const int theIndex) = 0;
 
   /// Returns the type of this class of attributes
-  MODELAPI_EXPORT static std::string type()
+  MODELAPI_EXPORT static std::string typeId()
   {
     return "IntArray";
   }
index afb2376a97d29b867f86a752b3fb66b08d452b11..94849fb138cdc96fb31e5774b779184e5ae65bb0 100644 (file)
@@ -9,7 +9,7 @@
 
 std::string ModelAPI_AttributeInteger::attributeType()
 {
-  return type();
+  return typeId();
 }
 
 /// To virtually destroy the fields of successors
index c1bc9e6afec24f1ee67304c277ecfbeb9dd983fa..e683166d32179ffcc6c9a92b63a2c576d8fe985e 100644 (file)
@@ -28,7 +28,7 @@ class ModelAPI_AttributeInteger : public ModelAPI_Attribute
   MODELAPI_EXPORT virtual int value() = 0;
 
   /// Returns the type of this class of attributes
-  MODELAPI_EXPORT static std::string type()
+  MODELAPI_EXPORT static std::string typeId()
   {
     return "Integer";
   }
index 35bd2d74d1b7b597541e5c2fb2be050963a5bf6f..523f289824adee59be301b48c9305ab8a2b94f56 100644 (file)
@@ -10,7 +10,7 @@
 
 std::string ModelAPI_AttributeRefAttr::attributeType()
 {
-  return type();
+  return typeId();
 }
 
 ModelAPI_AttributeRefAttr::~ModelAPI_AttributeRefAttr()
index bd4c7c4f41615c840b2bb7e69366ae7de959cda3..2d2580ab7c5a4ca2b8285548a9ff10e0a063b0f2 100644 (file)
@@ -35,7 +35,7 @@ class ModelAPI_AttributeRefAttr : public ModelAPI_Attribute
   MODELAPI_EXPORT virtual ObjectPtr object() = 0;
 
   /// Returns the type of this class of attributes
-  MODELAPI_EXPORT static std::string type()
+  MODELAPI_EXPORT static std::string typeId()
   {
     return "RefAttr";
   }
index ded44b22ccc3ea50e97958905268dc1d916d382d..eaedcc07421f066a659d6079d7d49c60a2259663 100644 (file)
@@ -9,7 +9,7 @@
 
 std::string ModelAPI_AttributeRefList::attributeType()
 {
-  return type();
+  return typeId();
 }
 
 ModelAPI_AttributeRefList::~ModelAPI_AttributeRefList()
index 9384d2855215acefab356e10b75e32e0a259c357..12235c5b8586f68079cb757a2aef474ed9561996 100644 (file)
@@ -20,7 +20,7 @@ class ModelAPI_AttributeRefList : public ModelAPI_Attribute
 {
  public:
   /// Returns the type of this class of attributes
-  MODELAPI_EXPORT static std::string type()
+  MODELAPI_EXPORT static std::string typeId()
   {
     return "RefList";
   }
index 4c13608200c21acd8876e729a05fe083c5d5aa07..1eb90580f5faa49c3cebc664cb6253d237a4db7b 100644 (file)
@@ -8,7 +8,7 @@
 
 std::string ModelAPI_AttributeReference::attributeType()
 {
-  return type();
+  return typeId();
 }
 
 ModelAPI_AttributeReference::~ModelAPI_AttributeReference()
index c90d78fe71fb6968bf40d6565bfa35acba4e2e32..948debd230c84159d0d439e7e420e5232b46ee84 100644 (file)
@@ -25,7 +25,7 @@ class ModelAPI_AttributeReference : public ModelAPI_Attribute
   MODELAPI_EXPORT virtual ObjectPtr value() = 0;
 
   /// Returns the type of this class of attributes
-  MODELAPI_EXPORT static std::string type()
+  MODELAPI_EXPORT static std::string typeId()
   {
     return "Reference";
   }
index e5accc0ca348f20d9643de84d129e571660006d7..455e6322478cbe08e488eaf724358968f545be18 100644 (file)
@@ -10,7 +10,7 @@
 
 std::string ModelAPI_AttributeSelection::attributeType()
 {
-  return type();
+  return typeId();
 }
 
 ModelAPI_AttributeSelection::~ModelAPI_AttributeSelection()
index b2986b3bb3b6fa963fd15c0977cbfb8e96b1ebeb..495da4180492d8eb36b9d62ba4d6e7978e6bd698 100644 (file)
@@ -33,7 +33,7 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute
   virtual bool update() = 0;
 
   /// Returns the type of this class of attributes
-  static std::string type()
+  static std::string typeId()
   {
     return "Selection";
   }
index e88f4c7a8f43a87a64a772844f44d54b941f4bbf..a3b06f3ee58005c62e0097fbd56547f90c174de9 100644 (file)
@@ -9,7 +9,7 @@
 
 std::string ModelAPI_AttributeSelectionList::attributeType()
 {
-  return type();
+  return typeId();
 }
 
 ModelAPI_AttributeSelectionList::~ModelAPI_AttributeSelectionList()
index 19e888f15f8b9e86016b7aa95830275c2c0da495..170efc09add30ae8f178f5acd159e82701d8935c 100644 (file)
@@ -45,7 +45,7 @@ class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute
   virtual void clear() = 0;
 
   /// Returns the type of this class of attributes
-  static std::string type()
+  static std::string typeId()
   {
     return "SelectionList";
   }
index 19df8f5ddd2258493a50f7caf812faf3b0316537..3c647633bb8bb27d76c9e356c33c9228df1bd592 100644 (file)
@@ -9,7 +9,7 @@
 
 std::string ModelAPI_AttributeString::attributeType()
 {
-  return type();
+  return typeId();
 }
 
 ModelAPI_AttributeString::~ModelAPI_AttributeString()
index 26f4b4e8a5f1f3e4797873938d88a3b338a65eeb..b3e0ad0e298d0d5a2be046c8cb45519db55b5e67 100644 (file)
@@ -26,7 +26,7 @@ class ModelAPI_AttributeString : public ModelAPI_Attribute
   MODELAPI_EXPORT virtual std::string value() = 0;
 
   /// Returns the type of this class of attributes
-  MODELAPI_EXPORT static std::string type()
+  MODELAPI_EXPORT static std::string typeId()
   {
     return "String";
   }
index b08640fdaca719c62267526845c5dd7de5f5fa11..ef212d23f1b13559d4d89280821cbb1f7af06c88 100644 (file)
@@ -128,6 +128,7 @@ void ModelAPI_Feature::eraseResults()
     // flush it to avoid left presentations after input of invalid arguments (radius=0)
     static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
     Events_Loop::loop()->flush(anEvent);
+    Events_Loop::loop()->flush(EVENT_DISP);
   }
 }
 
index 0ef625cd74f04ea4831d65016c0857947b64c292..fb03f459fbacc878155c6b552d2a9c37d3f0898f 100644 (file)
@@ -20,7 +20,7 @@ bool ModelAPI_ShapeValidator::isValid(const AttributePtr& theAttribute,
   std::string aCurrentAttributeId = theAttribute->id();
   // get all feature attributes
   std::list<AttributePtr> anAttrs = 
-                   aFeature->data()->attributes(ModelAPI_AttributeSelection::type());
+      aFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
   if (anAttrs.size() > 0 && aShape.get() != NULL) {
     std::list<AttributePtr>::iterator anAttr = anAttrs.begin();
     for(; anAttr != anAttrs.end(); anAttr++) {
index fd851f31042303b71a63cd7925e873d1691ded77..c15375d72726aac12387d0a8fff9d3fafbfc6579 100644 (file)
@@ -3,8 +3,8 @@
 #===============================================================================
 from ModelAPI import *
 assert (ModelAPI_Feature.group() == "Features")
-assert (ModelAPI_AttributeDocRef.type() == "DocRef")
-assert (ModelAPI_AttributeDouble.type() == "Double")
-assert (ModelAPI_AttributeReference.type() == "Reference")
-assert (ModelAPI_AttributeRefAttr.type() == "RefAttr")
-assert (ModelAPI_AttributeRefList.type() == "RefList")
\ No newline at end of file
+assert (ModelAPI_AttributeDocRef.typeId() == "DocRef")
+assert (ModelAPI_AttributeDouble.typeId() == "Double")
+assert (ModelAPI_AttributeReference.typeId() == "Reference")
+assert (ModelAPI_AttributeRefAttr.typeId() == "RefAttr")
+assert (ModelAPI_AttributeRefList.typeId() == "RefList")
\ No newline at end of file
index feaac1c185dd8b835166443035733f2eb9fc9570..c9c49f76b6bb496814655ff129d626f82e356535 100644 (file)
@@ -56,6 +56,8 @@ Standard_Boolean ModuleBase_FilterNoConsructionSubShapes::IsOk(const Handle(Sele
           std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
         return aComposite && aComposite->numberOfSubs() > 0;
       }
+      else
+        return Standard_True;
     }
   }
   return Standard_False;
index 4b8c7d34bec1db0259ad11036dc3dffed806e207..ff2780957fc336c22171175d85433ee26ea824c0 100644 (file)
@@ -135,8 +135,17 @@ void ModuleBase_Operation::start()
   }
   ModelAPI_Session::get()->startOperation(anId.toStdString());
 
-  if (!myIsEditing)
-    createFeature();
+  if (!myIsEditing) {
+    FeaturePtr aFeature = createFeature();
+    // if the feature is not created, there is no sense to start the operation
+    if (aFeature.get() == NULL) {
+      // it is necessary to abor the operation in the session and emit the aborted signal
+      // in order to update commands status in the workshop, to be exact the feature action
+      // to be unchecked
+      abort();
+      return;
+    }
+  }
 
   startOperation();
   emit started();
index ef46fa06220feb56ad5b131594aab1b1d19ae299..c0e4faacff2ee5aa7af6fc1c1af5024f157dd20d 100644 (file)
@@ -423,6 +423,15 @@ bool ModuleBase_WidgetShapeSelector::setSelection(const Handle_SelectMgr_EntityO
     std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aIt;
     for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
       if ((*aIt) == aRes)
+// TODO(nds): v1.0.2 (master)
+//  // Check the acceptability of the object as attribute
+//  aValidator = aValidators.begin();
+//  std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
+//  for (; aValidator != aValidators.end(); aValidator++, aArgs++) {
+//    const ModelAPI_RefAttrValidator* aAttrValidator =
+//        dynamic_cast<const ModelAPI_RefAttrValidator*>(*aValidator);
+//    if (aAttrValidator) {
+//      if (!aAttrValidator->isValid(myFeature, *aArgs, theObj, theShape)) {
         return false;
     }
   }
index 9ce081a007afb21f7c20b454d6b3b4307e7a75ef..7b1574183d7dce393e3870e0d5352010cfafe84e 100644 (file)
@@ -23,7 +23,7 @@
     <!-- Major module parameters -->
     <parameter name="name" value="NewGeom"/>
     <parameter name="icon" value="newgeom.png"/>
-    <parameter name="version" value="1.0.0"/>
+    <parameter name="version" value="1.0.2"/>
     <parameter name="documentation" value="newgeom_help"/>
   </section>
   <section name="newgeom_help" >
index 2bec8495515fdb6e2bb1fb7bf7a3d55dcce08062..1c8b9e477bbc1eca2cb0b7b37c32b7e9791549b5 100644 (file)
@@ -27,7 +27,7 @@
     <!-- Major module parameters -->
     <parameter name="name" value="NewGeom"/>
     <parameter name="icon" value="newgeom.png"/>
-    <parameter name="version" value="1.0.0"/>
+    <parameter name="version" value="1.0.2"/>
     <parameter name="documentation" value="newgeom_help"/>
   </section>
   <section name="newgeom_help" >
index 498b83d9a65c1583aa2766838d52635d17f6e64d..c3d72d272cb2997402be0256a4283f7f1e6d54d8 100644 (file)
@@ -13,8 +13,8 @@ ParametersPlugin_Parameter::ParametersPlugin_Parameter()
 
 void ParametersPlugin_Parameter::initAttributes()
 {
-  data()->addAttribute(ParametersPlugin_Parameter::VARIABLE_ID(), ModelAPI_AttributeString::type());
-  data()->addAttribute(ParametersPlugin_Parameter::EXPRESSION_ID(), ModelAPI_AttributeString::type());
+  data()->addAttribute(ParametersPlugin_Parameter::VARIABLE_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(ParametersPlugin_Parameter::EXPRESSION_ID(), ModelAPI_AttributeString::typeId());
 }
 
 void ParametersPlugin_Parameter::execute()
index bdbc48c5208fccb1cd8dc26216aa923d43269dc8..486a87511a898f1940ee9577138051bf1f42774d 100644 (file)
@@ -47,6 +47,7 @@ SET(PROJECT_LIBRARIES
     Config
     GeomAPI
     GeomValidators
+    GeomDataAPI
     ${QT_LIBRARIES}
     ${CAS_KERNEL}
     ${CAS_SHAPE}
index f7c4ab57f0c6fde0261324b1410766d0acf8a20b..a92364d0594b30c0c7d950c77e94bfc4995f720a 100644 (file)
@@ -222,7 +222,7 @@ std::shared_ptr<GeomDataAPI_Point2D> PartSet_Tools::getFeaturePoint(FeaturePtr t
   std::shared_ptr<GeomAPI_Pnt2d> aClickedPoint = std::shared_ptr<GeomAPI_Pnt2d>(
                                                                  new GeomAPI_Pnt2d(theX, theY));
   std::list<std::shared_ptr<ModelAPI_Attribute> > anAttiributes =
-                                    theFeature->data()->attributes(GeomDataAPI_Point2D::type());
+                                    theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
   std::list<std::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
                                                                     aLast = anAttiributes.end();
   std::shared_ptr<GeomDataAPI_Point2D> aFPoint;
@@ -321,7 +321,7 @@ std::shared_ptr<GeomDataAPI_Point2D> PartSet_Tools::
   for (int i = 0; i < theSketch->numberOfSubs(); i++) {
     FeaturePtr aFeature = theSketch->subFeature(i);
     if (!theIgnore.contains(aFeature)) {
-      anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::type());
+      anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
 
       std::list<std::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt;
       for (anIt = anAttiributes.cbegin(); anIt != anAttiributes.cend(); ++anIt) {
@@ -366,7 +366,7 @@ void PartSet_Tools::setConstraints(CompositeFeaturePtr theSketch, FeaturePtr the
     if (theFeature == aFeature)
       continue;
     // find the given point in the feature attributes
-    anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::type());
+    anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
     std::list<std::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
         aLast = anAttiributes.end();
     std::shared_ptr<GeomDataAPI_Point2D> aFPoint;
@@ -624,7 +624,7 @@ AttributePtr PartSet_Tools::findAttributeBy2dPoint(ObjectPtr theObj,
 
         // find the given point in the feature attributes
         std::list<AttributePtr> anAttiributes = 
-          aFeature->data()->attributes(GeomDataAPI_Point2D::type());
+          aFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
         std::list<AttributePtr>::const_iterator anIt = anAttiributes.begin(), 
                                                 aLast = anAttiributes.end();
         for (; anIt != aLast && !anAttribute; anIt++) {
index 85b0dd3eca700f983f09cbb2d8d32fabdfe70932..0e2ca6f20592abd11060e753f01e1273f1cf504a 100644 (file)
@@ -143,7 +143,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
     if (featureHasReferences(theAttribute)) {
       // 3. check whether the attribute value is not among other feature attributes
       std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs = 
-        aFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
+        aFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
       std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
       for(; anAttr != anAttrs.end(); anAttr++) {
         if (*anAttr) {
@@ -153,6 +153,58 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
           if (!aRef->isObject() && aRef->attr() == theAttribute)
             return false;
         }
+// TODO(nds) v1.0.2 master
+//bool PartSet_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
+//                                                const std::list<std::string>& theArguments,
+//                                                const ObjectPtr& theObject,
+//                                                const GeomShapePtr& theShape) const
+//{
+//  // Check RefAttr attributes
+//  std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs =
+//    theFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
+//  if (anAttrs.size() > 0) {
+//    std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+//    for(; anAttr != anAttrs.end(); anAttr++) {
+//      if (*anAttr) {
+//        std::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
+//          std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
+//        // check the object is already presented
+//        if (aRef->isObject() && aRef->object() == theObject)
+//          return false;
+//      }
+//    }
+//  }
+//  // Check selection attributes
+//  anAttrs = theFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
+//  if (anAttrs.size() > 0) {
+//    std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+//    for(; anAttr != anAttrs.end(); anAttr++) {
+//      if (*anAttr) {
+//        std::shared_ptr<ModelAPI_AttributeSelection> aRef =
+//          std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*anAttr);
+//        // check the object is already presented
+//        if (aRef->isInitialized() && aRef->context() == theObject) {
+//          if (theShape.get() != NULL) {
+//            if (aRef->value()->isEqual(theShape))
+//              return false;
+//          } else
+//            return false;
+//        }
+//      }
+//    }
+//  }
+//  // Check selection attributes
+//  anAttrs = theFeature->data()->attributes(ModelAPI_AttributeReference::typeId());
+//  if (anAttrs.size() > 0) {
+//    std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+//    for(; anAttr != anAttrs.end(); anAttr++) {
+//      if (*anAttr) {
+//        std::shared_ptr<ModelAPI_AttributeReference> aRef =
+//          std::dynamic_pointer_cast<ModelAPI_AttributeReference>(*anAttr);
+//        // check the object is already presented
+//        if (aRef->isInitialized() && aRef->value() == theObject)
+//          return false;
+// ======= end of todo
       }
       return true;
     }
@@ -161,6 +213,32 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
 }
 
 bool PartSet_DifferentObjectsValidator::featureHasReferences(const AttributePtr& theAttribute) const
+// TODO(nds) v1.0.2 master
+//bool PartSet_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
+//                                                const std::list<std::string>& theArguments,
+//                                                const AttributePtr& theAttribute) const
+//{
+//  if (PartSet_DifferentObjectsValidator::isValid(theAttribute, theArguments)) {
+//    std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs =
+//      theFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
+//    std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+//    for(; anAttr != anAttrs.end(); anAttr++) {
+//      if (*anAttr) {
+//        std::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
+//          std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
+//        // check the object is already presented
+//        if (!aRef->isObject() && aRef->attr() == theAttribute)
+//          return false;
+//      }
+//    }
+//    return true;
+//  }
+//  return false;
+//}
+//
+//bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute,
+//                                                const std::list<std::string>& theArguments) const
+// ======= end of todo
 {
   std::list<std::pair<std::string, std::list<ObjectPtr> > > allRefs;
   if (theAttribute->owner().get() && theAttribute->owner()->data().get())
@@ -201,7 +279,7 @@ bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
   }
 
   std::string anAttributeType = theAttribute->attributeType();
-  if (anAttributeType == ModelAPI_AttributeSelectionList::type()) {
+  if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
     AttributeSelectionListPtr aSelectionListAttr = 
                       std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
     // it filters only selection list attributes
@@ -215,7 +293,7 @@ bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
       isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
     }
   }
-  if (anAttributeType == ModelAPI_AttributeRefAttr::type()) {
+  if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) {
     std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
                      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
     isSketchEntities = false;
index 389cc4fa20def49b2048b0aa4707063d680465a1..02e73de5fd0308875f827dcb3d1c4a14dd1ffdca 100644 (file)
@@ -72,6 +72,22 @@ class PartSet_RigidValidator : public ModuleBase_SelectionValidator
 class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator
 {
  public:
+// TODO(nds) v1.0.2 master
+//   /// Returns True if the feature is valid
+//   /// \param theFeature a feature to check
+//   /// \param theArguments a list of arguments (names of attributes to check)
+//   /// \param theObject a selected object
+//   /// \param theShape a selected sub-shape
+//  virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+//                       const ObjectPtr& theObject, const GeomShapePtr& theShape) const;
+//
+//  //! Returns true if the attribute is good for the feature attribute
+//  //! \param theFeature a feature to check
+//  //! \param theArguments a list of arguments (names of attributes to check)
+//  //! \param theAttribute an attribute
+//  virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+//                       const AttributePtr& theAttribute) const;
+  // ======= end of todo
   //! Returns true if the attribute is good for the feature attribute
   //! \param theAttribute an attribute
   //! \param theArguments a list of arguments (names of attributes to check)
@@ -104,4 +120,4 @@ class PartSet_SketchEntityValidator : public ModelAPI_AttributeValidator
                        const std::list<std::string>& theArguments) const;
 };
 
-#endif
\ No newline at end of file
+#endif
index 578e1cdf9b7a7e7bc38d7919e96ce9d038635bd2..98c25d47b1dc4eda49d7e3e2af954673bc2ad324 100644 (file)
@@ -111,6 +111,40 @@ void PartSet_WidgetShapeSelector::createExternal(ObjectPtr theSelectedObject,
   if (aObj != myExternalObject) {
     removeExternal();
     myExternalObject = aObj;
+// TODO(nds) v1.0.2 master
+//  // Check the acceptability of the object and shape as validator attribute
+//  AttributePtr aPntAttr;
+//  DataPtr aData = myFeature->data();
+//  if (theShape.get() != NULL) {
+//    AttributePtr aAttr = aData->attribute(attributeID());
+//    AttributeRefAttrPtr aRefAttr =
+//      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aAttr);
+//    if (aRefAttr) {
+//      TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+//      aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theObj, aShape, mySketch);
+//    }
+//  }
+//  // Check the acceptability of the object as attribute
+//  aValidator = aValidators.begin();
+//  std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
+//  for (; aValidator != aValidators.end(); aValidator++, aArgs++) {
+//    const ModelAPI_RefAttrValidator* aAttrValidator =
+//        dynamic_cast<const ModelAPI_RefAttrValidator*>(*aValidator);
+//    if (aAttrValidator) {
+//      if (aPntAttr.get() != NULL)
+//      {
+//        if (!aAttrValidator->isValid(myFeature, *aArgs, aPntAttr)) {
+//          return false;
+//        }
+//      }
+//      else
+//      {
+//        if (!aAttrValidator->isValid(myFeature, *aArgs, theObj, theShape)) {
+//          return false;
+//        }
+//      }
+//    }
+// ======= end of todo
   }
 }
 
diff --git a/src/PythonFeaturesPlugin/CMakeLists.txt b/src/PythonFeaturesPlugin/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1e600b3
--- /dev/null
@@ -0,0 +1,17 @@
+INCLUDE(Common)
+
+SET(PYTHON_FILES
+  PythonFeaturesPlugin_Box.py
+  PythonFeaturesPlugin.py
+  sketch.py
+  extrusion.py
+  examples.py
+  SketchResult.py
+)
+
+SET(XML_RESSOURCES
+  plugin-PythonFeatures.xml
+  box_widget.xml
+)
+
+INSTALL(FILES ${PYTHON_FILES} ${XML_RESSOURCES} DESTINATION plugins)
diff --git a/src/PythonFeaturesPlugin/FeaturesAPI.py b/src/PythonFeaturesPlugin/FeaturesAPI.py
new file mode 100644 (file)
index 0000000..f47ba3f
--- /dev/null
@@ -0,0 +1,47 @@
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+
+# NOTE : I think this style should be chosen
+# for function as recommended by Python programming
+# standards
+
+
+def build_face_from_sketch(sketch, edges=None):
+    # If no edges have been selected, get the whole sketch
+    # edges
+    if edges == None:
+        result = sketch.firstResult()
+        edges = modelAPI_ResultConstruction(result).shape()
+
+    # Build the face
+    origin = geomDataAPI_Point(sketch.attribute("Origin")).pnt()
+    dirX = geomDataAPI_Dir(sketch.attribute("DirX")).dir()
+    dirY = geomDataAPI_Dir(sketch.attribute("DirY")).dir()
+    normal = geomDataAPI_Dir(sketch.attribute("Norm")).dir()
+    faces = ShapeList()
+    GeomAlgoAPI_SketchBuilder.createFaces(
+        origin, dirX, dirY, normal, edges, faces)
+    return faces[0]
+
+# NOTE : with an optional argument it is not
+# a so good idea to put part as last argument
+# it would result in a mandatory argument
+# put after an optionnal one
+
+
+def addExtrusion(part, sketch, size, reverse=False, subshapes=None):
+    feature = part.addFeature("Extrusion")
+
+    # Build apropriate face
+    face = build_face_from_sketch(sketch, subshapes)
+    # Get sketch result
+    sketchResult = sketch.firstResult()
+
+    # Set attributes and execute the feature
+    feature.selection("extrusion_face").setValue(sketchResult, face)
+    feature.real("extrusion_size").setValue(size)
+    feature.boolean("extrusion_reverse").setValue(False)
+    feature.execute()
+
+    return feature
diff --git a/src/PythonFeaturesPlugin/PythonFeaturesPlugin.py b/src/PythonFeaturesPlugin/PythonFeaturesPlugin.py
new file mode 100644 (file)
index 0000000..890b3ae
--- /dev/null
@@ -0,0 +1,27 @@
+"""
+"""
+
+import ModelAPI
+from PythonFeaturesPlugin_Box import PythonFeaturesPlugin_Box
+
+
+class PythonFeaturesPlugin(ModelAPI.ModelAPI_Plugin):
+
+    def __init__(self):
+        ModelAPI.ModelAPI_Plugin.__init__(self)
+        aSession = ModelAPI.ModelAPI_Session.get()
+        aSession.registerPlugin(self)
+        pass
+
+    def createFeature(self, theFeatureID):
+        aFeature = None
+        if theFeatureID == PythonFeaturesPlugin_Box.ID():
+            aCompositeFeature = PythonFeaturesPlugin_Box().__disown__()
+            aFeature = ModelAPI.compositeFeatureToFeature(aCompositeFeature)
+        else:
+            raise StandardError("No such feature %s" % theFeatureID)
+        return aFeature
+
+
+plugin = PythonFeaturesPlugin()
+plugin.__disown__()
diff --git a/src/PythonFeaturesPlugin/PythonFeaturesPlugin_Box.py b/src/PythonFeaturesPlugin/PythonFeaturesPlugin_Box.py
new file mode 100644 (file)
index 0000000..fd56863
--- /dev/null
@@ -0,0 +1,170 @@
+import ModelAPI
+
+from SketchResult import SketchResult
+import extrusion
+import sketch
+
+
+class PythonFeaturesPlugin_Box(ModelAPI.ModelAPI_CompositeFeature):
+    """Feature to create a box by drawing a sketch and extruding it
+    """
+
+    def __init__(self):
+        ModelAPI.ModelAPI_CompositeFeature.__init__(self)
+
+    @staticmethod
+    def ID():
+        return "Box"
+
+    @staticmethod
+    def WIDTH_ID():
+        return "box_width"
+
+    @staticmethod
+    def LENGTH_ID():
+        return "box_length"
+
+    @staticmethod
+    def HEIGHT_ID():
+        return "box_height"
+
+    @staticmethod
+    def WIDTH_REF_ID():
+        return "box_ref_width"
+
+    @staticmethod
+    def LENGTH_REF_ID():
+        return "box_ref_length"
+
+    @staticmethod
+    def HEIGHT_REF_ID():
+        return "box_ref_height"
+
+    def getKind(self):
+        return PythonFeaturesPlugin_Box.ID()
+
+    def initAttributes(self):
+        # C++ static methods (in example "type()" of the ModelAPI_AttributeDouble
+        # should be called like this: moduleName.ClassName_staticMethod()
+        self.data().addAttribute(self.WIDTH_ID(), ModelAPI.ModelAPI_AttributeDouble_typeId())
+        self.data().addAttribute(self.LENGTH_ID(), ModelAPI.ModelAPI_AttributeDouble_typeId())
+        self.data().addAttribute(self.HEIGHT_ID(), ModelAPI.ModelAPI_AttributeDouble_typeId())
+        self.data().addAttribute(self.WIDTH_REF_ID(), ModelAPI.ModelAPI_AttributeReference_typeId())
+        self.data().addAttribute(self.LENGTH_REF_ID(), ModelAPI.ModelAPI_AttributeReference_typeId())
+        self.data().addAttribute(self.HEIGHT_REF_ID(), ModelAPI.ModelAPI_AttributeReference_typeId())
+        aSession = ModelAPI.ModelAPI_Session.get()
+        aSession.validators().registerNotObligatory(self.getKind(), self.WIDTH_REF_ID())
+        aSession.validators().registerNotObligatory(self.getKind(), self.LENGTH_REF_ID())
+        aSession.validators().registerNotObligatory(self.getKind(), self.HEIGHT_REF_ID())
+        aSession.validators().registerConcealment(self.getKind(), self.HEIGHT_REF_ID())
+        self.mySketch = None  # not yet initialized
+        self.myExtrusion = None  # not yet initialized
+
+    def execute(self):
+        aWidth = self.real(self.WIDTH_ID()).value()
+        aLength = self.real(self.LENGTH_ID()).value()
+        aHeight = self.real(self.HEIGHT_ID()).value()
+        aWidthRefValue = self.reference(self.WIDTH_REF_ID()).value()
+        aLengthRefValue = self.reference(self.LENGTH_REF_ID()).value()
+        aHeightRefValue = self.reference(self.HEIGHT_REF_ID()).value()
+        aResult = None
+        if not all((aWidthRefValue, aLengthRefValue, aHeightRefValue)):
+            aResult = extrusion.getBody(self.makeBox(aLength, aWidth, aHeight))
+        else:
+            aHeightProxyResult = ModelAPI.modelAPI_Result(aHeightRefValue)
+            aWidthFeature = ModelAPI.objectToFeature(aWidthRefValue)
+            aLengthFeature = ModelAPI.objectToFeature(aLengthRefValue)
+            aHeightResult = ModelAPI.modelAPI_ResultBody(aHeightProxyResult)
+            aWidthFeature.real("ConstraintValue").setValue(aWidth)
+            aLengthFeature.real("ConstraintValue").setValue(aLength)
+            if aHeightResult is not None:
+                aHeightFeature = aHeightResult.document().feature(aHeightResult)
+                aHeightFeature.real("extrusion_size").setValue(aHeight)
+                aResult = extrusion.getBody(aHeightFeature)
+        # create a new result with copied shape from extrusion
+        aResultBody = self.document().createBody(self.data())
+        if not aResult is None:
+            aResultBody.store(aResult.shape())
+            self.setResult(aResultBody)
+        pass
+
+    def makeBox(self, aWidth, aLength, aHeight):
+        aSession = ModelAPI.ModelAPI_Session.get()
+        aPart = aSession.activeDocument()
+        # Starting the Sketch
+        aSketch = sketch.addTo(aPart)
+        self.mySketch = aSketch
+        sketch.setXOYPlane(aSketch)
+        # Creating the lines
+        l1 = sketch.addLine(10, 10, 10, 60, aSketch)
+        l2 = sketch.addLine(10, 60, 60, 60, aSketch)
+        l3 = sketch.addLine(60, 60, 60, 10, aSketch)
+        l4 = sketch.addLine(60, 10, 10, 10, aSketch)
+        aSketch.execute()
+        # Creating the constraints
+        sketch.makeCoincident(sketch.getEndPoint(l1), sketch.getStartPoint(l2), aSketch)
+        sketch.makeCoincident(sketch.getEndPoint(l2), sketch.getStartPoint(l3), aSketch)
+        sketch.makeCoincident(sketch.getEndPoint(l3), sketch.getStartPoint(l4), aSketch)
+        sketch.makeCoincident(sketch.getEndPoint(l4), sketch.getStartPoint(l1), aSketch)
+        sketch.makeParallel(sketch.getGeometry(l1), sketch.getGeometry(l3), aSketch)
+        sketch.makeParallel(sketch.getGeometry(l2), sketch.getGeometry(l4), aSketch)
+        sketch.makePerpendicular(sketch.getGeometry(l1), sketch.getGeometry(l4), aSketch)
+        # Set to 0X and 0Y lines defined length
+        aWidthFeature = sketch.makeConstantLength(sketch.getGeometry(l4), aWidth, aSketch)
+        aLengthFeature = sketch.makeConstantLength(sketch.getGeometry(l1), aLength, aSketch)
+        # Finalisation of the operation
+        builder = SketchResult(aSketch)
+        # Creating a feature Extrusion
+        aHeightFeature = extrusion.addNew(builder, aHeight, aPart)
+        self.myExtrusion = aHeightFeature
+        # Store features...
+        self.reference(self.WIDTH_REF_ID()).setValue(aWidthFeature)
+        self.reference(self.LENGTH_REF_ID()).setValue(aLengthFeature)
+        self.reference(self.HEIGHT_REF_ID()).setValue(aHeightFeature.firstResult())
+        return aHeightFeature
+
+    def addFeature(self, theID):
+        pass
+
+    def numberOfSubs(self):
+        subsCount = 0
+        if not self.mySketch is None:
+            subsCount += 1
+        if not self.myExtrusion is None:
+            subsCount += 1
+        # extrusion and sketch
+        return subsCount
+
+    def subFeature(self, theIndex):
+        if theIndex == 0: # sketch
+            return ModelAPI.compositeFeatureToFeature(self.mySketch)
+        return self.myExtrusion
+
+    def subFeatureId(self, theIndex):
+        return 0
+
+    def isSub(self, theFeature):
+        return theFeature == self.mySketch or theFeature == self.myExtrusion
+
+    def attributeChanged(self, theAttrID):
+        # on update of attributes values, transfer them to sub-features immideately to see good preview
+        # otherwise these features will be executed before execute of "Box" and with old parameters
+        aWidthRefValue = self.reference(self.WIDTH_REF_ID()).value()
+        aLengthRefValue = self.reference(self.LENGTH_REF_ID()).value()
+        aHeightRefValue = self.reference(self.HEIGHT_REF_ID()).value()
+        if all((aWidthRefValue, aLengthRefValue, aHeightRefValue)):
+          self.execute()
+
+# TEST
+"""
+if __name__=='__main__':
+  session = ModelAPI.ModelAPI_Session.get()
+  part = session.activeDocument()
+  session.startOperation()
+  feature = part.addFeature('Box')
+  feature.real('box_width').setValue(10)
+  feature.real('box_length').setValue(10)
+  feature.real('box_height').setValue(10)
+  feature.execute()
+  session.finishOperation()
+"""
diff --git a/src/PythonFeaturesPlugin/SketchResult.py b/src/PythonFeaturesPlugin/SketchResult.py
new file mode 100644 (file)
index 0000000..8d8b77a
--- /dev/null
@@ -0,0 +1,26 @@
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+
+
+class SketchResult:
+
+    def __init__(self, sketch):
+        self.geom = sketch.firstResult()
+        self.faces = ShapeList()
+        self.edges = modelAPI_ResultConstruction(self.geom).shape()
+        self.origin = geomDataAPI_Point(sketch.attribute("Origin")).pnt()
+        self.dirX = geomDataAPI_Dir(sketch.attribute("DirX")).dir()
+        self.dirY = geomDataAPI_Dir(sketch.attribute("DirY")).dir()
+        self.normal = geomDataAPI_Dir(sketch.attribute("Norm")).dir()
+
+    def setEdges(self, edges):
+        self.edges = edges
+
+    def geometry(self):
+        return self.geom
+
+    def face(self):
+        GeomAlgoAPI_SketchBuilder.createFaces(
+            self.origin, self.dirX, self.dirY, self.normal, self.edges, self.faces)
+        return self.faces[0]
diff --git a/src/PythonFeaturesPlugin/box_widget.xml b/src/PythonFeaturesPlugin/box_widget.xml
new file mode 100644 (file)
index 0000000..7c1a2c5
--- /dev/null
@@ -0,0 +1,11 @@
+<source>
+  <doublevalue id="box_width" label="Width" min="0" step="1.0" default="50" icon=":icons/dimension_v.png" tooltip="Set width of the box">
+    <validator id="GeomValidators_Positive"/>
+  </doublevalue>
+  <doublevalue id="box_length" label="Length" min="0" step="1.0" default="50" icon=":icons/dimension_v.png" tooltip="Set length of the box">
+    <validator id="GeomValidators_Positive"/>
+  </doublevalue>
+  <doublevalue id="box_height" label="Height" min="0" step="1.0" default="50" icon=":icons/dimension_v.png" tooltip="Set height of the box">
+    <validator id="GeomValidators_Positive"/>
+  </doublevalue>
+</source>
diff --git a/src/PythonFeaturesPlugin/examples.py b/src/PythonFeaturesPlugin/examples.py
new file mode 100644 (file)
index 0000000..9f68e92
--- /dev/null
@@ -0,0 +1,51 @@
+from ModelAPI import *
+from SketchResult import *
+import sketch
+import extrusion
+# reload(sketch) # Pour tester plus facilement
+# reload(extrusion) # Pour tester plus facilement
+
+
+def makeBox(aLength, aWidth, aHeight):
+    # Getting the active document
+    session = ModelAPI_Session.get()
+    part = session.activeDocument()
+
+    # Starting the Sketch
+    base = sketch.addTo(part)
+    sketch.setXOYPlane(base)
+
+    # Creating the lines
+    l1 = sketch.addLine(10, 10, 10, 50, base)
+    l2 = sketch.addLine(10, 50, 60, 60, base)
+    l3 = sketch.addLine(60, 60, 50, 10, base)
+    l4 = sketch.addLine(50, 10, 10, 10, base)
+    base.execute()
+
+    # Creating the constraints
+    sketch.makeCoincident(sketch.getEndPoint(l1),
+                          sketch.getStartPoint(l2), base)
+    sketch.makeCoincident(sketch.getEndPoint(l2),
+                          sketch.getStartPoint(l3), base)
+    sketch.makeCoincident(sketch.getEndPoint(l3),
+                          sketch.getStartPoint(l4), base)
+    sketch.makeCoincident(sketch.getEndPoint(l4),
+                          sketch.getStartPoint(l1), base)
+
+    sketch.makeParallel(sketch.getGeometry(l1), sketch.getGeometry(l3), base)
+    sketch.makeParallel(sketch.getGeometry(l2), sketch.getGeometry(l4), base)
+
+    sketch.makePerpendicular(sketch.getGeometry(l1),
+                             sketch.getGeometry(l4), base)
+    # Set to 0X and 0Y lines defined length
+    sketch.makeConstantLength(sketch.getGeometry(l1), aLength, base)
+    sketch.makeConstantLength(sketch.getGeometry(l4), aWidth, base)
+
+    # Finalisation of the operation
+    builder = SketchResult(base)
+
+    # Creating a feature Extrusion
+    box = extrusion.addNew(builder, aHeight, part)
+
+    # return base.lastResult()
+    return extrusion.getBody(box)
diff --git a/src/PythonFeaturesPlugin/extrusion.py b/src/PythonFeaturesPlugin/extrusion.py
new file mode 100644 (file)
index 0000000..225bd9e
--- /dev/null
@@ -0,0 +1,17 @@
+from ModelAPI import *
+
+
+def addNew(builder, length, part, edges=None, reverse=False):
+    feature = part.addFeature("Extrusion")
+    feature.selection("extrusion_face").setValue(builder.geometry(),
+                                                 builder.face())
+    if length < 0.0000001:
+      length = 50
+    feature.real("extrusion_size").setValue(length)
+    feature.boolean("extrusion_reverse").setValue(reverse)
+    feature.execute()
+    return feature
+
+
+def getBody(extrusion):
+    return modelAPI_ResultBody(extrusion.firstResult())
diff --git a/src/PythonFeaturesPlugin/plugin-PythonFeatures.xml b/src/PythonFeaturesPlugin/plugin-PythonFeatures.xml
new file mode 100644 (file)
index 0000000..2f7b97b
--- /dev/null
@@ -0,0 +1,9 @@
+<plugin>
+  <workbench id="Features" document="Part">
+    <group id="Basic">
+      <feature id="Box" title="Box" tooltip="Create a box" icon=":pictures/part_ico.png">
+          <source path="box_widget.xml"/>
+      </feature>
+    </group>
+  </workbench>  
+</plugin>
diff --git a/src/PythonFeaturesPlugin/sketch.py b/src/PythonFeaturesPlugin/sketch.py
new file mode 100644 (file)
index 0000000..39475c0
--- /dev/null
@@ -0,0 +1,134 @@
+from ModelAPI import *
+from GeomDataAPI import *
+
+
+# Initialization of the Sketch
+# ----------------------------
+
+def addTo(doc):
+    return featureToCompositeFeature(doc.addFeature("Sketch"))
+
+
+def setXOYPlane(sketch):
+    geomDataAPI_Point(sketch.attribute("Origin")).setValue(0, 0, 0)
+    geomDataAPI_Dir(sketch.attribute("DirX")).setValue(1, 0, 0)
+    geomDataAPI_Dir(sketch.attribute("DirY")).setValue(0, 1, 0)
+    geomDataAPI_Dir(sketch.attribute("Norm")).setValue(0, 0, 1)
+
+
+# Point geometry
+# --------------
+
+def addPoint(x, y, sketch):
+    point = sketch.addFeature("SketchPoint")
+    geomDataAPI_Point2D(point.attribute("PointCoordindates")).setValue(x, y)
+    # Required to get the result, if needed for creating constraints
+    point.execute()
+    return point
+
+
+def getGeometry(point):
+    return geomDataAPI_Point2D(point.attribute("PointCoordindates"))
+
+
+# Line geometry
+# -------------
+
+def addClosedBrokenLine(coords, sketch):
+    c0 = coords[0]
+    c1 = coords[1]
+    bl = []
+    l1 = sketch.addFeature("SketchLine")
+    geomDataAPI_Point2D(l1.attribute("StartPoint")).setValue(c0.x(), c0.y())
+    geomDataAPI_Point2D(l1.attribute("EndPoint")).setValue(c1.x(), c1.y())
+    l1.execute()
+    bl.append(l1)
+    l0 = l1
+
+    for c2 in coords[2:]:
+        l2 = sketch.addFeature("SketchLine")
+        geomDataAPI_Point2D(
+            l2.attribute("StartPoint")).setValue(c1.x(), c1.y())
+        geomDataAPI_Point2D(l2.attribute("EndPoint")).setValue(c2.x(), c2.y())
+        l2.execute()
+        bl.append(l2)
+        constraint = sketch.addFeature("SketchConstraintCoincidence")
+        constraint.refattr("ConstraintEntityA").setAttr(
+            l1.attribute("EndPoint"))
+        constraint.refattr("ConstraintEntityB").setAttr(
+            l2.attribute("StartPoint"))
+        c1 = c2
+        l1 = l2
+
+    if len(coords) > 2:
+        l2 = sketch.addFeature("SketchLine")
+        geomDataAPI_Point2D(
+            l2.attribute("StartPoint")).setValue(c1.x(), c1.y())
+        geomDataAPI_Point2D(l2.attribute("EndPoint")).setValue(c0.x(), c0.y())
+        l2.execute()
+        bl.append(l2)
+        constraint = sketch.addFeature("SketchConstraintCoincidence")
+        constraint.refattr("ConstraintEntityA").setAttr(
+            l1.attribute("EndPoint"))
+        constraint.refattr("ConstraintEntityB").setAttr(
+            l2.attribute("StartPoint"))
+
+        constraint = sketch.addFeature("SketchConstraintCoincidence")
+        constraint.refattr("ConstraintEntityA").setAttr(
+            l2.attribute("EndPoint"))
+        constraint.refattr("ConstraintEntityB").setAttr(
+            l0.attribute("StartPoint"))
+
+    return bl
+
+
+def addLine(x1, y1, x2, y2, sketch):
+    line = sketch.addFeature("SketchLine")
+    geomDataAPI_Point2D(line.attribute("StartPoint")).setValue(x1, y1)
+    geomDataAPI_Point2D(line.attribute("EndPoint")).setValue(x2, y2)
+    # Required to get the result, if needed for creating constraints
+    line.execute()
+    return line
+
+
+def getGeometry(line):
+    return modelAPI_ResultConstruction(line.firstResult())
+
+
+def getStartPoint(line):
+    return geomDataAPI_Point2D(line.attribute("StartPoint"))
+
+
+def getEndPoint(line):
+    return geomDataAPI_Point2D(line.attribute("EndPoint"))
+
+
+# Constraints
+# -----------
+
+def makeCoincident(p1, p2, sketch):
+    constraint = sketch.addFeature("SketchConstraintCoincidence")
+    constraint.refattr("ConstraintEntityA").setAttr(p1)
+    constraint.refattr("ConstraintEntityB").setAttr(p2)
+    return constraint
+
+
+def makeParallel(l1, l2, sketch):
+    constraint = sketch.addFeature("SketchConstraintParallel")
+    constraint.refattr("ConstraintEntityA").setObject(l1)
+    constraint.refattr("ConstraintEntityB").setObject(l2)
+    return constraint
+
+
+def makePerpendicular(l1, l2, sketch):
+    constraint = sketch.addFeature("SketchConstraintPerpendicular")
+    constraint.refattr("ConstraintEntityA").setObject(l1)
+    constraint.refattr("ConstraintEntityB").setObject(l2)
+    return constraint
+
+
+def makeConstantLength(line, length, sketch):
+    constraint = sketch.addFeature("SketchConstraintLength")
+    constraint.refattr("ConstraintEntityA").setObject(line)
+    constraint.real("ConstraintValue").setValue(length)
+    return constraint
index 22ce7d27eda3dce82e05a8039a73bad2c22198c1..d6a7d77ac49a5281895e779b9bdd02dc6aa26e6f 100644 (file)
@@ -66,6 +66,7 @@ SET(PROJECT_LIBRARIES
     GeomValidators
     ModelAPI
     SketcherPrs
+    GeomDataAPI
     ${CAS_KERNEL}
     ${CAS_SHAPE}
 )
index 27e3512ba0271294e165b54cf2566b7366146b82..026266a30d164a160208039d0a0c8c3f809d50fe 100644 (file)
@@ -33,10 +33,10 @@ void SketchPlugin_Arc::initAttributes()
 {
   SketchPlugin_SketchEntity::initAttributes();
 
-  data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(START_ID(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(END_ID(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+  data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(START_ID(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(END_ID(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
 }
 
index 934f40a04eb331cf8a0fb0a37ba044140e29b9c7..623b6c62549757eaf2b35f54ff9ddb38437baebf 100644 (file)
@@ -30,9 +30,9 @@ void SketchPlugin_Circle::initAttributes()
 {
   SketchPlugin_SketchEntity::initAttributes();
 
-  data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(RADIUS_ID(), ModelAPI_AttributeDouble::type());
-  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+  data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
 }
 
index 358158325fc9b4da8f49f9a60ca6efae1e14a66c..a78e1b4efc2d0b7b0aeddfc959586679345ecb63 100644 (file)
@@ -20,8 +20,8 @@ SketchPlugin_ConstraintCoincidence::SketchPlugin_ConstraintCoincidence()
 
 void SketchPlugin_ConstraintCoincidence::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
 }
 
 void SketchPlugin_ConstraintCoincidence::execute()
@@ -39,4 +39,4 @@ AISObjectPtr SketchPlugin_ConstraintCoincidence::getAISObject(AISObjectPtr thePr
     anAIS->setColor(0, 0, 255);
   }
   return anAIS;
-}
\ No newline at end of file
+}
index 3c46ab4a557ac098c9488f49eca7a04b4a989cf3..89bc7e429200644e92cf25f1a7cf015746bbc426 100644 (file)
@@ -27,10 +27,10 @@ SketchPlugin_ConstraintDistance::SketchPlugin_ConstraintDistance()
 //*************************************************************************************
 void SketchPlugin_ConstraintDistance::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type());
-  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
 }
 
 //*************************************************************************************
index efd034fea2ce18faa18d74b64d1790ef13b68e69..1b80c0c6b050e16088bea1b496c263716c60a5f0 100644 (file)
@@ -23,8 +23,8 @@ SketchPlugin_ConstraintEqual::SketchPlugin_ConstraintEqual()
 
 void SketchPlugin_ConstraintEqual::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
 }
 
 void SketchPlugin_ConstraintEqual::execute()
index 4b7b4cff7319ffad820915122ee8e1764e03cf00..22bc2541a224c8f24f04ab4ae12f7a39a0483d2a 100644 (file)
@@ -26,10 +26,10 @@ SketchPlugin_ConstraintFillet::SketchPlugin_ConstraintFillet()
 
 void SketchPlugin_ConstraintFillet::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::type());
+  data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::typeId());
   // initialize attribute not applicable for user
   data()->attribute(SketchPlugin_Constraint::ENTITY_C())->setInitialized();
 }
index 175715d28afd30f5f4a3694d6aa942753a81895c..9fe7e5188793955e98975860a063f0acaf706abf 100644 (file)
@@ -23,7 +23,7 @@ SketchPlugin_ConstraintHorizontal::SketchPlugin_ConstraintHorizontal()
 
 void SketchPlugin_ConstraintHorizontal::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
 }
 
 void SketchPlugin_ConstraintHorizontal::execute()
index da91dc5835cbead17fa834bec2c063fc18536912..06cf90cb77f4ae0bd4a29de0bfbc8efab441f9a9 100644 (file)
@@ -26,9 +26,9 @@ SketchPlugin_ConstraintLength::SketchPlugin_ConstraintLength()
 
 void SketchPlugin_ConstraintLength::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type());
-  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
 }
 
 void SketchPlugin_ConstraintLength::execute()
index 8479e107da7c3563772defdd61145c6b9c977d3b..f0da5515fa7a63ee32484a78dcfb5d5f2437f3bd 100644 (file)
@@ -25,9 +25,9 @@ SketchPlugin_ConstraintMirror::SketchPlugin_ConstraintMirror()
 
 void SketchPlugin_ConstraintMirror::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::typeId());
 }
 
 void SketchPlugin_ConstraintMirror::execute()
index 29a7f0a25c1c6da37e19c10a514b0ad0ee9687ff..42ce74b78572f01ad5a9af1544e639eca8544320 100644 (file)
@@ -29,9 +29,9 @@ SketchPlugin_ConstraintParallel::SketchPlugin_ConstraintParallel()
 
 void SketchPlugin_ConstraintParallel::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
-  //data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+  //data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
 }
 
 void SketchPlugin_ConstraintParallel::execute()
index 152fabe222534208c3096a2a9e6db326f05468cb..eb9ec92f5866d8ba552b5e798bfcfd88bfaf8ed6 100644 (file)
@@ -28,8 +28,8 @@ SketchPlugin_ConstraintPerpendicular::SketchPlugin_ConstraintPerpendicular()
 
 void SketchPlugin_ConstraintPerpendicular::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
 }
 
 void SketchPlugin_ConstraintPerpendicular::execute()
index 528d636ae9160d295624c811a77c473a70a1fe12..f9532a620d074dfc13b3304ab08aa0b0c6344f48 100644 (file)
@@ -29,9 +29,9 @@ SketchPlugin_ConstraintRadius::SketchPlugin_ConstraintRadius()
 
 void SketchPlugin_ConstraintRadius::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
 }
 
 void SketchPlugin_ConstraintRadius::execute()
index 6695a8813dd8f0b0b7b1be6929734e6e05d8be75..741674a5b9429e461ffa6cf1da6bbca6f7d00029 100644 (file)
@@ -21,7 +21,7 @@ SketchPlugin_ConstraintRigid::SketchPlugin_ConstraintRigid()
 
 void SketchPlugin_ConstraintRigid::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
 }
 
 void SketchPlugin_ConstraintRigid::execute()
index c979d8939ac74d1a45dbe903ad7a75761fa5557d..9d7256c18aef20b54139ab02501caa55b4159c6e 100644 (file)
@@ -23,8 +23,8 @@ SketchPlugin_ConstraintTangent::SketchPlugin_ConstraintTangent()
 
 void SketchPlugin_ConstraintTangent::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
 }
 
 void SketchPlugin_ConstraintTangent::execute()
index bb824715ad5b91f22e6b7ac696cbdfbafd725f2c..d5865e6ab3c14aafc6e2bb7da8fd13b75c992cd2 100644 (file)
@@ -23,7 +23,7 @@ SketchPlugin_ConstraintVertical::SketchPlugin_ConstraintVertical()
 
 void SketchPlugin_ConstraintVertical::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
 }
 
 void SketchPlugin_ConstraintVertical::execute()
index ea5d0a42b1e57039053e2a7ff2c63b1d0b34d0c5..ed07e4079bd6bd7eba234a943289ec1d97b6539e 100644 (file)
@@ -30,9 +30,9 @@ void SketchPlugin_Line::initAttributes()
 {
   SketchPlugin_SketchEntity::initAttributes();
 
-  data()->addAttribute(START_ID(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(END_ID(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+  data()->addAttribute(START_ID(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(END_ID(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
 }
 
index 04347759e5655848a0831c73ab5977e2abbc211d..35ff48c6ab8101d120185aa8db6e6ec22343d364 100644 (file)
@@ -53,9 +53,7 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
                               new SketchPlugin_DistanceAttrValidator);  
   //aFactory->registerValidator("SketchPlugin_DifferentObjects",
   //                            new SketchPlugin_DifferentObjectsValidator);
-
-  aFactory->registerValidator("SketchPlugin_ShapeValidator",
-                              new SketchPlugin_ShapeValidator);
+  aFactory->registerValidator("SketchPlugin_ShapeValidator", new SketchPlugin_ShapeValidator);
 
   // register this plugin
   ModelAPI_Session::get()->registerPlugin(this);
index 036fde19db093340f6a632a0b73b2f860e7e26a7..6fe1e2cfab638557a3c481b138ad00bbc603fdb6 100644 (file)
@@ -29,8 +29,8 @@ void SketchPlugin_Point::initAttributes()
 {
   SketchPlugin_SketchEntity::initAttributes();
 
-  data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+  data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
 }
 
index b57c1e3ba21e7b587c0a4fd950c6a516fa3d082b..377fc0beddf6fc491423951a2417c3ca474e0a2e 100644 (file)
@@ -44,12 +44,12 @@ SketchPlugin_Sketch::SketchPlugin_Sketch()
 
 void SketchPlugin_Sketch::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point::type());
-  data()->addAttribute(SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir::type());
-  data()->addAttribute(SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir::type());
-  data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::type());
+  data()->addAttribute(SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point::typeId());
+  data()->addAttribute(SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir::typeId());
+  data()->addAttribute(SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir::typeId());
+  data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::typeId());
   // the selected face, base for the sketcher plane, not obligatory
-  data()->addAttribute(SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+  data()->addAttribute(SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
   ModelAPI_Session::get()->validators()->registerNotObligatory(
     getKind(), SketchPlugin_SketchEntity::EXTERNAL_ID());
 }
index 39cc06a67d08c52d0ee42838df99aab293bd1e0c..9e95496ef455fa95572ba3c4f53c1a0c82b3ac47 100644 (file)
@@ -13,6 +13,6 @@ SketchPlugin_SketchEntity::SketchPlugin_SketchEntity()
 
 void SketchPlugin_SketchEntity::initAttributes()
 {
-  data()->addAttribute(AUXILIARY_ID(), ModelAPI_AttributeBoolean::type());
+  data()->addAttribute(AUXILIARY_ID(), ModelAPI_AttributeBoolean::typeId());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), AUXILIARY_ID());
 }
index 32a0b30b57cc3028c1311c8b1c5935d5c46841c8..ca7df854dcdf26bcbf700b5da88ef40ad542951e 100644 (file)
 
 bool SketchPlugin_DistanceAttrValidator::isValid(
   const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+//bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature,
+//                                                 const std::list<std::string>& theArguments,
+//                                                 const ObjectPtr& theObject,
+//                                                 const GeomShapePtr& theShape) const
+// ======= end of todo master
 {
   // there is a check whether the feature contains a point and a linear edge or two point values
   std::string aParamA = theArguments.front();
@@ -60,3 +65,84 @@ bool SketchPlugin_DistanceAttrValidator::isValid(
   }
   return false;
 }
+// TODO(nds) v1.0.2, master
+//  return false;
+//}
+
+//bool SketchPlugin_DistanceAttrValidator::isValid(
+//  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+//{
+//  // any point attribute is acceptable for the distance operation
+//  return true;
+//}
+//
+//bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature,
+//                                                 const std::list<std::string>& theArguments,
+//                                                 const AttributePtr& theAttribute) const
+//{
+//  return isValid(theAttribute, theArguments);
+//}
+
+// commented in v1.0.2, master:
+//bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
+//                                                 const std::list<std::string>& theArguments,
+//                                                 const ObjectPtr& theObject) const
+//{
+//  std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs = 
+//    theFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
+//  std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+//  for(; anAttr != anAttrs.end(); anAttr++) {
+//    if (*anAttr) {
+//      std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
+//        std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
+//      // check the object is already presented
+//      if (aRef->isObject() && aRef->object() == theObject)
+//        return false;
+//    }
+//  }
+//  return true;
+//}
+
+//bool SketchPlugin_DifferentObjectsValidator::isValid(
+//  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+//{
+//  std::shared_ptr<ModelAPI_AttributeRefAttr> anOrigAttr = 
+//    std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+//  if (anOrigAttr && anOrigAttr->isObject()) {
+//    const ObjectPtr& anObj = theAttribute->owner();
+//    const FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObj);
+//
+//    std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs = 
+//      aFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
+//    std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+//    for(; anAttr != anAttrs.end(); anAttr++) {
+//      if (*anAttr && *anAttr != theAttribute) {
+//        std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
+//          std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
+//        // check the object is already presented
+//        if (aRef->isObject() && aRef->object() == anOrigAttr->object())
+//          return false;
+//      }
+//    }
+//  }
+//  return true;
+//}
+
+//bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
+//  const std::list<std::string>& theArguments, const AttributePtr& theAttribute) const
+//{
+//  std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs = 
+//    theFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
+//  std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+//  for(; anAttr != anAttrs.end(); anAttr++) {
+//    if (*anAttr) {
+//      std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
+//        std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
+//      // check the object is already presented
+//      if (!aRef->isObject() && aRef->attr() == theAttribute)
+//        return false;
+//    }
+//  }
+//  return true;
+//}
+// =========== end of todo
index f686d3e6ebe97a5e75cefcee21b313b3fd2b7f04..6259c2bd682f82bbdb028c69b7bd71c69e4ce3f3 100644 (file)
@@ -25,5 +25,41 @@ class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator
   virtual bool isValid(const AttributePtr& theAttribute,
                        const std::list<std::string>& theArguments) const;
 };
+//  virtual bool isValid(const AttributePtr& theAttribute,
+//                       const std::list<std::string>& theArguments) const;
+//
+//  //! Returns true if object is good for the feature attribute
+//  virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+//                       const ObjectPtr& theObject, const GeomShapePtr& theShape) const;
+//
+//  //! Returns true if the attribute is good for the feature attribute
+//  virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+//                       const AttributePtr& theAttribute) const;
+//};
+
+// commented in v1.0.2, master:
+/**\class SketchPlugin_DifferentObjectsValidator
+ * \ingroup Validators
+ *
+ * Check that there is no same object was already selected in the feature.
+ * For an example: to avoid perpendicularity on line and the same line.
+ */
+// Use PartSet_DifferentObjectsValidator instead
+//class SketchPlugin_DifferentObjectsValidator : public ModelAPI_RefAttrValidator
+//{
+// public:
+//  //! returns true if attribute is valid
+//  //! \param theAttribute the checked attribute
+//  //! \param theArguments arguments of the attribute
+//  virtual bool isValid(
+//    const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const;
+//  //! Returns true if object is good for the feature attribute
+//  virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+//                       const ObjectPtr& theObject) const;
+//  //! Returns true if the attribute is good for the feature attribute
+//  virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+//                       const AttributePtr& theAttribute) const;
+//};
+// ======= end of todo
 
 #endif
index 772c94b96ea400fa9efdd87a0966b289d072ff9e..79589ac4c6fa840149bf2d0f68bb6891a0eccc17 100644 (file)
@@ -12,8 +12,8 @@
         
     SketchPlugin_ConstraintCoincidence
         static const std::string MY_CONSTRAINT_COINCIDENCE_ID("SketchConstraintCoincidence");
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
 
 """
 from GeomDataAPI import *
@@ -31,7 +31,7 @@ aDocument = aSession.moduleDocument()
 #=========================================================================
 aSession.startOperation()
 aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
index 4c50263b2e1baf1ee85da7b24d4deffc29d85aee..13aeada6f9f4fd19c766a85a48a363509d28aa8e 100644 (file)
         
     SketchPlugin_ConstraintDistance
         static const std::string MY_CONSTRAINT_DISTANCE_ID("SketchConstraintDistance");
-        data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::type());
-        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+        data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
         
     
 """
@@ -45,7 +45,7 @@ aDocument = aSession.moduleDocument()
 #=========================================================================
 aSession.startOperation()
 aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
index 09f8f076d4207e3cdb5c4308541c411b1f5da69b..5e99e051250f9e883848dcd6fe634dd08d581a50 100644 (file)
@@ -4,8 +4,8 @@
         
     SketchPlugin_ConstraintEqual
         static const std::string MY_CONSTRAINT_EQAUL_ID("SketchConstraintEqual");
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
 
 """
 from GeomDataAPI import *
index 337315858e173b5c95ad02c8d5e252ffb106ee31..050c60f249e7084053c6cad865e887c80661c520 100644 (file)
@@ -4,7 +4,7 @@
         
     SketchPlugin_ConstraintHorizontal
         static const std::string MY_CONSTRAINT_HORIZONTAL_ID("SketchConstraintHorizontal");
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
 
 """
 from GeomDataAPI import *
index 48acf2c6b612bc12b12749f1bd089b5c8025f7ca..4dc391889ed59c437751b40b12dcb0cf26386b88 100644 (file)
@@ -4,9 +4,9 @@
         
     SketchPlugin_ConstraintLength
         static const std::string MY_CONSTRAINT_LENGTH_ID("SketchConstraintLength");
-        data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::type());
-        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+        data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
 
 """
 from GeomDataAPI import *
@@ -24,7 +24,7 @@ aDocument = aSession.moduleDocument()
 #=========================================================================
 aSession.startOperation()
 aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
index 3c3c2d05288fa382ca68257de98e8e577695d0bf..4f85ec44ecf22a0c97f9dcfcb387c1b36aab02eb 100644 (file)
@@ -4,9 +4,9 @@
         
     SketchPlugin_ConstraintMirror
         static const std::string MY_CONSTRAINT_MIRROR_ID("SketchConstraintMirror");
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefListAttr::type());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefListAttr::type());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefListAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefListAttr::typeId());
 
 """
 from GeomDataAPI import *
index 052e9272af1961924b4391a28c50aa2d93cdd02d..965193b4e4ac188a5fdd787314204390ee8017e3 100644 (file)
@@ -4,9 +4,9 @@
         
     SketchPlugin_ConstraintParallel
         static const std::string MY_CONSTRAINT_PARALLEL_ID("SketchConstraintParallel");
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
-        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
 
 """
 from GeomDataAPI import *
@@ -24,7 +24,7 @@ aDocument = aSession.moduleDocument()
 #=========================================================================
 aSession.startOperation()
 aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
index 2f9c6bf069f7daaf11d36e93c2d9e68e38514965..64e15c899af7b1d0195aa9d8b7d9ec99618e05f0 100644 (file)
@@ -12,9 +12,9 @@
         
     SketchPlugin_ConstraintPerpendicular
         static const std::string MY_CONSTRAINT_PERPENDICULAR_ID("SketchConstraintPerpendicular");
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
-        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type()); 
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId()); 
 """
 from GeomDataAPI import *
 from ModelAPI import *
@@ -31,7 +31,7 @@ aDocument = aSession.moduleDocument()
 #=========================================================================
 aSession.startOperation()
 aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
index cc71a412ff7b5cc2904f46584ffebbc896614d14..175823e1e1e775cce2692e439ebbda784be54171 100644 (file)
@@ -12,9 +12,9 @@
         
     SketchPlugin_ConstraintRadius
         static const std::string MY_CONSTRAINT_RADIUS_ID("SketchConstraintRadius");
-        data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::type());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+        data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
 
 """
 from GeomDataAPI import *
@@ -33,7 +33,7 @@ aDocument = aSession.moduleDocument()
 #=========================================================================
 aSession.startOperation()
 aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
index 9f6eaf31a9dbea5db0938cc25917b6b243e864d7..e00acda2ca37e6a7a1952c1b4f8cb373a82c8ead 100644 (file)
@@ -12,7 +12,7 @@
         
     SketchPlugin_ConstraintRigid
         static const std::string MY_CONSTRAINT_RIGID_ID("SketchConstraintRigid");
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
 
 """
 from GeomDataAPI import *
@@ -31,7 +31,7 @@ aDocument = aSession.moduleDocument()
 #=========================================================================
 aSession.startOperation()
 aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
index df753488a2de9e413569e09498bdcf21c98543c4..a64b8a3a8c3db4293fa4bdbf982901ec5feaf90a 100644 (file)
@@ -4,8 +4,8 @@
         
     SketchPlugin_ConstraintTangent
         static const std::string MY_CONSTRAINT_TANGENT_ID("SketchConstraintTangent");
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
 
 """
 from GeomDataAPI import *
index 87ba28f970d8a8a232310e8467ceb6f280271d32..9272b21ec1384559cc4890505d1c75b7e9eebc16 100644 (file)
@@ -4,7 +4,7 @@
         
     SketchPlugin_ConstraintVertical
         static const std::string MY_CONSTRAINT_VERTICAL_ID("SketchConstraintVertical");
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
 
 """
 from GeomDataAPI import *
index f8fed6087f82e0ddf6147a1696b4aecdb97ab8b7..819cb00a566eff2a53d1b522a4c1445ba2691612 100644 (file)
@@ -90,7 +90,7 @@ aDocument = aSession.moduleDocument()
 #=========================================================================
 aSession.startOperation()
 aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
index c59725e218a969c2fe77015a48e7cc1edd79edba..9927598a6882632ae357d43412826b4bb6bf6eca 100644 (file)
@@ -5,15 +5,15 @@
     static const std::string MY_CENTER_ID = "ArcCenter";
     static const std::string MY_START_ID = "ArcStartPoint";
     static const std::string MY_END_ID = "ArcEndPoint";
-    data()->addAttribute(SketchPlugin_Arc::CENTER_ID(), GeomDataAPI_Point2D::type());
-    data()->addAttribute(SketchPlugin_Arc::START_ID(),  GeomDataAPI_Point2D::type());
-    data()->addAttribute(SketchPlugin_Arc::END_ID(),    GeomDataAPI_Point2D::type());
+    data()->addAttribute(SketchPlugin_Arc::CENTER_ID(), GeomDataAPI_Point2D::typeId());
+    data()->addAttribute(SketchPlugin_Arc::START_ID(),  GeomDataAPI_Point2D::typeId());
+    data()->addAttribute(SketchPlugin_Arc::END_ID(),    GeomDataAPI_Point2D::typeId());
     
     static const std::string MY_CIRCLE_ID("SketchCircle");
     static const std::string MY_CIRCLE_CENTER_ID("CircleCenter");
     static const std::string MY_CIRCLE_RADIUS_ID("CircleRadius");
-    data()->addAttribute(SketchPlugin_Circle::CENTER_ID(), GeomDataAPI_Point2D::type());
-    data()->addAttribute(SketchPlugin_Circle::RADIUS_ID(), ModelAPI_AttributeDouble::type());
+    data()->addAttribute(SketchPlugin_Circle::CENTER_ID(), GeomDataAPI_Point2D::typeId());
+    data()->addAttribute(SketchPlugin_Circle::RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
 """
 
 #=========================================================================
@@ -32,7 +32,7 @@ aDocument = aSession.moduleDocument()
 aSession.startOperation()
 #aSketchFeature = aDocument.addFeature("Sketch")
 aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
@@ -139,8 +139,8 @@ assert (anCircleCentr.y() == 0)
 assert (not anCircleCentr.isInitialized())
 aCircleRadius = aSketchCircle.real("CircleRadius")
 assert (type(aCircleRadius) == ModelAPI_AttributeDouble)
-# ModelAPI_AttributeDouble.type() is checked in ModelAPI_TestConstants
-assert (aCircleRadius.attributeType() == ModelAPI_AttributeDouble.type())
+# ModelAPI_AttributeDouble.typeId() is checked in ModelAPI_TestConstants
+assert (aCircleRadius.attributeType() == ModelAPI_AttributeDouble.typeId())
 assert (aCircleRadius.value() == 0)
 anCircleCentr.setValue(-25., -25)
 aCircleRadius.setValue(25.)
index df3f7cd64b6ab67a7ce2803a59d3c9409402f28a..cbf0d05bf40f07f4d0f3fd332aac5eb178e70335 100644 (file)
@@ -13,7 +13,7 @@ aDocument = aSession.moduleDocument()
 #=========================================================================
 aSession.startOperation()
 aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
 assert (aSketchFeature.getKind() == "Sketch")
 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
index 65b421354c8758b9d10523d5f5fa1bfb4273b086..4a0a31e53c0c8df2ca94a0fcdb0c5e8df1e380f1 100644 (file)
@@ -104,7 +104,7 @@ aDocument = aSession.moduleDocument()
 #=========================================================================
 aSession.startOperation()
 aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
index f1bc36d9b27c41994d0a79f142c99c07659b778b..af51a5dd6164706a677181ba402fd625d2910d1c 100644 (file)
           id="ConstraintEntityB" 
           label="Last object" 
           tooltip="Select point, line end point, line, center of circle or arc." 
-                shape_types="edge vertex">
+          shape_types="edge vertex">
           <validator id="PartSet_DifferentObjects"/>
           <validator id="SketchPlugin_DistanceAttr" parameters="ConstraintEntityA"/>
           <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityA"/>
           <validator id="GeomValidators_EdgeOrVertex"/>
         </sketch_shape_selector>
+ <!--
+ TODO(nds): v1.0.2, master  
+                           shape_types="edge vertex">
+                       <validator id="PartSet_DifferentObjects"/>
+      <validator id="SketchPlugin_DistanceAttr" parameters="ConstraintEntityA"/>
+      <selection_filter id="MultiFilter" parameters="line,vertex"/>
+    </sketch_shape_selector>
+               
+        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
+ -->
         
         <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt"  default="computed" internal="1" obligatory="0"/>
         
             <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityA"/>
         </sketch_constraint_shape_selector>
         
+<!--  
+  TODO(nds): v1.0.2, master  
+               <sketch_constraint_shape_selector id="ConstraintEntityA" 
+                       label="First line" tooltip="Select a line" shape_types="edge">
+                       <selection_filter id="EdgeFilter" parameters="line"/>
+               </sketch_constraint_shape_selector>
+               
+               <sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select a line" 
+                       shape_types="edge">
+                       <selection_filter id="EdgeFilter" parameters="line"/>
+                       <validator id="PartSet_DifferentObjects"/>
+               </sketch_constraint_shape_selector>
+               
+        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
+-->
         <validator id="PartSet_ParallelValidator"/>
       </feature>
     <!--  SketchConstraintPerpendicular  -->
-      <feature id="SketchConstraintPerpendicular" title="Perpendicular" tooltip="Create constraint defining two perpendicular lines" icon=":icons/perpendicular.png">
+      <feature id="SketchConstraintPerpendicular" title="Perpendicular" 
+        tooltip="Create constraint defining two perpendicular lines" 
+        icon=":icons/perpendicular.png">
         <sketch_constraint_shape_selector id="ConstraintEntityA" 
             label="First line" tooltip="Select an line" 
             shape_types="edge">
           <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityA"/>
             <validator id="GeomValidators_Edge" parameters="line"/>
         </sketch_constraint_shape_selector>
+<!--  
+  TODO(nds): v1.0.2, master
+               <sketch_constraint_shape_selector id="ConstraintEntityA" 
+                       label="First line" tooltip="Select an line" 
+                       shape_types="edge">
+      <selection_filter id="EdgeFilter" parameters="line"/>
+    </sketch_constraint_shape_selector>
+               
+               <sketch_constraint_shape_selector id="ConstraintEntityB" 
+                       label="Last line" tooltip="Select an line" 
+                       shape_types="edge">
+                       <validator id="PartSet_DifferentObjects"/>
+      <selection_filter id="EdgeFilter" parameters="line"/>
+    </sketch_constraint_shape_selector>
+-->
         <validator id="PartSet_PerpendicularValidator"/>
       </feature>
     <!--  SketchConstraintRigid  -->
index 4ee164e1d474c6dad091d377cb45835f051714a6..3c5b4be1b8cb72478c378cd2b538b7154043a825 100644 (file)
@@ -341,9 +341,9 @@ AttrType typeOfAttribute(std::shared_ptr<ModelAPI_Attribute> theAttribute)
   } else {
     if (anAttrRef->attr().get() != NULL) {
       const std::string aType = anAttrRef->attr()->attributeType();
-      if (aType == GeomDataAPI_Point2D::type())
+      if (aType == GeomDataAPI_Point2D::typeId())
         return POINT2D;
-      if (aType == GeomDataAPI_Point2D::type())
+      if (aType == GeomDataAPI_Point2D::typeId())
         return POINT2D;
     }
   }
index b650cbdabee544b8d56a85a3242adaf72f912dda..05171749b3acb6ac241f6e57aada2fa2994e468d 100644 (file)
@@ -777,7 +777,7 @@ bool SketchSolver_ConstraintGroup::changeMirrorConstraint(
       aBaseFeature = aRC ? aRC->document()->feature(aRC) :
           std::dynamic_pointer_cast<SketchPlugin_Feature>(*aBaseIter);
       if (!aBaseFeature) continue;
-      std::list<AttributePtr> aPoints = aBaseFeature->data()->attributes(GeomDataAPI_Point2D::type());
+      std::list<AttributePtr> aPoints = aBaseFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
       std::list<AttributePtr>::iterator anIt = aPoints.begin();
       for ( ; anIt != aPoints.end(); anIt++) {
         // Arcs are fixed by center and start points only (to avoid solving errors in SolveSpace)
@@ -1076,7 +1076,7 @@ bool SketchSolver_ConstraintGroup::changeFilletConstraint(
       continue;
     }
     std::list<AttributePtr> anAttributes =
-        aBaseFeature[indAttr]->data()->attributes(GeomDataAPI_Point2D::type());
+        aBaseFeature[indAttr]->data()->attributes(GeomDataAPI_Point2D::typeId());
     std::list<AttributePtr>::iterator anIt = anAttributes.begin();
     for ( ; anIt != anAttributes.end(); anIt++) {
       // Arc should be fixed by center and start points only (to avoid "conflicting constraints" message)