From: vsv Date: Thu, 29 Jan 2015 12:46:47 +0000 (+0300) Subject: Issue #61: Limit input of points coordinates by 1e12 value X-Git-Tag: V_1.0.0~13^2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=10f0f48c36b418c844bdb845428a2d374cc810ab;p=modules%2Fshaper.git Issue #61: Limit input of points coordinates by 1e12 value --- diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 1e061643c..a8cd1a823 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -44,6 +44,9 @@ #include #include +const double MaxCoordinate = 1e12; + + PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId) @@ -98,15 +101,17 @@ bool PartSet_WidgetPoint2D::setSelection(ModuleBase_ViewerPrs theValue) TopoDS_Shape aShape = theValue.shape(); double aX, aY; if (getPoint2d(aView, aShape, aX, aY)) { - setPoint(aX, aY); - isDone = true; + isDone = setPoint(aX, aY); } return isDone; } -void PartSet_WidgetPoint2D::setPoint(double theX, double theY) +bool PartSet_WidgetPoint2D::setPoint(double theX, double theY) { - + if (fabs(theX) >= MaxCoordinate) + return false; + if (fabs(theY) >= MaxCoordinate) + return false; bool isBlocked = this->blockSignals(true); myXSpin->blockSignals(true); myXSpin->setValue(theX); @@ -118,6 +123,7 @@ void PartSet_WidgetPoint2D::setPoint(double theX, double theY) this->blockSignals(isBlocked); emit valuesChanged(); + return true; } bool PartSet_WidgetPoint2D::storeValue() const @@ -257,7 +263,8 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous double aX, anY; Handle(V3d_View) aView = theWnd->v3dView(); PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, anY); - //setPoint(aX, anY); + if (!setPoint(aX, anY)) + return; std::shared_ptr aFeaturePoint = std::dynamic_pointer_cast< GeomDataAPI_Point2D>(feature()->data()->attribute(attributeID())); diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index b5ee13c47..bb5006963 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -87,7 +87,8 @@ Q_OBJECT /// Fill the widget values by given point /// \param theX the X coordinate /// \param theY the Y coordinate - void setPoint(double theX, double theY); + /// \returns True in case of success + bool setPoint(double theX, double theY); /// Returns coordinate X currently defined in the control double x() const;