The spin box value set without emitting a signal about valueChanged is necessary for some controls. So, it is moved to ModuleBase_Tools.
#include <QLayout>
#include <QPainter>
#include <QBitmap>
+#include <QDoubleSpinBox>
namespace ModuleBase_Tools {
return QPixmap::fromImage(aResult);
}
+void setSpinValue(QDoubleSpinBox* theSpin, double theValue)
+{
+ bool isBlocked = theSpin->blockSignals(true);
+ theSpin->setValue(theValue);
+ theSpin->blockSignals(isBlocked);
+}
+
}
class QWidget;
class QLayout;
+class QDoubleSpinBox;
namespace ModuleBase_Tools {
//! \param theLighterValue a lighter factor
//! \return resulting pixmap
MODULEBASE_EXPORT QPixmap lighter(const QString& theIcon, const int theLighterValue = 200);
+
+/// 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
+MODULEBASE_EXPORT void setSpinValue(QDoubleSpinBox* theSpin, double theValue);
+
}
#endif
bool isOk;
double aDefValue = QString::fromStdString(myDefaultValue).toDouble(&isOk);
- mySpinBox->setValue(isOk ? aDefValue : 0.0);
+ ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0);
}
bool ModuleBase_WidgetDoubleValue::storeValue() const
DataPtr aData = myFeature->data();
AttributeDoublePtr aRef = aData->real(attributeID());
- bool isBlocked = mySpinBox->blockSignals(true);
- mySpinBox->setValue(aRef->value());
- mySpinBox->blockSignals(isBlocked);
+ ModuleBase_Tools::setSpinValue(mySpinBox, aRef->value());
return true;
}
aValue = editedValue(aValue, isDone);
if (isDone) {
- bool isBlocked = mySpinBox->blockSignals(true);
- mySpinBox->setValue(aValue);
- mySpinBox->blockSignals(isBlocked);
+ ModuleBase_Tools::setSpinValue(mySpinBox, aValue);
}
emit valuesChanged();
emit focusOutWidget(this);
double aDefValue = QString::fromStdString(myDefaultValue).toDouble(&isOk);
// 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);
+ ModuleBase_Tools::setSpinValue(myXSpin, isOk ? aDefValue : 0.0);
+ ModuleBase_Tools::setSpinValue(myYSpin, isOk ? aDefValue : 0.0);
}
PartSet_WidgetPoint2D::~PartSet_WidgetPoint2D()
if (fabs(theY) >= MaxCoordinate)
return false;
- setSpinValue(myXSpin, theX);
- setSpinValue(myYSpin, theY);
+ ModuleBase_Tools::setSpinValue(myXSpin, theX);
+ ModuleBase_Tools::setSpinValue(myYSpin, theY);
storeValue();
return true;
double _Y = aPoint->y();
#endif
- setSpinValue(myXSpin, aPoint->x());
- setSpinValue(myYSpin, aPoint->y());
+ ModuleBase_Tools::setSpinValue(myXSpin, aPoint->x());
+ ModuleBase_Tools::setSpinValue(myYSpin, aPoint->y());
return true;
}
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);
-}
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
#include <ModuleBase_DoubleSpinBox.h>
#include <ModuleBase_IViewWindow.h>
+#include <ModuleBase_Tools.h>
#include <XGUI_ViewerProxy.h>
#include <XGUI_Workshop.h>
{
bool isOk;
double aDefValue = QString::fromStdString(myDefaultValue).toDouble(&isOk);
- mySpinBox->setValue(isOk ? aDefValue : 0.0);
+
+ ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0);
}
void PartSet_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature,
AttributeDoublePtr aReal = aData->real(attributeID());
if (aReal && (aReal->value() != aRadius)) {
aReal->setValue(aRadius);
- mySpinBox->blockSignals(true);
- mySpinBox->setValue(aRadius);
- mySpinBox->blockSignals(false);
+
+ ModuleBase_Tools::setSpinValue(mySpinBox, aRadius);
storeValue();
}
}