Salome HOME
Issue #3100: Restore state of hidden faces on Hide/Show an object
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index 2660cb93b4a6cd9f5937269e31258f04cf045ff9..56e784cb5a590a093d6d5273d053e6db3255b4d4 100644 (file)
@@ -45,7 +45,6 @@
 #include "XGUI_Tools.h"
 #include "XGUI_ViewerProxy.h"
 #include "XGUI_WorkshopListener.h"
-#include <XGUI_CustomPrs.h>
 #include <XGUI_HistoryMenu.h>
 #include <XGUI_QtEvents.h>
 #include <XGUI_DataModel.h>
@@ -67,6 +66,7 @@
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Feature.h>
@@ -79,6 +79,7 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultField.h>
 
 //#include <PartSetPlugin_Part.h>
 
 #include <Events_InfoMessage.h>
 #include <Events_LongOp.h>
 
+#include <ExchangePlugin_ExportPart.h>
+#include <ExchangePlugin_ImportPart.h>
+
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_ShapeExplorer.h>
+
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_WidgetFactory.h>
 #include <ModuleBase_OperationFeature.h>
-#include <ModuleBase_OperationAction.h>
 #include <ModuleBase_PagedContainer.h>
 #include <ModuleBase_WidgetValidated.h>
 #include <ModuleBase_ModelWidget.h>
 #include <ModuleBase_ResultPrs.h>
 #include <ModuleBase_ActionIntParameter.h>
+#include <ModuleBase_IStepPrs.h>
 
 #include <Config_Common.h>
 #include <Config_FeatureMessage.h>
@@ -164,21 +171,24 @@ static Handle(VInspector_CallBack) MyVCallBack;
 //#define DEBUG_WITH_MESSAGE_REPORT
 
 QString XGUI_Workshop::MOVE_TO_END_COMMAND = QObject::tr("Move to the end");
+QString XGUI_Workshop::MOVE_TO_END_SPLIT_COMMAND = QObject::tr("Move to the end and split");
 
 //#define DEBUG_DELETE
 //#define DEBUG_FEATURE_NAME
 //#define DEBUG_CLEAN_HISTORY
 
 #ifdef HAVE_SALOME
-static QString MyFilter(QObject::tr("SHAPER files (*.shaper *.opp)"));
+static QString MyFilter(QObject::tr("SHAPER files (*.shaper *.cadbld)"));
 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");
+static QString MyFilter(QObject::tr("CAD Builder files (*.cadbld);;All files (*.*)"));
+static QString MyFilter2(QObject::tr("CAD Builder files (*.cadbld)"));
+static QString MyExtension(".cadbld");
 #endif
 
+static QString MyImportPartFilter(QObject::tr("Part files (*.shaperpart);;All files (*.*)"));
+
 
 //******************************************************
 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
@@ -264,27 +274,14 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
 
 #ifndef HAVE_SALOME
   connect(myMainWindow, SIGNAL(exitKeySequence()), SLOT(onExit()));
-  onTrihedronVisibilityChanged(true);
+  myDisplayer->displayTrihedron(true);
 #endif
 
   connect(myEventsListener, SIGNAL(errorOccurred(std::shared_ptr<Events_InfoMessage>)),
           myErrorDlg, SLOT(addError(std::shared_ptr<Events_InfoMessage>)));
 
-  //Config_PropManager::registerProp("Visualization", "object_default_color", "Object color",
-  //                                 Config_Prop::Color, "225,225,225");
-
-  Config_PropManager::registerProp("Visualization", "result_body_color", "Result color",
-                                   Config_Prop::Color, ModelAPI_ResultBody::DEFAULT_COLOR());
-  Config_PropManager::registerProp("Visualization", "result_group_color", "Group color",
-                                   Config_Prop::Color, ModelAPI_ResultGroup::DEFAULT_COLOR());
-  Config_PropManager::registerProp("Visualization", "result_construction_color",
-                                   "Construction color",
-                                   Config_Prop::Color,
-                                   ModelAPI_ResultConstruction::DEFAULT_COLOR());
-  Config_PropManager::registerProp("Visualization", "result_part_color", "Part color",
-                                   Config_Prop::Color, ModelAPI_ResultPart::DEFAULT_COLOR());
-  Config_PropManager::registerProp("Visualization", "result_field_color", "Field color",
-                                   Config_Prop::Color, ModelAPI_ResultField::DEFAULT_COLOR());
+  Config_PropManager::registerProp("Visualization", "selection_color", "Selection color",
+    Config_Prop::Color, "255,255,255");
 
   if (ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "face-selection", true))
     myViewerSelMode.append(TopAbs_FACE);
@@ -342,6 +339,15 @@ void XGUI_Workshop::startApplication()
   // Calling of  loadCustomProps before activating module is required
   // by Config_PropManger to restore user-defined path to plugins
   ModuleBase_Preferences::loadCustomProps();
+  std::vector<int> aColor;
+  try {
+    aColor = Config_PropManager::color("Visualization", "selection_color");
+  }
+  catch (...) {
+  }
+  if (aColor.size() == 3)
+    myDisplayer->setSelectionColor(aColor);
+
   createModule();
 
 #ifndef HAVE_SALOME
@@ -466,6 +472,19 @@ void XGUI_Workshop::initMenu()
   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onOpen()));
   salomeConnector()->addDesktopMenuSeparator("MEN_DESK_FILE");
 
