Salome HOME
Merge branch 'master' into V9_3_BR
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
old mode 100755 (executable)
new mode 100644 (file)
index cb0f7a0..b42e4d0
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "XGUI_Workshop.h"
@@ -41,6 +40,7 @@
 #include "XGUI_PropertyDialog.h"
 #include "XGUI_SalomeConnector.h"
 #include "XGUI_Selection.h"
+#include "XGUI_SelectionActivate.h"
 #include "XGUI_SelectionMgr.h"
 #include "XGUI_Tools.h"
 #include "XGUI_ViewerProxy.h"
@@ -49,6 +49,8 @@
 #include <XGUI_HistoryMenu.h>
 #include <XGUI_QtEvents.h>
 #include <XGUI_DataModel.h>
+#include <XGUI_InspectionPanel.h>
+#include <XGUI_CompressFiles.h>
 
 #ifndef HAVE_SALOME
 #include <AppElements_Button.h>
@@ -70,7 +72,6 @@
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_ResultGroup.h>
 #include <ModelAPI_ResultParameter.h>
 #include <ModuleBase_WidgetValidated.h>
 #include <ModuleBase_ModelWidget.h>
 #include <ModuleBase_ResultPrs.h>
+#include <ModuleBase_ActionIntParameter.h>
 
 #include <Config_Common.h>
 #include <Config_FeatureMessage.h>
 #include <QToolButton>
 #include <QAction>
 #include <QDesktopWidget>
+#include <QProcess>
+#include <QDesktopServices>
 
 #include <iterator>
 
@@ -157,7 +161,6 @@ static Handle(VInspector_CallBack) MyVCallBack;
 #include <dlfcn.h>
 #endif
 
-//#define DEBUG_FACES_PANEL
 //#define DEBUG_WITH_MESSAGE_REPORT
 
 QString XGUI_Workshop::MOVE_TO_END_COMMAND = QObject::tr("Move to the end");
@@ -166,13 +169,24 @@ QString XGUI_Workshop::MOVE_TO_END_COMMAND = QObject::tr("Move to the end");
 //#define DEBUG_FEATURE_NAME
 //#define DEBUG_CLEAN_HISTORY
 
+#ifdef HAVE_SALOME
+static QString MyFilter(QObject::tr("SHAPER files (*.shaper *.opp)"));
+static QString MyFilter2(QObject::tr("SHAPER files (*.shaper)"));
+static QString MyExtension(".shaper");
+#else
+static QString MyFilter(QObject::tr("OpenParts files (*.opp);;All files (*.*)"));
+static QString MyFilter2(QObject::tr("OpenParts files (*.opp)"));
+static QString MyExtension(".opp");
+#endif
+
+
 //******************************************************
 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
     : QObject(),
-      myCurrentDir(QString()),
       myModule(NULL),
       mySalomeConnector(theConnector),
       myPropertyPanel(0),
+      myInspectionPanel(0),
       myFacesPanel(0),
       myObjectBrowser(0),
       myDisplayer(0)
@@ -183,7 +197,8 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   myOperationMgr = new XGUI_OperationMgr(this, 0);
   ModuleBase_IWorkshop* aWorkshop = moduleConnector();
   // Has to be defined first in order to get errors and messages from other components
-  myEventsListener = new XGUI_WorkshopListener(aWorkshop);
+  myEventsListener = new XGUI_WorkshopListener(this);
+  mySelectionActivate = new XGUI_SelectionActivate(aWorkshop);
 
   SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr();
 #ifndef HAVE_SALOME
@@ -294,6 +309,9 @@ XGUI_Workshop::~XGUI_Workshop(void)
 
   delete myDisplayer;
   delete myDataModelXMLReader;
+  delete mySelectionActivate;
+  delete myMenuMgr;
+  clearTemporaryDir();
 }
 
 //******************************************************
@@ -315,6 +333,9 @@ void XGUI_Workshop::startApplication()
 #ifdef _DEBUG
   Config_PropManager::registerProp("Plugins", "create_part_by_start", "Create Part by Start",
     Config_Prop::Boolean, "false");
+
+  Config_PropManager::registerProp("Plugins", "show_hide_faces", "Show Hide Faces (on the right)",
+    Config_Prop::Boolean, "false");
 #endif
   registerValidators();
 
@@ -347,7 +368,7 @@ void XGUI_Workshop::startApplication()
 //******************************************************
 void XGUI_Workshop::activateModule()
 {
-  myModule->activateSelectionFilters();
+  selectionActivate()->updateSelectionFilters();
 
   connect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)),
     myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr)));
@@ -366,10 +387,8 @@ void XGUI_Workshop::activateModule()
 //******************************************************
 void XGUI_Workshop::deactivateModule()
 {
-  myModule->deactivateSelectionFilters();
-
   // remove internal displayer filter
-  displayer()->deactivateSelectionFilters();
+  displayer()->deactivateSelectionFilters(false);
 
   disconnect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)),
     myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr)));
@@ -379,17 +398,10 @@ void XGUI_Workshop::deactivateModule()
   XGUI_Displayer* aDisplayer = displayer();
   QObjectPtrList aDisplayed = aDisplayer->displayedObjects();
   aDisplayer->deactivateObjects(aDisplayed, true);
-  Handle(AIS_InteractiveContext) aContext = viewer()->AISContext();
-  Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(aDisplayer->getTrihedron());
-  /// deactivate trihedron in selection modes
-  TColStd_ListOfInteger aTColModes;
-  aContext->ActivatedModes(aTrihedron, aTColModes);
-  TColStd_ListIteratorOfListOfInteger itr( aTColModes );
-  for (; itr.More(); itr.Next() ) {
-    Standard_Integer aMode = itr.Value();
-    aContext->Deactivate(aTrihedron, aMode);
-  }
+  selectionActivate()->deactivateTrihedronInSelectionModes();
+
 #ifdef BEFORE_TRIHEDRON_PATCH
+  //Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(aDisplayer->getTrihedron());
   /// Trihedron problem: objects stayed in the viewer, should be removed manually
   /// otherwise in SALOME happens crash by HideAll in the viewer
   aContext->Remove(aTrihedron->Position(), true);
@@ -414,7 +426,7 @@ void XGUI_Workshop::initMenu()
                                                         QKeySequence::Undo, false,
                                                         "MEN_DESK_EDIT");
   QString aToolBarTitle = tr( "INF_DESK_TOOLBAR_STANDARD" );
