#include <Model_Data.h>
#include <Model_Application.h>
#include <Model_PluginManager.h>
-#include <Model_Iterator.h>
#include <Model_Events.h>
-#include <Event_Loop.h>
+#include <Events_Loop.h>
+#include <Events_Error.h>
#include <TDataStd_Integer.hxx>
#include <TDataStd_Comment.hxx>
#include <TDF_ChildIDIterator.hxx>
+#include <TDataStd_ReferenceArray.hxx>
+#include <TDataStd_HLabelArray1.hxx>
#include <climits>
+#ifdef WIN32
+# define _separator_ '\\'
+#else
+# define _separator_ '/'
+#endif
+
static const int UNDO_LIMIT = 10; // number of possible undo operations
static const int TAG_GENERAL = 1; // general properties tag
-static const int TAG_OBJECTS = 2; // tag of the objects sub-tree (Root for Model_DatasMgr)
-static const int TAG_HISTORY = 3; // tag of the history sub-tree (Root for Model_History)
+static const int TAG_OBJECTS = 2; // tag of the objects sub-tree (features)
+static const int TAG_HISTORY = 3; // tag of the history sub-tree (python dump)
using namespace std;
+/// Returns the file name of this document by the nameof directory and identifuer of a document
+static TCollection_ExtendedString DocFileName(const char* theFileName, const string& theID)
+{
+ TCollection_ExtendedString aPath ((const Standard_CString)theFileName);
+ aPath += _separator_;
+ aPath += theID.c_str();
+ aPath += ".cbf"; // standard binary file extension
+ return aPath;
+}
+
bool Model_Document::load(const char* theFileName)
{
- bool myIsError = Standard_False;
- /*
- TCollection_ExtendedString aPath ((const Standard_CString)theFileName);
- PCDM_ReaderStatus aStatus = (PCDM_ReaderStatus) -1;
- try
- {
- Handle(TDocStd_Document) aDoc = this;
- aStatus = Model_Application::GetApplication()->Open(aPath, aDoc);
- }
- catch (Standard_Failure)
- {}
- myIsError = aStatus != PCDM_RS_OK;
- if (myIsError)
- {
- switch (aStatus)
- {
- case PCDM_RS_UnknownDocument: cout<<"OCAFApp_Appl_RUnknownDocument"<<endl; break;
- case PCDM_RS_AlreadyRetrieved: cout<<"OCAFApp_Appl_RAlreadyRetrieved"<<endl; break;
- case PCDM_RS_AlreadyRetrievedAndModified: cout<<"OCAFApp_Appl_RAlreadyRetrievedAndModified"<<endl; break;
- case PCDM_RS_NoDriver: cout<<"OCAFApp_Appl_RNoDriver"<<endl; break;
- case PCDM_RS_UnknownFileDriver: cout<<"OCAFApp_Appl_RNoDriver"<<endl; break;
- case PCDM_RS_OpenError: cout<<"OCAFApp_Appl_ROpenError"<<endl; break;
- case PCDM_RS_NoVersion: cout<<"OCAFApp_Appl_RNoVersion"<<endl; break;
- case PCDM_RS_NoModel: cout<<"OCAFApp_Appl_RNoModel"<<endl; break;
- case PCDM_RS_NoDocument: cout<<"OCAFApp_Appl_RNoDocument"<<endl; break;
- case PCDM_RS_FormatFailure: cout<<"OCAFApp_Appl_RFormatFailure"<<endl; break;
- case PCDM_RS_TypeNotFoundInSchema: cout<<"OCAFApp_Appl_RTypeNotFound"<<endl; break;
- case PCDM_RS_UnrecognizedFileFormat: cout<<"OCAFApp_Appl_RBadFileFormat"<<endl; break;
- case PCDM_RS_MakeFailure: cout<<"OCAFApp_Appl_RMakeFailure"<<endl; break;
- case PCDM_RS_PermissionDenied: cout<<"OCAFApp_Appl_RPermissionDenied"<<endl; break;
- case PCDM_RS_DriverFailure: cout<<"OCAFApp_Appl_RDriverFailure"<<endl; break;
- default: cout<<"OCAFApp_Appl_RUnknownFail"<<endl; break;
- }
- }
- SetUndoLimit(UNDO_LIMIT);
- */
- return !myIsError;
+ Handle(Model_Application) anApp = Model_Application::getApplication();
+ if (this == Model_PluginManager::get()->rootDocument().get()) {
+ anApp->setLoadPath(theFileName);
+ }
+ TCollection_ExtendedString aPath (DocFileName(theFileName, myID));
+ PCDM_ReaderStatus aStatus = (PCDM_ReaderStatus) -1;
+ try
+ {
+ aStatus = anApp->Open(aPath, myDoc);
+ }
+ catch (Standard_Failure)
+ {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ Events_Error::send(string("Exception in opening of document: ") + aFail->GetMessageString());
+ return false;
+ }
+ bool isError = aStatus != PCDM_RS_OK;
+ if (isError)
+ {
+ switch (aStatus)
+ {
+ case PCDM_RS_UnknownDocument:
+ Events_Error::send(string("Can not open document: PCDM_RS_UnknownDocument")); break;
+ case PCDM_RS_AlreadyRetrieved:
+ Events_Error::send(string("Can not open document: PCDM_RS_AlreadyRetrieved")); break;
+ case PCDM_RS_AlreadyRetrievedAndModified:
+ Events_Error::send(string("Can not open document: PCDM_RS_AlreadyRetrievedAndModified")); break;
+ case PCDM_RS_NoDriver:
+ Events_Error::send(string("Can not open document: PCDM_RS_NoDriver")); break;
+ case PCDM_RS_UnknownFileDriver:
+ Events_Error::send(string("Can not open document: PCDM_RS_UnknownFileDriver")); break;
+ case PCDM_RS_OpenError:
+ Events_Error::send(string("Can not open document: PCDM_RS_OpenError")); break;
+ case PCDM_RS_NoVersion:
+ Events_Error::send(string("Can not open document: PCDM_RS_NoVersion")); break;
+ case PCDM_RS_NoModel:
+ Events_Error::send(string("Can not open document: PCDM_RS_NoModel")); break;
+ case PCDM_RS_NoDocument:
+ Events_Error::send(string("Can not open document: PCDM_RS_NoDocument")); break;
+ case PCDM_RS_FormatFailure:
+ Events_Error::send(string("Can not open document: PCDM_RS_FormatFailure")); break;
+ case PCDM_RS_TypeNotFoundInSchema:
+ Events_Error::send(string("Can not open document: PCDM_RS_TypeNotFoundInSchema")); break;
+ case PCDM_RS_UnrecognizedFileFormat:
+ Events_Error::send(string("Can not open document: PCDM_RS_UnrecognizedFileFormat")); break;
+ case PCDM_RS_MakeFailure:
+ Events_Error::send(string("Can not open document: PCDM_RS_MakeFailure")); break;
+ case PCDM_RS_PermissionDenied:
+ Events_Error::send(string("Can not open document: PCDM_RS_PermissionDenied")); break;
+ case PCDM_RS_DriverFailure:
+ Events_Error::send(string("Can not open document: PCDM_RS_DriverFailure")); break;
+ default:
+ Events_Error::send(string("Can not open document: unknown error")); break;
+ }
+ }
+ if (!isError) {
+ myDoc->SetUndoLimit(UNDO_LIMIT);
+ synchronizeFeatures();
+ }
+ return !isError;
}
bool Model_Document::save(const char* theFileName)
{
- bool myIsError = true;
- /*
- TCollection_ExtendedString aPath ((const Standard_CString)theFileName);
- PCDM_StoreStatus aStatus;
- try {
- Handle(TDocStd_Document) aDoc = this;
- aStatus = Model_Application::GetApplication()->SaveAs (aDoc, aPath);
- }
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- cout<<"OCAFApp_Engine:save Error: "<<aFail->GetMessageString()<<endl;
- return false;
- }
- myIsError = aStatus != PCDM_SS_OK;
- if (myIsError)
- {
- switch (aStatus)
- {
- case PCDM_SS_DriverFailure:
- cout<<"OCAFApp_Appl_SDriverFailure"<<endl;
- break;
- case PCDM_SS_WriteFailure:
- cout<<"OCAFApp_Appl_SWriteFailure"<<endl;
- break;
- case PCDM_SS_Failure:
- default:
- cout<<"OCAFApp_Appl_SUnknownFailure"<<endl;
- break;
- }
- }
- myTransactionsAfterSave = 0;
- Standard::Purge(); // Release free memory
- */
- return !myIsError;
+ // create a directory in the root document if it is not yet exist
+ if (this == Model_PluginManager::get()->rootDocument().get()) {
+#ifdef WIN32
+ CreateDirectory(theFileName, NULL);
+#else
+ mkdir(theFileName, 0x1ff);
+#endif
+ }
+ // filename in the dir is id of document inside of the given directory
+ TCollection_ExtendedString aPath(DocFileName(theFileName, myID));
+ PCDM_StoreStatus aStatus;
+ try {
+ aStatus = Model_Application::getApplication()->SaveAs(myDoc, aPath);
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ Events_Error::send(string("Exception in saving of document: ") + aFail->GetMessageString());
+ return false;
+ }
+ bool isDone = aStatus == PCDM_SS_OK || aStatus == PCDM_SS_No_Obj;
+ if (!isDone)
+ {
+ switch (aStatus)
+ {
+ case PCDM_SS_DriverFailure:
+ Events_Error::send(string("Can not save document: PCDM_SS_DriverFailure"));
+ break;
+ case PCDM_SS_WriteFailure:
+ Events_Error::send(string("Can not save document: PCDM_SS_WriteFailure"));
+ break;
+ case PCDM_SS_Failure:
+ default:
+ Events_Error::send(string("Can not save document: PCDM_SS_Failure"));
+ break;
+ }
+ }
+ myTransactionsAfterSave = 0;
+ if (isDone) { // save also sub-documents if any
+ set<string>::iterator aSubIter = mySubs.begin();
+ for(; aSubIter != mySubs.end() && isDone; aSubIter++)
+ isDone = subDocument(*aSubIter)->save(theFileName);
+ }
+ return isDone;
}
void Model_Document::close()
void Model_Document::startOperation()
{
+ // check is it nested or not
+ if (myDoc->HasOpenCommand()) {
+ myIsNested = true;
+ }
// new command for this
myDoc->NewCommand();
// new command for all subs
// returns false if delta is empty and no transaction was made
myIsEmptyTr[myTransactionsAfterSave] = !myDoc->CommitCommand();
myTransactionsAfterSave++;
+ myIsNested = false;
// finish for all subs
set<string>::iterator aSubIter = mySubs.begin();
for(; aSubIter != mySubs.end(); aSubIter++)
subDocument(*aSubIter)->redo();
}
-shared_ptr<ModelAPI_Feature> Model_Document::addFeature(string theID)
+boost::shared_ptr<ModelAPI_Feature> Model_Document::addFeature(string theID)
{
- shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_PluginManager::get()->createFeature(theID);
+ boost::shared_ptr<ModelAPI_Feature> aFeature =
+ ModelAPI_PluginManager::get()->createFeature(theID);
if (aFeature) {
- dynamic_pointer_cast<Model_Document>(aFeature->documentToAdd())->addFeature(aFeature);
+ boost::dynamic_pointer_cast<Model_Document>(aFeature->documentToAdd())->addFeature(aFeature);
} else {
// TODO: generate error that feature is not created
}
return aFeature;
}
-void Model_Document::addFeature(const std::shared_ptr<ModelAPI_Feature> theFeature)
+void Model_Document::addFeature(const boost::shared_ptr<ModelAPI_Feature> theFeature)
{
const std::string& aGroup = theFeature->getGroup();
TDF_Label aGroupLab = groupLabel(aGroup);
TDF_Label anObjLab = aGroupLab.NewChild();
- std::shared_ptr<Model_Data> aData(new Model_Data);
+ boost::shared_ptr<Model_Data> aData(new Model_Data);
+ aData->setFeature(theFeature);
aData->setLabel(anObjLab);
- shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
- aData->setDocument(aThis);
+ boost::shared_ptr<ModelAPI_Document> aThis =
+ Model_Application::getApplication()->getDocument(myID);
theFeature->setData(aData);
+ theFeature->setDoc(aThis);
setUniqueName(theFeature);
theFeature->initAttributes();
// keep the feature ID to restore document later correctly
// put index of the feature in the group in the tree
TDataStd_Integer::Set(anObjLab, myFeatures[aGroup].size());
myFeatures[aGroup].push_back(theFeature);
+ // store feature in the history of features array
+ if (theFeature->isInHistory()) {
+ Handle(TDataStd_ReferenceArray) aRefs;
+ if (!groupLabel(FEATURES_GROUP).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) {
+ aRefs = TDataStd_ReferenceArray::Set(groupLabel(FEATURES_GROUP), 0, 0);
+ aRefs->SetValue(0, anObjLab);
+ } else { // extend array by one more element
+ Handle(TDataStd_HLabelArray1) aNewArray =
+ new TDataStd_HLabelArray1(aRefs->Lower(), aRefs->Upper() + 1);
+ for(int a = aRefs->Lower(); a <= aRefs->Upper(); a++) {
+ aNewArray->SetValue(a, aRefs->Value(a));
+ }
+ aNewArray->SetValue(aRefs->Upper() + 1, anObjLab);
+ aRefs->SetInternalArray(aNewArray);
+ }
+ }
// event: feature is added
- static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
- ModelAPI_FeatureUpdatedMessage aMsg(aThis, theFeature, anEvent);
- Event_Loop::loop()->send(aMsg);
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED);
+ Model_FeatureUpdatedMessage aMsg(theFeature, anEvent);
+ Events_Loop::loop()->send(aMsg);
}
-shared_ptr<ModelAPI_Feature> Model_Document::feature(TDF_Label& theLabel)
+boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(TDF_Label& theLabel)
{
Handle(TDataStd_Integer) aFeatureIndex;
if (theLabel.FindAttribute(TDataStd_Integer::GetID(), aFeatureIndex)) {
return myFeatures[aGroup][aFeatureIndex->Get()];
}
}
- return std::shared_ptr<ModelAPI_Feature>(); // not found
+ return boost::shared_ptr<ModelAPI_Feature>(); // not found
}
-int Model_Document::featureIndex(shared_ptr<ModelAPI_Feature> theFeature)
+int Model_Document::featureIndex(boost::shared_ptr<ModelAPI_Feature> theFeature)
{
- if (theFeature->data()->document().get() != this) {
- return theFeature->data()->document()->featureIndex(theFeature);
+ if (theFeature->document().get() != this) {
+ return theFeature->document()->featureIndex(theFeature);
}
- shared_ptr<Model_Data> aData = dynamic_pointer_cast<Model_Data>(theFeature->data());
+ boost::shared_ptr<Model_Data> aData =
+ boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
Handle(TDataStd_Integer) aFeatureIndex;
if (aData->label().FindAttribute(TDataStd_Integer::GetID(), aFeatureIndex)) {
return aFeatureIndex->Get();
return -1; // not found
}
-shared_ptr<ModelAPI_Document> Model_Document::subDocument(string theDocID)
+boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(string theDocID)
{
// just store sub-document identifier here to manage it later
if (mySubs.find(theDocID) == mySubs.end())
return Model_Application::getApplication()->getDocument(theDocID);
}
-shared_ptr<ModelAPI_Iterator> Model_Document::featuresIterator(const string theGroup)
+boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(
+ const string& theGroupID, const int theIndex)
{
- shared_ptr<Model_Document> aThis(Model_Application::getApplication()->getDocument(myID));
- // create an empty iterator for not existing group
- // (to avoidance of attributes management outside the transaction)
- if (myGroups.find(theGroup) == myGroups.end())
- return shared_ptr<ModelAPI_Iterator>(new Model_Iterator());
- return shared_ptr<ModelAPI_Iterator>(new Model_Iterator(aThis, groupLabel(theGroup)));
+ if (theGroupID == FEATURES_GROUP) { // history is just a references array
+ Handle(TDataStd_ReferenceArray) aRefs;
+ if (groupLabel(FEATURES_GROUP).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) {
+ if (aRefs->Lower() <= theIndex && aRefs->Upper() >= theIndex) {
+ TDF_Label aFeatureLab = aRefs->Value(theIndex);
+ return feature(aFeatureLab);
+ }
+ }
+ } else { // one of the group
+ map<string, vector<boost::shared_ptr<ModelAPI_Feature> > >::iterator aGroup =
+ myFeatures.find(theGroupID);
+ if (aGroup != myFeatures.end() && (int)(aGroup->second.size()) > theIndex) {
+ return aGroup->second[theIndex];
+ }
+ }
+ // not found
+ return boost::shared_ptr<ModelAPI_Feature>();
}
-shared_ptr<ModelAPI_Feature> Model_Document::feature(const string& theGroupID, const int theIndex)
+int Model_Document::size(const string& theGroupID)
{
- // TODO: optimize this method
- shared_ptr<ModelAPI_Iterator> anIter = featuresIterator(theGroupID);
- for(int a = 0; a != theIndex && anIter->more(); anIter->next()) a++;
- return anIter->more() ? anIter->current() : shared_ptr<ModelAPI_Feature>();
+ if (theGroupID == FEATURES_GROUP) { // history is just a references array
+ Handle(TDataStd_ReferenceArray) aRefs;
+ if (groupLabel(FEATURES_GROUP).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs))
+ return aRefs->Length();
+ } else { // one of the group
+ map<string, vector<boost::shared_ptr<ModelAPI_Feature> > >::iterator aGroup =
+ myFeatures.find(theGroupID);
+ if (aGroup != myFeatures.end())
+ return aGroup->second.size();
+ }
+ // group is not found
+ return 0;
}
const vector<string>& Model_Document::getGroups() const
{
myDoc->SetUndoLimit(UNDO_LIMIT);
myTransactionsAfterSave = 0;
- // to avoid creation of tag outside of the transaction (by iterator, for example)
- /*
- if (!myDoc->Main().FindChild(TAG_OBJECTS).IsAttribute(TDF_TagSource::GetID()))
- TDataStd_Comment::Set(myDoc->Main().FindChild(TAG_OBJECTS).NewChild(), "");
- */
+ myIsNested = false;
+ myDoc->SetNestedTransactionMode();
+ // to have something in the document and avoid empty doc open/save problem
+ TDataStd_Integer::Set(myDoc->Main().Father(), 0);
}
TDF_Label Model_Document::groupLabel(const string theGroup)
myGroupsNames.push_back(theGroup);
// set to the group label the group idntifier to restore on "open"
TDataStd_Comment::Set(myGroups[theGroup], theGroup.c_str());
- myFeatures[theGroup] = vector<shared_ptr<ModelAPI_Feature> >();
+ myFeatures[theGroup] = vector<boost::shared_ptr<ModelAPI_Feature> >();
}
return myGroups[theGroup];
}
-void Model_Document::setUniqueName(
- shared_ptr<ModelAPI_Feature> theFeature)
+void Model_Document::setUniqueName(boost::shared_ptr<ModelAPI_Feature> theFeature)
{
// first count all objects of such kind to start with index = count + 1
- int aNumObjects = 0;
- shared_ptr<ModelAPI_Iterator> anIter = featuresIterator(theFeature->getGroup());
- for(; anIter->more(); anIter->next()) {
- if (anIter->currentKind() == theFeature->getKind())
+ int a, aNumObjects = 0;
+ int aSize = size(theFeature->getGroup());
+ for(a = 0; a < aSize; a++) {
+ if (feature(theFeature->getGroup(), a)->getKind() == theFeature->getKind())
aNumObjects++;
}
// generate candidate name
aNameStream<<theFeature->getKind()<<"_"<<aNumObjects + 1;
string aName = aNameStream.str();
// check this is unique, if not, increase index by 1
- for(anIter = featuresIterator(theFeature->getGroup()); anIter->more();) {
- if (anIter->currentName() == aName) {
+ for(a = 0; a < aSize;) {
+ if (feature(theFeature->getGroup(), a)->data()->getName() == aName) {
aNumObjects++;
stringstream aNameStream;
aNameStream<<theFeature->getKind()<<"_"<<aNumObjects + 1;
// reinitialize iterator to make sure a new name is unique
- anIter = featuresIterator(theFeature->getGroup());
- } else anIter->next();
+ a = 0;
+ } else a++;
}
theFeature->data()->setName(aName);
void Model_Document::synchronizeFeatures()
{
- shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
+ boost::shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
// iterate groups labels
TDF_ChildIDIterator aGroupsIter(myDoc->Main().FindChild(TAG_OBJECTS),
TDataStd_Comment::GetID(), Standard_False);
myGroups.erase(aGroupName);
aGroupNamesIter = myGroupsNames.erase(aGroupNamesIter);
// say that features were deleted from group
- ModelAPI_FeatureDeletedMessage aMsg(aThis, aGroupName);
- Event_Loop::loop()->send(aMsg);
+ Model_FeatureDeletedMessage aMsg(aThis, aGroupName);
+ Events_Loop::loop()->send(aMsg);
}
// create new groups basing on the following data model update
for(; aGroupsIter.More(); aGroupsIter.Next()) {
aGroupsIter.Value())->Get()).ToCString();
myGroupsNames.push_back(aGroupName);
myGroups[aGroupName] = aGroupsIter.Value()->Label();
- myFeatures[aGroupName] = vector<shared_ptr<ModelAPI_Feature> >();
+ myFeatures[aGroupName] = vector<boost::shared_ptr<ModelAPI_Feature> >();
}
// update features group by group
aGroupsIter.Initialize(myDoc->Main().FindChild(TAG_OBJECTS),
string aGroupName = TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(
aGroupsIter.Value())->Get()).ToCString();
// iterate features in internal container
- vector<shared_ptr<ModelAPI_Feature> >& aFeatures = myFeatures[aGroupName];
- vector<shared_ptr<ModelAPI_Feature> >::iterator aFIter = aFeatures.begin();
+ vector<boost::shared_ptr<ModelAPI_Feature> >& aFeatures = myFeatures[aGroupName];
+ vector<boost::shared_ptr<ModelAPI_Feature> >::iterator aFIter = aFeatures.begin();
// and in parallel iterate labels of features
TDF_ChildIDIterator aFLabIter(
aGroupsIter.Value()->Label(), TDataStd_Comment::GetID(), Standard_False);
static const int INFINITE_TAG = INT_MAX; // no label means that it exists somwhere in infinite
int aFeatureTag = INFINITE_TAG;
if (aFIter != aFeatures.end()) { // existing tag for feature
- shared_ptr<Model_Data> aData = dynamic_pointer_cast<Model_Data>((*aFIter)->data());
+ boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>((*aFIter)->data());
aFeatureTag = aData->label().Tag();
}
int aDSTag = INFINITE_TAG;
if (aDSTag > aFeatureTag) { // feature is removed
aFIter = aFeatures.erase(aFIter);
// event: model is updated
- ModelAPI_FeatureDeletedMessage aMsg(aThis, aGroupName);
- Event_Loop::loop()->send(aMsg);
+ Model_FeatureDeletedMessage aMsg(aThis, aGroupName);
+ Events_Loop::loop()->send(aMsg);
} else if (aDSTag < aFeatureTag) { // a new feature is inserted
// create a feature
- shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_PluginManager::get()->createFeature(
+ boost::shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_PluginManager::get()->createFeature(
TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(
aFLabIter.Value())->Get()).ToCString());
- std::shared_ptr<Model_Data> aData(new Model_Data);
+ boost::shared_ptr<Model_Data> aData(new Model_Data);
TDF_Label aLab = aFLabIter.Value()->Label();
aData->setLabel(aLab);
- aData->setDocument(Model_Application::getApplication()->getDocument(myID));
+ aData->setFeature(aFeature);
+ aFeature->setDoc(aThis);
aFeature->setData(aData);
aFeature->initAttributes();
- // event: model is updated
- static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
- ModelAPI_FeatureUpdatedMessage aMsg(aThis, aFeature, anEvent);
- Event_Loop::loop()->send(aMsg);
if (aFIter == aFeatures.end()) {
aFeatures.push_back(aFeature);
aFIter++;
aFeatures.insert(aFIter, aFeature);
}
+ // event: model is updated
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED);
+ Model_FeatureUpdatedMessage aMsg(aFeature, anEvent);
+ Events_Loop::loop()->send(aMsg);
+
// feature for this label is added, so go to the next label
aFLabIter.Next();
} else { // nothing is changed, both iterators are incremented