]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #61: Limit input of points coordinates by 1e12 value
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 29 Jan 2015 12:46:47 +0000 (15:46 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 29 Jan 2015 12:46:47 +0000 (15:46 +0300)
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h

index 1e061643c10d3e882968a739c3c0219ce2c2fe73..a8cd1a82388860ffaeb3fdc8d764e7d56962e6b7 100644 (file)
@@ -44,6 +44,9 @@
 #include <cfloat>
 #include <climits>
 
+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<GeomDataAPI_Point2D> aFeaturePoint = std::dynamic_pointer_cast<
       GeomDataAPI_Point2D>(feature()->data()->attribute(attributeID()));
index b5ee13c47e8d8dc442a6689ece693830eabb7a9f..bb50069630e8762d60db4194227312859188548f 100644 (file)
@@ -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;