+  aAction = salomeConnector()->addDesktopCommand("EXPORT_PART_CMD", tr("Export part..."),
+                                          tr("Export a part of the current document into a file"),
+                                          QIcon(), QKeySequence(),
+                                          false, "MEN_DESK_FILE");
+  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onExportPart()));
+
+  aAction = salomeConnector()->addDesktopCommand("IMPORT_PART_CMD", tr("Import part..."),
+                                          tr("Import structure of a part"),
+                                          QIcon(), QKeySequence(),
+                                          false, "MEN_DESK_FILE");
+  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onImportPart()));
+  salomeConnector()->addDesktopMenuSeparator("MEN_DESK_FILE");
+
 #else
   // File commands group
   AppElements_MenuGroupPanel* aGroup = myMainWindow->menuObject()->generalPage();
@@ -620,7 +639,7 @@ void XGUI_Workshop::onHelpActionClicked()
             "salome" + aSep + "gui" + aSep + "SHAPER";
         }
 #else
-        QString aDir(getenv("OPENPARTS_ROOT_DIR"));
+        QString aDir(getenv("CADBUILDER_ROOT_DIR"));
         aDocDir = aDir + aSep + "doc" + aSep + "gui";
 #endif
         QString aFileName = aDocDir + aSep + aHelpPage;
@@ -672,12 +691,11 @@ void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation)
   if (!aFOperation)
     return;
 
-  showPanel(myPropertyPanel);
   myPropertyPanel->cleanContent();
 
   QList<ModuleBase_ModelWidget*> aWidgets;
-  if (!module()->createWidgets(theOperation, aWidgets)) {
-    QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+  QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+  if (!module()->createWidgets(aFOperation->feature(), aXmlRepr, aWidgets)) {
     ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myModuleConnector);
     aFactory.createWidget(myPropertyPanel->contentWidget());
     aWidgets = aFactory.getModelWidgets();
@@ -748,15 +766,22 @@ void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation)
   myModule->propertyPanelDefined(theOperation);
 
 #ifndef DEBUG_FEATURE_NAME
-  myPropertyPanel->setWindowTitle(theOperation->getDescription()->description());
+  myPropertyPanel->setWindowTitle(ModuleBase_Tools::translate("workshop",
+    theOperation->getDescription()->description().toStdString()));
 #else
   std::string aFeatureName = aFeature->name();
   myPropertyPanel->setWindowTitle(QString("%1: %2")
-    .arg(theOperation->getDescription()->description())
-    .arg(aFeatureName.c_str()));
+    .arg(translate(theOperation->getDescription()->description()))
+    .arg(translate(aFeatureName.c_str())));
 #endif
 
   myErrorMgr->setPropertyPanel(myPropertyPanel);
+  if (Config_PropManager::boolean("Windows", "use_hide_faces_panel")) {
+    theOperation->setHideFacesVisible(myFacesPanel->isVisible());
+    if (aFeatureInfo.get() && aFeatureInfo->isHideFacesPanel() && !myFacesPanel->isVisible())
+      myFacesPanel->show();
+  }
+  showPanel(myPropertyPanel);
 }
 
 //******************************************************
@@ -789,6 +814,12 @@ void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation)
   if (theOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
     fillPropertyPanel(theOperation);
     connectToPropertyPanel(true);
+    ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+      (theOperation);
+    if (aFOperation)
+      myPropertyPanel->updateApplyPlusButton(aFOperation->feature());
+    else
+      myPropertyPanel->updateApplyPlusButton(FeaturePtr());
   }
   updateCommandStatus();
 
@@ -832,6 +863,11 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
     }
   }
   activateObjectsSelection(anObjects);
+
+  if (Config_PropManager::boolean("Windows", "use_hide_faces_panel")) {
+    if (!theOperation->isHideFacesVisible())
+      myFacesPanel->close();
+  }
 }
 
 //******************************************************
@@ -916,7 +952,6 @@ void XGUI_Workshop::onOpen()
   //save current file before close if modified
   SessionPtr aSession = ModelAPI_Session::get();
   if (aSession->isModified()) {
-    //TODO(sbh): re-launch the app?
     int anAnswer = QMessageBox::question(
         desktop(), tr("Save current file"),
         tr("The document is modified, save before opening another?"),
@@ -930,7 +965,11 @@ void XGUI_Workshop::onOpen()
   }
 
   //show file dialog, check if readable and open
-  QString aFile = QFileDialog::getOpenFileName(desktop(), tr("Open file"), QString(), MyFilter);
+  qreal aRatio = ModuleBase_Tools::currentPixelRatio();
+  // If the ratio is > 1 (HD screen) then QT has a bug in
+  // displaying of system open file dialog (too small)
+  QString aFile = QFileDialog::getOpenFileName(desktop(), tr("Open file"), QString(), MyFilter,
+    Q_NULLPTR, ((aRatio > 1)? QFileDialog::DontUseNativeDialog : QFileDialog::Options()));
   if (!aFile.isNull())
     openFile(aFile);
 }
@@ -1005,6 +1044,8 @@ void XGUI_Workshop::onNew()
   QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
   aWnd->showMaximized();
   updateCommandStatus();
+  PyConsole_Console* aConsole = myMainWindow->pythonConsole();
+  connect(aConsole, SIGNAL(scriptLoaded()), SLOT(updateCommandStatus()));
 #endif
   myContextMenuMgr->connectViewer();
   QApplication::restoreOverrideCursor();
