}
if (!isSalomeMode()) {
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- if (aDoc->isModified() != myMainWindow->isModifiedState())
- myMainWindow->setModifiedState(aDoc->isModified());
+ if (aMgr->isModified() != myMainWindow->isModifiedState())
+ myMainWindow->setModifiedState(aMgr->isModified());
}
}
{
QApplication::restoreOverrideCursor();
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- aDoc->save(theName.toLatin1().constData(), theFileNames);
+ aMgr->save(theName.toLatin1().constData(), theFileNames);
QApplication::restoreOverrideCursor();
}
+bool XGUI_Workshop::isActiveOperationAborted()
+{
+ if(!myOperationMgr->hasOperation())
+ return true;
+ return myOperationMgr->abortOperation();
+}
+
//******************************************************
void XGUI_Workshop::onExit()
{
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- if (aDoc->isModified()) {
+ if (aMgr->isModified()) {
int anAnswer = QMessageBox::question(
myMainWindow, tr("Save current file"), tr("The document is modified, save before exit?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
//******************************************************
void XGUI_Workshop::onOpen()
{
+ if(!isActiveOperationAborted())
+ return;
//save current file before close if modified
- SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- if (aDoc->isModified()) {
+ SessionPtr aSession = ModelAPI_Session::get();
+ if (aSession->isModified()) {
//TODO(sbh): re-launch the app?
int anAnswer = QMessageBox::question(
myMainWindow, tr("Save current file"),
} else if (anAnswer == QMessageBox::Cancel) {
return;
}
- aDoc->close();
+ aSession->moduleDocument()->close();
myCurrentDir = "";
}
return;
}
QApplication::setOverrideCursor(Qt::WaitCursor);
- aDoc->load(myCurrentDir.toLatin1().constData());
+ aSession->load(myCurrentDir.toLatin1().constData());
myObjectBrowser->rebuildDataTree();
displayAllResults();
updateCommandStatus();
//******************************************************
bool XGUI_Workshop::onSave()
{
+ if(!isActiveOperationAborted())
+ return false;
if (myCurrentDir.isEmpty()) {
return onSaveAs();
}
//******************************************************
bool XGUI_Workshop::onSaveAs()
{
+ if(!isActiveOperationAborted())
+ return false;
QFileDialog dialog(mainWindow());
dialog.setWindowTitle(tr("Select directory to save files..."));
dialog.setFileMode(QFileDialog::Directory);
{
objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- if (aDoc->isOperation())
+ if (aMgr->isOperation())
operationMgr()->abortOperation();
- aDoc->undo();
+ aMgr->undo();
updateCommandStatus();
}
{
objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- if (aDoc->isOperation())
+ if (aMgr->isOperation())
operationMgr()->abortOperation();
- aDoc->redo();
+ aMgr->redo();
updateCommandStatus();
}
aCommands.append(aCmd);
}
SessionPtr aMgr = ModelAPI_Session::get();
- if (aMgr->hasRootDocument()) {
+ if (aMgr->hasModuleDocument()) {
QAction* aUndoCmd;
QAction* aRedoCmd;
foreach(QAction* aCmd, aCommands)
// Enable all commands
aCmd->setEnabled(true);
}
- DocumentPtr aDoc = aMgr->rootDocument();
- aUndoCmd->setEnabled(aDoc->canUndo());
- aRedoCmd->setEnabled(aDoc->canRedo());
+ aUndoCmd->setEnabled(aMgr->canUndo());
+ aRedoCmd->setEnabled(aMgr->canRedo());
} else {
foreach(QAction* aCmd, aCommands)
{
if (aPart) {
DocumentPtr aPartDoc = aPart->partDoc();
if (aPartDoc) {
- aMgr->setCurrentDocument(aPartDoc);
+ aMgr->setActiveDocument(aPartDoc);
return;
}
}
}
- aMgr->setCurrentDocument(aMgr->rootDocument());
+ aMgr->setActiveDocument(aMgr->moduleDocument());
}
//******************************************************
void XGUI_Workshop::activateLastPart()
{
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
+ DocumentPtr aDoc = aMgr->moduleDocument();
std::string aGrpName = ModelAPI_ResultPart::group();
ObjectPtr aLastPart = aDoc->object(aGrpName, aDoc->size(aGrpName) - 1);
ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aLastPart);
// ToDo: definbe deleting method
if (aRes == QMessageBox::Yes) {
SessionPtr aMgr = ModelAPI_Session::get();
- aMgr->rootDocument()->startOperation();
+ aMgr->startOperation();
foreach (ObjectPtr aObj, theList)
{
ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
if (aPart) {
DocumentPtr aDoc = aPart->document();
- if (aDoc == aMgr->currentDocument()) {
+ if (aDoc == aMgr->activeDocument()) {
aDoc->close();
}
- //aMgr->rootDocument()->removeFeature(aPart->owner());
+ //aMgr->moduleDocument()->removeFeature(aPart->owner());
} else {
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
if (aFeature)
}
}
myDisplayer->updateViewer();
- aMgr->rootDocument()->finishOperation();
+ aMgr->finishOperation();
}
}
void XGUI_Workshop::displayAllResults()
{
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aRootDoc = aMgr->rootDocument();
+ DocumentPtr aRootDoc = aMgr->moduleDocument();
displayDocumentResults(aRootDoc);
for (int i = 0; i < aRootDoc->size(ModelAPI_ResultPart::group()); i++) {
ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);