From: nds Date: Mon, 16 Feb 2015 08:28:08 +0000 (+0300) Subject: Issue #394 Undo-ing a Sketch element X-Git-Tag: V_1.1.0~184 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=af96b4b15732f18170c2967eed5bb717cde6f0da;p=modules%2Fshaper.git Issue #394 Undo-ing a Sketch element The reset should not lead to emitting valueChanged() signal. --- diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 5788a92c3..51609754f 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -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); +} diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index de3ab120d..c709280e1 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -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