Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 17 Jul 2014 13:30:15 +0000 (17:30 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 17 Jul 2014 13:30:15 +0000 (17:30 +0400)
31 files changed:
CMakeCommon/CodeCoverage.cmake [new file with mode: 0644]
CMakeLists.txt
eclipse.sh
linux_env.sh
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_AttributeRefList.h
src/ModelAPI/ModelAPI_Feature.cpp [new file with mode: 0644]
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_ResultBody.h
src/ModelAPI/ModelAPI_ResultConstruction.h
src/ModelAPI/ModelAPI_ResultPart.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_WidgetBoolValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetEditor.cpp
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/PartSet/PartSet_Module.cpp
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

diff --git a/CMakeCommon/CodeCoverage.cmake b/CMakeCommon/CodeCoverage.cmake
new file mode 100644 (file)
index 0000000..b8f5ce0
--- /dev/null
@@ -0,0 +1,164 @@
+#
+# 2012-01-31, Lars Bilke
+# - Enable Code Coverage
+#
+# 2013-09-17, Joakim Söderberg
+# - Added support for Clang.
+# - Some additional usage instructions.
+#
+# USAGE:
+
+# 0. (Mac only) If you use Xcode 5.1 make sure to patch geninfo as described here:
+#      http://stackoverflow.com/a/22404544/80480
+#
+# 1. Copy this file into your cmake modules path.
+#
+# 2. Add the following line to your CMakeLists.txt:
+#      INCLUDE(CodeCoverage)
+#
+# 3. Set compiler flags to turn off optimization and enable coverage: 
+#    SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
+#       SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
+#  
+# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target
+#    which runs your test executable and produces a lcov code coverage report:
+#    Example:
+#       SETUP_TARGET_FOR_COVERAGE(
+#                              my_coverage_target  # Name for custom target.
+#                              test_driver         # Name of the test driver executable that runs the tests.
+#                                                                      # NOTE! This should always have a ZERO as exit code
+#                                                                      # otherwise the coverage generation will not complete.
+#                              coverage            # Name of output directory.
+#                              )
+#
+# 4. Build a Debug build:
+#       cmake -DCMAKE_BUILD_TYPE=Debug ..
+#       make
+#       make my_coverage_target
+#
+#
+
+# Check prereqs
+FIND_PROGRAM( GCOV_PATH gcov )
+FIND_PROGRAM( LCOV_PATH lcov )
+FIND_PROGRAM( GENHTML_PATH genhtml )
+FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests)
+
+IF(NOT GCOV_PATH)
+       MESSAGE(FATAL_ERROR "gcov not found! Aborting...")
+ENDIF() # NOT GCOV_PATH
+
+IF(NOT CMAKE_COMPILER_IS_GNUCXX)
+       # Clang version 3.0.0 and greater now supports gcov as well.
+       MESSAGE(WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.")
+       
+       IF(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+               MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
+       ENDIF()
+ENDIF() # NOT CMAKE_COMPILER_IS_GNUCXX
+
+SET(CMAKE_CXX_FLAGS_COVERAGE
+    "-g -O0 --coverage -fprofile-arcs -ftest-coverage"
+    CACHE STRING "Flags used by the C++ compiler during coverage builds."
+    FORCE )
+SET(CMAKE_C_FLAGS_COVERAGE
+    "-g -O0 --coverage -fprofile-arcs -ftest-coverage"
+    CACHE STRING "Flags used by the C compiler during coverage builds."
+    FORCE )
+SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE
+    ""
+    CACHE STRING "Flags used for linking binaries during coverage builds."
+    FORCE )
+SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
+    ""
+    CACHE STRING "Flags used by the shared libraries linker during coverage builds."
+    FORCE )
+MARK_AS_ADVANCED(
+    CMAKE_CXX_FLAGS_COVERAGE
+    CMAKE_C_FLAGS_COVERAGE
+    CMAKE_EXE_LINKER_FLAGS_COVERAGE
+    CMAKE_SHARED_LINKER_FLAGS_COVERAGE )
+
+IF ( NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "Coverage"))
+  MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" )
+ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
+
+
+# Param _targetname     The name of new the custom make target
+# Param _testrunner     The name of the target which runs the tests.
+#                                              MUST return ZERO always, even on errors. 
+#                                              If not, no coverage report will be created!
+# Param _outputname     lcov output is generated as _outputname.info
+#                       HTML report is generated in _outputname/index.html
+# Optional fourth parameter is passed as arguments to _testrunner
+#   Pass them in list form, e.g.: "-j;2" for -j 2
+FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
+
+       IF(NOT LCOV_PATH)
+               MESSAGE(FATAL_ERROR "lcov not found! Aborting...")
+       ENDIF() # NOT LCOV_PATH
+
+       IF(NOT GENHTML_PATH)
+               MESSAGE(FATAL_ERROR "genhtml not found! Aborting...")
+       ENDIF() # NOT GENHTML_PATH
+
+       # Setup target
+       ADD_CUSTOM_TARGET(${_targetname}
+               
+               # Cleanup lcov
+               ${LCOV_PATH} --directory . --zerocounters
+               
+               # Run tests
+               COMMAND ${_testrunner} ${ARGV3}
+               
+               # Capturing lcov counters and generating report
+               COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info
+               COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' --output-file ${_outputname}.info.cleaned
+               COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned
+               COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_outputname}.info.cleaned
+               
+               WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+               COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
+       )
+       
+       # Show info where to find the report
+       ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
+               COMMAND ;
+               COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report."
+       )
+
+ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE
+
+# Param _targetname     The name of new the custom make target
+# Param _testrunner     The name of the target which runs the tests
+# Param _outputname     cobertura output is generated as _outputname.xml
+# Optional fourth parameter is passed as arguments to _testrunner
+#   Pass them in list form, e.g.: "-j;2" for -j 2
+FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname)
+
+       IF(NOT PYTHON_EXECUTABLE)
+               MESSAGE(FATAL_ERROR "Python not found! Aborting...")
+       ENDIF() # NOT PYTHON_EXECUTABLE
+
+       IF(NOT GCOVR_PATH)
+               MESSAGE(FATAL_ERROR "gcovr not found! Aborting...")
+       ENDIF() # NOT GCOVR_PATH
+
+       ADD_CUSTOM_TARGET(${_targetname}
+
+               # Run tests
+               ${_testrunner} ${ARGV3}
+
+               # Running gcovr
+               COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/'  -o ${_outputname}.xml
+               WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+               COMMENT "Running gcovr to produce Cobertura code coverage report."
+       )
+
+       # Show info where to find the report
+       ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
+               COMMAND ;
+               COMMENT "Cobertura code coverage report saved in ${_outputname}.xml."
+       )
+
+ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA
index 7b6d98c3ae913a97ac3b8a6b6047ff7aa51f44e8..6cfd58728f49cf36fb252188f1613f58cb53ffe2 100644 (file)
@@ -13,13 +13,28 @@ INCLUDE(FindSolveSpace)
 INCLUDE(FindCAS)
 
 IF(UNIX)
