]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/PartSet/PartSet_WidgetPoint2d.cpp
Salome HOME
Merge branch 'Dev_1.5.0' into BR_REENTRANCE_OPERATION
[modules/shaper.git] / src / PartSet / PartSet_WidgetPoint2d.cpp
index cbd3c97340ae571113effbd1827455b1cc9d8c36..020a9be68fcd5e1c1c2ef3c0bc3d5ffc4e068c11 100644 (file)
@@ -7,7 +7,6 @@
 #include "PartSet_WidgetPoint2d.h"
 #include <PartSet_Tools.h>
 #include <PartSet_Module.h>
-#include <PartSet_LockApplyMgr.h>
 
 #include <ModuleBase_ParamSpinBox.h>
 #include <ModuleBase_Tools.h>
@@ -52,8 +51,6 @@ const double MaxCoordinate = 1e12;
 
 static QStringList MyFeaturesForCoincedence;
 
-//#define APPLY_BY_ENTER_OR_TAB
-
 PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, 
                                              ModuleBase_IWorkshop* theWorkshop,
                                              const Config_WidgetAPI* theData,
@@ -66,7 +63,6 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
       << SketchPlugin_Point::ID().c_str()
       << SketchPlugin_Circle::ID().c_str();
   }
-  myLockApplyMgr = new PartSet_LockApplyMgr(theParent, myWorkshop);
 
   // the control should accept the focus, so the boolen flag is corrected to be true
   myIsObligatory = true;
@@ -90,12 +86,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
     myXSpin->setToolTip(tr("X"));
     aGroupLay->addWidget(myXSpin, 0, 1);
 
-#ifdef APPLY_BY_ENTER_OR_TAB
-    // Apply widget value change by enter/tab event.
-    connect(myXSpin, SIGNAL(editingFinished()), this, SLOT(onValuesChanged()));
-#else
-    connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SLOT(onValuesChanged()));
-#endif
+    connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
   }
   {
     QLabel* aLabel = new QLabel(myGroupBox);
@@ -108,12 +99,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
     myYSpin->setToolTip(tr("Y"));
     aGroupLay->addWidget(myYSpin, 1, 1);
 
-#ifdef APPLY_BY_ENTER_OR_TAB
-    // Apply widget value change by enter/tab event.
-    connect(myYSpin, SIGNAL(editingFinished()), this, SLOT(onValuesChanged()));
-#else
-    connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SLOT(onValuesChanged()));
-#endif
+    connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
   }
   QVBoxLayout* aLayout = new QVBoxLayout(this);
   ModuleBase_Tools::zeroMargins(aLayout);
@@ -121,7 +107,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
   setLayout(aLayout);
 }
 
-bool PartSet_WidgetPoint2D::reset()
+bool PartSet_WidgetPoint2D::resetCustom()
 {
   bool aDone = false;
   if (!isUseReset() || isComputedDefault() || myXSpin->hasVariable() || myYSpin->hasVariable()) {
@@ -281,8 +267,6 @@ void PartSet_WidgetPoint2D::activateCustom()
   aModes << TopAbs_VERTEX;
   aModes << TopAbs_EDGE;
   myWorkshop->activateSubShapesSelection(aModes);
-
-  myLockApplyMgr->activate();
 }
 
 bool PartSet_WidgetPoint2D::canBeActivatedByMove()
@@ -297,6 +281,7 @@ bool PartSet_WidgetPoint2D::canBeActivatedByMove()
 
 void PartSet_WidgetPoint2D::deactivate()
 {
+  ModuleBase_ModelWidget::deactivate();
   ModuleBase_IViewer* aViewer = myWorkshop->viewer();
   disconnect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
              this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
@@ -304,8 +289,6 @@ void PartSet_WidgetPoint2D::deactivate()
              this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
 
   myWorkshop->deactivateSubShapesSelection();
-
-  myLockApplyMgr->deactivate();
 }
 
 bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView, 
@@ -460,7 +443,11 @@ void PartSet_WidgetPoint2D::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEv
 
   double aX, anY;
   PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, anY);
+  // we need to block the value state change 
+  bool isBlocked = blockValueState(true);
   setPoint(aX, anY);
+  blockValueState(isBlocked);
+  setValueState(ModifiedInViewer);
 }
 
 double PartSet_WidgetPoint2D::x() const
@@ -497,8 +484,24 @@ bool PartSet_WidgetPoint2D::isFeatureContainsPoint(const FeaturePtr& theFeature,
   return aPointIsFound;
 }
 
-void PartSet_WidgetPoint2D::onValuesChanged()
+/*void PartSet_WidgetPoint2D::onValuesChanged()
 {
-  myLockApplyMgr->valuesChanged();
   emit valuesChanged();
+}*/
+
+bool PartSet_WidgetPoint2D::processEnter()
+{
+  bool isModified = myXSpin->isModified() || myYSpin->isModified();
+  if (isModified) {
+    bool isXModified = myXSpin->isModified();
+    emit valuesChanged();
+    //onValuesChanged();
+    myXSpin->clearModified();
+    myYSpin->clearModified();
+    if (isXModified)
+      myXSpin->selectAll();
+    else
+      myYSpin->selectAll();
+  }
+  return isModified;
 }