]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2129 Crash when clicking on Length after multiple selections
authornds <nds@opencascade.com>
Tue, 11 Apr 2017 16:29:46 +0000 (19:29 +0300)
committernds <nds@opencascade.com>
Tue, 11 Apr 2017 16:29:46 +0000 (19:29 +0300)
src/PartSet/PartSet_WidgetPoint2DFlyout.cpp
src/PartSet/PartSet_WidgetPoint2DFlyout.h
src/PartSet/PartSet_WidgetPoint2d.cpp

index 3563e950edfc90d1dddfc2182e2b556e2598ae4f..9041727f379e86d046b6fd52daff30268987dd0d 100755 (executable)
@@ -7,6 +7,7 @@
 #include "PartSet_WidgetPoint2DFlyout.h"
 
 #include "ModuleBase_WidgetValidator.h"
+#include "ModuleBase_ViewerPrs.h"
 
 #include <XGUI_Workshop.h>
 #include <XGUI_ModuleConnector.h>
@@ -26,6 +27,15 @@ PartSet_WidgetPoint2DFlyout::PartSet_WidgetPoint2DFlyout(QWidget* theParent,
   myWidgetValidator = new ModuleBase_WidgetValidator(this, myWorkshop);
 }
 
+bool PartSet_WidgetPoint2DFlyout::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
+                                               const bool theToValidate)
+{
+  PartSet_WidgetPoint2D::setSelection(theValues, theToValidate);
+  // true value should be returned to set this control as processed the selection
+  // to move focus to the next control if it is filled by preselection
+  return true;
+}
+
 bool PartSet_WidgetPoint2DFlyout::isValidSelectionCustom(
                                       const std::shared_ptr<ModuleBase_ViewerPrs>& theValue)
 {
index 8b1a87cb7ea7f2cd540de22812be8faf1dcb608c..4a67d00d65bbc39611587e424752215190a838dc 100755 (executable)
@@ -30,6 +30,13 @@ public:
   /// Destructor
   virtual ~PartSet_WidgetPoint2DFlyout() {};
 
+  /// Set the given wrapped value to the current widget
+  /// This value should be processed in the widget according to the needs
+  /// \param theValues the wrapped widget values
+  /// \param theToValidate a validation flag
+  virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
+                            const bool theToValidate);
+
   /// Checks if the selection presentation is valid in widget
   /// \param theValue a selected presentation in the view
   /// \return a boolean value
index 150b5909561c2e915fd3a752ed72217948aa7086..c81d84b967c594edec5c681a2a1963c599f600d6 100644 (file)
@@ -281,14 +281,17 @@ bool PartSet_WidgetPoint2D::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValu
     return isDone;
 
   ModuleBase_ViewerPrsPtr aValue = theValues.takeFirst();
-  GeomShapePtr aShape = aValue->shape();
-  if (aShape.get() && !aShape->isNull()) {
-    Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
-    double aX, aY;
-    const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
-    if (getPoint2d(aView, aTDShape, aX, aY)) {
-      isDone = setPoint(aX, aY);
-      setConstraintToPoint(aX, aY);
+
+  if (!theToValidate || myWidgetValidator->isValidSelection(aValue)) {
+    GeomShapePtr aShape = aValue->shape();
+    if (aShape.get() && !aShape->isNull()) {
+      Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
+      double aX, aY;
+      const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+      if (getPoint2d(aView, aTDShape, aX, aY)) {
+        isDone = setPoint(aX, aY);
+        setConstraintToPoint(aX, aY);
+      }
     }
   }
   return isDone;