//! Set path for the loaded by demand documents
void setLoadPath(std::string thePath);
+ //! Returns the path for the loaded by demand documents
+ const std::string& loadPath() const;
//! Defines that specified document must be loaded by demand
void setLoadByDemand(std::string theID);
//! Returns true if specified document must be loaded by demand
#include <TDF_Reference.hxx>
#include <TDF_ChildIDIterator.hxx>
#include <TDF_LabelMapHasher.hxx>
+#include <OSD_File.hxx>
+#include <OSD_Path.hxx>
#include <climits>
#ifndef WIN32
bool Model_Document::save(const char* theFileName, std::list<std::string>& theResults)
{
// create a directory in the root document if it is not yet exist
+ Handle(Model_Application) anApp = Model_Application::getApplication();
if (this == Model_Session::get()->moduleDocument().get()) {
#ifdef WIN32
CreateDirectory(theFileName, NULL);
TCollection_ExtendedString aPath(DocFileName(theFileName, myID));
PCDM_StoreStatus aStatus;
try {
- aStatus = Model_Application::getApplication()->SaveAs(myDoc, aPath);
+ aStatus = anApp->SaveAs(myDoc, aPath);
} catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
Events_Error::send(
for (; aSubIter != mySubs.end() && isDone; aSubIter++) {
isDone = subDoc(*aSubIter)->save(theFileName, theResults);
}
+ if (isDone) { // also try to copy the not-activated sub-documents
+ // they are not in mySubs but as ResultParts
+ int aPartsNum = size(ModelAPI_ResultPart::group());
+ for(int aPart = 0; aPart < aPartsNum; aPart++) {
+ ResultPartPtr aPartRes = std::dynamic_pointer_cast<ModelAPI_ResultPart>
+ (object(ModelAPI_ResultPart::group(), aPart));
+ if (aPartRes) {
+ std::string aDocName = aPartRes->data()->name();
+ if (!aDocName.empty() && mySubs.find(aDocName) == mySubs.end()) {
+ // just copy file
+ TCollection_AsciiString aSubPath(DocFileName(anApp->loadPath().c_str(), aDocName));
+ OSD_Path aPath(aSubPath);
+ OSD_File aFile(aPath);
+ if (aFile.Exists()) {
+ TCollection_AsciiString aDestinationDir(DocFileName(theFileName, aDocName));
+ OSD_Path aDestination(aDestinationDir);
+ aFile.Copy(aDestination);
+ } else {
+ Events_Error::send(
+ std::string("Can not open file ") + aSubPath.ToCString() + " for saving");
+ }
+ }
+ }
+ }
+ }
}
return isDone;
}
void Model_Session::abortOperation()
{
ROOT_DOC->abortOperation();
+ // here the update mechanism may work after abort, so, supress the warnings about
+ // modifications outside of the transactions
+ bool aWasCheck = myCheckTransactions;
+ myCheckTransactions = false;
static std::shared_ptr<Events_Message> anAbortMsg
(new Events_Message(Events_Loop::eventByName("AbortOperation")));
Events_Loop::loop()->send(anAbortMsg);
+ myCheckTransactions = true;
+ myCheckTransactions = aWasCheck;
}
bool Model_Session::isOperation()