-  salomeConnector()->addActionInToolbar( aAction,aToolBarTitle  );
+  salomeConnector()->addActionInToolbar( aAction,aToolBarTitle );
 
   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onUndo()));
   addHistoryMenu(aAction, SIGNAL(updateUndoHistory(const QList<ActionInfo>&)), SLOT(onUndo(int)));
@@ -429,6 +441,18 @@ void XGUI_Workshop::initMenu()
 
   salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT");
 
+  //aAction = salomeConnector()->addDesktopCommand("AUTOCOMPUTE_CMD", tr("Auto rebuild"),
+  //                                            tr("Blocks immediate apply of modifications"),
+  //                                            QIcon(":pictures/autoapply.png"), QKeySequence(),
+  //                                            false, "MEN_DESK_EDIT");
+  //salomeConnector()->addActionInToolbar( aAction, aToolBarTitle );
+
+  //connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onAutoApply()));
+
+  salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT");
+
+
+  // Add commands to a file menu
   aAction = salomeConnector()->addDesktopCommand("SAVEAS_CMD", tr("Export native..."),
                                              tr("Export the current document into a native file"),
                                               QIcon(), QKeySequence(),
@@ -479,6 +503,13 @@ void XGUI_Workshop::initMenu()
                                 QIcon(":pictures/open.png"), QKeySequence::Open);
   aCommand->connectTo(this, SLOT(onOpen()));
 
+
+  aCommand = aGroup->addFeature("AUTOCOMPUTE_CMD", tr("Auto rebuild"),
+                                tr("Blocks immediate apply of modifications"),
+                                QIcon(":pictures/autoapply_start.png"), QKeySequence());
+  aCommand->setChecked(ModelAPI_Session::get()->isAutoUpdateBlocked());
+  aCommand->connectTo(this, SLOT(onAutoApply()));
+
   aCommand = aGroup->addFeature("PREF_CMD", tr("Preferences"), tr("Edit preferences"),
                                 QIcon(":pictures/preferences.png"), QKeySequence::Preferences);
   aCommand->connectTo(this, SLOT(onPreferences()));
@@ -531,6 +562,21 @@ void XGUI_Workshop::onAcceptActionClicked()
   }
 }
 
+//******************************************************
+void XGUI_Workshop::onAcceptPlusActionClicked()
+{
+  QAction* anAction = dynamic_cast<QAction*>(sender());
+  XGUI_OperationMgr* anOperationMgr = operationMgr();
+  if (anOperationMgr) {
+    ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                    (anOperationMgr->currentOperation());
+    if (aFOperation) {
+      if (myOperationMgr->commitOperation())
+        module()->launchOperation(aFOperation->id(), false);
+    }
+  }
+}
+
 //******************************************************
 void XGUI_Workshop::onPreviewActionClicked()
 {
@@ -546,11 +592,53 @@ void XGUI_Workshop::onPreviewActionClicked()
   Events_Loop::loop()->send(aMsg);
 }
 