@@ -1038,8 +1079,7 @@ void XGUI_Workshop::onPreferences()
   ModuleBase_Preferences::editPreferences(aModif);
   if (aModif.size() > 0) {
     QString aSection;
-    foreach (ModuleBase_Pref aPref, aModif)
-    {
+    foreach (ModuleBase_Pref aPref, aModif) {
       aSection = aPref.first;
       if (aSection == ModuleBase_Preferences::VIEWER_SECTION) {
         myMainWindow->viewer()->updateFromResources();
@@ -1047,6 +1087,15 @@ void XGUI_Workshop::onPreferences()
         myMainWindow->menuObject()->updateFromResources();
       }
     }
+    std::vector<int> aColor;
+    try {
+      aColor = Config_PropManager::color("Visualization", "selection_color");
+    }
+    catch (...) {
+    }
+    if (aColor.size() == 3)
+      displayer()->setSelectionColor(aColor);
+
     displayer()->redisplayObjects();
   }
 }
@@ -1056,8 +1105,10 @@ void XGUI_Workshop::onPreferences()
 void XGUI_Workshop::onTrihedronVisibilityChanged(bool theState)
 {
   XGUI_Displayer* aDisplayer = displayer();
-  if (aDisplayer)
+  if (aDisplayer) {
     aDisplayer->displayTrihedron(theState);
+    aDisplayer->updateViewer();
+  }
 }
 
 //******************************************************
@@ -1073,15 +1124,23 @@ bool XGUI_Workshop::onSave()
     aMgr->blockAutoUpdate(false);
 
   std::list<std::string> aFiles;
-  saveDocument(myTmpDir.path(), aFiles);
-  if (!XGUI_CompressFiles::compress(myCurrentFile, aFiles))
-    return false;
+  // 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);
 
-  updateCommandStatus();
+  if (aResult) {
+    updateCommandStatus();
 #ifndef HAVE_SALOME
     myMainWindow->setModifiedState(false);
 #endif
-  return true;
+  }
+  return aResult;
 }
 
 //******************************************************
@@ -1089,8 +1148,10 @@ bool XGUI_Workshop::onSaveAs()
 {
   if(!myOperationMgr->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
     return false;
+  qreal aRatio = ModuleBase_Tools::currentPixelRatio();
   myCurrentFile = QFileDialog::getSaveFileName(desktop(), tr("Select name to save file..."),
-    QString(), MyFilter2);
+    QString(), MyFilter2,
+    Q_NULLPTR, ((aRatio > 1) ? QFileDialog::DontUseNativeDialog : QFileDialog::Options()));
   if (!myCurrentFile.isNull()) {
     if (!myCurrentFile.endsWith(MyExtension)) {
       myCurrentFile += MyExtension;
@@ -1158,7 +1219,8 @@ void XGUI_Workshop::processUndoRedo(const ModuleBase_ActionType theActionType, i
     else
       aMgr->redo();
 
-    if (QString((*aIt).c_str()) == MOVE_TO_END_COMMAND)
+    if (QString((*aIt).c_str()) == MOVE_TO_END_COMMAND ||
+        QString((*aIt).c_str()) == MOVE_TO_END_SPLIT_COMMAND)
       myObjectBrowser->rebuildDataTree();
   }
   operationMgr()->updateApplyOfOperations();
@@ -1214,6 +1276,27 @@ void XGUI_Workshop::onValuesChanged()
 void XGUI_Workshop::onWidgetObjectUpdated()
 {
   operationMgr()->onValidateOperation();
+  myDisplayer->updateViewer();
+}
+
+//******************************************************
+void XGUI_Workshop::onImportPart()
+{
+  if (abortAllOperations()) {
+    ModuleBase_OperationFeature* anImportPartOp = dynamic_cast<ModuleBase_OperationFeature*>(
+        module()->createOperation(ExchangePlugin_ImportPart::ID()));
+    operationMgr()->startOperation(anImportPartOp);
+  }
+}
+
+//******************************************************
+void XGUI_Workshop::onExportPart()
+{
+  if (abortAllOperations()) {
+    ModuleBase_OperationFeature* anExportPartOp = dynamic_cast<ModuleBase_OperationFeature*>(
+        module()->createOperation(ExchangePlugin_ExportPart::ID()));
+    operationMgr()->startOperation(anExportPartOp);
+  }
 }
 
 //******************************************************
@@ -1381,8 +1464,7 @@ QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
 {
   QDockWidget* aObjDock = new QDockWidget(theParent);
   aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea |
-                            Qt::RightDockWidgetArea |
-                            Qt::BottomDockWidgetArea);
+                            Qt::RightDockWidgetArea);
   aObjDock->setWindowTitle(tr("Object browser"));
   aObjDock->setStyleSheet(
       "::title { position: relative; padding-left: 5px; text-align: left center }");
@@ -1391,6 +1473,8 @@ QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
   myModule->customizeObjectBrowser(myObjectBrowser);
   aObjDock->setWidget(myObjectBrowser);
 
+  connect(myObjectBrowser, SIGNAL(sizeChanged()), SLOT(onDockSizeChanged()));
+
   myContextMenuMgr->connectObjectBrowser();
   return aObjDock;
 }
@@ -1410,19 +1494,19 @@ void XGUI_Workshop::createDockWidgets()
 
   myPropertyPanel->setupActions(myActionsMgr);
   myPropertyPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
-                                   Qt::RightDockWidgetArea |
-                                   Qt::BottomDockWidgetArea);
+                                   Qt::RightDockWidgetArea);
   aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);
+
   hidePanel(myPropertyPanel);  ///<! Invisible by default
 
-  myFacesPanel = new XGUI_FacesPanel(aDesktop, myModuleConnector);
+  myFacesPanel = new XGUI_FacesPanel(aDesktop, this);
   myActiveControlMgr->addSelector(new XGUI_FacesPanelSelector(myFacesPanel));
   myFacesPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
                                 Qt::RightDockWidgetArea |
                                 Qt::BottomDockWidgetArea);
   connect(myFacesPanel, SIGNAL(closed()), myFacesPanel, SLOT(onClosed()));
 
