From eab7248fd3b9120041364993091a51af7fc65577 Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 19 May 2014 12:27:48 +0400 Subject: [PATCH] Added "Object" feature: result of the operation in specialized folders. --- src/Model/CMakeLists.txt | 2 + src/Model/Model_Document.cpp | 318 +++++++++++------------- src/Model/Model_Document.h | 24 +- src/Model/Model_Object.cpp | 27 ++ src/Model/Model_Object.h | 53 ++++ src/ModelAPI/CMakeLists.txt | 1 + src/ModelAPI/ModelAPI.i | 3 + src/ModelAPI/ModelAPI_Document.h | 6 - src/ModelAPI/ModelAPI_Object.h | 33 +++ src/ModelAPI/ModelAPI_PluginManager.cpp | 1 + 10 files changed, 279 insertions(+), 189 deletions(-) create mode 100644 src/Model/Model_Object.cpp create mode 100644 src/Model/Model_Object.h create mode 100644 src/ModelAPI/ModelAPI_Object.h diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt index 65c929cc5..5db73c347 100644 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@ -7,6 +7,7 @@ SET(PROJECT_HEADERS Model_Document.h Model_PluginManager.h Model_Data.h + Model_Object.h Model_AttributeDouble.h Model_AttributeDocRef.h Model_AttributeReference.h @@ -20,6 +21,7 @@ SET(PROJECT_SOURCES Model_Document.cpp Model_PluginManager.cpp Model_Data.cpp + Model_Object.cpp Model_AttributeDouble.cpp Model_AttributeDocRef.cpp Model_AttributeReference.cpp diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 943992055..be6a5957b 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -16,6 +17,7 @@ #include #include #include +#include #include @@ -275,40 +277,54 @@ boost::shared_ptr Model_Document::addFeature(string theID) return aFeature; } +/// Appenad to the array of references a new referenced label +static void AddToRefArray(TDF_Label& theArrayLab, TDF_Label& theReferenced) { + Handle(TDataStd_ReferenceArray) aRefs; + if (!theArrayLab.FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) { + aRefs = TDataStd_ReferenceArray::Set(theArrayLab, 0, 0); + aRefs->SetValue(0, theReferenced); + } else { // extend array by one more element + Handle(TDataStd_HLabelArray1) aNewArray = + new TDataStd_HLabelArray1(aRefs->Lower(), aRefs->Upper() + 1); + for(int a = aRefs->Lower(); a <= aRefs->Upper(); a++) { + aNewArray->SetValue(a, aRefs->Value(a)); + } + aNewArray->SetValue(aRefs->Upper() + 1, theReferenced); + aRefs->SetInternalArray(aNewArray); + } +} + 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(); - boost::shared_ptr aData(new Model_Data); - aData->setFeature(theFeature); - aData->setLabel(anObjLab); boost::shared_ptr aThis = Model_Application::getApplication()->getDocument(myID); + TDF_Label aFeaturesLab = groupLabel(FEATURES_GROUP); + TDF_Label aFeatureLab = aFeaturesLab.NewChild(); + + // organize feature and data objects + boost::shared_ptr aData(new Model_Data); + aData->setFeature(theFeature); + aData->setLabel(aFeatureLab); theFeature->setDoc(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); + TDataStd_Comment::Set(aFeatureLab, theFeature->getKind().c_str()); + myFeatures.push_back(theFeature); // store feature in the history of features array if (theFeature->isInHistory()) { - Handle(TDataStd_ReferenceArray) aRefs; - if (!groupLabel(FEATURES_GROUP).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) { - aRefs = TDataStd_ReferenceArray::Set(groupLabel(FEATURES_GROUP), 0, 0); - aRefs->SetValue(0, anObjLab); - } else { // extend array by one more element - Handle(TDataStd_HLabelArray1) aNewArray = - new TDataStd_HLabelArray1(aRefs->Lower(), aRefs->Upper() + 1); - for(int a = aRefs->Lower(); a <= aRefs->Upper(); a++) { - aNewArray->SetValue(a, aRefs->Value(a)); - } - aNewArray->SetValue(aRefs->Upper() + 1, anObjLab); - aRefs->SetInternalArray(aNewArray); - } + AddToRefArray(aFeaturesLab, aFeatureLab); + // add featue to the group + const std::string& aGroup = theFeature->getGroup(); + TDF_Label aGroupLab = groupLabel(aGroup); + AddToRefArray(aGroupLab, aFeatureLab); + // new name of this feature object by default equal to name of feature + TDF_Label anObjLab = aGroupLab.NewChild(); + TCollection_ExtendedString aName(theFeature->data()->getName().c_str()); + TDataStd_Name::Set(anObjLab, aName); + AddToRefArray(aGroupLab.FindChild(1), anObjLab); // reference to names is on the first sub } // event: feature is added @@ -319,32 +335,17 @@ void Model_Document::addFeature(const boost::shared_ptr theFea 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(); - if (myFeatures[aGroup].size() > aFeatureIndex->Get()) - return myFeatures[aGroup][aFeatureIndex->Get()]; - } + // iterate all features, may be optimized later by keeping labels-map + vector >::iterator aFIter = myFeatures.begin(); + for(; aFIter != myFeatures.end(); aFIter++) { + boost::shared_ptr aData = + boost::dynamic_pointer_cast((*aFIter)->data()); + if (aData->label().IsEqual(theLabel)) + return *aFIter; } return boost::shared_ptr(); // not found } -int Model_Document::featureIndex(boost::shared_ptr theFeature) -{ - if (theFeature->document().get() != this) { - return theFeature->document()->featureIndex(theFeature); - } - 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 -} - boost::shared_ptr Model_Document::subDocument(string theDocID) { // just store sub-document identifier here to manage it later @@ -356,46 +357,38 @@ boost::shared_ptr Model_Document::subDocument(string theDocID boost::shared_ptr Model_Document::feature( const string& theGroupID, const int theIndex) { - if (theGroupID == FEATURES_GROUP) { // history is just a references array - Handle(TDataStd_ReferenceArray) aRefs; - if (groupLabel(FEATURES_GROUP).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) { - if (aRefs->Lower() <= theIndex && aRefs->Upper() >= theIndex) { - TDF_Label aFeatureLab = aRefs->Value(theIndex); - return feature(aFeatureLab); + TDF_Label aGroupLab = groupLabel(theGroupID); + Handle(TDataStd_ReferenceArray) aRefs; + if (aGroupLab.FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) { + if (aRefs->Lower() <= theIndex && aRefs->Upper() >= theIndex) { + TDF_Label aFeatureLab = aRefs->Value(theIndex); + boost::shared_ptr aFeature = feature(aFeatureLab); + + if (theGroupID == FEATURES_GROUP) { // just returns the feature from the history + return aFeature; + } else { // create a new object from the group to return it + Handle(TDataStd_Name) aName; // name of the object + if (aGroupLab.FindChild(1).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) + aRefs->Value(theIndex).FindAttribute(TDataStd_Name::GetID(), aName); + boost::shared_ptr anObj(new Model_Object(aFeature, aName)); + return anObj; } } - } else { // one of the group - map > >::iterator aGroup = - myFeatures.find(theGroupID); - if (aGroup != myFeatures.end() && (int)(aGroup->second.size()) > theIndex) { - return aGroup->second[theIndex]; - } } + // not found return boost::shared_ptr(); } int Model_Document::size(const string& theGroupID) { - if (theGroupID == FEATURES_GROUP) { // history is just a references array - Handle(TDataStd_ReferenceArray) aRefs; - if (groupLabel(FEATURES_GROUP).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) - return aRefs->Length(); - } else { // one of the group - map > >::iterator aGroup = - myFeatures.find(theGroupID); - if (aGroup != myFeatures.end()) - return aGroup->second.size(); - } + Handle(TDataStd_ReferenceArray) aRefs; + if (groupLabel(FEATURES_GROUP).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) + return aRefs->Length(); // group is not found return 0; } -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 { @@ -409,23 +402,27 @@ Model_Document::Model_Document(const std::string theID) 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 >(); + // 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(); } - return myGroups[theGroup]; + // create a new + TDF_Label aNew = myDoc->Main().FindChild(TAG_OBJECTS).NewChild(); + TDataStd_Comment::Set(aNew, aGroup); + return aNew; } void Model_Document::setUniqueName(boost::shared_ptr theFeature) { // first count all objects of such kind to start with index = count + 1 int a, aNumObjects = 0; - int aSize = size(theFeature->getGroup()); + int aSize = size(FEATURES_GROUP); for(a = 0; a < aSize; a++) { - if (feature(theFeature->getGroup(), a)->getKind() == theFeature->getKind()) + if (feature(FEATURES_GROUP, a)->getKind() == theFeature->getKind()) aNumObjects++; } // generate candidate name @@ -434,7 +431,7 @@ void Model_Document::setUniqueName(boost::shared_ptr theFeatur string aName = aNameStream.str(); // check this is unique, if not, increase index by 1 for(a = 0; a < aSize;) { - if (feature(theFeature->getGroup(), a)->data()->getName() == aName) { + if (feature(FEATURES_GROUP, a)->data()->getName() == aName) { aNumObjects++; stringstream aNameStream; aNameStream<getKind()<<"_"< theFeatur theFeature->data()->setName(aName); } +//! Returns the object by the feature +boost::shared_ptr Model_Document::objectByFeature( + const boost::shared_ptr theFeature) +{ + for(int a = 0; a < size(theFeature->getGroup()); a++) { + boost::shared_ptr anObj = + boost::dynamic_pointer_cast(feature(theFeature->getGroup(), a)); + if (anObj) { + return anObj; + } + } + return boost::shared_ptr(); // not found +} + void Model_Document::synchronizeFeatures() { 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 - Model_FeatureDeletedMessage aMsg(aThis, aGroupName); - Events_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 >(); - } - // 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(); - // 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 - 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 - Model_FeatureDeletedMessage aMsg(aThis, aGroupName); - Events_Loop::loop()->send(aMsg); - } else if (aDSTag < aFeatureTag) { // a new feature is inserted - // create a feature - boost::shared_ptr aFeature = ModelAPI_PluginManager::get()->createFeature( - TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast( - aFLabIter.Value())->Get()).ToCString()); - - if (aFIter == aFeatures.end()) { // must be before "setData" to redo the sketch line correctly - aFeatures.push_back(aFeature); - aFIter = aFeatures.end(); - } else { - aFIter++; - aFeatures.insert(aFIter, aFeature); - } - boost::shared_ptr aData(new Model_Data); - TDF_Label aLab = aFLabIter.Value()->Label(); - aData->setLabel(aLab); - aData->setFeature(aFeature); - aFeature->setDoc(aThis); - aFeature->setData(aData); - aFeature->initAttributes(); - - // event: model is updated - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED); - Model_FeatureUpdatedMessage aMsg(aFeature, anEvent); - Events_Loop::loop()->send(aMsg); - - // feature for this label is added, so go to the next label - aFLabIter.Next(); - } else { // nothing is changed, both iterators are incremented + // update features + vector >::iterator aFIter = myFeatures.begin(); + // and in parallel iterate labels of features + TDF_ChildIDIterator aFLabIter(groupLabel(FEATURES_GROUP), TDataStd_Comment::GetID()); + while(aFIter != myFeatures.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 != myFeatures.end()) { // existing tag for feature + 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 + Model_FeatureDeletedMessage aMsg1(aThis, FEATURES_GROUP); + Model_FeatureDeletedMessage aMsg2(aThis, (*aFIter)->getGroup()); + aFIter = myFeatures.erase(aFIter); + // event: model is updated + Events_Loop::loop()->send(aMsg1); + Events_Loop::loop()->send(aMsg2); + } else if (aDSTag < aFeatureTag) { // a new feature is inserted + // create a feature + boost::shared_ptr aFeature = ModelAPI_PluginManager::get()->createFeature( + TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast( + aFLabIter.Value())->Get()).ToCString()); + + if (aFIter == myFeatures.end()) { // must be before "setData" to redo the sketch line correctly + myFeatures.push_back(aFeature); + aFIter = myFeatures.end(); + } else { aFIter++; - aFLabIter.Next(); + myFeatures.insert(aFIter, aFeature); } + boost::shared_ptr aData(new Model_Data); + TDF_Label aLab = aFLabIter.Value()->Label(); + aData->setLabel(aLab); + aData->setFeature(aFeature); + aFeature->setDoc(aThis); + aFeature->setData(aData); + aFeature->initAttributes(); + + // event: model is updated + static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED); + Model_FeatureUpdatedMessage aMsg1(aFeature, anEvent); + Events_Loop::loop()->send(aMsg1); + boost::shared_ptr anObj = objectByFeature(aFeature); + if (anObj) { + Model_FeatureUpdatedMessage aMsg2(anObj, anEvent); + Events_Loop::loop()->send(aMsg2); + } + + // 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 --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 6d5d04b6b..218ea615b 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -80,13 +80,6 @@ public: //! Returns the number of features in the group MODEL_EXPORT virtual int size(const std::string& theGroupID); - ///! Returns the vector of groups already added to the document - MODEL_EXPORT virtual const std::vector& getGroups() const; - - //! Returns the index of feature in the group (zero based) - //! \retruns -1 if not found - MODEL_EXPORT virtual int featureIndex(boost::shared_ptr theFeature); - protected: //! Returns (creates if needed) the group label @@ -99,7 +92,11 @@ protected: //! Adds to the document the new feature void addFeature(const boost::shared_ptr theFeature); - //! Synchronizes myGroups, myGroupsNames, myFeatures and mySubs list with the updated document + //! Returns the object by the feature + boost::shared_ptr objectByFeature( + const boost::shared_ptr theFeature); + + //! Synchronizes myFeatures list with the updated document void synchronizeFeatures(); //! Creates new document with binary file format @@ -114,12 +111,11 @@ private: int myTransactionsAfterSave; /// number of myTransactionsAfterSave for the nested transaction start int myNestedStart; - /// root labels of the features groups identified by names - std::map myGroups; - std::vector myGroupsNames; ///< names of added groups to the document - /// Features managed by this document: by group name - std::map > > myFeatures; - std::set mySubs; ///< set of identifiers of sub-documents of this document + /// All features managed by this document (not only in history of OB) + std::vector > myFeatures; + + ///< set of identifiers of sub-documents of this document + std::set mySubs; /// transaction indexes (related to myTransactionsAfterSave) which were empty in this doc std::map myIsEmptyTr; }; diff --git a/src/Model/Model_Object.cpp b/src/Model/Model_Object.cpp new file mode 100644 index 000000000..9b39c6d2f --- /dev/null +++ b/src/Model/Model_Object.cpp @@ -0,0 +1,27 @@ +// File: Model_Object.cpp +// Created: 19 May 2014 +// Author: Mikhail PONIKAROV + +#include "Model_Object.h" +#include + +boost::shared_ptr Model_Object::featureRef() +{ + return myRef; +} + +std::string Model_Object::getName() +{ + return TCollection_AsciiString(myName->Get()).ToCString(); +} + +void Model_Object::setName(std::string theName) +{ + myName->Set(theName.c_str()); +} + +Model_Object::Model_Object(boost::shared_ptr theRef, + Handle_TDataStd_Name theName) + : myRef(theRef), myName(theName) +{ +} diff --git a/src/Model/Model_Object.h b/src/Model/Model_Object.h new file mode 100644 index 000000000..18314c04d --- /dev/null +++ b/src/Model/Model_Object.h @@ -0,0 +1,53 @@ +// File: Model_Object.hxx +// Created: 19 May 2014 +// Author: Mikhail PONIKAROV + +#ifndef Model_Object_HeaderFile +#define Model_Object_HeaderFile + +#include +#include + +#include + +/**\class ModelAPI_Object + * \ingroup DataModel + * \brief Represents the result of some feature in the object browser + * under the specific folder. Just a reference to specific feature-operation + * with possibility to rename it. + */ +class Model_Object : public ModelAPI_Object +{ + boost::shared_ptr myRef; ///< the referenced feature + Handle_TDataStd_Name myName; ///< the name of this object that may be changed +public: + /// Reference to the feature-operation that produces this object + MODEL_EXPORT virtual boost::shared_ptr featureRef(); + + /// Returns the name of this object (by default equal to the name of feature) + MODEL_EXPORT virtual std::string getName(); + + /// Defines the name of the object + MODEL_EXPORT virtual void setName(std::string theName); + + /// Returns the kind of a feature (like "Point") + MODEL_EXPORT virtual const std::string& getKind() {return myRef->getKind();} + + /// Returns to which group in the document must be added feature + MODEL_EXPORT virtual const std::string& getGroup() {return myRef->getGroup();} + + /// It is just a reference: don't init attributes + MODEL_EXPORT virtual void initAttributes() {} + + /// It is just a reference: don't execute + MODEL_EXPORT virtual void execute() {} + +private: + + /// Constructor fully defines this object + Model_Object(boost::shared_ptr theRef, Handle_TDataStd_Name theName); + + friend class Model_Document; +}; + +#endif diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index e57b2c619..49757f69f 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -8,6 +8,7 @@ SET(PROJECT_HEADERS ModelAPI_Plugin.h ModelAPI_Feature.h ModelAPI_Data.h + ModelAPI_Object.h ModelAPI_Document.h ModelAPI_Attribute.h ModelAPI_AttributeDouble.h diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index 097bdcfd2..589ac4026 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -6,6 +6,7 @@ #include "ModelAPI_PluginManager.h" #include "ModelAPI_Feature.h" #include "ModelAPI_Data.h" + #include "ModelAPI_Object.h" #include "ModelAPI_Attribute.h" #include "ModelAPI_AttributeDocRef.h" #include "ModelAPI_AttributeDouble.h" @@ -27,6 +28,7 @@ %shared_ptr(ModelAPI_PluginManager) %shared_ptr(ModelAPI_Feature) %shared_ptr(ModelAPI_Data) +%shared_ptr(ModelAPI_Object) %shared_ptr(ModelAPI_Attribute) %shared_ptr(ModelAPI_AttributeDocRef) %shared_ptr(ModelAPI_AttributeDouble) @@ -38,6 +40,7 @@ %include "ModelAPI_PluginManager.h" %include "ModelAPI_Feature.h" %include "ModelAPI_Data.h" +%include "ModelAPI_Object.h" %include "ModelAPI_Attribute.h" %include "ModelAPI_AttributeDocRef.h" %include "ModelAPI_AttributeDouble.h" diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 4ae738022..311745a16 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -82,12 +82,6 @@ public: //! Returns the number of features in the group MODELAPI_EXPORT virtual int size(const std::string& theGroupID) = 0; - //! Returns the index of feature in the group (zero based) - MODELAPI_EXPORT virtual int featureIndex(boost::shared_ptr theFeature) = 0; - - ///! Returns the vector of groups already added to the document - MODELAPI_EXPORT virtual const std::vector& getGroups() const = 0; - /// To virtually destroy the fields of successors virtual ~ModelAPI_Document() {} diff --git a/src/ModelAPI/ModelAPI_Object.h b/src/ModelAPI/ModelAPI_Object.h new file mode 100644 index 000000000..64240ce38 --- /dev/null +++ b/src/ModelAPI/ModelAPI_Object.h @@ -0,0 +1,33 @@ +// File: ModelAPI_Object.hxx +// Created: 19 May 2014 +// Author: Mikhail PONIKAROV + +#ifndef ModelAPI_Object_HeaderFile +#define ModelAPI_Object_HeaderFile + +#include "ModelAPI_Feature.h" + +/**\class ModelAPI_Object + * \ingroup DataModel + * \brief Represents the result of some feature in the object browser + * under the specific folder. Just a reference to specific feature-operation + * with possibility to rename it. + */ +class ModelAPI_Object : public ModelAPI_Feature +{ +public: + + /// It is never located in history + MODELAPI_EXPORT virtual bool isInHistory() {return false;} + + /// Reference to the feature-operation that produces this object + MODELAPI_EXPORT virtual boost::shared_ptr featureRef() = 0; + + /// Returns the name of this object (by default equal to the name of feature) + MODELAPI_EXPORT virtual std::string getName() = 0; + + /// Defines the name of the object + MODELAPI_EXPORT virtual void setName(std::string theName) = 0; +}; + +#endif diff --git a/src/ModelAPI/ModelAPI_PluginManager.cpp b/src/ModelAPI/ModelAPI_PluginManager.cpp index bfdfbe813..a8d497c7c 100644 --- a/src/ModelAPI/ModelAPI_PluginManager.cpp +++ b/src/ModelAPI/ModelAPI_PluginManager.cpp @@ -7,6 +7,7 @@ #include // to avoid unresolved ModelAPI_Feature() #include +#include // to avoid unresolved ModelAPI_Data() #include // to avoid unresolved ModelAPI_Plugin() -- 2.39.2