--- /dev/null
+#
+# 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
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)
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
##
#------ 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
##
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
#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;
}
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)
#include <TDataStd_HLabelArray1.hxx>
#include <TDataStd_Name.hxx>
#include <TDF_Reference.hxx>
+#include <TDF_ChildIDIterator.hxx>
+#include <TDF_LabelMapHasher.hxx>
#include <climits>
#ifndef WIN32
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);
{
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());
}
}
-/// 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))
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();
{
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++;
}
}
}
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
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();
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);
{
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);
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());
}
}
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);
+}
#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.
//! 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);
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
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,
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;
ModelAPI_ResultBody.h
ModelAPI_ResultConstruction.h
ModelAPI_ResultPart.h
- ModelAPI_ResultParameters.h
+ ModelAPI_ResultParameters.h
)
SET(PROJECT_SOURCES
+ ModelAPI_Feature.cpp
ModelAPI_PluginManager.cpp
)
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
--- /dev/null
+// 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());
+ }
+}
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").
/// 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
#include "ModelAPI_Result.h"
#include <GeomAPI_Shape.h>
+#include <string>
+
/**\class ModelAPI_ResultBody
* \ingroup DataModel
* \brief The body (shape) result of a feature.
{
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()
#include "ModelAPI_Result.h"
#include <GeomAPI_Shape.h>
+#include <string>
+
/**\class ModelAPI_ResultConstruction
* \ingroup DataModel
* \brief The construction element result of a feature.
#include "ModelAPI_Result.h"
+#include <string>
+
/**\class ModelAPI_ResultPart
* \ingroup DataModel
* \brief The Part document, result of a creation of new part feature.
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
#include <Events_Loop.h>
#include <Config_WidgetAPI.h>
#include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
#include <QWidget>
#include <QLayout>
#include <Config_WidgetAPI.h>
#include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
#include <QWidget>
#include <QLayout>
#include <Config_WidgetAPI.h>
#include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <Config_WidgetAPI.h>
#include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <Config_WidgetAPI.h>
#include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <Config_WidgetAPI.h>
#include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include "ModuleBase_Tools.h"
#include <Events_Loop.h>
-#include <Model_Events.h>
+#include <ModelAPI_Events.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
#include <QEvent>
#include <QDockWidget>
+#include <stdexcept>
+
typedef QMap<QString, TopAbs_ShapeEnum> ShapeTypes;
static ShapeTypes MyShapeTypes;
QDockWidget* aTabWgt = (QDockWidget*) aParent;
aTabWgt->raise();
}
-}
\ No newline at end of file
+}
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);
}
}
boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
document()->createConstruction(data());
aConstr->setShape(aCompound);
- results().push_back(aConstr);
+ setResult(aConstr);
}
}
}
#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>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_Object.h>
#include <SketchPlugin_Constraint.h>
#include <SketchPlugin_Point.h>
#include <SketchPlugin_Sketch.h>
+#include <list>
+
// Initialization of constraint manager self pointer
SketchSolver_ConstraintManager* SketchSolver_ConstraintManager::_self = 0;
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
${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})
#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>
#include <QString>
#include <QBrush>
+#include <set>
#define ACTIVE_COLOR QColor(0,72,140)
#define PASSIVE_COLOR Qt::black
// 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;
}
// 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();
}
// 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();
#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>
// 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;
}
//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;
}
}
//******************************************************
-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())
}
//******************************************************
-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;
}
//******************************************************
-void XGUI_Workshop::onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg)
+void XGUI_Workshop::onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg)
{
std::set<ObjectPtr> aObjects = theMsg->objects();
}
//******************************************************
-void XGUI_Workshop::onObjectDeletedMsg(const Model_ObjectDeletedMessage* theMsg)
+void XGUI_Workshop::onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theMsg)
{
//std::set<ObjectPtr> aFeatures = theMsg->objects();
}
class QWidget;
class QDockWidget;
-class Model_ObjectUpdatedMessage;
-class Model_ObjectDeletedMessage;
+class ModelAPI_ObjectUpdatedMessage;
+class ModelAPI_ObjectDeletedMessage;
class QAction;
/**\class XGUI_Workshop
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;