-  myInspectionPanel = new XGUI_InspectionPanel(aDesktop, mySelector);
+  myInspectionPanel = new XGUI_InspectionPanel(aDesktop, this);
   myInspectionPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
     Qt::RightDockWidgetArea);
   aDesktop->addDockWidget(Qt::RightDockWidgetArea, myInspectionPanel);
@@ -1498,7 +1582,7 @@ void XGUI_Workshop::showPanel(QDockWidget* theDockWidget)
   // in order to operation manager could process key events of the panel.
   // otherwise they are ignored. It happens only if the same(activateWindow) is
   // not happened by property panel activation(e.g. resume operation of Sketch)
-  ModuleBase_Tools::setFocus(theDockWidget, "XGUI_Workshop::showPanel()");
+  //ModuleBase_Tools::setFocus(theDockWidget, "XGUI_Workshop::showPanel()");
 }
 
 //******************************************************
@@ -1514,7 +1598,7 @@ void XGUI_Workshop::hidePanel(QDockWidget* theDockWidget)
   // the property panel is active window of the desktop, when it is
   // hidden, it is undefined which window becomes active. By this reason
   // it is defined to perform the desktop as the active window.
-  // in SALOME mode, workstack made the PyConsole the active window,
+  // in SALOME mode, work-stack made the PyConsole the active window,
   // set the focus on it. As a result, shortcuts of the application, like
   // are processed by this console. For example Undo actions.
   // It is possible that this code is to be moved to SHAPER package
@@ -1557,16 +1641,14 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
     deleteObjects();
   else if (theId == "CLEAN_HISTORY_CMD")
     cleanHistory();
-  else if (theId == "MOVE_CMD")
-    moveObjects();
+  else if (theId == "MOVE_CMD" || theId == "MOVE_SPLIT_CMD")
+    moveObjects(theId == "MOVE_SPLIT_CMD");
   else if (theId == "COLOR_CMD")
     changeColor(aObjects);
   else if (theId == "DEFLECTION_CMD")
     changeDeflection(aObjects);
-#ifdef USE_TRANSPARENCY
   else if (theId == "TRANSPARENCY_CMD")
     changeTransparency(aObjects);
-#endif
   else if (theId == "SHOW_CMD") {
     showObjects(aObjects, true);
     mySelector->updateSelectionBy(ModuleBase_ISelection::Browser);
@@ -1624,6 +1706,10 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
     highlightResults(aObjects);
   } else if (theId == "SHOW_FEATURE_CMD") {
     highlightFeature(aObjects);
+  } else if (theId == "SET_VIEW_NORMAL_CMD") {
+    setNormalView();
+  } else if (theId == "SET_VIEW_INVERTEDNORMAL_CMD") {
+    setNormalView(true);
   }
 #ifdef TINSPECTOR
   else if (theId == "TINSPECTOR_VIEW") {
@@ -1768,6 +1854,7 @@ void XGUI_Workshop::deleteObjects()
   // allow the module to delete objects, do nothing if it has succeed
   if (aModule->deleteObjects()) {
     updateCommandStatus();
+    myDisplayer->updateViewer();
     return;
   }
 
@@ -1783,9 +1870,24 @@ void XGUI_Workshop::deleteObjects()
   bool hasFolder = false;
   ModuleBase_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter, hasCompositeOwner,
                                  hasResultInHistory, hasFolder);
-  if (!(hasFeature || hasParameter || hasFolder))
+  if (!(hasResult || hasFeature || hasParameter || hasFolder))
     return;
 
+  // Remove from the list non-deletable objects: infinite constructions which are not in history
+  bool notDelete = true;
+  QObjectPtrList::iterator aIt;
+  for (aIt = anObjects.begin(); aIt != anObjects.end(); aIt++) {
+    ObjectPtr aObj = (*aIt);
+    ResultConstructionPtr aConstr = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+    FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+    if (aFeature) {
+      notDelete = (!aFeature->isInHistory()) && aConstr->isInfinite();
+      if (notDelete) {
+        anObjects.removeAll(aObj);
+        aIt--;
+      }
+    }
+  }
   // delete objects
   std::map<FeaturePtr, std::set<FeaturePtr> > aReferences;
   std::set<FeaturePtr> aFeatures;
@@ -1798,7 +1900,7 @@ void XGUI_Workshop::deleteObjects()
   bool aDone = false;
   QString aDescription = contextMenuMgr()->action("DELETE_CMD")->text() + " %1";
   aDescription = aDescription.arg(XGUI_Tools::unionOfObjectNames(anObjects, ", "));
-  ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction(aDescription, module());
+  ModuleBase_Operation* anOpAction = new ModuleBase_Operation(aDescription, module());
 
   operationMgr()->startOperation(anOpAction);
 
@@ -1824,11 +1926,25 @@ void XGUI_Workshop::deleteObjects()
       }
     }
   }
+  // remove results selected
+  std::list<ResultPtr> aResults;
+  for(QObjectPtrList::const_iterator anIt = anObjects.begin(); anIt != anObjects.end(); anIt++) {
+    ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(*anIt);
+    if (aRes.get() && aRes->data()->isValid() && !aRes->data()->isDeleted() &&
+        aRes->groupName() != ModelAPI_ResultGroup::group() && // don't remove groups and fields
+        aRes->groupName() != ModelAPI_ResultField::group()) // because they are badly selected
+      aResults.push_back(aRes);
+  }
+  if (!aResults.empty()) {
+    ModelAPI_Tools::removeResults(aResults);
+  }
 
   if (aDone)
     operationMgr()->commitOperation();
   else
     operationMgr()->abortOperation(operationMgr()->currentOperation());