+
+//******************************************************
+void XGUI_Workshop::onHelpActionClicked()
+{
+  XGUI_OperationMgr* anOperationMgr = operationMgr();
+  if (anOperationMgr) {
+    ModuleBase_Operation* aOperation = anOperationMgr->currentOperation();
+    if (aOperation) {
+      QString aHelpPage = aOperation->helpFileName();
+      if (!aHelpPage.isEmpty()) {
+        QString aDocDir;
+        const QChar aSep = QDir::separator();
+//        QString platform;
+//        SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr();
+//#ifdef WIN32
+//        platform = "winapplication";
+//#else
+//        platform = "application";
+//#endif
+//        QString aBrowserName = aResMgr->stringValue("ExternalBrowser", platform);
+
+#ifdef HAVE_SALOME
+        QString aDir(getenv("SHAPER_ROOT_DIR"));
+        if (!aDir.isEmpty()) {
+          aDocDir = aDir + aSep + "share" + aSep + "doc" + aSep +
+            "salome" + aSep + "gui" + aSep + "SHAPER";
+        }
+#else
+        QString aDir(getenv("OPENPARTS_ROOT_DIR"));
+        aDocDir = aDir + aSep + "doc" + aSep + "gui";
+#endif
+        QString aFileName = aDocDir + aSep + aHelpPage;
+        if (QFile::exists(aFileName)) {
+          QUrl aUrl = QUrl::fromLocalFile(aFileName);
+          QDesktopServices::openUrl(aUrl);
+        }
+      }
+    }
+  }
+}
+
+
 //******************************************************
 void XGUI_Workshop::deactivateActiveObject(const ObjectPtr& theObject, const bool theUpdateViewer)
 {
   if (!myModule->canActivateSelection(theObject)) {
-    if (myDisplayer->isActive(theObject)) {
+    if (selectionActivate()->isActive(theObject)) {
       QObjectPtrList anObjects;
       anObjects.append(theObject);
       myDisplayer->deactivateObjects(anObjects, theUpdateViewer);
@@ -599,13 +687,15 @@ void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation)
   FeaturePtr aFeature = aFOperation->feature();
   std::string aFeatureKind = aFeature->getKind();
   foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
-    if (!aWidget->attributeID().empty() && !aFeature->attribute(aWidget->attributeID()).get()) {
-      std::string anErrorMsg = "The feature '%1' has no attribute '%2' used by widget '%3'.";
-      Events_InfoMessage("XGUI_Workshop", anErrorMsg)
-        .arg(aFeatureKind).arg(aWidget->attributeID())
-        .arg(aWidget->metaObject()->className()).send();
-      myPropertyPanel->cleanContent();
-      return;
+    if (aWidget->usesAttribute()) {
+      if (!aWidget->attributeID().empty() && !aFeature->attribute(aWidget->attributeID()).get()) {
+        std::string anErrorMsg = "The feature '%1' has no attribute '%2' used by widget '%3'.";
+        Events_InfoMessage("XGUI_Workshop", anErrorMsg)
+          .arg(aFeatureKind).arg(aWidget->attributeID())
+          .arg(aWidget->metaObject()->className()).send();
+        myPropertyPanel->cleanContent();
+        return;
+      }
     }
   }
   // for performance purpose, flush should be done after all controls are filled
@@ -630,9 +720,10 @@ void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation)
     aFeatureInfo = aCommand->featureMessage();
 #endif
   bool anIsAutoPreview = true;
-  if (aFeatureInfo.get())
+  if (aFeatureInfo.get()) {
     anIsAutoPreview = aFeatureInfo->isAutoPreview();
-  else {
+    theOperation->setHelpFileName(aFeatureInfo->helpFileName().c_str());
+  } else {
     std::string aXmlCfg, aDescription;
     module()->getXMLRepresentation(aFeatureKind, aXmlCfg, aDescription);
     ModuleBase_WidgetFactory aFactory(aXmlCfg, moduleConnector());
@@ -704,7 +795,6 @@ void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation)
   myModule->operationResumed(theOperation);
 }
 
-
 //******************************************************
 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
 {
@@ -729,14 +819,14 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
   QObjectPtrList anObjects;
   FeaturePtr aFeature = aFOperation->feature();
   if (aFeature.get()) { // feature may be not created (plugin load fail)
-    if (myDisplayer->isVisible(aFeature) && !myDisplayer->isActive(aFeature))
+    if (myDisplayer->isVisible(aFeature) && !selectionActivate()->isActive(aFeature))
       anObjects.append(aFeature);
     std::list<ResultPtr> aResults;
     ModelAPI_Tools::allResults(aFeature, aResults);
     std::list<ResultPtr>::const_iterator aIt;
     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
       ResultPtr anObject = *aIt;
-      if (myDisplayer->isVisible(anObject) && !myDisplayer->isActive(anObject)) {
+      if (myDisplayer->isVisible(anObject) && !selectionActivate()->isActive(anObject)) {
         anObjects.append(anObject);
       }
     }
@@ -836,25 +926,26 @@ void XGUI_Workshop::onOpen()
     } else if (anAnswer == QMessageBox::Cancel) {
       return;
     }
-    myCurrentDir = "";
+    myCurrentFile = QString();
   }
 
   //show file dialog, check if readable and open
-  QString aDirectory = QFileDialog::getExistingDirectory(desktop(), tr("Select directory"));
-  openDirectory(aDirectory);
+  QString aFile = QFileDialog::getOpenFileName(desktop(), tr("Open file"), QString(), MyFilter);
+  if (!aFile.isNull())
+    openFile(aFile);
 }
 
 //******************************************************
-void XGUI_Workshop::openDirectory(const QString& theDirectory)
+void XGUI_Workshop::openFile(const QString& theDirectory)
 {
-  myCurrentDir = theDirectory;
-  if (myCurrentDir.isEmpty())
+  myCurrentFile = theDirectory;
+  if (myCurrentFile.isEmpty())
     return;
 
-  QFileInfo aFileInfo(myCurrentDir);
+  QFileInfo aFileInfo(myCurrentFile);
   if (!aFileInfo.exists() || !aFileInfo.isReadable()) {
     QMessageBox::critical(desktop(), tr("Warning"), tr("Unable to open the file."));
-    myCurrentDir = "";
+    myCurrentFile = QString();
     return;
   }
 
@@ -862,7 +953,12 @@ void XGUI_Workshop::openDirectory(const QString& theDirectory)
   module()->closeDocument();
   SessionPtr aSession = ModelAPI_Session::get();
   aSession->closeAll();
-  aSession->load(myCurrentDir.toLatin1().constData());
+
+  clearTemporaryDir();
+  if (!XGUI_CompressFiles::uncompress(myCurrentFile, myTmpDir.path()))
+    return;
+
+  aSession->load(myTmpDir.path().toLatin1().constData());
   myObjectBrowser->rebuildDataTree();
 
   // Open first level of data tree
@@ -873,7 +969,7 @@ void XGUI_Workshop::openDirectory(const QString& theDirectory)
 
   updateCommandStatus();
 #ifndef HAVE_SALOME
-  myMainWindow->setCurrentDir(myCurrentDir, true);
+  myMainWindow->setCurrentDir(myCurrentFile, true);
 #endif
 
 #ifdef _DEBUG
@@ -969,16 +1065,31 @@ bool XGUI_Workshop::onSave()
 {
   if(!myOperationMgr->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
     return false;
-  if (myCurrentDir.isEmpty()) {
+  if (myCurrentFile.isEmpty()) {
     return onSaveAs();
   }
+  SessionPtr aMgr = ModelAPI_Session::get();
+  if (aMgr->isAutoUpdateBlocked())
+    aMgr->blockAutoUpdate(false);
+
   std::list<std::string> aFiles;
-  saveDocument(myCurrentDir, aFiles);
-  updateCommandStatus();
+  // issue #2899: create a temporary directory, save and then remove it
+#ifdef HAVE_SALOME
+  std::string aTmpDir = XGUI_Tools::getTmpDirByEnv("SALOME_TMP_DIR");
+#else
+  std::string aTmpDir = XGUI_Tools::getTmpDirByEnv("");
+#endif
+  saveDocument(QString(aTmpDir.c_str()), aFiles);
+  bool aResult = XGUI_CompressFiles::compress(myCurrentFile, aFiles);
+  XGUI_Tools::removeTemporaryFiles(aTmpDir, aFiles);
+
+  if (aResult) {
+    updateCommandStatus();
 #ifndef HAVE_SALOME
     myMainWindow->setModifiedState(false);
 #endif
-  return true;
+  }
+  return aResult;
 }
 
 //******************************************************
@@ -986,34 +1097,17 @@ bool XGUI_Workshop::onSaveAs()
 {
   if(!myOperationMgr->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
     return false;
-  QFileDialog dialog(desktop());
-  dialog.setWindowTitle(tr("Select directory to save files..."));
-  dialog.setFileMode(QFileDialog::Directory);
-  dialog.setFilter(QDir::AllDirs);
-  dialog.setOptions(QFileDialog::HideNameFilterDetails | QFileDialog::ShowDirsOnly);
-  dialog.setViewMode(QFileDialog::Detail);
-
-  if (!dialog.exec()) {
-    return false;
-  }
-
-  QString aTempDir = dialog.selectedFiles().first();
-  QDir aDir(aTempDir);
-  if (aDir.exists() && !aDir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries).isEmpty()) {
-    int answer = QMessageBox::question(
-        desktop(),
-        // Title of the dialog which asks user if he wants to save study
-        // in existing non-empty folder
-        tr("Save"),
-        tr("The directory already contains some files, save anyway?"),
-        QMessageBox::Save | QMessageBox::Cancel);
-    if (answer == QMessageBox::Cancel) {
-      return false;
+  myCurrentFile = QFileDialog::getSaveFileName(desktop(), tr("Select name to save file..."),
+    QString(), MyFilter2);
+  if (!myCurrentFile.isNull()) {
+    if (!myCurrentFile.endsWith(MyExtension)) {
+      myCurrentFile += MyExtension;
     }
   }
-  myCurrentDir = aTempDir;
+  else
+    return false;
 #ifndef HAVE_SALOME
-    myMainWindow->setCurrentDir(myCurrentDir, false);
+    myMainWindow->setCurrentDir(myCurrentFile, false);
     myMainWindow->setModifiedState(false);
 #endif
   return onSave();
@@ -1022,64 +1116,68 @@ bool XGUI_Workshop::onSaveAs()
 //******************************************************
 void XGUI_Workshop::onUndo(int theTimes)
 {
-  ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget();
-  if (anActiveWidget && anActiveWidget->processAction(ActionUndo))
-    return;
-
-  objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
-  SessionPtr aMgr = ModelAPI_Session::get();
-  std::list<std::string> aUndoList = aMgr->undoList();
-  if (aMgr->isOperation()) {
-    /// this is important for nested operations
-    /// when sketch operation is active, this condition is false and
-    /// the sketch operation is not aborted
-    operationMgr()->onAbortOperation();
-  }
-  std::list<std::string>::const_iterator aIt = aUndoList.cbegin();
-  for (int i = 0; (i < theTimes) && (aIt != aUndoList.cend()); ++i, ++aIt) {
-    aMgr->undo();
-    if (QString((*aIt).c_str()) == MOVE_TO_END_COMMAND)
-      myObjectBrowser->rebuildDataTree();
-  }
-
-  operationMgr()->updateApplyOfOperations();
-  updateCommandStatus();
+  processUndoRedo(ActionUndo, theTimes);
+  myObjectBrowser->updateAllIndexes(1);
 }
 
 //******************************************************
 void XGUI_Workshop::onRedo(int theTimes)
 {
-  ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget();
-  if (anActiveWidget && anActiveWidget->processAction(ActionRedo))
-    return;
+  processUndoRedo(ActionRedo, theTimes);
+  myObjectBrowser->updateAllIndexes(1);
+}
 
+//******************************************************
+void XGUI_Workshop::processUndoRedo(const ModuleBase_ActionType theActionType, int theTimes)
+{
+  ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget();
+  if (anActiveWidget) {
+    ActionIntParamPtr aParam(new ModuleBase_ActionIntParameter(theTimes));
+    if (anActiveWidget->processAction(theActionType, aParam))
+      return;
+  }
   // the viewer update should be blocked in order to avoid the features blinking. For the created
   // feature a results are created, the flush of the created signal caused the viewer redisplay for
   // each created result. After a redisplay signal is flushed. So, the viewer update is blocked
   // until redo of all possible objects happens
   bool isUpdateEnabled = myDisplayer->enableUpdateViewer(false);
 
-  objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
   SessionPtr aMgr = ModelAPI_Session::get();
-  std::list<std::string> aRedoList = aMgr->redoList();
   if (aMgr->isOperation()) {
+    XGUI_OperationMgr* aOpMgr = operationMgr();
     /// this is important for nested operations
     /// when sketch operation is active, this condition is false and
     /// the sketch operation is not aborted
-    operationMgr()->onAbortOperation();
+    if (aOpMgr->canStopOperation(aOpMgr->currentOperation()))
+      aOpMgr->abortOperation(aOpMgr->currentOperation());
+    else
+    {
+      myDisplayer->enableUpdateViewer(isUpdateEnabled);
+      return;
+    }
   }
-  std::list<std::string>::const_iterator aIt = aRedoList.cbegin();
-  for (int i = 0; (i < theTimes) && (aIt != aRedoList.cend()); ++i, ++aIt) {
-    aMgr->redo();
+  objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
+  std::list<std::string> anActionList = theActionType == ActionUndo ? aMgr->undoList()
+    : aMgr->redoList();
+  std::list<std::string>::const_iterator aIt = anActionList.cbegin();
+  for (int i = 0; (i < theTimes) && (aIt != anActionList.cend()); ++i, ++aIt) {
+    if (theActionType == ActionUndo)
+      aMgr->undo();
+    else
+      aMgr->redo();
+
     if (QString((*aIt).c_str()) == MOVE_TO_END_COMMAND)
       myObjectBrowser->rebuildDataTree();
   }
   operationMgr()->updateApplyOfOperations();
+  facesPanel()->reset(true);
   updateCommandStatus();
 
   // unblock the viewer update functionality and make update on purpose
   myDisplayer->enableUpdateViewer(isUpdateEnabled);
   myDisplayer->updateViewer();
+  // Clear messages in status bar from previous operations if exists
+  setStatusBarMessage("");
 }
 
 //******************************************************
@@ -1139,7 +1237,7 @@ ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
   CREATE_FUNC crtInst = 0;
 
 #ifdef WIN32
-  HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
+  HINSTANCE modLib = ::LoadLibraryA(qPrintable(libName));
   if (!modLib) {
     LPVOID lpMsgBuf;
     ::FormatMessage(
@@ -1240,6 +1338,11 @@ void XGUI_Workshop::updateCommandStatus()
         else
           aCmd->setEnabled(myModule->canRedo());
       }
+      else if (aId == "AUTOCOMPUTE_CMD") {
+        aCmd->setIcon(aMgr->isAutoUpdateBlocked() ?
+          QIcon(":pictures/autoapply_stop.png") :
+          QIcon(":pictures/autoapply_start.png"));
+      }
       else
         // Enable all commands
         aCmd->setEnabled(true);
@@ -1263,12 +1366,21 @@ void XGUI_Workshop::updateCommandStatus()
 //******************************************************
 void XGUI_Workshop::updateHistory()
 {
-  std::list<std::string> aUndoList = ModelAPI_Session::get()->undoList();
-  QList<ActionInfo> aUndoRes = processHistoryList(aUndoList);
-  emit updateUndoHistory(aUndoRes);
+  bool isActionEnabled = false;
+  ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget();
+  QList<ActionInfo> aUndoRes;
+  QList<ActionInfo> aRedoRes;
+  if (anActiveWidget && anActiveWidget->canProcessAction(ActionUndo, isActionEnabled)) {
+    aUndoRes = anActiveWidget->actionsList(ActionUndo);
+    aRedoRes = anActiveWidget->actionsList(ActionRedo);
+  } else {
+    std::list<std::string> aUndoList = ModelAPI_Session::get()->undoList();
+    aUndoRes = processHistoryList(aUndoList);
 
-  std::list<std::string> aRedoList = ModelAPI_Session::get()->redoList();
-  QList<ActionInfo> aRedoRes = processHistoryList(aRedoList);
+    std::list<std::string> aRedoList = ModelAPI_Session::get()->redoList();
+    aRedoRes = processHistoryList(aRedoList);
+  }
+  emit updateUndoHistory(aUndoRes);
   emit updateRedoHistory(aRedoRes);
 }
 
@@ -1283,7 +1395,7 @@ QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
   aObjDock->setStyleSheet(
       "::title { position: relative; padding-left: 5px; text-align: left center }");
   myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock, this);
-  myObjectBrowser->setXMLReader(myDataModelXMLReader);
+  myObjectBrowser->initialize(myModule->rootNode());
   myModule->customizeObjectBrowser(myObjectBrowser);
   aObjDock->setWidget(myObjectBrowser);
 
@@ -1318,6 +1430,13 @@ void XGUI_Workshop::createDockWidgets()
                                 Qt::BottomDockWidgetArea);
   connect(myFacesPanel, SIGNAL(closed()), myFacesPanel, SLOT(onClosed()));
 
+  myInspectionPanel = new XGUI_InspectionPanel(aDesktop, mySelector);
+  myInspectionPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
+    Qt::RightDockWidgetArea);
+  aDesktop->addDockWidget(Qt::RightDockWidgetArea, myInspectionPanel);
+
+  myInspectionPanel->hide();
+
   aDesktop->addDockWidget(
 #ifdef HAVE_SALOME
     Qt::RightDockWidgetArea,
@@ -1327,19 +1446,26 @@ void XGUI_Workshop::createDockWidgets()
     myFacesPanel);
   hidePanel(myFacesPanel);  ///<! Invisible by default
 
-#ifdef DEBUG_FACES_PANEL
-  aDesktop->addDockWidget(Qt::RightDockWidgetArea, myFacesPanel);
-  showPanel(myFacesPanel);
+#ifdef _DEBUG
+  bool aShowOnTheRight = Config_PropManager::boolean("Plugins", "show_hide_faces");
+  if (aShowOnTheRight) {
+    aDesktop->addDockWidget(Qt::RightDockWidgetArea, myFacesPanel);
+    showPanel(myFacesPanel);
+  }
 #endif
-
   hideObjectBrowser();
 
-#ifdef DEBUG_FACES_PANEL
-#else
 #ifndef HAVE_SALOME
+#ifdef _DEBUG
+  if (!aShowOnTheRight)
+  {
+#endif // _DEBUG
   aDesktop->tabifyDockWidget(myFacesPanel, aObjDock);
-#endif
-#endif
+#ifdef _DEBUG
+  }
+#endif // _DEBUG
+
+#endif // HAVE_SALOME
 
   aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
   myPropertyPanel->installEventFilter(myOperationMgr);
@@ -1347,12 +1473,18 @@ void XGUI_Workshop::createDockWidgets()
   QAction* aOkAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept);
   connect(aOkAct, SIGNAL(triggered()), this, SLOT(onAcceptActionClicked()));
 
+  QAction* aOkContAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptPlus);
+  connect(aOkContAct, SIGNAL(triggered()), this, SLOT(onAcceptPlusActionClicked()));
+
   QAction* aCancelAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Abort);
   connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation()));
 
   QAction* aPreviewAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Preview);
   connect(aPreviewAct, SIGNAL(triggered()), this, SLOT(onPreviewActionClicked()));
 
