X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_WidgetPoint2dDistance.cpp;h=0e40984766fc5af49890a7b32df41b298958473a;hb=f3f60a3cb69f2534a5837cd249782395e5edb183;hp=2e722d02891ee77815a9855f8c914ad4207178e3;hpb=f1cd93fd02a54259f72e3191d037323a496b2bef;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp index 2e722d028..0e4098476 100644 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp +++ b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp @@ -9,9 +9,12 @@ #include #include +#include #include #include +#include +#include #include #include @@ -28,31 +31,24 @@ PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent, : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId) { myFirstPntName = theData->getProperty("first_point"); + + // Reconnect to local slot + disconnect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged())); + connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged())); } PartSet_WidgetPoint2dDistance::~PartSet_WidgetPoint2dDistance() { } -//bool PartSet_WidgetPoint2dDistance::setValue(ModuleBase_WidgetValue* theValue) -//{ -// bool isDone = false; -// -// if (theValue) { -// ModuleBase_WidgetValueFeature* aFeatureValue = -// dynamic_cast(theValue); -// if (aFeatureValue) { -// std::shared_ptr aPnt = aFeatureValue->point(); -// ObjectPtr aObject = aFeatureValue->object(); -// FeaturePtr aFeature = std::dynamic_pointer_cast(aObject); -// if (aFeature && aPnt) { -// setPoint(aFeature, aPnt); -// isDone = true; -// } -// } -// } -// return isDone; -//} +void PartSet_WidgetPoint2dDistance::reset() +{ + bool isOk; + double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk); + + ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0); + storeValueCustom(); +} void PartSet_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, const std::shared_ptr& thePnt) @@ -67,11 +63,13 @@ void PartSet_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, AttributeDoublePtr aReal = aData->real(attributeID()); if (aReal && (aReal->value() != aRadius)) { aReal->setValue(aRadius); - mySpinBox->setValue(aRadius); + + ModuleBase_Tools::setSpinValue(mySpinBox, aRadius); + storeValue(); } } -void PartSet_WidgetPoint2dDistance::activate() +void PartSet_WidgetPoint2dDistance::activateCustom() { XGUI_ViewerProxy* aViewer = myWorkshop->viewer(); connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), @@ -87,10 +85,15 @@ 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); } void PartSet_WidgetPoint2dDistance::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { + // the contex menu release by the right button should not be processed by this widget + if (theEvent->button() != Qt::LeftButton) + return; + gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView()); double aX, aY; @@ -103,6 +106,9 @@ void PartSet_WidgetPoint2dDistance::onMouseRelease(ModuleBase_IViewWindow* theWn void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { + myWorkshop->operationMgr()->setLockValidating(true); + myWorkshop->operationMgr()->setApplyEnabled(false); + gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView()); double aX, aY; @@ -112,4 +118,9 @@ void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, setPoint(feature(), aPnt); } +void PartSet_WidgetPoint2dDistance::onValuesChanged() +{ + myWorkshop->operationMgr()->setLockValidating(false); + emit valuesChanged(); +}