+
+  myDisplayer->updateViewer();
 }
 
 //**************************************************************
@@ -1878,11 +1994,11 @@ void XGUI_Workshop::cleanHistory()
   ModelAPI_Tools::findAllReferences(aFeatures, aReferences, true, false);
   // find for each object whether all reference values are in the map as key, that means that there
   // is no other reference in the model to this object, so it might be removed by cleaning history
-  // sk_1(ext_1, vertex_1) + (sk_3, bool_1) - cann't be deleted, dependency to bool_1
-  // ext_1(bool_1, sk_3)  - cann't be deleted, dependency to bool_1
+  // sk_1(ext_1, vertex_1) + (sk_3, bool_1) - can't be deleted, dependency to bool_1
+  // ext_1(bool_1, sk_3)  - can't be deleted, dependency to bool_1
   // vertex_1()
-  // sk_2(ext_2) + (bool_1)  - cann't be deleted, dependency to bool_1
-  // ext_2(bool_1)  - cann't be deleted, dependency to bool_1
+  // sk_2(ext_2) + (bool_1)  - can't be deleted, dependency to bool_1
+  // ext_2(bool_1)  - can't be deleted, dependency to bool_1
   // sk_3()
   // Information: bool_1 is not selected
   std::set<FeaturePtr> anUnusedObjects;
@@ -1922,7 +2038,8 @@ void XGUI_Workshop::cleanHistory()
     QString anUnusedNames = aNames.join(", ");
 
     QString anActionId = "CLEAN_HISTORY_CMD";
-    QString aDescription = contextMenuMgr()->action(anActionId)->text();
+    QString aDescription = ModuleBase_Tools::translate("workshop",
+        contextMenuMgr()->action(anActionId)->text().toStdString());
 
     QMessageBox aMessageBox(desktop());
     aMessageBox.setWindowTitle(aDescription);
@@ -1940,7 +2057,7 @@ void XGUI_Workshop::cleanHistory()
     // 1. start operation
     aDescription += "by deleting of " +
       aDescription.arg(XGUI_Tools::unionOfObjectNames(anObjects, ", "));
-    ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction(aDescription, module());
+    ModuleBase_Operation* anOpAction = new ModuleBase_Operation(aDescription, module());
     operationMgr()->startOperation(anOpAction);
 
     // WORKAROUND, should be done before each object remove, if it presents in XGUI_DataModel tree
@@ -1979,17 +2096,17 @@ void XGUI_Workshop::cleanHistory()
 }
 
 //**************************************************************
-void XGUI_Workshop::moveObjects()
+bool compareFeature(const FeaturePtr& theF1, const FeaturePtr& theF2) {
+  DocumentPtr aDoc = theF1->document();
+  return aDoc->index(theF1) < aDoc->index(theF2);
+}
+void XGUI_Workshop::moveObjects(const bool theSplit)
 {
   if (!abortAllOperations())
     return;
 
   SessionPtr aMgr = ModelAPI_Session::get();
 
-  QString anActionId = "MOVE_CMD";
-  QString aDescription = contextMenuMgr()->action(anActionId)->text();
-  aMgr->startOperation(aDescription.toStdString());
-
   QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
   // It is necessary to clear selection in order to avoid selection changed event during
   // moving and negative consequences connected with processing of already moved items
@@ -2000,18 +2117,28 @@ void XGUI_Workshop::moveObjects()
   if (!XGUI_Tools::canRemoveOrRename(desktop(), aFeatures))
     return;
 
+  QString anActionId = theSplit ? "MOVE_CMD" : "MOVE_SPLIT_CMD";
+  QString aDescription = contextMenuMgr()->action(anActionId)->text();
+  aMgr->startOperation(aDescription.toStdString());
+
+  // Sort features by index in document
+  std::list<FeaturePtr> aFList(aFeatures.begin(), aFeatures.end());
+  aFList.sort(compareFeature);
+
   DocumentPtr anActiveDocument = aMgr->activeDocument();
   FeaturePtr aCurrentFeature = anActiveDocument->currentFeature(true);
-  std::set<FeaturePtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+  std::list<FeaturePtr>::const_iterator anIt = aFList.begin(), aLast = aFList.end();
   for (; anIt != aLast; anIt++) {
     FeaturePtr aFeature = *anIt;
     if (!aFeature.get() || !myModule->canApplyAction(aFeature, anActionId))
       continue;
 
-    anActiveDocument->moveFeature(aFeature, aCurrentFeature);
+    anActiveDocument->moveFeature(aFeature, aCurrentFeature, theSplit);
     aCurrentFeature = anActiveDocument->currentFeature(true);
   }
   aMgr->finishOperation();
+  updateCommandStatus();
+  myViewerProxy->update();
 }
 
 //**************************************************************