-    IF(CMAKE_COMPILER_IS_GNUCC)
-        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
-        MESSAGE(STATUS "Setting -std=c++0x flag for the gcc...")
-        MESSAGE(STATUS "Now gcc flags are: " ${CMAKE_CXX_FLAGS})
-        
-       SET(CMAKE_SHARED_LINKER_FLAGS "${SMAKE_SHARED_LINKER_FLAGS} -Wl,-E")
-    ENDIF(CMAKE_COMPILER_IS_GNUCC)
+  IF(CMAKE_COMPILER_IS_GNUCC)
+    #C++11 is not supported on some platforms, disable it 
+    MESSAGE(STATUS "Setting -std=c++0x flag for the gcc...")
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+    
+    #Supporting test coverage checks (gcov) in the DEBUG mode
+    IF(CMAKE_BUILD_TYPE MATCHES Debug)
+      INCLUDE(CodeCoverage)
+      MESSAGE(STATUS "Setting flags for gcov support the the gcc...")
+      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
+      SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
+      SET(CMAKE_SHARED_LINKER_FLAGS "-lgcov")
+      
+      SETUP_TARGET_FOR_COVERAGE(test_coverage  # Name for custom target.
+                                               ctest          # Name of the test driver executable that runs the tests.
+                                               coverage)      # Name of output directory.
+    ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
+    
+    #SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -E")
+    MESSAGE(STATUS "gcc flags are: " ${CMAKE_CXX_FLAGS})
+    MESSAGE(STATUS "linker flags are: " ${CMAKE_SHARED_LINKER_FLAGS})
+  ENDIF(CMAKE_COMPILER_IS_GNUCC)
 ENDIF(UNIX)
 
 
index de64257e30eaeaad82db575bb38b04f9720810ba..0dddf7dec27da0033b1bdac91dc7539df5bbdd9e 100755 (executable)
@@ -13,8 +13,10 @@ CMAKE_ARGS="-D_ECLIPSE_VERSION=4.3"
 CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Debug"
 CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=ON"
 CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=${ROOT_DIR}/install"
+CMAKE_ARGS="${CMAKE_ARGS} -DPYTHON_EXECUTABLE=${PYTHONHOME}/bin/python"
 CMAKE_ARGS="${CMAKE_ARGS} ${SRC_DIR}"
 
 cmake -G "Eclipse CDT4 - Unix Makefiles" ${CMAKE_ARGS}
 
