Salome HOME
Merge branch 'Dev_GroupsRevision'
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index bff02679288cdb7013a859d500930f6b0ebeedb9..e55494d77bb45f26be0bba2d24ba54841c36a34f 100755 (executable)
@@ -527,6 +527,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) {
+      myOperationMgr->commitOperation();
+      module()->launchOperation(aFOperation->id(), false);
+    }
+  }
+}
+
 //******************************************************
 void XGUI_Workshop::onPreviewActionClicked()
 {
@@ -595,13 +610,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
@@ -686,12 +703,6 @@ void XGUI_Workshop::connectToPropertyPanel(const bool isToConnect)
   }
 }
 
-//******************************************************
-void XGUI_Workshop::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters)
-{
-  module()->selectionFilters(theSelectionFilters);
-}
-
 //******************************************************
 void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation)
 {
@@ -1056,7 +1067,10 @@ void XGUI_Workshop::processUndoRedo(const ModuleBase_ActionType theActionType, i
     if (aOpMgr->canStopOperation(aOpMgr->currentOperation()))
       aOpMgr->abortOperation(aOpMgr->currentOperation());
     else
+    {
+      myDisplayer->enableUpdateViewer(isUpdateEnabled);
       return;
+    }
   }
   objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
   std::list<std::string> anActionList = theActionType == ActionUndo ? aMgr->undoList()
@@ -1076,10 +1090,8 @@ void XGUI_Workshop::processUndoRedo(const ModuleBase_ActionType theActionType, i
   updateCommandStatus();
 
   // unblock the viewer update functionality and make update on purpose
-  if (theActionType == ActionRedo) {
-    myDisplayer->enableUpdateViewer(isUpdateEnabled);
-    myDisplayer->updateViewer();
-  }
+  myDisplayer->enableUpdateViewer(isUpdateEnabled);
+  myDisplayer->updateViewer();
 }
 
 //******************************************************
@@ -1363,6 +1375,9 @@ 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()));
 
@@ -1601,6 +1616,9 @@ void XGUI_Workshop::activateObjectsSelection(const QObjectPtrList& 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();
@@ -1631,14 +1649,14 @@ bool XGUI_Workshop::prepareForDisplay(const std::set<ObjectPtr>& theObjects) con
     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)
@@ -2630,9 +2648,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();
 }
 
 
@@ -2650,9 +2672,14 @@ 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();
+
+  aMgr->startOperation(aDescription.toStdString());
   aDoc->moveToFolder(aFeatures, aFolder);
   aMgr->finishOperation();
+
+  updateCommandStatus();
 }
 
 void XGUI_Workshop::moveOutFolder(bool isBefore)
@@ -2664,7 +2691,13 @@ 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();
+
+  aMgr->startOperation(aDescription.toStdString());
   aDoc->removeFromFolder(aFeatures, isBefore);
   aMgr->finishOperation();
+
+  updateCommandStatus();
 }