+  QAction* aHelpAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Help);
+  connect(aHelpAct, SIGNAL(triggered()), this, SLOT(onHelpActionClicked()));
+
   connect(myPropertyPanel, SIGNAL(keyReleased(QObject*, QKeyEvent*)),
           myOperationMgr,  SLOT(onKeyReleased(QObject*, QKeyEvent*)));
   connect(myPropertyPanel, SIGNAL(enterClicked(QObject*)),
@@ -1401,8 +1533,9 @@ void XGUI_Workshop::hidePanel(QDockWidget* theDockWidget)
 //******************************************************
 void XGUI_Workshop::showObjectBrowser()
 {
-  if (!isSalomeMode())
+  if (!isSalomeMode()) {
     myObjectBrowser->parentWidget()->show();
+  }
 }
 
 //******************************************************
@@ -1517,7 +1650,7 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
 
 #ifdef DEBUG_WITH_MESSAGE_REPORT
         Handle(Message_Report) aContextReport = aContext->GetReport();
-        aContextReport->SetActive (Standard_True);
+        aContext->SetReportActive (Standard_True);
         aContextReport->SetLimit (1000);
         if (!aContextReport.IsNull())
           aParameters.Append(aContextReport);
@@ -1537,7 +1670,7 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
 #ifdef DEBUG_WITH_MESSAGE_REPORT
         MyTCommunicator->RegisterPlugin("TKMessageView");
 #endif
-        MyTCommunicator->RegisterPlugin("SMBrowser"); // custom plugin to view ModelAPI
+        //MyTCommunicator->RegisterPlugin("SMBrowser"); // custom plugin to view ModelAPI
         //MyTCommunicator->RegisterPlugin("TKSMBrowser"); // custom plugin to view ModelAPI
 
         MyTCommunicator->Init(aParameters);
@@ -1561,10 +1694,6 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
 //**************************************************************
 void XGUI_Workshop::setViewerSelectionMode(int theMode)
 {
-  XGUI_ActiveControlSelector* anActiveSelector = activeControlMgr()->activeSelector();
-  if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
-    facesPanel()->setActivePanel(false);
-
   if (theMode == -1)
     myViewerSelMode.clear();
   else {
@@ -1573,7 +1702,7 @@ void XGUI_Workshop::setViewerSelectionMode(int theMode)
     else
       myViewerSelMode.append(theMode);
   }
-  activateObjectsSelection(myDisplayer->displayedObjects());
+  selectionActivate()->updateSelectionModes();
 }
 
 //**************************************************************
@@ -1583,50 +1712,55 @@ void XGUI_Workshop::activateObjectsSelection(const QObjectPtrList& theList)
   module()->activeSelectionModes(aModes);
   if (aModes.isEmpty() && (myViewerSelMode.length() > 0))
     aModes.append(myViewerSelMode);
-  myDisplayer->activateObjects(aModes, theList);
+  selectionActivate()->activateObjects(aModes, theList);
 }
 
 //**************************************************************
 bool XGUI_Workshop::prepareForDisplay(const std::set<ObjectPtr>& theObjects) const
 {
+  if (facesPanel()->isEmpty())
+    return true;
+
   // generate container of objects taking into account sub elments of compsolid
   std::set<ObjectPtr> anAllProcessedObjects;
   for (std::set<ObjectPtr>::const_iterator anObjectsIt = theObjects.begin();
     anObjectsIt != theObjects.end(); anObjectsIt++) {
     ObjectPtr anObject = *anObjectsIt;
-    ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(anObject);
+    ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(anObject);
     if (aCompRes.get()) {
-      if (aCompRes->numberOfSubs(true) == 0)
+      std::list<ResultPtr> allRes;
+      ModelAPI_Tools::allSubs(aCompRes, allRes);
+      if (allRes.empty()) {
         anAllProcessedObjects.insert(anObject);
-      else {
-        for (int i = 0; i < aCompRes->numberOfSubs(true); i++) {
-          ResultPtr aSubRes = aCompRes->subResult(i, true);
-          anAllProcessedObjects.insert(aCompRes->subResult(i, true));
+      } else {
+        for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+          ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aRes);
+          if (aBody.get() && aBody->numberOfSubs() == 0)
+            anAllProcessedObjects.insert(aBody);
         }
       }
-    }
-    else
+    } else
       anAllProcessedObjects.insert(anObject);
   }
 
   // find hidden objects in faces panel
   std::set<ObjectPtr> aHiddenObjects;
   QStringList aHiddenObjectNames;
