]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Apply disable state correction in distance/angle controls.
authornds <natalia.donis@opencascade.com>
Fri, 26 Jun 2015 07:36:17 +0000 (10:36 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 26 Jun 2015 07:36:17 +0000 (10:36 +0300)
12 files changed:
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_LockApplyMgr.cpp [new file with mode: 0755]
src/PartSet/PartSet_LockApplyMgr.h [new file with mode: 0755]
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h
src/PartSet/PartSet_WidgetPoint2dAngle.cpp
src/PartSet/PartSet_WidgetPoint2dAngle.h
src/PartSet/PartSet_WidgetPoint2dDistance.cpp
src/PartSet/PartSet_WidgetPoint2dDistance.h
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h

index 8148df0a0eaedb6393f17694850f2fb6d5cd7e73..f86ae4385bcf5d87f71b883d17a3b4e58d7b37ae 100644 (file)
@@ -20,6 +20,7 @@ SET(PROJECT_HEADERS
        PartSet_WidgetShapeSelector.h
        PartSet_WidgetFileSelector.h
        PartSet_Filters.h
+       PartSet_LockApplyMgr.h
        PartSet_FilterInfinite.h
        PartSet_SketcherMgr.h
        PartSet_MenuMgr.h
@@ -43,6 +44,7 @@ SET(PROJECT_SOURCES
        PartSet_WidgetShapeSelector.cpp
        PartSet_WidgetFileSelector.cpp
        PartSet_Filters.cpp
+       PartSet_LockApplyMgr.cpp
        PartSet_FilterInfinite.cpp
        PartSet_SketcherMgr.cpp
        PartSet_MenuMgr.cpp
diff --git a/src/PartSet/PartSet_LockApplyMgr.cpp b/src/PartSet/PartSet_LockApplyMgr.cpp
new file mode 100755 (executable)
index 0000000..547d730
--- /dev/null
@@ -0,0 +1,78 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_LockApplyMgr.cpp
+// Created:     25 Jun 2015
+// Author:      Natalia Ermolaeva
+
+#include "PartSet_LockApplyMgr.h"
+#include "PartSet_Module.h"
+
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_IViewer.h>
+
+#include <XGUI_Workshop.h>
+#include <XGUI_ViewerProxy.h>
+#include <XGUI_ModuleConnector.h>
+#include <XGUI_OperationMgr.h>
+
+PartSet_LockApplyMgr::PartSet_LockApplyMgr(QObject* theParent,
+                                           ModuleBase_IWorkshop* theWorkshop)
+: QObject(theParent), myWorkshop(theWorkshop)
+{
+}
+
+void PartSet_LockApplyMgr::activate()
+{
+  XGUI_ViewerProxy* aViewer = dynamic_cast<XGUI_ViewerProxy*>(myWorkshop->viewer());
+  connect(aViewer, SIGNAL(enterViewPort()), this, SLOT(onLockValidating()));
+  connect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onUnlockValidating()));
+
+  PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+  if (aModule->isMouseOverWindow())
+    onLockValidating();
+}
+
+void PartSet_LockApplyMgr::deactivate()
+{
+  XGUI_ViewerProxy* aViewer = dynamic_cast<XGUI_ViewerProxy*>(myWorkshop->viewer());
+  disconnect(aViewer, SIGNAL(enterViewPort()), this, SLOT(onLockValidating()));
+  disconnect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onUnlockValidating()));
+
+  onUnlockValidating();
+}
+
+void PartSet_LockApplyMgr::valuesChanged()
+{
+  operationMgr()->setLockValidating(false);
+}
+
+void PartSet_LockApplyMgr::onLockValidating()
+{
+  XGUI_OperationMgr* anOperationMgr = 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_LockApplyMgr::onUnlockValidating()
+{
+  XGUI_OperationMgr* anOperationMgr = operationMgr();
+
+  // it is important to restore the validity state in the property panel after leaving the
+  // view port. Unlock the validating.
+  if (anOperationMgr->isValidationLocked()) {
+    anOperationMgr->setLockValidating(false);
+    //anOperationMgr->onValidateOperation();
+  }
+}
+
+XGUI_OperationMgr* PartSet_LockApplyMgr::operationMgr() const
+{
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
+  XGUI_Workshop* aWorkshop = aConnector->workshop();
+
+  return aWorkshop->operationMgr();
+}
diff --git a/src/PartSet/PartSet_LockApplyMgr.h b/src/PartSet/PartSet_LockApplyMgr.h
new file mode 100755 (executable)
index 0000000..bf6fed7
--- /dev/null
@@ -0,0 +1,52 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_LockApplyMgr.h
+// Created:     25 Jun 2015
+// Author:      Natalia Ermolaeva
+
+#ifndef PartSet_LockApplyMgr_H
+#define PartSet_LockApplyMgr_H
+
+#include "PartSet.h"
+
+#include <QObject>
+
+class ModuleBase_IWorkshop;
+class XGUI_OperationMgr;
+
+/**
+* \ingroup Modules
+* Customosation of ModuleBase_WidgetShapeSelector in order to provide 
+* working with sketch specific objects.
+*/
+class PARTSET_EXPORT PartSet_LockApplyMgr : public QObject
+{
+  Q_OBJECT
+
+public:
+  /// Constructor
+  /// \param theExternal the external state
+  /// \param theDefaultValue the default value for the external object using
+  PartSet_LockApplyMgr(QObject* theParent,
+                       ModuleBase_IWorkshop* theWorkshop);
+
+  virtual ~PartSet_LockApplyMgr() {}
+
+  void activate();
+  void deactivate();
+  void valuesChanged();
+
+protected slots:
+  // 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();
+
+private:
+  XGUI_OperationMgr* operationMgr() const;
+
+private:
+  ModuleBase_IWorkshop* myWorkshop; // the current application workshop
+};
+
+#endif
\ No newline at end of file
index 096c090f2abad0fdee58fff70411d557c1f0332b..d90aec2401f4e814371e32eb79d66b7b99c152d0 100644 (file)
@@ -477,48 +477,49 @@ void PartSet_Module::onVertexSelected()
 ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
                                             Config_WidgetAPI* theWidgetApi, std::string theParentId)
 {
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
+  ModuleBase_IWorkshop* aWorkshop = workshop();
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+  XGUI_Workshop* aXUIWorkshop = aConnector->workshop();
   ModuleBase_ModelWidget* aWgt = NULL;
   if (theType == "sketch-start-label") {
     PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, 
       theWidgetApi, theParentId, mySketchMgr->isConstraintsShown());
-    aLabelWgt->setWorkshop(aWorkshop);
+    aLabelWgt->setWorkshop(aXUIWorkshop);
     connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
       mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
     connect(aLabelWgt, SIGNAL(showConstraintToggled(bool)),
       mySketchMgr, SLOT(onShowConstraintsToggle(bool)));
     aWgt = aLabelWgt;
   } else if (theType == "sketch-2dpoint_selector") {
-    PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
-    aPointWgt->setWorkshop(aWorkshop);
+    PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, aWorkshop,
+                                                                 theWidgetApi, theParentId);
     aPointWgt->setSketch(mySketchMgr->activeSketch());
     connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
     aWgt = aPointWgt;
   } else if (theType == "point2ddistance") {
-    PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
-    aDistanceWgt->setWorkshop(aWorkshop);
+    PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent,
+                                                        aWorkshop, theWidgetApi, theParentId);
     aDistanceWgt->setSketch(mySketchMgr->activeSketch());
     aWgt = aDistanceWgt;
   } else if(theType == "point2dangle") {
-    PartSet_WidgetPoint2dAngle* anAngleWgt = new PartSet_WidgetPoint2dAngle(theParent, theWidgetApi, theParentId);
-    anAngleWgt->setWorkshop(aWorkshop);
+    PartSet_WidgetPoint2dAngle* anAngleWgt = new PartSet_WidgetPoint2dAngle(theParent,
+                                                           aWorkshop, theWidgetApi, theParentId);
     anAngleWgt->setSketch(mySketchMgr->activeSketch());
     aWgt = anAngleWgt;
   } else if (theType == "sketch_shape_selector") {
     PartSet_WidgetShapeSelector* aShapeSelectorWgt =
-      new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
+      new PartSet_WidgetShapeSelector(theParent, aWorkshop, theWidgetApi, theParentId);
     aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
     aWgt = aShapeSelectorWgt;
   } else if (theType == "sketch_multi_selector") {
     PartSet_WidgetMultiSelector* aShapeSelectorWgt =
-      new PartSet_WidgetMultiSelector(theParent, workshop(), theWidgetApi, theParentId);
+      new PartSet_WidgetMultiSelector(theParent, aWorkshop, theWidgetApi, theParentId);
     aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
     aWgt = aShapeSelectorWgt;
   } else if (theType == WDG_DOUBLEVALUE_EDITOR) {
-    aWgt = new PartSet_WidgetEditor(theParent, workshop(), theWidgetApi, theParentId);
+    aWgt = new PartSet_WidgetEditor(theParent, aWorkshop, theWidgetApi, theParentId);
   } else if (theType == "export_file_selector") {
-    aWgt = new PartSet_WidgetFileSelector(theParent, workshop(), theWidgetApi, theParentId);
+    aWgt = new PartSet_WidgetFileSelector(theParent, aWorkshop, theWidgetApi, theParentId);
   } else if (theType == "sketch_launcher") {
     aWgt = new PartSet_WidgetSketchCreator(theParent, this, theWidgetApi, theParentId);
   }
