]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #394 Undo-ing a Sketch element
authornds <natalia.donis@opencascade.com>
Mon, 16 Feb 2015 08:28:08 +0000 (11:28 +0300)
committernds <natalia.donis@opencascade.com>
Mon, 16 Feb 2015 08:28:08 +0000 (11:28 +0300)
The reset should not lead to emitting valueChanged() signal.

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

index 5788a92c3637d77732e5e0ecef9cbe1138294cb6..51609754f2ec62f00284d96e959859acc2fb5e7a 100644 (file)
@@ -96,9 +96,10 @@ void PartSet_WidgetPoint2D::reset()
 {
   bool isOk;
   double aDefValue = QString::fromStdString(myDefaultValue).toDouble(&isOk);
-
-  myXSpin->setValue(isOk ? aDefValue : 0.0);
-  myYSpin->setValue(isOk ? aDefValue : 0.0);
+  // it is important to block the spin box control in order to do not through out the
+  // locking of the validating state.
+  setSpinValue(myXSpin, isOk ? aDefValue : 0.0);
+  setSpinValue(myYSpin, isOk ? aDefValue : 0.0);
 }
 
 PartSet_WidgetPoint2D::~PartSet_WidgetPoint2D()
@@ -123,15 +124,9 @@ bool PartSet_WidgetPoint2D::setPoint(double theX, double theY)
     return false;
   if (fabs(theY) >= MaxCoordinate)
     return false;
-  bool isBlocked = this->blockSignals(true);
-  myXSpin->blockSignals(true);
-  myXSpin->setValue(theX);
-  myXSpin->blockSignals(false);
 
-  myYSpin->blockSignals(true);
-  myYSpin->setValue(theY);
-  myYSpin->blockSignals(false);
-  this->blockSignals(isBlocked);
+  setSpinValue(myXSpin, theX);
+  setSpinValue(myYSpin, theY);
 
   storeValue();
   return true;
@@ -173,15 +168,9 @@ bool PartSet_WidgetPoint2D::restoreValue()
   double _X = aPoint->x();
   double _Y = aPoint->y();
 #endif
-  bool isBlocked = this->blockSignals(true);
-  myXSpin->blockSignals(true);
-  myXSpin->setValue(aPoint->x());
-  myXSpin->blockSignals(false);
-
-  myYSpin->blockSignals(true);
-  myYSpin->setValue(aPoint->y());
-  myYSpin->blockSignals(false);
-  this->blockSignals(isBlocked);
+
+  setSpinValue(myXSpin, aPoint->x());
+  setSpinValue(myYSpin, aPoint->y());
   return true;
 }
 
@@ -331,3 +320,10 @@ void PartSet_WidgetPoint2D::onValuesChanged()
   myWorkshop->operationMgr()->setLockValidating(false);
   emit valuesChanged();
 }
+
+void PartSet_WidgetPoint2D::setSpinValue(ModuleBase_DoubleSpinBox* theSpin, double theValue)
+{
+  bool isBlocked = theSpin->blockSignals(true);
+  theSpin->setValue(theValue);
+  theSpin->blockSignals(isBlocked);
+}
index de3ab120ddc92db4f75006dd9b28c3e59eefc2d2..c709280e1026a837ba6ae4859174a3017d44b3cc 100644 (file)
@@ -131,6 +131,11 @@ private slots:
    bool getPoint2d(const Handle(V3d_View)& theView, const TopoDS_Shape& theShape, 
                    double& theX, double& theY) const;
 
+   /// Sets programmatically the value to the spin box without emitting any signals(e.g. valueChanged)
+   /// \param theSpin an X or Y coordinate widget
+   /// \param theValue a new value
+   static void setSpinValue(ModuleBase_DoubleSpinBox* theSpin, double theValue);
+
   XGUI_Workshop* myWorkshop;
 
   QGroupBox* myGroupBox;  ///< the parent group box for all intenal widgets