-  for (std::set<ObjectPtr>::const_iterator anObjectsIt = theObjects.begin();
-    anObjectsIt != theObjects.end(); anObjectsIt++) {
+  for (std::set<ObjectPtr>::const_iterator anObjectsIt = anAllProcessedObjects.begin();
+       anObjectsIt != anAllProcessedObjects.end(); anObjectsIt++) {
     if (!facesPanel()->isObjectHiddenByPanel(*anObjectsIt))
       continue;
     aHiddenObjects.insert(*anObjectsIt);
     aHiddenObjectNames.append((*anObjectsIt)->data()->name().c_str());
   }
-  if (aHiddenObjects.empty())
+  if (aHiddenObjects.empty()) // in parameter objects there are no hidden objects in hide face
     return true;
 
   int anAnswer = QMessageBox::question(
         desktop(), tr("Show object"),
         tr("'%1'\n are hidden by %2:\nRemove objects from the panel to be displayed?")
-        .arg(aHiddenObjectNames.join(',').arg(facesPanel()->windowTitle()),
-        QMessageBox::Yes | QMessageBox::No, QMessageBox::No));
+        .arg(aHiddenObjectNames.join(", ")).arg(facesPanel()->windowTitle()),
+        QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
 
   bool aToBeDisplayed = anAnswer == QMessageBox::Yes;
   if (aToBeDisplayed)
@@ -1891,7 +2025,6 @@ void XGUI_Workshop::moveObjects()
 //**************************************************************
 bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theObjects)
 {
-  std::map<FeaturePtr, std::set<FeaturePtr> > aReferences;
   std::set<FeaturePtr> aFeatures;
   ModuleBase_Tools::convertToFeatures(theObjects, aFeatures);
 
@@ -1995,6 +2128,17 @@ bool XGUI_Workshop::canMoveFeature()
   QObjectPtrList::const_iterator anIt = aObjects.begin(), aLast = aObjects.end();
   for (; anIt != aLast && aCanMove; anIt++) {
     ObjectPtr aObject = *anIt;
+    if (!aObject.get() || !aObject->data().get() || !aObject->data()->isValid()) {
+      aCanMove = false;
+      break;
+    }
+    FeaturePtr aFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
+    // only groups can be moved to the end for now (#2451)
+    if (aFeat.get() && aFeat->getKind() != "Group") {
+      aCanMove = false;
+      break;
+    }
+
     // 1. Get features placed between selected and current in the document
     std::list<FeaturePtr> aFeaturesBetween = toCurrentFeatures(aObject);
     // if aFeaturesBetween is empty it means wrong order or aObject is the current feature
@@ -2028,11 +2172,14 @@ bool XGUI_Workshop::canBeShaded(const ObjectPtr& theObject) const
 {
   bool aCanBeShaded = myDisplayer->canBeShaded(theObject);
   if (!aCanBeShaded) {
-    ResultCompSolidPtr aCompsolidResult =
-                std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theObject);
-    if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
-      for(int i = 0; i < aCompsolidResult->numberOfSubs() && !aCanBeShaded; i++)
-        aCanBeShaded = myDisplayer->canBeShaded(aCompsolidResult->subResult(i));
+    ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theObject);
+    if (aCompRes.get() != NULL) { // change colors for all sub-solids
+      std::list<ResultPtr> allRes;
+      ModelAPI_Tools::allSubs(aCompRes, allRes);
+      std::list<ResultPtr>::iterator aRes = allRes.begin();
+      for(; aRes != allRes.end() && !aCanBeShaded; aRes++) {
+        aCanBeShaded = myDisplayer->canBeShaded(*aRes);
+      }
     }
   }
   return aCanBeShaded;
@@ -2075,6 +2222,9 @@ void setColor(ResultPtr theResult, const std::vector<int>& theColor)
     aColorAttr->setValue(1, theColor[1]);
     aColorAttr->setValue(2, theColor[2]);
   }
