Salome HOME
Lock/unlock the "Apply" button by mouse enter/leave the viewer view port.
authornds <natalia.donis@opencascade.com>
Tue, 26 May 2015 13:58:34 +0000 (16:58 +0300)
committernds <natalia.donis@opencascade.com>
Tue, 26 May 2015 13:58:34 +0000 (16:58 +0300)
Scenarios: 1. issue #487, 2. start translate operation in the sketch. Select the 1st, the end point. The "Apply" was not valid.

src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h

index 1bdd8dc03d25fc4782730dbb6b024a4c632d92ca..add40ce6abeff8281fb092c603022aa4005db2c9 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "PartSet_WidgetPoint2d.h"
 #include <PartSet_Tools.h>
+#include <PartSet_Module.h>
 
 #include <XGUI_Workshop.h>
 #include <XGUI_ViewerProxy.h>
@@ -213,12 +214,17 @@ void PartSet_WidgetPoint2D::activateCustom()
           this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
   connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
           this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
-  connect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort()));
+  connect(aViewer, SIGNAL(enterViewPort()), this, SLOT(onLockValidating()));
+  connect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onUnlockValidating()));
 
   QIntList aModes;
   aModes << TopAbs_VERTEX;
   aModes << TopAbs_EDGE;
   myWorkshop->moduleConnector()->activateSubShapesSelection(aModes);
+
+  PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+  if (aModule->isMouseOverWindow())
+    onLockValidating();
 }
 
 void PartSet_WidgetPoint2D::deactivate()
@@ -228,10 +234,11 @@ void PartSet_WidgetPoint2D::deactivate()
              this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
   disconnect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
              this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
-  disconnect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort()));
+  disconnect(aViewer, SIGNAL(enterViewPort()), this, SLOT(onLockValidating()));
+  disconnect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onUnlockValidating()));
 
   myWorkshop->moduleConnector()->deactivateSubShapesSelection();
-  myWorkshop->operationMgr()->setLockValidating(false);
+  onUnlockValidating();
 }
 
 bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView, 
@@ -340,11 +347,6 @@ void PartSet_WidgetPoint2D::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEv
 {
   if (isEditingMode())
     return;
-  myWorkshop->operationMgr()->setLockValidating(true);
-  // the Ok button should be disabled in the property panel by moving the mouse point in the viewer
-  // this leads that the user does not try to click Ok and it avoids an incorrect situation that the 
-  // line is moved to the cursor to the Ok button
-  myWorkshop->operationMgr()->setApplyEnabled(false);
 
   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
 
@@ -353,7 +355,17 @@ void PartSet_WidgetPoint2D::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEv
   setPoint(aX, anY);
 }
 
-void PartSet_WidgetPoint2D::onLeaveViewPort()
+void PartSet_WidgetPoint2D::onLockValidating()
+{
+  XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
+  anOperationMgr->setLockValidating(true);
+  // the Ok button should be disabled in the property panel by moving the mouse point in the viewer
+  // this leads that the user does not try to click Ok and it avoids an incorrect situation that the 
+  // line is moved to the cursor to the Ok button
+  anOperationMgr->setApplyEnabled(false);
+}
+
+void PartSet_WidgetPoint2D::onUnlockValidating()
 {
   // it is important to restore the validity state in the property panel after leaving the
   // view port. Unlock the validating.
index 07e33c759c3c003a75e3468d34b590b0c35d49e1..dc47f2d7a7d78d46b9cbab0bf7bbdc4a36356cd4 100644 (file)
@@ -106,8 +106,11 @@ protected slots:
   /// \param theEvent a mouse event
   void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
 
-  /// Process mouse leave view port to update validity state of the property panel
-  void onLeaveViewPort();
+  // Set lock validating in the operation manager. Set apply is disabled
+  void onLockValidating();
+
+  // Set unlock validating in the operation manager. Call method to update the apply state.
+  void onUnlockValidating();
 
 protected:
   /// Saves the internal parameters to the given feature