#include <cfloat>
#include <climits>
+const double MaxCoordinate = 1e12;
+
+
PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
const Config_WidgetAPI* theData,
const std::string& theParentId)
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);
this->blockSignals(isBlocked);
emit valuesChanged();
+ return true;
}
bool PartSet_WidgetPoint2D::storeValue() const
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<GeomDataAPI_Point2D> aFeaturePoint = std::dynamic_pointer_cast<
GeomDataAPI_Point2D>(feature()->data()->attribute(attributeID()));
/// 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;