+  static const Events_ID kRedisplayEvent =
+    Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+  ModelAPI_EventCreator::get()->sendUpdated(theResult, kRedisplayEvent);
 }
 
 //**************************************************************
@@ -2129,12 +2279,12 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
   foreach(ObjectPtr anObj, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
     if (aResult.get() != NULL) {
-      ResultCompSolidPtr aCompsolidResult =
-        std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
-      if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
-        for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
-          setColor(aCompsolidResult->subResult(i), !isRandomColor ? aColorResult :
-                                                                    aDlg->getRandomColor());
+      ResultBodyPtr aBodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
+      if (aBodyResult.get() != NULL) { // change colors for all sub-solids
+        std::list<ResultPtr> allRes;
+        ModelAPI_Tools::allSubs(aBodyResult, allRes);
+        for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+          setColor(*aRes, !isRandomColor ? aColorResult : aDlg->getRandomColor());
         }
       }
       setColor(aResult, !isRandomColor ? aColorResult : aDlg->getRandomColor());
@@ -2153,6 +2303,9 @@ void setDeflection(ResultPtr theResult, const double theDeflection)
   AttributeDoublePtr aDeflectionAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
   if (aDeflectionAttr.get() != NULL)
     aDeflectionAttr->setValue(theDeflection);
+  static const Events_ID kRedisplayEvent =
+    Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+  ModelAPI_EventCreator::get()->sendUpdated(theResult, kRedisplayEvent);
 }
 
 //**************************************************************