@@ -2181,11 +2308,8 @@ bool XGUI_Workshop::canBeShaded(const ObjectPtr& theObject) const
 bool XGUI_Workshop::canChangeProperty(const QString& theActionName) const
 {
   if (theActionName == "COLOR_CMD" ||
-      theActionName == "DEFLECTION_CMD"
-#ifdef USE_TRANSPARENCY
-      || theActionName == "TRANSPARENCY_CMD"
-#endif
-      ) {
+      theActionName == "DEFLECTION_CMD" ||
+      theActionName == "TRANSPARENCY_CMD") {
     QObjectPtrList aObjects = mySelector->selection()->selectedObjects();
 
     std::set<std::string> aTypes;
@@ -2214,9 +2338,28 @@ 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);
+}
+
+//**************************************************************
+void getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
+  std::vector<int>& theColor)
+{
+  theColor.clear();
+  // get default color from the preferences manager for the given result
+  if (theColor.empty()) {
+    std::string aSection, aName, aDefault;
+    theObject->colorConfigInfo(aSection, aName, aDefault);
+    if (!aSection.empty() && !aName.empty()) {
+      theColor = Config_PropManager::color(aSection, aName);
+    }
+  }
+  if (!isEmptyColorValid && theColor.empty()) {
+    // all AIS objects, where the color is not set, are in black.
+    // The color should be defined in XML or set in the attribute
+    theColor = Config_PropManager::color("Visualization", "object_default_color");
+    Events_InfoMessage("XGUI_CustomPrs",
+      "A default color is not defined in the preferences for this kind of result").send();
+  }
 }
 
 //**************************************************************
@@ -2230,7 +2373,9 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
   foreach(ObjectPtr anObject, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
     if (aResult.get()) {
-      XGUI_CustomPrs::getResultColor(aResult, aColor);
+      ModelAPI_Tools::getColor(aResult, aColor);
+      if (aColor.empty())
+        getDefaultColor(aResult, false, aColor);
     }
     else {
       // TODO: remove the obtaining a color from the AIS object
@@ -2282,8 +2427,10 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
       setColor(aResult, !isRandomColor ? aColorResult : aDlg->getRandomColor());
     }
   }
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   aMgr->finishOperation();
   updateCommandStatus();
+  myViewerProxy->update();
 }
 
 //**************************************************************
@@ -2293,11 +2440,9 @@ void setDeflection(ResultPtr theResult, const double theDeflection)
     return;
 
   AttributeDoublePtr aDeflectionAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
-  if (aDeflectionAttr.get() != NULL)
+  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);
+  }
 }
 
 //**************************************************************
@@ -2307,11 +2452,9 @@ void setTransparency(ResultPtr theResult, double theTransparency)
     return;
 
   AttributeDoublePtr anAttribute = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID());
-  if (anAttribute.get() != NULL)
+  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);
+  }
 }
 
 //**************************************************************
@@ -2324,7 +2467,8 @@ void setTransparency(double theTransparency, const QObjectPtrList& theObjects)
       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++) {
+        std::list<ResultPtr>::iterator aRes;
+        for(aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
           setTransparency(*aRes, theTransparency);
         }
       }
@@ -2333,6 +2477,34 @@ void setTransparency(double theTransparency, const QObjectPtrList& theObjects)
   }
 }
 
+//**************************************************************
+double getDefaultDeflection(const ObjectPtr& theObject)
+{
+  double aDeflection = -1;
+  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+  if (aResult.get()) {
+    bool isConstruction = false;
+
+    std::string aResultGroup = aResult->groupName();
+    if (aResultGroup == ModelAPI_ResultConstruction::group())
+      isConstruction = true;
+    else if (aResultGroup == ModelAPI_ResultBody::group()) {
+      GeomShapePtr aGeomShape = aResult->shape();
+      if (aGeomShape.get()) {
+        // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
+        // correction of deviation for them should not influence to the application performance
+        GeomAPI_ShapeExplorer anExp(aGeomShape, GeomAPI_Shape::FACE);
+        isConstruction = !anExp.more();
+      }
+    }
+    if (isConstruction)
+      aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
+    else
+      aDeflection = Config_PropManager::real("Visualization", "body_deflection");
+  }
+  return aDeflection;
+}
+
 //**************************************************************
 void XGUI_Workshop::changeDeflection(const QObjectPtrList& theObjects)
 {
@@ -2343,7 +2515,9 @@ void XGUI_Workshop::changeDeflection(const QObjectPtrList& theObjects)
   foreach(ObjectPtr anObject, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
     if (aResult.get()) {
-      aDeflection = XGUI_CustomPrs::getResultDeflection(aResult);
+      aDeflection = ModelAPI_Tools::getDeflection(aResult);
+      if (aDeflection < 0)
+        aDeflection = getDefaultDeflection(aResult);
     }
     else {
       // TODO: remove the obtaining a property from the AIS object
@@ -2392,10 +2566,17 @@ void XGUI_Workshop::changeDeflection(const QObjectPtrList& theObjects)
       setDeflection(aResult, aDeflection);
     }
   }
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   aMgr->finishOperation();
   updateCommandStatus();
 }
 
