From 5e6c61f177b2d7f07fcf94abaf96de4f8366f27b Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 22 Jan 2015 12:02:50 +0300 Subject: [PATCH] Issue #348 Validate sketch is disabled when point coordinates are set manually Do not store value if the default value was not defined in the XML file. It corrects setValue in the Point2D to update attributes even if the value are the same. --- src/GeomData/GeomData_Point2D.cpp | 2 +- src/ModuleBase/ModuleBase_ModelWidget.cpp | 1 + src/ModuleBase/ModuleBase_ModelWidget.h | 6 ++++++ src/PartSet/PartSet_WidgetPoint2d.cpp | 6 ++++++ src/XGUI/XGUI_Workshop.cpp | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/GeomData/GeomData_Point2D.cpp b/src/GeomData/GeomData_Point2D.cpp index 5061f8193..314a0ab79 100644 --- a/src/GeomData/GeomData_Point2D.cpp +++ b/src/GeomData/GeomData_Point2D.cpp @@ -13,7 +13,7 @@ using namespace std; void GeomData_Point2D::setValue(const double theX, const double theY) { - if (myCoords->Value(0) != theX || myCoords->Value(1) != theY) { + if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY) { myCoords->SetValue(0, theX); myCoords->SetValue(1, theY); owner()->data()->sendAttributeUpdated(this); diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 79b00dfe2..6a5421549 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -27,6 +27,7 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, const Config_ : QObject(theParent), myParentId(theParentId) { + myIsValueDefault = !theData->getProperty(ATTR_DEFAULT).empty(); myIsComputedDefault = false; myAttributeID = theData ? theData->widgetId() : ""; } diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 15a0c5b2a..3b0a4c5a4 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -50,6 +50,11 @@ Q_OBJECT /// on operation's execute, like radius for circle's constraint (can not be zero) bool isComputedDefault() { return myIsComputedDefault; } + /// Returns true, if default value of the widget is defined in the XML and it is not the + /// computed value + /// \return the boolean result + bool isValueDefault() { return myIsValueDefault; } + /// Defines if it is supposed that the widget should interact with the viewer. virtual bool isViewerSelector() { return false; } @@ -160,6 +165,7 @@ signals: bool myIsComputedDefault; /// Value should be computed on execute, /// like radius for circle's constraint (can not be zero) + bool myIsValueDefault; /// the default value is defined in the XML for this attribute bool myIsEditing; }; diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 6af2c5094..fe48cb7b6 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -194,6 +194,9 @@ void PartSet_WidgetPoint2D::activate() QIntList aModes; aModes << TopAbs_VERTEX; myWorkshop->moduleConnector()->activateSubShapesSelection(aModes); + // the control value is stored to the mode by the focus in on the widget + // we need the value is initialized in order to enable the apply button in the property panel + storeValue(); } void PartSet_WidgetPoint2D::deactivate() @@ -276,6 +279,9 @@ void PartSet_WidgetPoint2D::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEv if (isEditingMode()) return; myWorkshop->operationMgr()->setLockValidating(true); + // the Ok button should be disabled in the property panel by moving the mouse point in the viewer + // this leads that the user does not try to click Ok and it avoids an incorrect situation that the + // line is moved to the cursor to the Ok button myWorkshop->propertyPanel()->setOkEnabled(false); gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView()); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 87d424125..d14fe7545 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -644,7 +644,7 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation) aWidget->enableFocusProcessing(); QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged())); // Init default values - if (!theOperation->isEditOperation() && !aWidget->isComputedDefault()) { + if (!theOperation->isEditOperation() && aWidget->isValueDefault() && !aWidget->isComputedDefault()) { aWidget->storeValue(); } } -- 2.39.2