From: mpv Date: Fri, 11 Jul 2014 07:17:01 +0000 (+0400) Subject: Initial version of redesign of working with results X-Git-Tag: V_0.4.4~200 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c0565e75ce0bd2f2994dc9874c4775cf7a4cb7ad;p=modules%2Fshaper.git Initial version of redesign of working with results --- diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt index 9dea7108a..fdfb04ccf 100644 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@ -6,7 +6,6 @@ SET(PROJECT_HEADERS Model_Document.h Model_PluginManager.h Model_Data.h - Model_Object.h Model_AttributeDouble.h Model_AttributeDocRef.h Model_AttributeReference.h @@ -16,6 +15,9 @@ SET(PROJECT_HEADERS Model_Events.h Model_Update.h Model_Validator.h + Model_ResultBody.h + Model_ResultConstruction.h + Model_ResultPart.h ) SET(PROJECT_SOURCES @@ -23,7 +25,6 @@ SET(PROJECT_SOURCES Model_Document.cpp Model_PluginManager.cpp Model_Data.cpp - Model_Object.cpp Model_AttributeDouble.cpp Model_AttributeDocRef.cpp Model_AttributeReference.cpp @@ -33,6 +34,9 @@ SET(PROJECT_SOURCES Model_Events.cpp Model_Update.cpp Model_Validator.cpp + Model_ResultBody.cpp + Model_ResultConstruction.cpp + Model_ResultPart.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 5b3a944c9..53e34ce97 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -15,6 +15,7 @@ #include #include "Model_Events.h" #include +#include using namespace std; @@ -27,7 +28,7 @@ void Model_Data::setLabel(TDF_Label& theLab) myLab = theLab; } -string Model_Data::getName() +string Model_Data::name() { Handle(TDataStd_Name) aName; if (myLab.FindAttribute(TDataStd_Name::GetID(), aName)) @@ -48,8 +49,8 @@ void Model_Data::setName(string theName) aName->Set(theName.c_str()); } if (isModified) { - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent, false); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false); } } @@ -78,10 +79,11 @@ void Model_Data::addAttribute(string theID, string theAttrType) if (anAttr) { myAttrs[theID] = boost::shared_ptr(anAttr); - anAttr->setFeature(myFeature); + anAttr->setObject(myObject); + } + else { + Events_Error::send("Can not create unknown type of attribute " + theAttrType); } - else - ; // TODO: generate error on unknown attribute request and/or add mechanism for customization } boost::shared_ptr Model_Data::docRef(const string theID) @@ -221,37 +223,6 @@ list > Model_Data::attributes(const string void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr) { theAttr->setInitialized(); - static const Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent); -} - -#include -#include -#include -#include - -void Model_Data::store(const boost::shared_ptr& theShape) -{ - // the simplest way is to keep this attribute here, on Data - // TODO: add naming structure in separated document for shape storage - TNaming_Builder aBuilder(myLab); - if (!theShape) return; // bad shape - TopoDS_Shape aShape = theShape->impl(); - if (aShape.IsNull()) return; // null shape inside - - aBuilder.Generated(aShape); -} - -boost::shared_ptr Model_Data::shape() -{ - Handle(TNaming_NamedShape) aName; - if (myLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { - TopoDS_Shape aShape = aName->Get(); - if (!aShape.IsNull()) { - boost::shared_ptr aRes(new GeomAPI_Shape); - aRes->setImpl(new TopoDS_Shape(aShape)); - return aRes; - } - } - return boost::shared_ptr(); + static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent); } diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index eca52e960..34f3ec7a9 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -26,8 +26,8 @@ class Model_Data: public ModelAPI_Data /// All attributes of the object identified by the attribute ID std::map > myAttrs; - /// needed here to emit signal that feature changed on change of the attribute - FeaturePtr myFeature; + /// needed here to emit signal that object changed on change of the attribute + ObjectPtr myObject; Model_Data(); @@ -41,7 +41,7 @@ class Model_Data: public ModelAPI_Data public: /// Returns the name of the feature visible by the user in the object browser - MODEL_EXPORT virtual std::string getName(); + MODEL_EXPORT virtual std::string name(); /// Defines the name of the feature visible by the user in the object browser MODEL_EXPORT virtual void setName(std::string theName); /// Returns the attribute that references to another document @@ -76,10 +76,8 @@ public: /// Returns true if it is correctly connected t othe data model MODEL_EXPORT virtual bool isValid(); - /// Stores the shape (called by the execution method). - MODEL_EXPORT virtual void store(const boost::shared_ptr& theShape); - /// Returns the shape-result produced by this feature - MODEL_EXPORT virtual boost::shared_ptr shape(); + /// Returns the label where the shape must be stored (used in ResultBody) + TDF_Label& shapeLab() {return myLab;} /// Initializes object by the attributes: must be called just after the object is created /// for each attribute of the object @@ -94,9 +92,9 @@ public: /// Puts feature to the document data sub-structure MODEL_EXPORT void setLabel(TDF_Label& theLab); - /// Sets the feature of this data - MODEL_EXPORT virtual void setFeature(FeaturePtr theFeature) - {myFeature = theFeature;} + /// Sets the object of this data + MODEL_EXPORT virtual void setObject(ObjectPtr theObject) + {myObject = theObject;} }; #endif diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 95cc5a9d1..68ec29401 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -3,12 +3,13 @@ // Author: Mikhail PONIKAROV #include -#include #include -#include #include #include #include +#include +#include +#include #include #include @@ -18,6 +19,7 @@ #include #include #include +#include #include #ifndef WIN32 @@ -33,9 +35,13 @@ 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 (features) +static const int TAG_OBJECTS = 2; // tag of the objects sub-tree (features, results) static const int TAG_HISTORY = 3; // tag of the history sub-tree (python dump) +// feature sub-labels +static const int TAG_FEATURE_ARGUMENTS = 1; ///< where the arguments are located +static const int TAG_FEATURE_RESULTS = 2; ///< where the results are located + using namespace std; /// Returns the file name of this document by the nameof directory and identifuer of a document @@ -212,9 +218,9 @@ void Model_Document::compactNested() { void Model_Document::finishOperation() { // just to be sure that everybody knows that changes were performed - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_CREATED)); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_DELETED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); if (myNestedNum != -1) // this nested transaction is owervritten myNestedNum++; @@ -319,18 +325,6 @@ void Model_Document::redo() subDocument(*aSubIter)->redo(); } -FeaturePtr Model_Document::addFeature(string theID) -{ - FeaturePtr aFeature = - ModelAPI_PluginManager::get()->createFeature(theID); - if (aFeature) { - boost::dynamic_pointer_cast(aFeature->documentToAdd())->addFeature(aFeature); - } else { - // TODO: generate error that feature is not created - } - 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; @@ -348,45 +342,41 @@ static void AddToRefArray(TDF_Label& theArrayLab, TDF_Label& theReferenced) { } } -void Model_Document::addFeature(const FeaturePtr theFeature) -{ - if (theFeature->isAction()) return; // do not add action to the data model - - 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(aFeatureLab, theFeature->getKind().c_str()); - myFeatures.push_back(theFeature); - // store feature in the history of features array - if (theFeature->isInHistory()) { - AddToRefArray(aFeaturesLab, aFeatureLab); +FeaturePtr Model_Document::addFeature(string theID) +{ + TDF_Label anEmptyLab; + FeaturePtr anEmptyFeature; + FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature(theID); + if (aFeature) { + TDF_Label aFeatureLab; + if (!aFeature->isAction()) {// do not add action to the data model + TDF_Label aFeaturesLab = groupLabel(FEATURES_GROUP); + aFeatureLab = aFeaturesLab.NewChild(); + initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS); + // keep the feature ID to restore document later correctly + TDataStd_Comment::Set(aFeatureLab, aFeature->getKind().c_str()); + myObjs[FEATURES_GROUP].push_back(aFeature); + // store feature in the history of features array + if (aFeature->isInHistory()) { + AddToRefArray(aFeaturesLab, aFeatureLab); + } + } + setUniqueName(aFeature); + if (!aFeature->isAction()) {// do not add action to the data model + // event: feature is added + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); + ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent); + } } - // 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); - TDF_Label aGrLabChild = aGroupLab.FindChild(1); - AddToRefArray(aGrLabChild, anObjLab); // reference to names is on the first sub - - // event: feature is added - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED); - ModelAPI_EventCreator::get()->sendUpdated(theFeature, anEvent); + return aFeature; +} + +void Model_Document::storeResult(boost::shared_ptr theResult, + const int theResultIndex) +{ + initData(theResult, boost::dynamic_pointer_cast(theResult->owner()->data())-> + label().Father().FindChild(TAG_FEATURE_RESULTS), theResultIndex); } /// Appenad to the array of references a new referenced label. @@ -423,18 +413,15 @@ static int RemoveFromRefArray( void Model_Document::removeFeature(FeaturePtr theFeature) { boost::shared_ptr aData = boost::static_pointer_cast(theFeature->data()); - TDF_Label aFeatureLabel = aData->label(); - // remove the object - TDF_Label aGroupLabel = groupLabel(theFeature->getGroup()); - int aRemovedIndex = RemoveFromRefArray(aGroupLabel, aFeatureLabel); - RemoveFromRefArray(aGroupLabel.FindChild(1), TDF_Label(), aRemovedIndex); - // remove feature from the myFeatures list - std::vector::iterator aFIter = myFeatures.begin(); - while(aFIter != myFeatures.end()) { - if (*aFIter == theFeature) { - aFIter = myFeatures.erase(aFIter); + TDF_Label aFeatureLabel = aData->label().Father(); + // remove feature from the myObjects list + std::vector& aVec = myObjs[FEATURES_GROUP]; + std::vector::iterator anIter = aVec.begin(); + while(anIter != aVec.end()) { + if (*anIter == theFeature) { + anIter = aVec.erase(anIter); } else { - aFIter++; + anIter++; } } // erase all attributes under the label of feature @@ -442,19 +429,29 @@ void Model_Document::removeFeature(FeaturePtr theFeature) // remove it from the references array RemoveFromRefArray(groupLabel(FEATURES_GROUP), aData->label()); - // event: feature is added - ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), theFeature->getGroup()); + // event: feature is deleted + ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), FEATURES_GROUP); +} + +/// returns the object group name by the object label +static string groupName(TDF_Label theObjectLabel) { + TDF_Label aGroupLab = theObjectLabel.Father(); + Handle(TDataStd_Comment) aComment; + if (aGroupLab.FindAttribute(TDataStd_Comment::GetID(), aComment)) + return 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 - vector::iterator aFIter = myFeatures.begin(); - for(; aFIter != myFeatures.end(); aFIter++) { + std::vector& aVec = myObjs[FEATURES_GROUP]; + vector::iterator aFIter = aVec.begin(); + for(; aFIter != aVec.end(); aFIter++) { boost::shared_ptr aData = boost::dynamic_pointer_cast((*aFIter)->data()); if (aData->label().IsEqual(theLabel)) - return *aFIter; + return boost::dynamic_pointer_cast(*aFIter); } return FeaturePtr(); // not found } @@ -467,39 +464,65 @@ boost::shared_ptr Model_Document::subDocument(string theDocID return Model_Application::getApplication()->getDocument(theDocID); } -FeaturePtr Model_Document::feature( - const string& theGroupID, const int theIndex, const bool isOperation) +ObjectPtr Model_Document::object(const string& theGroupID, const int theIndex) { - 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); - FeaturePtr aFeature = feature(aFeatureLab); - - if (theGroupID == FEATURES_GROUP || isOperation) { // 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; + if (theGroupID == FEATURES_GROUP) { + std::map >::iterator aFind = myObjs.find(theGroupID); + if (aFind != myObjs.end()) { + int aSize = aFind->second.size(); + if (theIndex >= 0 && theIndex < aSize) + return aFind->second[theIndex]; + } + } else { + // iterate all features in order to find the needed result + std::map >::iterator aFind = myObjs.find(FEATURES_GROUP); + if (aFind != myObjs.end()) { + vector::iterator aFIter = aFind->second.begin(); + for(int anIndex = 0; aFIter != aFind->second.end(); aFIter++) { + const list >& aResults = + boost::dynamic_pointer_cast(*aFIter)->results(); + list >::const_iterator aRIter = aResults.begin(); + for(; aRIter != aResults.cend(); aRIter++) { + if ((*aRIter)->isInHistory() && (*aRIter)->group() == theGroupID) { + if (anIndex == theIndex) + return *aRIter; + anIndex++; + } + } } } } - // not found - return FeaturePtr(); + return ObjectPtr(); } int Model_Document::size(const string& theGroupID) { - Handle(TDataStd_ReferenceArray) aRefs; - if (groupLabel(theGroupID).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) - return aRefs->Length(); + int aResult = 0; + if (theGroupID == FEATURES_GROUP) { + std::map >::iterator aFind = myObjs.find(theGroupID); + if (aFind != myObjs.end()) { + aResult = aFind->second.size(); + } + } else { + // iterate all features in order to find the needed result + std::map >::iterator aFind = myObjs.find(FEATURES_GROUP); + if (aFind != myObjs.end()) { + vector::iterator aFIter = aFind->second.begin(); + for(; aFIter != aFind->second.end(); aFIter++) { + const list >& aResults = + boost::dynamic_pointer_cast(*aFIter)->results(); + list >::const_iterator aRIter = aResults.begin(); + for(; aRIter != aResults.cend(); aRIter++) { + if ((*aRIter)->isInHistory() && (*aRIter)->group() == theGroupID) { + aResult++; + } + } + } + } + } // group is not found - return 0; + return aResult; } Model_Document::Model_Document(const std::string theID) @@ -535,126 +558,120 @@ TDF_Label Model_Document::groupLabel(const string theGroup) void Model_Document::setUniqueName(FeaturePtr theFeature) { string aName; // result - // iterate all features but also iterate group of this feature if object is not in history - list aGroups; - aGroups.push_back(FEATURES_GROUP); - if (!theFeature->isInHistory()) { - aGroups.push_back(theFeature->getGroup()); + // first count all objects of such kind to start with index = count + 1 + int a, aNumObjects = 0; + int aSize = size(FEATURES_GROUP); + for(a = 0; a < aSize; a++) { + if (boost::dynamic_pointer_cast(object(FEATURES_GROUP, a))->getKind() + == theFeature->getKind()) + aNumObjects++; } - for(list::iterator aGIter = aGroups.begin(); aGIter != aGroups.end(); aGIter++) { - // first count all objects of such kind to start with index = count + 1 - int a, aNumObjects = 0; - int aSize = size(*aGIter); - for(a = 0; a < aSize; a++) { - if (feature(*aGIter, a)->getKind() == theFeature->getKind()) - aNumObjects++; - } - // generate candidate name - stringstream aNameStream; - aNameStream<getKind()<<"_"<data()->getName() == aName) { - aNumObjects++; - stringstream aNameStream; - aNameStream<getKind()<<"_"<getKind()<<"_"<(object(FEATURES_GROUP, a)) + ->data()->name() == aName) { + aNumObjects++; + stringstream aNameStream; + aNameStream<getKind()<<"_"<data()->setName(aName); } -//! Returns the object by the feature -FeaturePtr Model_Document::objectByFeature( - const FeaturePtr theFeature) -{ - for(int a = 0; a < size(theFeature->getGroup()); a++) { - boost::shared_ptr anObj = - boost::dynamic_pointer_cast(feature(theFeature->getGroup(), a)); - if (anObj && anObj->featureRef() == theFeature) { - return anObj; - } - } - return FeaturePtr(); // not found +void Model_Document::initData(ObjectPtr theObj, TDF_Label& theLab, const int theTag) { + boost::shared_ptr aThis = + Model_Application::getApplication()->getDocument(myID); + boost::shared_ptr aData(new Model_Data); + aData->setLabel(theLab.FindChild(theTag)); + aData->setObject(theObj); + theObj->setDoc(aThis); + theObj->setData(aData); + FeaturePtr aFeature = boost::dynamic_pointer_cast(theObj); + if (aFeature) aFeature->initAttributes(); } void Model_Document::synchronizeFeatures(const bool theMarkUpdated) { - boost::shared_ptr aThis = Model_Application::getApplication()->getDocument(myID); - // 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 - FeaturePtr aFeature = *aFIter; - aFIter = myFeatures.erase(aFIter); - // event: model is updated - if (aFeature->isInHistory()) { - ModelAPI_EventCreator::get()->sendDeleted(aThis, FEATURES_GROUP); - } - ModelAPI_EventCreator::get()->sendDeleted(aThis, aFeature->getGroup()); - } else if (aDSTag < aFeatureTag) { // a new feature is inserted - // create a feature - FeaturePtr 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++; - myFeatures.insert(aFIter, aFeature); + boost::shared_ptr aThis = + Model_Application::getApplication()->getDocument(myID); + // update all objects: iterate from the end: as they appeared in the list + map >::reverse_iterator aGroupIter = myObjs.rbegin(); + for(; aGroupIter != myObjs.rend(); aGroupIter++) { + vector::iterator anObjIter = aGroupIter->second.begin(); + // and in parallel iterate labels of features + const 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 aData = + boost::dynamic_pointer_cast((*anObjIter)->data()); + aFeatureTag = aData->label().Tag(); } - 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); - ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent); - FeaturePtr anObj = objectByFeature(aFeature); - if (anObj) { - ModelAPI_EventCreator::get()->sendUpdated(anObj, anEvent); + int aDSTag = INFINITE_TAG; + if (aLabIter.More()) { // next label in DS is existing + aDSTag = aLabIter.Value()->Label().Tag(); } - - // feature for this label is added, so go to the next label - aFLabIter.Next(); - } else { // nothing is changed, both iterators are incremented - if (theMarkUpdated) { - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - ModelAPI_EventCreator::get()->sendUpdated(*aFIter, anEvent); + 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); + } + ModelAPI_EventCreator::get()->sendDeleted(aThis, aGroupName); + } 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(); } - aFIter++; - aFLabIter.Next(); } } // after all updates, sends a message that groups of features were created or updated boost::static_pointer_cast(Model_PluginManager::get())-> setCheckTransactions(false); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_CREATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); if (theMarkUpdated) - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_DELETED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); boost::static_pointer_cast(Model_PluginManager::get())-> setCheckTransactions(true); } + +boost::shared_ptr createConstruction() +{ + boost::shared_ptr aResult(new Model_ResultConstruction()); + return aResult; +} diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index eaedf13db..f6d59b785 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -64,7 +65,7 @@ public: //! \param creates feature and puts it in the document MODEL_EXPORT virtual FeaturePtr addFeature(std::string theID); - //! Removes the feature from the document + //! Removes the feature from the document (with result) MODEL_EXPORT virtual void removeFeature(FeaturePtr theFeature); //! Returns the existing feature by the label @@ -81,12 +82,18 @@ public: //! \param theGroupID group that contains a feature //! \param theIndex zero-based index of feature in the group //! \param isOperation if it is true, returns feature (not Object) - MODEL_EXPORT virtual FeaturePtr - feature(const std::string& theGroupID, const int theIndex, const bool isOperation = false); + MODEL_EXPORT virtual ObjectPtr object(const std::string& theGroupID, const int theIndex); //! Returns the number of features in the group MODEL_EXPORT virtual int size(const std::string& theGroupID); + //! 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 theResult, const int theResultIndex); + + /// Creates a construction cresults + MODEL_EXPORT virtual boost::shared_ptr createConstruction(); + protected: //! Returns (creates if needed) the group label @@ -96,13 +103,6 @@ protected: //! feature type + "_" + index void setUniqueName(FeaturePtr theFeature); - //! Adds to the document the new feature - void addFeature(const FeaturePtr theFeature); - - //! Returns the object by the feature - FeaturePtr objectByFeature( - const FeaturePtr theFeature); - //! Synchronizes myFeatures list with the updated document void synchronizeFeatures(const bool theMarkUpdated = false); @@ -114,6 +114,11 @@ protected: //! performas compactification of all nested operations into one void compactNested(); + //! Initializes the data fields of the feature + void Model_Document::initData(ObjectPtr theObj, TDF_Label& theLab, const int theTag); + + + friend class Model_Application; friend class Model_PluginManager; friend class DFBrowser; @@ -125,8 +130,8 @@ private: int myTransactionsAfterSave; /// number of nested transactions performed (or -1 if not nested) int myNestedNum; - /// All features managed by this document (not only in history of OB) - std::vector myFeatures; + /// All objects managed by this document (not only in history of OB) + std::map > myObjs; ///< set of identifiers of sub-documents of this document std::set mySubs; diff --git a/src/Model/Model_Events.cpp b/src/Model/Model_Events.cpp index fb94001b8..2def67f43 100644 --- a/src/Model/Model_Events.cpp +++ b/src/Model/Model_Events.cpp @@ -10,16 +10,16 @@ Model_EventCreator MY_CREATOR; /////////////////////// CREATOR ///////////////////////////// void Model_EventCreator::sendUpdated( - const FeaturePtr& theFeature, const Events_ID& theEvent, const bool isGroupped) const + const ObjectPtr& theObject, const Events_ID& theEvent, const bool isGroupped) const { - Model_FeatureUpdatedMessage aMsg(theFeature, theEvent); + Model_ObjectUpdatedMessage aMsg(theObject, theEvent); Events_Loop::loop()->send(aMsg, isGroupped); } void Model_EventCreator::sendDeleted( const boost::shared_ptr& theDoc, const std::string& theGroup) const { - Model_FeatureDeletedMessage aMsg(theDoc, theGroup); + Model_ObjectDeletedMessage aMsg(theDoc, theGroup); Events_Loop::loop()->send(aMsg, true); } @@ -29,56 +29,56 @@ Model_EventCreator::Model_EventCreator() } /////////////////////// UPDATED MESSAGE ///////////////////////////// -Model_FeatureUpdatedMessage::Model_FeatureUpdatedMessage( - const FeaturePtr& theFeature, - const Events_ID& theEvent) : ModelAPI_FeatureUpdatedMessage(theEvent, 0) +Model_ObjectUpdatedMessage::Model_ObjectUpdatedMessage( + const ObjectPtr& theObject, + const Events_ID& theEvent) : ModelAPI_ObjectUpdatedMessage(theEvent, 0) { - if (theFeature) myFeatures.insert(theFeature); + if (theObject) myObjects.insert(theObject); } -std::set Model_FeatureUpdatedMessage::features() const +std::set Model_ObjectUpdatedMessage::features() const { - return myFeatures; + return myObjects; } -Events_MessageGroup* Model_FeatureUpdatedMessage::newEmpty() +Events_MessageGroup* Model_ObjectUpdatedMessage::newEmpty() { - FeaturePtr anEmptyFeature; - return new Model_FeatureUpdatedMessage(anEmptyFeature, eventID()); + ObjectPtr anEmptyObject; + return new Model_ObjectUpdatedMessage(anEmptyObject, eventID()); } -void Model_FeatureUpdatedMessage::Join(Events_MessageGroup& theJoined) +void Model_ObjectUpdatedMessage::Join(Events_MessageGroup& theJoined) { - Model_FeatureUpdatedMessage* aJoined = dynamic_cast(&theJoined); - std::set::iterator aFIter = aJoined->myFeatures.begin(); - for(; aFIter != aJoined->myFeatures.end(); aFIter++) { - myFeatures.insert(*aFIter); + Model_ObjectUpdatedMessage* aJoined = dynamic_cast(&theJoined); + std::set::iterator aFIter = aJoined->myObjects.begin(); + for(; aFIter != aJoined->myObjects.end(); aFIter++) { + myObjects.insert(*aFIter); } } /////////////////////// DELETED MESSAGE ///////////////////////////// -Model_FeatureDeletedMessage::Model_FeatureDeletedMessage( +Model_ObjectDeletedMessage::Model_ObjectDeletedMessage( const boost::shared_ptr& theDoc, const std::string& theGroup) - : ModelAPI_FeatureDeletedMessage(messageId(), 0), myDoc(theDoc) + : ModelAPI_ObjectDeletedMessage(messageId(), 0), myDoc(theDoc) { if (!theGroup.empty()) myGroups.insert(theGroup); } -Events_MessageGroup* Model_FeatureDeletedMessage::newEmpty() +Events_MessageGroup* Model_ObjectDeletedMessage::newEmpty() { - return new Model_FeatureDeletedMessage(myDoc, ""); + return new Model_ObjectDeletedMessage(myDoc, ""); } -const Events_ID Model_FeatureDeletedMessage::messageId() +const Events_ID Model_ObjectDeletedMessage::messageId() { - static Events_ID MY_ID = Events_Loop::eventByName(EVENT_FEATURE_DELETED); + static Events_ID MY_ID = Events_Loop::eventByName(EVENT_OBJECT_DELETED); return MY_ID; } -void Model_FeatureDeletedMessage::Join(Events_MessageGroup& theJoined) +void Model_ObjectDeletedMessage::Join(Events_MessageGroup& theJoined) { - Model_FeatureDeletedMessage* aJoined = dynamic_cast(&theJoined); + Model_ObjectDeletedMessage* aJoined = dynamic_cast(&theJoined); std::set::iterator aGIter = aJoined->myGroups.begin(); for(; aGIter != aJoined->myGroups.end(); aGIter++) { myGroups.insert(*aGIter); diff --git a/src/Model/Model_Events.h b/src/Model/Model_Events.h index a4912648d..56e4b141f 100644 --- a/src/Model/Model_Events.h +++ b/src/Model/Model_Events.h @@ -13,7 +13,7 @@ class Model_EventCreator : public ModelAPI_EventCreator { public: /// creates created, updated or moved messages and sends to the loop virtual void sendUpdated( - const FeaturePtr& theFeature, const Events_ID& theEvent, const bool isGroupped = true) const; + const ObjectPtr& theObject, const Events_ID& theEvent, const bool isGroupped = true) const; /// creates deleted message and sends to the loop virtual void sendDeleted( const boost::shared_ptr& theDoc, const std::string& theGroup) const; @@ -23,20 +23,20 @@ public: }; /// Message that feature was changed (used for Object Browser update): moved, updated and deleted -class Model_FeatureUpdatedMessage : public ModelAPI_FeatureUpdatedMessage { - std::set myFeatures; ///< which feature is changed +class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage { + std::set myObjects; ///< which feature is changed /// Sender is not important, all information is located in the feature. /// Use ModelAPI for creation of this event. Used for creation, movement and edition events. - Model_FeatureUpdatedMessage( - const FeaturePtr& theFeature, + Model_ObjectUpdatedMessage( + const ObjectPtr& theObject, const Events_ID& theEvent); friend class Model_EventCreator; public: /// Returns the feature that has been updated - virtual std::set features() const; + virtual std::set features() const; //! Creates a new empty group (to store it in the loop before flush) virtual Events_MessageGroup* newEmpty(); @@ -46,12 +46,12 @@ public: }; /// Message that feature was deleted (used for Object Browser update) -class Model_FeatureDeletedMessage : public ModelAPI_FeatureDeletedMessage { +class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage { boost::shared_ptr myDoc; ///< document owner of the feature std::set myGroups; ///< group identifiers that contained the deleted feature /// Use ModelAPI for creation of this event. - Model_FeatureDeletedMessage( + Model_ObjectDeletedMessage( const boost::shared_ptr& theDoc, const std::string& theGroup); friend class Model_EventCreator; diff --git a/src/Model/Model_Object.cpp b/src/Model/Model_Object.cpp deleted file mode 100644 index e0c5b3028..000000000 --- a/src/Model/Model_Object.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// File: Model_Object.cpp -// Created: 19 May 2014 -// Author: Mikhail PONIKAROV - -#include "Model_Object.h" -#include -#include "Model_Events.h" -#include - -FeaturePtr Model_Object::featureRef() -{ - return myRef; -} - -std::string Model_Object::getName() -{ - return TCollection_AsciiString(myName->Get()).ToCString(); -} - -void Model_Object::setName(std::string theName) -{ - if (myName->Get() != theName.c_str()) { - myName->Set(theName.c_str()); - /* - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - Model_FeatureUpdatedMessage aMsg(boost::shared_ptr(this), anEvent); - Events_Loop::loop()->send(aMsg, false); - */ - } -} - -Model_Object::Model_Object(FeaturePtr theRef, - Handle_TDataStd_Name theName) - : myRef(theRef), myName(theName) -{ -} diff --git a/src/Model/Model_Object.h b/src/Model/Model_Object.h deleted file mode 100644 index 73975bc28..000000000 --- a/src/Model/Model_Object.h +++ /dev/null @@ -1,65 +0,0 @@ -// File: Model_Object.hxx -// Created: 19 May 2014 -// Author: Mikhail PONIKAROV - -#ifndef Model_Object_HeaderFile -#define Model_Object_HeaderFile - -#include -#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 -{ - FeaturePtr 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 FeaturePtr 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 FEATURES_GROUP;} - - /// Returns document this feature belongs to - MODEL_EXPORT virtual boost::shared_ptr document() - {return myRef->document();} - - /// Returns true if feature refers to the same model data instance - MODEL_EXPORT virtual bool isSame(const FeaturePtr& theFeature) - { - boost::shared_ptr anObj = boost::dynamic_pointer_cast(theFeature); - return anObj && myRef == anObj->myRef; - } - - /// 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(FeaturePtr theRef, Handle_TDataStd_Name theName); - - friend class Model_Document; -}; - -#endif diff --git a/src/Model/Model_PluginManager.cpp b/src/Model/Model_PluginManager.cpp index d26ccd144..1dabf1990 100644 --- a/src/Model/Model_PluginManager.cpp +++ b/src/Model/Model_PluginManager.cpp @@ -47,6 +47,8 @@ FeaturePtr Model_PluginManager::createFeature(string theFeatureID) } else { Events_Error::send(string("Can not load plugin '") + myCurrentPluginName + "'"); } + } else { + Events_Error::send(string("Feature '") + theFeatureID + "' not found in any plugin"); } return FeaturePtr(); // return nothing @@ -107,9 +109,9 @@ Model_PluginManager::Model_PluginManager() Events_Loop* aLoop = Events_Loop::loop(); static Events_ID FeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent"); aLoop->registerListener(this, FeatureEvent); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); } void Model_PluginManager::processEvent(const Events_Message* theMessage) diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp new file mode 100644 index 000000000..687bc112c --- /dev/null +++ b/src/Model/Model_ResultBody.cpp @@ -0,0 +1,53 @@ +// File: Model_ResultBody.cpp +// Created: 08 Jul 2014 +// Author: Mikhail PONIKAROV + +#include +#include +#include +#include +#include +#include + +Model_ResultBody::Model_ResultBody(const boost::shared_ptr& theFeature) + : myOwner(theFeature) +{ +} + +void Model_ResultBody::store(const boost::shared_ptr& theShape) +{ + boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); + if (aData) { + TDF_Label& aShapeLab = aData->shapeLab(); + // TODO: to add the naming mechanism for shape storage in the next iteration + TNaming_Builder aBuilder(aShapeLab); + if (!theShape) return; // bad shape + TopoDS_Shape aShape = theShape->impl(); + if (aShape.IsNull()) return; // null shape inside + + aBuilder.Generated(aShape); + } +} + +boost::shared_ptr Model_ResultBody::shape() +{ + boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); + if (aData) { + TDF_Label& aShapeLab = aData->shapeLab(); + Handle(TNaming_NamedShape) aName; + if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { + TopoDS_Shape aShape = aName->Get(); + if (!aShape.IsNull()) { + boost::shared_ptr aRes(new GeomAPI_Shape); + aRes->setImpl(new TopoDS_Shape(aShape)); + return aRes; + } + } + } + return boost::shared_ptr(); +} + +boost::shared_ptr Model_ResultBody::owner() +{ + return myOwner; +} diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h new file mode 100644 index 000000000..3757e5d1f --- /dev/null +++ b/src/Model/Model_ResultBody.h @@ -0,0 +1,37 @@ +// File: Model_ResultBody.h +// Created: 08 Jul 2014 +// Author: Mikhail PONIKAROV + +#ifndef Model_ResultBody_HeaderFile +#define Model_ResultBody_HeaderFile + +#include "Model.h" +#include + +/**\class ModelAPI_ResultBody + * \ingroup DataModel + * \brief The body (shape) result of a feature. + * + * Provides a shape that may be displayed in the viewer. + * May provide really huge results, so, working with this kind + * of result must be optimized. + */ +class Model_ResultBody : public ModelAPI_ResultBody +{ + boost::shared_ptr myOwner; ///< owner of this result +public: + /// Stores the shape (called by the execution method). + MODEL_EXPORT virtual void store(const boost::shared_ptr& theShape); + /// Returns the shape-result produced by this feature + MODEL_EXPORT virtual boost::shared_ptr shape(); + /// Returns the source feature of this result + MODEL_EXPORT virtual boost::shared_ptr owner(); + +protected: + /// Makes a body on the given feature + Model_ResultBody(const boost::shared_ptr& theFeature); + + friend class Model_Document; +}; + +#endif diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp new file mode 100644 index 000000000..a5e1ccc9b --- /dev/null +++ b/src/Model/Model_ResultConstruction.cpp @@ -0,0 +1,26 @@ +// File: ModelAPI_ResultConstruction.cpp +// Created: 07 Jul 2014 +// Author: Mikhail PONIKAROV + +#include + +void Model_ResultConstruction::setShape(boost::shared_ptr theShape) +{ + myShape = theShape; +} + +boost::shared_ptr& Model_ResultConstruction::shape() +{ + return myShape; +} + +boost::shared_ptr Model_ResultConstruction::owner() +{ + return myOwner; +} + +Model_ResultConstruction::Model_ResultConstruction( + const boost::shared_ptr& theFeature) + : myOwner(theFeature) +{ +} diff --git a/src/Model/Model_ResultConstruction.h b/src/Model/Model_ResultConstruction.h new file mode 100644 index 000000000..b6ca72156 --- /dev/null +++ b/src/Model/Model_ResultConstruction.h @@ -0,0 +1,40 @@ +// File: ModelAPI_ResultConstruction.hxx +// Created: 07 Jul 2014 +// Author: Mikhail PONIKAROV + +#ifndef Model_ResultConstruction_HeaderFile +#define Model_ResultConstruction_HeaderFile + +#include "Model.h" +#include + +/**\class ModelAPI_ResultConstruction + * \ingroup DataModel + * \brief The construction element result of a feature. + * + * Provides a shape that may be displayed in the viewer. + * Intermediate, light result that in many cases produces a result on the fly. + */ +class Model_ResultConstruction : public ModelAPI_ResultConstruction +{ + boost::shared_ptr myOwner; ///< owner of this result + boost::shared_ptr myShape; ///< shape of this result created "on the fly" +public: + /// Returns the group identifier of this result + virtual std::string group() + {static std::string MY_GROUP = "Construction"; return MY_GROUP;} + /// Sets the result + MODEL_EXPORT virtual void setShape(boost::shared_ptr theShape); + /// Returns the shape-result produced by this feature + MODEL_EXPORT virtual boost::shared_ptr& shape(); + /// Returns the source feature of this result + MODEL_EXPORT virtual boost::shared_ptr owner(); + +protected: + /// Makes a body on the given feature + Model_ResultConstruction(); + + friend class Model_Document; +}; + +#endif diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp new file mode 100644 index 000000000..38b72fad9 --- /dev/null +++ b/src/Model/Model_ResultPart.cpp @@ -0,0 +1,22 @@ +// File: ModelAPI_ResultPart.cpp +// Created: 07 Jul 2014 +// Author: Mikhail PONIKAROV + +#include +#include +#include + +boost::shared_ptr Model_ResultPart::partDoc() +{ + return data()->docRef("PartDocument")->value(); +} + +boost::shared_ptr Model_ResultPart::owner() +{ + return boost::shared_ptr(); // return empty pointer +} + +Model_ResultPart::Model_ResultPart( +const boost::shared_ptr& theFeature) +{ +} diff --git a/src/Model/Model_ResultPart.h b/src/Model/Model_ResultPart.h new file mode 100644 index 000000000..b2daa5dfe --- /dev/null +++ b/src/Model/Model_ResultPart.h @@ -0,0 +1,36 @@ +// File: ModelAPI_ResultPart.hxx +// Created: 07 Jul 2014 +// Author: Mikhail PONIKAROV + +#ifndef Model_ResultPart_HeaderFile +#define Model_ResultPart_HeaderFile + +#include "Model.h" +#include + +/**\class ModelAPI_ResultPart + * \ingroup DataModel + * \brief The Part document, result of a creation of new part feature. + * + * This result leaves without feature: no parametricity for this element, + * only add/remove, undo/redo. + */ +class Model_ResultPart : public ModelAPI_ResultPart +{ +public: + /// Returns the group identifier of this result + virtual std::string group() + {static std::string MY_GROUP = "Parts"; return MY_GROUP;} + /// Returns the part-document of this result + MODEL_EXPORT virtual boost::shared_ptr partDoc(); + /// Part has no stored feature: this method returns NULL + MODEL_EXPORT virtual boost::shared_ptr owner(); + +protected: + /// makes a result on a temporary feature (an action) + Model_ResultPart(const boost::shared_ptr& theFeature); + + friend class Model_Document; +}; + +#endif diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 6c8bd6431..4fd5f2965 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -17,17 +17,17 @@ Model_Update MY_INSTANCE; /// the only one instance initialized on load of the l Model_Update::Model_Update() { - Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); + Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); } void Model_Update::processEvent(const Events_Message* theMessage) { - const ModelAPI_FeatureUpdatedMessage* aMsg = - dynamic_cast(theMessage); + const ModelAPI_ObjectUpdatedMessage* aMsg = + dynamic_cast(theMessage); myInitial = aMsg->features(); // collect all documents involved into the update set > aDocs; - set >::iterator aFIter = myInitial.begin(); + set >::iterator aFIter = myInitial.begin(); for(; aFIter != myInitial.end(); aFIter++) { aDocs.insert((*aFIter)->document()); } @@ -36,14 +36,15 @@ void Model_Update::processEvent(const Events_Message* theMessage) for(; aDIter != aDocs.end(); aDIter++) { int aNbFeatures = (*aDIter)->size(FEATURES_GROUP); for(int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) { - boost::shared_ptr aFeature = (*aDIter)->feature(FEATURES_GROUP, aFIndex); + boost::shared_ptr aFeature = + boost::dynamic_pointer_cast((*aDIter)->object(FEATURES_GROUP, aFIndex)); if (aFeature) updateFeature(aFeature); } } myUpdated.clear(); // flush - static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_FEATURE_TO_REDISPLAY); + static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); Events_Loop::loop()->flush(EVENT_DISP); } @@ -80,7 +81,7 @@ bool Model_Update::updateFeature(boost::shared_ptr theFeature) bool anExecute = aMustbeUpdated || myInitial.find(theFeature) != myInitial.end(); if (anExecute) { theFeature->execute(); - static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_FEATURE_TO_REDISPLAY); + static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP); } myUpdated[theFeature] = anExecute; diff --git a/src/Model/Model_Update.h b/src/Model/Model_Update.h index d49c1c01e..3d5e58a01 100644 --- a/src/Model/Model_Update.h +++ b/src/Model/Model_Update.h @@ -11,6 +11,7 @@ #include #include +class ModelAPI_Object; class ModelAPI_Feature; /**\class Model_Update @@ -20,9 +21,9 @@ class ModelAPI_Feature; class Model_Update : public Events_Listener { ///< initial set of updated features that must be processed - std::set > myInitial; + std::set > myInitial; ///< already updated and processed features and modificated feature flag - std::map, bool> myUpdated; + std::map, bool> myUpdated; public: /// Is called only once, on startup of the application Model_Update(); diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 8b834dd72..80ec6cd74 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -20,6 +20,10 @@ SET(PROJECT_HEADERS ModelAPI_Events.h ModelAPI_Validator.h ModelAPI_FeatureValidator.h + ModelAPI_Result.h + ModelAPI_ResultBody.h + ModelAPI_ResultConstruction.h + ModelAPI_ResultPart.h ) SET(PROJECT_SOURCES diff --git a/src/ModelAPI/ModelAPI_Attribute.h b/src/ModelAPI/ModelAPI_Attribute.h index 4a15abb88..55cbb7cfd 100644 --- a/src/ModelAPI/ModelAPI_Attribute.h +++ b/src/ModelAPI/ModelAPI_Attribute.h @@ -9,7 +9,7 @@ #include #include -class ModelAPI_Feature; +class ModelAPI_Object; /**\class ModelAPI_Attribute * \ingroup DataModel @@ -18,7 +18,7 @@ class ModelAPI_Feature; class ModelAPI_Attribute { ///< needed here to emit signal that feature changed on change of the attribute - boost::shared_ptr myFeature; + boost::shared_ptr myObject; protected: // accessible from the attributes bool myIsInitialized; public: @@ -30,12 +30,12 @@ public: MODELAPI_EXPORT virtual ~ModelAPI_Attribute() {} /// Sets the owner of this attribute - MODELAPI_EXPORT void setFeature(const boost::shared_ptr& theFeature) - {myFeature = theFeature;} + MODELAPI_EXPORT void setObject(const boost::shared_ptr& theObject) + {myObject = theObject;} /// Returns the owner of this attribute - MODELAPI_EXPORT const boost::shared_ptr& owner() - {return myFeature;} + MODELAPI_EXPORT const boost::shared_ptr& owner() + {return myObject;} /// Returns true if attribute was initialized by some value MODELAPI_EXPORT bool isInitialized() {return myIsInitialized;} diff --git a/src/ModelAPI/ModelAPI_Data.h b/src/ModelAPI/ModelAPI_Data.h index 5d6e36d5f..eea1d1ae8 100644 --- a/src/ModelAPI/ModelAPI_Data.h +++ b/src/ModelAPI/ModelAPI_Data.h @@ -31,7 +31,7 @@ class MODELAPI_EXPORT ModelAPI_Data public: /// Returns the name of the feature visible by the user in the object browser - virtual std::string getName() = 0; + virtual std::string name() = 0; /// Defines the name of the feature visible by the user in the object browser virtual void setName(std::string theName) = 0; @@ -64,11 +64,6 @@ public: /// Returns true if it is correctly connected t othe data model virtual bool isValid() = 0; - /// Stores the shape (called by the execution method). - virtual void store(const boost::shared_ptr& theShape) = 0; - /// Returns the shape-result produced by this feature - virtual boost::shared_ptr shape() = 0; - /// Initializes object by the attributes: must be called just after the object is created /// for each attribute of the object /// \param theID identifier of the attribute that can be referenced by this ID later diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 9070718b4..36342b3dd 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -11,6 +11,9 @@ #include class ModelAPI_Feature; +class ModelAPI_Object; +class ModelAPI_Result; +class ModelAPI_ResultConstruction; /// Common groups identifiers /// Group of parameters @@ -19,6 +22,8 @@ static const std::string PARAMETERS_GROUP = "Parameters"; static const std::string CONSTRUCTIONS_GROUP = "Construction"; /// Group of parts static const std::string PARTS_GROUP = "Parts"; +/// Group of bodies +static const std::string BODIES_GROUP = "Bodies"; /// All created fetaures of the document (a history) static const std::string FEATURES_GROUP = "Features"; @@ -35,63 +40,65 @@ public: //! \param theFileName full name of the file to load //! \param theStudyID identifier of the SALOME study to associate with loaded file //! \returns true if file was loaded successfully - MODELAPI_EXPORT virtual bool load(const char* theFileName) = 0; + virtual bool load(const char* theFileName) = 0; //! Saves the OCAF document to the file. //! \param theFileName full name of the file to store //! \returns true if file was stored successfully - MODELAPI_EXPORT virtual bool save(const char* theFileName) = 0; + virtual bool save(const char* theFileName) = 0; //! Removes document data - MODELAPI_EXPORT virtual void close() = 0; + virtual void close() = 0; //! Starts a new operation (opens a tansaction) - MODELAPI_EXPORT virtual void startOperation() = 0; + virtual void startOperation() = 0; //! Finishes the previously started operation (closes the transaction) - MODELAPI_EXPORT virtual void finishOperation() = 0; + virtual void finishOperation() = 0; //! Aborts the operation - MODELAPI_EXPORT virtual void abortOperation() = 0; + virtual void abortOperation() = 0; //! Returns true if operation has been started, but not yet finished or aborted - MODELAPI_EXPORT virtual bool isOperation() = 0; + virtual bool isOperation() = 0; //! Returns true if document was modified (since creation/opening) - MODELAPI_EXPORT virtual bool isModified() = 0; + virtual bool isModified() = 0; //! Returns True if there are available Undos - MODELAPI_EXPORT virtual bool canUndo() = 0; + virtual bool canUndo() = 0; //! Undoes last operation - MODELAPI_EXPORT virtual void undo() = 0; + virtual void undo() = 0; //! Returns True if there are available Redos - MODELAPI_EXPORT virtual bool canRedo() = 0; + virtual bool canRedo() = 0; //! Redoes last operation - MODELAPI_EXPORT virtual void redo() = 0; + virtual void redo() = 0; //! Adds to the document the new feature of the given feature id - //! \param creates feature and puts it in the document - MODELAPI_EXPORT virtual boost::shared_ptr addFeature(std::string theID) = 0; + //! \param creates feature and puts it in the document (if it is not action) + virtual boost::shared_ptr addFeature(std::string theID) = 0; //! Removes the feature from the document - MODELAPI_EXPORT virtual void removeFeature(boost::shared_ptr theFeature) = 0; + virtual void removeFeature(boost::shared_ptr theFeature) = 0; ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist - MODELAPI_EXPORT virtual boost::shared_ptr + virtual boost::shared_ptr subDocument(std::string theDocID) = 0; - ///! Returns the id of hte document - MODELAPI_EXPORT virtual const std::string& id() const = 0; + ///! Returns the id of the document + virtual const std::string& id() const = 0; - //! Returns the feature in the group by the index (started from zero) - //! \param theGroupID group that contains a feature + //! Returns the object in the group by the index (started from zero) + //! \param theGroupID group that contains an object //! \param theIndex zero-based index of feature in the group - //! \param isOperation if it is true, returns feature (not Object) - MODELAPI_EXPORT virtual boost::shared_ptr - feature(const std::string& theGroupID, const int theIndex, const bool isOperation = false) = 0; + virtual boost::shared_ptr + object(const std::string& theGroupID, const int theIndex) = 0; - //! Returns the number of features in the group - MODELAPI_EXPORT virtual int size(const std::string& theGroupID) = 0; + //! Returns the number of objects in the group of objects + virtual int size(const std::string& theGroupID) = 0; /// To virtually destroy the fields of successors virtual ~ModelAPI_Document() {} + /// Creates a construction cresults + virtual boost::shared_ptr createConstruction() = 0; + protected: /// Only for SWIG wrapping it is here MODELAPI_EXPORT ModelAPI_Document() diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index 215c34c71..773d20b41 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -11,32 +11,32 @@ #include #include -#include "ModelAPI_Feature.h" +#include "ModelAPI_Object.h" class ModelAPI_Document; -/// Event ID that feature is created (comes with ModelAPI_FeatureUpdatedMessage) -static const char * EVENT_FEATURE_CREATED = "FeatureCreated"; -/// Event ID that data of feature is updated (comes with Model_FeatureUpdatedMessage) -static const char * EVENT_FEATURE_UPDATED = "FeatureUpdated"; -/// Event ID that data of feature is deleted (comes with Model_FeatureDeletedMessage) -static const char * EVENT_FEATURE_DELETED = "FeatureDeleted"; -/// Event ID that data of feature is updated (comes with ModelAPI_FeatureUpdatedMessage) -static const char * EVENT_FEATURE_MOVED = "FeaturesMoved"; -/// Event ID that visualization must be redisplayed (comes with ModelAPI_FeatureUpdatedMessage) -static const char * EVENT_FEATURE_TO_REDISPLAY = "FeaturesToRedisplay"; -/// Event ID that visualization must be redisplayed (comes with ModelAPI_FeatureUpdatedMessage) +/// Event ID that feature is created (comes with ModelAPI_ObjectUpdatedMessage) +static const char * EVENT_OBJECT_CREATED = "ObjectCreated"; +/// Event ID that data of feature is updated (comes with Model_ObjectUpdatedMessage) +static const char * EVENT_OBJECT_UPDATED = "ObjectUpdated"; +/// Event ID that data of feature is deleted (comes with Model_ObjectDeletedMessage) +static const char * EVENT_OBJECT_DELETED = "ObjectDeleted"; +/// Event ID that data of feature is updated (comes with ModelAPI_ObjectUpdatedMessage) +static const char * EVENT_OBJECT_MOVED = "ObjectsMoved"; +/// Event ID that visualization must be redisplayed (comes with ModelAPI_ObjectUpdatedMessage) +static const char * EVENT_OBJECT_TO_REDISPLAY = "ObjectsToRedisplay"; +/// Event ID that visualization must be redisplayed (comes with ModelAPI_ObjectUpdatedMessage) static const char * EVENT_OPERATION_LAUNCHED = "OperationLaunched"; /// Message that feature was changed (used for Object Browser update): moved, updated and deleted -class ModelAPI_FeatureUpdatedMessage : public Events_MessageGroup { +class ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup { protected: - ModelAPI_FeatureUpdatedMessage(const Events_ID theID, const void* theSender = 0) + ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender = 0) : Events_MessageGroup(theID, theSender) {} public: /// Returns the feature that has been updated - virtual std::set features() const = 0; + virtual std::set features() const = 0; //! Creates a new empty group (to store it in the loop before flush) virtual Events_MessageGroup* newEmpty() = 0; @@ -46,9 +46,9 @@ public: }; /// Message that feature was deleted (used for Object Browser update) -class ModelAPI_FeatureDeletedMessage : public Events_MessageGroup { +class ModelAPI_ObjectDeletedMessage : public Events_MessageGroup { protected: - ModelAPI_FeatureDeletedMessage(const Events_ID theID, const void* theSender = 0) + ModelAPI_ObjectDeletedMessage(const Events_ID theID, const void* theSender = 0) : Events_MessageGroup(theID, theSender) {} public: @@ -69,7 +69,7 @@ public: class MODELAPI_EXPORT ModelAPI_EventCreator { public: /// creates created, updated or moved messages and sends to the loop - virtual void sendUpdated(const FeaturePtr& theFeature, const Events_ID& theEvent, + virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent, const bool isGroupped = true) const = 0; /// creates deleted message and sends to the loop virtual void sendDeleted( diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index 6d7955f4b..0bdb7817e 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -5,81 +5,53 @@ #ifndef ModelAPI_Feature_HeaderFile #define ModelAPI_Feature_HeaderFile -#include "ModelAPI.h" +#include "ModelAPI_Object.h" #include "ModelAPI_PluginManager.h" #include +#include #include class ModelAPI_Data; class ModelAPI_Document; +class ModelAPI_Result; /**\class ModelAPI_Feature * \ingroup DataModel - * \brief Functionality of the model object: to update result, - * to initialize attributes, etc. + * \brief Feature function that represents the particular functionality + * of this operation. Produces results by the arguments. */ -class ModelAPI_Feature +class ModelAPI_Feature : public ModelAPI_Object { - boost::shared_ptr myData; ///< manager of the data model of a feature - boost::shared_ptr myDoc; ///< document this feature belongs to - + ///< list of current results of this feature + std::list > myResults; public: - /// Returns the kind of a feature (like "Point") - MODELAPI_EXPORT virtual const std::string& getKind() = 0; - - /// Returns to which group in the document must be added feature - MODELAPI_EXPORT virtual const std::string& getGroup() = 0; + /// Returns the unique kind of a feature (like "Point") + virtual const std::string& getKind() = 0; /// Request for initialization of data model of the feature: adding all attributes - MODELAPI_EXPORT virtual void initAttributes() = 0; + virtual void initAttributes() = 0; - /// Computes or recomputes the result - MODELAPI_EXPORT virtual void execute() = 0; + /// Computes or recomputes the results + virtual void execute() = 0; - /// Returns true if this feature must be displayed in the history (top level of Part tree) - MODELAPI_EXPORT virtual bool isInHistory() {return true;} + // returns the current results of the feature + std::list >& results() {return myResults;} /// Returns true if this feature must not be created: this is just an action - /// that is not stored in the features history (like delete part). - MODELAPI_EXPORT virtual bool isAction() {return false;} - - /// Returns the data manager of this feature - MODELAPI_EXPORT virtual boost::shared_ptr data() {return myData;} + /// that is not stored in the features history and data model (like "delete part"). + virtual bool isAction() {return false;} /// Must return document where the new feature must be added to /// By default it is current document - MODELAPI_EXPORT virtual boost::shared_ptr documentToAdd() + virtual boost::shared_ptr documentToAdd() {return ModelAPI_PluginManager::get()->currentDocument();} - /// Returns document this feature belongs to - MODELAPI_EXPORT virtual boost::shared_ptr document() - {return myDoc;} - - /// Returns true if feature refers to the same model data instance - MODELAPI_EXPORT virtual bool isSame(const boost::shared_ptr& theFeature) - {return theFeature.get() == this;} - /// To virtually destroy the fields of successors virtual ~ModelAPI_Feature() {} - -protected: - /// Use plugin manager for features creation: this method is - /// defined here only for SWIG-wrapping - ModelAPI_Feature() - {} - - /// Sets the data manager of an object (document does) - MODELAPI_EXPORT virtual void setData(boost::shared_ptr theData) - {myData = theData;} - /// Sets the data manager of an object (document does) - MODELAPI_EXPORT void setDoc(boost::shared_ptr theDoc) {myDoc = theDoc;} - - friend class Model_Document; }; //! Pointer on feature object typedef boost::shared_ptr FeaturePtr; - #endif diff --git a/src/ModelAPI/ModelAPI_Object.h b/src/ModelAPI/ModelAPI_Object.h index 581f04588..04a281b8f 100644 --- a/src/ModelAPI/ModelAPI_Object.h +++ b/src/ModelAPI/ModelAPI_Object.h @@ -5,33 +5,51 @@ #ifndef ModelAPI_Object_HeaderFile #define ModelAPI_Object_HeaderFile -#include "ModelAPI_Feature.h" +#include "ModelAPI.h" #include +class ModelAPI_Data; +class ModelAPI_Document; + /**\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. + * \brief Represents any object in the data model and in the object browser. + * + * It may be feature or result of the feature. User just may set name for it + * or change this name later. Generic class for Feature, Body, Parameter and other + * objects related to the features and their results. Contains attributes of this + * object in the "Data". */ -class ModelAPI_Object : public ModelAPI_Feature +class ModelAPI_Object { + boost::shared_ptr myData; ///< manager of the data model of a feature + boost::shared_ptr myDoc; ///< document this feature belongs to public: + /// By default object is displayed in the object browser. + virtual bool isInHistory() {return true;} - /// It is never located in history - MODELAPI_EXPORT virtual bool isInHistory() {return false;} + /// Returns the data manager of this object: attributes + virtual boost::shared_ptr data() {return myData;} - /// Reference to the feature-operation that produces this object - MODELAPI_EXPORT virtual FeaturePtr featureRef() = 0; + /// Returns true if feature refers to the same data model instance + virtual bool isSame(const boost::shared_ptr& theObject) + {return theObject.get() == this;} - /// Returns the name of this object (by default equal to the name of feature) - MODELAPI_EXPORT virtual std::string getName() = 0; + /// Returns document this feature belongs to + virtual boost::shared_ptr document() + {return myDoc;} - /// Defines the name of the object - MODELAPI_EXPORT virtual void setName(std::string theName) = 0; -}; +protected: + /// Sets the data manager of an object (document does) + virtual void setData(boost::shared_ptr theData) + {myData = theData;} + /// Sets the data manager of an object (document does) + virtual void setDoc(boost::shared_ptr theDoc) {myDoc = theDoc;} + + friend class Model_Document; +}; typedef boost::shared_ptr ObjectPtr; diff --git a/src/ModelAPI/ModelAPI_Result.h b/src/ModelAPI/ModelAPI_Result.h new file mode 100644 index 000000000..b84cd0b20 --- /dev/null +++ b/src/ModelAPI/ModelAPI_Result.h @@ -0,0 +1,31 @@ +// File: ModelAPI_Result.hxx +// Created: 07 Jul 2014 +// Author: Mikhail PONIKAROV + +#ifndef ModelAPI_Result_HeaderFile +#define ModelAPI_Result_HeaderFile + +#include "ModelAPI_Object.h" + +class ModelAPI_Feature; + +/**\class ModelAPI_Result + * \ingroup DataModel + * \brief The result of a feature. + * + * A generic class that . + */ +class ModelAPI_Result : public ModelAPI_Object +{ +public: + /// Returns the source feature of this result + //virtual boost::shared_ptr owner() = 0; + + /// Returns the group identifier of this result + virtual std::string group() = 0; +}; + +//! Pointer on feature object +typedef boost::shared_ptr ResultPtr; + +#endif diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h new file mode 100644 index 000000000..f801ad45c --- /dev/null +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -0,0 +1,44 @@ +// File: ModelAPI_ResultBody.hxx +// Created: 07 Jul 2014 +// Author: Mikhail PONIKAROV + +#ifndef ModelAPI_ResultBody_HeaderFile +#define ModelAPI_ResultBody_HeaderFile + +#include "ModelAPI_Result.h" +#include + +/**\class ModelAPI_ResultBody + * \ingroup DataModel + * \brief The body (shape) result of a feature. + * + * Provides a shape that may be displayed in the viewer. + * May provide really huge results, so, working with this kind + * of result must be optimized. + */ +class ModelAPI_ResultBody : public ModelAPI_Result +{ +public: + /// Returns the group identifier of this result + virtual std::string group() + {static std::string MY_GROUP = "Bodies"; return MY_GROUP;} + + /// Stores the shape (called by the execution method). + virtual void store(const boost::shared_ptr& theShape) = 0; + /// Returns the shape-result produced by this feature + virtual boost::shared_ptr shape() = 0; + + /// To virtually destroy the fields of successors + virtual ~ModelAPI_ResultBody() {} + +protected: + /// Use plugin manager for features creation: this method is + /// defined here only for SWIG-wrapping + ModelAPI_ResultBody() + {} +}; + +//! Pointer on feature object +typedef boost::shared_ptr ResultBodyPtr; + +#endif diff --git a/src/ModelAPI/ModelAPI_ResultConstruction.h b/src/ModelAPI/ModelAPI_ResultConstruction.h new file mode 100644 index 000000000..ede2f73a4 --- /dev/null +++ b/src/ModelAPI/ModelAPI_ResultConstruction.h @@ -0,0 +1,31 @@ +// File: ModelAPI_ResultConstruction.h +// Created: 07 Jul 2014 +// Author: Mikhail PONIKAROV + +#ifndef ModelAPI_ResultConstruction_HeaderFile +#define ModelAPI_ResultConstruction_HeaderFile + +#include "ModelAPI_Result.h" +#include + +/**\class ModelAPI_ResultConstruction + * \ingroup DataModel + * \brief The construction element result of a feature. + * + * Provides a shape that may be displayed in the viewer. + * Intermediate, light result that in many cases produces a result on the fly. + */ +class ModelAPI_ResultConstruction : public ModelAPI_Result +{ +public: + /// Returns the shape-result produced by this feature + virtual boost::shared_ptr& shape() = 0; + + /// Sets the result + virtual void setShape(boost::shared_ptr theShape) = 0; +}; + +//! Pointer on feature object +typedef boost::shared_ptr ResultConstructionPtr; + +#endif diff --git a/src/ModelAPI/ModelAPI_ResultPart.h b/src/ModelAPI/ModelAPI_ResultPart.h new file mode 100644 index 000000000..575328b6a --- /dev/null +++ b/src/ModelAPI/ModelAPI_ResultPart.h @@ -0,0 +1,27 @@ +// File: ModelAPI_ResultPart.h +// Created: 07 Jul 2014 +// Author: Mikhail PONIKAROV + +#ifndef ModelAPI_ResultPart_HeaderFile +#define ModelAPI_ResultPart_HeaderFile + +#include "ModelAPI_Result.h" + +/**\class ModelAPI_ResultPart + * \ingroup DataModel + * \brief The Part document, result of a creation of new part feature. + * + * This result leaves without feature: no parametricity for this element, + * only add/remove, undo/redo. + */ +class ModelAPI_ResultPart : public ModelAPI_Result +{ +public: + /// Returns the part-document of this result + virtual boost::shared_ptr partDoc() = 0; +}; + +//! Pointer on feature object +typedef boost::shared_ptr ResultPart; + +#endif diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index c1ed4b0d0..ba757565d 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -93,12 +93,12 @@ void ModuleBase_Operation::afterCommitOperation() void ModuleBase_Operation::flushUpdated() { - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); } void ModuleBase_Operation::flushCreated() { - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_CREATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); } FeaturePtr ModuleBase_Operation::createFeature(const bool theFlushMessage) diff --git a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp index a34a73d6f..58a7f371d 100644 --- a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp @@ -47,7 +47,7 @@ bool ModuleBase_WidgetBoolValue::storeValue(FeaturePtr theFeature) const if (aBool->value() != myCheckBox->isChecked()) { aBool->setValue(myCheckBox->isChecked()); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); } return true; } diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index ccbb0ad7e..19828f008 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -94,7 +94,7 @@ bool ModuleBase_WidgetDoubleValue::storeValue(FeaturePtr theFeature) const AttributeDoublePtr aReal = aData->real(attributeID()); if (aReal->value() != mySpinBox->value()) { aReal->setValue(mySpinBox->value()); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); } return true; } diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index d1e2ceea6..7e43f4f55 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -88,7 +88,7 @@ bool ModuleBase_WidgetFeature::storeValue(FeaturePtr theFeature) const ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this; aRef->setFeature(myFeature); theFeature->execute(); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); return true; } diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp index 0099c993f..6fd65bf96 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp @@ -85,7 +85,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::storeValue(FeaturePtr theFeature) cons aRef->setAttr(myAttribute); theFeature->execute(); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); return true; } diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp index baa7285b0..8407084ed 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp @@ -110,7 +110,7 @@ bool ModuleBase_WidgetPoint2D::storeValue(FeaturePtr theFeature) const ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this; bool isBlocked = that->blockSignals(true); aPoint->setValue(myXSpin->value(), myYSpin->value()); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); that->blockSignals(isBlocked); return true; diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index df7b431fb..08e9eb020 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -106,7 +106,7 @@ bool ModuleBase_WidgetSelector::storeValue(FeaturePtr theFeature) const FeaturePtr aFeature = aRef->value(); if (!(aFeature && aFeature->isSame(mySelectedFeature))) { aRef->setValue(mySelectedFeature); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); } return true; } diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index f9229d383..1b357fadb 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -24,9 +24,9 @@ PartSet_Listener::PartSet_Listener(PartSet_Module* theModule) : myModule(theModule) { Events_Loop* aLoop = Events_Loop::loop(); - aLoop->registerListener(this, aLoop->eventByName(EVENT_FEATURE_UPDATED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED)); + aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_UPDATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); } PartSet_Listener::~PartSet_Listener() @@ -37,25 +37,25 @@ PartSet_Listener::~PartSet_Listener() void PartSet_Listener::processEvent(const Events_Message* theMessage) { QString aType = QString(theMessage->eventID().eventText()); - if (aType == EVENT_FEATURE_UPDATED || - aType == EVENT_FEATURE_CREATED) + if (aType == EVENT_OBJECT_UPDATED || + aType == EVENT_OBJECT_CREATED) { - const ModelAPI_FeatureUpdatedMessage* aUpdMsg = - dynamic_cast(theMessage); + const ModelAPI_ObjectUpdatedMessage* aUpdMsg = + dynamic_cast(theMessage); std::set aFeatures = aUpdMsg->features(); std::set::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); for (; anIt != aLast; anIt++) { FeaturePtr aFeature = *anIt; if (myModule->workshop()->displayer()->isVisible(aFeature) || - aType == EVENT_FEATURE_CREATED) { + aType == EVENT_OBJECT_CREATED) { myModule->visualizePreview(aFeature, true, false); - //if (aType == EVENT_FEATURE_CREATED) + //if (aType == EVENT_OBJECT_CREATED) myModule->activateFeature(aFeature, true); } } myModule->workshop()->displayer()->updateViewer(); } - if (aType == EVENT_FEATURE_DELETED) + if (aType == EVENT_OBJECT_DELETED) { const ModelAPI_FeatureDeletedMessage* aDelMsg = dynamic_cast(theMessage); diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp index c6ad6130e..468eb635c 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.cpp +++ b/src/PartSet/PartSet_OperationFeatureEdit.cpp @@ -195,7 +195,7 @@ FeaturePtr PartSet_OperationFeatureEdit::createFeature(const bool /*theFlushMess void PartSet_OperationFeatureEdit::sendFeatures() { - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); FeaturePtr aFeature = feature(); ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent); diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp index ac2cd6982..960cab6b4 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp @@ -181,7 +181,7 @@ void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, const boo void PartSet_OperationFeatureEditMulti::sendFeatures() { - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); std::list aFeatures; std::list::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end(); diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index e166608d1..4b8e0e995 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -5,13 +5,12 @@ #include "SketchPlugin_Arc.h" #include "SketchPlugin_Sketch.h" #include +#include #include #include - #include #include - #include #include #include @@ -31,10 +30,6 @@ void SketchPlugin_Arc::initAttributes() } void SketchPlugin_Arc::execute() -{ -} - -const boost::shared_ptr& SketchPlugin_Arc::preview() { SketchPlugin_Sketch* aSketch = sketch(); if (aSketch) { @@ -79,16 +74,12 @@ const boost::shared_ptr& SketchPlugin_Arc::preview() aShapes.push_back(aCircleShape); } boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); - setPreview(aCompound); + // store the result + boost::shared_ptr aConstr = document()->createConstruction(); + aConstr->setShape(aCompound); + results().push_back(aConstr); } } - return getPreview(); -} - -boost::shared_ptr SketchPlugin_Arc::getAISObject( - boost::shared_ptr thePrevious) -{ - return prepareAISShape(thePrevious); } void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY) diff --git a/src/SketchPlugin/SketchPlugin_Arc.h b/src/SketchPlugin/SketchPlugin_Arc.h index 946607795..5a4c6ed78 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.h +++ b/src/SketchPlugin/SketchPlugin_Arc.h @@ -30,19 +30,12 @@ public: SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = SKETCH_ARC_KIND; return MY_KIND;} - /// Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} - - /// Creates a new part document if needed + /// Creates an arc-shape SKETCHPLUGIN_EXPORT virtual void execute(); /// Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); - /// Returns the sketch preview - SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); - /// Returns the AIS preview SKETCHPLUGIN_EXPORT virtual boost::shared_ptr getAISObject( boost::shared_ptr thePrevious); diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp index 593716ed9..d962d4cfa 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.cpp +++ b/src/SketchPlugin/SketchPlugin_Circle.cpp @@ -5,16 +5,14 @@ #include "SketchPlugin_Circle.h" #include "SketchPlugin_Sketch.h" #include +#include #include - #include #include - #include #include #include - #include SketchPlugin_Circle::SketchPlugin_Circle() @@ -28,11 +26,7 @@ void SketchPlugin_Circle::initAttributes() data()->addAttribute(CIRCLE_ATTR_RADIUS, ModelAPI_AttributeDouble::type()); } -void SketchPlugin_Circle::execute() -{ -} - -const boost::shared_ptr& SketchPlugin_Circle::preview() +void SketchPlugin_Circle::execute(boost::shared_ptr& theResult) { SketchPlugin_Sketch* aSketch = sketch(); if (aSketch) { @@ -64,15 +58,9 @@ const boost::shared_ptr& SketchPlugin_Circle::preview() } } boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); - setPreview(aCompound); + // store the result + boost::dynamic_pointer_cast(theResult)->setShape(aCompound); } - return getPreview(); -} - -boost::shared_ptr SketchPlugin_Circle::getAISObject( - boost::shared_ptr thePrevious) -{ - return prepareAISShape(thePrevious); } void SketchPlugin_Circle::move(double theDeltaX, double theDeltaY) diff --git a/src/SketchPlugin/SketchPlugin_Circle.h b/src/SketchPlugin/SketchPlugin_Circle.h index bb47c214d..2f2f01e42 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.h +++ b/src/SketchPlugin/SketchPlugin_Circle.h @@ -28,12 +28,8 @@ public: SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = SKETCH_CIRCLE_KIND; return MY_KIND;} - /// Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} - /// Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr& theResult); /// Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); diff --git a/src/SketchPlugin/SketchPlugin_Constraint.cpp b/src/SketchPlugin/SketchPlugin_Constraint.cpp index 5e8727687..70e4d7be6 100644 --- a/src/SketchPlugin/SketchPlugin_Constraint.cpp +++ b/src/SketchPlugin/SketchPlugin_Constraint.cpp @@ -9,9 +9,3 @@ boost::shared_ptr SketchPlugin_Constraint::getAISObject( { return thePrevious; } - -const boost::shared_ptr& SketchPlugin_Constraint::preview() -{ - return getPreview(); -} - diff --git a/src/SketchPlugin/SketchPlugin_Constraint.h b/src/SketchPlugin/SketchPlugin_Constraint.h index 5db923562..9b6878b33 100644 --- a/src/SketchPlugin/SketchPlugin_Constraint.h +++ b/src/SketchPlugin/SketchPlugin_Constraint.h @@ -52,19 +52,12 @@ const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] = class SketchPlugin_Constraint: public SketchPlugin_Feature { public: - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} - /** \brief Adds sub-feature of the higher level feature (sub-element of the sketch) * \param theFeature sub-feature */ SKETCHPLUGIN_EXPORT virtual const void addSub( const FeaturePtr& theFeature) {} - /// \brief Returns the sketch preview - SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); - /// Returns the AIS preview SKETCHPLUGIN_EXPORT virtual boost::shared_ptr getAISObject( boost::shared_ptr thePrevious); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp index e052d1ace..0fd8b0bff 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp @@ -18,7 +18,7 @@ void SketchPlugin_ConstraintCoincidence::initAttributes() data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type()); } -void SketchPlugin_ConstraintCoincidence::execute() +void SketchPlugin_ConstraintCoincidence::execute(boost::shared_ptr& theResult) { } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h index 9ed0e9653..f227d4cf8 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h @@ -27,12 +27,8 @@ public: SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = SKETCH_CONSTRAINT_COINCIDENCE_KIND; return MY_KIND;} - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} - /// \brief Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr& theResult); /// \brief Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index faa2d7b62..23ecc6435 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -30,7 +30,7 @@ void SketchPlugin_ConstraintDistance::initAttributes() data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type()); } -void SketchPlugin_ConstraintDistance::execute() +void SketchPlugin_ConstraintDistance::execute(boost::shared_ptr& theResult) { boost::shared_ptr aData = data(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h index 4350e3cb4..e633e9fe4 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h @@ -28,12 +28,8 @@ public: SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = SKETCH_CONSTRAINT_DISTANCE_KIND; return MY_KIND;} - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} - /// \brief Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr& theResult); /// \brief Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index 71a35c4f1..0a5a11fcc 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -26,7 +26,7 @@ void SketchPlugin_ConstraintLength::initAttributes() data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type()); } -void SketchPlugin_ConstraintLength::execute() +void SketchPlugin_ConstraintLength::execute(boost::shared_ptr& theResult) { if (data()->attribute(CONSTRAINT_ATTR_ENTITY_A)->isInitialized() && !data()->attribute(CONSTRAINT_ATTR_VALUE)->isInitialized()) { diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.h b/src/SketchPlugin/SketchPlugin_ConstraintLength.h index 3d07ce186..3ad18ea20 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.h @@ -28,12 +28,8 @@ public: SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = SKETCH_CONSTRAINT_LENGTH_KIND; return MY_KIND;} - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} - /// \brief Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr& theResult); /// \brief Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp index e45980582..45713e124 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp @@ -25,17 +25,10 @@ void SketchPlugin_ConstraintParallel::initAttributes() data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type()); } -void SketchPlugin_ConstraintParallel::execute() +void SketchPlugin_ConstraintParallel::execute(boost::shared_ptr& theResult) { } -const boost::shared_ptr& SketchPlugin_ConstraintParallel::preview() -{ - /// \todo Preview for parallel constraint - return getPreview(); -} - - boost::shared_ptr SketchPlugin_ConstraintParallel::getAISObject( boost::shared_ptr thePrevious) { diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h index 7f92e2e56..9fd42ba88 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h @@ -26,12 +26,8 @@ public: SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = SKETCH_CONSTRAINT_PARALLEL_KIND; return MY_KIND;} - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} - /// \brief Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr& theResult); /// \brief Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp index d4d73b003..b6b9de72a 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp @@ -25,16 +25,10 @@ void SketchPlugin_ConstraintPerpendicular::initAttributes() data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type()); } -void SketchPlugin_ConstraintPerpendicular::execute() +void SketchPlugin_ConstraintPerpendicular::execute(boost::shared_ptr& theResult) { } -const boost::shared_ptr& SketchPlugin_ConstraintPerpendicular::preview() -{ - /// \todo Preview for perpendicular constraint - return getPreview(); -} - boost::shared_ptr SketchPlugin_ConstraintPerpendicular::getAISObject( boost::shared_ptr thePrevious) { diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h index 2bb4a7b63..9f6956d91 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h @@ -26,12 +26,8 @@ public: SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = SKETCH_CONSTRAINT_PERPENDICULAR_KIND; return MY_KIND;} - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} - /// \brief Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr& theResult); /// \brief Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp index 65ab125b5..ee05e7c9c 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp @@ -30,7 +30,7 @@ void SketchPlugin_ConstraintRadius::initAttributes() data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type()); } -void SketchPlugin_ConstraintRadius::execute() +void SketchPlugin_ConstraintRadius::execute(boost::shared_ptr& theResult) { if (data()->attribute(CONSTRAINT_ATTR_ENTITY_A)->isInitialized() && !data()->attribute(CONSTRAINT_ATTR_VALUE)->isInitialized()) { diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h index a2e9abad8..c11757dfb 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h @@ -27,12 +27,8 @@ public: SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = SKETCH_CONSTRAINT_RADIUS_KIND; return MY_KIND;} - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} - /// \brief Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr& theResult); /// \brief Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); diff --git a/src/SketchPlugin/SketchPlugin_Feature.cpp b/src/SketchPlugin/SketchPlugin_Feature.cpp index 4404ea1b8..7195bb706 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.cpp +++ b/src/SketchPlugin/SketchPlugin_Feature.cpp @@ -10,16 +10,6 @@ SketchPlugin_Feature::SketchPlugin_Feature() mySketch = 0; } -void SketchPlugin_Feature::setPreview(const boost::shared_ptr& theShape) -{ - myPreview = theShape; -} - -const boost::shared_ptr& SketchPlugin_Feature::getPreview() const -{ - return myPreview; -} - SketchPlugin_Sketch* SketchPlugin_Feature::sketch() { if (!mySketch) { @@ -27,7 +17,7 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch() int aSketches = document()->size("Construction"); for(int a = 0; a < aSketches && !mySketch; a++) { boost::shared_ptr aSketch = boost:: - dynamic_pointer_cast(document()->feature("Construction", a, true)); + dynamic_pointer_cast(document()->object("Construction", a)); if (aSketch) { std::list aList = aSketch->data()->reflist(SKETCH_ATTR_FEATURES)->list(); @@ -47,6 +37,7 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch() boost::shared_ptr SketchPlugin_Feature::prepareAISShape( boost::shared_ptr thePrevious) { + document()->result(); boost::shared_ptr aPreview = preview(); boost::shared_ptr aResult = thePrevious; if (!aResult) diff --git a/src/SketchPlugin/SketchPlugin_Feature.h b/src/SketchPlugin/SketchPlugin_Feature.h index 1cddba03f..3d9cbf9a0 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.h +++ b/src/SketchPlugin/SketchPlugin_Feature.h @@ -9,6 +9,7 @@ #include #include #include +#include class SketchPlugin_Sketch; class GeomAPI_Pnt2d; @@ -22,10 +23,8 @@ class Handle_AIS_InteractiveObject; class SketchPlugin_Feature: public ModelAPI_Feature { public: - /// Returns the sketch preview - /// \param theSketch the owner of this feature - /// \return the built preview - SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview() = 0; + /// Returns the type of the feature result: it is allways construction element + virtual const std::string& getResultType() {return CONSTRUCTIONS_GROUP;} /// Returns the AIS preview SKETCHPLUGIN_EXPORT virtual boost::shared_ptr getAISObject( @@ -49,15 +48,6 @@ public: virtual double distanceToPoint(const boost::shared_ptr& thePoint) = 0; protected: - /// Set the shape to the internal preview field - /// \param theShape a preview shape - void setPreview(const boost::shared_ptr& theShape); ///< the preview shape - /// Return the shape from the internal preview field - /// \return theShape a preview shape - const boost::shared_ptr& getPreview() const; - /// Common method for other features to produce AIS shape - boost::shared_ptr prepareAISShape( - boost::shared_ptr thePrevious); /// Sets the higher-level feature for the sub-feature (sketch for line) void setSketch(SketchPlugin_Sketch* theSketch) {mySketch = theSketch;} /// Returns the sketch of this feature diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp index 3175ac13f..c15a8b62f 100644 --- a/src/SketchPlugin/SketchPlugin_Line.cpp +++ b/src/SketchPlugin/SketchPlugin_Line.cpp @@ -5,6 +5,7 @@ #include "SketchPlugin_Line.h" #include "SketchPlugin_Sketch.h" #include +#include #include #include @@ -29,11 +30,7 @@ void SketchPlugin_Line::initAttributes() data()->addAttribute(LINE_ATTR_END, GeomDataAPI_Point2D::type()); } -void SketchPlugin_Line::execute() -{ -} - -const boost::shared_ptr& SketchPlugin_Line::preview() +void SketchPlugin_Line::execute(boost::shared_ptr& theResult) { SketchPlugin_Sketch* aSketch = sketch(); if (aSketch) { @@ -48,19 +45,12 @@ const boost::shared_ptr& SketchPlugin_Line::preview() boost::shared_ptr anEnd(aSketch->to3D(anEndAttr->x(), anEndAttr->y())); // make linear edge boost::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd); - setPreview(anEdge); + // store the result + boost::dynamic_pointer_cast(theResult)->setShape(anEdge); } } - return getPreview(); } -boost::shared_ptr SketchPlugin_Line::getAISObject( - boost::shared_ptr thePrevious) -{ - return prepareAISShape(thePrevious); -} - - void SketchPlugin_Line::move(double theDeltaX, double theDeltaY) { boost::shared_ptr aData = data(); diff --git a/src/SketchPlugin/SketchPlugin_Line.h b/src/SketchPlugin/SketchPlugin_Line.h index f440bac1d..af454d8c9 100644 --- a/src/SketchPlugin/SketchPlugin_Line.h +++ b/src/SketchPlugin/SketchPlugin_Line.h @@ -29,19 +29,12 @@ public: SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = SKETCH_LINE_KIND; return MY_KIND;} - /// Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} - /// Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr& theResult); /// Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); - /// Returns the sketch preview - SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); - /// Returns the AIS preview SKETCHPLUGIN_EXPORT virtual boost::shared_ptr getAISObject( boost::shared_ptr thePrevious); diff --git a/src/SketchPlugin/SketchPlugin_Point.cpp b/src/SketchPlugin/SketchPlugin_Point.cpp index 984d98919..3a24b7a87 100644 --- a/src/SketchPlugin/SketchPlugin_Point.cpp +++ b/src/SketchPlugin/SketchPlugin_Point.cpp @@ -6,6 +6,7 @@ #include "SketchPlugin_Sketch.h" #include +#include #include @@ -23,11 +24,7 @@ void SketchPlugin_Point::initAttributes() data()->addAttribute(POINT_ATTR_COORD, GeomDataAPI_Point2D::type()); } -void SketchPlugin_Point::execute() -{ -} - -const boost::shared_ptr& SketchPlugin_Point::preview() +void SketchPlugin_Point::execute(boost::shared_ptr& theResult) { SketchPlugin_Sketch* aSketch = sketch(); if (aSketch) { @@ -37,15 +34,8 @@ const boost::shared_ptr& SketchPlugin_Point::preview() boost::shared_ptr aPoint3D(aSketch->to3D(aPoint->x(), aPoint->y())); // make a visible point boost::shared_ptr aPointShape = GeomAlgoAPI_PointBuilder::point(aPoint3D); - setPreview(aPointShape); + boost::dynamic_pointer_cast(theResult)->setShape(aPointShape); } - return getPreview(); -} - -boost::shared_ptr SketchPlugin_Point::getAISObject( - boost::shared_ptr thePrevious) -{ - return prepareAISShape(thePrevious); } void SketchPlugin_Point::move(double theDeltaX, double theDeltaY) diff --git a/src/SketchPlugin/SketchPlugin_Point.h b/src/SketchPlugin/SketchPlugin_Point.h index 31fad0ea4..ea3e125b7 100644 --- a/src/SketchPlugin/SketchPlugin_Point.h +++ b/src/SketchPlugin/SketchPlugin_Point.h @@ -27,19 +27,12 @@ public: SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = SKETCH_POINT_KIND; return MY_KIND;} - /// Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} - /// Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr& theResult); /// Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); - /// Returns the sketch preview - SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); - /// Returns the AIS preview SKETCHPLUGIN_EXPORT virtual boost::shared_ptr getAISObject( boost::shared_ptr thePrevious); diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 7bc0ec600..b451c99b0 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -12,6 +12,7 @@ #include #include #include +#include const int SKETCH_PLANE_COLOR = Colors::COLOR_BROWN; /// the plane edge color @@ -35,8 +36,18 @@ void SketchPlugin_Sketch::initAttributes() data()->addAttribute(SKETCH_ATTR_FEATURES, ModelAPI_AttributeRefList::type()); } -void SketchPlugin_Sketch::execute() +void SketchPlugin_Sketch::execute(boost::shared_ptr& theResult) { + if (!isPlaneSet()) { + std::list > aFaces; + + addPlane(1, 0, 0, aFaces); // YZ plane + addPlane(0, 1, 0, aFaces); // XZ plane + addPlane(0, 0, 1, aFaces); // XY plane + boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces); + boost::dynamic_pointer_cast(theResult)->setShape(aCompound); + return; + } if (!data()->isValid()) return ; boost::shared_ptr aRefList = @@ -62,9 +73,13 @@ void SketchPlugin_Sketch::execute() std::list< boost::shared_ptr > aFeaturesPreview; for (; anIt != aLast; anIt++) { aFeature = boost::dynamic_pointer_cast(*anIt); - boost::shared_ptr aPreview = aFeature->preview(); - if (aPreview) - aFeaturesPreview.push_back(aPreview); + boost::shared_ptr aRes = + boost::dynamic_pointer_cast(document()->result(aFeature)); + if (aRes) { + boost::shared_ptr aShape = aRes->shape(); + if (aShape) + aFeaturesPreview.push_back(aShape); + } } if (aFeaturesPreview.empty()) @@ -76,7 +91,7 @@ void SketchPlugin_Sketch::execute() aLoops.insert(aLoops.end(), aWires.begin(), aWires.end()); boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aLoops); - data()->store(aCompound); + boost::dynamic_pointer_cast(theResult)->setShape(aCompound); } boost::shared_ptr SketchPlugin_Sketch::getAISObject( @@ -89,23 +104,6 @@ boost::shared_ptr SketchPlugin_Sketch::getAISObject( return anAIS; } -const boost::shared_ptr& SketchPlugin_Sketch::preview() -{ - if (isPlaneSet()) { - setPreview(boost::shared_ptr()); - } - else { - std::list > aFaces; - - addPlane(1, 0, 0, aFaces); // YZ plane - addPlane(0, 1, 0, aFaces); // XZ plane - addPlane(0, 0, 1, aFaces); // XY plane - boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces); - setPreview(aCompound); - } - return getPreview(); -} - const void SketchPlugin_Sketch::addSub(const FeaturePtr& theFeature) { boost::dynamic_pointer_cast(theFeature)->setSketch(this); diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index d88267bed..798019b18 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -41,14 +41,11 @@ public: {static std::string MY_GROUP = "Construction"; return MY_GROUP;} /// Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(boost::shared_ptr& theResult); /// Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); - /// Returns the sketch preview - SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); - /// Returns the AIS preview SKETCHPLUGIN_EXPORT virtual boost::shared_ptr getAISObject( boost::shared_ptr thePrevious); diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index 2f7931f9b..29d21da0a 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -1147,7 +1147,7 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints( if (isUpd) { - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); ModelAPI_EventCreator::get()->sendUpdated(aConstrIter->first, anEvent); break; } @@ -1173,7 +1173,7 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints( boost::dynamic_pointer_cast(*anAttrIter); if (aRefAttr && aRefAttr->isFeature() && aRefAttr->feature() == theFeature) { - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); ModelAPI_EventCreator::get()->sendUpdated(aConstrIter->first, anEvent); break; } diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index ff571878b..985688043 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -41,10 +41,10 @@ SketchSolver_ConstraintManager::SketchSolver_ConstraintManager() myGroups.clear(); // Register in event loop - Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED)); - Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); - Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED)); - Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_MOVED)); + Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); + Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_MOVED)); } SketchSolver_ConstraintManager::~SketchSolver_ConstraintManager() @@ -59,16 +59,16 @@ SketchSolver_ConstraintManager::~SketchSolver_ConstraintManager() // ============================================================================ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessage) { - if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_CREATED) || - theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED) || - theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_MOVED)) + if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED) || + theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED) || + theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) { - const ModelAPI_FeatureUpdatedMessage* anUpdateMsg = - dynamic_cast(theMessage); + const ModelAPI_ObjectUpdatedMessage* anUpdateMsg = + dynamic_cast(theMessage); std::set< FeaturePtr > aFeatures = anUpdateMsg->features(); bool isModifiedEvt = - theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_MOVED); + theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED); if (!isModifiedEvt) { std::set< FeaturePtr >::iterator aFeatIter; @@ -102,7 +102,7 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa // Solve the set of constraints resolveConstraints(); } - else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) + else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { const ModelAPI_FeatureDeletedMessage* aDeleteMsg = dynamic_cast(theMessage); @@ -374,6 +374,6 @@ void SketchSolver_ConstraintManager::resolveConstraints() (*aGroupIter)->resolveConstraints(); // Features may be updated => send events - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); } diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index b4cc62c0c..7857bd7a4 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -26,9 +26,9 @@ XGUI_DocumentDataModel::XGUI_DocumentDataModel(QObject* theParent) : QAbstractItemModel(theParent), myActivePart(0) { // Register in event loop - Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED)); - Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); - Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED)); + Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); // Create a top part of data tree model myModel = new XGUI_TopDataModel(this); @@ -47,7 +47,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); // Created object event ******************* - if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_CREATED)) { + if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); std::set aFeatures = aUpdMsg->features(); @@ -87,7 +87,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) } } // Deleted object event *********************** - } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) { + } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { const Model_FeatureDeletedMessage* aUpdMsg = dynamic_cast(theMessage); DocumentPtr aDoc = aUpdMsg->document(); std::set aGroups = aUpdMsg->groups(); @@ -129,7 +129,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) } } // Deleted object event *********************** - } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED)) { + } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) { //const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); //FeaturePtr aFeature = aUpdMsg->feature(); //DocumentPtr aDoc = aFeature->document(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index b5b0b5f6b..d480ef348 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -129,8 +129,8 @@ void XGUI_Workshop::startApplication() aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_LOADED)); // TODO Is it good to use non standard event within workshop? aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_TO_REDISPLAY)); activateModule(); @@ -229,7 +229,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) } // Process creation of Part - if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_CREATED)) { + if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); onFeatureCreatedMsg(aUpdMsg); } @@ -242,7 +242,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) //Update property panel on corresponding message. If there is no current operation (no //property panel), or received message has different feature to the current - do nothing. - if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED)) { + if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) { const Model_FeatureUpdatedMessage* anUpdateMsg = dynamic_cast(theMessage); onFeatureUpdatedMsg(anUpdateMsg);