@@ -2164,6 +2317,9 @@ void setTransparency(ResultPtr theResult, double theTransparency)
   AttributeDoublePtr anAttribute = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID());
   if (anAttribute.get() != NULL)
     anAttribute->setValue(theTransparency);
+  static const Events_ID kRedisplayEvent =
+    Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+  ModelAPI_EventCreator::get()->sendUpdated(theResult, kRedisplayEvent);
 }
 
 //**************************************************************
@@ -2172,11 +2328,12 @@ void setTransparency(double theTransparency, const QObjectPtrList& theObjects)
   foreach(ObjectPtr anObj, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
     if (aResult.get() != NULL) {
-      ResultCompSolidPtr aCompsolidResult =
-        std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
-      if (aCompsolidResult.get() != NULL) { // change property for all sub-solids
-        for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
-          setTransparency(aCompsolidResult->subResult(i), theTransparency);
+      ResultBodyPtr aBodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
+      if (aBodyResult.get() != NULL) { // change property for all sub-solids
+        std::list<ResultPtr> allRes;
+        ModelAPI_Tools::allSubs(aBodyResult, allRes);
+        for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+          setTransparency(*aRes, theTransparency);
         }
       }
       setTransparency(aResult, theTransparency);
@@ -2232,11 +2389,12 @@ void XGUI_Workshop::changeDeflection(const QObjectPtrList& theObjects)
   foreach(ObjectPtr anObj, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
     if (aResult.get() != NULL) {
-      ResultCompSolidPtr aCompsolidResult =
-        std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
-      if (aCompsolidResult.get() != NULL) { // change property for all sub-solids
-        for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
-          setDeflection(aCompsolidResult->subResult(i), aDeflection);
+      ResultBodyPtr aBodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
+      if (aBodyResult.get() != NULL) { // change property for all sub-solids
+        std::list<ResultPtr> allRes;
+        ModelAPI_Tools::allSubs(aBodyResult, allRes);
+        for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+          setDeflection(*aRes, aDeflection);
         }
       }
       setDeflection(aResult, aDeflection);
@@ -2352,25 +2510,20 @@ void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)
     aObj->setDisplayed(isVisible);
   }
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
-#ifndef WIN32
-  // Necessary for update icons in ObjectBrowser on Linux
-  QModelIndexList aIndexes = mySelector->selection()->selectedIndexes();
-  foreach (QModelIndex aIdx, aIndexes) {
-    if (aIdx.column() == 0) {
-      myObjectBrowser->treeView()->update(aIdx);
-    }
-  }
-#endif
+  myObjectBrowser->updateAllIndexes();
 }
 
 //**************************************************************
 void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList)
 {
+  QObjectPtrList aSrcList = theList;
   // Hide all displayed objects
   QObjectPtrList aList = myDisplayer->displayedObjects();
   foreach (ObjectPtr aObj, aList) {
-    if (module()->canEraseObject(aObj))
+    if ((!aSrcList.contains(aObj)) && (module()->canEraseObject(aObj)))
       aObj->setDisplayed(false);
+    else
+      aSrcList.removeAll(aObj);
   }
   //Do not use eraseAll if you didn't send Redisplay event:
   //all objects are erased from viewer, but considered as displayed in displayer
@@ -2382,7 +2535,7 @@ void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList)
 #endif
 
   std::set<ObjectPtr> anObjects;
-  foreach (ObjectPtr aObj, theList) {
+  foreach (ObjectPtr aObj, aSrcList) {
     anObjects.insert(aObj);
   }
 
@@ -2390,7 +2543,7 @@ void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList)
     return;
 
   // Show only objects from the list
-  foreach (ObjectPtr aObj, theList) {
+  foreach (ObjectPtr aObj, aSrcList) {
     aObj->setDisplayed(true);
   }
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
@@ -2427,14 +2580,15 @@ void XGUI_Workshop::displayGroupResults(DocumentPtr theDoc, std::string theGroup
 //**************************************************************
 void XGUI_Workshop::setDisplayMode(const QObjectPtrList& theList, int theMode)
 {
-  foreach(ObjectPtr aObj, theList) {
-    myDisplayer->setDisplayMode(aObj, (XGUI_Displayer::DisplayMode)theMode, false);
+  foreach(ObjectPtr anObj, theList) {
+    myDisplayer->setDisplayMode(anObj, (XGUI_Displayer::DisplayMode)theMode, false);
 
-    ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aObj);
-    if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
-      for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
-          myDisplayer->setDisplayMode(aCompsolidResult->subResult(i),
-                                      (XGUI_Displayer::DisplayMode)theMode, false);
+    ResultBodyPtr aBodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(anObj);
+    if (aBodyResult.get() != NULL) { // change display mode for all sub-solids
+      std::list<ResultPtr> allRes;
+      ModelAPI_Tools::allSubs(aBodyResult, allRes);
+      for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+        myDisplayer->setDisplayMode(*aRes, (XGUI_Displayer::DisplayMode)theMode, false);
       }
     }
   }
@@ -2522,6 +2676,7 @@ void XGUI_Workshop::setStatusBarMessage(const QString& theMessage)
 #endif
 }
 
+#ifdef HAVE_SALOME
 //******************************************************
 void XGUI_Workshop::synchronizeViewer()
 {
@@ -2553,18 +2708,36 @@ void XGUI_Workshop::synchronizeGroupInViewer(const DocumentPtr& theDoc,
       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
       if (aRes.get() && (!aRes->shape().get() || aRes->shape()->isNull()))
         continue;
-      myDisplayer->display(aObj, false);
+      ResultBodyPtr aResBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
+      if (aResBody.get())
+        synchronizeResultTree(aResBody, false);
+      else
+        myDisplayer->display(aObj, false);
     }
   }
   if (theUpdateViewer)
     myDisplayer->updateViewer();
 }
 
