X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_WidgetPoint2dDistance.cpp;h=829380cef043548846458c274782a0df8eecb46f;hb=0d9a107853208317a6352bb7f8c77eb54d5efbe1;hp=e20186a26a43eb68422d222064f729855b826731;hpb=fc1a9c802c59a0e853dc43125362e513b6f6358f;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp index e20186a26..829380cef 100644 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp +++ b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp @@ -1,6 +1,6 @@ // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -// File: PartSet_WidgetPoint2dDistance.h +// File: PartSet_WidgetPoint2dDistance.cpp // Created: 23 June 2014 // Author: Vitaly Smetannikov @@ -8,14 +8,11 @@ #include "PartSet_Tools.h" #include +#include #include +#include #include -#include -#include -#include -#include - #include #include #include @@ -26,31 +23,18 @@ #include PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent, - const Config_WidgetAPI* theData, - const std::string& theParentId) - : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId) + ModuleBase_IWorkshop* theWorkshop, + const Config_WidgetAPI* theData, + const std::string& theParentId) + : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId), myWorkshop(theWorkshop) { 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() { } -// It is not clear a necesity of this method also it contradicts to scenario defined in parent class -//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) { @@ -60,20 +44,26 @@ void PartSet_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, if (!aPoint) return; - double aRadius = thePnt->distance(aPoint->pnt()); + double aValue = computeValue(aPoint->pnt(), thePnt); AttributeDoublePtr aReal = aData->real(attributeID()); - if (aReal && (aReal->value() != aRadius)) { - aReal->setValue(aRadius); + if (aReal && (aReal->value() != aValue)) { + aReal->setValue(aValue); - ModuleBase_Tools::setSpinValue(mySpinBox, aRadius); + ModuleBase_Tools::setSpinValue(mySpinBox, aValue); storeValue(); } } +double PartSet_WidgetPoint2dDistance::computeValue(const std::shared_ptr& theFirstPnt, + const std::shared_ptr& theCurrentPnt) +{ + return theCurrentPnt->distance(theFirstPnt); +} + void PartSet_WidgetPoint2dDistance::activateCustom() { - XGUI_ViewerProxy* aViewer = myWorkshop->viewer(); - connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), + ModuleBase_IViewer* aViewer = myWorkshop->viewer(); + connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*))); connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*))); @@ -81,12 +71,12 @@ void PartSet_WidgetPoint2dDistance::activateCustom() void PartSet_WidgetPoint2dDistance::deactivate() { + ModuleBase_ModelWidget::deactivate(); ModuleBase_IViewer* aViewer = myWorkshop->viewer(); disconnect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), 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) @@ -110,11 +100,11 @@ void PartSet_WidgetPoint2dDistance::onMouseRelease(ModuleBase_IViewWindow* theWn void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { - if (mySpinBox->hasVariable()) + if (isEditingMode()) return; - myWorkshop->operationMgr()->setLockValidating(true); - myWorkshop->operationMgr()->setApplyEnabled(false); + if (mySpinBox->hasVariable()) + return; gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView()); @@ -122,12 +112,20 @@ void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, aY); std::shared_ptr aPnt = std::shared_ptr(new GeomAPI_Pnt2d(aX, aY)); + bool isBlocked = blockValueState(true); setPoint(feature(), aPnt); + blockValueState(isBlocked); + setValueState(ModifiedInViewer); } -void PartSet_WidgetPoint2dDistance::onValuesChanged() +bool PartSet_WidgetPoint2dDistance::processEnter() { - myWorkshop->operationMgr()->setLockValidating(false); - emit valuesChanged(); + //bool isModified = mySpinBox->isModified(); + bool isModified = getValueState() == ModifiedInPP; + if (isModified) { + emit valuesChanged(); + //mySpinBox->clearModified(); + mySpinBox->selectAll(); + } + return isModified; } -