Salome HOME
Issue #2806: Provide correct selection with Shift button when Multi selector widget...
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index 0a1b1570ca901a64d408103893edbf3050ec8f3b..e3db137e014486486f5838eb1501c447bd5b4a17 100755 (executable)
@@ -51,6 +51,7 @@
 #include <XGUI_QtEvents.h>
 #include <XGUI_DataModel.h>
 #include <XGUI_InspectionPanel.h>
+#include <XGUI_CompressFiles.h>
 
 #ifndef HAVE_SALOME
 #include <AppElements_Button.h>
@@ -72,7 +73,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 <QToolButton>
 #include <QAction>
 #include <QDesktopWidget>
+#include <QProcess>
+#include <QDesktopServices>
 
 #include <iterator>
 
@@ -168,10 +170,20 @@ 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),
@@ -186,7 +198,7 @@ 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();
@@ -298,6 +310,9 @@ XGUI_Workshop::~XGUI_Workshop(void)
 
   delete myDisplayer;
   delete myDataModelXMLReader;
+  delete mySelectionActivate;
+  delete myMenuMgr;
+  clearTemporaryDir();
 }
 
 //******************************************************
@@ -412,7 +427,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)));
@@ -427,6 +442,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(),
@@ -477,6 +504,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()));
@@ -559,6 +593,48 @@ 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)
 {
@@ -645,9 +721,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());
@@ -850,25 +927,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;
   }
 
@@ -876,7 +954,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
@@ -887,7 +970,7 @@ void XGUI_Workshop::openDirectory(const QString& theDirectory)
 
   updateCommandStatus();
 #ifndef HAVE_SALOME
-  myMainWindow->setCurrentDir(myCurrentDir, true);
+  myMainWindow->setCurrentDir(myCurrentFile, true);
 #endif
 
 #ifdef _DEBUG
@@ -983,11 +1066,18 @@ 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);
+  saveDocument(myTmpDir.path(), aFiles);
+  if (!XGUI_CompressFiles::compress(myCurrentFile, aFiles))
+    return false;
+
   updateCommandStatus();
 #ifndef HAVE_SALOME
     myMainWindow->setModifiedState(false);
@@ -1000,34 +1090,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();
@@ -1157,7 +1230,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(
@@ -1258,6 +1331,12 @@ void XGUI_Workshop::updateCommandStatus()
         else
           aCmd->setEnabled(myModule->canRedo());
       }
+      else if (aId == "AUTOCOMPUTE_CMD") {
+        //aCmd->setChecked(aMgr->isAutoUpdateBlocked());
+        aCmd->setIcon(aMgr->isAutoUpdateBlocked() ?
+          QIcon(":pictures/autoapply_stop.png") :
+          QIcon(":pictures/autoapply_start.png"));
+      }
       else
         // Enable all commands
         aCmd->setEnabled(true);
@@ -1310,7 +1389,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);
 
@@ -1350,6 +1429,8 @@ void XGUI_Workshop::createDockWidgets()
     Qt::RightDockWidgetArea);
   aDesktop->addDockWidget(Qt::RightDockWidgetArea, myInspectionPanel);
 
+  myInspectionPanel->hide();
+
   aDesktop->addDockWidget(
 #ifdef HAVE_SALOME
     Qt::RightDockWidgetArea,
@@ -1395,6 +1476,9 @@ void XGUI_Workshop::createDockWidgets()
   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*)),
@@ -1443,8 +1527,9 @@ void XGUI_Workshop::hidePanel(QDockWidget* theDockWidget)
 //******************************************************
 void XGUI_Workshop::showObjectBrowser()
 {
-  if (!isSalomeMode())
+  if (!isSalomeMode()) {
     myObjectBrowser->parentWidget()->show();
+  }
 }
 
 //******************************************************
@@ -1579,7 +1664,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);
@@ -1635,18 +1720,20 @@ bool XGUI_Workshop::prepareForDisplay(const std::set<ObjectPtr>& theObjects) con
   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);
   }
 
@@ -2079,11 +2166,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;
@@ -2180,12 +2270,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());
@@ -2223,11 +2313,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);
@@ -2283,11 +2374,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);
@@ -2409,11 +2501,14 @@ void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)
 //**************************************************************
 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
@@ -2425,7 +2520,7 @@ void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList)
 #endif
 
   std::set<ObjectPtr> anObjects;
-  foreach (ObjectPtr aObj, theList) {
+  foreach (ObjectPtr aObj, aSrcList) {
     anObjects.insert(aObj);
   }
 
@@ -2433,7 +2528,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));
@@ -2470,14 +2565,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);
       }
     }
   }
@@ -2627,9 +2723,7 @@ void XGUI_Workshop::highlightResults(const QObjectPtrList& theObjects)
   }
   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)
@@ -2656,9 +2750,7 @@ void XGUI_Workshop::highlightFeature(const QObjectPtrList& theObjects)
   }
   if (aSelList.count() > theObjects.count()) {
     // if something was found
-    bool aBlocked = objectBrowser()->blockSignals(true);
     objectBrowser()->setObjectsSelected(aSelList);
-    objectBrowser()->blockSignals(aBlocked);
     objectBrowser()->ensureVisible(aNewSel.first());
   }
 }
@@ -2735,3 +2827,46 @@ void XGUI_Workshop::moveOutFolder(bool isBefore)
 
   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