index 964303fcd659a215d0e6008f80a48c2742233ad0..6ad84d8fe9a4f05a9ab33081734100daa65fd76c 100644 (file)
@@ -7,17 +7,13 @@
 #include "PartSet_WidgetPoint2d.h"
 #include <PartSet_Tools.h>
 #include <PartSet_Module.h>
-
-#include <XGUI_Workshop.h>
-#include <XGUI_ViewerProxy.h>
-#include <XGUI_ModuleConnector.h>
-#include <XGUI_SelectionMgr.h>
-#include <XGUI_Selection.h>
-#include <XGUI_OperationMgr.h>
+#include <PartSet_LockApplyMgr.h>
 
 #include <ModuleBase_ParamSpinBox.h>
 #include <ModuleBase_Tools.h>
+#include <ModuleBase_IViewer.h>
 #include <ModuleBase_IViewWindow.h>
+#include <ModuleBase_ISelection.h>
 
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
@@ -52,10 +48,13 @@ const double MaxCoordinate = 1e12;
 
 
 PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, 
-                                              const Config_WidgetAPI* theData,
-                                              const std::string& theParentId)
-    : ModuleBase_ModelWidget(theParent, theData, theParentId)
+                                             ModuleBase_IWorkshop* theWorkshop,
+                                             const Config_WidgetAPI* theData,
+                                             const std::string& theParentId)
+ : ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop)
 {
+  myLockApplyMgr = new PartSet_LockApplyMgr(theParent, myWorkshop);
+
   // the control should accept the focus, so the boolen flag is corrected to be true
   myIsObligatory = true;
   //myOptionParam = theData->getProperty(PREVIOUS_FEATURE_PARAM);
@@ -211,36 +210,31 @@ QList<QWidget*> PartSet_WidgetPoint2D::getControls() const
 
 void PartSet_WidgetPoint2D::activateCustom()
 {
-  XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
+  ModuleBase_IViewer* aViewer = myWorkshop->viewer();
   connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), 
           this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
   connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
           this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
-  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);
+  myWorkshop->activateSubShapesSelection(aModes);
 