+//**************************************************************
+double getDefaultTransparency(const ResultPtr& theResult)
+{
+  return Config_PropManager::integer("Visualization", "shaper_default_transparency") / 100.;
+}
+
 //**************************************************************
 void XGUI_Workshop::changeTransparency(const QObjectPtrList& theObjects)
 {
@@ -2406,17 +2587,9 @@ void XGUI_Workshop::changeTransparency(const QObjectPtrList& theObjects)
   foreach(ObjectPtr anObject, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
     if (aResult.get()) {
-      aCurrentValue = XGUI_CustomPrs::getResultTransparency(aResult);
-    }
-    else {
-      // TODO: remove the obtaining a property from the AIS object
-      // this does not happen never because:
-      // 1. The property can be changed only on results
-      // 2. The result can be not visualized in the viewer(e.g. Origin Construction)
-      AISObjectPtr anAISObj = myDisplayer->getAISObject(anObject);
-      if (anAISObj.get()) {
-        aCurrentValue = anAISObj->getDeflection();
-      }
+      aCurrentValue = ModelAPI_Tools::getTransparency(aResult);
+      if (aCurrentValue < 0)
+        aCurrentValue = getDefaultTransparency(aResult);
     }
     if (aCurrentValue > 0)
       break;
@@ -2425,16 +2598,14 @@ void XGUI_Workshop::changeTransparency(const QObjectPtrList& theObjects)
     return;
 
   if (!abortAllOperations())
-  return;
+    return;
 
   // 2. show the dialog to change the value
   XGUI_PropertyDialog* aDlg = new XGUI_PropertyDialog(desktop());
-  aDlg->setWindowTitle("Transparency");
+  aDlg->setWindowTitle(tr("Transparency"));
   XGUI_TransparencyWidget* aTransparencyWidget = new XGUI_TransparencyWidget(aDlg);
   connect(aTransparencyWidget, SIGNAL(transparencyValueChanged()),
           this, SLOT(onTransparencyValueChanged()));
-  connect(aTransparencyWidget, SIGNAL(previewStateChanged()),
-          this, SLOT(onPreviewStateChanged()));
   aDlg->setContent(aTransparencyWidget);
   aTransparencyWidget->setValue(aCurrentValue);
 
@@ -2443,16 +2614,16 @@ void XGUI_Workshop::changeTransparency(const QObjectPtrList& theObjects)
   QString aDescription = contextMenuMgr()->action("TRANSPARENCY_CMD")->text();
   aMgr->startOperation(aDescription.toStdString());
 
-  aDlg->move(QCursor::pos());
-  bool isDone = aDlg->exec() == QDialog::Accepted;
-  if (!isDone)
-    return;
-
-  // 4. set the value to all results
-  aCurrentValue = aTransparencyWidget->getValue();
-  setTransparency(aCurrentValue, theObjects);
+  if (aDlg->exec() == QDialog::Accepted) {
+    // 4. set the value to all results
+    aCurrentValue = aTransparencyWidget->getValue();
+    setTransparency(aCurrentValue, theObjects);
+    aMgr->finishOperation();
+  } else {
+    aMgr->abortOperation();
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  }
 
-  aMgr->finishOperation();
   updateCommandStatus();
 }
 
@@ -2460,31 +2631,18 @@ void XGUI_Workshop::changeTransparency(const QObjectPtrList& theObjects)
 void XGUI_Workshop::onTransparencyValueChanged()
 {
   XGUI_TransparencyWidget* aTransparencyWidget = (XGUI_TransparencyWidget*)sender();
-  if (!aTransparencyWidget || !aTransparencyWidget->isPreviewNeeded())
+  if (!aTransparencyWidget)
     return;
 
   QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
   setTransparency(aTransparencyWidget->getValue(), anObjects);
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
-}
-
-//**************************************************************
-void XGUI_Workshop::onPreviewStateChanged()
-{
-  XGUI_TransparencyWidget* aTransparencyWidget = (XGUI_TransparencyWidget*)sender();
-  if (!aTransparencyWidget || !aTransparencyWidget->isPreviewNeeded())
-    return;
+  static const Events_ID kRedisplayEvent =
+    Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+  Events_Loop::loop()->flush(kRedisplayEvent);
 
-  QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
-  setTransparency(aTransparencyWidget->getValue(), anObjects);
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  myViewerProxy->update();
 }
 
-//**************************************************************
-#define SET_DISPLAY_GROUP(aGroupName, aDisplay) \
-for (int i = 0; i < aDoc->size(aGroupName); i++) { \
-  aDoc->object(aGroupName, i)->setDisplayed(aDisplay); \
-}
 
 //******************************************************
 void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)
@@ -2503,6 +2661,9 @@ void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)
   }
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   myObjectBrowser->updateAllIndexes();
+
+  updateColorScaleVisibility();
+  displayer()->updateViewer();
 }
 
 //**************************************************************
@@ -2542,6 +2703,79 @@ void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList)
 
   // Necessary for update icons in ObjectBrowser on Linux
   myObjectBrowser->updateAllIndexes();
