From: vsv Date: Wed, 23 Apr 2014 14:05:43 +0000 (+0400) Subject: Merge branch 'master' of newgeom:newgeom X-Git-Tag: V_0.2~132 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c80e8ac643930b858f4f653e2659896ba587b165;p=modules%2Fshaper.git Merge branch 'master' of newgeom:newgeom Conflicts: src/ModuleBase/ModuleBase_Operation.h src/PartSet/PartSet_OperationSketchBase.cpp --- c80e8ac643930b858f4f653e2659896ba587b165 diff --cc src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp index 000000000,c433491f9..5c1f39f2f mode 000000,100644..100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp @@@ -1,0 -1,24 +1,24 @@@ + #include "ConstructionPlugin_Plugin.h" + #include "ConstructionPlugin_Point.h" + #include + #include + + using namespace std; + + // the only created instance of this plugin + static ConstructionPlugin_Plugin* MY_INSTANCE = new ConstructionPlugin_Plugin(); + + ConstructionPlugin_Plugin::ConstructionPlugin_Plugin() + { + // register this plugin + ModelAPI_PluginManager::get()->registerPlugin(this); + } + -shared_ptr ConstructionPlugin_Plugin::createFeature(string theFeatureID) ++boost::shared_ptr ConstructionPlugin_Plugin::createFeature(string theFeatureID) + { + if (theFeatureID == "Point") { - return shared_ptr(new ConstructionPlugin_Point); ++ return boost::shared_ptr(new ConstructionPlugin_Point); + } + // feature of such kind is not found - return shared_ptr(); ++ return boost::shared_ptr(); + } diff --cc src/GeomAPI/GeomAPI.i index 000000000,717c7d264..3f65f05f2 mode 000000,100644..100644 --- a/src/GeomAPI/GeomAPI.i +++ b/src/GeomAPI/GeomAPI.i @@@ -1,0 -1,28 +1,29 @@@ + /* GeomAPI.i */ + %module GeomAPI + %{ - #include "memory" ++ #include "boost/shared_ptr.hpp" + #include "GeomAPI.h" + #include "GeomAPI_Interface.h" + #include "GeomAPI_Pnt.h" + #include "GeomAPI_Shape.h" + %} + + // to avoid error on this + #define GEOMAPI_EXPORT + + // standard definitions + %include "typemaps.i" + %include "std_string.i" -%include ++//%include ++%include + + // boost pointers + // %include + %shared_ptr(GeomAPI_Interface) + %shared_ptr(GeomAPI_Pnt) + %shared_ptr(GeomAPI_Shape) + + // all supported interfaces + %include "GeomAPI_Interface.h" + %include "GeomAPI_Pnt.h" + %include "GeomAPI_Shape.h" diff --cc src/GeomAlgoAPI/GeomAlgoAPI.i index 000000000,4e71ea109..99a815f74 mode 000000,100644..100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI.i +++ b/src/GeomAlgoAPI/GeomAlgoAPI.i @@@ -1,0 -1,18 +1,19 @@@ + /* GeomAPI.i */ + %module GeomAlgoAPI + %{ + #include "memory" + #include "GeomAlgoAPI.h" + #include "GeomAlgoAPI_FaceBuilder.h" + %} + + // to avoid error on this + #define GEOMALGOAPI_EXPORT + + // standard definitions + %include "typemaps.i" + %include "std_string.i" -%include ++//%include ++%include + + // all supported interfaces + %include "GeomAlgoAPI_FaceBuilder.h" diff --cc src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp index 000000000,bec2c7f1b..642e90996 mode 000000,100644..100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp @@@ -1,0 -1,23 +1,23 @@@ + // File: GeomAlgoAPI_FaceBuilder.cpp + // Created: 23 Apr 2014 + // Author: Mikhail PONIKAROV + + #include + #include + #include + #include + -std::shared_ptr GeomAlgoAPI_FaceBuilder::square( - std::shared_ptr theCenter, std::shared_ptr theNormal, ++boost::shared_ptr GeomAlgoAPI_FaceBuilder::square( ++ boost::shared_ptr theCenter, boost::shared_ptr theNormal, + const double theSize) + { + gp_Pnt* aCenter = static_cast(theCenter->implementation()); + gp_Dir* aDir = static_cast(theNormal->implementation()); + gp_Pln aPlane(*aCenter, *aDir); + // half of the size in each direction from the center + BRepBuilderAPI_MakeFace aFaceBuilder(aPlane, + -theSize / 2., theSize / 2., -theSize / 2., theSize / 2.); - std::shared_ptr aRes(new GeomAPI_Shape); ++ boost::shared_ptr aRes(new GeomAPI_Shape); + aRes->setImplementation(new TopoDS_Shape(aFaceBuilder.Face())); + return aRes; + } diff --cc src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.h index 000000000,15243f233..61ebfaeb6 mode 000000,100644..100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.h @@@ -1,0 -1,28 +1,28 @@@ + // File: GeomAlgoAPI_FaceBuilder.h + // Created: 23 Apr 2014 + // Author: Mikhail PONIKAROV + + #ifndef GeomAlgoAPI_FaceBuilder_HeaderFile + #define GeomAlgoAPI_FaceBuilder_HeaderFile + + #include + #include + #include + #include -#include ++#include + + /**\class GeomAlgoAPI_FaceBuilder + * \ingroup DataAlgo + * \brief Allows to create face-shapes by different parameters + */ + + class GEOMALGOAPI_EXPORT GeomAlgoAPI_FaceBuilder + { + public: + /// Creates square planar face by given point of the center, + /// normal to the plane and size of square - static std::shared_ptr square(std::shared_ptr theCenter, - std::shared_ptr theNormal, const double theSize); ++ static boost::shared_ptr square(boost::shared_ptr theCenter, ++ boost::shared_ptr theNormal, const double theSize); + }; + + #endif diff --cc src/Model/CMakeLists.txt index 53f1ec956,abad9811b..310c9f8a3 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@@ -14,17 -14,17 +14,17 @@@ SET(PROJECT_HEADER ) SET(PROJECT_SOURCES - Model_Application.cxx - Model_Document.cxx - Model_PluginManager.cxx - Model_Data.cxx - Model_Iterator.cxx - Model_AttributeDouble.cxx - Model_AttributeDocRef.cxx - Model_Events.cxx + Model_Application.cpp + Model_Document.cpp + Model_PluginManager.cpp + Model_Data.cpp + Model_Iterator.cpp + Model_AttributeDouble.cpp + Model_AttributeDocRef.cpp + Model_Events.cpp ) -ADD_DEFINITIONS(-DMODEL_EXPORTS ${CAS_DEFINITIONS}) +ADD_DEFINITIONS(-DMODEL_EXPORTS ${CAS_DEFINITIONS} ${BOOST_DEFINITIONS}) ADD_LIBRARY(Model SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) TARGET_LINK_LIBRARIES(Model ${PROJECT_LIBRARIES} ${CAS_OCAF} ModelAPI Event Config) diff --cc src/Model/Model_Application.cpp index 000000000,40704967e..166b4e1a1 mode 000000,100644..100644 --- a/src/Model/Model_Application.cpp +++ b/src/Model/Model_Application.cpp @@@ -1,0 -1,61 +1,61 @@@ + // File: Model_Application.cxx + // Created: Fri Sep 2 2011 + // Author: Mikhail PONIKAROV + + #include + #include + + IMPLEMENT_STANDARD_HANDLE(Model_Application, TDocStd_Application) + IMPLEMENT_STANDARD_RTTIEXT(Model_Application, TDocStd_Application) + + using namespace std; + + static Handle_Model_Application TheApplication = new Model_Application; + + //======================================================================= + Handle(Model_Application) Model_Application::getApplication() + { + return TheApplication; + } + + //======================================================================= -const std::shared_ptr& Model_Application::getDocument(string theDocID) ++const boost::shared_ptr& Model_Application::getDocument(string theDocID) + { + if (myDocs.find(theDocID) != myDocs.end()) + return myDocs[theDocID]; + - std::shared_ptr aNew(new Model_Document(theDocID)); ++ boost::shared_ptr aNew(new Model_Document(theDocID)); + myDocs[theDocID] = aNew; + return myDocs[theDocID]; + } + + void Model_Application::deleteDocument(string theDocID) + { + myDocs.erase(theDocID); + } + + //======================================================================= + bool Model_Application::hasDocument(std::string theDocID) + { + return myDocs.find(theDocID) != myDocs.end(); + } + + //======================================================================= + Model_Application::Model_Application() + { + // store handle to the application to avoid nullification + static Handle(Model_Application) TheKeepHandle; + TheKeepHandle = this; + } + + //======================================================================= + void Model_Application::Formats(TColStd_SequenceOfExtendedString& theFormats) + { + theFormats.Append(TCollection_ExtendedString("BinOcaf")); // standard binary schema + } + + //======================================================================= + Standard_CString Model_Application::ResourcesName() + { + return Standard_CString("Standard"); + } diff --cc src/Model/Model_AttributeDocRef.cpp index 000000000,07712d0b6..9df9c2219 mode 000000,100644..100644 --- a/src/Model/Model_AttributeDocRef.cpp +++ b/src/Model/Model_AttributeDocRef.cpp @@@ -1,0 -1,31 +1,31 @@@ + // File: ModelAPI_AttributeDocRef.cxx + // Created: 2 Apr 2014 + // Author: Mikhail PONIKAROV + + #include "Model_AttributeDocRef.h" + #include "Model_Application.h" + + using namespace std; + -void Model_AttributeDocRef::setValue(std::shared_ptr theDoc) ++void Model_AttributeDocRef::setValue(boost::shared_ptr theDoc) + { + myComment->Set(TCollection_ExtendedString(theDoc->id().c_str())); + } + -std::shared_ptr Model_AttributeDocRef::value() ++boost::shared_ptr Model_AttributeDocRef::value() + { + if (myComment->Get().Length()) + return Model_Application::getApplication()->getDocument( + TCollection_AsciiString(myComment->Get()).ToCString()); + // not initialized - return std::shared_ptr(); ++ return boost::shared_ptr(); + } + + Model_AttributeDocRef::Model_AttributeDocRef(TDF_Label& theLabel) + { + // check the attribute could be already presented in this doc (after load document) + if (!theLabel.FindAttribute(TDataStd_Comment::GetID(), myComment)) { + // create attribute: not initialized by value yet, just empty string + myComment = TDataStd_Comment::Set(theLabel, ""); + } + } diff --cc src/Model/Model_Data.cpp index 000000000,a9ac29bf0..87c7be867 mode 000000,100644..100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@@ -1,0 -1,77 +1,77 @@@ + // File: Model_Data.hxx + // Created: 21 Mar 2014 + // Author: Mikhail PONIKAROV + + #include + #include + #include + #include + + using namespace std; + + Model_Data::Model_Data() + { + } + + void Model_Data::setLabel(TDF_Label& theLab) + { + myLab = theLab; + } + + string Model_Data::getName() + { + Handle(TDataStd_Name) aName; + if (myLab.FindAttribute(TDataStd_Name::GetID(), aName)) + return string(TCollection_AsciiString(aName->Get()).ToCString()); + return ""; // not defined + } + + void Model_Data::setName(string theName) + { + TDataStd_Name::Set(myLab, theName.c_str()); + } + + void Model_Data::addAttribute(string theID, string theAttrType) + { + TDF_Label anAttrLab = myLab.FindChild(myAttrs.size() + 1); + ModelAPI_Attribute* anAttr = 0; + if (theAttrType == ModelAPI_AttributeDocRef::type()) + anAttr = new Model_AttributeDocRef(anAttrLab); + else if (theAttrType == ModelAPI_AttributeDouble::type()) + anAttr = new Model_AttributeDouble(anAttrLab); + + if (anAttr) - myAttrs[theID] = std::shared_ptr(anAttr); ++ myAttrs[theID] = boost::shared_ptr(anAttr); + else + ; // TODO: generate error on unknown attribute request and/or add mechanism for customization + } + -shared_ptr Model_Data::docRef(const string theID) ++boost::shared_ptr Model_Data::docRef(const string theID) + { - map >::iterator aFound = myAttrs.find(theID); ++ map >::iterator aFound = myAttrs.find(theID); + if (aFound == myAttrs.end()) { + // TODO: generate error on unknown attribute request and/or add mechanism for customization - return std::shared_ptr(); ++ return boost::shared_ptr(); + } - shared_ptr aRes = - dynamic_pointer_cast(aFound->second); ++ boost::shared_ptr aRes = ++ boost::dynamic_pointer_cast(aFound->second); + if (!aRes) { + // TODO: generate error on invalid attribute type request + } + return aRes; + } + -shared_ptr Model_Data::real(const string theID) ++boost::shared_ptr Model_Data::real(const string theID) + { - map >::iterator aFound = myAttrs.find(theID); ++ map >::iterator aFound = myAttrs.find(theID); + if (aFound == myAttrs.end()) { + // TODO: generate error on unknown attribute request and/or add mechanism for customization - return std::shared_ptr(); ++ return boost::shared_ptr(); + } - shared_ptr aRes = - dynamic_pointer_cast(aFound->second); ++ boost::shared_ptr aRes = ++ boost::dynamic_pointer_cast(aFound->second); + if (!aRes) { + // TODO: generate error on invalid attribute type request + } + return aRes; + } diff --cc src/Model/Model_Document.cpp index 000000000,22641f4b3..c022362e8 mode 000000,100644..100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@@ -1,0 -1,445 +1,444 @@@ + // File: Model_Document.cxx + // Created: 28 Feb 2014 + // Author: Mikhail PONIKAROV + + #include + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + + #include + + static const int UNDO_LIMIT = 10; // number of possible undo operations + + static const int TAG_GENERAL = 1; // general properties tag + static const int TAG_OBJECTS = 2; // tag of the objects sub-tree (Root for Model_DatasMgr) + static const int TAG_HISTORY = 3; // tag of the history sub-tree (Root for Model_History) + + using namespace std; + + bool Model_Document::load(const char* theFileName) + { + bool myIsError = Standard_False; + /* + TCollection_ExtendedString aPath ((const Standard_CString)theFileName); + PCDM_ReaderStatus aStatus = (PCDM_ReaderStatus) -1; + try + { + Handle(TDocStd_Document) aDoc = this; + aStatus = Model_Application::GetApplication()->Open(aPath, aDoc); + } + catch (Standard_Failure) + {} + myIsError = aStatus != PCDM_RS_OK; + if (myIsError) + { + switch (aStatus) + { + case PCDM_RS_UnknownDocument: cout<<"OCAFApp_Appl_RUnknownDocument"<SaveAs (aDoc, aPath); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + cout<<"OCAFApp_Engine:save Error: "<GetMessageString()<::iterator aSubIter = mySubs.begin(); + for(; aSubIter != mySubs.end(); aSubIter++) + subDocument(*aSubIter)->close(); + mySubs.clear(); + // close this + myDoc->Close(); + Model_Application::getApplication()->deleteDocument(myID); + } + + void Model_Document::startOperation() + { + // new command for this + myDoc->NewCommand(); + // new command for all subs + set::iterator aSubIter = mySubs.begin(); + for(; aSubIter != mySubs.end(); aSubIter++) + subDocument(*aSubIter)->startOperation(); + } + + void Model_Document::finishOperation() + { + // returns false if delta is empty and no transaction was made + myIsEmptyTr[myTransactionsAfterSave] = !myDoc->CommitCommand(); + myTransactionsAfterSave++; + // finish for all subs + set::iterator aSubIter = mySubs.begin(); + for(; aSubIter != mySubs.end(); aSubIter++) + subDocument(*aSubIter)->finishOperation(); + } + + void Model_Document::abortOperation() + { + myDoc->AbortCommand(); + // abort for all subs + set::iterator aSubIter = mySubs.begin(); + for(; aSubIter != mySubs.end(); aSubIter++) + subDocument(*aSubIter)->abortOperation(); + } + + bool Model_Document::isOperation() + { + // operation is opened for all documents: no need to check subs + return myDoc->HasOpenCommand() == Standard_True ; + } + + bool Model_Document::isModified() + { + // is modified if at least one operation was commited and not undoed + return myTransactionsAfterSave > 0; + } + + bool Model_Document::canUndo() + { + if (myDoc->GetAvailableUndos() > 0) + return true; + // check other subs contains operation that can be undoed + set::iterator aSubIter = mySubs.begin(); + for(; aSubIter != mySubs.end(); aSubIter++) + if (subDocument(*aSubIter)->canUndo()) + return true; + return false; + } + + void Model_Document::undo() + { + myTransactionsAfterSave--; + if (!myIsEmptyTr[myTransactionsAfterSave]) + myDoc->Undo(); + synchronizeFeatures(); + // undo for all subs + set::iterator aSubIter = mySubs.begin(); + for(; aSubIter != mySubs.end(); aSubIter++) + subDocument(*aSubIter)->undo(); + } + + bool Model_Document::canRedo() + { + if (myDoc->GetAvailableRedos() > 0) + return true; + // check other subs contains operation that can be redoed + set::iterator aSubIter = mySubs.begin(); + for(; aSubIter != mySubs.end(); aSubIter++) + if (subDocument(*aSubIter)->canRedo()) + return true; + return false; + } + + void Model_Document::redo() + { + if (!myIsEmptyTr[myTransactionsAfterSave]) + myDoc->Redo(); + myTransactionsAfterSave++; + synchronizeFeatures(); + // redo for all subs + set::iterator aSubIter = mySubs.begin(); + for(; aSubIter != mySubs.end(); aSubIter++) + subDocument(*aSubIter)->redo(); + } + -shared_ptr Model_Document::addFeature(string theID) ++boost::shared_ptr Model_Document::addFeature(string theID) + { - shared_ptr aFeature = ModelAPI_PluginManager::get()->createFeature(theID); ++ boost::shared_ptr aFeature = ModelAPI_PluginManager::get()->createFeature(theID); + if (aFeature) { - dynamic_pointer_cast(aFeature->documentToAdd())->addFeature(aFeature); ++ boost::dynamic_pointer_cast(aFeature->documentToAdd())->addFeature(aFeature); + } else { + // TODO: generate error that feature is not created + } + return aFeature; + } + -void Model_Document::addFeature(const std::shared_ptr theFeature) ++void Model_Document::addFeature(const boost::shared_ptr theFeature) + { + const std::string& aGroup = theFeature->getGroup(); + TDF_Label aGroupLab = groupLabel(aGroup); + TDF_Label anObjLab = aGroupLab.NewChild(); - std::shared_ptr aData(new Model_Data); ++ boost::shared_ptr aData(new Model_Data); + aData->setLabel(anObjLab); - shared_ptr aThis = Model_Application::getApplication()->getDocument(myID); ++ boost::shared_ptr aThis = Model_Application::getApplication()->getDocument(myID); + aData->setDocument(aThis); + theFeature->setData(aData); + setUniqueName(theFeature); + theFeature->initAttributes(); + // keep the feature ID to restore document later correctly + TDataStd_Comment::Set(anObjLab, theFeature->getKind().c_str()); + // put index of the feature in the group in the tree + TDataStd_Integer::Set(anObjLab, myFeatures[aGroup].size()); + myFeatures[aGroup].push_back(theFeature); + + // event: feature is added + static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED); + ModelAPI_FeatureUpdatedMessage aMsg(aThis, theFeature, anEvent); + Event_Loop::loop()->send(aMsg); + } + -shared_ptr Model_Document::feature(TDF_Label& theLabel) ++boost::shared_ptr Model_Document::feature(TDF_Label& theLabel) + { + Handle(TDataStd_Integer) aFeatureIndex; + if (theLabel.FindAttribute(TDataStd_Integer::GetID(), aFeatureIndex)) { + Handle(TDataStd_Comment) aGroupID; + if (theLabel.Father().FindAttribute(TDataStd_Comment::GetID(), aGroupID)) { + string aGroup = TCollection_AsciiString(aGroupID->Get()).ToCString(); + return myFeatures[aGroup][aFeatureIndex->Get()]; + } + } - return std::shared_ptr(); // not found ++ return boost::shared_ptr(); // not found + } + -int Model_Document::featureIndex(shared_ptr theFeature) ++int Model_Document::featureIndex(boost::shared_ptr theFeature) + { + if (theFeature->data()->document().get() != this) { + return theFeature->data()->document()->featureIndex(theFeature); + } - shared_ptr aData = dynamic_pointer_cast(theFeature->data()); ++ boost::shared_ptr aData = boost::dynamic_pointer_cast(theFeature->data()); + Handle(TDataStd_Integer) aFeatureIndex; + if (aData->label().FindAttribute(TDataStd_Integer::GetID(), aFeatureIndex)) { + return aFeatureIndex->Get(); + } + return -1; // not found + } + -shared_ptr Model_Document::subDocument(string theDocID) ++boost::shared_ptr Model_Document::subDocument(string theDocID) + { + // just store sub-document identifier here to manage it later + if (mySubs.find(theDocID) == mySubs.end()) + mySubs.insert(theDocID); + return Model_Application::getApplication()->getDocument(theDocID); + } + -shared_ptr Model_Document::featuresIterator(const string theGroup) ++boost::shared_ptr Model_Document::featuresIterator(const string theGroup) + { - shared_ptr aThis(Model_Application::getApplication()->getDocument(myID)); ++ boost::shared_ptr aThis(Model_Application::getApplication()->getDocument(myID)); + // create an empty iterator for not existing group + // (to avoidance of attributes management outside the transaction) + if (myGroups.find(theGroup) == myGroups.end()) - return shared_ptr(new Model_Iterator()); - return shared_ptr(new Model_Iterator(aThis, groupLabel(theGroup))); ++ return boost::shared_ptr(new Model_Iterator()); ++ return boost::shared_ptr(new Model_Iterator(aThis, groupLabel(theGroup))); + } + -shared_ptr Model_Document::feature(const string& theGroupID, const int theIndex) ++boost::shared_ptr Model_Document::feature(const string& theGroupID, const int theIndex) + { + // TODO: optimize this method - shared_ptr anIter = featuresIterator(theGroupID); ++ boost::shared_ptr anIter = featuresIterator(theGroupID); + for(int a = 0; a != theIndex && anIter->more(); anIter->next()) a++; - return anIter->more() ? anIter->current() : shared_ptr(); ++ return anIter->more() ? anIter->current() : boost::shared_ptr(); + } + + const vector& Model_Document::getGroups() const + { + return myGroupsNames; + } + + Model_Document::Model_Document(const std::string theID) + : myID(theID), myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format + { + myDoc->SetUndoLimit(UNDO_LIMIT); + myTransactionsAfterSave = 0; + // to avoid creation of tag outside of the transaction (by iterator, for example) + /* + if (!myDoc->Main().FindChild(TAG_OBJECTS).IsAttribute(TDF_TagSource::GetID())) + TDataStd_Comment::Set(myDoc->Main().FindChild(TAG_OBJECTS).NewChild(), ""); + */ + } + + TDF_Label Model_Document::groupLabel(const string theGroup) + { + if (myGroups.find(theGroup) == myGroups.end()) { + myGroups[theGroup] = myDoc->Main().FindChild(TAG_OBJECTS).NewChild(); + myGroupsNames.push_back(theGroup); + // set to the group label the group idntifier to restore on "open" + TDataStd_Comment::Set(myGroups[theGroup], theGroup.c_str()); - myFeatures[theGroup] = vector >(); ++ myFeatures[theGroup] = vector >(); + } + return myGroups[theGroup]; + } + -void Model_Document::setUniqueName( - shared_ptr theFeature) ++void Model_Document::setUniqueName(boost::shared_ptr theFeature) + { + // first count all objects of such kind to start with index = count + 1 + int aNumObjects = 0; - shared_ptr anIter = featuresIterator(theFeature->getGroup()); ++ boost::shared_ptr anIter = featuresIterator(theFeature->getGroup()); + for(; anIter->more(); anIter->next()) { + if (anIter->currentKind() == theFeature->getKind()) + aNumObjects++; + } + // generate candidate name + stringstream aNameStream; + aNameStream<getKind()<<"_"<getGroup()); anIter->more();) { + if (anIter->currentName() == aName) { + aNumObjects++; + stringstream aNameStream; + aNameStream<getKind()<<"_"<getGroup()); + } else anIter->next(); + } + + theFeature->data()->setName(aName); + } + + void Model_Document::synchronizeFeatures() + { - shared_ptr aThis = Model_Application::getApplication()->getDocument(myID); ++ boost::shared_ptr aThis = Model_Application::getApplication()->getDocument(myID); + // iterate groups labels + TDF_ChildIDIterator aGroupsIter(myDoc->Main().FindChild(TAG_OBJECTS), + TDataStd_Comment::GetID(), Standard_False); + vector::iterator aGroupNamesIter = myGroupsNames.begin(); + for(; aGroupsIter.More() && aGroupNamesIter != myGroupsNames.end(); + aGroupsIter.Next(), aGroupNamesIter++) { + string aGroupName = TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast( + aGroupsIter.Value())->Get()).ToCString(); + if (*aGroupNamesIter != aGroupName) + break; // all since there is a change this must be recreated from scratch + } + // delete all groups left after the data model groups iteration + while(aGroupNamesIter != myGroupsNames.end()) { + string aGroupName = *aGroupNamesIter; + myFeatures.erase(aGroupName); + myGroups.erase(aGroupName); + aGroupNamesIter = myGroupsNames.erase(aGroupNamesIter); + // say that features were deleted from group + ModelAPI_FeatureDeletedMessage aMsg(aThis, aGroupName); + Event_Loop::loop()->send(aMsg); + } + // create new groups basing on the following data model update + for(; aGroupsIter.More(); aGroupsIter.Next()) { + string aGroupName = TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast( + aGroupsIter.Value())->Get()).ToCString(); + myGroupsNames.push_back(aGroupName); + myGroups[aGroupName] = aGroupsIter.Value()->Label(); - myFeatures[aGroupName] = vector >(); ++ myFeatures[aGroupName] = vector >(); + } + // update features group by group + aGroupsIter.Initialize(myDoc->Main().FindChild(TAG_OBJECTS), + TDataStd_Comment::GetID(), Standard_False); + for(; aGroupsIter.More(); aGroupsIter.Next()) { + string aGroupName = TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast( + aGroupsIter.Value())->Get()).ToCString(); + // iterate features in internal container - vector >& aFeatures = myFeatures[aGroupName]; - vector >::iterator aFIter = aFeatures.begin(); ++ vector >& aFeatures = myFeatures[aGroupName]; ++ vector >::iterator aFIter = aFeatures.begin(); + // and in parallel iterate labels of features + TDF_ChildIDIterator aFLabIter( + aGroupsIter.Value()->Label(), TDataStd_Comment::GetID(), Standard_False); + while(aFIter != aFeatures.end() || aFLabIter.More()) { + static const int INFINITE_TAG = INT_MAX; // no label means that it exists somwhere in infinite + int aFeatureTag = INFINITE_TAG; + if (aFIter != aFeatures.end()) { // existing tag for feature - shared_ptr aData = dynamic_pointer_cast((*aFIter)->data()); ++ boost::shared_ptr aData = boost::dynamic_pointer_cast((*aFIter)->data()); + aFeatureTag = aData->label().Tag(); + } + int aDSTag = INFINITE_TAG; + if (aFLabIter.More()) { // next label in DS is existing + aDSTag = aFLabIter.Value()->Label().Tag(); + } + if (aDSTag > aFeatureTag) { // feature is removed + aFIter = aFeatures.erase(aFIter); + // event: model is updated + ModelAPI_FeatureDeletedMessage aMsg(aThis, aGroupName); + Event_Loop::loop()->send(aMsg); + } else if (aDSTag < aFeatureTag) { // a new feature is inserted + // create a feature - shared_ptr aFeature = ModelAPI_PluginManager::get()->createFeature( ++ boost::shared_ptr aFeature = ModelAPI_PluginManager::get()->createFeature( + TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast( + aFLabIter.Value())->Get()).ToCString()); + - std::shared_ptr aData(new Model_Data); ++ boost::shared_ptr aData(new Model_Data); + TDF_Label aLab = aFLabIter.Value()->Label(); + aData->setLabel(aLab); + aData->setDocument(Model_Application::getApplication()->getDocument(myID)); + aFeature->setData(aData); + aFeature->initAttributes(); + // event: model is updated + static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED); + ModelAPI_FeatureUpdatedMessage aMsg(aThis, aFeature, anEvent); + Event_Loop::loop()->send(aMsg); + + if (aFIter == aFeatures.end()) { + aFeatures.push_back(aFeature); + aFIter = aFeatures.end(); + } else { + aFIter++; + aFeatures.insert(aFIter, aFeature); + } + // feature for this label is added, so go to the next label + aFLabIter.Next(); + } else { // nothing is changed, both iterators are incremented + aFIter++; + aFLabIter.Next(); + } + } + } + } diff --cc src/Model/Model_Events.cpp index 000000000,dc35573eb..a83e9cabd mode 000000,100644..100644 --- a/src/Model/Model_Events.cpp +++ b/src/Model/Model_Events.cpp @@@ -1,0 -1,25 +1,25 @@@ + // File: Model_Events.cxx + // Created: 10 Apr 2014 + // Author: Mikhail PONIKAROV + + #include + #include + + ModelAPI_FeatureUpdatedMessage::ModelAPI_FeatureUpdatedMessage( - const std::shared_ptr& theDoc, - const std::shared_ptr& theFeature, const Event_ID& theEvent) ++ const boost::shared_ptr& theDoc, ++ const boost::shared_ptr& theFeature, const Event_ID& theEvent) + : Event_Message(theEvent, 0), myFeature(theFeature), myDoc(theDoc) + {} + + ModelAPI_FeatureDeletedMessage::ModelAPI_FeatureDeletedMessage( - const std::shared_ptr& theDoc, const std::string& theGroup) ++ const boost::shared_ptr& theDoc, const std::string& theGroup) + : Event_Message(messageId(), 0), myDoc(theDoc), myGroup(theGroup) + + { + } + + const Event_ID ModelAPI_FeatureDeletedMessage::messageId() + { + static Event_ID MY_ID = Event_Loop::eventByName(EVENT_FEATURE_DELETED); + return MY_ID; + } diff --cc src/Model/Model_Iterator.cpp index 000000000,001ebdff8..ba59cdf75 mode 000000,100644..100644 --- a/src/Model/Model_Iterator.cpp +++ b/src/Model/Model_Iterator.cpp @@@ -1,0 -1,67 +1,67 @@@ + // File: Model_Iterator.hxx + // Created: 1 Apr 2014 + // Author: Mikhail PONIKAROV + + #include "Model_Iterator.h" + #include "Model_Document.h" + #include "ModelAPI_Feature.h" + #include "Model_Data.h" + #include + #include + + using namespace std; + + void Model_Iterator::next() + { + return myIter.Next(); + } + + bool Model_Iterator::more() + { + return myIter.More() == Standard_True; + } + -shared_ptr Model_Iterator::current() ++boost::shared_ptr Model_Iterator::current() + { + TDF_Label aLab = myIter.Value()->Label(); + return myDoc->feature(aLab); + } + + string Model_Iterator::currentKind() + { + return string(TCollection_AsciiString( + Handle(TDataStd_Comment)::DownCast(myIter.Value())->Get()).ToCString()); + } + + string Model_Iterator::currentName() + { + TDF_Label aLab = myIter.Value()->Label(); + Handle(TDataStd_Name) aName; + if (aLab.FindAttribute(TDataStd_Name::GetID(), aName)) + return string(TCollection_AsciiString(aName->Get()).ToCString()); + return ""; // name is not found + } + + int Model_Iterator::numIterationsLeft() + { + int aResult = 0; + TDF_ChildIDIterator aTempIter(myIter); + for(; aTempIter.More(); aTempIter.Next()) + aResult++; + return aResult; + } + -bool Model_Iterator::isEqual(std::shared_ptr theFeature) ++bool Model_Iterator::isEqual(boost::shared_ptr theFeature) + { + return (myIter.Value()->Label() == - dynamic_pointer_cast(theFeature->data())->label()) == Standard_True; ++ boost::dynamic_pointer_cast(theFeature->data())->label()) == Standard_True; + + } + + Model_Iterator::Model_Iterator() + { + } + -Model_Iterator::Model_Iterator(std::shared_ptr theDoc, TDF_Label theLab) ++Model_Iterator::Model_Iterator(boost::shared_ptr theDoc, TDF_Label theLab) + : myDoc(theDoc), myIter(theLab, TDataStd_Comment::GetID(), Standard_False) + {} diff --cc src/Model/Model_PluginManager.cpp index 000000000,75cc0430c..e816fdd4a mode 000000,100644..100644 --- a/src/Model/Model_PluginManager.cpp +++ b/src/Model/Model_PluginManager.cpp @@@ -1,0 -1,103 +1,103 @@@ + // File: Model_PluginManager.cxx + // Created: 20 Mar 2014 + // Author: Mikhail PONIKAROV + + #include + #include + #include + #include + #include + #include + #include + #include + #include + + using namespace std; + + static Model_PluginManager* myImpl = new Model_PluginManager(); + -shared_ptr Model_PluginManager::createFeature(string theFeatureID) ++boost::shared_ptr Model_PluginManager::createFeature(string theFeatureID) + { + if (this != myImpl) return myImpl->createFeature(theFeatureID); + + LoadPluginsInfo(); + if (myPlugins.find(theFeatureID) != myPlugins.end()) { + myCurrentPluginName = myPlugins[theFeatureID]; + if (myPluginObjs.find(myCurrentPluginName) == myPluginObjs.end()) { + // load plugin library if not yet done + loadLibrary(myCurrentPluginName); + } + if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) { - std::shared_ptr aCreated = ++ boost::shared_ptr aCreated = + myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID); + return aCreated; + } + } + - return std::shared_ptr(); // return nothing ++ return boost::shared_ptr(); // return nothing + } + -std::shared_ptr Model_PluginManager::rootDocument() ++boost::shared_ptr Model_PluginManager::rootDocument() + { - return std::shared_ptr( ++ return boost::shared_ptr( + Model_Application::getApplication()->getDocument("root")); + } + + bool Model_PluginManager::hasRootDocument() + { + return Model_Application::getApplication()->hasDocument("root"); + } + -shared_ptr Model_PluginManager::currentDocument() ++boost::shared_ptr Model_PluginManager::currentDocument() + { + if (!myCurrentDoc) + myCurrentDoc = rootDocument(); + return myCurrentDoc; + } + -void Model_PluginManager::setCurrentDocument(shared_ptr theDoc) ++void Model_PluginManager::setCurrentDocument(boost::shared_ptr theDoc) + { + myCurrentDoc = theDoc; + } + + Model_PluginManager::Model_PluginManager() + { + myPluginsInfoLoaded = false; + //TODO(sbh): Implement static method to extract event id [SEID] + static Event_ID aFeatureEvent = Event_Loop::eventByName("FeatureRegisterEvent"); + - ModelAPI_PluginManager::SetPluginManager(std::shared_ptr(this)); ++ ModelAPI_PluginManager::SetPluginManager(boost::shared_ptr(this)); + // register the configuration reading listener + Event_Loop* aLoop = Event_Loop::loop(); + aLoop->registerListener(this, aFeatureEvent); + } + + void Model_PluginManager::processEvent(const Event_Message* theMessage) + { + const Config_FeatureMessage* aMsg = + dynamic_cast(theMessage); + if (aMsg) { + // proccess the plugin info, load plugin + if (myPlugins.find(aMsg->id()) == myPlugins.end()) { + myPlugins[aMsg->id()] = aMsg->pluginLibrary(); + } + } + // plugins information was started to load, so, it will be loaded + myPluginsInfoLoaded = true; + } + + void Model_PluginManager::LoadPluginsInfo() + { + if (myPluginsInfoLoaded) // nothing to do + return; + + // Read plugins information from XML files + Config_ModuleReader aXMLReader("FeatureRegisterEvent"); + aXMLReader.setAutoImport(true); + aXMLReader.readAll(); + } + + void Model_PluginManager::registerPlugin(ModelAPI_Plugin* thePlugin) + { + myPluginObjs[myCurrentPluginName] = thePlugin; + } diff --cc src/ModelAPI/ModelAPI_PluginManager.cpp index 000000000,f3e7e9b9d..772ac8d98 mode 000000,100644..100644 --- a/src/ModelAPI/ModelAPI_PluginManager.cpp +++ b/src/ModelAPI/ModelAPI_PluginManager.cpp @@@ -1,0 -1,94 +1,94 @@@ + // File: ModelAPI_PluginManager.hxx + // Created: 20 Mar 2014 + // Author: Mikhail PONIKAROV + + #include + // to avoid unresolved ModelAPI_Document() + #include + // to avoid unresolved ModelAPI_Feature() + #include + // to avoid unresolved ModelAPI_Data() + #include + // to avoid unresolved ModelAPI_Plugin() + #include + // to avoid unresolved ModelAPI_Iterator() + #include + // to avoid unresolved ModelAPI_Iterator() + #include + #include + #include + #include + + #ifdef WIN32 + #include + #else + #include + #endif + + using namespace std; + + /// Converts library name to the operation system file name + string library(const string& theLibName); + + /// Manager that will be initialized from Model package, one per application -std::shared_ptr MY_MANAGER; ++boost::shared_ptr MY_MANAGER; + + ModelAPI_PluginManager::ModelAPI_PluginManager() + { + } + + void ModelAPI_PluginManager::SetPluginManager( - std::shared_ptr theManager) ++ boost::shared_ptr theManager) + { + MY_MANAGER = theManager; + } + -std::shared_ptr ModelAPI_PluginManager::get() ++boost::shared_ptr ModelAPI_PluginManager::get() + { + if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI + loadLibrary("Model"); + } + return MY_MANAGER; + } + + string library(const string& theLibName) + { + string aLibName = theLibName; + + #ifndef WIN32 + static string aLibExt( ".so" ); + if (aLibName.size() < 3 || aLibName.substr(0, 3) !="lib") + aLibName = "lib" + aLibName; + #else + static string aLibExt( ".dll" ); + #endif + + string anExt = aLibName.substr(aLibName.size() - 4); + + if ( anExt != aLibExt) + aLibName += aLibExt; + + return aLibName; + } + + // for debug purpose only (cerr), before the error management system is implemented + #include + void ModelAPI_PluginManager::loadLibrary(const string theLibName) + { + string aFileName = library(theLibName); + if ( aFileName.empty() ) + { + cerr<<"Library "< myFeature; + boost::shared_ptr myFeature; }; #endif diff --cc src/PartSet/PartSet_OperationSketchBase.cpp index 69bbe52dc,9b34aa2eb..ec0d695d5 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@@ -31,8 -31,8 +31,8 @@@ PartSet_OperationSketchBase::~PartSet_O */ const TopoDS_Shape& PartSet_OperationSketchBase::preview() const { - shared_ptr aFeature = dynamic_pointer_cast(feature()); + boost::shared_ptr aFeature = boost::dynamic_pointer_cast(feature()); - return aFeature->preview(); + return *(static_cast(aFeature->preview()->implementation())); } /*! diff --cc src/PartSetPlugin/PartSetPlugin_Part.cpp index 000000000,440eb6f25..144411717 mode 000000,100644..100644 --- a/src/PartSetPlugin/PartSetPlugin_Part.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Part.cpp @@@ -1,0 -1,34 +1,34 @@@ + // File: PartSetPlugin_Part.cxx + // Created: 27 Mar 2014 + // Author: Mikhail PONIKAROV + + #include "PartSetPlugin_Part.h" + #include "ModelAPI_PluginManager.h" + #include "ModelAPI_Document.h" + #include "ModelAPI_Data.h" + #include "ModelAPI_Iterator.h" + #include "ModelAPI_AttributeDocRef.h" + + using namespace std; + + PartSetPlugin_Part::PartSetPlugin_Part() + { + } + + void PartSetPlugin_Part::initAttributes() + { + data()->addAttribute(PART_ATTR_DOC_REF, ModelAPI_AttributeDocRef::type()); + } + + void PartSetPlugin_Part::execute() + { - shared_ptr aDocRef = data()->docRef(PART_ATTR_DOC_REF); ++ boost::shared_ptr aDocRef = data()->docRef(PART_ATTR_DOC_REF); + if (!aDocRef->value()) { // create a document if not yet created - shared_ptr aPartSetDoc = ModelAPI_PluginManager::get()->rootDocument(); ++ boost::shared_ptr aPartSetDoc = ModelAPI_PluginManager::get()->rootDocument(); + aDocRef->setValue(aPartSetDoc->subDocument(data()->getName())); + } + } + -shared_ptr PartSetPlugin_Part::documentToAdd() { ++boost::shared_ptr PartSetPlugin_Part::documentToAdd() { + return ModelAPI_PluginManager::get()->rootDocument(); + } diff --cc src/PartSetPlugin/PartSetPlugin_Plugin.cpp index 000000000,7ef8f66e1..85ea1c37e mode 000000,100644..100644 --- a/src/PartSetPlugin/PartSetPlugin_Plugin.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Plugin.cpp @@@ -1,0 -1,24 +1,24 @@@ + #include "PartSetPlugin_Plugin.h" + #include "PartSetPlugin_Part.h" + #include + #include + + using namespace std; + + // the only created instance of this plugin + static PartSetPlugin_Plugin* MY_INSTANCE = new PartSetPlugin_Plugin(); + + PartSetPlugin_Plugin::PartSetPlugin_Plugin() + { + // register this plugin + ModelAPI_PluginManager::get()->registerPlugin(this); + } + -shared_ptr PartSetPlugin_Plugin::createFeature(string theFeatureID) ++boost::shared_ptr PartSetPlugin_Plugin::createFeature(string theFeatureID) + { + if (theFeatureID == "Part") { - return shared_ptr(new PartSetPlugin_Part); ++ return boost::shared_ptr(new PartSetPlugin_Part); + } + // feature of such kind is not found - return shared_ptr(); ++ return boost::shared_ptr(); + } diff --cc src/SketchPlugin/SketchPlugin_Feature.cpp index 57bc3582d,27040b92d..8586525f7 --- a/src/SketchPlugin/SketchPlugin_Feature.cpp +++ b/src/SketchPlugin/SketchPlugin_Feature.cpp @@@ -3,7 -3,7 +3,7 @@@ /** * Returns the sketch preview */ - const TopoDS_Shape& SketchPlugin_Feature::preview() -const std::shared_ptr& SketchPlugin_Feature::preview() ++const boost::shared_ptr& SketchPlugin_Feature::preview() { return myPreview; } @@@ -12,7 -12,7 +12,7 @@@ * Set the shape to the internal preview field * \param theShape a preview shape */ - void SketchPlugin_Feature::setPreview(const TopoDS_Shape& theShape) -void SketchPlugin_Feature::setPreview(const std::shared_ptr& theShape) ++void SketchPlugin_Feature::setPreview(const boost::shared_ptr& theShape) { myPreview = theShape; } diff --cc src/SketchPlugin/SketchPlugin_Feature.h index 4b91631c9,a440dbdfd..964abe80e --- a/src/SketchPlugin/SketchPlugin_Feature.h +++ b/src/SketchPlugin/SketchPlugin_Feature.h @@@ -17,13 -17,13 +17,13 @@@ class SketchPlugin_Feature: public ModelAPI_Feature { public: - SKETCHPLUGIN_EXPORT virtual const TopoDS_Shape& preview() = 0; - SKETCHPLUGIN_EXPORT virtual const std::shared_ptr& preview() = 0; ++ SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview() = 0; protected: - void setPreview(const TopoDS_Shape& theShape); ///< the preview shape - void setPreview(const std::shared_ptr& theShape); ///< the preview shape ++ void setPreview(const boost::shared_ptr& theShape); ///< the preview shape private: - TopoDS_Shape myPreview; ///< the preview shape - std::shared_ptr myPreview; ///< the preview shape ++ boost::shared_ptr myPreview; ///< the preview shape }; #endif diff --cc src/SketchPlugin/SketchPlugin_Sketch.cpp index 7fb20f079,9a3624daf..f450ec746 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@@ -34,23 -22,18 +22,18 @@@ void SketchPlugin_Sketch::initAttribute void SketchPlugin_Sketch::execute() { - /*shared_ptr aDocRef = data()->docRef(PART_ATTR_DOC_REF); - if (!aDocRef->value()) { // create a document if not yet created - shared_ptr aPartSetDoc = ModelAPI_PluginManager::get()->rootDocument(); - aDocRef->setValue(aPartSetDoc->subDocument(data()->getName())); - }*/ } - const TopoDS_Shape& SketchPlugin_Sketch::preview() -const shared_ptr& SketchPlugin_Sketch::preview() ++const boost::shared_ptr& SketchPlugin_Sketch::preview() { - if (SketchPlugin_Feature::preview().IsNull()) + if (!SketchPlugin_Feature::preview()) { - gp_Pnt anOrigin(0, 0, 0); - gp_Dir aDir(gp_Vec(gp_Pnt(0,0,0), gp_Pnt(1,0,0))); - gp_Pln aPlane(anOrigin, aDir); - BRepBuilderAPI_MakeFace aFaceBuilder(aPlane, PLANE_U_MIN, PLANE_U_MAX, PLANE_V_MIN, - PLANE_V_MAX); - setPreview(aFaceBuilder.Face()); + - shared_ptr anOrigin(new GeomAPI_Pnt(0, 0, 0)); - shared_ptr aNormal(new GeomAPI_Dir(1, 0, 0)); - shared_ptr aFace = ++ boost::shared_ptr anOrigin(new GeomAPI_Pnt(0, 0, 0)); ++ boost::shared_ptr aNormal(new GeomAPI_Dir(1, 0, 0)); ++ boost::shared_ptr aFace = + GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE); + setPreview(aFace); } return SketchPlugin_Feature::preview(); } diff --cc src/SketchPlugin/SketchPlugin_Sketch.h index a2b63388a,e261df1a8..4cceee37f --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@@ -35,7 -33,7 +33,7 @@@ public SKETCHPLUGIN_EXPORT virtual void initAttributes(); /// Returns the sketch preview - SKETCHPLUGIN_EXPORT virtual const TopoDS_Shape& preview(); - SKETCHPLUGIN_EXPORT virtual const std::shared_ptr& preview(); ++ SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); /// Use plugin manager for features creation SketchPlugin_Sketch(); diff --cc src/XGUI/XGUI_Displayer.cpp index 5300fe5c1,79abb676f..8fb825b5b --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@@ -45,3 -45,15 +45,15 @@@ void XGUI_Displayer::Display(boost::sha aContext->UpdateCurrentViewer(); } + + /*! + * Erase the feature and a shape. + * \param theFeature a feature instance + * \param theFeature a shape + */ -void XGUI_Displayer::Erase(std::shared_ptr theFeature, ++void XGUI_Displayer::Erase(boost::shared_ptr theFeature, + const TopoDS_Shape& theShape) + { + Handle(AIS_InteractiveContext) aContext = myViewer->AISContext(); + aContext->EraseAll(); + } diff --cc src/XGUI/XGUI_Displayer.h index 10480ef97,4c5333f45..dc09d99bd --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@@ -21,10 -20,12 +21,12 @@@ public XGUI_Displayer(XGUI_Viewer* theViewer); virtual ~XGUI_Displayer(); - void Display(std::shared_ptr theFeature); + void Display(boost::shared_ptr theFeature); - void Display(std::shared_ptr theFeature, const TopoDS_Shape& theShape); + void Display(boost::shared_ptr theFeature, const TopoDS_Shape& theShape); - void Erase(std::shared_ptr theFeature, const TopoDS_Shape& theShape); ++ void Erase(boost::shared_ptr theFeature, const TopoDS_Shape& theShape); + protected: XGUI_Viewer* myViewer; ///< the viewer };