X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_WidgetPoint2dDistance.cpp;h=e8d24eb51421f612c0b514c7d61b8263a460a667;hb=3400f9977cb5bbc2c00d5d797b572acd083d1675;hp=9fdbc3f2773d6962fb5f509a73b7421f7efbbc8a;hpb=60bbd6f564271cbd47808e7acc3c9b725499d45a;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp index 9fdbc3f27..e8d24eb51 100644 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp +++ b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: PartSet_WidgetPoint2dDistance.h // Created: 23 June 2014 // Author: Vitaly Smetannikov @@ -5,11 +7,14 @@ #include "PartSet_WidgetPoint2dDistance.h" #include "PartSet_Tools.h" -#include +#include #include +#include #include #include +#include +#include #include #include @@ -26,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) @@ -65,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*)), @@ -85,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; @@ -101,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; @@ -110,4 +118,9 @@ void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, setPoint(feature(), aPnt); } +void PartSet_WidgetPoint2dDistance::onValuesChanged() +{ + myWorkshop->operationMgr()->setLockValidating(false); + emit valuesChanged(); +}