-  PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
-  if (aModule->isMouseOverWindow())
-    onLockValidating();
+  myLockApplyMgr->activate();
 }
 
 void PartSet_WidgetPoint2D::deactivate()
 {
   ModuleBase_IViewer* aViewer = myWorkshop->viewer();
-  disconnect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), 
+  disconnect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
              this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
   disconnect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
              this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
-  disconnect(aViewer, SIGNAL(enterViewPort()), this, SLOT(onLockValidating()));
-  disconnect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onUnlockValidating()));
 
-  myWorkshop->moduleConnector()->deactivateSubShapesSelection();
-  onUnlockValidating();
+  myWorkshop->deactivateSubShapesSelection();
+
+  myLockApplyMgr->deactivate();
 }
 
 bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView, 
@@ -268,7 +262,7 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
   if (theEvent->button() != Qt::LeftButton)
     return;
 
-  XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+  ModuleBase_ISelection* aSelection = myWorkshop->selection();
   Handle(V3d_View) aView = theWnd->v3dView();
   // TODO: This fragment doesn't work because bug in OCC Viewer. It can be used after fixing.
   NCollection_List<TopoDS_Shape> aShapes;
@@ -357,27 +351,6 @@ void PartSet_WidgetPoint2D::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEv
   setPoint(aX, anY);
 }
 