-/misc/dn48/newgeom/common/eclipse-4.3.0/eclipse -Dosgi.locking=none &
\ No newline at end of file
+#/misc/dn48/newgeom/common/eclipse-4.3.0/eclipse&
+/misc/dn48/newgeom/common/eclipse-4.4.0/eclipse&
\ No newline at end of file
index 6cd1e816b0b77a876634860af689db040e3a6375..5562147724b57887d3793cee58de0ded13f98ad3 100644 (file)
@@ -28,7 +28,7 @@ export LD_LIBRARY_PATH=${QT4_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
 ##
 #------ boost ------
 export BOOST_ROOT_DIR=${PDIR}/boost-1.52.0
-export LD_LIBRARY_PATH=${BOOST_ROOT_DIR}/lib
+export LD_LIBRARY_PATH=${BOOST_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
 ##
 #------ swig ------
 export SWIG_ROOT_DIR=${PDIR}/swig-2.0.8
@@ -97,8 +97,13 @@ export CASROOT=${CAS_ROOT_DIR}
 ##
 export LIB=${LD_LIBRARY_PATH}
 
+#------ lcov ------
+export LCOV_ROOT_DIR=${PDIR}/lcov-1.11
+export PATH=${LCOV_ROOT_DIR}/bin:${PATH}
+
 #------ NewGEOM ------
 export INST_DIR=${ROOT_DIR}/install
 export PATH=${INST_DIR}/bin:${INST_DIR}/plugins:${PATH}
-export LD_LIBRARY_PATH=${INST_DIR}/bin:${INST_DIR}/swig:${INST_DIR}/plugins:${PATH}${LD_LIBRARY_PATH}
+export PYTHONPATH=${INST_DIR}/swig:${PYTHONPATH}
+export LD_LIBRARY_PATH=${INST_DIR}/bin:${INST_DIR}/swig:${INST_DIR}/plugins:${LD_LIBRARY_PATH}
 export NEW_GEOM_CONFIG_FILE=${INST_DIR}/plugins
index 53e34ce9746f399f5771cb8b4fad3c63091981eb..9cd9d082cedb5969b7e95ba9163409ee48591705 100644 (file)
 #include <Events_Loop.h>
 #include <Events_Error.h>
 
+
 using namespace std;
 
 Model_Data::Model_Data()
 {
 }
 
-void Model_Data::setLabel(TDF_Label& theLab)
+void Model_Data::setLabel(TDF_Label theLab)
 {
   myLab = theLab;
 }
index 34f3ec7a98ba3e17ddac4526326e3700a92dc31d..c63bce4760be2f493f829d01c9fd691331ad2623 100644 (file)
@@ -90,7 +90,7 @@ public:
   MODEL_EXPORT virtual void sendAttributeUpdated(ModelAPI_Attribute* theAttr);
 
   /// Puts feature to the document data sub-structure
-  MODEL_EXPORT void setLabel(TDF_Label& theLab);
+  MODEL_EXPORT void setLabel(TDF_Label theLab);
 
   /// Sets the object of this data
   MODEL_EXPORT virtual void setObject(ObjectPtr theObject)
index 88a0914ff9c1dc539f233f719f6c43c1db1d7711..f63dbbb25a6bc478b95fbc7a218779a298672d8b 100644 (file)
@@ -20,6 +20,8 @@
 #include <TDataStd_HLabelArray1.hxx>
 #include <TDataStd_Name.hxx>
 #include <TDF_Reference.hxx>
+#include <TDF_ChildIDIterator.hxx>
+#include <TDF_LabelMapHasher.hxx>
 
 #include <climits>
 #ifndef WIN32
@@ -355,13 +357,13 @@ FeaturePtr Model_Document::addFeature(std::string theID)
   if (aFeature) {
     TDF_Label aFeatureLab;
     if (!aFeature->isAction()) {// do not add action to the data model
-      TDF_Label aFeaturesLab = aDocToAdd->groupLabel(ModelAPI_Feature::group());
+      TDF_Label aFeaturesLab = aDocToAdd->featuresLabel();
       aFeatureLab = aFeaturesLab.NewChild();
       aDocToAdd->initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS);
       // keep the feature ID to restore document later correctly
       TDataStd_Comment::Set(aFeatureLab, aFeature->getKind().c_str());
       aDocToAdd->setUniqueName(aFeature);
-      aDocToAdd->myObjs[ModelAPI_Feature::group()].push_back(aFeature);
+      aDocToAdd->myObjs.Bind(aFeatureLab, aFeature);
       // store feature in the history of features array
       if (aFeature->isInHistory()) {
         AddToRefArray(aFeaturesLab, aFeatureLab);
@@ -411,20 +413,14 @@ void Model_Document::removeFeature(FeaturePtr theFeature)
 {
   boost::shared_ptr<Model_Data> aData = boost::static_pointer_cast<Model_Data>(theFeature->data());
   TDF_Label aFeatureLabel = aData->label().Father();
-  // remove feature from the myObjects list
-  std::vector<ObjectPtr>& aVec = myObjs[ModelAPI_Feature::group()];
-  std::vector<ObjectPtr>::iterator anIter = aVec.begin();
-  while(anIter != aVec.end()) {
-    if (*anIter == theFeature) {
-      anIter = aVec.erase(anIter);
-    } else {
-      anIter++;
-    }
-  }
+  if (myObjs.IsBound(aFeatureLabel)) 
+    myObjs.UnBind(aFeatureLabel);
+  else return; // not found feature => do not remove
+
   // erase all attributes under the label of feature
   aFeatureLabel.ForgetAllAttributes();
   // remove it from the references array
-  RemoveFromRefArray(groupLabel(ModelAPI_Feature::group()), aData->label());
+  RemoveFromRefArray(featuresLabel(), aData->label());
 
   // event: feature is deleted
   ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group());
@@ -440,43 +436,21 @@ void Model_Document::removeFeature(FeaturePtr theFeature)
   }
 }
 
-/// returns the object group name by the object label
-static std::string groupName(TDF_Label theObjectLabel) {
-  TDF_Label aGroupLab = theObjectLabel.Father();
-  Handle(TDataStd_Comment) aComment;
-  if (aGroupLab.FindAttribute(TDataStd_Comment::GetID(), aComment))
-    return std::string(TCollection_AsciiString(aComment->Get()).ToCString());
-  return ""; // not found
-}
-
 FeaturePtr Model_Document::feature(TDF_Label& theLabel)
 {
-  // iterate all features, may be optimized later by keeping labels-map
-  std::vector<ObjectPtr>& aVec = myObjs[ModelAPI_Feature::group()];
-  std::vector<ObjectPtr>::iterator aFIter = aVec.begin();
-  for(; aFIter != aVec.end(); aFIter++) {
-    boost::shared_ptr<Model_Data> aData = 
-      boost::dynamic_pointer_cast<Model_Data>((*aFIter)->data());
-    if (aData->label().IsEqual(theLabel))
-      return boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
-  }
+  if (myObjs.IsBound(theLabel))
+    return myObjs.Find(theLabel);
   return FeaturePtr(); // not found
 }
 
-ObjectPtr Model_Document::object(TDF_Label& theLabel)
+ObjectPtr Model_Document::object(TDF_Label theLabel)
 {
-  // iterate all features, may be optimized later by keeping labels-map
-  std::vector<ObjectPtr>& aVec = myObjs[ModelAPI_Feature::group()];
-  std::vector<ObjectPtr>::iterator aFIter = aVec.begin();
-  for(; aFIter != aVec.end(); aFIter++) {
-    boost::shared_ptr<Model_Data> aData = 
-      boost::dynamic_pointer_cast<Model_Data>((*aFIter)->data());
-    if (aData->label().IsEqual(theLabel))
-      return *aFIter;
-    std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = 
-      boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter)->results();
-    std::list<boost::shared_ptr<ModelAPI_Result> >::iterator aRIter = aResults.begin();
-    for(; aRIter != aResults.end(); aRIter++) {
+  TDF_Label aFeatureLabel = theLabel.Father().Father();
+  FeaturePtr aFeature = feature(aFeatureLabel);
+  if (aFeature) {
+    const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
+    std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.cbegin();
+    for(; aRIter != aResults.cend(); aRIter++) {
       boost::shared_ptr<Model_Data> aResData = 
         boost::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
       if (aResData->label().IsEqual(theLabel))
@@ -497,39 +471,30 @@ boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(std::string the
 ObjectPtr Model_Document::object(const std::string& theGroupID, const int theIndex)
 {
   if (theGroupID == ModelAPI_Feature::group()) {
-    // features may be not in history but in the myObjs, so, iterate all
+    Handle(TDataStd_ReferenceArray) aRefs;
+    if (!featuresLabel().FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs))
+      return ObjectPtr();
+    if (aRefs->Lower() > theIndex || aRefs->Upper() < theIndex)
+      return ObjectPtr();
+    TDF_Label aFeatureLabel = aRefs->Value(theIndex);
+    return feature(aFeatureLabel);
+  } else {
+    // comment must be in any feature: it is kind
     int anIndex = 0;
-    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = 
-      myObjs.find(ModelAPI_Feature::group());
-    if (aFind != myObjs.end()) {
-      std::vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
-      for(; aFIter != aFind->second.end(); aFIter++) {
-        if ((*aFIter)->isInHistory()) {
-          if (theIndex == anIndex)
-            return *aFIter;
+    TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID());
+    for(; aLabIter.More(); aLabIter.Next()) {
+      TDF_Label aFLabel = aLabIter.Value()->Label();
+      FeaturePtr aFeature = feature(aFLabel);
+      const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
+      std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+      for(; aRIter != aResults.cend(); aRIter++) {
+        if ((*aRIter)->isInHistory() && (*aRIter)->groupName() == theGroupID) {
+          if (anIndex == theIndex)
+            return *aRIter;
           anIndex++;
         }
       }
     }
-  } else {
-    // iterate all features in order to find the needed result
-    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = 
-      myObjs.find(ModelAPI_Feature::group());
-    if (aFind != myObjs.end()) {
-      std::vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
-      for(int anIndex = 0; aFIter != aFind->second.end(); aFIter++) {
-        const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = 
-          boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter)->results();
-        std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
-        for(; aRIter != aResults.cend(); aRIter++) {
-          if ((*aRIter)->isInHistory() && (*aRIter)->groupName() == theGroupID) {
-            if (anIndex == theIndex)
-              return *aRIter;
-            anIndex++;
-          }
-        }
-      }
-    }
   }
   // not found
   return ObjectPtr();
@@ -539,31 +504,20 @@ int Model_Document::size(const std::string& theGroupID)
 {
   int aResult = 0;
   if (theGroupID == ModelAPI_Feature::group()) {
-    // features may be not in history but in the myObjs, so, iterate all
-    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = 
-      myObjs.find(ModelAPI_Feature::group());
-    if (aFind != myObjs.end()) {
-      std::vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
-      for(; aFIter != aFind->second.end(); aFIter++) {
-        if ((*aFIter)->isInHistory()) {
-          aResult++;
-        }
-      }
-    }
+    Handle(TDataStd_ReferenceArray) aRefs;
+    if (featuresLabel().FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs))
+      return aRefs->Length();
   } else {
-    // iterate all features in order to find the needed result
-    std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = 
-      myObjs.find(ModelAPI_Feature::group());
-    if (aFind != myObjs.end()) {
-      std::vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
-      for(; aFIter != aFind->second.end(); aFIter++) {
-        const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = 
-          boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter)->results();
-        std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
-        for(; aRIter != aResults.cend(); aRIter++) {
-          if ((*aRIter)->isInHistory() && (*aRIter)->groupName() == theGroupID) {
-            aResult++;
-          }
+    // comment must be in any feature: it is kind
+    TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID());
+    for(; aLabIter.More(); aLabIter.Next()) {
+      TDF_Label aFLabel = aLabIter.Value()->Label();
+      FeaturePtr aFeature = feature(aFLabel);
+      const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
+      std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+      for(; aRIter != aResults.cend(); aRIter++) {
+        if ((*aRIter)->isInHistory() && (*aRIter)->groupName() == theGroupID) {
+          aResult++;
         }
       }
     }
@@ -586,32 +540,19 @@ Model_Document::Model_Document(const std::string theID)
   myDoc->CommitCommand();
 }
 
-TDF_Label Model_Document::groupLabel(const std::string theGroup)
+TDF_Label Model_Document::featuresLabel()
 {
-  // searching for existing
-  TCollection_ExtendedString aGroup(theGroup.c_str());
-  TDF_ChildIDIterator aGroupIter(myDoc->Main().FindChild(TAG_OBJECTS), TDataStd_Comment::GetID());
-  for(; aGroupIter.More(); aGroupIter.Next()) {
-    Handle(TDataStd_Comment) aName = Handle(TDataStd_Comment)::DownCast(aGroupIter.Value());
-    if (aName->Get() == aGroup)
-      return aGroupIter.Value()->Label();
-  }
-  // create a new
-  TDF_Label aNew = myDoc->Main().FindChild(TAG_OBJECTS).NewChild();
-  TDataStd_Comment::Set(aNew, aGroup);
-  return aNew;
+  return myDoc->Main().FindChild(TAG_OBJECTS);
 }
 
 void Model_Document::setUniqueName(FeaturePtr theFeature)
 {
   std::string aName; // result
   // first count all objects of such kind to start with index = count + 1
-  int a, aNumObjects = 0;
-  int aSize = myObjs.find(ModelAPI_Feature::group()) == myObjs.end() ? 
-    0 : myObjs[ModelAPI_Feature::group()].size();
-  for(a = 0; a < aSize; a++) {
-    if (boost::dynamic_pointer_cast<ModelAPI_Feature>(myObjs[ModelAPI_Feature::group()][a])->
-        getKind() == theFeature->getKind())
+  int aNumObjects = 0;
+  NCollection_DataMap<TDF_Label, FeaturePtr>::Iterator aFIter(myObjs);
+  for(; aFIter.More(); aFIter.Next()) {
+    if (aFIter.Value()->getKind() == theFeature->getKind())
       aNumObjects++;
   }
   // generate candidate name
@@ -619,9 +560,8 @@ void Model_Document::setUniqueName(FeaturePtr theFeature)
   aNameStream<<theFeature->getKind()<<"_"<<aNumObjects + 1;
   aName = aNameStream.str();
   // check this is unique, if not, increase index by 1
-  for(a = 0; a < aSize;) {
-    FeaturePtr aFeature = 
-      boost::dynamic_pointer_cast<ModelAPI_Feature>(myObjs[ModelAPI_Feature::group()][a]);
+  for(aFIter.Initialize(myObjs); aFIter.More(); ) {
+    FeaturePtr aFeature = aFIter.Value();
     bool isSameName = aFeature->isInHistory() && aFeature->data()->name() == aName;
     if (!isSameName) { // check also results to avoid same results names (actual for Parts)
       const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
@@ -636,13 +576,13 @@ void Model_Document::setUniqueName(FeaturePtr theFeature)
       aNameStream<<theFeature->getKind()<<"_"<<aNumObjects + 1;
       aName = aNameStream.str();
       // reinitialize iterator to make sure a new name is unique
-      a = 0;
-    } else a++;
+      aFIter.Initialize(myObjs);
+    } else aFIter.Next();
   }
   theFeature->data()->setName(aName);
 }
 
-void Model_Document::initData(ObjectPtr theObj, TDF_Label& theLab, const int theTag) {
+void Model_Document::initData(ObjectPtr theObj, TDF_Label theLab, const int theTag) {
   boost::shared_ptr<ModelAPI_Document> aThis = 
     Model_Application::getApplication()->getDocument(myID);
   boost::shared_ptr<Model_Data> aData(new Model_Data);
@@ -658,73 +598,59 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
 {
   boost::shared_ptr<ModelAPI_Document> aThis = 
     Model_Application::getApplication()->getDocument(myID);
-  // update all objects: iterate from the end: as they appeared in the list
-  std::map<std::string, std::vector<ObjectPtr> >::reverse_iterator aGroupIter = myObjs.rbegin();
-  for(; aGroupIter != myObjs.rend(); aGroupIter++) {
-    std::vector<ObjectPtr>::iterator anObjIter = aGroupIter->second.begin();
-    // and in parallel iterate labels of features
-    const std::string& aGroupName = aGroupIter->first;
-    TDF_ChildIDIterator aLabIter(groupLabel(aGroupName), TDataStd_Comment::GetID());
-    while(anObjIter != aGroupIter->second.end() || aLabIter.More()) {
-      static const int INFINITE_TAG = INT_MAX; // no label means that it exists somwhere in infinite
-      int aFeatureTag = INFINITE_TAG; 
-      if (anObjIter != aGroupIter->second.end()) { // existing tag for feature
-        boost::shared_ptr<Model_Data> aData = 
-          boost::dynamic_pointer_cast<Model_Data>((*anObjIter)->data());
-        aFeatureTag = aData->label().Tag();
+  // update all objects by checking are they of labels or not
+  std::set<FeaturePtr> aCheckedFeatures;
+  TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID());
+  for(; aLabIter.More(); aLabIter.Next()) {
+    TDF_Label aFeatureLabel = aLabIter.Value()->Label();
+    if (!myObjs.IsBound(aFeatureLabel)) { // a new feature is inserted
+      // create a feature
+      FeaturePtr aNewObj = ModelAPI_PluginManager::get()->createFeature(
+        TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(aLabIter.Value())->Get())
+        .ToCString());
+      // this must be before "setData" to redo the sketch line correctly
+      myObjs.Bind(aFeatureLabel, aNewObj);
+      aCheckedFeatures.insert(aNewObj);
+      initData(aNewObj, aFeatureLabel, TAG_FEATURE_ARGUMENTS);
+      aNewObj->execute(); // to restore results list
+
+      // event: model is updated
+      static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+      ModelAPI_EventCreator::get()->sendUpdated(aNewObj, anEvent);
+      // feature for this label is added, so go to the next label
+    } else { // nothing is changed, both iterators are incremented
+      aCheckedFeatures.insert(myObjs.Find(aFeatureLabel));
+      if (theMarkUpdated) {
+        static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+        ModelAPI_EventCreator::get()->sendUpdated(myObjs.Find(aFeatureLabel), anEvent);
       }
-      int aDSTag = INFINITE_TAG; 
-      if (aLabIter.More()) { // next label in DS is existing
-        aDSTag = aLabIter.Value()->Label().Tag();
+    }
+  }
+  // check all features are checked: if not => it was removed
+  NCollection_DataMap<TDF_Label, FeaturePtr>::Iterator aFIter(myObjs);
+  while(aFIter.More()) {
+    if (aCheckedFeatures.find(aFIter.Value()) == aCheckedFeatures.end()) {
+      FeaturePtr aFeature = aFIter.Value();
+      TDF_Label aLab = aFIter.Key();
+      aFIter.Next();
+      myObjs.UnBind(aLab);
+      // event: model is updated
+      if (aFeature->isInHistory()) {
+        ModelAPI_EventCreator::get()->sendDeleted(aThis, ModelAPI_Feature::group());
       }
-      if (aDSTag > aFeatureTag) { // feature is removed
-        ObjectPtr anObj = *anObjIter;
-        anObjIter = aGroupIter->second.erase(anObjIter);
-        // event: model is updated
-        if (anObj->isInHistory()) {
-          ModelAPI_EventCreator::get()->sendDeleted(aThis, aGroupName);
-        }
-        // results of this feature must be redisplayed (hided)
-        static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-        const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = boost::dynamic_pointer_cast<ModelAPI_Feature>(anObj)->results();
-        std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
-        for(; aRIter != aResults.cend(); aRIter++) {
-          boost::shared_ptr<ModelAPI_Result> aRes = *aRIter;
-          aRes->setData(boost::shared_ptr<ModelAPI_Data>()); // deleted flag
-          ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
-          ModelAPI_EventCreator::get()->sendDeleted(aThis, aRes->groupName());
-        }
-      } else if (aDSTag < aFeatureTag) { // a new feature is inserted
-        // create a feature
-        TDF_Label aLab = aLabIter.Value()->Label();
-        ObjectPtr aNewObj = ModelAPI_PluginManager::get()->createFeature(
-          TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(aLabIter.Value())->Get())
-          .ToCString());
-        // this must be before "setData" to redo the sketch line correctly
-        if (anObjIter == aGroupIter->second.end()) {
-          aGroupIter->second.push_back(aNewObj);
-          anObjIter = aGroupIter->second.end();
-        } else {
-          anObjIter++;
-          aGroupIter->second.insert(anObjIter, aNewObj);
-        }
-        initData(aNewObj, aLab, TAG_FEATURE_ARGUMENTS);
-
-        // event: model is updated
-        static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
-        ModelAPI_EventCreator::get()->sendUpdated(aNewObj, anEvent);
-        // feature for this label is added, so go to the next label
-        aLabIter.Next();
-      } else { // nothing is changed, both iterators are incremented
-        if (theMarkUpdated) {
-          static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
-          ModelAPI_EventCreator::get()->sendUpdated(*anObjIter, anEvent);
-        }
-        anObjIter++;
-        aLabIter.Next();
+      // results of this feature must be redisplayed (hided)
+      static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+      const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
+      std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+      for(; aRIter != aResults.cend(); aRIter++) {
+        boost::shared_ptr<ModelAPI_Result> aRes = *aRIter;
+        aRes->setData(boost::shared_ptr<ModelAPI_Data>()); // deleted flag
+        ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
+        ModelAPI_EventCreator::get()->sendDeleted(aThis, aRes->groupName());
       }
-    }
+    } else aFIter.Next();
   }
+
   // after all updates, sends a message that groups of features were created or updated
   boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())->
     setCheckTransactions(false);
@@ -745,8 +671,6 @@ void Model_Document::storeResult(boost::shared_ptr<ModelAPI_Data> theFeatureData
   initData(theResult, boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->
     label().Father().FindChild(TAG_FEATURE_RESULTS), theResultIndex);
   if (theResult->data()->name().empty()) { // if was not initialized, generate event and set a name
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
-    ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent);
     theResult->data()->setName(theFeatureData->name());
   }
 }
@@ -802,21 +726,20 @@ boost::shared_ptr<ModelAPI_ResultPart> Model_Document::createPart(
 boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(
   const boost::shared_ptr<ModelAPI_Result>& theResult)
 {
-  // iterate all features in order to find the needed result
-  std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = 
-    myObjs.find(ModelAPI_Feature::group());
-  if (aFind != myObjs.end()) {
-    std::vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
-    for(; aFIter != aFind->second.end(); aFIter++) {
-      FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
-      const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
-      std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
-      for(; aRIter != aResults.cend(); aRIter++) {
-        if (*aRIter == theResult) {
-          return aFeature;
-        }
-      }
-    }
+  boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theResult->data());
+  if (aData) {
+    TDF_Label aFeatureLab = aData->label().Father().Father();
+    return feature(aFeatureLab);
   }
   return FeaturePtr();
 }
+
+Standard_Integer HashCode(const TDF_Label& theLab,const Standard_Integer theUpper)
+{
+  return TDF_LabelMapHasher::HashCode(theLab, theUpper);
+
+}
+Standard_Boolean IsEqual(const TDF_Label& theLab1,const TDF_Label& theLab2)
+{
+  return TDF_LabelMapHasher::IsEqual(theLab1, theLab2);
+}
index db353a93babe0e59fa71ae479b6eceb8652b4091..340ecd4ccf9d662be95224b9c883686c01a1ac99 100644 (file)
 #include <ModelAPI_Result.h>
 
 #include <TDocStd_Document.hxx>
+#include <NCollection_DataMap.hxx>
+#include <TDF_Label.hxx>
 #include <map>
 #include <set>
 
 class Handle_Model_Document;
 
+// for TDF_Label map usage
+static  Standard_Integer HashCode(const TDF_Label& theLab,const Standard_Integer theUpper);
+static  Standard_Boolean IsEqual(const TDF_Label& theLab1,const TDF_Label& theLab2);
+
 /**\class Model_Document
  * \ingroup DataModel
  * \brief Document for internal data structure of any object storage.
@@ -74,7 +80,7 @@ public:
 
   //! Returns the existing object: result or feature
   //! \param theLabel base label of the object
-  MODEL_EXPORT virtual ObjectPtr object(TDF_Label& theLabel);
+  MODEL_EXPORT virtual ObjectPtr object(TDF_Label theLabel);
 
   //! Adds a new sub-document by the identifier, or returns existing one if it is already exist
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID);
@@ -108,8 +114,8 @@ public:
 
 protected:
 
-  //! Returns (creates if needed) the group label
-  TDF_Label groupLabel(const std::string theGroup);
+  //! Returns (creates if needed) the features label
+  TDF_Label featuresLabel();
 
   //! Initializes feature with a unique name in this group (unique name is generated as 
   //! feature type + "_" + index
@@ -127,7 +133,7 @@ protected:
   void compactNested();
 
   //! Initializes the data fields of the feature
-  void Model_Document::initData(ObjectPtr theObj, TDF_Label& theLab, const int theTag);
+  void initData(ObjectPtr theObj, TDF_Label theLab, const int theTag);
 
   //! Allows to store the result in the data tree of the document (attaches 'data' of result to tree)
   MODEL_EXPORT virtual void storeResult(boost::shared_ptr<ModelAPI_Data> theFeatureData,
@@ -145,8 +151,9 @@ private:
   int myTransactionsAfterSave;
   /// number of nested transactions performed (or -1 if not nested)
   int myNestedNum;
-  /// All objects managed by this document (not only in history of OB)
-  std::map<std::string, std::vector<ObjectPtr> > myObjs;
+  /// All features managed by this document (not only in history of OB)
+  /// For optimization mapped by labels
+  NCollection_DataMap<TDF_Label, FeaturePtr> myObjs;
 
   ///< set of identifiers of sub-documents of this document
   std::set<std::string> mySubs;
index 78d9901e685a9be732fa4c6cc6fafcb288a00361..a79ea6a88443b7d50f8ec5d0c9d5f2094a7cf231 100644 (file)
@@ -24,10 +24,11 @@ SET(PROJECT_HEADERS
     ModelAPI_ResultBody.h
     ModelAPI_ResultConstruction.h
     ModelAPI_ResultPart.h
-       ModelAPI_ResultParameters.h
+    ModelAPI_ResultParameters.h
 )
 
 SET(PROJECT_SOURCES
+    ModelAPI_Feature.cpp
     ModelAPI_PluginManager.cpp
 )
 
index b897c1b4250e173bb3591bdd0ac425b330f07ff5..d6004f7af4fd1bf1d0c3318a22a91050c0c05ec5 100644 (file)
@@ -33,7 +33,7 @@ public:
   MODELAPI_EXPORT virtual int size() = 0;
 
   /// Returns the list of features
-  MODELAPI_EXPORT virtual std::list<ObjectPtr > list() = 0;
+  MODELAPI_EXPORT virtual std::list<ObjectPtr> list() = 0;
 
 protected:
   /// Objects are created for features automatically
diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp
new file mode 100644 (file)
index 0000000..882e99a
--- /dev/null
@@ -0,0 +1,50 @@
+// File:        ModelAPI_Feature.cpp
+// Created:     17 Jul 2014
+// Author:      Mikhail PONIKAROV
+
+#include "ModelAPI_Feature.h"
+#include <ModelAPI_Events.h>
+#include <ModelAPI_Result.h>
+#include <Events_Loop.h>
+
+const std::list<boost::shared_ptr<ModelAPI_Result> >& ModelAPI_Feature::results() 
+{
+  return myResults;
+}
+
+boost::shared_ptr<ModelAPI_Result> ModelAPI_Feature::firstResult() 
+{
+  return myResults.empty() ? boost::shared_ptr<ModelAPI_Result>() : *(myResults.begin());
+}
+
+void ModelAPI_Feature::setResult(const boost::shared_ptr<ModelAPI_Result>& theResult) 
+{
+  if (firstResult() == theResult) { // just updated
+    static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+    ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent);
+    return;
+  }
+  // created
+  while(!myResults.empty()) { // remove one by one with messages
+    boost::shared_ptr<ModelAPI_Result> aRes = *(myResults.begin());
+    myResults.erase(myResults.begin());
+    ModelAPI_EventCreator::get()->sendDeleted(aRes->document(), aRes->groupName());
+  }
+  myResults.push_back(theResult);
+  static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+  ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent);
+}
+
+boost::shared_ptr<ModelAPI_Document> ModelAPI_Feature::documentToAdd()
+{
+  return ModelAPI_PluginManager::get()->currentDocument();
+}
+
+ModelAPI_Feature::~ModelAPI_Feature()
+{
+  while(!myResults.empty()) { // remove one by one with messages
+    boost::shared_ptr<ModelAPI_Result> aRes = *(myResults.begin());
+    myResults.erase(myResults.begin());
+    ModelAPI_EventCreator::get()->sendDeleted(aRes->document(), aRes->groupName());
+  }
+}
index 3770c06f02a00bb9d522b0ca2642485f77efa42e..2305044edd546e0905e5e07d2d6b8daff88dba3f 100644 (file)
@@ -43,13 +43,11 @@ public:
   virtual void execute() = 0;
 
   /// returns the current results of the feature
-  std::list<boost::shared_ptr<ModelAPI_Result> >& results() {return myResults;}
+  MODELAPI_EXPORT const std::list<boost::shared_ptr<ModelAPI_Result> >& results();
   /// returns the first result in the list or NULL reference
-  boost::shared_ptr<ModelAPI_Result> firstResult() 
-  {return myResults.empty() ? boost::shared_ptr<ModelAPI_Result>() : *(myResults.begin());}
+  MODELAPI_EXPORT boost::shared_ptr<ModelAPI_Result> firstResult();
   /// sets the alone result
-  void setResult(const boost::shared_ptr<ModelAPI_Result>& theResult) 
-  {myResults.clear(); myResults.push_back(theResult);}
+  MODELAPI_EXPORT void setResult(const boost::shared_ptr<ModelAPI_Result>& theResult);
 
   /// Returns true if this feature must not be created: this is just an action
   /// that is not stored in the features history and data model (like "delete part").
@@ -57,11 +55,10 @@ public:
 
   /// Must return document where the new feature must be added to
   /// By default it is current document
-  virtual boost::shared_ptr<ModelAPI_Document> documentToAdd()
-  {return ModelAPI_PluginManager::get()->currentDocument();}
+  MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> documentToAdd();
 
   /// To virtually destroy the fields of successors
-  virtual ~ModelAPI_Feature() {}
+  MODELAPI_EXPORT virtual ~ModelAPI_Feature();
 };
 
 //! Pointer on feature object
index 09ce4d6b0f6225b78242ae107ce7632b47079e5f..debc96d3e4f281d4a1f0c344c6b6b6830d9e257d 100644 (file)
@@ -8,6 +8,8 @@
 #include "ModelAPI_Result.h"
 #include <GeomAPI_Shape.h>
 
+#include <string>
+
 /**\class ModelAPI_ResultBody
  * \ingroup DataModel
  * \brief The body (shape) result of a feature.
@@ -20,8 +22,9 @@ class ModelAPI_ResultBody : public ModelAPI_Result
 {
 public:
   /// Returns the group identifier of this result
-  virtual std::string groupName()
-    { return group(); }
+  virtual std::string groupName() {
+    return group();
+  }
 
   /// Returns the group identifier of this result
   static std::string group()
index 4207ff5e3c42516d0a16dd60c96b0e9287c14cde..bd9220ae515033e8ef0c0392bb9b0456990eaa2d 100644 (file)
@@ -8,6 +8,8 @@
 #include "ModelAPI_Result.h"
 #include <GeomAPI_Shape.h>
 
+#include <string>
+
 /**\class ModelAPI_ResultConstruction
  * \ingroup DataModel
  * \brief The construction element result of a feature.
index 82e0cee5d79f28a663ad96fc341c149a7734b1a3..2f6feb5e5bae06a44166cd607656b943661ee65d 100644 (file)
@@ -7,6 +7,8 @@
 
 #include "ModelAPI_Result.h"
 
+#include <string>
+
 /**\class ModelAPI_ResultPart
  * \ingroup DataModel
  * \brief The Part document, result of a creation of new part feature.
index ba757565d4dd40614e5cbe2292f65cf62bc34a2d..e967a1d4918d7c855e4cf8a5353363873561d257 100644 (file)
@@ -15,7 +15,7 @@
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
 
 #include <Events_Loop.h>
 
index 81be8438b667393ef320e5b2030f3931002aa6be..2c5faadd25fdb9053aef8afb7bb9a9ca0d8213b2 100644 (file)
@@ -11,7 +11,7 @@
 #include <Config_WidgetAPI.h>
 
 #include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
 
 #include <QWidget>
 #include <QLayout>
index 587e1e04141fd09bb49e167d87b692ca623862c6..f246713cd7d5e6d54482a6f0b27bf3a547a513fc 100644 (file)
@@ -11,7 +11,7 @@
 #include <Config_WidgetAPI.h>
 
 #include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
 
 #include <QWidget>
 #include <QLayout>
index 1e00eb180ea7e65e3ce0d5edad56e11130403f59..16d4c52cbc60bc9dbdf0de0e2ae3a5389695e69f 100644 (file)
@@ -8,7 +8,7 @@
 #include <Config_WidgetAPI.h>
 
 #include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
 
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
index 5f625caeeafd045744a35b8504bd07e43e385445..2a65062b0828686a48437c0765064244f4b60165 100644 (file)
@@ -11,7 +11,7 @@
 #include <Config_WidgetAPI.h>
 
 #include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
 
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
index a26a70d0ac81c569af8b5c72af442f1b1fe28e47..87a1a88c2bd226cc68e3e9a820c7736b8ce1ac12 100644 (file)
@@ -11,7 +11,7 @@
 #include <Config_WidgetAPI.h>
 
 #include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
 
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
index 51db5770b64f28dc04fb1aa6b88423e1fb7bcf1f..cefa9284771c98de52d5b0ebf2f55af5febd0e02 100644 (file)
@@ -9,7 +9,7 @@
 #include <Config_WidgetAPI.h>
 
 #include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
 
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
index 88aa9c3816570569346f60c04b4290928558197c..5e0cd3e9837fce05a1d1cca2d2c49c42cc2bb396 100644 (file)
@@ -8,7 +8,7 @@
 #include "ModuleBase_Tools.h"
 
 #include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
@@ -30,6 +30,8 @@
 #include <QEvent>
 #include <QDockWidget>
 
+#include <stdexcept>
+
 
 typedef QMap<QString, TopAbs_ShapeEnum> ShapeTypes;
 static ShapeTypes MyShapeTypes;
@@ -250,4 +252,4 @@ void ModuleBase_WidgetSelector::raisePanel() const
     QDockWidget* aTabWgt = (QDockWidget*) aParent;
     aTabWgt->raise();
   }
-}
\ No newline at end of file
+}
index 4999e4f53ef03d6d221634c176eb9ca8563a21c1..8e05584b9cb6e9bdf84d4e31990b6c9216e803f4 100644 (file)
@@ -330,9 +330,9 @@ void PartSet_Module::onStopSelection(const QFeatureList& theFeatures, const bool
   QResultList aResults;
   foreach(FeaturePtr aFeature, theFeatures) {
     if (aFeature->results().size() > 0) {
-      std::list<ResultPtr>& aResList = aFeature->results();
-      std::list<ResultPtr>::iterator aIt;
-      for (aIt = aResList.begin(); aIt != aResList.end(); ++aIt)
+      const std::list<ResultPtr>& aResList = aFeature->results();
+      std::list<ResultPtr>::const_iterator aIt;
+      for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt)
         aResults.append(*aIt);
     }
   }
index e5eb1f301197d75ec6452a0acc4a73849004dbfb..1445df99b718c0c335f0e43da15c61d987895ef3 100644 (file)
@@ -78,7 +78,7 @@ void SketchPlugin_Arc::execute()
       boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
         document()->createConstruction(data());
       aConstr->setShape(aCompound);
-      results().push_back(aConstr);
+      setResult(aConstr);
     }
   }
 }
index 4818f6608be77bf57e34471bd414b73c520edb16..fe1faa56db70f3b18e20855641ce48e3963da796 100644 (file)
@@ -5,8 +5,8 @@
 #include "SketchPlugin_ConstraintDistance.h"
 #include <SketchPlugin_Point.h>
 
-#include <GeomAPI_Lin2D.h>
-#include <GeomAPI_Pnt2D.h>
+#include <GeomAPI_Lin2d.h>
+#include <GeomAPI_Pnt2d.h>
 #include <GeomDataAPI_Point2D.h>
 
 #include <ModelAPI_AttributeDouble.h>
index e21bb346acbb9b52dd4613f480b911885637e4e1..d9e10c85e2a214d98e4fc3ac276aae62a0448476 100644 (file)
@@ -9,6 +9,7 @@
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Events.h>
+#include <ModelAPI_Object.h>
 
 #include <SketchPlugin_Constraint.h>
 
@@ -18,6 +19,8 @@
 #include <SketchPlugin_Point.h>
 #include <SketchPlugin_Sketch.h>
 
+#include <list>
+
 
 // Initialization of constraint manager self pointer
 SketchSolver_ConstraintManager* SketchSolver_ConstraintManager::_self = 0;
@@ -353,8 +356,8 @@ boost::shared_ptr<SketchPlugin_Feature> SketchSolver_ConstraintManager::findWork
 
     boost::shared_ptr<ModelAPI_AttributeRefList> aWPFeatures =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aWP->data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
-    std::list< ObjectPtr >& aFeaturesList = aWPFeatures->list();
-    std::list< ObjectPtr >::const_iterator anIter;
+    std::list<ObjectPtr> aFeaturesList = aWPFeatures->list();
+    std::list<ObjectPtr>::const_iterator anIter;
     for (anIter = aFeaturesList.begin(); anIter != aFeaturesList.end(); anIter++)
       if (*anIter == theConstraint)
         return aWP; // workplane is found
index 4380786974b39ccc470174b26c01fd4a8e9236d7..67ba7629dcd28365ffb75f99e84791f2d7db21b2 100644 (file)
@@ -115,7 +115,6 @@ INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events
                                         ${PROJECT_SOURCE_DIR}/src/PyConsole
                                         ${PROJECT_SOURCE_DIR}/src/ModelAPI
                                         ${PROJECT_SOURCE_DIR}/src/GeomAPI
-                                    ${PROJECT_SOURCE_DIR}/src/Model
                                         ${PROJECT_SOURCE_DIR}/src/ModuleBase
                                         ${PROJECT_SOURCE_DIR}/src/PartSetPlugin
                                         ${CAS_INCLUDE_DIRS})
index a9c3f7a48ca1b56f983cca7c27deb58330146a8e..45788794fd2570b3871679f5008a39dcebe86657 100644 (file)
@@ -8,7 +8,7 @@
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_ResultPart.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
 #include <ModelAPI_Object.h>
 
 #include <Events_Loop.h>
@@ -19,6 +19,7 @@
 #include <QString>
 #include <QBrush>
 
+#include <set>
 
 #define ACTIVE_COLOR QColor(0,72,140)
 #define PASSIVE_COLOR Qt::black
@@ -49,7 +50,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
 
   // Created object event *******************
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
-    const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
+    const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
     std::set<ObjectPtr> aObjects = aUpdMsg->objects();
 
     std::set<ObjectPtr>::const_iterator aIt;
@@ -93,7 +94,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
     }
   // Deleted object event ***********************
   } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
-    const Model_ObjectDeletedMessage* aUpdMsg = dynamic_cast<const Model_ObjectDeletedMessage*>(theMessage);
+    const ModelAPI_ObjectDeletedMessage* aUpdMsg = dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
     DocumentPtr aDoc = aUpdMsg->document();
     std::set<std::string> aGroups = aUpdMsg->groups();
 
@@ -135,7 +136,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
     }
   // Deleted object event ***********************
   } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
-    //const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
+    //const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
     //ObjectPtr aFeature = aUpdMsg->feature();
     //DocumentPtr aDoc = aFeature->document();
     
index b047562126338358a2e1aa3da493d386a3549bdc..9b0a8f0867a8183a040da712b69b4a81db6cc7d7 100644 (file)
@@ -23,7 +23,7 @@
 #include "XGUI_ContextMenuMgr.h"
 #include "XGUI_ModuleConnector.h"
 
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
@@ -232,14 +232,14 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
 
   // Process creation of Part
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
-    const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
+    const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
     onFeatureCreatedMsg(aUpdMsg);
     return;
   }
 
   // Redisplay feature
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
-    const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
+    const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
     onFeatureRedisplayMsg(aUpdMsg);
     return;
   }
@@ -247,15 +247,15 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
   //Update property panel on corresponding message. If there is no current operation (no
   //property panel), or received message has different feature to the current - do nothing.
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
-    const Model_ObjectUpdatedMessage* anUpdateMsg =
-        dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
+    const ModelAPI_ObjectUpdatedMessage* anUpdateMsg =
+        dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
     onFeatureUpdatedMsg(anUpdateMsg);
     return;
   }
 
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
-    const Model_ObjectDeletedMessage* aDelMsg =
-        dynamic_cast<const Model_ObjectDeletedMessage*>(theMessage);
+    const ModelAPI_ObjectDeletedMessage* aDelMsg =
+        dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
     onObjectDeletedMsg(aDelMsg);
     return;
   }
@@ -283,7 +283,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
 }
 
 //******************************************************
-void XGUI_Workshop::onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg)
+void XGUI_Workshop::onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg)
 {
   std::set<ObjectPtr> aFeatures = theMsg->objects();
   if (myOperationMgr->hasOperation())
@@ -301,7 +301,7 @@ void XGUI_Workshop::onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg
 }
 
 //******************************************************
-void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg)
+void XGUI_Workshop::onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* theMsg)
 {
   std::set<ObjectPtr> aObjects = theMsg->objects();
   std::set<ObjectPtr>::const_iterator aIt;
@@ -317,7 +317,7 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theM
 }
 
 //******************************************************
-void XGUI_Workshop::onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg)
+void XGUI_Workshop::onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg)
 {
   std::set<ObjectPtr> aObjects = theMsg->objects();
 
@@ -344,7 +344,7 @@ void XGUI_Workshop::onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg
 }
 
 //******************************************************
-void XGUI_Workshop::onObjectDeletedMsg(const Model_ObjectDeletedMessage* theMsg)
+void XGUI_Workshop::onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theMsg)
 {
   //std::set<ObjectPtr> aFeatures = theMsg->objects();
 }
index 681afb312cd09e406e457296cc012309e05e0ea3..c0d5d64551235f98e38fd66280d39be3ebd8abe0 100644 (file)
@@ -38,8 +38,8 @@ class Config_PointerMessage;
 class QWidget;
 class QDockWidget;
 
-class Model_ObjectUpdatedMessage;
-class Model_ObjectDeletedMessage;
+class ModelAPI_ObjectUpdatedMessage;
+class ModelAPI_ObjectDeletedMessage;
 class QAction;
 
 /**\class XGUI_Workshop
@@ -154,10 +154,10 @@ protected:
   void connectWithOperation(ModuleBase_Operation* theOperation);
   void saveDocument(QString theName);
 
-  void onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg);
-  void onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg);
-  void onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg);
-  void onObjectDeletedMsg(const Model_ObjectDeletedMessage* theMsg);
+  void onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
+  void onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
+  void onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
+  void onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theMsg);
 
   QList<QAction*> getModuleCommands() const;