]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
1. Accept All to be enabled when 1st sketch feature is reentrant(feature in the model...
authornds <nds@opencascade.com>
Fri, 24 Jun 2016 06:41:36 +0000 (09:41 +0300)
committernds <nds@opencascade.com>
Fri, 24 Jun 2016 06:41:36 +0000 (09:41 +0300)
2. Selection should be cleared only if the operation is stopped but it is not a reentrant operation because on restart the previous selected object is used as a preselection for the new created object.

src/ModuleBase/ModuleBase_IModule.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.h
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_ErrorMgr.cpp

index 78f48a39f876b3e77a85a58466e00a1ffd2a7c99..ad8132e4ac212d4367dc8fdab50f80e94df4f7ea 100755 (executable)
@@ -266,6 +266,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// \param theStdActions - a map of standard actions\r
   virtual void updateViewerMenu(const QMap<QString, QAction*>& theStdActions) {}\r
 \r
+  /// Returns true if the action should be always enabled\r
+  /// \param theActionId an action index: Accept or Accept All\r
+  /// \return boolean value\r
+  virtual bool isActionEnableStateFixed(const int theActionId) const { return false; }\r
+\r
   //! Returns the feature error if the current state of the feature in the module is not correct\r
   //! If the feature is correct, it returns an empty value\r
   //! \return string value\r
index 1b182cdf3cdab963c489ae0cdd7501f3f3ec09c0..5b858673cbed399d24e3f3808355b5945fca8769 100755 (executable)
@@ -70,6 +70,7 @@
 #include <XGUI_ErrorMgr.h>
 #include <XGUI_CustomPrs.h>
 #include <XGUI_SelectionMgr.h>
+#include <XGUI_ActionsMgr.h>
 
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_Sketch.h>
@@ -503,6 +504,15 @@ void PartSet_Module::updateViewerMenu(const QMap<QString, QAction*>& theStdActio
   myMenuMgr->updateViewerMenu(theStdActions);
 }
 
+bool PartSet_Module::isActionEnableStateFixed(const int theActionId) const
+{
+  bool isEnabledFixed = false;
+  if (theActionId == XGUI_ActionsMgr::AcceptAll &&
+      mySketchReentrantMgr->isInternalEditStarted())
+    isEnabledFixed = true;
+  return isEnabledFixed;
+}
+
 QString PartSet_Module::getFeatureError(const FeaturePtr& theFeature)
 {
   QString anError = ModuleBase_IModule::getFeatureError(theFeature);
index c71187fcbf48a810b079f1610f08da11392c152c..ada0628974d81061bca4c319eb9be891dee7620f 100755 (executable)
@@ -277,6 +277,11 @@ public:
   /// \param theStdActions - a map of standard actions
   virtual void updateViewerMenu(const QMap<QString, QAction*>& theStdActions); 
 
+  /// Returns true if the action should be always enabled
+  /// \param theActionId an action index: Accept or Accept All
+  /// \return boolean value
+  virtual bool isActionEnableStateFixed(const int theActionId) const;
+
   //! Returns the feature error if the current state of the feature in the module is not correct
   //! If the feature is correct, it returns an empty value
   //! \return string value
index b95786c36a8bc0f131faa6b752663a545ee25e8e..6059ab187e98bd6eab55ade4ea8a72b98ea9e3f8 100755 (executable)
 #include <ModelAPI_Session.h>
 #include <ModelAPI_AttributeString.h>
 
+#include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
+
 #include <QMouseEvent>
 #include <QApplication>
 #include <QCursor>
 #include <QMessageBox>
+#include <QMainWindow>
 
 //#define DEBUG_DO_NOT_BY_ENTER
 
@@ -870,6 +874,28 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
   }
   myCurrentSketch->setDisplayed(false);
 
+  // Remove invalid sketch entities
+  /*
+  std::set<FeaturePtr> anInvalidFeatures;
+  ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
+  for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
+    FeaturePtr aFeature = myCurrentSketch->subFeature(i);
+    if (aFeature.get()) {
+      if (!aFactory->validate(aFeature))
+        anInvalidFeatures.insert(aFeature);
+    }
+  }
+  std::map<FeaturePtr, std::set<FeaturePtr> > aReferences;
+  ModelAPI_Tools::findAllReferences(anInvalidFeatures, aReferences, false);
+  std::set<FeaturePtr> aFeatureRefsToDelete;
+  if (ModuleBase_Tools::askToDelete(anInvalidFeatures, aReferences, aConnector->desktop(), aFeatureRefsToDelete)) {
+    if (!aFeatureRefsToDelete.empty())
+      anInvalidFeatures.insert(aFeatureRefsToDelete.begin(), aFeatureRefsToDelete.end());
+    bool aDone = ModelAPI_Tools::removeFeatures(anInvalidFeatures, false);
+  }
+  else
+    return;
+  */
   // Display sketcher objects
   for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
     FeaturePtr aFeature = myCurrentSketch->subFeature(i);
@@ -996,7 +1022,9 @@ void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOperation)
   }
   /// improvement to deselect automatically all eventual selected objects, when
   // returning to the neutral point of the Sketcher
-  workshop()->selector()->clearSelection();
+  // if the operation is restarted, the previous selection is used to initialize started operation
+  if (!myModule->sketchReentranceMgr()->isInternalEditStarted())
+    workshop()->selector()->clearSelection();
 }
 
 void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
