Salome HOME
Unpressing the button of the current action must behave like a validation if the...
authornds <nds@opencascade.com>
Wed, 22 Jun 2016 06:16:02 +0000 (09:16 +0300)
committernds <nds@opencascade.com>
Wed, 22 Jun 2016 08:19:45 +0000 (11:19 +0300)
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IWorkshop.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/ModuleBase/ModuleBase_OperationFeature.cpp
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ModuleConnector.h
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h

index 9442ddc27d871e05eafc0c7cfedff0ec33793e3e..942d9ec6584ef3a288b08f1746d3ee1238a7cd8f 100644 (file)
@@ -201,7 +201,7 @@ void ModuleBase_IModule::onFeatureTriggered()
   if (aCmd->isCheckable() && !aCmd->isChecked()) {
     ModuleBase_Operation* anOperation = myWorkshop->findStartedOperation(aCmd->data().toString());
     if (myWorkshop->canStopOperation(anOperation))
-      myWorkshop->abortOperation(anOperation);
+      myWorkshop->stopOperation(anOperation);
     else {
       aCmd->setChecked(true);
     }
index ec8d04906ea780fab13d6a487f92f3cff3784e9a..c7ff4ceee902bdab60b9bebb48c8fd9e9edb0658 100644 (file)
@@ -86,9 +86,9 @@ Q_OBJECT
   //! \return boolean result
   virtual bool canStopOperation(ModuleBase_Operation* theOperation) = 0;
 
-  //! Aborts the operation.
+  //! Commits if possible or aborts the given operation.
   //! \param theOperation an aborted operation
-  virtual void abortOperation(ModuleBase_Operation* theOperation) = 0;
+  virtual void stopOperation(ModuleBase_Operation* theOperation) = 0;
 
   //! Returns AIS object by data object
   //! \param theObject a data object
index 8b19dcd8270b9c0a57a0f5f1826ba605c911b774..af08c48fd0d23ab1fe601447a8c084a49e278dd5 100644 (file)
@@ -142,6 +142,17 @@ void ModuleBase_Operation::onValuesChanged()
   myIsModified = true;
 }
 
+void ModuleBase_Operation::onValueStateChanged(int thePreviousState)
+{
+  if (propertyPanel()) {
+    ModuleBase_ModelWidget* aWidget = propertyPanel()->activeWidget();
+    if (aWidget) {
+      if (aWidget->getValueState() == ModuleBase_ModelWidget::ModifiedInPP)
+        myIsModified = true;
+    }
+  }
+}
+
 void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp) 
 { 
   myPropertyPanel = theProp; 
index 0fffbc0fdae9bea6f8bfd4fbf3e9678e2b79f2f1..2e04b5b07f8f5fc1f5cb49ebd792b31418951a0d 100644 (file)
@@ -148,6 +148,10 @@ signals:
   /// Changes the modified flag of the operation
   void onValuesChanged();
 
+  /// Changes the modified flag of the operation if the current state of the widget is modified
+  /// \param thePreviousState the previous vlaue state of the widget
+  void onValueStateChanged(int thePreviousState);
+
  protected:
   /// Virtual method called when operation started (see start() method for more description)
   /// Default impl calls corresponding slot and commits immediately.
index 6066fa00aad09503d83ac9e08e6a51ab03402075..9745c5fe0c72d6d103027f1d9dc7aaa7f63b501c 100755 (executable)
@@ -497,6 +497,7 @@ void ModuleBase_OperationFeature::setPropertyPanel(ModuleBase_IPropertyPanel* th
     for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) {
       ModuleBase_ModelWidget* aWgt = (*aWIt);
       connect(aWgt, SIGNAL(valuesChanged()), this, SLOT(onValuesChanged()));
+      connect(aWgt, SIGNAL(valueStateChanged(int)), this, SLOT(onValueStateChanged(int)));
     }
   }
 