+void XGUI_Workshop::synchronizeResultTree(const ResultBodyPtr& theRes, bool theUpdateViewer)
+{
+  if (theRes->numberOfSubs() > 0)
+    for (int i = 0; i < theRes->numberOfSubs(); i++) {
+      ResultBodyPtr aRes = theRes->subResult(i);
+      if (aRes.get())
+        synchronizeResultTree(aRes, theUpdateViewer);
+    }
+  else
+    myDisplayer->display(theRes, theUpdateViewer);
+}
+#endif
+
 //******************************************************
 void XGUI_Workshop::highlightResults(const QObjectPtrList& theObjects)
 {
   FeaturePtr aFeature;
   QObjectPtrList aSelList = theObjects;
+  QObjectPtrList aNewSel;
   bool aHasHidden = false;
   foreach(ObjectPtr aObj, theObjects) {
     aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
@@ -2575,14 +2748,14 @@ void XGUI_Workshop::highlightResults(const QObjectPtrList& theObjects)
       for(aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
         aHasHidden |= (*aIt)->isConcealed();
         aSelList.append(*aIt);
+        aNewSel.append(*aIt);
       }
     }
   }
   if (aSelList.count() > theObjects.count()) {
     // if something was found
-    bool aBlocked = objectBrowser()->blockSignals(true);
     objectBrowser()->setObjectsSelected(aSelList);
-    objectBrowser()->blockSignals(aBlocked);
+    objectBrowser()->ensureVisible(aNewSel.first());
   }
   if (aHasHidden)
     QMessageBox::information(desktop(), tr("Find results"),
@@ -2594,6 +2767,7 @@ void XGUI_Workshop::highlightFeature(const QObjectPtrList& theObjects)
 {
   ResultPtr aResult;
   QObjectPtrList aSelList = theObjects;
+  QObjectPtrList aNewSel;
   FeaturePtr aFeature;
   foreach(ObjectPtr aObj, theObjects) {
     aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
@@ -2601,14 +2775,14 @@ void XGUI_Workshop::highlightFeature(const QObjectPtrList& theObjects)
       aFeature = ModelAPI_Feature::feature(aResult);
       if (aFeature.get()) {
         aSelList.append(aFeature);
+        aNewSel.append(aFeature);
       }
     }
   }
   if (aSelList.count() > theObjects.count()) {
     // if something was found
-    bool aBlocked = objectBrowser()->blockSignals(true);
     objectBrowser()->setObjectsSelected(aSelList);
-    objectBrowser()->blockSignals(aBlocked);
+    objectBrowser()->ensureVisible(aNewSel.first());
   }
 }
 
@@ -2624,9 +2798,13 @@ void XGUI_Workshop::insertFeatureFolder()
   SessionPtr aMgr = ModelAPI_Session::get();
   DocumentPtr aDoc = aMgr->activeDocument();
 
-  aMgr->startOperation();
+  QString aDescription = contextMenuMgr()->action("INSERT_FOLDER_CMD")->text();
+
+  aMgr->startOperation(aDescription.toStdString());
   aDoc->addFolder(aFeature);
   aMgr->finishOperation();
+
+  updateCommandStatus();
 }
 
 
@@ -2644,9 +2822,18 @@ void XGUI_Workshop::insertToFolder(bool isBefore)
   if (!aFolder.get())
     return;
 
-  aMgr->startOperation();
+  QString aDescription = contextMenuMgr()->action(
+    isBefore ? "ADD_TO_FOLDER_BEFORE_CMD" : "ADD_TO_FOLDER_AFTER_CMD")->text();
+
+  QMap<ObjectPtr, bool> aStates = myObjectBrowser->getFoldersState(aDoc);
+
+  aMgr->startOperation(aDescription.toStdString());
   aDoc->moveToFolder(aFeatures, aFolder);
   aMgr->finishOperation();
+
+  myObjectBrowser->setFoldersState(aStates);
+
+  updateCommandStatus();
 }
 
 void XGUI_Workshop::moveOutFolder(bool isBefore)
@@ -2658,7 +2845,59 @@ void XGUI_Workshop::moveOutFolder(bool isBefore)
   SessionPtr aMgr = ModelAPI_Session::get();
   DocumentPtr aDoc = aMgr->activeDocument();
 
-  aMgr->startOperation();
+  QString aDescription = contextMenuMgr()->action(
+    isBefore ? "ADD_OUT_FOLDER_BEFORE_CMD" : "ADD_OUT_FOLDER_AFTER_CMD")->text();
+
+  QMap<ObjectPtr, bool> aStates = myObjectBrowser->getFoldersState(aDoc);
+
+  aMgr->startOperation(aDescription.toStdString());
   aDoc->removeFromFolder(aFeatures, isBefore);
   aMgr->finishOperation();
+
+  myObjectBrowser->setFoldersState(aStates);
+
+  updateCommandStatus();
+}
+
+void XGUI_Workshop::onAutoApply()
+{
+  SessionPtr aMgr = ModelAPI_Session::get();
+  bool isBlocked = aMgr->isAutoUpdateBlocked();
+  aMgr->blockAutoUpdate(!isBlocked);
+}
+
+void XGUI_Workshop::updateAutoComputeState()
+{
+  SessionPtr aMgr = ModelAPI_Session::get();
+  bool isComputeBlocked = aMgr->isAutoUpdateBlocked();
+#ifdef HAVE_SALOME
+//  QAction* aUpdateCmd;
+//  QList<QAction*> aCommands = mySalomeConnector->commandList();
+//  foreach(QAction* aCmd, aCommands) {
+//    if (aCmd->data().toString() == "AUTOCOMPUTE_CMD") {
+//      aUpdateCmd = aCmd;
+//      break;
+//    }
+//  }
+//  aUpdateCmd->setIcon(isComputeBlocked? QIcon(":pictures/autoapply_stop.png") :
+//    QIcon(":pictures/autoapply_start.png"));
+#else
+  AppElements_MainMenu* aMenuBar = myMainWindow->menuObject();
+  AppElements_Command* aUpdateCmd = aMenuBar->feature("AUTOCOMPUTE_CMD");
+  aUpdateCmd->button()->setIcon(isComputeBlocked? QIcon(":pictures/autoapply_stop.png") :
+    QIcon(":pictures/autoapply_start.png"));
+#endif
 }
+
+
+void XGUI_Workshop::clearTemporaryDir()
+{
+  QDir aDir(myTmpDir.path());
+  if (!aDir.isEmpty()) {
+    QStringList aEntries;
+    aDir.entryList(aEntries);
+    foreach(QString aFile, aEntries) {
+      aDir.remove(aFile);
+    }
+  }
+}
\ No newline at end of file