index eb0432ff4823efbbc0319644d8f8a6cff149bf02..7f92c9646270063521c997db83a4579c6d2a3da7 100755 (executable)
@@ -31,6 +31,7 @@
 #include <XGUI_ModuleConnector.h>
 #include <XGUI_OperationMgr.h>
 #include <XGUI_PropertyPanel.h>
+#include <XGUI_ErrorMgr.h>
 
 #include <QToolButton>
 
@@ -84,6 +85,7 @@ void PartSet_SketcherReetntrantMgr::updateInternalEditActiveState()
         //workshop()->operationMgr()->updateApplyOfOperations();
         beforeStopInternalEdit();
         myIsInternalEditOperation = false;
+        updateAcceptAllAction();
       }
     }
   }
@@ -341,6 +343,11 @@ bool PartSet_SketcherReetntrantMgr::canBeCommittedByPreselection()
   return !isActiveMgr() || myRestartingMode == RM_None;
 }
 
+bool PartSet_SketcherReetntrantMgr::isInternalEditStarted() const
+{
+  return myIsInternalEditOperation;
+}
+
 bool PartSet_SketcherReetntrantMgr::isActiveMgr() const
 {
   ModuleBase_Operation* aCurrentOperation = myWorkshop->currentOperation();
@@ -372,11 +379,11 @@ bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev
 
   if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
     aFOperation->setEditOperation(true/*, false*/);
-    workshop()->operationMgr()->updateApplyOfOperations();
-
     createInternalFeature();
 
     myIsInternalEditOperation = true;
+    updateAcceptAllAction();
+
     isDone = true;
     connect(aFOperation, SIGNAL(beforeCommitted()), this, SLOT(onBeforeStopped()));
     connect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
@@ -537,6 +544,7 @@ void PartSet_SketcherReetntrantMgr::resetFlags()
 {
   if (!myIsFlagsBlocked) {
     myIsInternalEditOperation = false;
+    updateAcceptAllAction();
     myRestartingMode = RM_None;
   }
 }
@@ -578,6 +586,13 @@ bool PartSet_SketcherReetntrantMgr::isTangentArc(ModuleBase_Operation* theOperat
   return aTangentArc;
 }
 
+void PartSet_SketcherReetntrantMgr::updateAcceptAllAction()
+{
+  CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
+  if (aSketch.get())
+    workshop()->errorMgr()->updateAcceptAllAction(aSketch);
+}
+
 XGUI_Workshop* PartSet_SketcherReetntrantMgr::workshop() const
 {
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
index 2c9a8a4312470fcc1d7ed609293aedb65b39b4fb..74e8bd92b49eaa997976531bc291c82bd95e304a 100755 (executable)
@@ -97,6 +97,10 @@ public:
   /// Returns false if the reentrant mode of the operation is not empty.
   bool canBeCommittedByPreselection();
 
+  /// returns true if an internal edit operation is started
+  /// \return boolean value
+  bool isInternalEditStarted() const;
+
 private slots:
   /// SLOT, that is called by a widget activating in the property panel
   /// If the 'internal' edit operation is started, it activates the first widget selection
@@ -152,6 +156,9 @@ private:
 
   static bool isTangentArc(ModuleBase_Operation* theOperation);
 
+  /// Accept All action is enabled if an internal edit is started. It updates the state of the button
+  void updateAcceptAllAction();
+
   /// Returns the workshop
   XGUI_Workshop* workshop() const;
 
index 178fc3f9daa7439bafe21732c0ac2305aba676ac..d7a7d1579bba55d1f7f454576ef4dc040d1d209c 100644 (file)
@@ -132,7 +132,7 @@ void XGUI_ContextMenuMgr::createActions()
   addAction("SELECT_FACE_CMD", aAction);
   //mySelectActions->addAction(aAction);
 
-  aAction = ModuleBase_Tools::createAction(QIcon(":pictures/result.png"), tr("Result"), aDesktop,
+  aAction = ModuleBase_Tools::createAction(QIcon(":pictures/result.png"), tr("Results"), aDesktop,
                                            this, SLOT(onResultSelection(bool)));
   aAction->setCheckable(true);
   addAction("SELECT_RESULT_CMD", aAction);
index b2a1a87f9f9e1b2ab0640196280da0dc5da51d37..317babf1e83fe0d45226e5610da537bd135b3609 100644 (file)
@@ -94,11 +94,16 @@ void XGUI_ErrorMgr::updateAcceptAllAction(const FeaturePtr& theFeature)
   if (myAcceptAllToolTip.isEmpty() && myAcceptToolTip.isEmpty())
     storeInitialActionValues();
 
-  QString anError = myWorkshop->module()->getFeatureError(theFeature);
-  if (anError.isEmpty()) {
-    ModuleBase_ModelWidget* anActiveWidget = activeWidget();
-    if (anActiveWidget)
-      anError = anActiveWidget->getError();
+  QString anError = "";
+  /// to allow the module have the button always enabled
+  bool isActionStateEnabled = myWorkshop->module()->isActionEnableStateFixed(XGUI_ActionsMgr::AcceptAll);
+  if (!isActionStateEnabled) {
+    anError = myWorkshop->module()->getFeatureError(theFeature);
+    if (anError.isEmpty()) {
+      ModuleBase_ModelWidget* anActiveWidget = activeWidget();
+      if (anActiveWidget)
+        anError = anActiveWidget->getError();
+    }
   }
   XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
   if (workshop()->isFeatureOfNested(theFeature)) {