+  updateColorScaleVisibility();
+  displayer()->updateViewer();
+}
+
+
+//**************************************************************
+void XGUI_Workshop::updateColorScaleVisibility()
+{
+  QObjectPtrList aObjects = mySelector->selection()->selectedObjects();
+  viewer()->setColorScaleShown(false);
+  if (aObjects.size() == 1) {
+    FieldStepPtr aStep =
+      std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(aObjects.first());
+    if (aStep.get() && myDisplayer->isVisible(aStep)) {
+      AISObjectPtr aAisPtr = myDisplayer->getAISObject(aStep);
+      Handle(AIS_InteractiveObject) aIO = aAisPtr->impl<Handle(AIS_InteractiveObject)>();
+      ModuleBase_IStepPrs* aPrs = dynamic_cast<ModuleBase_IStepPrs*>(aIO.get());
+      if (aPrs) {
+        ModelAPI_AttributeTables::ValueType aType = aPrs->dataType();
+        if ((aType == ModelAPI_AttributeTables::DOUBLE) ||
+          (aType == ModelAPI_AttributeTables::INTEGER) ||
+          (aType == ModelAPI_AttributeTables::BOOLEAN)) {
+          myViewerProxy->setupColorScale();
+          if (aType == ModelAPI_AttributeTables::BOOLEAN) {
+            myViewerProxy->setColorScaleIntervals(2);
+            myViewerProxy->setColorScaleRange(0., 1.);
+          }
+          else {
+            double aMin, aMax;
+            aPrs->dataRange(aMin, aMax);
+            myViewerProxy->setColorScaleRange(aMin, aMax);
+          }
+          myViewerProxy->setColorScaleTitle(aStep->name().c_str());
+          myViewerProxy->setColorScaleShown(true);
+        }
+      }
+    }
+  }
+}
+
+
+//**************************************************************
+void XGUI_Workshop::setNormalView(bool toInvert)
+{
+  QList<ModuleBase_ViewerPrsPtr> aPrsList =
+    mySelector->selection()->getSelected(ModuleBase_ISelection::Viewer);
+  GeomShapePtr aPlanarFace;
+  foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) {
+    GeomShapePtr aShape = aPrs->shape();
+    if (aShape.get() && aShape->isPlanar()) {
+      aPlanarFace = aShape;
+      break;
+    }
+  }
+  if (aPlanarFace.get()) {
+    GeomFacePtr aFace(new GeomAPI_Face(aPlanarFace));
+    GeomPlanePtr aPlane = aFace->getPlane();
+    GeomDirPtr aNormal = aPlane->direction();
+    if (toInvert)
+      aNormal->reverse();
+    GeomPointPtr aPos = aPlane->location();
+
+    double aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+    aFace->computeSize(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+
+    Handle(V3d_View) aView = myViewerProxy->activeView();
+    double aScale = aView->Scale();
+    aView->SetAt(aPos->x(), aPos->y(), aPos->z());
+    aView->SetProj(aNormal->x(), aNormal->y(), aNormal->z());
+    Bnd_Box aBox;
+    aBox.Update(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+    aView->FitAll(aBox);
+  }
 }
 
 //**************************************************************
@@ -2678,34 +2912,66 @@ void XGUI_Workshop::synchronizeViewer()
   aDocs.append(aMgr->moduleDocument());
 
   foreach(DocumentPtr aDoc, aDocs) {
-    synchronizeGroupInViewer(aDoc, ModelAPI_ResultConstruction::group(), false);
-    synchronizeGroupInViewer(aDoc, ModelAPI_ResultBody::group(), false);
-    synchronizeGroupInViewer(aDoc, ModelAPI_ResultPart::group(), false);
-    synchronizeGroupInViewer(aDoc, ModelAPI_ResultGroup::group(), false);
+    synchronizeGroupInViewer(aDoc, false);
   }
 }
 
 //******************************************************
 void XGUI_Workshop::synchronizeGroupInViewer(const DocumentPtr& theDoc,
-                                             const std::string& theGroup,
                                              bool theUpdateViewer)
 {
-  ObjectPtr aObj;
-  int aSize = theDoc->size(theGroup);
+  FeaturePtr aFeature;
+  ResultPtr aRes;
+  int aSize = theDoc->numInternalFeatures();
   for (int i = 0; i < aSize; i++) {
-    aObj = theDoc->object(theGroup, i);
-    if (aObj->isDisplayed()) {
-      // Hide the presentation with an empty shape. But isDisplayed state of the object should not
-      // be changed to the object becomes visible when the shape becomes not empty
-      ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
-      if (aRes.get() && (!aRes->shape().get() || aRes->shape()->isNull()))
-        continue;
-      myDisplayer->display(aObj, false);
+    aFeature = theDoc->internalFeature(i);
+    if (!aFeature.get())
+      continue;
+    const std::list<ResultPtr>& aResults = aFeature->results();
+    std::list<ResultPtr>::const_iterator aIt;
+    aFeature->setDisplayed(false);
+    for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
+      aRes = (*aIt);
+      if (aRes->isDisplayed() && !aRes->isConcealed()) {
+        // Hide the presentation with an empty shape. But isDisplayed state of the object should not
+        // be changed to the object becomes visible when the shape becomes not empty
+        if (!aRes->shape().get() || aRes->shape()->isNull())
+          continue;
+        ResultBodyPtr aResBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aRes);
+        if (aResBody.get())
+          synchronizeResultTree(aResBody, false);
+        else {
+          if (aRes->isInHistory()) {
+            if (aRes->isDisplayed())
+              myDisplayer->display(aRes, false);
+            else
+              myDisplayer->erase(aRes, false);
+          }
+          else
+            aRes->setDisplayed(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 {
+    if (theRes->isDisplayed())
+      myDisplayer->display(theRes, theUpdateViewer);
+    else
+      myDisplayer->erase(theRes, theUpdateViewer);
+  }
+}
 #endif
 
 //******************************************************
@@ -2876,4 +3142,24 @@ void XGUI_Workshop::clearTemporaryDir()
       aDir.remove(aFile);
     }
   }
-}
\ No newline at end of file
+}
+
+
+void XGUI_Workshop::onDockSizeChanged()
+{
+  QDockWidget* aDockWgt = dynamic_cast<QDockWidget*>(myObjectBrowser->parentWidget());
+  int aObWidth = aDockWgt->size().width();
+  if (myPropertyPanel->width() != aObWidth) {
+    QList<QDockWidget*> aWgtList;
+    aWgtList << myPropertyPanel << aDockWgt;
+    QList<int> aSizeList;
+    aSizeList << aObWidth << aObWidth;
+    desktop()->resizeDocks(aWgtList, aSizeList, Qt::Horizontal);
+    disconnect(myObjectBrowser, SIGNAL(sizeChanged()), this, SLOT(onDockSizeChanged()));
+  }
+}
+
+void XGUI_Workshop::deactivateCurrentSelector()
+{
+  myActiveControlMgr->deactivateSelector(myActiveControlMgr->activeSelector());
+}