}
TCollection_ExtendedString aPath(DocFileName(theFileName, myID));
PCDM_ReaderStatus aStatus = (PCDM_ReaderStatus) -1;
+ Handle(TDocStd_Document) aLoaded;
try {
- aStatus = anApp->Open(aPath, myDoc);
+ aStatus = anApp->Open(aPath, aLoaded);
} catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
Events_Error::send(
}
}
if (!isError) {
+ myDoc = aLoaded;
myDoc->SetUndoLimit(UNDO_LIMIT);
// to avoid the problem that feature is created in the current, not this, document
std::shared_ptr<Model_Session> aSession =
aSession->setActiveDocument(Model_Session::get()->moduleDocument(), false);
// this is done in Part result "activate", so no needed here. Causes not-blue active part.
// aSession->setActiveDocument(anApp->getDocument(myID), true);
- }
+ } else { // open failed, but new documnet was created to work with it: inform the model
+ static std::shared_ptr<Events_Message> aMsg(
+ new Events_Message(Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED)));
+ Events_Loop::loop()->send(aMsg);
+ TDF_LabelList anEmpty;
+ myObjs->synchronizeFeatures(anEmpty, true, true);
+ }
return !isError;
}
FeaturePtr aFeature = aSession->createFeature(theID, this);
if (!aFeature)
return aFeature;
+ aFeature->init();
Model_Document* aDocToAdd;
if (!aFeature->documentToAdd().empty()) { // use the customized document to add
if (aFeature->documentToAdd() != kind()) { // the root document by default
}
void Model_Document::setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurrent,
- const bool theVisible)
+ const bool theVisible, const bool theFlushUpdates)
{
// blocks the flush signals to avoid each objects visualization in the viewer
// they should not be shown once after all modifications are performed
// unblock the flush signals and up them after this
aLoop->activateFlushes(isActive);
- aLoop->flush(aCreateEvent);
- aLoop->flush(aRedispEvent);
- aLoop->flush(aDeleteEvent);
+ if (theFlushUpdates) {
+ aLoop->flush(aCreateEvent);
+ aLoop->flush(aRedispEvent);
+ aLoop->flush(aDeleteEvent);
+ }
}
void Model_Document::setCurrentFeatureUp()
FeaturePtr aCurrent = currentFeature(false);
if (aCurrent.get()) { // if not, do nothing because null is the upper
FeaturePtr aPrev = myObjs->nextFeature(aCurrent, true);
- setCurrentFeature(aPrev, false);
+ // do not flush: it is called only on remove, it will be flushed in the end of transaction
+ setCurrentFeature(aPrev, false, false);
}
}
return myObjs->internalFeature(theIndex);
}
-// Feature that is used for selection in the Part document by the external request
+void Model_Document::synchronizeTransactions()
+{
+ Model_Document* aRoot =
+ std::dynamic_pointer_cast<Model_Document>(ModelAPI_Session::get()->moduleDocument()).get();
+ if (aRoot == this)
+ return; // don't need to synchronise root with root
+
+ std::shared_ptr<Model_Session> aSession =
+ std::dynamic_pointer_cast<Model_Session>(Model_Session::get());
+ while(myRedos.size() > aRoot->myRedos.size()) { // remove redos in this
+ aSession->setCheckTransactions(false);
+ redo();
+ aSession->setCheckTransactions(true);
+ }
+ /* this case can not be reproduced in any known case for the current moment, so, just comment
+ while(myRedos.size() < aRoot->myRedos.size()) { // add more redos in this
+ undoInternal(false, true);
+ }*/
+}
+
+/// Feature that is used for selection in the Part document by the external request
class Model_SelectionInPartFeature : public ModelAPI_Feature {
public:
/// Nothing to do in constructor