Salome HOME
Make same planes cannot be used twice in partition tool
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index 3101617b62aaf1d5ec2d2371b608b8ad5713eb4b..cb56c38795c4e51f8a1c29093dfa6b31a54ee0f2 100755 (executable)
@@ -300,12 +300,12 @@ void XGUI_Workshop::initMenu()
   //connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRebuild()));
   //salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT");
 
-  aAction = salomeConnector()->addDesktopCommand("SAVEAS_CMD", tr("Export NewGeom..."), tr("Export the current document into a NewGeom file"),
+  aAction = salomeConnector()->addDesktopCommand("SAVEAS_CMD", tr("Export native..."), tr("Export the current document into a native file"),
                                               QIcon(), QKeySequence(),
                                               false, "MEN_DESK_FILE");
   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onSaveAs()));
 
-  aAction = salomeConnector()->addDesktopCommand("OPEN_CMD", tr("Import NewGeom..."), tr("Import a NewGeom file"),
+  aAction = salomeConnector()->addDesktopCommand("OPEN_CMD", tr("Import native..."), tr("Import native file"),
                                               QIcon(), QKeySequence(),
                                               false, "MEN_DESK_FILE");
   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onOpen()));
@@ -1128,7 +1128,7 @@ void XGUI_Workshop::hidePropertyPanel()
   // in SALOME mode, workstack 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 NewGeom package
+  // It is possible that this code is to be moved to SHAPER package
   QMainWindow* aDesktop = desktop();
   ModuleBase_Tools::activateWindow(aDesktop, "XGUI_Workshop::hidePropertyPanel()");
   ModuleBase_Tools::setFocus(aDesktop, "XGUI_Workshop::showPropertyPanel()");
@@ -1305,6 +1305,21 @@ void XGUI_Workshop::cleanHistory()
 
     QString aText = QString(tr("Unused features are the following: %1.\nThese features will be deleted.\nWould you like to continue?")
                    .arg(anUnusedNames));
+    /*QString aText;
+    if (anUnusedNames.isEmpty()) {
+      aMessageBox.setStandardButtons(QMessageBox::Ok);
+      aMessageBox.setDefaultButton(QMessageBox::Ok);
+
+      aText = QString(tr("All features are relevant, there is nothing to be deleted"));
+    }
+    else {
+      aMessageBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
+      aMessageBox.setDefaultButton(QMessageBox::No);
+
+      aText = QString(tr("Unused features are the following: %1.\nThese features will be deleted.\nWould you like to continue?")
+        .arg(anUnusedNames));
+    }*/
+
     aMessageBox.setText(aText);
     if (aMessageBox.exec() == QMessageBox::No)
       return;
@@ -1322,6 +1337,26 @@ void XGUI_Workshop::cleanHistory()
       operationMgr()->abortOperation(operationMgr()->currentOperation());
     }
   }
+  else {
+    QString anActionId = "CLEAN_HISTORY_CMD";
+    QString aDescription = contextMenuMgr()->action(anActionId)->text();
+
+    QMessageBox aMessageBox(desktop());
+    aMessageBox.setWindowTitle(aDescription);
+    aMessageBox.setIcon(QMessageBox::Warning);
+    aMessageBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
+    aMessageBox.setDefaultButton(QMessageBox::No);
+
+    QString aText;
+    aMessageBox.setStandardButtons(QMessageBox::Ok);
+    aMessageBox.setDefaultButton(QMessageBox::Ok);
+
+    aText = QString(tr("All features are relevant, there is nothing to be deleted"));
+    aMessageBox.setText(aText);
+
+    if (aMessageBox.exec() == QMessageBox::No)
+      return;
+  }
 }
 
 //**************************************************************
@@ -1401,6 +1436,11 @@ bool XGUI_Workshop::isDeleteFeatureWithReferences(const QObjectPtrList& theList,
   QStringList aPartFeatureNames;
   foreach (ObjectPtr aObj, theList) {
     FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+    // invalid feature data means that the feature is already removed in model,
+    // we needn't process it. E.g. delete of feature from create operation. The operation abort
+    // will delete the operation
+    if (!aFeature->data()->isValid())
+      continue;
     ResultPtr aFirstResult = aFeature->firstResult();
     std::string aResultGroupName = aFirstResult->groupName();
     if (aResultGroupName == ModelAPI_ResultPart::group())
@@ -1938,8 +1978,14 @@ void XGUI_Workshop::synchronizeGroupInViewer(const DocumentPtr& theDoc,
   int aSize = theDoc->size(theGroup);
   for (int i = 0; i < aSize; i++) {
     aObj = theDoc->object(theGroup, i);
-    if (aObj->isDisplayed())
+    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);
+    }
   }
   if (theUpdateViewer)
     myDisplayer->updateViewer();