index d3eb60aa144bfcca3d313c82f3b293e5c475a8b7..1892f8b0a5ef1511c84e7199c05740cb9ccdbc8b 100755 (executable)
@@ -796,7 +796,9 @@ bool PartSet_Module::deleteObjects()
 
 void PartSet_Module::onFeatureTriggered()
 {
-  QAction* aCmd = dynamic_cast<QAction*>(sender());
+  // is commented for imp: Unpressing the button of the current action must behave like
+  // a validation if the entity can be created (instead of Cancel, as currently)
+  /*QAction* aCmd = dynamic_cast<QAction*>(sender());
   if (aCmd->isCheckable() && aCmd->isChecked()) {
     // 1. check whether the delete should be processed in the module
     ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
@@ -811,7 +813,7 @@ void PartSet_Module::onFeatureTriggered()
         launchOperation(aCmd->data().toString());
       }
     }
-  }
+  }*/
   ModuleBase_IModule::onFeatureTriggered();
 }
 
index 5fbeebf5e2f980add4cd55df549753374dd69521..a01004ceb41005c4510a3e6e377d91de86a5a3dc 100644 (file)
@@ -139,9 +139,9 @@ bool XGUI_ModuleConnector::canStopOperation(ModuleBase_Operation* theOperation)
   return myWorkshop->operationMgr()->canStopOperation(theOperation);
 }
 
-void XGUI_ModuleConnector::abortOperation(ModuleBase_Operation* theOperation)
+void XGUI_ModuleConnector::stopOperation(ModuleBase_Operation* theOperation)
 {
-  myWorkshop->operationMgr()->abortOperation(theOperation);
+  myWorkshop->operationMgr()->stopOperation(theOperation);
 }
 
 void XGUI_ModuleConnector::updateCommandStatus()
index 0afbe49ac09544e65716e0f9dfb52b1f45599629..89f5625dd7746ba3ed4fa6d4a03f46be28ff6c74 100644 (file)
@@ -67,9 +67,9 @@ Q_OBJECT
   //! \return boolean result
   virtual bool canStopOperation(ModuleBase_Operation* theOperation);
 
-  //! Aborts the operation. The operation manager is called.
+  //! Commits if possible or aborts the given operation.
   //! \param theOperation an aborted operation
-  void abortOperation(ModuleBase_Operation* theOperation);
+  virtual void stopOperation(ModuleBase_Operation* theOperation);
 
   //! Returns AIS object by data object
   virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
index b41264d77b160e08096eb11793e6e8ba74ed6d24..d975519a338c303e0dd4808f12c21f44de39a9c8 100644 (file)
@@ -368,10 +368,7 @@ bool XGUI_OperationMgr::canStartOperation(const QString& theId)
       else if (canStopOperation(aCurrentOp)) {
         // the started operation is granted in the parrent operation,
         // e.g. current - Line in Sketch, started Circle 
-        if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled() && aCurrentOp->isModified())
-          aCurrentOp->commit();
-        else
-          abortOperation(aCurrentOp);
+        stopOperation(aCurrentOp);
       } else {
         aCanStart = false;
       }
@@ -380,6 +377,14 @@ bool XGUI_OperationMgr::canStartOperation(const QString& theId)
   return aCanStart;
 }
 
+void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation)
+{
+  if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled() && theOperation->isModified())
+    theOperation->commit();
+  else
+    abortOperation(theOperation);
+}
+
 void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation)
 {
   ModuleBase_Operation* aCurrentOperation = currentOperation();
index 2b3e31069c3fe3dabdca995463b0421cfd57fb32..41d678c599678afa5c04ec0cff62395cd5539b6d 100755 (executable)
@@ -103,6 +103,10 @@ Q_OBJECT
   /// \param theId id of the operation which is going to start
   bool canStartOperation(const QString& theId);
 
+  /// If Apply is enabled and operation has modification, it is applyed, otherwise aborted
+  /// \param theOperation the started operation
+  void stopOperation(ModuleBase_Operation* theOperation);
+
   /// Aborts the parameter operation if it is current, else abort operations from the stack
   /// of operations until the operation is found. All operations upper the parameter one are
   /// not aborted.