-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.
-  XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
-  if (anOperationMgr->isValidationLocked()) {
-    anOperationMgr->setLockValidating(false);
-    anOperationMgr->onValidateOperation();
-  }
-}
-
 double PartSet_WidgetPoint2D::x() const
 {
   return myXSpin->value();
@@ -390,6 +363,6 @@ double PartSet_WidgetPoint2D::y() const
 
 void PartSet_WidgetPoint2D::onValuesChanged()
 {
-  myWorkshop->operationMgr()->setLockValidating(false);
+  myLockApplyMgr->valuesChanged();
   emit valuesChanged();
 }
index 21f9738b4de9dcd59f87e7d4c576e01ebc475bb5..473eccfedeb530a8eea14423a204fccd9e84fdc6 100644 (file)
@@ -21,7 +21,8 @@ class ModuleBase_IWorkshop;
 class ModuleBase_ParamSpinBox;
 class ModuleBase_IViewWindow;
 class GeomAPI_Pnt2d;
-class XGUI_Workshop;
+class ModuleBase_IWorkshop;
+class PartSet_LockApplyMgr;
 
 class QGroupBox;
 class QMouseEvent;
@@ -40,9 +41,11 @@ Q_OBJECT
  public:
   /// Constructor
   /// \param theParent the parent object
+  /// \param theWorkshop a current workshop
   /// \param theData the widget configuation. The attribute of the model widget is obtained from
   /// \param theParentId is Id of a parent of the current attribute
-  PartSet_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData, 
+  PartSet_WidgetPoint2D(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+                        const Config_WidgetAPI* theData, 
                         const std::string& theParentId);
   /// Destructor
   virtual ~PartSet_WidgetPoint2D();
@@ -66,12 +69,6 @@ Q_OBJECT
   /// The methiod called when widget is deactivated
   virtual void deactivate();
 
-  /// Return workshop
-  XGUI_Workshop* workshop() const { return myWorkshop; }
-
-  /// Set workshop
-  void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
-
   /// \returns the sketch instance
   CompositeFeaturePtr sketch() const { return mySketch; }
 
@@ -106,12 +103,6 @@ protected slots:
   /// \param theEvent a mouse event
   void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
 
-  // 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
   /// \return True in success
@@ -133,7 +124,8 @@ private slots:
    bool getPoint2d(const Handle(V3d_View)& theView, const TopoDS_Shape& theShape, 
                    double& theX, double& theY) const;
 
-  XGUI_Workshop* myWorkshop;
+  ModuleBase_IWorkshop* myWorkshop;
+  PartSet_LockApplyMgr* myLockApplyMgr; ///< a manager to lock/unlock Apply button in PP
 
   QGroupBox* myGroupBox;  ///< the parent group box for all intenal widgets
   ModuleBase_ParamSpinBox* myXSpin;  ///< the spin box for the X coordinate
index b014d34b480412d4f175dcc6eaad9f38de41ffc0..06e9b43863095109be50f598475d035374b5baf4 100644 (file)
 #define PI 3.1415926535897932
 
 PartSet_WidgetPoint2dAngle::PartSet_WidgetPoint2dAngle(QWidget* theParent,
+                                                       ModuleBase_IWorkshop* theWorkshop,
                                                        const Config_WidgetAPI* theData,
                                                        const std::string& theParentId)
-: PartSet_WidgetPoint2dDistance(theParent, theData, theParentId)
+: PartSet_WidgetPoint2dDistance(theParent, theWorkshop, theData, theParentId)
 {
 }
 
index 6dac991b2fbd7e1a0d3eaeb0b26e4a6bcb3fe9cb..93e4fdd780b70413293426c3d63a339ccd66b381 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <ModelAPI_Feature.h>
 
+class ModuleBase_IWorkshop;
+
 class GeomAPI_Pnt2d;
 
 /**
@@ -25,10 +27,11 @@ Q_OBJECT
  public:
   /// Constructor
   /// \param theParent the parent object
+  /// \param theWorkshop a current workshop
   /// \param theData the widget configuation. The attribute of the model widget is obtained from
   /// \param theParentId is Id of a parent of the current attribute
-  PartSet_WidgetPoint2dAngle(QWidget* theParent, const Config_WidgetAPI* theData,
-                             const std::string& theParentId);
+  PartSet_WidgetPoint2dAngle(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+                             const Config_WidgetAPI* theData, const std::string& theParentId);
 
   virtual ~PartSet_WidgetPoint2dAngle();
 
index f4c5bc6d16cd7980d27be2f4a0d32ee5523358f9..3dfefe34962ae3378ab53ef8ed4d66ecc06c70ed 100644 (file)
@@ -6,16 +6,14 @@
 
 #include "PartSet_WidgetPoint2dDistance.h"
 #include "PartSet_Tools.h"
+#include "PartSet_LockApplyMgr.h"
 
 #include <ModuleBase_ParamSpinBox.h>
+#include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_IViewWindow.h>
+#include <ModuleBase_IViewer.h>
 #include <ModuleBase_Tools.h>
 
-#include <XGUI_ViewerProxy.h>
-#include <XGUI_Workshop.h>
-#include <XGUI_PropertyPanel.h>
-#include <XGUI_OperationMgr.h>
-
 #include <GeomAPI_Pnt2d.h>
 #include <Config_WidgetAPI.h>
 #include <GeomDataAPI_Point2D.h>
 #include <QMouseEvent>
 
 PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent,
-                                                                   const Config_WidgetAPI* theData,
-                                                                   const std::string& theParentId)
-    : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId)
+                                                             ModuleBase_IWorkshop* theWorkshop,
+                                                             const Config_WidgetAPI* theData,
+                                                             const std::string& theParentId)
+ : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId), myWorkshop(theWorkshop)
 {
+  myLockApplyMgr = new PartSet_LockApplyMgr(theParent, myWorkshop);
+
   myFirstPntName = theData->getProperty("first_point");
 
   // Reconnect to local slot
@@ -78,11 +79,13 @@ double PartSet_WidgetPoint2dDistance::computeValue(const std::shared_ptr<GeomAPI
 
 void PartSet_WidgetPoint2dDistance::activateCustom()
 {
-  XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
-  connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), 
+  ModuleBase_IViewer* aViewer = myWorkshop->viewer();
+  connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
           this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
   connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
           this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
+
+  myLockApplyMgr->activate();
 }
 
 void PartSet_WidgetPoint2dDistance::deactivate()
@@ -92,7 +95,8 @@ void PartSet_WidgetPoint2dDistance::deactivate()
              this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
   disconnect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
              this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
-  myWorkshop->operationMgr()->setLockValidating(false);
+
+  myLockApplyMgr->deactivate();
 }
 
 void PartSet_WidgetPoint2dDistance::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
@@ -122,9 +126,6 @@ void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd,
   if (mySpinBox->hasVariable())
     return;
 
-  myWorkshop->operationMgr()->setLockValidating(true);
-  myWorkshop->operationMgr()->setApplyEnabled(false);
-
   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
 
   double aX, aY;
@@ -136,7 +137,7 @@ void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd,
 
 void PartSet_WidgetPoint2dDistance::onValuesChanged()
 {
-  myWorkshop->operationMgr()->setLockValidating(false);
+  myLockApplyMgr->valuesChanged();
   emit valuesChanged();
 }
 
index c3020e3a97c5208ba601087d7dedc893b6928d7d..5db72e573fbfcff1f6f1b8d6c6332698b912a3a8 100644 (file)
@@ -12,8 +12,9 @@
 
 #include <ModelAPI_CompositeFeature.h>
 
+class PartSet_LockApplyMgr;
 class GeomAPI_Pnt2d;
-class XGUI_Workshop;
+class ModuleBase_IWorkshop;
 class ModuleBase_IViewWindow;
 class QMouseEvent;
 
@@ -40,10 +41,12 @@ Q_OBJECT
  public:
   /// Constructor
   /// \param theParent the parent object
+  /// \param theWorkshop a current workshop
   /// \param theData the widget configuation. The attribute of the model widget is obtained from
   /// \param theParentId is Id of a parent of the current attribute
-  PartSet_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData,
-                                   const std::string& theParentId);
+   PartSet_WidgetPoint2dDistance(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+                                 const Config_WidgetAPI* theData,
+                                 const std::string& theParentId);
 
   virtual ~PartSet_WidgetPoint2dDistance();
 
@@ -53,13 +56,6 @@ Q_OBJECT
   /// The methiod called when widget is deactivated
   virtual void deactivate();
 
-  /// Returns workshop
-  XGUI_Workshop* workshop() const { return myWorkshop; }
-
-  /// Set workshop
-  /// \param theWork a pointer to workshop
-  void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
-
   /// \returns the sketch instance
   CompositeFeaturePtr sketch() const { return mySketch; }
 
@@ -97,9 +93,10 @@ private slots:
   void onValuesChanged();
 
 protected:
-  XGUI_Workshop* myWorkshop;
-  std::string myFirstPntName;
+  ModuleBase_IWorkshop* myWorkshop;
+  PartSet_LockApplyMgr* myLockApplyMgr; ///< a manager to lock/unlock Apply button in PP
 
+  std::string myFirstPntName;
   CompositeFeaturePtr mySketch;
 };
 
index 5256eb7db48f75f414d198b75c883c046b2c1483..65e76b68c56ef4d34b81ee117928c447d25e25f3 100644 (file)
@@ -152,11 +152,17 @@ void XGUI_OperationMgr::onValidateOperation()
   if (!hasOperation())
     return;
   ModuleBase_Operation* anOperation = currentOperation();
-  if(anOperation && (!myIsValidationLock)) {
-    setApplyEnabled(anOperation->isValid());
+  if(anOperation) {
+    setApplyEnabled(!myIsValidationLock && anOperation->isValid());
   }
 }
 
+void XGUI_OperationMgr::setLockValidating(bool toLock)
+{
+  myIsValidationLock = toLock;
+  onValidateOperation();
+}
+
 void XGUI_OperationMgr::setApplyEnabled(const bool theEnabled)
 {
   myIsApplyEnabled = theEnabled;
index bf132446a38dfcebe9bf86d1dc7aa944f67465bd..812c61c3dd2a1b83be4b31f46ee4c79df8a01b50 100644 (file)
@@ -81,15 +81,11 @@ Q_OBJECT
 
   /// Blocking/unblocking enabling of Ok button in property panel.
   /// It is used when operation can not be validated even all attributes are valid
-  void setLockValidating(bool toLock) { myIsValidationLock = toLock; }
+  void setLockValidating(bool toLock);
 
   /// Returns state of validation locking
   bool isValidationLocked() const { return myIsValidationLock; }
 
-  /// Sets apply state to the value and emit signal about this state is changed
-  /// \param theEnabled the state value
-  void setApplyEnabled(const bool theEnabled);
-
   /// Returns enable apply state 
   /// \return theEnabled a boolean value
   bool isApplyEnabled() const;
@@ -136,6 +132,10 @@ signals:
   void keyEnterReleased();
 
  protected:
+  /// Sets apply state to the value and emit signal about this state is changed
+  /// \param theEnabled the state value
+  void setApplyEnabled(const bool theEnabled);
+
   /// Commits the current operatin if it is valid
   bool commitOperation();